mutation.go 1.4 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698
  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/whatsapp"
  43. "wechat-api/ent/whatsappchannel"
  44. "wechat-api/ent/workexperience"
  45. "wechat-api/ent/wpchatroom"
  46. "wechat-api/ent/wpchatroommember"
  47. "wechat-api/ent/wx"
  48. "wechat-api/ent/wxcard"
  49. "wechat-api/ent/wxcarduser"
  50. "wechat-api/ent/wxcardvisit"
  51. "entgo.io/ent"
  52. "entgo.io/ent/dialect/sql"
  53. )
  54. const (
  55. // Operation types.
  56. OpCreate = ent.OpCreate
  57. OpDelete = ent.OpDelete
  58. OpDeleteOne = ent.OpDeleteOne
  59. OpUpdate = ent.OpUpdate
  60. OpUpdateOne = ent.OpUpdateOne
  61. // Node types.
  62. TypeAgent = "Agent"
  63. TypeAgentBase = "AgentBase"
  64. TypeAliyunAvatar = "AliyunAvatar"
  65. TypeAllocAgent = "AllocAgent"
  66. TypeBatchMsg = "BatchMsg"
  67. TypeCategory = "Category"
  68. TypeChatRecords = "ChatRecords"
  69. TypeChatSession = "ChatSession"
  70. TypeContact = "Contact"
  71. TypeCreditBalance = "CreditBalance"
  72. TypeCreditUsage = "CreditUsage"
  73. TypeEmployee = "Employee"
  74. TypeEmployeeConfig = "EmployeeConfig"
  75. TypeLabel = "Label"
  76. TypeLabelRelationship = "LabelRelationship"
  77. TypeLabelTagging = "LabelTagging"
  78. TypeMessage = "Message"
  79. TypeMessageRecords = "MessageRecords"
  80. TypeMsg = "Msg"
  81. TypePayRecharge = "PayRecharge"
  82. TypeServer = "Server"
  83. TypeSopNode = "SopNode"
  84. TypeSopStage = "SopStage"
  85. TypeSopTask = "SopTask"
  86. TypeToken = "Token"
  87. TypeTutorial = "Tutorial"
  88. TypeUsageDetail = "UsageDetail"
  89. TypeUsageStatisticDay = "UsageStatisticDay"
  90. TypeUsageStatisticHour = "UsageStatisticHour"
  91. TypeUsageStatisticMonth = "UsageStatisticMonth"
  92. TypeUsageTotal = "UsageTotal"
  93. TypeWhatsapp = "Whatsapp"
  94. TypeWhatsappChannel = "WhatsappChannel"
  95. TypeWorkExperience = "WorkExperience"
  96. TypeWpChatroom = "WpChatroom"
  97. TypeWpChatroomMember = "WpChatroomMember"
  98. TypeWx = "Wx"
  99. TypeWxCard = "WxCard"
  100. TypeWxCardUser = "WxCardUser"
  101. TypeWxCardVisit = "WxCardVisit"
  102. )
  103. // AgentMutation represents an operation that mutates the Agent nodes in the graph.
  104. type AgentMutation struct {
  105. config
  106. op Op
  107. typ string
  108. id *uint64
  109. created_at *time.Time
  110. updated_at *time.Time
  111. deleted_at *time.Time
  112. name *string
  113. role *string
  114. status *int
  115. addstatus *int
  116. background *string
  117. examples *string
  118. organization_id *uint64
  119. addorganization_id *int64
  120. dataset_id *string
  121. collection_id *string
  122. clearedFields map[string]struct{}
  123. wx_agent map[uint64]struct{}
  124. removedwx_agent map[uint64]struct{}
  125. clearedwx_agent bool
  126. token_agent map[uint64]struct{}
  127. removedtoken_agent map[uint64]struct{}
  128. clearedtoken_agent bool
  129. wa_agent map[uint64]struct{}
  130. removedwa_agent map[uint64]struct{}
  131. clearedwa_agent bool
  132. done bool
  133. oldValue func(context.Context) (*Agent, error)
  134. predicates []predicate.Agent
  135. }
  136. var _ ent.Mutation = (*AgentMutation)(nil)
  137. // agentOption allows management of the mutation configuration using functional options.
  138. type agentOption func(*AgentMutation)
  139. // newAgentMutation creates new mutation for the Agent entity.
  140. func newAgentMutation(c config, op Op, opts ...agentOption) *AgentMutation {
  141. m := &AgentMutation{
  142. config: c,
  143. op: op,
  144. typ: TypeAgent,
  145. clearedFields: make(map[string]struct{}),
  146. }
  147. for _, opt := range opts {
  148. opt(m)
  149. }
  150. return m
  151. }
  152. // withAgentID sets the ID field of the mutation.
  153. func withAgentID(id uint64) agentOption {
  154. return func(m *AgentMutation) {
  155. var (
  156. err error
  157. once sync.Once
  158. value *Agent
  159. )
  160. m.oldValue = func(ctx context.Context) (*Agent, error) {
  161. once.Do(func() {
  162. if m.done {
  163. err = errors.New("querying old values post mutation is not allowed")
  164. } else {
  165. value, err = m.Client().Agent.Get(ctx, id)
  166. }
  167. })
  168. return value, err
  169. }
  170. m.id = &id
  171. }
  172. }
  173. // withAgent sets the old Agent of the mutation.
  174. func withAgent(node *Agent) agentOption {
  175. return func(m *AgentMutation) {
  176. m.oldValue = func(context.Context) (*Agent, error) {
  177. return node, nil
  178. }
  179. m.id = &node.ID
  180. }
  181. }
  182. // Client returns a new `ent.Client` from the mutation. If the mutation was
  183. // executed in a transaction (ent.Tx), a transactional client is returned.
  184. func (m AgentMutation) Client() *Client {
  185. client := &Client{config: m.config}
  186. client.init()
  187. return client
  188. }
  189. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  190. // it returns an error otherwise.
  191. func (m AgentMutation) Tx() (*Tx, error) {
  192. if _, ok := m.driver.(*txDriver); !ok {
  193. return nil, errors.New("ent: mutation is not running in a transaction")
  194. }
  195. tx := &Tx{config: m.config}
  196. tx.init()
  197. return tx, nil
  198. }
  199. // SetID sets the value of the id field. Note that this
  200. // operation is only accepted on creation of Agent entities.
  201. func (m *AgentMutation) SetID(id uint64) {
  202. m.id = &id
  203. }
  204. // ID returns the ID value in the mutation. Note that the ID is only available
  205. // if it was provided to the builder or after it was returned from the database.
  206. func (m *AgentMutation) ID() (id uint64, exists bool) {
  207. if m.id == nil {
  208. return
  209. }
  210. return *m.id, true
  211. }
  212. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  213. // That means, if the mutation is applied within a transaction with an isolation level such
  214. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  215. // or updated by the mutation.
  216. func (m *AgentMutation) IDs(ctx context.Context) ([]uint64, error) {
  217. switch {
  218. case m.op.Is(OpUpdateOne | OpDeleteOne):
  219. id, exists := m.ID()
  220. if exists {
  221. return []uint64{id}, nil
  222. }
  223. fallthrough
  224. case m.op.Is(OpUpdate | OpDelete):
  225. return m.Client().Agent.Query().Where(m.predicates...).IDs(ctx)
  226. default:
  227. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  228. }
  229. }
  230. // SetCreatedAt sets the "created_at" field.
  231. func (m *AgentMutation) SetCreatedAt(t time.Time) {
  232. m.created_at = &t
  233. }
  234. // CreatedAt returns the value of the "created_at" field in the mutation.
  235. func (m *AgentMutation) CreatedAt() (r time.Time, exists bool) {
  236. v := m.created_at
  237. if v == nil {
  238. return
  239. }
  240. return *v, true
  241. }
  242. // OldCreatedAt returns the old "created_at" field's value of the Agent entity.
  243. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  244. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  245. func (m *AgentMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  246. if !m.op.Is(OpUpdateOne) {
  247. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  248. }
  249. if m.id == nil || m.oldValue == nil {
  250. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  251. }
  252. oldValue, err := m.oldValue(ctx)
  253. if err != nil {
  254. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  255. }
  256. return oldValue.CreatedAt, nil
  257. }
  258. // ResetCreatedAt resets all changes to the "created_at" field.
  259. func (m *AgentMutation) ResetCreatedAt() {
  260. m.created_at = nil
  261. }
  262. // SetUpdatedAt sets the "updated_at" field.
  263. func (m *AgentMutation) SetUpdatedAt(t time.Time) {
  264. m.updated_at = &t
  265. }
  266. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  267. func (m *AgentMutation) UpdatedAt() (r time.Time, exists bool) {
  268. v := m.updated_at
  269. if v == nil {
  270. return
  271. }
  272. return *v, true
  273. }
  274. // OldUpdatedAt returns the old "updated_at" field's value of the Agent entity.
  275. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  276. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  277. func (m *AgentMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  278. if !m.op.Is(OpUpdateOne) {
  279. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  280. }
  281. if m.id == nil || m.oldValue == nil {
  282. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  283. }
  284. oldValue, err := m.oldValue(ctx)
  285. if err != nil {
  286. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  287. }
  288. return oldValue.UpdatedAt, nil
  289. }
  290. // ResetUpdatedAt resets all changes to the "updated_at" field.
  291. func (m *AgentMutation) ResetUpdatedAt() {
  292. m.updated_at = nil
  293. }
  294. // SetDeletedAt sets the "deleted_at" field.
  295. func (m *AgentMutation) SetDeletedAt(t time.Time) {
  296. m.deleted_at = &t
  297. }
  298. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  299. func (m *AgentMutation) DeletedAt() (r time.Time, exists bool) {
  300. v := m.deleted_at
  301. if v == nil {
  302. return
  303. }
  304. return *v, true
  305. }
  306. // OldDeletedAt returns the old "deleted_at" field's value of the Agent entity.
  307. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  308. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  309. func (m *AgentMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  310. if !m.op.Is(OpUpdateOne) {
  311. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  312. }
  313. if m.id == nil || m.oldValue == nil {
  314. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  315. }
  316. oldValue, err := m.oldValue(ctx)
  317. if err != nil {
  318. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  319. }
  320. return oldValue.DeletedAt, nil
  321. }
  322. // ClearDeletedAt clears the value of the "deleted_at" field.
  323. func (m *AgentMutation) ClearDeletedAt() {
  324. m.deleted_at = nil
  325. m.clearedFields[agent.FieldDeletedAt] = struct{}{}
  326. }
  327. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  328. func (m *AgentMutation) DeletedAtCleared() bool {
  329. _, ok := m.clearedFields[agent.FieldDeletedAt]
  330. return ok
  331. }
  332. // ResetDeletedAt resets all changes to the "deleted_at" field.
  333. func (m *AgentMutation) ResetDeletedAt() {
  334. m.deleted_at = nil
  335. delete(m.clearedFields, agent.FieldDeletedAt)
  336. }
  337. // SetName sets the "name" field.
  338. func (m *AgentMutation) SetName(s string) {
  339. m.name = &s
  340. }
  341. // Name returns the value of the "name" field in the mutation.
  342. func (m *AgentMutation) Name() (r string, exists bool) {
  343. v := m.name
  344. if v == nil {
  345. return
  346. }
  347. return *v, true
  348. }
  349. // OldName returns the old "name" field's value of the Agent entity.
  350. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  351. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  352. func (m *AgentMutation) OldName(ctx context.Context) (v string, err error) {
  353. if !m.op.Is(OpUpdateOne) {
  354. return v, errors.New("OldName is only allowed on UpdateOne operations")
  355. }
  356. if m.id == nil || m.oldValue == nil {
  357. return v, errors.New("OldName requires an ID field in the mutation")
  358. }
  359. oldValue, err := m.oldValue(ctx)
  360. if err != nil {
  361. return v, fmt.Errorf("querying old value for OldName: %w", err)
  362. }
  363. return oldValue.Name, nil
  364. }
  365. // ResetName resets all changes to the "name" field.
  366. func (m *AgentMutation) ResetName() {
  367. m.name = nil
  368. }
  369. // SetRole sets the "role" field.
  370. func (m *AgentMutation) SetRole(s string) {
  371. m.role = &s
  372. }
  373. // Role returns the value of the "role" field in the mutation.
  374. func (m *AgentMutation) Role() (r string, exists bool) {
  375. v := m.role
  376. if v == nil {
  377. return
  378. }
  379. return *v, true
  380. }
  381. // OldRole returns the old "role" field's value of the Agent entity.
  382. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  383. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  384. func (m *AgentMutation) OldRole(ctx context.Context) (v string, err error) {
  385. if !m.op.Is(OpUpdateOne) {
  386. return v, errors.New("OldRole is only allowed on UpdateOne operations")
  387. }
  388. if m.id == nil || m.oldValue == nil {
  389. return v, errors.New("OldRole requires an ID field in the mutation")
  390. }
  391. oldValue, err := m.oldValue(ctx)
  392. if err != nil {
  393. return v, fmt.Errorf("querying old value for OldRole: %w", err)
  394. }
  395. return oldValue.Role, nil
  396. }
  397. // ResetRole resets all changes to the "role" field.
  398. func (m *AgentMutation) ResetRole() {
  399. m.role = nil
  400. }
  401. // SetStatus sets the "status" field.
  402. func (m *AgentMutation) SetStatus(i int) {
  403. m.status = &i
  404. m.addstatus = nil
  405. }
  406. // Status returns the value of the "status" field in the mutation.
  407. func (m *AgentMutation) Status() (r int, exists bool) {
  408. v := m.status
  409. if v == nil {
  410. return
  411. }
  412. return *v, true
  413. }
  414. // OldStatus returns the old "status" field's value of the Agent entity.
  415. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  416. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  417. func (m *AgentMutation) OldStatus(ctx context.Context) (v int, err error) {
  418. if !m.op.Is(OpUpdateOne) {
  419. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  420. }
  421. if m.id == nil || m.oldValue == nil {
  422. return v, errors.New("OldStatus requires an ID field in the mutation")
  423. }
  424. oldValue, err := m.oldValue(ctx)
  425. if err != nil {
  426. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  427. }
  428. return oldValue.Status, nil
  429. }
  430. // AddStatus adds i to the "status" field.
  431. func (m *AgentMutation) AddStatus(i int) {
  432. if m.addstatus != nil {
  433. *m.addstatus += i
  434. } else {
  435. m.addstatus = &i
  436. }
  437. }
  438. // AddedStatus returns the value that was added to the "status" field in this mutation.
  439. func (m *AgentMutation) AddedStatus() (r int, exists bool) {
  440. v := m.addstatus
  441. if v == nil {
  442. return
  443. }
  444. return *v, true
  445. }
  446. // ClearStatus clears the value of the "status" field.
  447. func (m *AgentMutation) ClearStatus() {
  448. m.status = nil
  449. m.addstatus = nil
  450. m.clearedFields[agent.FieldStatus] = struct{}{}
  451. }
  452. // StatusCleared returns if the "status" field was cleared in this mutation.
  453. func (m *AgentMutation) StatusCleared() bool {
  454. _, ok := m.clearedFields[agent.FieldStatus]
  455. return ok
  456. }
  457. // ResetStatus resets all changes to the "status" field.
  458. func (m *AgentMutation) ResetStatus() {
  459. m.status = nil
  460. m.addstatus = nil
  461. delete(m.clearedFields, agent.FieldStatus)
  462. }
  463. // SetBackground sets the "background" field.
  464. func (m *AgentMutation) SetBackground(s string) {
  465. m.background = &s
  466. }
  467. // Background returns the value of the "background" field in the mutation.
  468. func (m *AgentMutation) Background() (r string, exists bool) {
  469. v := m.background
  470. if v == nil {
  471. return
  472. }
  473. return *v, true
  474. }
  475. // OldBackground returns the old "background" field's value of the Agent entity.
  476. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  477. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  478. func (m *AgentMutation) OldBackground(ctx context.Context) (v string, err error) {
  479. if !m.op.Is(OpUpdateOne) {
  480. return v, errors.New("OldBackground is only allowed on UpdateOne operations")
  481. }
  482. if m.id == nil || m.oldValue == nil {
  483. return v, errors.New("OldBackground requires an ID field in the mutation")
  484. }
  485. oldValue, err := m.oldValue(ctx)
  486. if err != nil {
  487. return v, fmt.Errorf("querying old value for OldBackground: %w", err)
  488. }
  489. return oldValue.Background, nil
  490. }
  491. // ClearBackground clears the value of the "background" field.
  492. func (m *AgentMutation) ClearBackground() {
  493. m.background = nil
  494. m.clearedFields[agent.FieldBackground] = struct{}{}
  495. }
  496. // BackgroundCleared returns if the "background" field was cleared in this mutation.
  497. func (m *AgentMutation) BackgroundCleared() bool {
  498. _, ok := m.clearedFields[agent.FieldBackground]
  499. return ok
  500. }
  501. // ResetBackground resets all changes to the "background" field.
  502. func (m *AgentMutation) ResetBackground() {
  503. m.background = nil
  504. delete(m.clearedFields, agent.FieldBackground)
  505. }
  506. // SetExamples sets the "examples" field.
  507. func (m *AgentMutation) SetExamples(s string) {
  508. m.examples = &s
  509. }
  510. // Examples returns the value of the "examples" field in the mutation.
  511. func (m *AgentMutation) Examples() (r string, exists bool) {
  512. v := m.examples
  513. if v == nil {
  514. return
  515. }
  516. return *v, true
  517. }
  518. // OldExamples returns the old "examples" field's value of the Agent entity.
  519. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  520. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  521. func (m *AgentMutation) OldExamples(ctx context.Context) (v string, err error) {
  522. if !m.op.Is(OpUpdateOne) {
  523. return v, errors.New("OldExamples is only allowed on UpdateOne operations")
  524. }
  525. if m.id == nil || m.oldValue == nil {
  526. return v, errors.New("OldExamples requires an ID field in the mutation")
  527. }
  528. oldValue, err := m.oldValue(ctx)
  529. if err != nil {
  530. return v, fmt.Errorf("querying old value for OldExamples: %w", err)
  531. }
  532. return oldValue.Examples, nil
  533. }
  534. // ClearExamples clears the value of the "examples" field.
  535. func (m *AgentMutation) ClearExamples() {
  536. m.examples = nil
  537. m.clearedFields[agent.FieldExamples] = struct{}{}
  538. }
  539. // ExamplesCleared returns if the "examples" field was cleared in this mutation.
  540. func (m *AgentMutation) ExamplesCleared() bool {
  541. _, ok := m.clearedFields[agent.FieldExamples]
  542. return ok
  543. }
  544. // ResetExamples resets all changes to the "examples" field.
  545. func (m *AgentMutation) ResetExamples() {
  546. m.examples = nil
  547. delete(m.clearedFields, agent.FieldExamples)
  548. }
  549. // SetOrganizationID sets the "organization_id" field.
  550. func (m *AgentMutation) SetOrganizationID(u uint64) {
  551. m.organization_id = &u
  552. m.addorganization_id = nil
  553. }
  554. // OrganizationID returns the value of the "organization_id" field in the mutation.
  555. func (m *AgentMutation) OrganizationID() (r uint64, exists bool) {
  556. v := m.organization_id
  557. if v == nil {
  558. return
  559. }
  560. return *v, true
  561. }
  562. // OldOrganizationID returns the old "organization_id" field's value of the Agent entity.
  563. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  564. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  565. func (m *AgentMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  566. if !m.op.Is(OpUpdateOne) {
  567. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  568. }
  569. if m.id == nil || m.oldValue == nil {
  570. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  571. }
  572. oldValue, err := m.oldValue(ctx)
  573. if err != nil {
  574. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  575. }
  576. return oldValue.OrganizationID, nil
  577. }
  578. // AddOrganizationID adds u to the "organization_id" field.
  579. func (m *AgentMutation) AddOrganizationID(u int64) {
  580. if m.addorganization_id != nil {
  581. *m.addorganization_id += u
  582. } else {
  583. m.addorganization_id = &u
  584. }
  585. }
  586. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  587. func (m *AgentMutation) AddedOrganizationID() (r int64, exists bool) {
  588. v := m.addorganization_id
  589. if v == nil {
  590. return
  591. }
  592. return *v, true
  593. }
  594. // ResetOrganizationID resets all changes to the "organization_id" field.
  595. func (m *AgentMutation) ResetOrganizationID() {
  596. m.organization_id = nil
  597. m.addorganization_id = nil
  598. }
  599. // SetDatasetID sets the "dataset_id" field.
  600. func (m *AgentMutation) SetDatasetID(s string) {
  601. m.dataset_id = &s
  602. }
  603. // DatasetID returns the value of the "dataset_id" field in the mutation.
  604. func (m *AgentMutation) DatasetID() (r string, exists bool) {
  605. v := m.dataset_id
  606. if v == nil {
  607. return
  608. }
  609. return *v, true
  610. }
  611. // OldDatasetID returns the old "dataset_id" field's value of the Agent entity.
  612. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  613. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  614. func (m *AgentMutation) OldDatasetID(ctx context.Context) (v string, err error) {
  615. if !m.op.Is(OpUpdateOne) {
  616. return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
  617. }
  618. if m.id == nil || m.oldValue == nil {
  619. return v, errors.New("OldDatasetID requires an ID field in the mutation")
  620. }
  621. oldValue, err := m.oldValue(ctx)
  622. if err != nil {
  623. return v, fmt.Errorf("querying old value for OldDatasetID: %w", err)
  624. }
  625. return oldValue.DatasetID, nil
  626. }
  627. // ResetDatasetID resets all changes to the "dataset_id" field.
  628. func (m *AgentMutation) ResetDatasetID() {
  629. m.dataset_id = nil
  630. }
  631. // SetCollectionID sets the "collection_id" field.
  632. func (m *AgentMutation) SetCollectionID(s string) {
  633. m.collection_id = &s
  634. }
  635. // CollectionID returns the value of the "collection_id" field in the mutation.
  636. func (m *AgentMutation) CollectionID() (r string, exists bool) {
  637. v := m.collection_id
  638. if v == nil {
  639. return
  640. }
  641. return *v, true
  642. }
  643. // OldCollectionID returns the old "collection_id" field's value of the Agent entity.
  644. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  645. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  646. func (m *AgentMutation) OldCollectionID(ctx context.Context) (v string, err error) {
  647. if !m.op.Is(OpUpdateOne) {
  648. return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
  649. }
  650. if m.id == nil || m.oldValue == nil {
  651. return v, errors.New("OldCollectionID requires an ID field in the mutation")
  652. }
  653. oldValue, err := m.oldValue(ctx)
  654. if err != nil {
  655. return v, fmt.Errorf("querying old value for OldCollectionID: %w", err)
  656. }
  657. return oldValue.CollectionID, nil
  658. }
  659. // ResetCollectionID resets all changes to the "collection_id" field.
  660. func (m *AgentMutation) ResetCollectionID() {
  661. m.collection_id = nil
  662. }
  663. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  664. func (m *AgentMutation) AddWxAgentIDs(ids ...uint64) {
  665. if m.wx_agent == nil {
  666. m.wx_agent = make(map[uint64]struct{})
  667. }
  668. for i := range ids {
  669. m.wx_agent[ids[i]] = struct{}{}
  670. }
  671. }
  672. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  673. func (m *AgentMutation) ClearWxAgent() {
  674. m.clearedwx_agent = true
  675. }
  676. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  677. func (m *AgentMutation) WxAgentCleared() bool {
  678. return m.clearedwx_agent
  679. }
  680. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  681. func (m *AgentMutation) RemoveWxAgentIDs(ids ...uint64) {
  682. if m.removedwx_agent == nil {
  683. m.removedwx_agent = make(map[uint64]struct{})
  684. }
  685. for i := range ids {
  686. delete(m.wx_agent, ids[i])
  687. m.removedwx_agent[ids[i]] = struct{}{}
  688. }
  689. }
  690. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  691. func (m *AgentMutation) RemovedWxAgentIDs() (ids []uint64) {
  692. for id := range m.removedwx_agent {
  693. ids = append(ids, id)
  694. }
  695. return
  696. }
  697. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  698. func (m *AgentMutation) WxAgentIDs() (ids []uint64) {
  699. for id := range m.wx_agent {
  700. ids = append(ids, id)
  701. }
  702. return
  703. }
  704. // ResetWxAgent resets all changes to the "wx_agent" edge.
  705. func (m *AgentMutation) ResetWxAgent() {
  706. m.wx_agent = nil
  707. m.clearedwx_agent = false
  708. m.removedwx_agent = nil
  709. }
  710. // AddTokenAgentIDs adds the "token_agent" edge to the Token entity by ids.
  711. func (m *AgentMutation) AddTokenAgentIDs(ids ...uint64) {
  712. if m.token_agent == nil {
  713. m.token_agent = make(map[uint64]struct{})
  714. }
  715. for i := range ids {
  716. m.token_agent[ids[i]] = struct{}{}
  717. }
  718. }
  719. // ClearTokenAgent clears the "token_agent" edge to the Token entity.
  720. func (m *AgentMutation) ClearTokenAgent() {
  721. m.clearedtoken_agent = true
  722. }
  723. // TokenAgentCleared reports if the "token_agent" edge to the Token entity was cleared.
  724. func (m *AgentMutation) TokenAgentCleared() bool {
  725. return m.clearedtoken_agent
  726. }
  727. // RemoveTokenAgentIDs removes the "token_agent" edge to the Token entity by IDs.
  728. func (m *AgentMutation) RemoveTokenAgentIDs(ids ...uint64) {
  729. if m.removedtoken_agent == nil {
  730. m.removedtoken_agent = make(map[uint64]struct{})
  731. }
  732. for i := range ids {
  733. delete(m.token_agent, ids[i])
  734. m.removedtoken_agent[ids[i]] = struct{}{}
  735. }
  736. }
  737. // RemovedTokenAgent returns the removed IDs of the "token_agent" edge to the Token entity.
  738. func (m *AgentMutation) RemovedTokenAgentIDs() (ids []uint64) {
  739. for id := range m.removedtoken_agent {
  740. ids = append(ids, id)
  741. }
  742. return
  743. }
  744. // TokenAgentIDs returns the "token_agent" edge IDs in the mutation.
  745. func (m *AgentMutation) TokenAgentIDs() (ids []uint64) {
  746. for id := range m.token_agent {
  747. ids = append(ids, id)
  748. }
  749. return
  750. }
  751. // ResetTokenAgent resets all changes to the "token_agent" edge.
  752. func (m *AgentMutation) ResetTokenAgent() {
  753. m.token_agent = nil
  754. m.clearedtoken_agent = false
  755. m.removedtoken_agent = nil
  756. }
  757. // AddWaAgentIDs adds the "wa_agent" edge to the Whatsapp entity by ids.
  758. func (m *AgentMutation) AddWaAgentIDs(ids ...uint64) {
  759. if m.wa_agent == nil {
  760. m.wa_agent = make(map[uint64]struct{})
  761. }
  762. for i := range ids {
  763. m.wa_agent[ids[i]] = struct{}{}
  764. }
  765. }
  766. // ClearWaAgent clears the "wa_agent" edge to the Whatsapp entity.
  767. func (m *AgentMutation) ClearWaAgent() {
  768. m.clearedwa_agent = true
  769. }
  770. // WaAgentCleared reports if the "wa_agent" edge to the Whatsapp entity was cleared.
  771. func (m *AgentMutation) WaAgentCleared() bool {
  772. return m.clearedwa_agent
  773. }
  774. // RemoveWaAgentIDs removes the "wa_agent" edge to the Whatsapp entity by IDs.
  775. func (m *AgentMutation) RemoveWaAgentIDs(ids ...uint64) {
  776. if m.removedwa_agent == nil {
  777. m.removedwa_agent = make(map[uint64]struct{})
  778. }
  779. for i := range ids {
  780. delete(m.wa_agent, ids[i])
  781. m.removedwa_agent[ids[i]] = struct{}{}
  782. }
  783. }
  784. // RemovedWaAgent returns the removed IDs of the "wa_agent" edge to the Whatsapp entity.
  785. func (m *AgentMutation) RemovedWaAgentIDs() (ids []uint64) {
  786. for id := range m.removedwa_agent {
  787. ids = append(ids, id)
  788. }
  789. return
  790. }
  791. // WaAgentIDs returns the "wa_agent" edge IDs in the mutation.
  792. func (m *AgentMutation) WaAgentIDs() (ids []uint64) {
  793. for id := range m.wa_agent {
  794. ids = append(ids, id)
  795. }
  796. return
  797. }
  798. // ResetWaAgent resets all changes to the "wa_agent" edge.
  799. func (m *AgentMutation) ResetWaAgent() {
  800. m.wa_agent = nil
  801. m.clearedwa_agent = false
  802. m.removedwa_agent = nil
  803. }
  804. // Where appends a list predicates to the AgentMutation builder.
  805. func (m *AgentMutation) Where(ps ...predicate.Agent) {
  806. m.predicates = append(m.predicates, ps...)
  807. }
  808. // WhereP appends storage-level predicates to the AgentMutation builder. Using this method,
  809. // users can use type-assertion to append predicates that do not depend on any generated package.
  810. func (m *AgentMutation) WhereP(ps ...func(*sql.Selector)) {
  811. p := make([]predicate.Agent, len(ps))
  812. for i := range ps {
  813. p[i] = ps[i]
  814. }
  815. m.Where(p...)
  816. }
  817. // Op returns the operation name.
  818. func (m *AgentMutation) Op() Op {
  819. return m.op
  820. }
  821. // SetOp allows setting the mutation operation.
  822. func (m *AgentMutation) SetOp(op Op) {
  823. m.op = op
  824. }
  825. // Type returns the node type of this mutation (Agent).
  826. func (m *AgentMutation) Type() string {
  827. return m.typ
  828. }
  829. // Fields returns all fields that were changed during this mutation. Note that in
  830. // order to get all numeric fields that were incremented/decremented, call
  831. // AddedFields().
  832. func (m *AgentMutation) Fields() []string {
  833. fields := make([]string, 0, 11)
  834. if m.created_at != nil {
  835. fields = append(fields, agent.FieldCreatedAt)
  836. }
  837. if m.updated_at != nil {
  838. fields = append(fields, agent.FieldUpdatedAt)
  839. }
  840. if m.deleted_at != nil {
  841. fields = append(fields, agent.FieldDeletedAt)
  842. }
  843. if m.name != nil {
  844. fields = append(fields, agent.FieldName)
  845. }
  846. if m.role != nil {
  847. fields = append(fields, agent.FieldRole)
  848. }
  849. if m.status != nil {
  850. fields = append(fields, agent.FieldStatus)
  851. }
  852. if m.background != nil {
  853. fields = append(fields, agent.FieldBackground)
  854. }
  855. if m.examples != nil {
  856. fields = append(fields, agent.FieldExamples)
  857. }
  858. if m.organization_id != nil {
  859. fields = append(fields, agent.FieldOrganizationID)
  860. }
  861. if m.dataset_id != nil {
  862. fields = append(fields, agent.FieldDatasetID)
  863. }
  864. if m.collection_id != nil {
  865. fields = append(fields, agent.FieldCollectionID)
  866. }
  867. return fields
  868. }
  869. // Field returns the value of a field with the given name. The second boolean
  870. // return value indicates that this field was not set, or was not defined in the
  871. // schema.
  872. func (m *AgentMutation) Field(name string) (ent.Value, bool) {
  873. switch name {
  874. case agent.FieldCreatedAt:
  875. return m.CreatedAt()
  876. case agent.FieldUpdatedAt:
  877. return m.UpdatedAt()
  878. case agent.FieldDeletedAt:
  879. return m.DeletedAt()
  880. case agent.FieldName:
  881. return m.Name()
  882. case agent.FieldRole:
  883. return m.Role()
  884. case agent.FieldStatus:
  885. return m.Status()
  886. case agent.FieldBackground:
  887. return m.Background()
  888. case agent.FieldExamples:
  889. return m.Examples()
  890. case agent.FieldOrganizationID:
  891. return m.OrganizationID()
  892. case agent.FieldDatasetID:
  893. return m.DatasetID()
  894. case agent.FieldCollectionID:
  895. return m.CollectionID()
  896. }
  897. return nil, false
  898. }
  899. // OldField returns the old value of the field from the database. An error is
  900. // returned if the mutation operation is not UpdateOne, or the query to the
  901. // database failed.
  902. func (m *AgentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  903. switch name {
  904. case agent.FieldCreatedAt:
  905. return m.OldCreatedAt(ctx)
  906. case agent.FieldUpdatedAt:
  907. return m.OldUpdatedAt(ctx)
  908. case agent.FieldDeletedAt:
  909. return m.OldDeletedAt(ctx)
  910. case agent.FieldName:
  911. return m.OldName(ctx)
  912. case agent.FieldRole:
  913. return m.OldRole(ctx)
  914. case agent.FieldStatus:
  915. return m.OldStatus(ctx)
  916. case agent.FieldBackground:
  917. return m.OldBackground(ctx)
  918. case agent.FieldExamples:
  919. return m.OldExamples(ctx)
  920. case agent.FieldOrganizationID:
  921. return m.OldOrganizationID(ctx)
  922. case agent.FieldDatasetID:
  923. return m.OldDatasetID(ctx)
  924. case agent.FieldCollectionID:
  925. return m.OldCollectionID(ctx)
  926. }
  927. return nil, fmt.Errorf("unknown Agent field %s", name)
  928. }
  929. // SetField sets the value of a field with the given name. It returns an error if
  930. // the field is not defined in the schema, or if the type mismatched the field
  931. // type.
  932. func (m *AgentMutation) SetField(name string, value ent.Value) error {
  933. switch name {
  934. case agent.FieldCreatedAt:
  935. v, ok := value.(time.Time)
  936. if !ok {
  937. return fmt.Errorf("unexpected type %T for field %s", value, name)
  938. }
  939. m.SetCreatedAt(v)
  940. return nil
  941. case agent.FieldUpdatedAt:
  942. v, ok := value.(time.Time)
  943. if !ok {
  944. return fmt.Errorf("unexpected type %T for field %s", value, name)
  945. }
  946. m.SetUpdatedAt(v)
  947. return nil
  948. case agent.FieldDeletedAt:
  949. v, ok := value.(time.Time)
  950. if !ok {
  951. return fmt.Errorf("unexpected type %T for field %s", value, name)
  952. }
  953. m.SetDeletedAt(v)
  954. return nil
  955. case agent.FieldName:
  956. v, ok := value.(string)
  957. if !ok {
  958. return fmt.Errorf("unexpected type %T for field %s", value, name)
  959. }
  960. m.SetName(v)
  961. return nil
  962. case agent.FieldRole:
  963. v, ok := value.(string)
  964. if !ok {
  965. return fmt.Errorf("unexpected type %T for field %s", value, name)
  966. }
  967. m.SetRole(v)
  968. return nil
  969. case agent.FieldStatus:
  970. v, ok := value.(int)
  971. if !ok {
  972. return fmt.Errorf("unexpected type %T for field %s", value, name)
  973. }
  974. m.SetStatus(v)
  975. return nil
  976. case agent.FieldBackground:
  977. v, ok := value.(string)
  978. if !ok {
  979. return fmt.Errorf("unexpected type %T for field %s", value, name)
  980. }
  981. m.SetBackground(v)
  982. return nil
  983. case agent.FieldExamples:
  984. v, ok := value.(string)
  985. if !ok {
  986. return fmt.Errorf("unexpected type %T for field %s", value, name)
  987. }
  988. m.SetExamples(v)
  989. return nil
  990. case agent.FieldOrganizationID:
  991. v, ok := value.(uint64)
  992. if !ok {
  993. return fmt.Errorf("unexpected type %T for field %s", value, name)
  994. }
  995. m.SetOrganizationID(v)
  996. return nil
  997. case agent.FieldDatasetID:
  998. v, ok := value.(string)
  999. if !ok {
  1000. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1001. }
  1002. m.SetDatasetID(v)
  1003. return nil
  1004. case agent.FieldCollectionID:
  1005. v, ok := value.(string)
  1006. if !ok {
  1007. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1008. }
  1009. m.SetCollectionID(v)
  1010. return nil
  1011. }
  1012. return fmt.Errorf("unknown Agent field %s", name)
  1013. }
  1014. // AddedFields returns all numeric fields that were incremented/decremented during
  1015. // this mutation.
  1016. func (m *AgentMutation) AddedFields() []string {
  1017. var fields []string
  1018. if m.addstatus != nil {
  1019. fields = append(fields, agent.FieldStatus)
  1020. }
  1021. if m.addorganization_id != nil {
  1022. fields = append(fields, agent.FieldOrganizationID)
  1023. }
  1024. return fields
  1025. }
  1026. // AddedField returns the numeric value that was incremented/decremented on a field
  1027. // with the given name. The second boolean return value indicates that this field
  1028. // was not set, or was not defined in the schema.
  1029. func (m *AgentMutation) AddedField(name string) (ent.Value, bool) {
  1030. switch name {
  1031. case agent.FieldStatus:
  1032. return m.AddedStatus()
  1033. case agent.FieldOrganizationID:
  1034. return m.AddedOrganizationID()
  1035. }
  1036. return nil, false
  1037. }
  1038. // AddField adds the value to the field with the given name. It returns an error if
  1039. // the field is not defined in the schema, or if the type mismatched the field
  1040. // type.
  1041. func (m *AgentMutation) AddField(name string, value ent.Value) error {
  1042. switch name {
  1043. case agent.FieldStatus:
  1044. v, ok := value.(int)
  1045. if !ok {
  1046. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1047. }
  1048. m.AddStatus(v)
  1049. return nil
  1050. case agent.FieldOrganizationID:
  1051. v, ok := value.(int64)
  1052. if !ok {
  1053. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1054. }
  1055. m.AddOrganizationID(v)
  1056. return nil
  1057. }
  1058. return fmt.Errorf("unknown Agent numeric field %s", name)
  1059. }
  1060. // ClearedFields returns all nullable fields that were cleared during this
  1061. // mutation.
  1062. func (m *AgentMutation) ClearedFields() []string {
  1063. var fields []string
  1064. if m.FieldCleared(agent.FieldDeletedAt) {
  1065. fields = append(fields, agent.FieldDeletedAt)
  1066. }
  1067. if m.FieldCleared(agent.FieldStatus) {
  1068. fields = append(fields, agent.FieldStatus)
  1069. }
  1070. if m.FieldCleared(agent.FieldBackground) {
  1071. fields = append(fields, agent.FieldBackground)
  1072. }
  1073. if m.FieldCleared(agent.FieldExamples) {
  1074. fields = append(fields, agent.FieldExamples)
  1075. }
  1076. return fields
  1077. }
  1078. // FieldCleared returns a boolean indicating if a field with the given name was
  1079. // cleared in this mutation.
  1080. func (m *AgentMutation) FieldCleared(name string) bool {
  1081. _, ok := m.clearedFields[name]
  1082. return ok
  1083. }
  1084. // ClearField clears the value of the field with the given name. It returns an
  1085. // error if the field is not defined in the schema.
  1086. func (m *AgentMutation) ClearField(name string) error {
  1087. switch name {
  1088. case agent.FieldDeletedAt:
  1089. m.ClearDeletedAt()
  1090. return nil
  1091. case agent.FieldStatus:
  1092. m.ClearStatus()
  1093. return nil
  1094. case agent.FieldBackground:
  1095. m.ClearBackground()
  1096. return nil
  1097. case agent.FieldExamples:
  1098. m.ClearExamples()
  1099. return nil
  1100. }
  1101. return fmt.Errorf("unknown Agent nullable field %s", name)
  1102. }
  1103. // ResetField resets all changes in the mutation for the field with the given name.
  1104. // It returns an error if the field is not defined in the schema.
  1105. func (m *AgentMutation) ResetField(name string) error {
  1106. switch name {
  1107. case agent.FieldCreatedAt:
  1108. m.ResetCreatedAt()
  1109. return nil
  1110. case agent.FieldUpdatedAt:
  1111. m.ResetUpdatedAt()
  1112. return nil
  1113. case agent.FieldDeletedAt:
  1114. m.ResetDeletedAt()
  1115. return nil
  1116. case agent.FieldName:
  1117. m.ResetName()
  1118. return nil
  1119. case agent.FieldRole:
  1120. m.ResetRole()
  1121. return nil
  1122. case agent.FieldStatus:
  1123. m.ResetStatus()
  1124. return nil
  1125. case agent.FieldBackground:
  1126. m.ResetBackground()
  1127. return nil
  1128. case agent.FieldExamples:
  1129. m.ResetExamples()
  1130. return nil
  1131. case agent.FieldOrganizationID:
  1132. m.ResetOrganizationID()
  1133. return nil
  1134. case agent.FieldDatasetID:
  1135. m.ResetDatasetID()
  1136. return nil
  1137. case agent.FieldCollectionID:
  1138. m.ResetCollectionID()
  1139. return nil
  1140. }
  1141. return fmt.Errorf("unknown Agent field %s", name)
  1142. }
  1143. // AddedEdges returns all edge names that were set/added in this mutation.
  1144. func (m *AgentMutation) AddedEdges() []string {
  1145. edges := make([]string, 0, 3)
  1146. if m.wx_agent != nil {
  1147. edges = append(edges, agent.EdgeWxAgent)
  1148. }
  1149. if m.token_agent != nil {
  1150. edges = append(edges, agent.EdgeTokenAgent)
  1151. }
  1152. if m.wa_agent != nil {
  1153. edges = append(edges, agent.EdgeWaAgent)
  1154. }
  1155. return edges
  1156. }
  1157. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  1158. // name in this mutation.
  1159. func (m *AgentMutation) AddedIDs(name string) []ent.Value {
  1160. switch name {
  1161. case agent.EdgeWxAgent:
  1162. ids := make([]ent.Value, 0, len(m.wx_agent))
  1163. for id := range m.wx_agent {
  1164. ids = append(ids, id)
  1165. }
  1166. return ids
  1167. case agent.EdgeTokenAgent:
  1168. ids := make([]ent.Value, 0, len(m.token_agent))
  1169. for id := range m.token_agent {
  1170. ids = append(ids, id)
  1171. }
  1172. return ids
  1173. case agent.EdgeWaAgent:
  1174. ids := make([]ent.Value, 0, len(m.wa_agent))
  1175. for id := range m.wa_agent {
  1176. ids = append(ids, id)
  1177. }
  1178. return ids
  1179. }
  1180. return nil
  1181. }
  1182. // RemovedEdges returns all edge names that were removed in this mutation.
  1183. func (m *AgentMutation) RemovedEdges() []string {
  1184. edges := make([]string, 0, 3)
  1185. if m.removedwx_agent != nil {
  1186. edges = append(edges, agent.EdgeWxAgent)
  1187. }
  1188. if m.removedtoken_agent != nil {
  1189. edges = append(edges, agent.EdgeTokenAgent)
  1190. }
  1191. if m.removedwa_agent != nil {
  1192. edges = append(edges, agent.EdgeWaAgent)
  1193. }
  1194. return edges
  1195. }
  1196. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  1197. // the given name in this mutation.
  1198. func (m *AgentMutation) RemovedIDs(name string) []ent.Value {
  1199. switch name {
  1200. case agent.EdgeWxAgent:
  1201. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  1202. for id := range m.removedwx_agent {
  1203. ids = append(ids, id)
  1204. }
  1205. return ids
  1206. case agent.EdgeTokenAgent:
  1207. ids := make([]ent.Value, 0, len(m.removedtoken_agent))
  1208. for id := range m.removedtoken_agent {
  1209. ids = append(ids, id)
  1210. }
  1211. return ids
  1212. case agent.EdgeWaAgent:
  1213. ids := make([]ent.Value, 0, len(m.removedwa_agent))
  1214. for id := range m.removedwa_agent {
  1215. ids = append(ids, id)
  1216. }
  1217. return ids
  1218. }
  1219. return nil
  1220. }
  1221. // ClearedEdges returns all edge names that were cleared in this mutation.
  1222. func (m *AgentMutation) ClearedEdges() []string {
  1223. edges := make([]string, 0, 3)
  1224. if m.clearedwx_agent {
  1225. edges = append(edges, agent.EdgeWxAgent)
  1226. }
  1227. if m.clearedtoken_agent {
  1228. edges = append(edges, agent.EdgeTokenAgent)
  1229. }
  1230. if m.clearedwa_agent {
  1231. edges = append(edges, agent.EdgeWaAgent)
  1232. }
  1233. return edges
  1234. }
  1235. // EdgeCleared returns a boolean which indicates if the edge with the given name
  1236. // was cleared in this mutation.
  1237. func (m *AgentMutation) EdgeCleared(name string) bool {
  1238. switch name {
  1239. case agent.EdgeWxAgent:
  1240. return m.clearedwx_agent
  1241. case agent.EdgeTokenAgent:
  1242. return m.clearedtoken_agent
  1243. case agent.EdgeWaAgent:
  1244. return m.clearedwa_agent
  1245. }
  1246. return false
  1247. }
  1248. // ClearEdge clears the value of the edge with the given name. It returns an error
  1249. // if that edge is not defined in the schema.
  1250. func (m *AgentMutation) ClearEdge(name string) error {
  1251. switch name {
  1252. }
  1253. return fmt.Errorf("unknown Agent unique edge %s", name)
  1254. }
  1255. // ResetEdge resets all changes to the edge with the given name in this mutation.
  1256. // It returns an error if the edge is not defined in the schema.
  1257. func (m *AgentMutation) ResetEdge(name string) error {
  1258. switch name {
  1259. case agent.EdgeWxAgent:
  1260. m.ResetWxAgent()
  1261. return nil
  1262. case agent.EdgeTokenAgent:
  1263. m.ResetTokenAgent()
  1264. return nil
  1265. case agent.EdgeWaAgent:
  1266. m.ResetWaAgent()
  1267. return nil
  1268. }
  1269. return fmt.Errorf("unknown Agent edge %s", name)
  1270. }
  1271. // AgentBaseMutation represents an operation that mutates the AgentBase nodes in the graph.
  1272. type AgentBaseMutation struct {
  1273. config
  1274. op Op
  1275. typ string
  1276. id *string
  1277. q *string
  1278. a *string
  1279. chunk_index *uint64
  1280. addchunk_index *int64
  1281. indexes *[]string
  1282. appendindexes []string
  1283. dataset_id *string
  1284. collection_id *string
  1285. source_name *string
  1286. can_write *[]bool
  1287. appendcan_write []bool
  1288. is_owner *[]bool
  1289. appendis_owner []bool
  1290. clearedFields map[string]struct{}
  1291. wx_agent map[uint64]struct{}
  1292. removedwx_agent map[uint64]struct{}
  1293. clearedwx_agent bool
  1294. done bool
  1295. oldValue func(context.Context) (*AgentBase, error)
  1296. predicates []predicate.AgentBase
  1297. }
  1298. var _ ent.Mutation = (*AgentBaseMutation)(nil)
  1299. // agentbaseOption allows management of the mutation configuration using functional options.
  1300. type agentbaseOption func(*AgentBaseMutation)
  1301. // newAgentBaseMutation creates new mutation for the AgentBase entity.
  1302. func newAgentBaseMutation(c config, op Op, opts ...agentbaseOption) *AgentBaseMutation {
  1303. m := &AgentBaseMutation{
  1304. config: c,
  1305. op: op,
  1306. typ: TypeAgentBase,
  1307. clearedFields: make(map[string]struct{}),
  1308. }
  1309. for _, opt := range opts {
  1310. opt(m)
  1311. }
  1312. return m
  1313. }
  1314. // withAgentBaseID sets the ID field of the mutation.
  1315. func withAgentBaseID(id string) agentbaseOption {
  1316. return func(m *AgentBaseMutation) {
  1317. var (
  1318. err error
  1319. once sync.Once
  1320. value *AgentBase
  1321. )
  1322. m.oldValue = func(ctx context.Context) (*AgentBase, error) {
  1323. once.Do(func() {
  1324. if m.done {
  1325. err = errors.New("querying old values post mutation is not allowed")
  1326. } else {
  1327. value, err = m.Client().AgentBase.Get(ctx, id)
  1328. }
  1329. })
  1330. return value, err
  1331. }
  1332. m.id = &id
  1333. }
  1334. }
  1335. // withAgentBase sets the old AgentBase of the mutation.
  1336. func withAgentBase(node *AgentBase) agentbaseOption {
  1337. return func(m *AgentBaseMutation) {
  1338. m.oldValue = func(context.Context) (*AgentBase, error) {
  1339. return node, nil
  1340. }
  1341. m.id = &node.ID
  1342. }
  1343. }
  1344. // Client returns a new `ent.Client` from the mutation. If the mutation was
  1345. // executed in a transaction (ent.Tx), a transactional client is returned.
  1346. func (m AgentBaseMutation) Client() *Client {
  1347. client := &Client{config: m.config}
  1348. client.init()
  1349. return client
  1350. }
  1351. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  1352. // it returns an error otherwise.
  1353. func (m AgentBaseMutation) Tx() (*Tx, error) {
  1354. if _, ok := m.driver.(*txDriver); !ok {
  1355. return nil, errors.New("ent: mutation is not running in a transaction")
  1356. }
  1357. tx := &Tx{config: m.config}
  1358. tx.init()
  1359. return tx, nil
  1360. }
  1361. // SetID sets the value of the id field. Note that this
  1362. // operation is only accepted on creation of AgentBase entities.
  1363. func (m *AgentBaseMutation) SetID(id string) {
  1364. m.id = &id
  1365. }
  1366. // ID returns the ID value in the mutation. Note that the ID is only available
  1367. // if it was provided to the builder or after it was returned from the database.
  1368. func (m *AgentBaseMutation) ID() (id string, exists bool) {
  1369. if m.id == nil {
  1370. return
  1371. }
  1372. return *m.id, true
  1373. }
  1374. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  1375. // That means, if the mutation is applied within a transaction with an isolation level such
  1376. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  1377. // or updated by the mutation.
  1378. func (m *AgentBaseMutation) IDs(ctx context.Context) ([]string, error) {
  1379. switch {
  1380. case m.op.Is(OpUpdateOne | OpDeleteOne):
  1381. id, exists := m.ID()
  1382. if exists {
  1383. return []string{id}, nil
  1384. }
  1385. fallthrough
  1386. case m.op.Is(OpUpdate | OpDelete):
  1387. return m.Client().AgentBase.Query().Where(m.predicates...).IDs(ctx)
  1388. default:
  1389. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  1390. }
  1391. }
  1392. // SetQ sets the "q" field.
  1393. func (m *AgentBaseMutation) SetQ(s string) {
  1394. m.q = &s
  1395. }
  1396. // Q returns the value of the "q" field in the mutation.
  1397. func (m *AgentBaseMutation) Q() (r string, exists bool) {
  1398. v := m.q
  1399. if v == nil {
  1400. return
  1401. }
  1402. return *v, true
  1403. }
  1404. // OldQ returns the old "q" field's value of the AgentBase entity.
  1405. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1406. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1407. func (m *AgentBaseMutation) OldQ(ctx context.Context) (v string, err error) {
  1408. if !m.op.Is(OpUpdateOne) {
  1409. return v, errors.New("OldQ is only allowed on UpdateOne operations")
  1410. }
  1411. if m.id == nil || m.oldValue == nil {
  1412. return v, errors.New("OldQ requires an ID field in the mutation")
  1413. }
  1414. oldValue, err := m.oldValue(ctx)
  1415. if err != nil {
  1416. return v, fmt.Errorf("querying old value for OldQ: %w", err)
  1417. }
  1418. return oldValue.Q, nil
  1419. }
  1420. // ClearQ clears the value of the "q" field.
  1421. func (m *AgentBaseMutation) ClearQ() {
  1422. m.q = nil
  1423. m.clearedFields[agentbase.FieldQ] = struct{}{}
  1424. }
  1425. // QCleared returns if the "q" field was cleared in this mutation.
  1426. func (m *AgentBaseMutation) QCleared() bool {
  1427. _, ok := m.clearedFields[agentbase.FieldQ]
  1428. return ok
  1429. }
  1430. // ResetQ resets all changes to the "q" field.
  1431. func (m *AgentBaseMutation) ResetQ() {
  1432. m.q = nil
  1433. delete(m.clearedFields, agentbase.FieldQ)
  1434. }
  1435. // SetA sets the "a" field.
  1436. func (m *AgentBaseMutation) SetA(s string) {
  1437. m.a = &s
  1438. }
  1439. // A returns the value of the "a" field in the mutation.
  1440. func (m *AgentBaseMutation) A() (r string, exists bool) {
  1441. v := m.a
  1442. if v == nil {
  1443. return
  1444. }
  1445. return *v, true
  1446. }
  1447. // OldA returns the old "a" field's value of the AgentBase entity.
  1448. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1449. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1450. func (m *AgentBaseMutation) OldA(ctx context.Context) (v string, err error) {
  1451. if !m.op.Is(OpUpdateOne) {
  1452. return v, errors.New("OldA is only allowed on UpdateOne operations")
  1453. }
  1454. if m.id == nil || m.oldValue == nil {
  1455. return v, errors.New("OldA requires an ID field in the mutation")
  1456. }
  1457. oldValue, err := m.oldValue(ctx)
  1458. if err != nil {
  1459. return v, fmt.Errorf("querying old value for OldA: %w", err)
  1460. }
  1461. return oldValue.A, nil
  1462. }
  1463. // ClearA clears the value of the "a" field.
  1464. func (m *AgentBaseMutation) ClearA() {
  1465. m.a = nil
  1466. m.clearedFields[agentbase.FieldA] = struct{}{}
  1467. }
  1468. // ACleared returns if the "a" field was cleared in this mutation.
  1469. func (m *AgentBaseMutation) ACleared() bool {
  1470. _, ok := m.clearedFields[agentbase.FieldA]
  1471. return ok
  1472. }
  1473. // ResetA resets all changes to the "a" field.
  1474. func (m *AgentBaseMutation) ResetA() {
  1475. m.a = nil
  1476. delete(m.clearedFields, agentbase.FieldA)
  1477. }
  1478. // SetChunkIndex sets the "chunk_index" field.
  1479. func (m *AgentBaseMutation) SetChunkIndex(u uint64) {
  1480. m.chunk_index = &u
  1481. m.addchunk_index = nil
  1482. }
  1483. // ChunkIndex returns the value of the "chunk_index" field in the mutation.
  1484. func (m *AgentBaseMutation) ChunkIndex() (r uint64, exists bool) {
  1485. v := m.chunk_index
  1486. if v == nil {
  1487. return
  1488. }
  1489. return *v, true
  1490. }
  1491. // OldChunkIndex returns the old "chunk_index" field's value of the AgentBase entity.
  1492. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1493. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1494. func (m *AgentBaseMutation) OldChunkIndex(ctx context.Context) (v uint64, err error) {
  1495. if !m.op.Is(OpUpdateOne) {
  1496. return v, errors.New("OldChunkIndex is only allowed on UpdateOne operations")
  1497. }
  1498. if m.id == nil || m.oldValue == nil {
  1499. return v, errors.New("OldChunkIndex requires an ID field in the mutation")
  1500. }
  1501. oldValue, err := m.oldValue(ctx)
  1502. if err != nil {
  1503. return v, fmt.Errorf("querying old value for OldChunkIndex: %w", err)
  1504. }
  1505. return oldValue.ChunkIndex, nil
  1506. }
  1507. // AddChunkIndex adds u to the "chunk_index" field.
  1508. func (m *AgentBaseMutation) AddChunkIndex(u int64) {
  1509. if m.addchunk_index != nil {
  1510. *m.addchunk_index += u
  1511. } else {
  1512. m.addchunk_index = &u
  1513. }
  1514. }
  1515. // AddedChunkIndex returns the value that was added to the "chunk_index" field in this mutation.
  1516. func (m *AgentBaseMutation) AddedChunkIndex() (r int64, exists bool) {
  1517. v := m.addchunk_index
  1518. if v == nil {
  1519. return
  1520. }
  1521. return *v, true
  1522. }
  1523. // ResetChunkIndex resets all changes to the "chunk_index" field.
  1524. func (m *AgentBaseMutation) ResetChunkIndex() {
  1525. m.chunk_index = nil
  1526. m.addchunk_index = nil
  1527. }
  1528. // SetIndexes sets the "indexes" field.
  1529. func (m *AgentBaseMutation) SetIndexes(s []string) {
  1530. m.indexes = &s
  1531. m.appendindexes = nil
  1532. }
  1533. // Indexes returns the value of the "indexes" field in the mutation.
  1534. func (m *AgentBaseMutation) Indexes() (r []string, exists bool) {
  1535. v := m.indexes
  1536. if v == nil {
  1537. return
  1538. }
  1539. return *v, true
  1540. }
  1541. // OldIndexes returns the old "indexes" field's value of the AgentBase entity.
  1542. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1543. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1544. func (m *AgentBaseMutation) OldIndexes(ctx context.Context) (v []string, err error) {
  1545. if !m.op.Is(OpUpdateOne) {
  1546. return v, errors.New("OldIndexes is only allowed on UpdateOne operations")
  1547. }
  1548. if m.id == nil || m.oldValue == nil {
  1549. return v, errors.New("OldIndexes requires an ID field in the mutation")
  1550. }
  1551. oldValue, err := m.oldValue(ctx)
  1552. if err != nil {
  1553. return v, fmt.Errorf("querying old value for OldIndexes: %w", err)
  1554. }
  1555. return oldValue.Indexes, nil
  1556. }
  1557. // AppendIndexes adds s to the "indexes" field.
  1558. func (m *AgentBaseMutation) AppendIndexes(s []string) {
  1559. m.appendindexes = append(m.appendindexes, s...)
  1560. }
  1561. // AppendedIndexes returns the list of values that were appended to the "indexes" field in this mutation.
  1562. func (m *AgentBaseMutation) AppendedIndexes() ([]string, bool) {
  1563. if len(m.appendindexes) == 0 {
  1564. return nil, false
  1565. }
  1566. return m.appendindexes, true
  1567. }
  1568. // ClearIndexes clears the value of the "indexes" field.
  1569. func (m *AgentBaseMutation) ClearIndexes() {
  1570. m.indexes = nil
  1571. m.appendindexes = nil
  1572. m.clearedFields[agentbase.FieldIndexes] = struct{}{}
  1573. }
  1574. // IndexesCleared returns if the "indexes" field was cleared in this mutation.
  1575. func (m *AgentBaseMutation) IndexesCleared() bool {
  1576. _, ok := m.clearedFields[agentbase.FieldIndexes]
  1577. return ok
  1578. }
  1579. // ResetIndexes resets all changes to the "indexes" field.
  1580. func (m *AgentBaseMutation) ResetIndexes() {
  1581. m.indexes = nil
  1582. m.appendindexes = nil
  1583. delete(m.clearedFields, agentbase.FieldIndexes)
  1584. }
  1585. // SetDatasetID sets the "dataset_id" field.
  1586. func (m *AgentBaseMutation) SetDatasetID(s string) {
  1587. m.dataset_id = &s
  1588. }
  1589. // DatasetID returns the value of the "dataset_id" field in the mutation.
  1590. func (m *AgentBaseMutation) DatasetID() (r string, exists bool) {
  1591. v := m.dataset_id
  1592. if v == nil {
  1593. return
  1594. }
  1595. return *v, true
  1596. }
  1597. // OldDatasetID returns the old "dataset_id" field's value of the AgentBase entity.
  1598. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1599. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1600. func (m *AgentBaseMutation) OldDatasetID(ctx context.Context) (v string, err error) {
  1601. if !m.op.Is(OpUpdateOne) {
  1602. return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
  1603. }
  1604. if m.id == nil || m.oldValue == nil {
  1605. return v, errors.New("OldDatasetID requires an ID field in the mutation")
  1606. }
  1607. oldValue, err := m.oldValue(ctx)
  1608. if err != nil {
  1609. return v, fmt.Errorf("querying old value for OldDatasetID: %w", err)
  1610. }
  1611. return oldValue.DatasetID, nil
  1612. }
  1613. // ClearDatasetID clears the value of the "dataset_id" field.
  1614. func (m *AgentBaseMutation) ClearDatasetID() {
  1615. m.dataset_id = nil
  1616. m.clearedFields[agentbase.FieldDatasetID] = struct{}{}
  1617. }
  1618. // DatasetIDCleared returns if the "dataset_id" field was cleared in this mutation.
  1619. func (m *AgentBaseMutation) DatasetIDCleared() bool {
  1620. _, ok := m.clearedFields[agentbase.FieldDatasetID]
  1621. return ok
  1622. }
  1623. // ResetDatasetID resets all changes to the "dataset_id" field.
  1624. func (m *AgentBaseMutation) ResetDatasetID() {
  1625. m.dataset_id = nil
  1626. delete(m.clearedFields, agentbase.FieldDatasetID)
  1627. }
  1628. // SetCollectionID sets the "collection_id" field.
  1629. func (m *AgentBaseMutation) SetCollectionID(s string) {
  1630. m.collection_id = &s
  1631. }
  1632. // CollectionID returns the value of the "collection_id" field in the mutation.
  1633. func (m *AgentBaseMutation) CollectionID() (r string, exists bool) {
  1634. v := m.collection_id
  1635. if v == nil {
  1636. return
  1637. }
  1638. return *v, true
  1639. }
  1640. // OldCollectionID returns the old "collection_id" field's value of the AgentBase entity.
  1641. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1642. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1643. func (m *AgentBaseMutation) OldCollectionID(ctx context.Context) (v string, err error) {
  1644. if !m.op.Is(OpUpdateOne) {
  1645. return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
  1646. }
  1647. if m.id == nil || m.oldValue == nil {
  1648. return v, errors.New("OldCollectionID requires an ID field in the mutation")
  1649. }
  1650. oldValue, err := m.oldValue(ctx)
  1651. if err != nil {
  1652. return v, fmt.Errorf("querying old value for OldCollectionID: %w", err)
  1653. }
  1654. return oldValue.CollectionID, nil
  1655. }
  1656. // ClearCollectionID clears the value of the "collection_id" field.
  1657. func (m *AgentBaseMutation) ClearCollectionID() {
  1658. m.collection_id = nil
  1659. m.clearedFields[agentbase.FieldCollectionID] = struct{}{}
  1660. }
  1661. // CollectionIDCleared returns if the "collection_id" field was cleared in this mutation.
  1662. func (m *AgentBaseMutation) CollectionIDCleared() bool {
  1663. _, ok := m.clearedFields[agentbase.FieldCollectionID]
  1664. return ok
  1665. }
  1666. // ResetCollectionID resets all changes to the "collection_id" field.
  1667. func (m *AgentBaseMutation) ResetCollectionID() {
  1668. m.collection_id = nil
  1669. delete(m.clearedFields, agentbase.FieldCollectionID)
  1670. }
  1671. // SetSourceName sets the "source_name" field.
  1672. func (m *AgentBaseMutation) SetSourceName(s string) {
  1673. m.source_name = &s
  1674. }
  1675. // SourceName returns the value of the "source_name" field in the mutation.
  1676. func (m *AgentBaseMutation) SourceName() (r string, exists bool) {
  1677. v := m.source_name
  1678. if v == nil {
  1679. return
  1680. }
  1681. return *v, true
  1682. }
  1683. // OldSourceName returns the old "source_name" field's value of the AgentBase entity.
  1684. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1685. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1686. func (m *AgentBaseMutation) OldSourceName(ctx context.Context) (v string, err error) {
  1687. if !m.op.Is(OpUpdateOne) {
  1688. return v, errors.New("OldSourceName is only allowed on UpdateOne operations")
  1689. }
  1690. if m.id == nil || m.oldValue == nil {
  1691. return v, errors.New("OldSourceName requires an ID field in the mutation")
  1692. }
  1693. oldValue, err := m.oldValue(ctx)
  1694. if err != nil {
  1695. return v, fmt.Errorf("querying old value for OldSourceName: %w", err)
  1696. }
  1697. return oldValue.SourceName, nil
  1698. }
  1699. // ClearSourceName clears the value of the "source_name" field.
  1700. func (m *AgentBaseMutation) ClearSourceName() {
  1701. m.source_name = nil
  1702. m.clearedFields[agentbase.FieldSourceName] = struct{}{}
  1703. }
  1704. // SourceNameCleared returns if the "source_name" field was cleared in this mutation.
  1705. func (m *AgentBaseMutation) SourceNameCleared() bool {
  1706. _, ok := m.clearedFields[agentbase.FieldSourceName]
  1707. return ok
  1708. }
  1709. // ResetSourceName resets all changes to the "source_name" field.
  1710. func (m *AgentBaseMutation) ResetSourceName() {
  1711. m.source_name = nil
  1712. delete(m.clearedFields, agentbase.FieldSourceName)
  1713. }
  1714. // SetCanWrite sets the "can_write" field.
  1715. func (m *AgentBaseMutation) SetCanWrite(b []bool) {
  1716. m.can_write = &b
  1717. m.appendcan_write = nil
  1718. }
  1719. // CanWrite returns the value of the "can_write" field in the mutation.
  1720. func (m *AgentBaseMutation) CanWrite() (r []bool, exists bool) {
  1721. v := m.can_write
  1722. if v == nil {
  1723. return
  1724. }
  1725. return *v, true
  1726. }
  1727. // OldCanWrite returns the old "can_write" field's value of the AgentBase entity.
  1728. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1729. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1730. func (m *AgentBaseMutation) OldCanWrite(ctx context.Context) (v []bool, err error) {
  1731. if !m.op.Is(OpUpdateOne) {
  1732. return v, errors.New("OldCanWrite is only allowed on UpdateOne operations")
  1733. }
  1734. if m.id == nil || m.oldValue == nil {
  1735. return v, errors.New("OldCanWrite requires an ID field in the mutation")
  1736. }
  1737. oldValue, err := m.oldValue(ctx)
  1738. if err != nil {
  1739. return v, fmt.Errorf("querying old value for OldCanWrite: %w", err)
  1740. }
  1741. return oldValue.CanWrite, nil
  1742. }
  1743. // AppendCanWrite adds b to the "can_write" field.
  1744. func (m *AgentBaseMutation) AppendCanWrite(b []bool) {
  1745. m.appendcan_write = append(m.appendcan_write, b...)
  1746. }
  1747. // AppendedCanWrite returns the list of values that were appended to the "can_write" field in this mutation.
  1748. func (m *AgentBaseMutation) AppendedCanWrite() ([]bool, bool) {
  1749. if len(m.appendcan_write) == 0 {
  1750. return nil, false
  1751. }
  1752. return m.appendcan_write, true
  1753. }
  1754. // ClearCanWrite clears the value of the "can_write" field.
  1755. func (m *AgentBaseMutation) ClearCanWrite() {
  1756. m.can_write = nil
  1757. m.appendcan_write = nil
  1758. m.clearedFields[agentbase.FieldCanWrite] = struct{}{}
  1759. }
  1760. // CanWriteCleared returns if the "can_write" field was cleared in this mutation.
  1761. func (m *AgentBaseMutation) CanWriteCleared() bool {
  1762. _, ok := m.clearedFields[agentbase.FieldCanWrite]
  1763. return ok
  1764. }
  1765. // ResetCanWrite resets all changes to the "can_write" field.
  1766. func (m *AgentBaseMutation) ResetCanWrite() {
  1767. m.can_write = nil
  1768. m.appendcan_write = nil
  1769. delete(m.clearedFields, agentbase.FieldCanWrite)
  1770. }
  1771. // SetIsOwner sets the "is_owner" field.
  1772. func (m *AgentBaseMutation) SetIsOwner(b []bool) {
  1773. m.is_owner = &b
  1774. m.appendis_owner = nil
  1775. }
  1776. // IsOwner returns the value of the "is_owner" field in the mutation.
  1777. func (m *AgentBaseMutation) IsOwner() (r []bool, exists bool) {
  1778. v := m.is_owner
  1779. if v == nil {
  1780. return
  1781. }
  1782. return *v, true
  1783. }
  1784. // OldIsOwner returns the old "is_owner" field's value of the AgentBase entity.
  1785. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1786. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1787. func (m *AgentBaseMutation) OldIsOwner(ctx context.Context) (v []bool, err error) {
  1788. if !m.op.Is(OpUpdateOne) {
  1789. return v, errors.New("OldIsOwner is only allowed on UpdateOne operations")
  1790. }
  1791. if m.id == nil || m.oldValue == nil {
  1792. return v, errors.New("OldIsOwner requires an ID field in the mutation")
  1793. }
  1794. oldValue, err := m.oldValue(ctx)
  1795. if err != nil {
  1796. return v, fmt.Errorf("querying old value for OldIsOwner: %w", err)
  1797. }
  1798. return oldValue.IsOwner, nil
  1799. }
  1800. // AppendIsOwner adds b to the "is_owner" field.
  1801. func (m *AgentBaseMutation) AppendIsOwner(b []bool) {
  1802. m.appendis_owner = append(m.appendis_owner, b...)
  1803. }
  1804. // AppendedIsOwner returns the list of values that were appended to the "is_owner" field in this mutation.
  1805. func (m *AgentBaseMutation) AppendedIsOwner() ([]bool, bool) {
  1806. if len(m.appendis_owner) == 0 {
  1807. return nil, false
  1808. }
  1809. return m.appendis_owner, true
  1810. }
  1811. // ClearIsOwner clears the value of the "is_owner" field.
  1812. func (m *AgentBaseMutation) ClearIsOwner() {
  1813. m.is_owner = nil
  1814. m.appendis_owner = nil
  1815. m.clearedFields[agentbase.FieldIsOwner] = struct{}{}
  1816. }
  1817. // IsOwnerCleared returns if the "is_owner" field was cleared in this mutation.
  1818. func (m *AgentBaseMutation) IsOwnerCleared() bool {
  1819. _, ok := m.clearedFields[agentbase.FieldIsOwner]
  1820. return ok
  1821. }
  1822. // ResetIsOwner resets all changes to the "is_owner" field.
  1823. func (m *AgentBaseMutation) ResetIsOwner() {
  1824. m.is_owner = nil
  1825. m.appendis_owner = nil
  1826. delete(m.clearedFields, agentbase.FieldIsOwner)
  1827. }
  1828. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  1829. func (m *AgentBaseMutation) AddWxAgentIDs(ids ...uint64) {
  1830. if m.wx_agent == nil {
  1831. m.wx_agent = make(map[uint64]struct{})
  1832. }
  1833. for i := range ids {
  1834. m.wx_agent[ids[i]] = struct{}{}
  1835. }
  1836. }
  1837. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  1838. func (m *AgentBaseMutation) ClearWxAgent() {
  1839. m.clearedwx_agent = true
  1840. }
  1841. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  1842. func (m *AgentBaseMutation) WxAgentCleared() bool {
  1843. return m.clearedwx_agent
  1844. }
  1845. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  1846. func (m *AgentBaseMutation) RemoveWxAgentIDs(ids ...uint64) {
  1847. if m.removedwx_agent == nil {
  1848. m.removedwx_agent = make(map[uint64]struct{})
  1849. }
  1850. for i := range ids {
  1851. delete(m.wx_agent, ids[i])
  1852. m.removedwx_agent[ids[i]] = struct{}{}
  1853. }
  1854. }
  1855. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  1856. func (m *AgentBaseMutation) RemovedWxAgentIDs() (ids []uint64) {
  1857. for id := range m.removedwx_agent {
  1858. ids = append(ids, id)
  1859. }
  1860. return
  1861. }
  1862. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  1863. func (m *AgentBaseMutation) WxAgentIDs() (ids []uint64) {
  1864. for id := range m.wx_agent {
  1865. ids = append(ids, id)
  1866. }
  1867. return
  1868. }
  1869. // ResetWxAgent resets all changes to the "wx_agent" edge.
  1870. func (m *AgentBaseMutation) ResetWxAgent() {
  1871. m.wx_agent = nil
  1872. m.clearedwx_agent = false
  1873. m.removedwx_agent = nil
  1874. }
  1875. // Where appends a list predicates to the AgentBaseMutation builder.
  1876. func (m *AgentBaseMutation) Where(ps ...predicate.AgentBase) {
  1877. m.predicates = append(m.predicates, ps...)
  1878. }
  1879. // WhereP appends storage-level predicates to the AgentBaseMutation builder. Using this method,
  1880. // users can use type-assertion to append predicates that do not depend on any generated package.
  1881. func (m *AgentBaseMutation) WhereP(ps ...func(*sql.Selector)) {
  1882. p := make([]predicate.AgentBase, len(ps))
  1883. for i := range ps {
  1884. p[i] = ps[i]
  1885. }
  1886. m.Where(p...)
  1887. }
  1888. // Op returns the operation name.
  1889. func (m *AgentBaseMutation) Op() Op {
  1890. return m.op
  1891. }
  1892. // SetOp allows setting the mutation operation.
  1893. func (m *AgentBaseMutation) SetOp(op Op) {
  1894. m.op = op
  1895. }
  1896. // Type returns the node type of this mutation (AgentBase).
  1897. func (m *AgentBaseMutation) Type() string {
  1898. return m.typ
  1899. }
  1900. // Fields returns all fields that were changed during this mutation. Note that in
  1901. // order to get all numeric fields that were incremented/decremented, call
  1902. // AddedFields().
  1903. func (m *AgentBaseMutation) Fields() []string {
  1904. fields := make([]string, 0, 9)
  1905. if m.q != nil {
  1906. fields = append(fields, agentbase.FieldQ)
  1907. }
  1908. if m.a != nil {
  1909. fields = append(fields, agentbase.FieldA)
  1910. }
  1911. if m.chunk_index != nil {
  1912. fields = append(fields, agentbase.FieldChunkIndex)
  1913. }
  1914. if m.indexes != nil {
  1915. fields = append(fields, agentbase.FieldIndexes)
  1916. }
  1917. if m.dataset_id != nil {
  1918. fields = append(fields, agentbase.FieldDatasetID)
  1919. }
  1920. if m.collection_id != nil {
  1921. fields = append(fields, agentbase.FieldCollectionID)
  1922. }
  1923. if m.source_name != nil {
  1924. fields = append(fields, agentbase.FieldSourceName)
  1925. }
  1926. if m.can_write != nil {
  1927. fields = append(fields, agentbase.FieldCanWrite)
  1928. }
  1929. if m.is_owner != nil {
  1930. fields = append(fields, agentbase.FieldIsOwner)
  1931. }
  1932. return fields
  1933. }
  1934. // Field returns the value of a field with the given name. The second boolean
  1935. // return value indicates that this field was not set, or was not defined in the
  1936. // schema.
  1937. func (m *AgentBaseMutation) Field(name string) (ent.Value, bool) {
  1938. switch name {
  1939. case agentbase.FieldQ:
  1940. return m.Q()
  1941. case agentbase.FieldA:
  1942. return m.A()
  1943. case agentbase.FieldChunkIndex:
  1944. return m.ChunkIndex()
  1945. case agentbase.FieldIndexes:
  1946. return m.Indexes()
  1947. case agentbase.FieldDatasetID:
  1948. return m.DatasetID()
  1949. case agentbase.FieldCollectionID:
  1950. return m.CollectionID()
  1951. case agentbase.FieldSourceName:
  1952. return m.SourceName()
  1953. case agentbase.FieldCanWrite:
  1954. return m.CanWrite()
  1955. case agentbase.FieldIsOwner:
  1956. return m.IsOwner()
  1957. }
  1958. return nil, false
  1959. }
  1960. // OldField returns the old value of the field from the database. An error is
  1961. // returned if the mutation operation is not UpdateOne, or the query to the
  1962. // database failed.
  1963. func (m *AgentBaseMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  1964. switch name {
  1965. case agentbase.FieldQ:
  1966. return m.OldQ(ctx)
  1967. case agentbase.FieldA:
  1968. return m.OldA(ctx)
  1969. case agentbase.FieldChunkIndex:
  1970. return m.OldChunkIndex(ctx)
  1971. case agentbase.FieldIndexes:
  1972. return m.OldIndexes(ctx)
  1973. case agentbase.FieldDatasetID:
  1974. return m.OldDatasetID(ctx)
  1975. case agentbase.FieldCollectionID:
  1976. return m.OldCollectionID(ctx)
  1977. case agentbase.FieldSourceName:
  1978. return m.OldSourceName(ctx)
  1979. case agentbase.FieldCanWrite:
  1980. return m.OldCanWrite(ctx)
  1981. case agentbase.FieldIsOwner:
  1982. return m.OldIsOwner(ctx)
  1983. }
  1984. return nil, fmt.Errorf("unknown AgentBase field %s", name)
  1985. }
  1986. // SetField sets the value of a field with the given name. It returns an error if
  1987. // the field is not defined in the schema, or if the type mismatched the field
  1988. // type.
  1989. func (m *AgentBaseMutation) SetField(name string, value ent.Value) error {
  1990. switch name {
  1991. case agentbase.FieldQ:
  1992. v, ok := value.(string)
  1993. if !ok {
  1994. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1995. }
  1996. m.SetQ(v)
  1997. return nil
  1998. case agentbase.FieldA:
  1999. v, ok := value.(string)
  2000. if !ok {
  2001. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2002. }
  2003. m.SetA(v)
  2004. return nil
  2005. case agentbase.FieldChunkIndex:
  2006. v, ok := value.(uint64)
  2007. if !ok {
  2008. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2009. }
  2010. m.SetChunkIndex(v)
  2011. return nil
  2012. case agentbase.FieldIndexes:
  2013. v, ok := value.([]string)
  2014. if !ok {
  2015. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2016. }
  2017. m.SetIndexes(v)
  2018. return nil
  2019. case agentbase.FieldDatasetID:
  2020. v, ok := value.(string)
  2021. if !ok {
  2022. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2023. }
  2024. m.SetDatasetID(v)
  2025. return nil
  2026. case agentbase.FieldCollectionID:
  2027. v, ok := value.(string)
  2028. if !ok {
  2029. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2030. }
  2031. m.SetCollectionID(v)
  2032. return nil
  2033. case agentbase.FieldSourceName:
  2034. v, ok := value.(string)
  2035. if !ok {
  2036. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2037. }
  2038. m.SetSourceName(v)
  2039. return nil
  2040. case agentbase.FieldCanWrite:
  2041. v, ok := value.([]bool)
  2042. if !ok {
  2043. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2044. }
  2045. m.SetCanWrite(v)
  2046. return nil
  2047. case agentbase.FieldIsOwner:
  2048. v, ok := value.([]bool)
  2049. if !ok {
  2050. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2051. }
  2052. m.SetIsOwner(v)
  2053. return nil
  2054. }
  2055. return fmt.Errorf("unknown AgentBase field %s", name)
  2056. }
  2057. // AddedFields returns all numeric fields that were incremented/decremented during
  2058. // this mutation.
  2059. func (m *AgentBaseMutation) AddedFields() []string {
  2060. var fields []string
  2061. if m.addchunk_index != nil {
  2062. fields = append(fields, agentbase.FieldChunkIndex)
  2063. }
  2064. return fields
  2065. }
  2066. // AddedField returns the numeric value that was incremented/decremented on a field
  2067. // with the given name. The second boolean return value indicates that this field
  2068. // was not set, or was not defined in the schema.
  2069. func (m *AgentBaseMutation) AddedField(name string) (ent.Value, bool) {
  2070. switch name {
  2071. case agentbase.FieldChunkIndex:
  2072. return m.AddedChunkIndex()
  2073. }
  2074. return nil, false
  2075. }
  2076. // AddField adds the value to the field with the given name. It returns an error if
  2077. // the field is not defined in the schema, or if the type mismatched the field
  2078. // type.
  2079. func (m *AgentBaseMutation) AddField(name string, value ent.Value) error {
  2080. switch name {
  2081. case agentbase.FieldChunkIndex:
  2082. v, ok := value.(int64)
  2083. if !ok {
  2084. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2085. }
  2086. m.AddChunkIndex(v)
  2087. return nil
  2088. }
  2089. return fmt.Errorf("unknown AgentBase numeric field %s", name)
  2090. }
  2091. // ClearedFields returns all nullable fields that were cleared during this
  2092. // mutation.
  2093. func (m *AgentBaseMutation) ClearedFields() []string {
  2094. var fields []string
  2095. if m.FieldCleared(agentbase.FieldQ) {
  2096. fields = append(fields, agentbase.FieldQ)
  2097. }
  2098. if m.FieldCleared(agentbase.FieldA) {
  2099. fields = append(fields, agentbase.FieldA)
  2100. }
  2101. if m.FieldCleared(agentbase.FieldIndexes) {
  2102. fields = append(fields, agentbase.FieldIndexes)
  2103. }
  2104. if m.FieldCleared(agentbase.FieldDatasetID) {
  2105. fields = append(fields, agentbase.FieldDatasetID)
  2106. }
  2107. if m.FieldCleared(agentbase.FieldCollectionID) {
  2108. fields = append(fields, agentbase.FieldCollectionID)
  2109. }
  2110. if m.FieldCleared(agentbase.FieldSourceName) {
  2111. fields = append(fields, agentbase.FieldSourceName)
  2112. }
  2113. if m.FieldCleared(agentbase.FieldCanWrite) {
  2114. fields = append(fields, agentbase.FieldCanWrite)
  2115. }
  2116. if m.FieldCleared(agentbase.FieldIsOwner) {
  2117. fields = append(fields, agentbase.FieldIsOwner)
  2118. }
  2119. return fields
  2120. }
  2121. // FieldCleared returns a boolean indicating if a field with the given name was
  2122. // cleared in this mutation.
  2123. func (m *AgentBaseMutation) FieldCleared(name string) bool {
  2124. _, ok := m.clearedFields[name]
  2125. return ok
  2126. }
  2127. // ClearField clears the value of the field with the given name. It returns an
  2128. // error if the field is not defined in the schema.
  2129. func (m *AgentBaseMutation) ClearField(name string) error {
  2130. switch name {
  2131. case agentbase.FieldQ:
  2132. m.ClearQ()
  2133. return nil
  2134. case agentbase.FieldA:
  2135. m.ClearA()
  2136. return nil
  2137. case agentbase.FieldIndexes:
  2138. m.ClearIndexes()
  2139. return nil
  2140. case agentbase.FieldDatasetID:
  2141. m.ClearDatasetID()
  2142. return nil
  2143. case agentbase.FieldCollectionID:
  2144. m.ClearCollectionID()
  2145. return nil
  2146. case agentbase.FieldSourceName:
  2147. m.ClearSourceName()
  2148. return nil
  2149. case agentbase.FieldCanWrite:
  2150. m.ClearCanWrite()
  2151. return nil
  2152. case agentbase.FieldIsOwner:
  2153. m.ClearIsOwner()
  2154. return nil
  2155. }
  2156. return fmt.Errorf("unknown AgentBase nullable field %s", name)
  2157. }
  2158. // ResetField resets all changes in the mutation for the field with the given name.
  2159. // It returns an error if the field is not defined in the schema.
  2160. func (m *AgentBaseMutation) ResetField(name string) error {
  2161. switch name {
  2162. case agentbase.FieldQ:
  2163. m.ResetQ()
  2164. return nil
  2165. case agentbase.FieldA:
  2166. m.ResetA()
  2167. return nil
  2168. case agentbase.FieldChunkIndex:
  2169. m.ResetChunkIndex()
  2170. return nil
  2171. case agentbase.FieldIndexes:
  2172. m.ResetIndexes()
  2173. return nil
  2174. case agentbase.FieldDatasetID:
  2175. m.ResetDatasetID()
  2176. return nil
  2177. case agentbase.FieldCollectionID:
  2178. m.ResetCollectionID()
  2179. return nil
  2180. case agentbase.FieldSourceName:
  2181. m.ResetSourceName()
  2182. return nil
  2183. case agentbase.FieldCanWrite:
  2184. m.ResetCanWrite()
  2185. return nil
  2186. case agentbase.FieldIsOwner:
  2187. m.ResetIsOwner()
  2188. return nil
  2189. }
  2190. return fmt.Errorf("unknown AgentBase field %s", name)
  2191. }
  2192. // AddedEdges returns all edge names that were set/added in this mutation.
  2193. func (m *AgentBaseMutation) AddedEdges() []string {
  2194. edges := make([]string, 0, 1)
  2195. if m.wx_agent != nil {
  2196. edges = append(edges, agentbase.EdgeWxAgent)
  2197. }
  2198. return edges
  2199. }
  2200. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  2201. // name in this mutation.
  2202. func (m *AgentBaseMutation) AddedIDs(name string) []ent.Value {
  2203. switch name {
  2204. case agentbase.EdgeWxAgent:
  2205. ids := make([]ent.Value, 0, len(m.wx_agent))
  2206. for id := range m.wx_agent {
  2207. ids = append(ids, id)
  2208. }
  2209. return ids
  2210. }
  2211. return nil
  2212. }
  2213. // RemovedEdges returns all edge names that were removed in this mutation.
  2214. func (m *AgentBaseMutation) RemovedEdges() []string {
  2215. edges := make([]string, 0, 1)
  2216. if m.removedwx_agent != nil {
  2217. edges = append(edges, agentbase.EdgeWxAgent)
  2218. }
  2219. return edges
  2220. }
  2221. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  2222. // the given name in this mutation.
  2223. func (m *AgentBaseMutation) RemovedIDs(name string) []ent.Value {
  2224. switch name {
  2225. case agentbase.EdgeWxAgent:
  2226. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  2227. for id := range m.removedwx_agent {
  2228. ids = append(ids, id)
  2229. }
  2230. return ids
  2231. }
  2232. return nil
  2233. }
  2234. // ClearedEdges returns all edge names that were cleared in this mutation.
  2235. func (m *AgentBaseMutation) ClearedEdges() []string {
  2236. edges := make([]string, 0, 1)
  2237. if m.clearedwx_agent {
  2238. edges = append(edges, agentbase.EdgeWxAgent)
  2239. }
  2240. return edges
  2241. }
  2242. // EdgeCleared returns a boolean which indicates if the edge with the given name
  2243. // was cleared in this mutation.
  2244. func (m *AgentBaseMutation) EdgeCleared(name string) bool {
  2245. switch name {
  2246. case agentbase.EdgeWxAgent:
  2247. return m.clearedwx_agent
  2248. }
  2249. return false
  2250. }
  2251. // ClearEdge clears the value of the edge with the given name. It returns an error
  2252. // if that edge is not defined in the schema.
  2253. func (m *AgentBaseMutation) ClearEdge(name string) error {
  2254. switch name {
  2255. }
  2256. return fmt.Errorf("unknown AgentBase unique edge %s", name)
  2257. }
  2258. // ResetEdge resets all changes to the edge with the given name in this mutation.
  2259. // It returns an error if the edge is not defined in the schema.
  2260. func (m *AgentBaseMutation) ResetEdge(name string) error {
  2261. switch name {
  2262. case agentbase.EdgeWxAgent:
  2263. m.ResetWxAgent()
  2264. return nil
  2265. }
  2266. return fmt.Errorf("unknown AgentBase edge %s", name)
  2267. }
  2268. // AliyunAvatarMutation represents an operation that mutates the AliyunAvatar nodes in the graph.
  2269. type AliyunAvatarMutation struct {
  2270. config
  2271. op Op
  2272. typ string
  2273. id *uint64
  2274. created_at *time.Time
  2275. updated_at *time.Time
  2276. deleted_at *time.Time
  2277. user_id *uint64
  2278. adduser_id *int64
  2279. biz_id *string
  2280. access_key_id *string
  2281. access_key_secret *string
  2282. app_id *string
  2283. tenant_id *uint64
  2284. addtenant_id *int64
  2285. response *string
  2286. token *string
  2287. session_id *string
  2288. clearedFields map[string]struct{}
  2289. done bool
  2290. oldValue func(context.Context) (*AliyunAvatar, error)
  2291. predicates []predicate.AliyunAvatar
  2292. }
  2293. var _ ent.Mutation = (*AliyunAvatarMutation)(nil)
  2294. // aliyunavatarOption allows management of the mutation configuration using functional options.
  2295. type aliyunavatarOption func(*AliyunAvatarMutation)
  2296. // newAliyunAvatarMutation creates new mutation for the AliyunAvatar entity.
  2297. func newAliyunAvatarMutation(c config, op Op, opts ...aliyunavatarOption) *AliyunAvatarMutation {
  2298. m := &AliyunAvatarMutation{
  2299. config: c,
  2300. op: op,
  2301. typ: TypeAliyunAvatar,
  2302. clearedFields: make(map[string]struct{}),
  2303. }
  2304. for _, opt := range opts {
  2305. opt(m)
  2306. }
  2307. return m
  2308. }
  2309. // withAliyunAvatarID sets the ID field of the mutation.
  2310. func withAliyunAvatarID(id uint64) aliyunavatarOption {
  2311. return func(m *AliyunAvatarMutation) {
  2312. var (
  2313. err error
  2314. once sync.Once
  2315. value *AliyunAvatar
  2316. )
  2317. m.oldValue = func(ctx context.Context) (*AliyunAvatar, error) {
  2318. once.Do(func() {
  2319. if m.done {
  2320. err = errors.New("querying old values post mutation is not allowed")
  2321. } else {
  2322. value, err = m.Client().AliyunAvatar.Get(ctx, id)
  2323. }
  2324. })
  2325. return value, err
  2326. }
  2327. m.id = &id
  2328. }
  2329. }
  2330. // withAliyunAvatar sets the old AliyunAvatar of the mutation.
  2331. func withAliyunAvatar(node *AliyunAvatar) aliyunavatarOption {
  2332. return func(m *AliyunAvatarMutation) {
  2333. m.oldValue = func(context.Context) (*AliyunAvatar, error) {
  2334. return node, nil
  2335. }
  2336. m.id = &node.ID
  2337. }
  2338. }
  2339. // Client returns a new `ent.Client` from the mutation. If the mutation was
  2340. // executed in a transaction (ent.Tx), a transactional client is returned.
  2341. func (m AliyunAvatarMutation) Client() *Client {
  2342. client := &Client{config: m.config}
  2343. client.init()
  2344. return client
  2345. }
  2346. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  2347. // it returns an error otherwise.
  2348. func (m AliyunAvatarMutation) Tx() (*Tx, error) {
  2349. if _, ok := m.driver.(*txDriver); !ok {
  2350. return nil, errors.New("ent: mutation is not running in a transaction")
  2351. }
  2352. tx := &Tx{config: m.config}
  2353. tx.init()
  2354. return tx, nil
  2355. }
  2356. // SetID sets the value of the id field. Note that this
  2357. // operation is only accepted on creation of AliyunAvatar entities.
  2358. func (m *AliyunAvatarMutation) SetID(id uint64) {
  2359. m.id = &id
  2360. }
  2361. // ID returns the ID value in the mutation. Note that the ID is only available
  2362. // if it was provided to the builder or after it was returned from the database.
  2363. func (m *AliyunAvatarMutation) ID() (id uint64, exists bool) {
  2364. if m.id == nil {
  2365. return
  2366. }
  2367. return *m.id, true
  2368. }
  2369. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  2370. // That means, if the mutation is applied within a transaction with an isolation level such
  2371. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  2372. // or updated by the mutation.
  2373. func (m *AliyunAvatarMutation) IDs(ctx context.Context) ([]uint64, error) {
  2374. switch {
  2375. case m.op.Is(OpUpdateOne | OpDeleteOne):
  2376. id, exists := m.ID()
  2377. if exists {
  2378. return []uint64{id}, nil
  2379. }
  2380. fallthrough
  2381. case m.op.Is(OpUpdate | OpDelete):
  2382. return m.Client().AliyunAvatar.Query().Where(m.predicates...).IDs(ctx)
  2383. default:
  2384. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  2385. }
  2386. }
  2387. // SetCreatedAt sets the "created_at" field.
  2388. func (m *AliyunAvatarMutation) SetCreatedAt(t time.Time) {
  2389. m.created_at = &t
  2390. }
  2391. // CreatedAt returns the value of the "created_at" field in the mutation.
  2392. func (m *AliyunAvatarMutation) CreatedAt() (r time.Time, exists bool) {
  2393. v := m.created_at
  2394. if v == nil {
  2395. return
  2396. }
  2397. return *v, true
  2398. }
  2399. // OldCreatedAt returns the old "created_at" field's value of the AliyunAvatar entity.
  2400. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2401. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2402. func (m *AliyunAvatarMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  2403. if !m.op.Is(OpUpdateOne) {
  2404. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  2405. }
  2406. if m.id == nil || m.oldValue == nil {
  2407. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  2408. }
  2409. oldValue, err := m.oldValue(ctx)
  2410. if err != nil {
  2411. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  2412. }
  2413. return oldValue.CreatedAt, nil
  2414. }
  2415. // ResetCreatedAt resets all changes to the "created_at" field.
  2416. func (m *AliyunAvatarMutation) ResetCreatedAt() {
  2417. m.created_at = nil
  2418. }
  2419. // SetUpdatedAt sets the "updated_at" field.
  2420. func (m *AliyunAvatarMutation) SetUpdatedAt(t time.Time) {
  2421. m.updated_at = &t
  2422. }
  2423. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  2424. func (m *AliyunAvatarMutation) UpdatedAt() (r time.Time, exists bool) {
  2425. v := m.updated_at
  2426. if v == nil {
  2427. return
  2428. }
  2429. return *v, true
  2430. }
  2431. // OldUpdatedAt returns the old "updated_at" field's value of the AliyunAvatar entity.
  2432. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2433. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2434. func (m *AliyunAvatarMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  2435. if !m.op.Is(OpUpdateOne) {
  2436. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  2437. }
  2438. if m.id == nil || m.oldValue == nil {
  2439. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  2440. }
  2441. oldValue, err := m.oldValue(ctx)
  2442. if err != nil {
  2443. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  2444. }
  2445. return oldValue.UpdatedAt, nil
  2446. }
  2447. // ResetUpdatedAt resets all changes to the "updated_at" field.
  2448. func (m *AliyunAvatarMutation) ResetUpdatedAt() {
  2449. m.updated_at = nil
  2450. }
  2451. // SetDeletedAt sets the "deleted_at" field.
  2452. func (m *AliyunAvatarMutation) SetDeletedAt(t time.Time) {
  2453. m.deleted_at = &t
  2454. }
  2455. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  2456. func (m *AliyunAvatarMutation) DeletedAt() (r time.Time, exists bool) {
  2457. v := m.deleted_at
  2458. if v == nil {
  2459. return
  2460. }
  2461. return *v, true
  2462. }
  2463. // OldDeletedAt returns the old "deleted_at" field's value of the AliyunAvatar entity.
  2464. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2465. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2466. func (m *AliyunAvatarMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  2467. if !m.op.Is(OpUpdateOne) {
  2468. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  2469. }
  2470. if m.id == nil || m.oldValue == nil {
  2471. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  2472. }
  2473. oldValue, err := m.oldValue(ctx)
  2474. if err != nil {
  2475. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  2476. }
  2477. return oldValue.DeletedAt, nil
  2478. }
  2479. // ClearDeletedAt clears the value of the "deleted_at" field.
  2480. func (m *AliyunAvatarMutation) ClearDeletedAt() {
  2481. m.deleted_at = nil
  2482. m.clearedFields[aliyunavatar.FieldDeletedAt] = struct{}{}
  2483. }
  2484. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  2485. func (m *AliyunAvatarMutation) DeletedAtCleared() bool {
  2486. _, ok := m.clearedFields[aliyunavatar.FieldDeletedAt]
  2487. return ok
  2488. }
  2489. // ResetDeletedAt resets all changes to the "deleted_at" field.
  2490. func (m *AliyunAvatarMutation) ResetDeletedAt() {
  2491. m.deleted_at = nil
  2492. delete(m.clearedFields, aliyunavatar.FieldDeletedAt)
  2493. }
  2494. // SetUserID sets the "user_id" field.
  2495. func (m *AliyunAvatarMutation) SetUserID(u uint64) {
  2496. m.user_id = &u
  2497. m.adduser_id = nil
  2498. }
  2499. // UserID returns the value of the "user_id" field in the mutation.
  2500. func (m *AliyunAvatarMutation) UserID() (r uint64, exists bool) {
  2501. v := m.user_id
  2502. if v == nil {
  2503. return
  2504. }
  2505. return *v, true
  2506. }
  2507. // OldUserID returns the old "user_id" field's value of the AliyunAvatar entity.
  2508. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2509. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2510. func (m *AliyunAvatarMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  2511. if !m.op.Is(OpUpdateOne) {
  2512. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  2513. }
  2514. if m.id == nil || m.oldValue == nil {
  2515. return v, errors.New("OldUserID requires an ID field in the mutation")
  2516. }
  2517. oldValue, err := m.oldValue(ctx)
  2518. if err != nil {
  2519. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  2520. }
  2521. return oldValue.UserID, nil
  2522. }
  2523. // AddUserID adds u to the "user_id" field.
  2524. func (m *AliyunAvatarMutation) AddUserID(u int64) {
  2525. if m.adduser_id != nil {
  2526. *m.adduser_id += u
  2527. } else {
  2528. m.adduser_id = &u
  2529. }
  2530. }
  2531. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  2532. func (m *AliyunAvatarMutation) AddedUserID() (r int64, exists bool) {
  2533. v := m.adduser_id
  2534. if v == nil {
  2535. return
  2536. }
  2537. return *v, true
  2538. }
  2539. // ResetUserID resets all changes to the "user_id" field.
  2540. func (m *AliyunAvatarMutation) ResetUserID() {
  2541. m.user_id = nil
  2542. m.adduser_id = nil
  2543. }
  2544. // SetBizID sets the "biz_id" field.
  2545. func (m *AliyunAvatarMutation) SetBizID(s string) {
  2546. m.biz_id = &s
  2547. }
  2548. // BizID returns the value of the "biz_id" field in the mutation.
  2549. func (m *AliyunAvatarMutation) BizID() (r string, exists bool) {
  2550. v := m.biz_id
  2551. if v == nil {
  2552. return
  2553. }
  2554. return *v, true
  2555. }
  2556. // OldBizID returns the old "biz_id" field's value of the AliyunAvatar entity.
  2557. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2558. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2559. func (m *AliyunAvatarMutation) OldBizID(ctx context.Context) (v string, err error) {
  2560. if !m.op.Is(OpUpdateOne) {
  2561. return v, errors.New("OldBizID is only allowed on UpdateOne operations")
  2562. }
  2563. if m.id == nil || m.oldValue == nil {
  2564. return v, errors.New("OldBizID requires an ID field in the mutation")
  2565. }
  2566. oldValue, err := m.oldValue(ctx)
  2567. if err != nil {
  2568. return v, fmt.Errorf("querying old value for OldBizID: %w", err)
  2569. }
  2570. return oldValue.BizID, nil
  2571. }
  2572. // ResetBizID resets all changes to the "biz_id" field.
  2573. func (m *AliyunAvatarMutation) ResetBizID() {
  2574. m.biz_id = nil
  2575. }
  2576. // SetAccessKeyID sets the "access_key_id" field.
  2577. func (m *AliyunAvatarMutation) SetAccessKeyID(s string) {
  2578. m.access_key_id = &s
  2579. }
  2580. // AccessKeyID returns the value of the "access_key_id" field in the mutation.
  2581. func (m *AliyunAvatarMutation) AccessKeyID() (r string, exists bool) {
  2582. v := m.access_key_id
  2583. if v == nil {
  2584. return
  2585. }
  2586. return *v, true
  2587. }
  2588. // OldAccessKeyID returns the old "access_key_id" field's value of the AliyunAvatar entity.
  2589. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2590. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2591. func (m *AliyunAvatarMutation) OldAccessKeyID(ctx context.Context) (v string, err error) {
  2592. if !m.op.Is(OpUpdateOne) {
  2593. return v, errors.New("OldAccessKeyID is only allowed on UpdateOne operations")
  2594. }
  2595. if m.id == nil || m.oldValue == nil {
  2596. return v, errors.New("OldAccessKeyID requires an ID field in the mutation")
  2597. }
  2598. oldValue, err := m.oldValue(ctx)
  2599. if err != nil {
  2600. return v, fmt.Errorf("querying old value for OldAccessKeyID: %w", err)
  2601. }
  2602. return oldValue.AccessKeyID, nil
  2603. }
  2604. // ResetAccessKeyID resets all changes to the "access_key_id" field.
  2605. func (m *AliyunAvatarMutation) ResetAccessKeyID() {
  2606. m.access_key_id = nil
  2607. }
  2608. // SetAccessKeySecret sets the "access_key_secret" field.
  2609. func (m *AliyunAvatarMutation) SetAccessKeySecret(s string) {
  2610. m.access_key_secret = &s
  2611. }
  2612. // AccessKeySecret returns the value of the "access_key_secret" field in the mutation.
  2613. func (m *AliyunAvatarMutation) AccessKeySecret() (r string, exists bool) {
  2614. v := m.access_key_secret
  2615. if v == nil {
  2616. return
  2617. }
  2618. return *v, true
  2619. }
  2620. // OldAccessKeySecret returns the old "access_key_secret" field's value of the AliyunAvatar entity.
  2621. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2622. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2623. func (m *AliyunAvatarMutation) OldAccessKeySecret(ctx context.Context) (v string, err error) {
  2624. if !m.op.Is(OpUpdateOne) {
  2625. return v, errors.New("OldAccessKeySecret is only allowed on UpdateOne operations")
  2626. }
  2627. if m.id == nil || m.oldValue == nil {
  2628. return v, errors.New("OldAccessKeySecret requires an ID field in the mutation")
  2629. }
  2630. oldValue, err := m.oldValue(ctx)
  2631. if err != nil {
  2632. return v, fmt.Errorf("querying old value for OldAccessKeySecret: %w", err)
  2633. }
  2634. return oldValue.AccessKeySecret, nil
  2635. }
  2636. // ResetAccessKeySecret resets all changes to the "access_key_secret" field.
  2637. func (m *AliyunAvatarMutation) ResetAccessKeySecret() {
  2638. m.access_key_secret = nil
  2639. }
  2640. // SetAppID sets the "app_id" field.
  2641. func (m *AliyunAvatarMutation) SetAppID(s string) {
  2642. m.app_id = &s
  2643. }
  2644. // AppID returns the value of the "app_id" field in the mutation.
  2645. func (m *AliyunAvatarMutation) AppID() (r string, exists bool) {
  2646. v := m.app_id
  2647. if v == nil {
  2648. return
  2649. }
  2650. return *v, true
  2651. }
  2652. // OldAppID returns the old "app_id" field's value of the AliyunAvatar entity.
  2653. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2654. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2655. func (m *AliyunAvatarMutation) OldAppID(ctx context.Context) (v string, err error) {
  2656. if !m.op.Is(OpUpdateOne) {
  2657. return v, errors.New("OldAppID is only allowed on UpdateOne operations")
  2658. }
  2659. if m.id == nil || m.oldValue == nil {
  2660. return v, errors.New("OldAppID requires an ID field in the mutation")
  2661. }
  2662. oldValue, err := m.oldValue(ctx)
  2663. if err != nil {
  2664. return v, fmt.Errorf("querying old value for OldAppID: %w", err)
  2665. }
  2666. return oldValue.AppID, nil
  2667. }
  2668. // ClearAppID clears the value of the "app_id" field.
  2669. func (m *AliyunAvatarMutation) ClearAppID() {
  2670. m.app_id = nil
  2671. m.clearedFields[aliyunavatar.FieldAppID] = struct{}{}
  2672. }
  2673. // AppIDCleared returns if the "app_id" field was cleared in this mutation.
  2674. func (m *AliyunAvatarMutation) AppIDCleared() bool {
  2675. _, ok := m.clearedFields[aliyunavatar.FieldAppID]
  2676. return ok
  2677. }
  2678. // ResetAppID resets all changes to the "app_id" field.
  2679. func (m *AliyunAvatarMutation) ResetAppID() {
  2680. m.app_id = nil
  2681. delete(m.clearedFields, aliyunavatar.FieldAppID)
  2682. }
  2683. // SetTenantID sets the "tenant_id" field.
  2684. func (m *AliyunAvatarMutation) SetTenantID(u uint64) {
  2685. m.tenant_id = &u
  2686. m.addtenant_id = nil
  2687. }
  2688. // TenantID returns the value of the "tenant_id" field in the mutation.
  2689. func (m *AliyunAvatarMutation) TenantID() (r uint64, exists bool) {
  2690. v := m.tenant_id
  2691. if v == nil {
  2692. return
  2693. }
  2694. return *v, true
  2695. }
  2696. // OldTenantID returns the old "tenant_id" field's value of the AliyunAvatar entity.
  2697. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2698. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2699. func (m *AliyunAvatarMutation) OldTenantID(ctx context.Context) (v uint64, err error) {
  2700. if !m.op.Is(OpUpdateOne) {
  2701. return v, errors.New("OldTenantID is only allowed on UpdateOne operations")
  2702. }
  2703. if m.id == nil || m.oldValue == nil {
  2704. return v, errors.New("OldTenantID requires an ID field in the mutation")
  2705. }
  2706. oldValue, err := m.oldValue(ctx)
  2707. if err != nil {
  2708. return v, fmt.Errorf("querying old value for OldTenantID: %w", err)
  2709. }
  2710. return oldValue.TenantID, nil
  2711. }
  2712. // AddTenantID adds u to the "tenant_id" field.
  2713. func (m *AliyunAvatarMutation) AddTenantID(u int64) {
  2714. if m.addtenant_id != nil {
  2715. *m.addtenant_id += u
  2716. } else {
  2717. m.addtenant_id = &u
  2718. }
  2719. }
  2720. // AddedTenantID returns the value that was added to the "tenant_id" field in this mutation.
  2721. func (m *AliyunAvatarMutation) AddedTenantID() (r int64, exists bool) {
  2722. v := m.addtenant_id
  2723. if v == nil {
  2724. return
  2725. }
  2726. return *v, true
  2727. }
  2728. // ResetTenantID resets all changes to the "tenant_id" field.
  2729. func (m *AliyunAvatarMutation) ResetTenantID() {
  2730. m.tenant_id = nil
  2731. m.addtenant_id = nil
  2732. }
  2733. // SetResponse sets the "response" field.
  2734. func (m *AliyunAvatarMutation) SetResponse(s string) {
  2735. m.response = &s
  2736. }
  2737. // Response returns the value of the "response" field in the mutation.
  2738. func (m *AliyunAvatarMutation) Response() (r string, exists bool) {
  2739. v := m.response
  2740. if v == nil {
  2741. return
  2742. }
  2743. return *v, true
  2744. }
  2745. // OldResponse returns the old "response" field's value of the AliyunAvatar entity.
  2746. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2747. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2748. func (m *AliyunAvatarMutation) OldResponse(ctx context.Context) (v string, err error) {
  2749. if !m.op.Is(OpUpdateOne) {
  2750. return v, errors.New("OldResponse is only allowed on UpdateOne operations")
  2751. }
  2752. if m.id == nil || m.oldValue == nil {
  2753. return v, errors.New("OldResponse requires an ID field in the mutation")
  2754. }
  2755. oldValue, err := m.oldValue(ctx)
  2756. if err != nil {
  2757. return v, fmt.Errorf("querying old value for OldResponse: %w", err)
  2758. }
  2759. return oldValue.Response, nil
  2760. }
  2761. // ResetResponse resets all changes to the "response" field.
  2762. func (m *AliyunAvatarMutation) ResetResponse() {
  2763. m.response = nil
  2764. }
  2765. // SetToken sets the "token" field.
  2766. func (m *AliyunAvatarMutation) SetToken(s string) {
  2767. m.token = &s
  2768. }
  2769. // Token returns the value of the "token" field in the mutation.
  2770. func (m *AliyunAvatarMutation) Token() (r string, exists bool) {
  2771. v := m.token
  2772. if v == nil {
  2773. return
  2774. }
  2775. return *v, true
  2776. }
  2777. // OldToken returns the old "token" field's value of the AliyunAvatar entity.
  2778. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2779. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2780. func (m *AliyunAvatarMutation) OldToken(ctx context.Context) (v string, err error) {
  2781. if !m.op.Is(OpUpdateOne) {
  2782. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  2783. }
  2784. if m.id == nil || m.oldValue == nil {
  2785. return v, errors.New("OldToken requires an ID field in the mutation")
  2786. }
  2787. oldValue, err := m.oldValue(ctx)
  2788. if err != nil {
  2789. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  2790. }
  2791. return oldValue.Token, nil
  2792. }
  2793. // ResetToken resets all changes to the "token" field.
  2794. func (m *AliyunAvatarMutation) ResetToken() {
  2795. m.token = nil
  2796. }
  2797. // SetSessionID sets the "session_id" field.
  2798. func (m *AliyunAvatarMutation) SetSessionID(s string) {
  2799. m.session_id = &s
  2800. }
  2801. // SessionID returns the value of the "session_id" field in the mutation.
  2802. func (m *AliyunAvatarMutation) SessionID() (r string, exists bool) {
  2803. v := m.session_id
  2804. if v == nil {
  2805. return
  2806. }
  2807. return *v, true
  2808. }
  2809. // OldSessionID returns the old "session_id" field's value of the AliyunAvatar entity.
  2810. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2811. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2812. func (m *AliyunAvatarMutation) OldSessionID(ctx context.Context) (v string, err error) {
  2813. if !m.op.Is(OpUpdateOne) {
  2814. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  2815. }
  2816. if m.id == nil || m.oldValue == nil {
  2817. return v, errors.New("OldSessionID requires an ID field in the mutation")
  2818. }
  2819. oldValue, err := m.oldValue(ctx)
  2820. if err != nil {
  2821. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  2822. }
  2823. return oldValue.SessionID, nil
  2824. }
  2825. // ResetSessionID resets all changes to the "session_id" field.
  2826. func (m *AliyunAvatarMutation) ResetSessionID() {
  2827. m.session_id = nil
  2828. }
  2829. // Where appends a list predicates to the AliyunAvatarMutation builder.
  2830. func (m *AliyunAvatarMutation) Where(ps ...predicate.AliyunAvatar) {
  2831. m.predicates = append(m.predicates, ps...)
  2832. }
  2833. // WhereP appends storage-level predicates to the AliyunAvatarMutation builder. Using this method,
  2834. // users can use type-assertion to append predicates that do not depend on any generated package.
  2835. func (m *AliyunAvatarMutation) WhereP(ps ...func(*sql.Selector)) {
  2836. p := make([]predicate.AliyunAvatar, len(ps))
  2837. for i := range ps {
  2838. p[i] = ps[i]
  2839. }
  2840. m.Where(p...)
  2841. }
  2842. // Op returns the operation name.
  2843. func (m *AliyunAvatarMutation) Op() Op {
  2844. return m.op
  2845. }
  2846. // SetOp allows setting the mutation operation.
  2847. func (m *AliyunAvatarMutation) SetOp(op Op) {
  2848. m.op = op
  2849. }
  2850. // Type returns the node type of this mutation (AliyunAvatar).
  2851. func (m *AliyunAvatarMutation) Type() string {
  2852. return m.typ
  2853. }
  2854. // Fields returns all fields that were changed during this mutation. Note that in
  2855. // order to get all numeric fields that were incremented/decremented, call
  2856. // AddedFields().
  2857. func (m *AliyunAvatarMutation) Fields() []string {
  2858. fields := make([]string, 0, 12)
  2859. if m.created_at != nil {
  2860. fields = append(fields, aliyunavatar.FieldCreatedAt)
  2861. }
  2862. if m.updated_at != nil {
  2863. fields = append(fields, aliyunavatar.FieldUpdatedAt)
  2864. }
  2865. if m.deleted_at != nil {
  2866. fields = append(fields, aliyunavatar.FieldDeletedAt)
  2867. }
  2868. if m.user_id != nil {
  2869. fields = append(fields, aliyunavatar.FieldUserID)
  2870. }
  2871. if m.biz_id != nil {
  2872. fields = append(fields, aliyunavatar.FieldBizID)
  2873. }
  2874. if m.access_key_id != nil {
  2875. fields = append(fields, aliyunavatar.FieldAccessKeyID)
  2876. }
  2877. if m.access_key_secret != nil {
  2878. fields = append(fields, aliyunavatar.FieldAccessKeySecret)
  2879. }
  2880. if m.app_id != nil {
  2881. fields = append(fields, aliyunavatar.FieldAppID)
  2882. }
  2883. if m.tenant_id != nil {
  2884. fields = append(fields, aliyunavatar.FieldTenantID)
  2885. }
  2886. if m.response != nil {
  2887. fields = append(fields, aliyunavatar.FieldResponse)
  2888. }
  2889. if m.token != nil {
  2890. fields = append(fields, aliyunavatar.FieldToken)
  2891. }
  2892. if m.session_id != nil {
  2893. fields = append(fields, aliyunavatar.FieldSessionID)
  2894. }
  2895. return fields
  2896. }
  2897. // Field returns the value of a field with the given name. The second boolean
  2898. // return value indicates that this field was not set, or was not defined in the
  2899. // schema.
  2900. func (m *AliyunAvatarMutation) Field(name string) (ent.Value, bool) {
  2901. switch name {
  2902. case aliyunavatar.FieldCreatedAt:
  2903. return m.CreatedAt()
  2904. case aliyunavatar.FieldUpdatedAt:
  2905. return m.UpdatedAt()
  2906. case aliyunavatar.FieldDeletedAt:
  2907. return m.DeletedAt()
  2908. case aliyunavatar.FieldUserID:
  2909. return m.UserID()
  2910. case aliyunavatar.FieldBizID:
  2911. return m.BizID()
  2912. case aliyunavatar.FieldAccessKeyID:
  2913. return m.AccessKeyID()
  2914. case aliyunavatar.FieldAccessKeySecret:
  2915. return m.AccessKeySecret()
  2916. case aliyunavatar.FieldAppID:
  2917. return m.AppID()
  2918. case aliyunavatar.FieldTenantID:
  2919. return m.TenantID()
  2920. case aliyunavatar.FieldResponse:
  2921. return m.Response()
  2922. case aliyunavatar.FieldToken:
  2923. return m.Token()
  2924. case aliyunavatar.FieldSessionID:
  2925. return m.SessionID()
  2926. }
  2927. return nil, false
  2928. }
  2929. // OldField returns the old value of the field from the database. An error is
  2930. // returned if the mutation operation is not UpdateOne, or the query to the
  2931. // database failed.
  2932. func (m *AliyunAvatarMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  2933. switch name {
  2934. case aliyunavatar.FieldCreatedAt:
  2935. return m.OldCreatedAt(ctx)
  2936. case aliyunavatar.FieldUpdatedAt:
  2937. return m.OldUpdatedAt(ctx)
  2938. case aliyunavatar.FieldDeletedAt:
  2939. return m.OldDeletedAt(ctx)
  2940. case aliyunavatar.FieldUserID:
  2941. return m.OldUserID(ctx)
  2942. case aliyunavatar.FieldBizID:
  2943. return m.OldBizID(ctx)
  2944. case aliyunavatar.FieldAccessKeyID:
  2945. return m.OldAccessKeyID(ctx)
  2946. case aliyunavatar.FieldAccessKeySecret:
  2947. return m.OldAccessKeySecret(ctx)
  2948. case aliyunavatar.FieldAppID:
  2949. return m.OldAppID(ctx)
  2950. case aliyunavatar.FieldTenantID:
  2951. return m.OldTenantID(ctx)
  2952. case aliyunavatar.FieldResponse:
  2953. return m.OldResponse(ctx)
  2954. case aliyunavatar.FieldToken:
  2955. return m.OldToken(ctx)
  2956. case aliyunavatar.FieldSessionID:
  2957. return m.OldSessionID(ctx)
  2958. }
  2959. return nil, fmt.Errorf("unknown AliyunAvatar field %s", name)
  2960. }
  2961. // SetField sets the value of a field with the given name. It returns an error if
  2962. // the field is not defined in the schema, or if the type mismatched the field
  2963. // type.
  2964. func (m *AliyunAvatarMutation) SetField(name string, value ent.Value) error {
  2965. switch name {
  2966. case aliyunavatar.FieldCreatedAt:
  2967. v, ok := value.(time.Time)
  2968. if !ok {
  2969. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2970. }
  2971. m.SetCreatedAt(v)
  2972. return nil
  2973. case aliyunavatar.FieldUpdatedAt:
  2974. v, ok := value.(time.Time)
  2975. if !ok {
  2976. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2977. }
  2978. m.SetUpdatedAt(v)
  2979. return nil
  2980. case aliyunavatar.FieldDeletedAt:
  2981. v, ok := value.(time.Time)
  2982. if !ok {
  2983. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2984. }
  2985. m.SetDeletedAt(v)
  2986. return nil
  2987. case aliyunavatar.FieldUserID:
  2988. v, ok := value.(uint64)
  2989. if !ok {
  2990. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2991. }
  2992. m.SetUserID(v)
  2993. return nil
  2994. case aliyunavatar.FieldBizID:
  2995. v, ok := value.(string)
  2996. if !ok {
  2997. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2998. }
  2999. m.SetBizID(v)
  3000. return nil
  3001. case aliyunavatar.FieldAccessKeyID:
  3002. v, ok := value.(string)
  3003. if !ok {
  3004. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3005. }
  3006. m.SetAccessKeyID(v)
  3007. return nil
  3008. case aliyunavatar.FieldAccessKeySecret:
  3009. v, ok := value.(string)
  3010. if !ok {
  3011. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3012. }
  3013. m.SetAccessKeySecret(v)
  3014. return nil
  3015. case aliyunavatar.FieldAppID:
  3016. v, ok := value.(string)
  3017. if !ok {
  3018. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3019. }
  3020. m.SetAppID(v)
  3021. return nil
  3022. case aliyunavatar.FieldTenantID:
  3023. v, ok := value.(uint64)
  3024. if !ok {
  3025. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3026. }
  3027. m.SetTenantID(v)
  3028. return nil
  3029. case aliyunavatar.FieldResponse:
  3030. v, ok := value.(string)
  3031. if !ok {
  3032. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3033. }
  3034. m.SetResponse(v)
  3035. return nil
  3036. case aliyunavatar.FieldToken:
  3037. v, ok := value.(string)
  3038. if !ok {
  3039. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3040. }
  3041. m.SetToken(v)
  3042. return nil
  3043. case aliyunavatar.FieldSessionID:
  3044. v, ok := value.(string)
  3045. if !ok {
  3046. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3047. }
  3048. m.SetSessionID(v)
  3049. return nil
  3050. }
  3051. return fmt.Errorf("unknown AliyunAvatar field %s", name)
  3052. }
  3053. // AddedFields returns all numeric fields that were incremented/decremented during
  3054. // this mutation.
  3055. func (m *AliyunAvatarMutation) AddedFields() []string {
  3056. var fields []string
  3057. if m.adduser_id != nil {
  3058. fields = append(fields, aliyunavatar.FieldUserID)
  3059. }
  3060. if m.addtenant_id != nil {
  3061. fields = append(fields, aliyunavatar.FieldTenantID)
  3062. }
  3063. return fields
  3064. }
  3065. // AddedField returns the numeric value that was incremented/decremented on a field
  3066. // with the given name. The second boolean return value indicates that this field
  3067. // was not set, or was not defined in the schema.
  3068. func (m *AliyunAvatarMutation) AddedField(name string) (ent.Value, bool) {
  3069. switch name {
  3070. case aliyunavatar.FieldUserID:
  3071. return m.AddedUserID()
  3072. case aliyunavatar.FieldTenantID:
  3073. return m.AddedTenantID()
  3074. }
  3075. return nil, false
  3076. }
  3077. // AddField adds the value to the field with the given name. It returns an error if
  3078. // the field is not defined in the schema, or if the type mismatched the field
  3079. // type.
  3080. func (m *AliyunAvatarMutation) AddField(name string, value ent.Value) error {
  3081. switch name {
  3082. case aliyunavatar.FieldUserID:
  3083. v, ok := value.(int64)
  3084. if !ok {
  3085. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3086. }
  3087. m.AddUserID(v)
  3088. return nil
  3089. case aliyunavatar.FieldTenantID:
  3090. v, ok := value.(int64)
  3091. if !ok {
  3092. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3093. }
  3094. m.AddTenantID(v)
  3095. return nil
  3096. }
  3097. return fmt.Errorf("unknown AliyunAvatar numeric field %s", name)
  3098. }
  3099. // ClearedFields returns all nullable fields that were cleared during this
  3100. // mutation.
  3101. func (m *AliyunAvatarMutation) ClearedFields() []string {
  3102. var fields []string
  3103. if m.FieldCleared(aliyunavatar.FieldDeletedAt) {
  3104. fields = append(fields, aliyunavatar.FieldDeletedAt)
  3105. }
  3106. if m.FieldCleared(aliyunavatar.FieldAppID) {
  3107. fields = append(fields, aliyunavatar.FieldAppID)
  3108. }
  3109. return fields
  3110. }
  3111. // FieldCleared returns a boolean indicating if a field with the given name was
  3112. // cleared in this mutation.
  3113. func (m *AliyunAvatarMutation) FieldCleared(name string) bool {
  3114. _, ok := m.clearedFields[name]
  3115. return ok
  3116. }
  3117. // ClearField clears the value of the field with the given name. It returns an
  3118. // error if the field is not defined in the schema.
  3119. func (m *AliyunAvatarMutation) ClearField(name string) error {
  3120. switch name {
  3121. case aliyunavatar.FieldDeletedAt:
  3122. m.ClearDeletedAt()
  3123. return nil
  3124. case aliyunavatar.FieldAppID:
  3125. m.ClearAppID()
  3126. return nil
  3127. }
  3128. return fmt.Errorf("unknown AliyunAvatar nullable field %s", name)
  3129. }
  3130. // ResetField resets all changes in the mutation for the field with the given name.
  3131. // It returns an error if the field is not defined in the schema.
  3132. func (m *AliyunAvatarMutation) ResetField(name string) error {
  3133. switch name {
  3134. case aliyunavatar.FieldCreatedAt:
  3135. m.ResetCreatedAt()
  3136. return nil
  3137. case aliyunavatar.FieldUpdatedAt:
  3138. m.ResetUpdatedAt()
  3139. return nil
  3140. case aliyunavatar.FieldDeletedAt:
  3141. m.ResetDeletedAt()
  3142. return nil
  3143. case aliyunavatar.FieldUserID:
  3144. m.ResetUserID()
  3145. return nil
  3146. case aliyunavatar.FieldBizID:
  3147. m.ResetBizID()
  3148. return nil
  3149. case aliyunavatar.FieldAccessKeyID:
  3150. m.ResetAccessKeyID()
  3151. return nil
  3152. case aliyunavatar.FieldAccessKeySecret:
  3153. m.ResetAccessKeySecret()
  3154. return nil
  3155. case aliyunavatar.FieldAppID:
  3156. m.ResetAppID()
  3157. return nil
  3158. case aliyunavatar.FieldTenantID:
  3159. m.ResetTenantID()
  3160. return nil
  3161. case aliyunavatar.FieldResponse:
  3162. m.ResetResponse()
  3163. return nil
  3164. case aliyunavatar.FieldToken:
  3165. m.ResetToken()
  3166. return nil
  3167. case aliyunavatar.FieldSessionID:
  3168. m.ResetSessionID()
  3169. return nil
  3170. }
  3171. return fmt.Errorf("unknown AliyunAvatar field %s", name)
  3172. }
  3173. // AddedEdges returns all edge names that were set/added in this mutation.
  3174. func (m *AliyunAvatarMutation) AddedEdges() []string {
  3175. edges := make([]string, 0, 0)
  3176. return edges
  3177. }
  3178. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  3179. // name in this mutation.
  3180. func (m *AliyunAvatarMutation) AddedIDs(name string) []ent.Value {
  3181. return nil
  3182. }
  3183. // RemovedEdges returns all edge names that were removed in this mutation.
  3184. func (m *AliyunAvatarMutation) RemovedEdges() []string {
  3185. edges := make([]string, 0, 0)
  3186. return edges
  3187. }
  3188. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  3189. // the given name in this mutation.
  3190. func (m *AliyunAvatarMutation) RemovedIDs(name string) []ent.Value {
  3191. return nil
  3192. }
  3193. // ClearedEdges returns all edge names that were cleared in this mutation.
  3194. func (m *AliyunAvatarMutation) ClearedEdges() []string {
  3195. edges := make([]string, 0, 0)
  3196. return edges
  3197. }
  3198. // EdgeCleared returns a boolean which indicates if the edge with the given name
  3199. // was cleared in this mutation.
  3200. func (m *AliyunAvatarMutation) EdgeCleared(name string) bool {
  3201. return false
  3202. }
  3203. // ClearEdge clears the value of the edge with the given name. It returns an error
  3204. // if that edge is not defined in the schema.
  3205. func (m *AliyunAvatarMutation) ClearEdge(name string) error {
  3206. return fmt.Errorf("unknown AliyunAvatar unique edge %s", name)
  3207. }
  3208. // ResetEdge resets all changes to the edge with the given name in this mutation.
  3209. // It returns an error if the edge is not defined in the schema.
  3210. func (m *AliyunAvatarMutation) ResetEdge(name string) error {
  3211. return fmt.Errorf("unknown AliyunAvatar edge %s", name)
  3212. }
  3213. // AllocAgentMutation represents an operation that mutates the AllocAgent nodes in the graph.
  3214. type AllocAgentMutation struct {
  3215. config
  3216. op Op
  3217. typ string
  3218. id *uint64
  3219. created_at *time.Time
  3220. updated_at *time.Time
  3221. deleted_at *time.Time
  3222. user_id *string
  3223. organization_id *uint64
  3224. addorganization_id *int64
  3225. agents *[]uint64
  3226. appendagents []uint64
  3227. status *int
  3228. addstatus *int
  3229. clearedFields map[string]struct{}
  3230. done bool
  3231. oldValue func(context.Context) (*AllocAgent, error)
  3232. predicates []predicate.AllocAgent
  3233. }
  3234. var _ ent.Mutation = (*AllocAgentMutation)(nil)
  3235. // allocagentOption allows management of the mutation configuration using functional options.
  3236. type allocagentOption func(*AllocAgentMutation)
  3237. // newAllocAgentMutation creates new mutation for the AllocAgent entity.
  3238. func newAllocAgentMutation(c config, op Op, opts ...allocagentOption) *AllocAgentMutation {
  3239. m := &AllocAgentMutation{
  3240. config: c,
  3241. op: op,
  3242. typ: TypeAllocAgent,
  3243. clearedFields: make(map[string]struct{}),
  3244. }
  3245. for _, opt := range opts {
  3246. opt(m)
  3247. }
  3248. return m
  3249. }
  3250. // withAllocAgentID sets the ID field of the mutation.
  3251. func withAllocAgentID(id uint64) allocagentOption {
  3252. return func(m *AllocAgentMutation) {
  3253. var (
  3254. err error
  3255. once sync.Once
  3256. value *AllocAgent
  3257. )
  3258. m.oldValue = func(ctx context.Context) (*AllocAgent, error) {
  3259. once.Do(func() {
  3260. if m.done {
  3261. err = errors.New("querying old values post mutation is not allowed")
  3262. } else {
  3263. value, err = m.Client().AllocAgent.Get(ctx, id)
  3264. }
  3265. })
  3266. return value, err
  3267. }
  3268. m.id = &id
  3269. }
  3270. }
  3271. // withAllocAgent sets the old AllocAgent of the mutation.
  3272. func withAllocAgent(node *AllocAgent) allocagentOption {
  3273. return func(m *AllocAgentMutation) {
  3274. m.oldValue = func(context.Context) (*AllocAgent, error) {
  3275. return node, nil
  3276. }
  3277. m.id = &node.ID
  3278. }
  3279. }
  3280. // Client returns a new `ent.Client` from the mutation. If the mutation was
  3281. // executed in a transaction (ent.Tx), a transactional client is returned.
  3282. func (m AllocAgentMutation) Client() *Client {
  3283. client := &Client{config: m.config}
  3284. client.init()
  3285. return client
  3286. }
  3287. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  3288. // it returns an error otherwise.
  3289. func (m AllocAgentMutation) Tx() (*Tx, error) {
  3290. if _, ok := m.driver.(*txDriver); !ok {
  3291. return nil, errors.New("ent: mutation is not running in a transaction")
  3292. }
  3293. tx := &Tx{config: m.config}
  3294. tx.init()
  3295. return tx, nil
  3296. }
  3297. // SetID sets the value of the id field. Note that this
  3298. // operation is only accepted on creation of AllocAgent entities.
  3299. func (m *AllocAgentMutation) SetID(id uint64) {
  3300. m.id = &id
  3301. }
  3302. // ID returns the ID value in the mutation. Note that the ID is only available
  3303. // if it was provided to the builder or after it was returned from the database.
  3304. func (m *AllocAgentMutation) ID() (id uint64, exists bool) {
  3305. if m.id == nil {
  3306. return
  3307. }
  3308. return *m.id, true
  3309. }
  3310. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  3311. // That means, if the mutation is applied within a transaction with an isolation level such
  3312. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  3313. // or updated by the mutation.
  3314. func (m *AllocAgentMutation) IDs(ctx context.Context) ([]uint64, error) {
  3315. switch {
  3316. case m.op.Is(OpUpdateOne | OpDeleteOne):
  3317. id, exists := m.ID()
  3318. if exists {
  3319. return []uint64{id}, nil
  3320. }
  3321. fallthrough
  3322. case m.op.Is(OpUpdate | OpDelete):
  3323. return m.Client().AllocAgent.Query().Where(m.predicates...).IDs(ctx)
  3324. default:
  3325. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  3326. }
  3327. }
  3328. // SetCreatedAt sets the "created_at" field.
  3329. func (m *AllocAgentMutation) SetCreatedAt(t time.Time) {
  3330. m.created_at = &t
  3331. }
  3332. // CreatedAt returns the value of the "created_at" field in the mutation.
  3333. func (m *AllocAgentMutation) CreatedAt() (r time.Time, exists bool) {
  3334. v := m.created_at
  3335. if v == nil {
  3336. return
  3337. }
  3338. return *v, true
  3339. }
  3340. // OldCreatedAt returns the old "created_at" field's value of the AllocAgent entity.
  3341. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3342. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3343. func (m *AllocAgentMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  3344. if !m.op.Is(OpUpdateOne) {
  3345. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  3346. }
  3347. if m.id == nil || m.oldValue == nil {
  3348. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  3349. }
  3350. oldValue, err := m.oldValue(ctx)
  3351. if err != nil {
  3352. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  3353. }
  3354. return oldValue.CreatedAt, nil
  3355. }
  3356. // ResetCreatedAt resets all changes to the "created_at" field.
  3357. func (m *AllocAgentMutation) ResetCreatedAt() {
  3358. m.created_at = nil
  3359. }
  3360. // SetUpdatedAt sets the "updated_at" field.
  3361. func (m *AllocAgentMutation) SetUpdatedAt(t time.Time) {
  3362. m.updated_at = &t
  3363. }
  3364. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  3365. func (m *AllocAgentMutation) UpdatedAt() (r time.Time, exists bool) {
  3366. v := m.updated_at
  3367. if v == nil {
  3368. return
  3369. }
  3370. return *v, true
  3371. }
  3372. // OldUpdatedAt returns the old "updated_at" field's value of the AllocAgent entity.
  3373. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3374. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3375. func (m *AllocAgentMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  3376. if !m.op.Is(OpUpdateOne) {
  3377. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  3378. }
  3379. if m.id == nil || m.oldValue == nil {
  3380. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  3381. }
  3382. oldValue, err := m.oldValue(ctx)
  3383. if err != nil {
  3384. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  3385. }
  3386. return oldValue.UpdatedAt, nil
  3387. }
  3388. // ResetUpdatedAt resets all changes to the "updated_at" field.
  3389. func (m *AllocAgentMutation) ResetUpdatedAt() {
  3390. m.updated_at = nil
  3391. }
  3392. // SetDeletedAt sets the "deleted_at" field.
  3393. func (m *AllocAgentMutation) SetDeletedAt(t time.Time) {
  3394. m.deleted_at = &t
  3395. }
  3396. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  3397. func (m *AllocAgentMutation) DeletedAt() (r time.Time, exists bool) {
  3398. v := m.deleted_at
  3399. if v == nil {
  3400. return
  3401. }
  3402. return *v, true
  3403. }
  3404. // OldDeletedAt returns the old "deleted_at" field's value of the AllocAgent entity.
  3405. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3406. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3407. func (m *AllocAgentMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  3408. if !m.op.Is(OpUpdateOne) {
  3409. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  3410. }
  3411. if m.id == nil || m.oldValue == nil {
  3412. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  3413. }
  3414. oldValue, err := m.oldValue(ctx)
  3415. if err != nil {
  3416. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  3417. }
  3418. return oldValue.DeletedAt, nil
  3419. }
  3420. // ClearDeletedAt clears the value of the "deleted_at" field.
  3421. func (m *AllocAgentMutation) ClearDeletedAt() {
  3422. m.deleted_at = nil
  3423. m.clearedFields[allocagent.FieldDeletedAt] = struct{}{}
  3424. }
  3425. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  3426. func (m *AllocAgentMutation) DeletedAtCleared() bool {
  3427. _, ok := m.clearedFields[allocagent.FieldDeletedAt]
  3428. return ok
  3429. }
  3430. // ResetDeletedAt resets all changes to the "deleted_at" field.
  3431. func (m *AllocAgentMutation) ResetDeletedAt() {
  3432. m.deleted_at = nil
  3433. delete(m.clearedFields, allocagent.FieldDeletedAt)
  3434. }
  3435. // SetUserID sets the "user_id" field.
  3436. func (m *AllocAgentMutation) SetUserID(s string) {
  3437. m.user_id = &s
  3438. }
  3439. // UserID returns the value of the "user_id" field in the mutation.
  3440. func (m *AllocAgentMutation) UserID() (r string, exists bool) {
  3441. v := m.user_id
  3442. if v == nil {
  3443. return
  3444. }
  3445. return *v, true
  3446. }
  3447. // OldUserID returns the old "user_id" field's value of the AllocAgent entity.
  3448. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3449. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3450. func (m *AllocAgentMutation) OldUserID(ctx context.Context) (v string, err error) {
  3451. if !m.op.Is(OpUpdateOne) {
  3452. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  3453. }
  3454. if m.id == nil || m.oldValue == nil {
  3455. return v, errors.New("OldUserID requires an ID field in the mutation")
  3456. }
  3457. oldValue, err := m.oldValue(ctx)
  3458. if err != nil {
  3459. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  3460. }
  3461. return oldValue.UserID, nil
  3462. }
  3463. // ClearUserID clears the value of the "user_id" field.
  3464. func (m *AllocAgentMutation) ClearUserID() {
  3465. m.user_id = nil
  3466. m.clearedFields[allocagent.FieldUserID] = struct{}{}
  3467. }
  3468. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  3469. func (m *AllocAgentMutation) UserIDCleared() bool {
  3470. _, ok := m.clearedFields[allocagent.FieldUserID]
  3471. return ok
  3472. }
  3473. // ResetUserID resets all changes to the "user_id" field.
  3474. func (m *AllocAgentMutation) ResetUserID() {
  3475. m.user_id = nil
  3476. delete(m.clearedFields, allocagent.FieldUserID)
  3477. }
  3478. // SetOrganizationID sets the "organization_id" field.
  3479. func (m *AllocAgentMutation) SetOrganizationID(u uint64) {
  3480. m.organization_id = &u
  3481. m.addorganization_id = nil
  3482. }
  3483. // OrganizationID returns the value of the "organization_id" field in the mutation.
  3484. func (m *AllocAgentMutation) OrganizationID() (r uint64, exists bool) {
  3485. v := m.organization_id
  3486. if v == nil {
  3487. return
  3488. }
  3489. return *v, true
  3490. }
  3491. // OldOrganizationID returns the old "organization_id" field's value of the AllocAgent entity.
  3492. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3493. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3494. func (m *AllocAgentMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  3495. if !m.op.Is(OpUpdateOne) {
  3496. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  3497. }
  3498. if m.id == nil || m.oldValue == nil {
  3499. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  3500. }
  3501. oldValue, err := m.oldValue(ctx)
  3502. if err != nil {
  3503. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  3504. }
  3505. return oldValue.OrganizationID, nil
  3506. }
  3507. // AddOrganizationID adds u to the "organization_id" field.
  3508. func (m *AllocAgentMutation) AddOrganizationID(u int64) {
  3509. if m.addorganization_id != nil {
  3510. *m.addorganization_id += u
  3511. } else {
  3512. m.addorganization_id = &u
  3513. }
  3514. }
  3515. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  3516. func (m *AllocAgentMutation) AddedOrganizationID() (r int64, exists bool) {
  3517. v := m.addorganization_id
  3518. if v == nil {
  3519. return
  3520. }
  3521. return *v, true
  3522. }
  3523. // ClearOrganizationID clears the value of the "organization_id" field.
  3524. func (m *AllocAgentMutation) ClearOrganizationID() {
  3525. m.organization_id = nil
  3526. m.addorganization_id = nil
  3527. m.clearedFields[allocagent.FieldOrganizationID] = struct{}{}
  3528. }
  3529. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  3530. func (m *AllocAgentMutation) OrganizationIDCleared() bool {
  3531. _, ok := m.clearedFields[allocagent.FieldOrganizationID]
  3532. return ok
  3533. }
  3534. // ResetOrganizationID resets all changes to the "organization_id" field.
  3535. func (m *AllocAgentMutation) ResetOrganizationID() {
  3536. m.organization_id = nil
  3537. m.addorganization_id = nil
  3538. delete(m.clearedFields, allocagent.FieldOrganizationID)
  3539. }
  3540. // SetAgents sets the "agents" field.
  3541. func (m *AllocAgentMutation) SetAgents(u []uint64) {
  3542. m.agents = &u
  3543. m.appendagents = nil
  3544. }
  3545. // Agents returns the value of the "agents" field in the mutation.
  3546. func (m *AllocAgentMutation) Agents() (r []uint64, exists bool) {
  3547. v := m.agents
  3548. if v == nil {
  3549. return
  3550. }
  3551. return *v, true
  3552. }
  3553. // OldAgents returns the old "agents" field's value of the AllocAgent entity.
  3554. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3555. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3556. func (m *AllocAgentMutation) OldAgents(ctx context.Context) (v []uint64, err error) {
  3557. if !m.op.Is(OpUpdateOne) {
  3558. return v, errors.New("OldAgents is only allowed on UpdateOne operations")
  3559. }
  3560. if m.id == nil || m.oldValue == nil {
  3561. return v, errors.New("OldAgents requires an ID field in the mutation")
  3562. }
  3563. oldValue, err := m.oldValue(ctx)
  3564. if err != nil {
  3565. return v, fmt.Errorf("querying old value for OldAgents: %w", err)
  3566. }
  3567. return oldValue.Agents, nil
  3568. }
  3569. // AppendAgents adds u to the "agents" field.
  3570. func (m *AllocAgentMutation) AppendAgents(u []uint64) {
  3571. m.appendagents = append(m.appendagents, u...)
  3572. }
  3573. // AppendedAgents returns the list of values that were appended to the "agents" field in this mutation.
  3574. func (m *AllocAgentMutation) AppendedAgents() ([]uint64, bool) {
  3575. if len(m.appendagents) == 0 {
  3576. return nil, false
  3577. }
  3578. return m.appendagents, true
  3579. }
  3580. // ResetAgents resets all changes to the "agents" field.
  3581. func (m *AllocAgentMutation) ResetAgents() {
  3582. m.agents = nil
  3583. m.appendagents = nil
  3584. }
  3585. // SetStatus sets the "status" field.
  3586. func (m *AllocAgentMutation) SetStatus(i int) {
  3587. m.status = &i
  3588. m.addstatus = nil
  3589. }
  3590. // Status returns the value of the "status" field in the mutation.
  3591. func (m *AllocAgentMutation) Status() (r int, exists bool) {
  3592. v := m.status
  3593. if v == nil {
  3594. return
  3595. }
  3596. return *v, true
  3597. }
  3598. // OldStatus returns the old "status" field's value of the AllocAgent entity.
  3599. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3600. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3601. func (m *AllocAgentMutation) OldStatus(ctx context.Context) (v int, err error) {
  3602. if !m.op.Is(OpUpdateOne) {
  3603. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  3604. }
  3605. if m.id == nil || m.oldValue == nil {
  3606. return v, errors.New("OldStatus requires an ID field in the mutation")
  3607. }
  3608. oldValue, err := m.oldValue(ctx)
  3609. if err != nil {
  3610. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  3611. }
  3612. return oldValue.Status, nil
  3613. }
  3614. // AddStatus adds i to the "status" field.
  3615. func (m *AllocAgentMutation) AddStatus(i int) {
  3616. if m.addstatus != nil {
  3617. *m.addstatus += i
  3618. } else {
  3619. m.addstatus = &i
  3620. }
  3621. }
  3622. // AddedStatus returns the value that was added to the "status" field in this mutation.
  3623. func (m *AllocAgentMutation) AddedStatus() (r int, exists bool) {
  3624. v := m.addstatus
  3625. if v == nil {
  3626. return
  3627. }
  3628. return *v, true
  3629. }
  3630. // ClearStatus clears the value of the "status" field.
  3631. func (m *AllocAgentMutation) ClearStatus() {
  3632. m.status = nil
  3633. m.addstatus = nil
  3634. m.clearedFields[allocagent.FieldStatus] = struct{}{}
  3635. }
  3636. // StatusCleared returns if the "status" field was cleared in this mutation.
  3637. func (m *AllocAgentMutation) StatusCleared() bool {
  3638. _, ok := m.clearedFields[allocagent.FieldStatus]
  3639. return ok
  3640. }
  3641. // ResetStatus resets all changes to the "status" field.
  3642. func (m *AllocAgentMutation) ResetStatus() {
  3643. m.status = nil
  3644. m.addstatus = nil
  3645. delete(m.clearedFields, allocagent.FieldStatus)
  3646. }
  3647. // Where appends a list predicates to the AllocAgentMutation builder.
  3648. func (m *AllocAgentMutation) Where(ps ...predicate.AllocAgent) {
  3649. m.predicates = append(m.predicates, ps...)
  3650. }
  3651. // WhereP appends storage-level predicates to the AllocAgentMutation builder. Using this method,
  3652. // users can use type-assertion to append predicates that do not depend on any generated package.
  3653. func (m *AllocAgentMutation) WhereP(ps ...func(*sql.Selector)) {
  3654. p := make([]predicate.AllocAgent, len(ps))
  3655. for i := range ps {
  3656. p[i] = ps[i]
  3657. }
  3658. m.Where(p...)
  3659. }
  3660. // Op returns the operation name.
  3661. func (m *AllocAgentMutation) Op() Op {
  3662. return m.op
  3663. }
  3664. // SetOp allows setting the mutation operation.
  3665. func (m *AllocAgentMutation) SetOp(op Op) {
  3666. m.op = op
  3667. }
  3668. // Type returns the node type of this mutation (AllocAgent).
  3669. func (m *AllocAgentMutation) Type() string {
  3670. return m.typ
  3671. }
  3672. // Fields returns all fields that were changed during this mutation. Note that in
  3673. // order to get all numeric fields that were incremented/decremented, call
  3674. // AddedFields().
  3675. func (m *AllocAgentMutation) Fields() []string {
  3676. fields := make([]string, 0, 7)
  3677. if m.created_at != nil {
  3678. fields = append(fields, allocagent.FieldCreatedAt)
  3679. }
  3680. if m.updated_at != nil {
  3681. fields = append(fields, allocagent.FieldUpdatedAt)
  3682. }
  3683. if m.deleted_at != nil {
  3684. fields = append(fields, allocagent.FieldDeletedAt)
  3685. }
  3686. if m.user_id != nil {
  3687. fields = append(fields, allocagent.FieldUserID)
  3688. }
  3689. if m.organization_id != nil {
  3690. fields = append(fields, allocagent.FieldOrganizationID)
  3691. }
  3692. if m.agents != nil {
  3693. fields = append(fields, allocagent.FieldAgents)
  3694. }
  3695. if m.status != nil {
  3696. fields = append(fields, allocagent.FieldStatus)
  3697. }
  3698. return fields
  3699. }
  3700. // Field returns the value of a field with the given name. The second boolean
  3701. // return value indicates that this field was not set, or was not defined in the
  3702. // schema.
  3703. func (m *AllocAgentMutation) Field(name string) (ent.Value, bool) {
  3704. switch name {
  3705. case allocagent.FieldCreatedAt:
  3706. return m.CreatedAt()
  3707. case allocagent.FieldUpdatedAt:
  3708. return m.UpdatedAt()
  3709. case allocagent.FieldDeletedAt:
  3710. return m.DeletedAt()
  3711. case allocagent.FieldUserID:
  3712. return m.UserID()
  3713. case allocagent.FieldOrganizationID:
  3714. return m.OrganizationID()
  3715. case allocagent.FieldAgents:
  3716. return m.Agents()
  3717. case allocagent.FieldStatus:
  3718. return m.Status()
  3719. }
  3720. return nil, false
  3721. }
  3722. // OldField returns the old value of the field from the database. An error is
  3723. // returned if the mutation operation is not UpdateOne, or the query to the
  3724. // database failed.
  3725. func (m *AllocAgentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  3726. switch name {
  3727. case allocagent.FieldCreatedAt:
  3728. return m.OldCreatedAt(ctx)
  3729. case allocagent.FieldUpdatedAt:
  3730. return m.OldUpdatedAt(ctx)
  3731. case allocagent.FieldDeletedAt:
  3732. return m.OldDeletedAt(ctx)
  3733. case allocagent.FieldUserID:
  3734. return m.OldUserID(ctx)
  3735. case allocagent.FieldOrganizationID:
  3736. return m.OldOrganizationID(ctx)
  3737. case allocagent.FieldAgents:
  3738. return m.OldAgents(ctx)
  3739. case allocagent.FieldStatus:
  3740. return m.OldStatus(ctx)
  3741. }
  3742. return nil, fmt.Errorf("unknown AllocAgent field %s", name)
  3743. }
  3744. // SetField sets the value of a field with the given name. It returns an error if
  3745. // the field is not defined in the schema, or if the type mismatched the field
  3746. // type.
  3747. func (m *AllocAgentMutation) SetField(name string, value ent.Value) error {
  3748. switch name {
  3749. case allocagent.FieldCreatedAt:
  3750. v, ok := value.(time.Time)
  3751. if !ok {
  3752. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3753. }
  3754. m.SetCreatedAt(v)
  3755. return nil
  3756. case allocagent.FieldUpdatedAt:
  3757. v, ok := value.(time.Time)
  3758. if !ok {
  3759. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3760. }
  3761. m.SetUpdatedAt(v)
  3762. return nil
  3763. case allocagent.FieldDeletedAt:
  3764. v, ok := value.(time.Time)
  3765. if !ok {
  3766. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3767. }
  3768. m.SetDeletedAt(v)
  3769. return nil
  3770. case allocagent.FieldUserID:
  3771. v, ok := value.(string)
  3772. if !ok {
  3773. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3774. }
  3775. m.SetUserID(v)
  3776. return nil
  3777. case allocagent.FieldOrganizationID:
  3778. v, ok := value.(uint64)
  3779. if !ok {
  3780. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3781. }
  3782. m.SetOrganizationID(v)
  3783. return nil
  3784. case allocagent.FieldAgents:
  3785. v, ok := value.([]uint64)
  3786. if !ok {
  3787. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3788. }
  3789. m.SetAgents(v)
  3790. return nil
  3791. case allocagent.FieldStatus:
  3792. v, ok := value.(int)
  3793. if !ok {
  3794. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3795. }
  3796. m.SetStatus(v)
  3797. return nil
  3798. }
  3799. return fmt.Errorf("unknown AllocAgent field %s", name)
  3800. }
  3801. // AddedFields returns all numeric fields that were incremented/decremented during
  3802. // this mutation.
  3803. func (m *AllocAgentMutation) AddedFields() []string {
  3804. var fields []string
  3805. if m.addorganization_id != nil {
  3806. fields = append(fields, allocagent.FieldOrganizationID)
  3807. }
  3808. if m.addstatus != nil {
  3809. fields = append(fields, allocagent.FieldStatus)
  3810. }
  3811. return fields
  3812. }
  3813. // AddedField returns the numeric value that was incremented/decremented on a field
  3814. // with the given name. The second boolean return value indicates that this field
  3815. // was not set, or was not defined in the schema.
  3816. func (m *AllocAgentMutation) AddedField(name string) (ent.Value, bool) {
  3817. switch name {
  3818. case allocagent.FieldOrganizationID:
  3819. return m.AddedOrganizationID()
  3820. case allocagent.FieldStatus:
  3821. return m.AddedStatus()
  3822. }
  3823. return nil, false
  3824. }
  3825. // AddField adds the value to the field with the given name. It returns an error if
  3826. // the field is not defined in the schema, or if the type mismatched the field
  3827. // type.
  3828. func (m *AllocAgentMutation) AddField(name string, value ent.Value) error {
  3829. switch name {
  3830. case allocagent.FieldOrganizationID:
  3831. v, ok := value.(int64)
  3832. if !ok {
  3833. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3834. }
  3835. m.AddOrganizationID(v)
  3836. return nil
  3837. case allocagent.FieldStatus:
  3838. v, ok := value.(int)
  3839. if !ok {
  3840. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3841. }
  3842. m.AddStatus(v)
  3843. return nil
  3844. }
  3845. return fmt.Errorf("unknown AllocAgent numeric field %s", name)
  3846. }
  3847. // ClearedFields returns all nullable fields that were cleared during this
  3848. // mutation.
  3849. func (m *AllocAgentMutation) ClearedFields() []string {
  3850. var fields []string
  3851. if m.FieldCleared(allocagent.FieldDeletedAt) {
  3852. fields = append(fields, allocagent.FieldDeletedAt)
  3853. }
  3854. if m.FieldCleared(allocagent.FieldUserID) {
  3855. fields = append(fields, allocagent.FieldUserID)
  3856. }
  3857. if m.FieldCleared(allocagent.FieldOrganizationID) {
  3858. fields = append(fields, allocagent.FieldOrganizationID)
  3859. }
  3860. if m.FieldCleared(allocagent.FieldStatus) {
  3861. fields = append(fields, allocagent.FieldStatus)
  3862. }
  3863. return fields
  3864. }
  3865. // FieldCleared returns a boolean indicating if a field with the given name was
  3866. // cleared in this mutation.
  3867. func (m *AllocAgentMutation) FieldCleared(name string) bool {
  3868. _, ok := m.clearedFields[name]
  3869. return ok
  3870. }
  3871. // ClearField clears the value of the field with the given name. It returns an
  3872. // error if the field is not defined in the schema.
  3873. func (m *AllocAgentMutation) ClearField(name string) error {
  3874. switch name {
  3875. case allocagent.FieldDeletedAt:
  3876. m.ClearDeletedAt()
  3877. return nil
  3878. case allocagent.FieldUserID:
  3879. m.ClearUserID()
  3880. return nil
  3881. case allocagent.FieldOrganizationID:
  3882. m.ClearOrganizationID()
  3883. return nil
  3884. case allocagent.FieldStatus:
  3885. m.ClearStatus()
  3886. return nil
  3887. }
  3888. return fmt.Errorf("unknown AllocAgent nullable field %s", name)
  3889. }
  3890. // ResetField resets all changes in the mutation for the field with the given name.
  3891. // It returns an error if the field is not defined in the schema.
  3892. func (m *AllocAgentMutation) ResetField(name string) error {
  3893. switch name {
  3894. case allocagent.FieldCreatedAt:
  3895. m.ResetCreatedAt()
  3896. return nil
  3897. case allocagent.FieldUpdatedAt:
  3898. m.ResetUpdatedAt()
  3899. return nil
  3900. case allocagent.FieldDeletedAt:
  3901. m.ResetDeletedAt()
  3902. return nil
  3903. case allocagent.FieldUserID:
  3904. m.ResetUserID()
  3905. return nil
  3906. case allocagent.FieldOrganizationID:
  3907. m.ResetOrganizationID()
  3908. return nil
  3909. case allocagent.FieldAgents:
  3910. m.ResetAgents()
  3911. return nil
  3912. case allocagent.FieldStatus:
  3913. m.ResetStatus()
  3914. return nil
  3915. }
  3916. return fmt.Errorf("unknown AllocAgent field %s", name)
  3917. }
  3918. // AddedEdges returns all edge names that were set/added in this mutation.
  3919. func (m *AllocAgentMutation) AddedEdges() []string {
  3920. edges := make([]string, 0, 0)
  3921. return edges
  3922. }
  3923. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  3924. // name in this mutation.
  3925. func (m *AllocAgentMutation) AddedIDs(name string) []ent.Value {
  3926. return nil
  3927. }
  3928. // RemovedEdges returns all edge names that were removed in this mutation.
  3929. func (m *AllocAgentMutation) RemovedEdges() []string {
  3930. edges := make([]string, 0, 0)
  3931. return edges
  3932. }
  3933. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  3934. // the given name in this mutation.
  3935. func (m *AllocAgentMutation) RemovedIDs(name string) []ent.Value {
  3936. return nil
  3937. }
  3938. // ClearedEdges returns all edge names that were cleared in this mutation.
  3939. func (m *AllocAgentMutation) ClearedEdges() []string {
  3940. edges := make([]string, 0, 0)
  3941. return edges
  3942. }
  3943. // EdgeCleared returns a boolean which indicates if the edge with the given name
  3944. // was cleared in this mutation.
  3945. func (m *AllocAgentMutation) EdgeCleared(name string) bool {
  3946. return false
  3947. }
  3948. // ClearEdge clears the value of the edge with the given name. It returns an error
  3949. // if that edge is not defined in the schema.
  3950. func (m *AllocAgentMutation) ClearEdge(name string) error {
  3951. return fmt.Errorf("unknown AllocAgent unique edge %s", name)
  3952. }
  3953. // ResetEdge resets all changes to the edge with the given name in this mutation.
  3954. // It returns an error if the edge is not defined in the schema.
  3955. func (m *AllocAgentMutation) ResetEdge(name string) error {
  3956. return fmt.Errorf("unknown AllocAgent edge %s", name)
  3957. }
  3958. // BatchMsgMutation represents an operation that mutates the BatchMsg nodes in the graph.
  3959. type BatchMsgMutation struct {
  3960. config
  3961. op Op
  3962. typ string
  3963. id *uint64
  3964. created_at *time.Time
  3965. updated_at *time.Time
  3966. deleted_at *time.Time
  3967. status *uint8
  3968. addstatus *int8
  3969. batch_no *string
  3970. task_name *string
  3971. fromwxid *string
  3972. msg *string
  3973. tag *string
  3974. tagids *string
  3975. total *int32
  3976. addtotal *int32
  3977. success *int32
  3978. addsuccess *int32
  3979. fail *int32
  3980. addfail *int32
  3981. start_time *time.Time
  3982. stop_time *time.Time
  3983. send_time *time.Time
  3984. _type *int32
  3985. add_type *int32
  3986. organization_id *uint64
  3987. addorganization_id *int64
  3988. ctype *uint64
  3989. addctype *int64
  3990. cc *string
  3991. phone *string
  3992. clearedFields map[string]struct{}
  3993. done bool
  3994. oldValue func(context.Context) (*BatchMsg, error)
  3995. predicates []predicate.BatchMsg
  3996. }
  3997. var _ ent.Mutation = (*BatchMsgMutation)(nil)
  3998. // batchmsgOption allows management of the mutation configuration using functional options.
  3999. type batchmsgOption func(*BatchMsgMutation)
  4000. // newBatchMsgMutation creates new mutation for the BatchMsg entity.
  4001. func newBatchMsgMutation(c config, op Op, opts ...batchmsgOption) *BatchMsgMutation {
  4002. m := &BatchMsgMutation{
  4003. config: c,
  4004. op: op,
  4005. typ: TypeBatchMsg,
  4006. clearedFields: make(map[string]struct{}),
  4007. }
  4008. for _, opt := range opts {
  4009. opt(m)
  4010. }
  4011. return m
  4012. }
  4013. // withBatchMsgID sets the ID field of the mutation.
  4014. func withBatchMsgID(id uint64) batchmsgOption {
  4015. return func(m *BatchMsgMutation) {
  4016. var (
  4017. err error
  4018. once sync.Once
  4019. value *BatchMsg
  4020. )
  4021. m.oldValue = func(ctx context.Context) (*BatchMsg, error) {
  4022. once.Do(func() {
  4023. if m.done {
  4024. err = errors.New("querying old values post mutation is not allowed")
  4025. } else {
  4026. value, err = m.Client().BatchMsg.Get(ctx, id)
  4027. }
  4028. })
  4029. return value, err
  4030. }
  4031. m.id = &id
  4032. }
  4033. }
  4034. // withBatchMsg sets the old BatchMsg of the mutation.
  4035. func withBatchMsg(node *BatchMsg) batchmsgOption {
  4036. return func(m *BatchMsgMutation) {
  4037. m.oldValue = func(context.Context) (*BatchMsg, error) {
  4038. return node, nil
  4039. }
  4040. m.id = &node.ID
  4041. }
  4042. }
  4043. // Client returns a new `ent.Client` from the mutation. If the mutation was
  4044. // executed in a transaction (ent.Tx), a transactional client is returned.
  4045. func (m BatchMsgMutation) Client() *Client {
  4046. client := &Client{config: m.config}
  4047. client.init()
  4048. return client
  4049. }
  4050. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  4051. // it returns an error otherwise.
  4052. func (m BatchMsgMutation) Tx() (*Tx, error) {
  4053. if _, ok := m.driver.(*txDriver); !ok {
  4054. return nil, errors.New("ent: mutation is not running in a transaction")
  4055. }
  4056. tx := &Tx{config: m.config}
  4057. tx.init()
  4058. return tx, nil
  4059. }
  4060. // SetID sets the value of the id field. Note that this
  4061. // operation is only accepted on creation of BatchMsg entities.
  4062. func (m *BatchMsgMutation) SetID(id uint64) {
  4063. m.id = &id
  4064. }
  4065. // ID returns the ID value in the mutation. Note that the ID is only available
  4066. // if it was provided to the builder or after it was returned from the database.
  4067. func (m *BatchMsgMutation) ID() (id uint64, exists bool) {
  4068. if m.id == nil {
  4069. return
  4070. }
  4071. return *m.id, true
  4072. }
  4073. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  4074. // That means, if the mutation is applied within a transaction with an isolation level such
  4075. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  4076. // or updated by the mutation.
  4077. func (m *BatchMsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  4078. switch {
  4079. case m.op.Is(OpUpdateOne | OpDeleteOne):
  4080. id, exists := m.ID()
  4081. if exists {
  4082. return []uint64{id}, nil
  4083. }
  4084. fallthrough
  4085. case m.op.Is(OpUpdate | OpDelete):
  4086. return m.Client().BatchMsg.Query().Where(m.predicates...).IDs(ctx)
  4087. default:
  4088. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  4089. }
  4090. }
  4091. // SetCreatedAt sets the "created_at" field.
  4092. func (m *BatchMsgMutation) SetCreatedAt(t time.Time) {
  4093. m.created_at = &t
  4094. }
  4095. // CreatedAt returns the value of the "created_at" field in the mutation.
  4096. func (m *BatchMsgMutation) CreatedAt() (r time.Time, exists bool) {
  4097. v := m.created_at
  4098. if v == nil {
  4099. return
  4100. }
  4101. return *v, true
  4102. }
  4103. // OldCreatedAt returns the old "created_at" field's value of the BatchMsg entity.
  4104. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4105. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4106. func (m *BatchMsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  4107. if !m.op.Is(OpUpdateOne) {
  4108. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  4109. }
  4110. if m.id == nil || m.oldValue == nil {
  4111. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  4112. }
  4113. oldValue, err := m.oldValue(ctx)
  4114. if err != nil {
  4115. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  4116. }
  4117. return oldValue.CreatedAt, nil
  4118. }
  4119. // ResetCreatedAt resets all changes to the "created_at" field.
  4120. func (m *BatchMsgMutation) ResetCreatedAt() {
  4121. m.created_at = nil
  4122. }
  4123. // SetUpdatedAt sets the "updated_at" field.
  4124. func (m *BatchMsgMutation) SetUpdatedAt(t time.Time) {
  4125. m.updated_at = &t
  4126. }
  4127. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  4128. func (m *BatchMsgMutation) UpdatedAt() (r time.Time, exists bool) {
  4129. v := m.updated_at
  4130. if v == nil {
  4131. return
  4132. }
  4133. return *v, true
  4134. }
  4135. // OldUpdatedAt returns the old "updated_at" field's value of the BatchMsg entity.
  4136. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4137. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4138. func (m *BatchMsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  4139. if !m.op.Is(OpUpdateOne) {
  4140. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  4141. }
  4142. if m.id == nil || m.oldValue == nil {
  4143. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  4144. }
  4145. oldValue, err := m.oldValue(ctx)
  4146. if err != nil {
  4147. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  4148. }
  4149. return oldValue.UpdatedAt, nil
  4150. }
  4151. // ResetUpdatedAt resets all changes to the "updated_at" field.
  4152. func (m *BatchMsgMutation) ResetUpdatedAt() {
  4153. m.updated_at = nil
  4154. }
  4155. // SetDeletedAt sets the "deleted_at" field.
  4156. func (m *BatchMsgMutation) SetDeletedAt(t time.Time) {
  4157. m.deleted_at = &t
  4158. }
  4159. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  4160. func (m *BatchMsgMutation) DeletedAt() (r time.Time, exists bool) {
  4161. v := m.deleted_at
  4162. if v == nil {
  4163. return
  4164. }
  4165. return *v, true
  4166. }
  4167. // OldDeletedAt returns the old "deleted_at" field's value of the BatchMsg entity.
  4168. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4169. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4170. func (m *BatchMsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  4171. if !m.op.Is(OpUpdateOne) {
  4172. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  4173. }
  4174. if m.id == nil || m.oldValue == nil {
  4175. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  4176. }
  4177. oldValue, err := m.oldValue(ctx)
  4178. if err != nil {
  4179. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  4180. }
  4181. return oldValue.DeletedAt, nil
  4182. }
  4183. // ClearDeletedAt clears the value of the "deleted_at" field.
  4184. func (m *BatchMsgMutation) ClearDeletedAt() {
  4185. m.deleted_at = nil
  4186. m.clearedFields[batchmsg.FieldDeletedAt] = struct{}{}
  4187. }
  4188. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  4189. func (m *BatchMsgMutation) DeletedAtCleared() bool {
  4190. _, ok := m.clearedFields[batchmsg.FieldDeletedAt]
  4191. return ok
  4192. }
  4193. // ResetDeletedAt resets all changes to the "deleted_at" field.
  4194. func (m *BatchMsgMutation) ResetDeletedAt() {
  4195. m.deleted_at = nil
  4196. delete(m.clearedFields, batchmsg.FieldDeletedAt)
  4197. }
  4198. // SetStatus sets the "status" field.
  4199. func (m *BatchMsgMutation) SetStatus(u uint8) {
  4200. m.status = &u
  4201. m.addstatus = nil
  4202. }
  4203. // Status returns the value of the "status" field in the mutation.
  4204. func (m *BatchMsgMutation) Status() (r uint8, exists bool) {
  4205. v := m.status
  4206. if v == nil {
  4207. return
  4208. }
  4209. return *v, true
  4210. }
  4211. // OldStatus returns the old "status" field's value of the BatchMsg entity.
  4212. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4213. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4214. func (m *BatchMsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  4215. if !m.op.Is(OpUpdateOne) {
  4216. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  4217. }
  4218. if m.id == nil || m.oldValue == nil {
  4219. return v, errors.New("OldStatus requires an ID field in the mutation")
  4220. }
  4221. oldValue, err := m.oldValue(ctx)
  4222. if err != nil {
  4223. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  4224. }
  4225. return oldValue.Status, nil
  4226. }
  4227. // AddStatus adds u to the "status" field.
  4228. func (m *BatchMsgMutation) AddStatus(u int8) {
  4229. if m.addstatus != nil {
  4230. *m.addstatus += u
  4231. } else {
  4232. m.addstatus = &u
  4233. }
  4234. }
  4235. // AddedStatus returns the value that was added to the "status" field in this mutation.
  4236. func (m *BatchMsgMutation) AddedStatus() (r int8, exists bool) {
  4237. v := m.addstatus
  4238. if v == nil {
  4239. return
  4240. }
  4241. return *v, true
  4242. }
  4243. // ClearStatus clears the value of the "status" field.
  4244. func (m *BatchMsgMutation) ClearStatus() {
  4245. m.status = nil
  4246. m.addstatus = nil
  4247. m.clearedFields[batchmsg.FieldStatus] = struct{}{}
  4248. }
  4249. // StatusCleared returns if the "status" field was cleared in this mutation.
  4250. func (m *BatchMsgMutation) StatusCleared() bool {
  4251. _, ok := m.clearedFields[batchmsg.FieldStatus]
  4252. return ok
  4253. }
  4254. // ResetStatus resets all changes to the "status" field.
  4255. func (m *BatchMsgMutation) ResetStatus() {
  4256. m.status = nil
  4257. m.addstatus = nil
  4258. delete(m.clearedFields, batchmsg.FieldStatus)
  4259. }
  4260. // SetBatchNo sets the "batch_no" field.
  4261. func (m *BatchMsgMutation) SetBatchNo(s string) {
  4262. m.batch_no = &s
  4263. }
  4264. // BatchNo returns the value of the "batch_no" field in the mutation.
  4265. func (m *BatchMsgMutation) BatchNo() (r string, exists bool) {
  4266. v := m.batch_no
  4267. if v == nil {
  4268. return
  4269. }
  4270. return *v, true
  4271. }
  4272. // OldBatchNo returns the old "batch_no" field's value of the BatchMsg entity.
  4273. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4274. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4275. func (m *BatchMsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  4276. if !m.op.Is(OpUpdateOne) {
  4277. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  4278. }
  4279. if m.id == nil || m.oldValue == nil {
  4280. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  4281. }
  4282. oldValue, err := m.oldValue(ctx)
  4283. if err != nil {
  4284. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  4285. }
  4286. return oldValue.BatchNo, nil
  4287. }
  4288. // ClearBatchNo clears the value of the "batch_no" field.
  4289. func (m *BatchMsgMutation) ClearBatchNo() {
  4290. m.batch_no = nil
  4291. m.clearedFields[batchmsg.FieldBatchNo] = struct{}{}
  4292. }
  4293. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  4294. func (m *BatchMsgMutation) BatchNoCleared() bool {
  4295. _, ok := m.clearedFields[batchmsg.FieldBatchNo]
  4296. return ok
  4297. }
  4298. // ResetBatchNo resets all changes to the "batch_no" field.
  4299. func (m *BatchMsgMutation) ResetBatchNo() {
  4300. m.batch_no = nil
  4301. delete(m.clearedFields, batchmsg.FieldBatchNo)
  4302. }
  4303. // SetTaskName sets the "task_name" field.
  4304. func (m *BatchMsgMutation) SetTaskName(s string) {
  4305. m.task_name = &s
  4306. }
  4307. // TaskName returns the value of the "task_name" field in the mutation.
  4308. func (m *BatchMsgMutation) TaskName() (r string, exists bool) {
  4309. v := m.task_name
  4310. if v == nil {
  4311. return
  4312. }
  4313. return *v, true
  4314. }
  4315. // OldTaskName returns the old "task_name" field's value of the BatchMsg entity.
  4316. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4317. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4318. func (m *BatchMsgMutation) OldTaskName(ctx context.Context) (v string, err error) {
  4319. if !m.op.Is(OpUpdateOne) {
  4320. return v, errors.New("OldTaskName is only allowed on UpdateOne operations")
  4321. }
  4322. if m.id == nil || m.oldValue == nil {
  4323. return v, errors.New("OldTaskName requires an ID field in the mutation")
  4324. }
  4325. oldValue, err := m.oldValue(ctx)
  4326. if err != nil {
  4327. return v, fmt.Errorf("querying old value for OldTaskName: %w", err)
  4328. }
  4329. return oldValue.TaskName, nil
  4330. }
  4331. // ClearTaskName clears the value of the "task_name" field.
  4332. func (m *BatchMsgMutation) ClearTaskName() {
  4333. m.task_name = nil
  4334. m.clearedFields[batchmsg.FieldTaskName] = struct{}{}
  4335. }
  4336. // TaskNameCleared returns if the "task_name" field was cleared in this mutation.
  4337. func (m *BatchMsgMutation) TaskNameCleared() bool {
  4338. _, ok := m.clearedFields[batchmsg.FieldTaskName]
  4339. return ok
  4340. }
  4341. // ResetTaskName resets all changes to the "task_name" field.
  4342. func (m *BatchMsgMutation) ResetTaskName() {
  4343. m.task_name = nil
  4344. delete(m.clearedFields, batchmsg.FieldTaskName)
  4345. }
  4346. // SetFromwxid sets the "fromwxid" field.
  4347. func (m *BatchMsgMutation) SetFromwxid(s string) {
  4348. m.fromwxid = &s
  4349. }
  4350. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  4351. func (m *BatchMsgMutation) Fromwxid() (r string, exists bool) {
  4352. v := m.fromwxid
  4353. if v == nil {
  4354. return
  4355. }
  4356. return *v, true
  4357. }
  4358. // OldFromwxid returns the old "fromwxid" field's value of the BatchMsg entity.
  4359. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4360. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4361. func (m *BatchMsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  4362. if !m.op.Is(OpUpdateOne) {
  4363. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  4364. }
  4365. if m.id == nil || m.oldValue == nil {
  4366. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  4367. }
  4368. oldValue, err := m.oldValue(ctx)
  4369. if err != nil {
  4370. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  4371. }
  4372. return oldValue.Fromwxid, nil
  4373. }
  4374. // ClearFromwxid clears the value of the "fromwxid" field.
  4375. func (m *BatchMsgMutation) ClearFromwxid() {
  4376. m.fromwxid = nil
  4377. m.clearedFields[batchmsg.FieldFromwxid] = struct{}{}
  4378. }
  4379. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  4380. func (m *BatchMsgMutation) FromwxidCleared() bool {
  4381. _, ok := m.clearedFields[batchmsg.FieldFromwxid]
  4382. return ok
  4383. }
  4384. // ResetFromwxid resets all changes to the "fromwxid" field.
  4385. func (m *BatchMsgMutation) ResetFromwxid() {
  4386. m.fromwxid = nil
  4387. delete(m.clearedFields, batchmsg.FieldFromwxid)
  4388. }
  4389. // SetMsg sets the "msg" field.
  4390. func (m *BatchMsgMutation) SetMsg(s string) {
  4391. m.msg = &s
  4392. }
  4393. // Msg returns the value of the "msg" field in the mutation.
  4394. func (m *BatchMsgMutation) Msg() (r string, exists bool) {
  4395. v := m.msg
  4396. if v == nil {
  4397. return
  4398. }
  4399. return *v, true
  4400. }
  4401. // OldMsg returns the old "msg" field's value of the BatchMsg entity.
  4402. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4403. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4404. func (m *BatchMsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  4405. if !m.op.Is(OpUpdateOne) {
  4406. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  4407. }
  4408. if m.id == nil || m.oldValue == nil {
  4409. return v, errors.New("OldMsg requires an ID field in the mutation")
  4410. }
  4411. oldValue, err := m.oldValue(ctx)
  4412. if err != nil {
  4413. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  4414. }
  4415. return oldValue.Msg, nil
  4416. }
  4417. // ClearMsg clears the value of the "msg" field.
  4418. func (m *BatchMsgMutation) ClearMsg() {
  4419. m.msg = nil
  4420. m.clearedFields[batchmsg.FieldMsg] = struct{}{}
  4421. }
  4422. // MsgCleared returns if the "msg" field was cleared in this mutation.
  4423. func (m *BatchMsgMutation) MsgCleared() bool {
  4424. _, ok := m.clearedFields[batchmsg.FieldMsg]
  4425. return ok
  4426. }
  4427. // ResetMsg resets all changes to the "msg" field.
  4428. func (m *BatchMsgMutation) ResetMsg() {
  4429. m.msg = nil
  4430. delete(m.clearedFields, batchmsg.FieldMsg)
  4431. }
  4432. // SetTag sets the "tag" field.
  4433. func (m *BatchMsgMutation) SetTag(s string) {
  4434. m.tag = &s
  4435. }
  4436. // Tag returns the value of the "tag" field in the mutation.
  4437. func (m *BatchMsgMutation) Tag() (r string, exists bool) {
  4438. v := m.tag
  4439. if v == nil {
  4440. return
  4441. }
  4442. return *v, true
  4443. }
  4444. // OldTag returns the old "tag" field's value of the BatchMsg entity.
  4445. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4446. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4447. func (m *BatchMsgMutation) OldTag(ctx context.Context) (v string, err error) {
  4448. if !m.op.Is(OpUpdateOne) {
  4449. return v, errors.New("OldTag is only allowed on UpdateOne operations")
  4450. }
  4451. if m.id == nil || m.oldValue == nil {
  4452. return v, errors.New("OldTag requires an ID field in the mutation")
  4453. }
  4454. oldValue, err := m.oldValue(ctx)
  4455. if err != nil {
  4456. return v, fmt.Errorf("querying old value for OldTag: %w", err)
  4457. }
  4458. return oldValue.Tag, nil
  4459. }
  4460. // ClearTag clears the value of the "tag" field.
  4461. func (m *BatchMsgMutation) ClearTag() {
  4462. m.tag = nil
  4463. m.clearedFields[batchmsg.FieldTag] = struct{}{}
  4464. }
  4465. // TagCleared returns if the "tag" field was cleared in this mutation.
  4466. func (m *BatchMsgMutation) TagCleared() bool {
  4467. _, ok := m.clearedFields[batchmsg.FieldTag]
  4468. return ok
  4469. }
  4470. // ResetTag resets all changes to the "tag" field.
  4471. func (m *BatchMsgMutation) ResetTag() {
  4472. m.tag = nil
  4473. delete(m.clearedFields, batchmsg.FieldTag)
  4474. }
  4475. // SetTagids sets the "tagids" field.
  4476. func (m *BatchMsgMutation) SetTagids(s string) {
  4477. m.tagids = &s
  4478. }
  4479. // Tagids returns the value of the "tagids" field in the mutation.
  4480. func (m *BatchMsgMutation) Tagids() (r string, exists bool) {
  4481. v := m.tagids
  4482. if v == nil {
  4483. return
  4484. }
  4485. return *v, true
  4486. }
  4487. // OldTagids returns the old "tagids" field's value of the BatchMsg entity.
  4488. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4489. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4490. func (m *BatchMsgMutation) OldTagids(ctx context.Context) (v string, err error) {
  4491. if !m.op.Is(OpUpdateOne) {
  4492. return v, errors.New("OldTagids is only allowed on UpdateOne operations")
  4493. }
  4494. if m.id == nil || m.oldValue == nil {
  4495. return v, errors.New("OldTagids requires an ID field in the mutation")
  4496. }
  4497. oldValue, err := m.oldValue(ctx)
  4498. if err != nil {
  4499. return v, fmt.Errorf("querying old value for OldTagids: %w", err)
  4500. }
  4501. return oldValue.Tagids, nil
  4502. }
  4503. // ClearTagids clears the value of the "tagids" field.
  4504. func (m *BatchMsgMutation) ClearTagids() {
  4505. m.tagids = nil
  4506. m.clearedFields[batchmsg.FieldTagids] = struct{}{}
  4507. }
  4508. // TagidsCleared returns if the "tagids" field was cleared in this mutation.
  4509. func (m *BatchMsgMutation) TagidsCleared() bool {
  4510. _, ok := m.clearedFields[batchmsg.FieldTagids]
  4511. return ok
  4512. }
  4513. // ResetTagids resets all changes to the "tagids" field.
  4514. func (m *BatchMsgMutation) ResetTagids() {
  4515. m.tagids = nil
  4516. delete(m.clearedFields, batchmsg.FieldTagids)
  4517. }
  4518. // SetTotal sets the "total" field.
  4519. func (m *BatchMsgMutation) SetTotal(i int32) {
  4520. m.total = &i
  4521. m.addtotal = nil
  4522. }
  4523. // Total returns the value of the "total" field in the mutation.
  4524. func (m *BatchMsgMutation) Total() (r int32, exists bool) {
  4525. v := m.total
  4526. if v == nil {
  4527. return
  4528. }
  4529. return *v, true
  4530. }
  4531. // OldTotal returns the old "total" field's value of the BatchMsg entity.
  4532. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4533. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4534. func (m *BatchMsgMutation) OldTotal(ctx context.Context) (v int32, err error) {
  4535. if !m.op.Is(OpUpdateOne) {
  4536. return v, errors.New("OldTotal is only allowed on UpdateOne operations")
  4537. }
  4538. if m.id == nil || m.oldValue == nil {
  4539. return v, errors.New("OldTotal requires an ID field in the mutation")
  4540. }
  4541. oldValue, err := m.oldValue(ctx)
  4542. if err != nil {
  4543. return v, fmt.Errorf("querying old value for OldTotal: %w", err)
  4544. }
  4545. return oldValue.Total, nil
  4546. }
  4547. // AddTotal adds i to the "total" field.
  4548. func (m *BatchMsgMutation) AddTotal(i int32) {
  4549. if m.addtotal != nil {
  4550. *m.addtotal += i
  4551. } else {
  4552. m.addtotal = &i
  4553. }
  4554. }
  4555. // AddedTotal returns the value that was added to the "total" field in this mutation.
  4556. func (m *BatchMsgMutation) AddedTotal() (r int32, exists bool) {
  4557. v := m.addtotal
  4558. if v == nil {
  4559. return
  4560. }
  4561. return *v, true
  4562. }
  4563. // ClearTotal clears the value of the "total" field.
  4564. func (m *BatchMsgMutation) ClearTotal() {
  4565. m.total = nil
  4566. m.addtotal = nil
  4567. m.clearedFields[batchmsg.FieldTotal] = struct{}{}
  4568. }
  4569. // TotalCleared returns if the "total" field was cleared in this mutation.
  4570. func (m *BatchMsgMutation) TotalCleared() bool {
  4571. _, ok := m.clearedFields[batchmsg.FieldTotal]
  4572. return ok
  4573. }
  4574. // ResetTotal resets all changes to the "total" field.
  4575. func (m *BatchMsgMutation) ResetTotal() {
  4576. m.total = nil
  4577. m.addtotal = nil
  4578. delete(m.clearedFields, batchmsg.FieldTotal)
  4579. }
  4580. // SetSuccess sets the "success" field.
  4581. func (m *BatchMsgMutation) SetSuccess(i int32) {
  4582. m.success = &i
  4583. m.addsuccess = nil
  4584. }
  4585. // Success returns the value of the "success" field in the mutation.
  4586. func (m *BatchMsgMutation) Success() (r int32, exists bool) {
  4587. v := m.success
  4588. if v == nil {
  4589. return
  4590. }
  4591. return *v, true
  4592. }
  4593. // OldSuccess returns the old "success" field's value of the BatchMsg entity.
  4594. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4595. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4596. func (m *BatchMsgMutation) OldSuccess(ctx context.Context) (v int32, err error) {
  4597. if !m.op.Is(OpUpdateOne) {
  4598. return v, errors.New("OldSuccess is only allowed on UpdateOne operations")
  4599. }
  4600. if m.id == nil || m.oldValue == nil {
  4601. return v, errors.New("OldSuccess requires an ID field in the mutation")
  4602. }
  4603. oldValue, err := m.oldValue(ctx)
  4604. if err != nil {
  4605. return v, fmt.Errorf("querying old value for OldSuccess: %w", err)
  4606. }
  4607. return oldValue.Success, nil
  4608. }
  4609. // AddSuccess adds i to the "success" field.
  4610. func (m *BatchMsgMutation) AddSuccess(i int32) {
  4611. if m.addsuccess != nil {
  4612. *m.addsuccess += i
  4613. } else {
  4614. m.addsuccess = &i
  4615. }
  4616. }
  4617. // AddedSuccess returns the value that was added to the "success" field in this mutation.
  4618. func (m *BatchMsgMutation) AddedSuccess() (r int32, exists bool) {
  4619. v := m.addsuccess
  4620. if v == nil {
  4621. return
  4622. }
  4623. return *v, true
  4624. }
  4625. // ClearSuccess clears the value of the "success" field.
  4626. func (m *BatchMsgMutation) ClearSuccess() {
  4627. m.success = nil
  4628. m.addsuccess = nil
  4629. m.clearedFields[batchmsg.FieldSuccess] = struct{}{}
  4630. }
  4631. // SuccessCleared returns if the "success" field was cleared in this mutation.
  4632. func (m *BatchMsgMutation) SuccessCleared() bool {
  4633. _, ok := m.clearedFields[batchmsg.FieldSuccess]
  4634. return ok
  4635. }
  4636. // ResetSuccess resets all changes to the "success" field.
  4637. func (m *BatchMsgMutation) ResetSuccess() {
  4638. m.success = nil
  4639. m.addsuccess = nil
  4640. delete(m.clearedFields, batchmsg.FieldSuccess)
  4641. }
  4642. // SetFail sets the "fail" field.
  4643. func (m *BatchMsgMutation) SetFail(i int32) {
  4644. m.fail = &i
  4645. m.addfail = nil
  4646. }
  4647. // Fail returns the value of the "fail" field in the mutation.
  4648. func (m *BatchMsgMutation) Fail() (r int32, exists bool) {
  4649. v := m.fail
  4650. if v == nil {
  4651. return
  4652. }
  4653. return *v, true
  4654. }
  4655. // OldFail returns the old "fail" field's value of the BatchMsg entity.
  4656. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4657. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4658. func (m *BatchMsgMutation) OldFail(ctx context.Context) (v int32, err error) {
  4659. if !m.op.Is(OpUpdateOne) {
  4660. return v, errors.New("OldFail is only allowed on UpdateOne operations")
  4661. }
  4662. if m.id == nil || m.oldValue == nil {
  4663. return v, errors.New("OldFail requires an ID field in the mutation")
  4664. }
  4665. oldValue, err := m.oldValue(ctx)
  4666. if err != nil {
  4667. return v, fmt.Errorf("querying old value for OldFail: %w", err)
  4668. }
  4669. return oldValue.Fail, nil
  4670. }
  4671. // AddFail adds i to the "fail" field.
  4672. func (m *BatchMsgMutation) AddFail(i int32) {
  4673. if m.addfail != nil {
  4674. *m.addfail += i
  4675. } else {
  4676. m.addfail = &i
  4677. }
  4678. }
  4679. // AddedFail returns the value that was added to the "fail" field in this mutation.
  4680. func (m *BatchMsgMutation) AddedFail() (r int32, exists bool) {
  4681. v := m.addfail
  4682. if v == nil {
  4683. return
  4684. }
  4685. return *v, true
  4686. }
  4687. // ClearFail clears the value of the "fail" field.
  4688. func (m *BatchMsgMutation) ClearFail() {
  4689. m.fail = nil
  4690. m.addfail = nil
  4691. m.clearedFields[batchmsg.FieldFail] = struct{}{}
  4692. }
  4693. // FailCleared returns if the "fail" field was cleared in this mutation.
  4694. func (m *BatchMsgMutation) FailCleared() bool {
  4695. _, ok := m.clearedFields[batchmsg.FieldFail]
  4696. return ok
  4697. }
  4698. // ResetFail resets all changes to the "fail" field.
  4699. func (m *BatchMsgMutation) ResetFail() {
  4700. m.fail = nil
  4701. m.addfail = nil
  4702. delete(m.clearedFields, batchmsg.FieldFail)
  4703. }
  4704. // SetStartTime sets the "start_time" field.
  4705. func (m *BatchMsgMutation) SetStartTime(t time.Time) {
  4706. m.start_time = &t
  4707. }
  4708. // StartTime returns the value of the "start_time" field in the mutation.
  4709. func (m *BatchMsgMutation) StartTime() (r time.Time, exists bool) {
  4710. v := m.start_time
  4711. if v == nil {
  4712. return
  4713. }
  4714. return *v, true
  4715. }
  4716. // OldStartTime returns the old "start_time" field's value of the BatchMsg entity.
  4717. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4718. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4719. func (m *BatchMsgMutation) OldStartTime(ctx context.Context) (v time.Time, err error) {
  4720. if !m.op.Is(OpUpdateOne) {
  4721. return v, errors.New("OldStartTime is only allowed on UpdateOne operations")
  4722. }
  4723. if m.id == nil || m.oldValue == nil {
  4724. return v, errors.New("OldStartTime requires an ID field in the mutation")
  4725. }
  4726. oldValue, err := m.oldValue(ctx)
  4727. if err != nil {
  4728. return v, fmt.Errorf("querying old value for OldStartTime: %w", err)
  4729. }
  4730. return oldValue.StartTime, nil
  4731. }
  4732. // ClearStartTime clears the value of the "start_time" field.
  4733. func (m *BatchMsgMutation) ClearStartTime() {
  4734. m.start_time = nil
  4735. m.clearedFields[batchmsg.FieldStartTime] = struct{}{}
  4736. }
  4737. // StartTimeCleared returns if the "start_time" field was cleared in this mutation.
  4738. func (m *BatchMsgMutation) StartTimeCleared() bool {
  4739. _, ok := m.clearedFields[batchmsg.FieldStartTime]
  4740. return ok
  4741. }
  4742. // ResetStartTime resets all changes to the "start_time" field.
  4743. func (m *BatchMsgMutation) ResetStartTime() {
  4744. m.start_time = nil
  4745. delete(m.clearedFields, batchmsg.FieldStartTime)
  4746. }
  4747. // SetStopTime sets the "stop_time" field.
  4748. func (m *BatchMsgMutation) SetStopTime(t time.Time) {
  4749. m.stop_time = &t
  4750. }
  4751. // StopTime returns the value of the "stop_time" field in the mutation.
  4752. func (m *BatchMsgMutation) StopTime() (r time.Time, exists bool) {
  4753. v := m.stop_time
  4754. if v == nil {
  4755. return
  4756. }
  4757. return *v, true
  4758. }
  4759. // OldStopTime returns the old "stop_time" field's value of the BatchMsg entity.
  4760. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4761. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4762. func (m *BatchMsgMutation) OldStopTime(ctx context.Context) (v time.Time, err error) {
  4763. if !m.op.Is(OpUpdateOne) {
  4764. return v, errors.New("OldStopTime is only allowed on UpdateOne operations")
  4765. }
  4766. if m.id == nil || m.oldValue == nil {
  4767. return v, errors.New("OldStopTime requires an ID field in the mutation")
  4768. }
  4769. oldValue, err := m.oldValue(ctx)
  4770. if err != nil {
  4771. return v, fmt.Errorf("querying old value for OldStopTime: %w", err)
  4772. }
  4773. return oldValue.StopTime, nil
  4774. }
  4775. // ClearStopTime clears the value of the "stop_time" field.
  4776. func (m *BatchMsgMutation) ClearStopTime() {
  4777. m.stop_time = nil
  4778. m.clearedFields[batchmsg.FieldStopTime] = struct{}{}
  4779. }
  4780. // StopTimeCleared returns if the "stop_time" field was cleared in this mutation.
  4781. func (m *BatchMsgMutation) StopTimeCleared() bool {
  4782. _, ok := m.clearedFields[batchmsg.FieldStopTime]
  4783. return ok
  4784. }
  4785. // ResetStopTime resets all changes to the "stop_time" field.
  4786. func (m *BatchMsgMutation) ResetStopTime() {
  4787. m.stop_time = nil
  4788. delete(m.clearedFields, batchmsg.FieldStopTime)
  4789. }
  4790. // SetSendTime sets the "send_time" field.
  4791. func (m *BatchMsgMutation) SetSendTime(t time.Time) {
  4792. m.send_time = &t
  4793. }
  4794. // SendTime returns the value of the "send_time" field in the mutation.
  4795. func (m *BatchMsgMutation) SendTime() (r time.Time, exists bool) {
  4796. v := m.send_time
  4797. if v == nil {
  4798. return
  4799. }
  4800. return *v, true
  4801. }
  4802. // OldSendTime returns the old "send_time" field's value of the BatchMsg entity.
  4803. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4804. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4805. func (m *BatchMsgMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  4806. if !m.op.Is(OpUpdateOne) {
  4807. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  4808. }
  4809. if m.id == nil || m.oldValue == nil {
  4810. return v, errors.New("OldSendTime requires an ID field in the mutation")
  4811. }
  4812. oldValue, err := m.oldValue(ctx)
  4813. if err != nil {
  4814. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  4815. }
  4816. return oldValue.SendTime, nil
  4817. }
  4818. // ClearSendTime clears the value of the "send_time" field.
  4819. func (m *BatchMsgMutation) ClearSendTime() {
  4820. m.send_time = nil
  4821. m.clearedFields[batchmsg.FieldSendTime] = struct{}{}
  4822. }
  4823. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  4824. func (m *BatchMsgMutation) SendTimeCleared() bool {
  4825. _, ok := m.clearedFields[batchmsg.FieldSendTime]
  4826. return ok
  4827. }
  4828. // ResetSendTime resets all changes to the "send_time" field.
  4829. func (m *BatchMsgMutation) ResetSendTime() {
  4830. m.send_time = nil
  4831. delete(m.clearedFields, batchmsg.FieldSendTime)
  4832. }
  4833. // SetType sets the "type" field.
  4834. func (m *BatchMsgMutation) SetType(i int32) {
  4835. m._type = &i
  4836. m.add_type = nil
  4837. }
  4838. // GetType returns the value of the "type" field in the mutation.
  4839. func (m *BatchMsgMutation) GetType() (r int32, exists bool) {
  4840. v := m._type
  4841. if v == nil {
  4842. return
  4843. }
  4844. return *v, true
  4845. }
  4846. // OldType returns the old "type" field's value of the BatchMsg entity.
  4847. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4848. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4849. func (m *BatchMsgMutation) OldType(ctx context.Context) (v int32, err error) {
  4850. if !m.op.Is(OpUpdateOne) {
  4851. return v, errors.New("OldType is only allowed on UpdateOne operations")
  4852. }
  4853. if m.id == nil || m.oldValue == nil {
  4854. return v, errors.New("OldType requires an ID field in the mutation")
  4855. }
  4856. oldValue, err := m.oldValue(ctx)
  4857. if err != nil {
  4858. return v, fmt.Errorf("querying old value for OldType: %w", err)
  4859. }
  4860. return oldValue.Type, nil
  4861. }
  4862. // AddType adds i to the "type" field.
  4863. func (m *BatchMsgMutation) AddType(i int32) {
  4864. if m.add_type != nil {
  4865. *m.add_type += i
  4866. } else {
  4867. m.add_type = &i
  4868. }
  4869. }
  4870. // AddedType returns the value that was added to the "type" field in this mutation.
  4871. func (m *BatchMsgMutation) AddedType() (r int32, exists bool) {
  4872. v := m.add_type
  4873. if v == nil {
  4874. return
  4875. }
  4876. return *v, true
  4877. }
  4878. // ClearType clears the value of the "type" field.
  4879. func (m *BatchMsgMutation) ClearType() {
  4880. m._type = nil
  4881. m.add_type = nil
  4882. m.clearedFields[batchmsg.FieldType] = struct{}{}
  4883. }
  4884. // TypeCleared returns if the "type" field was cleared in this mutation.
  4885. func (m *BatchMsgMutation) TypeCleared() bool {
  4886. _, ok := m.clearedFields[batchmsg.FieldType]
  4887. return ok
  4888. }
  4889. // ResetType resets all changes to the "type" field.
  4890. func (m *BatchMsgMutation) ResetType() {
  4891. m._type = nil
  4892. m.add_type = nil
  4893. delete(m.clearedFields, batchmsg.FieldType)
  4894. }
  4895. // SetOrganizationID sets the "organization_id" field.
  4896. func (m *BatchMsgMutation) SetOrganizationID(u uint64) {
  4897. m.organization_id = &u
  4898. m.addorganization_id = nil
  4899. }
  4900. // OrganizationID returns the value of the "organization_id" field in the mutation.
  4901. func (m *BatchMsgMutation) OrganizationID() (r uint64, exists bool) {
  4902. v := m.organization_id
  4903. if v == nil {
  4904. return
  4905. }
  4906. return *v, true
  4907. }
  4908. // OldOrganizationID returns the old "organization_id" field's value of the BatchMsg entity.
  4909. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4910. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4911. func (m *BatchMsgMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  4912. if !m.op.Is(OpUpdateOne) {
  4913. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  4914. }
  4915. if m.id == nil || m.oldValue == nil {
  4916. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  4917. }
  4918. oldValue, err := m.oldValue(ctx)
  4919. if err != nil {
  4920. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  4921. }
  4922. return oldValue.OrganizationID, nil
  4923. }
  4924. // AddOrganizationID adds u to the "organization_id" field.
  4925. func (m *BatchMsgMutation) AddOrganizationID(u int64) {
  4926. if m.addorganization_id != nil {
  4927. *m.addorganization_id += u
  4928. } else {
  4929. m.addorganization_id = &u
  4930. }
  4931. }
  4932. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  4933. func (m *BatchMsgMutation) AddedOrganizationID() (r int64, exists bool) {
  4934. v := m.addorganization_id
  4935. if v == nil {
  4936. return
  4937. }
  4938. return *v, true
  4939. }
  4940. // ResetOrganizationID resets all changes to the "organization_id" field.
  4941. func (m *BatchMsgMutation) ResetOrganizationID() {
  4942. m.organization_id = nil
  4943. m.addorganization_id = nil
  4944. }
  4945. // SetCtype sets the "ctype" field.
  4946. func (m *BatchMsgMutation) SetCtype(u uint64) {
  4947. m.ctype = &u
  4948. m.addctype = nil
  4949. }
  4950. // Ctype returns the value of the "ctype" field in the mutation.
  4951. func (m *BatchMsgMutation) Ctype() (r uint64, exists bool) {
  4952. v := m.ctype
  4953. if v == nil {
  4954. return
  4955. }
  4956. return *v, true
  4957. }
  4958. // OldCtype returns the old "ctype" field's value of the BatchMsg entity.
  4959. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4960. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4961. func (m *BatchMsgMutation) OldCtype(ctx context.Context) (v uint64, err error) {
  4962. if !m.op.Is(OpUpdateOne) {
  4963. return v, errors.New("OldCtype is only allowed on UpdateOne operations")
  4964. }
  4965. if m.id == nil || m.oldValue == nil {
  4966. return v, errors.New("OldCtype requires an ID field in the mutation")
  4967. }
  4968. oldValue, err := m.oldValue(ctx)
  4969. if err != nil {
  4970. return v, fmt.Errorf("querying old value for OldCtype: %w", err)
  4971. }
  4972. return oldValue.Ctype, nil
  4973. }
  4974. // AddCtype adds u to the "ctype" field.
  4975. func (m *BatchMsgMutation) AddCtype(u int64) {
  4976. if m.addctype != nil {
  4977. *m.addctype += u
  4978. } else {
  4979. m.addctype = &u
  4980. }
  4981. }
  4982. // AddedCtype returns the value that was added to the "ctype" field in this mutation.
  4983. func (m *BatchMsgMutation) AddedCtype() (r int64, exists bool) {
  4984. v := m.addctype
  4985. if v == nil {
  4986. return
  4987. }
  4988. return *v, true
  4989. }
  4990. // ResetCtype resets all changes to the "ctype" field.
  4991. func (m *BatchMsgMutation) ResetCtype() {
  4992. m.ctype = nil
  4993. m.addctype = nil
  4994. }
  4995. // SetCc sets the "cc" field.
  4996. func (m *BatchMsgMutation) SetCc(s string) {
  4997. m.cc = &s
  4998. }
  4999. // Cc returns the value of the "cc" field in the mutation.
  5000. func (m *BatchMsgMutation) Cc() (r string, exists bool) {
  5001. v := m.cc
  5002. if v == nil {
  5003. return
  5004. }
  5005. return *v, true
  5006. }
  5007. // OldCc returns the old "cc" field's value of the BatchMsg entity.
  5008. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5009. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5010. func (m *BatchMsgMutation) OldCc(ctx context.Context) (v string, err error) {
  5011. if !m.op.Is(OpUpdateOne) {
  5012. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  5013. }
  5014. if m.id == nil || m.oldValue == nil {
  5015. return v, errors.New("OldCc requires an ID field in the mutation")
  5016. }
  5017. oldValue, err := m.oldValue(ctx)
  5018. if err != nil {
  5019. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  5020. }
  5021. return oldValue.Cc, nil
  5022. }
  5023. // ClearCc clears the value of the "cc" field.
  5024. func (m *BatchMsgMutation) ClearCc() {
  5025. m.cc = nil
  5026. m.clearedFields[batchmsg.FieldCc] = struct{}{}
  5027. }
  5028. // CcCleared returns if the "cc" field was cleared in this mutation.
  5029. func (m *BatchMsgMutation) CcCleared() bool {
  5030. _, ok := m.clearedFields[batchmsg.FieldCc]
  5031. return ok
  5032. }
  5033. // ResetCc resets all changes to the "cc" field.
  5034. func (m *BatchMsgMutation) ResetCc() {
  5035. m.cc = nil
  5036. delete(m.clearedFields, batchmsg.FieldCc)
  5037. }
  5038. // SetPhone sets the "phone" field.
  5039. func (m *BatchMsgMutation) SetPhone(s string) {
  5040. m.phone = &s
  5041. }
  5042. // Phone returns the value of the "phone" field in the mutation.
  5043. func (m *BatchMsgMutation) Phone() (r string, exists bool) {
  5044. v := m.phone
  5045. if v == nil {
  5046. return
  5047. }
  5048. return *v, true
  5049. }
  5050. // OldPhone returns the old "phone" field's value of the BatchMsg entity.
  5051. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5052. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5053. func (m *BatchMsgMutation) OldPhone(ctx context.Context) (v string, err error) {
  5054. if !m.op.Is(OpUpdateOne) {
  5055. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  5056. }
  5057. if m.id == nil || m.oldValue == nil {
  5058. return v, errors.New("OldPhone requires an ID field in the mutation")
  5059. }
  5060. oldValue, err := m.oldValue(ctx)
  5061. if err != nil {
  5062. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  5063. }
  5064. return oldValue.Phone, nil
  5065. }
  5066. // ClearPhone clears the value of the "phone" field.
  5067. func (m *BatchMsgMutation) ClearPhone() {
  5068. m.phone = nil
  5069. m.clearedFields[batchmsg.FieldPhone] = struct{}{}
  5070. }
  5071. // PhoneCleared returns if the "phone" field was cleared in this mutation.
  5072. func (m *BatchMsgMutation) PhoneCleared() bool {
  5073. _, ok := m.clearedFields[batchmsg.FieldPhone]
  5074. return ok
  5075. }
  5076. // ResetPhone resets all changes to the "phone" field.
  5077. func (m *BatchMsgMutation) ResetPhone() {
  5078. m.phone = nil
  5079. delete(m.clearedFields, batchmsg.FieldPhone)
  5080. }
  5081. // Where appends a list predicates to the BatchMsgMutation builder.
  5082. func (m *BatchMsgMutation) Where(ps ...predicate.BatchMsg) {
  5083. m.predicates = append(m.predicates, ps...)
  5084. }
  5085. // WhereP appends storage-level predicates to the BatchMsgMutation builder. Using this method,
  5086. // users can use type-assertion to append predicates that do not depend on any generated package.
  5087. func (m *BatchMsgMutation) WhereP(ps ...func(*sql.Selector)) {
  5088. p := make([]predicate.BatchMsg, len(ps))
  5089. for i := range ps {
  5090. p[i] = ps[i]
  5091. }
  5092. m.Where(p...)
  5093. }
  5094. // Op returns the operation name.
  5095. func (m *BatchMsgMutation) Op() Op {
  5096. return m.op
  5097. }
  5098. // SetOp allows setting the mutation operation.
  5099. func (m *BatchMsgMutation) SetOp(op Op) {
  5100. m.op = op
  5101. }
  5102. // Type returns the node type of this mutation (BatchMsg).
  5103. func (m *BatchMsgMutation) Type() string {
  5104. return m.typ
  5105. }
  5106. // Fields returns all fields that were changed during this mutation. Note that in
  5107. // order to get all numeric fields that were incremented/decremented, call
  5108. // AddedFields().
  5109. func (m *BatchMsgMutation) Fields() []string {
  5110. fields := make([]string, 0, 21)
  5111. if m.created_at != nil {
  5112. fields = append(fields, batchmsg.FieldCreatedAt)
  5113. }
  5114. if m.updated_at != nil {
  5115. fields = append(fields, batchmsg.FieldUpdatedAt)
  5116. }
  5117. if m.deleted_at != nil {
  5118. fields = append(fields, batchmsg.FieldDeletedAt)
  5119. }
  5120. if m.status != nil {
  5121. fields = append(fields, batchmsg.FieldStatus)
  5122. }
  5123. if m.batch_no != nil {
  5124. fields = append(fields, batchmsg.FieldBatchNo)
  5125. }
  5126. if m.task_name != nil {
  5127. fields = append(fields, batchmsg.FieldTaskName)
  5128. }
  5129. if m.fromwxid != nil {
  5130. fields = append(fields, batchmsg.FieldFromwxid)
  5131. }
  5132. if m.msg != nil {
  5133. fields = append(fields, batchmsg.FieldMsg)
  5134. }
  5135. if m.tag != nil {
  5136. fields = append(fields, batchmsg.FieldTag)
  5137. }
  5138. if m.tagids != nil {
  5139. fields = append(fields, batchmsg.FieldTagids)
  5140. }
  5141. if m.total != nil {
  5142. fields = append(fields, batchmsg.FieldTotal)
  5143. }
  5144. if m.success != nil {
  5145. fields = append(fields, batchmsg.FieldSuccess)
  5146. }
  5147. if m.fail != nil {
  5148. fields = append(fields, batchmsg.FieldFail)
  5149. }
  5150. if m.start_time != nil {
  5151. fields = append(fields, batchmsg.FieldStartTime)
  5152. }
  5153. if m.stop_time != nil {
  5154. fields = append(fields, batchmsg.FieldStopTime)
  5155. }
  5156. if m.send_time != nil {
  5157. fields = append(fields, batchmsg.FieldSendTime)
  5158. }
  5159. if m._type != nil {
  5160. fields = append(fields, batchmsg.FieldType)
  5161. }
  5162. if m.organization_id != nil {
  5163. fields = append(fields, batchmsg.FieldOrganizationID)
  5164. }
  5165. if m.ctype != nil {
  5166. fields = append(fields, batchmsg.FieldCtype)
  5167. }
  5168. if m.cc != nil {
  5169. fields = append(fields, batchmsg.FieldCc)
  5170. }
  5171. if m.phone != nil {
  5172. fields = append(fields, batchmsg.FieldPhone)
  5173. }
  5174. return fields
  5175. }
  5176. // Field returns the value of a field with the given name. The second boolean
  5177. // return value indicates that this field was not set, or was not defined in the
  5178. // schema.
  5179. func (m *BatchMsgMutation) Field(name string) (ent.Value, bool) {
  5180. switch name {
  5181. case batchmsg.FieldCreatedAt:
  5182. return m.CreatedAt()
  5183. case batchmsg.FieldUpdatedAt:
  5184. return m.UpdatedAt()
  5185. case batchmsg.FieldDeletedAt:
  5186. return m.DeletedAt()
  5187. case batchmsg.FieldStatus:
  5188. return m.Status()
  5189. case batchmsg.FieldBatchNo:
  5190. return m.BatchNo()
  5191. case batchmsg.FieldTaskName:
  5192. return m.TaskName()
  5193. case batchmsg.FieldFromwxid:
  5194. return m.Fromwxid()
  5195. case batchmsg.FieldMsg:
  5196. return m.Msg()
  5197. case batchmsg.FieldTag:
  5198. return m.Tag()
  5199. case batchmsg.FieldTagids:
  5200. return m.Tagids()
  5201. case batchmsg.FieldTotal:
  5202. return m.Total()
  5203. case batchmsg.FieldSuccess:
  5204. return m.Success()
  5205. case batchmsg.FieldFail:
  5206. return m.Fail()
  5207. case batchmsg.FieldStartTime:
  5208. return m.StartTime()
  5209. case batchmsg.FieldStopTime:
  5210. return m.StopTime()
  5211. case batchmsg.FieldSendTime:
  5212. return m.SendTime()
  5213. case batchmsg.FieldType:
  5214. return m.GetType()
  5215. case batchmsg.FieldOrganizationID:
  5216. return m.OrganizationID()
  5217. case batchmsg.FieldCtype:
  5218. return m.Ctype()
  5219. case batchmsg.FieldCc:
  5220. return m.Cc()
  5221. case batchmsg.FieldPhone:
  5222. return m.Phone()
  5223. }
  5224. return nil, false
  5225. }
  5226. // OldField returns the old value of the field from the database. An error is
  5227. // returned if the mutation operation is not UpdateOne, or the query to the
  5228. // database failed.
  5229. func (m *BatchMsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  5230. switch name {
  5231. case batchmsg.FieldCreatedAt:
  5232. return m.OldCreatedAt(ctx)
  5233. case batchmsg.FieldUpdatedAt:
  5234. return m.OldUpdatedAt(ctx)
  5235. case batchmsg.FieldDeletedAt:
  5236. return m.OldDeletedAt(ctx)
  5237. case batchmsg.FieldStatus:
  5238. return m.OldStatus(ctx)
  5239. case batchmsg.FieldBatchNo:
  5240. return m.OldBatchNo(ctx)
  5241. case batchmsg.FieldTaskName:
  5242. return m.OldTaskName(ctx)
  5243. case batchmsg.FieldFromwxid:
  5244. return m.OldFromwxid(ctx)
  5245. case batchmsg.FieldMsg:
  5246. return m.OldMsg(ctx)
  5247. case batchmsg.FieldTag:
  5248. return m.OldTag(ctx)
  5249. case batchmsg.FieldTagids:
  5250. return m.OldTagids(ctx)
  5251. case batchmsg.FieldTotal:
  5252. return m.OldTotal(ctx)
  5253. case batchmsg.FieldSuccess:
  5254. return m.OldSuccess(ctx)
  5255. case batchmsg.FieldFail:
  5256. return m.OldFail(ctx)
  5257. case batchmsg.FieldStartTime:
  5258. return m.OldStartTime(ctx)
  5259. case batchmsg.FieldStopTime:
  5260. return m.OldStopTime(ctx)
  5261. case batchmsg.FieldSendTime:
  5262. return m.OldSendTime(ctx)
  5263. case batchmsg.FieldType:
  5264. return m.OldType(ctx)
  5265. case batchmsg.FieldOrganizationID:
  5266. return m.OldOrganizationID(ctx)
  5267. case batchmsg.FieldCtype:
  5268. return m.OldCtype(ctx)
  5269. case batchmsg.FieldCc:
  5270. return m.OldCc(ctx)
  5271. case batchmsg.FieldPhone:
  5272. return m.OldPhone(ctx)
  5273. }
  5274. return nil, fmt.Errorf("unknown BatchMsg field %s", name)
  5275. }
  5276. // SetField sets the value of a field with the given name. It returns an error if
  5277. // the field is not defined in the schema, or if the type mismatched the field
  5278. // type.
  5279. func (m *BatchMsgMutation) SetField(name string, value ent.Value) error {
  5280. switch name {
  5281. case batchmsg.FieldCreatedAt:
  5282. v, ok := value.(time.Time)
  5283. if !ok {
  5284. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5285. }
  5286. m.SetCreatedAt(v)
  5287. return nil
  5288. case batchmsg.FieldUpdatedAt:
  5289. v, ok := value.(time.Time)
  5290. if !ok {
  5291. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5292. }
  5293. m.SetUpdatedAt(v)
  5294. return nil
  5295. case batchmsg.FieldDeletedAt:
  5296. v, ok := value.(time.Time)
  5297. if !ok {
  5298. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5299. }
  5300. m.SetDeletedAt(v)
  5301. return nil
  5302. case batchmsg.FieldStatus:
  5303. v, ok := value.(uint8)
  5304. if !ok {
  5305. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5306. }
  5307. m.SetStatus(v)
  5308. return nil
  5309. case batchmsg.FieldBatchNo:
  5310. v, ok := value.(string)
  5311. if !ok {
  5312. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5313. }
  5314. m.SetBatchNo(v)
  5315. return nil
  5316. case batchmsg.FieldTaskName:
  5317. v, ok := value.(string)
  5318. if !ok {
  5319. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5320. }
  5321. m.SetTaskName(v)
  5322. return nil
  5323. case batchmsg.FieldFromwxid:
  5324. v, ok := value.(string)
  5325. if !ok {
  5326. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5327. }
  5328. m.SetFromwxid(v)
  5329. return nil
  5330. case batchmsg.FieldMsg:
  5331. v, ok := value.(string)
  5332. if !ok {
  5333. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5334. }
  5335. m.SetMsg(v)
  5336. return nil
  5337. case batchmsg.FieldTag:
  5338. v, ok := value.(string)
  5339. if !ok {
  5340. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5341. }
  5342. m.SetTag(v)
  5343. return nil
  5344. case batchmsg.FieldTagids:
  5345. v, ok := value.(string)
  5346. if !ok {
  5347. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5348. }
  5349. m.SetTagids(v)
  5350. return nil
  5351. case batchmsg.FieldTotal:
  5352. v, ok := value.(int32)
  5353. if !ok {
  5354. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5355. }
  5356. m.SetTotal(v)
  5357. return nil
  5358. case batchmsg.FieldSuccess:
  5359. v, ok := value.(int32)
  5360. if !ok {
  5361. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5362. }
  5363. m.SetSuccess(v)
  5364. return nil
  5365. case batchmsg.FieldFail:
  5366. v, ok := value.(int32)
  5367. if !ok {
  5368. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5369. }
  5370. m.SetFail(v)
  5371. return nil
  5372. case batchmsg.FieldStartTime:
  5373. v, ok := value.(time.Time)
  5374. if !ok {
  5375. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5376. }
  5377. m.SetStartTime(v)
  5378. return nil
  5379. case batchmsg.FieldStopTime:
  5380. v, ok := value.(time.Time)
  5381. if !ok {
  5382. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5383. }
  5384. m.SetStopTime(v)
  5385. return nil
  5386. case batchmsg.FieldSendTime:
  5387. v, ok := value.(time.Time)
  5388. if !ok {
  5389. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5390. }
  5391. m.SetSendTime(v)
  5392. return nil
  5393. case batchmsg.FieldType:
  5394. v, ok := value.(int32)
  5395. if !ok {
  5396. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5397. }
  5398. m.SetType(v)
  5399. return nil
  5400. case batchmsg.FieldOrganizationID:
  5401. v, ok := value.(uint64)
  5402. if !ok {
  5403. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5404. }
  5405. m.SetOrganizationID(v)
  5406. return nil
  5407. case batchmsg.FieldCtype:
  5408. v, ok := value.(uint64)
  5409. if !ok {
  5410. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5411. }
  5412. m.SetCtype(v)
  5413. return nil
  5414. case batchmsg.FieldCc:
  5415. v, ok := value.(string)
  5416. if !ok {
  5417. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5418. }
  5419. m.SetCc(v)
  5420. return nil
  5421. case batchmsg.FieldPhone:
  5422. v, ok := value.(string)
  5423. if !ok {
  5424. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5425. }
  5426. m.SetPhone(v)
  5427. return nil
  5428. }
  5429. return fmt.Errorf("unknown BatchMsg field %s", name)
  5430. }
  5431. // AddedFields returns all numeric fields that were incremented/decremented during
  5432. // this mutation.
  5433. func (m *BatchMsgMutation) AddedFields() []string {
  5434. var fields []string
  5435. if m.addstatus != nil {
  5436. fields = append(fields, batchmsg.FieldStatus)
  5437. }
  5438. if m.addtotal != nil {
  5439. fields = append(fields, batchmsg.FieldTotal)
  5440. }
  5441. if m.addsuccess != nil {
  5442. fields = append(fields, batchmsg.FieldSuccess)
  5443. }
  5444. if m.addfail != nil {
  5445. fields = append(fields, batchmsg.FieldFail)
  5446. }
  5447. if m.add_type != nil {
  5448. fields = append(fields, batchmsg.FieldType)
  5449. }
  5450. if m.addorganization_id != nil {
  5451. fields = append(fields, batchmsg.FieldOrganizationID)
  5452. }
  5453. if m.addctype != nil {
  5454. fields = append(fields, batchmsg.FieldCtype)
  5455. }
  5456. return fields
  5457. }
  5458. // AddedField returns the numeric value that was incremented/decremented on a field
  5459. // with the given name. The second boolean return value indicates that this field
  5460. // was not set, or was not defined in the schema.
  5461. func (m *BatchMsgMutation) AddedField(name string) (ent.Value, bool) {
  5462. switch name {
  5463. case batchmsg.FieldStatus:
  5464. return m.AddedStatus()
  5465. case batchmsg.FieldTotal:
  5466. return m.AddedTotal()
  5467. case batchmsg.FieldSuccess:
  5468. return m.AddedSuccess()
  5469. case batchmsg.FieldFail:
  5470. return m.AddedFail()
  5471. case batchmsg.FieldType:
  5472. return m.AddedType()
  5473. case batchmsg.FieldOrganizationID:
  5474. return m.AddedOrganizationID()
  5475. case batchmsg.FieldCtype:
  5476. return m.AddedCtype()
  5477. }
  5478. return nil, false
  5479. }
  5480. // AddField adds the value to the field with the given name. It returns an error if
  5481. // the field is not defined in the schema, or if the type mismatched the field
  5482. // type.
  5483. func (m *BatchMsgMutation) AddField(name string, value ent.Value) error {
  5484. switch name {
  5485. case batchmsg.FieldStatus:
  5486. v, ok := value.(int8)
  5487. if !ok {
  5488. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5489. }
  5490. m.AddStatus(v)
  5491. return nil
  5492. case batchmsg.FieldTotal:
  5493. v, ok := value.(int32)
  5494. if !ok {
  5495. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5496. }
  5497. m.AddTotal(v)
  5498. return nil
  5499. case batchmsg.FieldSuccess:
  5500. v, ok := value.(int32)
  5501. if !ok {
  5502. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5503. }
  5504. m.AddSuccess(v)
  5505. return nil
  5506. case batchmsg.FieldFail:
  5507. v, ok := value.(int32)
  5508. if !ok {
  5509. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5510. }
  5511. m.AddFail(v)
  5512. return nil
  5513. case batchmsg.FieldType:
  5514. v, ok := value.(int32)
  5515. if !ok {
  5516. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5517. }
  5518. m.AddType(v)
  5519. return nil
  5520. case batchmsg.FieldOrganizationID:
  5521. v, ok := value.(int64)
  5522. if !ok {
  5523. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5524. }
  5525. m.AddOrganizationID(v)
  5526. return nil
  5527. case batchmsg.FieldCtype:
  5528. v, ok := value.(int64)
  5529. if !ok {
  5530. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5531. }
  5532. m.AddCtype(v)
  5533. return nil
  5534. }
  5535. return fmt.Errorf("unknown BatchMsg numeric field %s", name)
  5536. }
  5537. // ClearedFields returns all nullable fields that were cleared during this
  5538. // mutation.
  5539. func (m *BatchMsgMutation) ClearedFields() []string {
  5540. var fields []string
  5541. if m.FieldCleared(batchmsg.FieldDeletedAt) {
  5542. fields = append(fields, batchmsg.FieldDeletedAt)
  5543. }
  5544. if m.FieldCleared(batchmsg.FieldStatus) {
  5545. fields = append(fields, batchmsg.FieldStatus)
  5546. }
  5547. if m.FieldCleared(batchmsg.FieldBatchNo) {
  5548. fields = append(fields, batchmsg.FieldBatchNo)
  5549. }
  5550. if m.FieldCleared(batchmsg.FieldTaskName) {
  5551. fields = append(fields, batchmsg.FieldTaskName)
  5552. }
  5553. if m.FieldCleared(batchmsg.FieldFromwxid) {
  5554. fields = append(fields, batchmsg.FieldFromwxid)
  5555. }
  5556. if m.FieldCleared(batchmsg.FieldMsg) {
  5557. fields = append(fields, batchmsg.FieldMsg)
  5558. }
  5559. if m.FieldCleared(batchmsg.FieldTag) {
  5560. fields = append(fields, batchmsg.FieldTag)
  5561. }
  5562. if m.FieldCleared(batchmsg.FieldTagids) {
  5563. fields = append(fields, batchmsg.FieldTagids)
  5564. }
  5565. if m.FieldCleared(batchmsg.FieldTotal) {
  5566. fields = append(fields, batchmsg.FieldTotal)
  5567. }
  5568. if m.FieldCleared(batchmsg.FieldSuccess) {
  5569. fields = append(fields, batchmsg.FieldSuccess)
  5570. }
  5571. if m.FieldCleared(batchmsg.FieldFail) {
  5572. fields = append(fields, batchmsg.FieldFail)
  5573. }
  5574. if m.FieldCleared(batchmsg.FieldStartTime) {
  5575. fields = append(fields, batchmsg.FieldStartTime)
  5576. }
  5577. if m.FieldCleared(batchmsg.FieldStopTime) {
  5578. fields = append(fields, batchmsg.FieldStopTime)
  5579. }
  5580. if m.FieldCleared(batchmsg.FieldSendTime) {
  5581. fields = append(fields, batchmsg.FieldSendTime)
  5582. }
  5583. if m.FieldCleared(batchmsg.FieldType) {
  5584. fields = append(fields, batchmsg.FieldType)
  5585. }
  5586. if m.FieldCleared(batchmsg.FieldCc) {
  5587. fields = append(fields, batchmsg.FieldCc)
  5588. }
  5589. if m.FieldCleared(batchmsg.FieldPhone) {
  5590. fields = append(fields, batchmsg.FieldPhone)
  5591. }
  5592. return fields
  5593. }
  5594. // FieldCleared returns a boolean indicating if a field with the given name was
  5595. // cleared in this mutation.
  5596. func (m *BatchMsgMutation) FieldCleared(name string) bool {
  5597. _, ok := m.clearedFields[name]
  5598. return ok
  5599. }
  5600. // ClearField clears the value of the field with the given name. It returns an
  5601. // error if the field is not defined in the schema.
  5602. func (m *BatchMsgMutation) ClearField(name string) error {
  5603. switch name {
  5604. case batchmsg.FieldDeletedAt:
  5605. m.ClearDeletedAt()
  5606. return nil
  5607. case batchmsg.FieldStatus:
  5608. m.ClearStatus()
  5609. return nil
  5610. case batchmsg.FieldBatchNo:
  5611. m.ClearBatchNo()
  5612. return nil
  5613. case batchmsg.FieldTaskName:
  5614. m.ClearTaskName()
  5615. return nil
  5616. case batchmsg.FieldFromwxid:
  5617. m.ClearFromwxid()
  5618. return nil
  5619. case batchmsg.FieldMsg:
  5620. m.ClearMsg()
  5621. return nil
  5622. case batchmsg.FieldTag:
  5623. m.ClearTag()
  5624. return nil
  5625. case batchmsg.FieldTagids:
  5626. m.ClearTagids()
  5627. return nil
  5628. case batchmsg.FieldTotal:
  5629. m.ClearTotal()
  5630. return nil
  5631. case batchmsg.FieldSuccess:
  5632. m.ClearSuccess()
  5633. return nil
  5634. case batchmsg.FieldFail:
  5635. m.ClearFail()
  5636. return nil
  5637. case batchmsg.FieldStartTime:
  5638. m.ClearStartTime()
  5639. return nil
  5640. case batchmsg.FieldStopTime:
  5641. m.ClearStopTime()
  5642. return nil
  5643. case batchmsg.FieldSendTime:
  5644. m.ClearSendTime()
  5645. return nil
  5646. case batchmsg.FieldType:
  5647. m.ClearType()
  5648. return nil
  5649. case batchmsg.FieldCc:
  5650. m.ClearCc()
  5651. return nil
  5652. case batchmsg.FieldPhone:
  5653. m.ClearPhone()
  5654. return nil
  5655. }
  5656. return fmt.Errorf("unknown BatchMsg nullable field %s", name)
  5657. }
  5658. // ResetField resets all changes in the mutation for the field with the given name.
  5659. // It returns an error if the field is not defined in the schema.
  5660. func (m *BatchMsgMutation) ResetField(name string) error {
  5661. switch name {
  5662. case batchmsg.FieldCreatedAt:
  5663. m.ResetCreatedAt()
  5664. return nil
  5665. case batchmsg.FieldUpdatedAt:
  5666. m.ResetUpdatedAt()
  5667. return nil
  5668. case batchmsg.FieldDeletedAt:
  5669. m.ResetDeletedAt()
  5670. return nil
  5671. case batchmsg.FieldStatus:
  5672. m.ResetStatus()
  5673. return nil
  5674. case batchmsg.FieldBatchNo:
  5675. m.ResetBatchNo()
  5676. return nil
  5677. case batchmsg.FieldTaskName:
  5678. m.ResetTaskName()
  5679. return nil
  5680. case batchmsg.FieldFromwxid:
  5681. m.ResetFromwxid()
  5682. return nil
  5683. case batchmsg.FieldMsg:
  5684. m.ResetMsg()
  5685. return nil
  5686. case batchmsg.FieldTag:
  5687. m.ResetTag()
  5688. return nil
  5689. case batchmsg.FieldTagids:
  5690. m.ResetTagids()
  5691. return nil
  5692. case batchmsg.FieldTotal:
  5693. m.ResetTotal()
  5694. return nil
  5695. case batchmsg.FieldSuccess:
  5696. m.ResetSuccess()
  5697. return nil
  5698. case batchmsg.FieldFail:
  5699. m.ResetFail()
  5700. return nil
  5701. case batchmsg.FieldStartTime:
  5702. m.ResetStartTime()
  5703. return nil
  5704. case batchmsg.FieldStopTime:
  5705. m.ResetStopTime()
  5706. return nil
  5707. case batchmsg.FieldSendTime:
  5708. m.ResetSendTime()
  5709. return nil
  5710. case batchmsg.FieldType:
  5711. m.ResetType()
  5712. return nil
  5713. case batchmsg.FieldOrganizationID:
  5714. m.ResetOrganizationID()
  5715. return nil
  5716. case batchmsg.FieldCtype:
  5717. m.ResetCtype()
  5718. return nil
  5719. case batchmsg.FieldCc:
  5720. m.ResetCc()
  5721. return nil
  5722. case batchmsg.FieldPhone:
  5723. m.ResetPhone()
  5724. return nil
  5725. }
  5726. return fmt.Errorf("unknown BatchMsg field %s", name)
  5727. }
  5728. // AddedEdges returns all edge names that were set/added in this mutation.
  5729. func (m *BatchMsgMutation) AddedEdges() []string {
  5730. edges := make([]string, 0, 0)
  5731. return edges
  5732. }
  5733. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  5734. // name in this mutation.
  5735. func (m *BatchMsgMutation) AddedIDs(name string) []ent.Value {
  5736. return nil
  5737. }
  5738. // RemovedEdges returns all edge names that were removed in this mutation.
  5739. func (m *BatchMsgMutation) RemovedEdges() []string {
  5740. edges := make([]string, 0, 0)
  5741. return edges
  5742. }
  5743. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  5744. // the given name in this mutation.
  5745. func (m *BatchMsgMutation) RemovedIDs(name string) []ent.Value {
  5746. return nil
  5747. }
  5748. // ClearedEdges returns all edge names that were cleared in this mutation.
  5749. func (m *BatchMsgMutation) ClearedEdges() []string {
  5750. edges := make([]string, 0, 0)
  5751. return edges
  5752. }
  5753. // EdgeCleared returns a boolean which indicates if the edge with the given name
  5754. // was cleared in this mutation.
  5755. func (m *BatchMsgMutation) EdgeCleared(name string) bool {
  5756. return false
  5757. }
  5758. // ClearEdge clears the value of the edge with the given name. It returns an error
  5759. // if that edge is not defined in the schema.
  5760. func (m *BatchMsgMutation) ClearEdge(name string) error {
  5761. return fmt.Errorf("unknown BatchMsg unique edge %s", name)
  5762. }
  5763. // ResetEdge resets all changes to the edge with the given name in this mutation.
  5764. // It returns an error if the edge is not defined in the schema.
  5765. func (m *BatchMsgMutation) ResetEdge(name string) error {
  5766. return fmt.Errorf("unknown BatchMsg edge %s", name)
  5767. }
  5768. // CategoryMutation represents an operation that mutates the Category nodes in the graph.
  5769. type CategoryMutation struct {
  5770. config
  5771. op Op
  5772. typ string
  5773. id *uint64
  5774. created_at *time.Time
  5775. updated_at *time.Time
  5776. deleted_at *time.Time
  5777. name *string
  5778. organization_id *uint64
  5779. addorganization_id *int64
  5780. clearedFields map[string]struct{}
  5781. done bool
  5782. oldValue func(context.Context) (*Category, error)
  5783. predicates []predicate.Category
  5784. }
  5785. var _ ent.Mutation = (*CategoryMutation)(nil)
  5786. // categoryOption allows management of the mutation configuration using functional options.
  5787. type categoryOption func(*CategoryMutation)
  5788. // newCategoryMutation creates new mutation for the Category entity.
  5789. func newCategoryMutation(c config, op Op, opts ...categoryOption) *CategoryMutation {
  5790. m := &CategoryMutation{
  5791. config: c,
  5792. op: op,
  5793. typ: TypeCategory,
  5794. clearedFields: make(map[string]struct{}),
  5795. }
  5796. for _, opt := range opts {
  5797. opt(m)
  5798. }
  5799. return m
  5800. }
  5801. // withCategoryID sets the ID field of the mutation.
  5802. func withCategoryID(id uint64) categoryOption {
  5803. return func(m *CategoryMutation) {
  5804. var (
  5805. err error
  5806. once sync.Once
  5807. value *Category
  5808. )
  5809. m.oldValue = func(ctx context.Context) (*Category, error) {
  5810. once.Do(func() {
  5811. if m.done {
  5812. err = errors.New("querying old values post mutation is not allowed")
  5813. } else {
  5814. value, err = m.Client().Category.Get(ctx, id)
  5815. }
  5816. })
  5817. return value, err
  5818. }
  5819. m.id = &id
  5820. }
  5821. }
  5822. // withCategory sets the old Category of the mutation.
  5823. func withCategory(node *Category) categoryOption {
  5824. return func(m *CategoryMutation) {
  5825. m.oldValue = func(context.Context) (*Category, error) {
  5826. return node, nil
  5827. }
  5828. m.id = &node.ID
  5829. }
  5830. }
  5831. // Client returns a new `ent.Client` from the mutation. If the mutation was
  5832. // executed in a transaction (ent.Tx), a transactional client is returned.
  5833. func (m CategoryMutation) Client() *Client {
  5834. client := &Client{config: m.config}
  5835. client.init()
  5836. return client
  5837. }
  5838. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  5839. // it returns an error otherwise.
  5840. func (m CategoryMutation) Tx() (*Tx, error) {
  5841. if _, ok := m.driver.(*txDriver); !ok {
  5842. return nil, errors.New("ent: mutation is not running in a transaction")
  5843. }
  5844. tx := &Tx{config: m.config}
  5845. tx.init()
  5846. return tx, nil
  5847. }
  5848. // SetID sets the value of the id field. Note that this
  5849. // operation is only accepted on creation of Category entities.
  5850. func (m *CategoryMutation) SetID(id uint64) {
  5851. m.id = &id
  5852. }
  5853. // ID returns the ID value in the mutation. Note that the ID is only available
  5854. // if it was provided to the builder or after it was returned from the database.
  5855. func (m *CategoryMutation) ID() (id uint64, exists bool) {
  5856. if m.id == nil {
  5857. return
  5858. }
  5859. return *m.id, true
  5860. }
  5861. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  5862. // That means, if the mutation is applied within a transaction with an isolation level such
  5863. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  5864. // or updated by the mutation.
  5865. func (m *CategoryMutation) IDs(ctx context.Context) ([]uint64, error) {
  5866. switch {
  5867. case m.op.Is(OpUpdateOne | OpDeleteOne):
  5868. id, exists := m.ID()
  5869. if exists {
  5870. return []uint64{id}, nil
  5871. }
  5872. fallthrough
  5873. case m.op.Is(OpUpdate | OpDelete):
  5874. return m.Client().Category.Query().Where(m.predicates...).IDs(ctx)
  5875. default:
  5876. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  5877. }
  5878. }
  5879. // SetCreatedAt sets the "created_at" field.
  5880. func (m *CategoryMutation) SetCreatedAt(t time.Time) {
  5881. m.created_at = &t
  5882. }
  5883. // CreatedAt returns the value of the "created_at" field in the mutation.
  5884. func (m *CategoryMutation) CreatedAt() (r time.Time, exists bool) {
  5885. v := m.created_at
  5886. if v == nil {
  5887. return
  5888. }
  5889. return *v, true
  5890. }
  5891. // OldCreatedAt returns the old "created_at" field's value of the Category entity.
  5892. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  5893. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5894. func (m *CategoryMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  5895. if !m.op.Is(OpUpdateOne) {
  5896. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  5897. }
  5898. if m.id == nil || m.oldValue == nil {
  5899. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  5900. }
  5901. oldValue, err := m.oldValue(ctx)
  5902. if err != nil {
  5903. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  5904. }
  5905. return oldValue.CreatedAt, nil
  5906. }
  5907. // ResetCreatedAt resets all changes to the "created_at" field.
  5908. func (m *CategoryMutation) ResetCreatedAt() {
  5909. m.created_at = nil
  5910. }
  5911. // SetUpdatedAt sets the "updated_at" field.
  5912. func (m *CategoryMutation) SetUpdatedAt(t time.Time) {
  5913. m.updated_at = &t
  5914. }
  5915. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  5916. func (m *CategoryMutation) UpdatedAt() (r time.Time, exists bool) {
  5917. v := m.updated_at
  5918. if v == nil {
  5919. return
  5920. }
  5921. return *v, true
  5922. }
  5923. // OldUpdatedAt returns the old "updated_at" field's value of the Category entity.
  5924. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  5925. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5926. func (m *CategoryMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  5927. if !m.op.Is(OpUpdateOne) {
  5928. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  5929. }
  5930. if m.id == nil || m.oldValue == nil {
  5931. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  5932. }
  5933. oldValue, err := m.oldValue(ctx)
  5934. if err != nil {
  5935. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  5936. }
  5937. return oldValue.UpdatedAt, nil
  5938. }
  5939. // ResetUpdatedAt resets all changes to the "updated_at" field.
  5940. func (m *CategoryMutation) ResetUpdatedAt() {
  5941. m.updated_at = nil
  5942. }
  5943. // SetDeletedAt sets the "deleted_at" field.
  5944. func (m *CategoryMutation) SetDeletedAt(t time.Time) {
  5945. m.deleted_at = &t
  5946. }
  5947. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  5948. func (m *CategoryMutation) DeletedAt() (r time.Time, exists bool) {
  5949. v := m.deleted_at
  5950. if v == nil {
  5951. return
  5952. }
  5953. return *v, true
  5954. }
  5955. // OldDeletedAt returns the old "deleted_at" field's value of the Category entity.
  5956. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  5957. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5958. func (m *CategoryMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  5959. if !m.op.Is(OpUpdateOne) {
  5960. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  5961. }
  5962. if m.id == nil || m.oldValue == nil {
  5963. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  5964. }
  5965. oldValue, err := m.oldValue(ctx)
  5966. if err != nil {
  5967. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  5968. }
  5969. return oldValue.DeletedAt, nil
  5970. }
  5971. // ClearDeletedAt clears the value of the "deleted_at" field.
  5972. func (m *CategoryMutation) ClearDeletedAt() {
  5973. m.deleted_at = nil
  5974. m.clearedFields[category.FieldDeletedAt] = struct{}{}
  5975. }
  5976. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  5977. func (m *CategoryMutation) DeletedAtCleared() bool {
  5978. _, ok := m.clearedFields[category.FieldDeletedAt]
  5979. return ok
  5980. }
  5981. // ResetDeletedAt resets all changes to the "deleted_at" field.
  5982. func (m *CategoryMutation) ResetDeletedAt() {
  5983. m.deleted_at = nil
  5984. delete(m.clearedFields, category.FieldDeletedAt)
  5985. }
  5986. // SetName sets the "name" field.
  5987. func (m *CategoryMutation) SetName(s string) {
  5988. m.name = &s
  5989. }
  5990. // Name returns the value of the "name" field in the mutation.
  5991. func (m *CategoryMutation) Name() (r string, exists bool) {
  5992. v := m.name
  5993. if v == nil {
  5994. return
  5995. }
  5996. return *v, true
  5997. }
  5998. // OldName returns the old "name" field's value of the Category entity.
  5999. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  6000. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6001. func (m *CategoryMutation) OldName(ctx context.Context) (v string, err error) {
  6002. if !m.op.Is(OpUpdateOne) {
  6003. return v, errors.New("OldName is only allowed on UpdateOne operations")
  6004. }
  6005. if m.id == nil || m.oldValue == nil {
  6006. return v, errors.New("OldName requires an ID field in the mutation")
  6007. }
  6008. oldValue, err := m.oldValue(ctx)
  6009. if err != nil {
  6010. return v, fmt.Errorf("querying old value for OldName: %w", err)
  6011. }
  6012. return oldValue.Name, nil
  6013. }
  6014. // ResetName resets all changes to the "name" field.
  6015. func (m *CategoryMutation) ResetName() {
  6016. m.name = nil
  6017. }
  6018. // SetOrganizationID sets the "organization_id" field.
  6019. func (m *CategoryMutation) SetOrganizationID(u uint64) {
  6020. m.organization_id = &u
  6021. m.addorganization_id = nil
  6022. }
  6023. // OrganizationID returns the value of the "organization_id" field in the mutation.
  6024. func (m *CategoryMutation) OrganizationID() (r uint64, exists bool) {
  6025. v := m.organization_id
  6026. if v == nil {
  6027. return
  6028. }
  6029. return *v, true
  6030. }
  6031. // OldOrganizationID returns the old "organization_id" field's value of the Category entity.
  6032. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  6033. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6034. func (m *CategoryMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  6035. if !m.op.Is(OpUpdateOne) {
  6036. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  6037. }
  6038. if m.id == nil || m.oldValue == nil {
  6039. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  6040. }
  6041. oldValue, err := m.oldValue(ctx)
  6042. if err != nil {
  6043. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  6044. }
  6045. return oldValue.OrganizationID, nil
  6046. }
  6047. // AddOrganizationID adds u to the "organization_id" field.
  6048. func (m *CategoryMutation) AddOrganizationID(u int64) {
  6049. if m.addorganization_id != nil {
  6050. *m.addorganization_id += u
  6051. } else {
  6052. m.addorganization_id = &u
  6053. }
  6054. }
  6055. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  6056. func (m *CategoryMutation) AddedOrganizationID() (r int64, exists bool) {
  6057. v := m.addorganization_id
  6058. if v == nil {
  6059. return
  6060. }
  6061. return *v, true
  6062. }
  6063. // ResetOrganizationID resets all changes to the "organization_id" field.
  6064. func (m *CategoryMutation) ResetOrganizationID() {
  6065. m.organization_id = nil
  6066. m.addorganization_id = nil
  6067. }
  6068. // Where appends a list predicates to the CategoryMutation builder.
  6069. func (m *CategoryMutation) Where(ps ...predicate.Category) {
  6070. m.predicates = append(m.predicates, ps...)
  6071. }
  6072. // WhereP appends storage-level predicates to the CategoryMutation builder. Using this method,
  6073. // users can use type-assertion to append predicates that do not depend on any generated package.
  6074. func (m *CategoryMutation) WhereP(ps ...func(*sql.Selector)) {
  6075. p := make([]predicate.Category, len(ps))
  6076. for i := range ps {
  6077. p[i] = ps[i]
  6078. }
  6079. m.Where(p...)
  6080. }
  6081. // Op returns the operation name.
  6082. func (m *CategoryMutation) Op() Op {
  6083. return m.op
  6084. }
  6085. // SetOp allows setting the mutation operation.
  6086. func (m *CategoryMutation) SetOp(op Op) {
  6087. m.op = op
  6088. }
  6089. // Type returns the node type of this mutation (Category).
  6090. func (m *CategoryMutation) Type() string {
  6091. return m.typ
  6092. }
  6093. // Fields returns all fields that were changed during this mutation. Note that in
  6094. // order to get all numeric fields that were incremented/decremented, call
  6095. // AddedFields().
  6096. func (m *CategoryMutation) Fields() []string {
  6097. fields := make([]string, 0, 5)
  6098. if m.created_at != nil {
  6099. fields = append(fields, category.FieldCreatedAt)
  6100. }
  6101. if m.updated_at != nil {
  6102. fields = append(fields, category.FieldUpdatedAt)
  6103. }
  6104. if m.deleted_at != nil {
  6105. fields = append(fields, category.FieldDeletedAt)
  6106. }
  6107. if m.name != nil {
  6108. fields = append(fields, category.FieldName)
  6109. }
  6110. if m.organization_id != nil {
  6111. fields = append(fields, category.FieldOrganizationID)
  6112. }
  6113. return fields
  6114. }
  6115. // Field returns the value of a field with the given name. The second boolean
  6116. // return value indicates that this field was not set, or was not defined in the
  6117. // schema.
  6118. func (m *CategoryMutation) Field(name string) (ent.Value, bool) {
  6119. switch name {
  6120. case category.FieldCreatedAt:
  6121. return m.CreatedAt()
  6122. case category.FieldUpdatedAt:
  6123. return m.UpdatedAt()
  6124. case category.FieldDeletedAt:
  6125. return m.DeletedAt()
  6126. case category.FieldName:
  6127. return m.Name()
  6128. case category.FieldOrganizationID:
  6129. return m.OrganizationID()
  6130. }
  6131. return nil, false
  6132. }
  6133. // OldField returns the old value of the field from the database. An error is
  6134. // returned if the mutation operation is not UpdateOne, or the query to the
  6135. // database failed.
  6136. func (m *CategoryMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  6137. switch name {
  6138. case category.FieldCreatedAt:
  6139. return m.OldCreatedAt(ctx)
  6140. case category.FieldUpdatedAt:
  6141. return m.OldUpdatedAt(ctx)
  6142. case category.FieldDeletedAt:
  6143. return m.OldDeletedAt(ctx)
  6144. case category.FieldName:
  6145. return m.OldName(ctx)
  6146. case category.FieldOrganizationID:
  6147. return m.OldOrganizationID(ctx)
  6148. }
  6149. return nil, fmt.Errorf("unknown Category field %s", name)
  6150. }
  6151. // SetField sets the value of a field with the given name. It returns an error if
  6152. // the field is not defined in the schema, or if the type mismatched the field
  6153. // type.
  6154. func (m *CategoryMutation) SetField(name string, value ent.Value) error {
  6155. switch name {
  6156. case category.FieldCreatedAt:
  6157. v, ok := value.(time.Time)
  6158. if !ok {
  6159. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6160. }
  6161. m.SetCreatedAt(v)
  6162. return nil
  6163. case category.FieldUpdatedAt:
  6164. v, ok := value.(time.Time)
  6165. if !ok {
  6166. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6167. }
  6168. m.SetUpdatedAt(v)
  6169. return nil
  6170. case category.FieldDeletedAt:
  6171. v, ok := value.(time.Time)
  6172. if !ok {
  6173. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6174. }
  6175. m.SetDeletedAt(v)
  6176. return nil
  6177. case category.FieldName:
  6178. v, ok := value.(string)
  6179. if !ok {
  6180. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6181. }
  6182. m.SetName(v)
  6183. return nil
  6184. case category.FieldOrganizationID:
  6185. v, ok := value.(uint64)
  6186. if !ok {
  6187. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6188. }
  6189. m.SetOrganizationID(v)
  6190. return nil
  6191. }
  6192. return fmt.Errorf("unknown Category field %s", name)
  6193. }
  6194. // AddedFields returns all numeric fields that were incremented/decremented during
  6195. // this mutation.
  6196. func (m *CategoryMutation) AddedFields() []string {
  6197. var fields []string
  6198. if m.addorganization_id != nil {
  6199. fields = append(fields, category.FieldOrganizationID)
  6200. }
  6201. return fields
  6202. }
  6203. // AddedField returns the numeric value that was incremented/decremented on a field
  6204. // with the given name. The second boolean return value indicates that this field
  6205. // was not set, or was not defined in the schema.
  6206. func (m *CategoryMutation) AddedField(name string) (ent.Value, bool) {
  6207. switch name {
  6208. case category.FieldOrganizationID:
  6209. return m.AddedOrganizationID()
  6210. }
  6211. return nil, false
  6212. }
  6213. // AddField adds the value to the field with the given name. It returns an error if
  6214. // the field is not defined in the schema, or if the type mismatched the field
  6215. // type.
  6216. func (m *CategoryMutation) AddField(name string, value ent.Value) error {
  6217. switch name {
  6218. case category.FieldOrganizationID:
  6219. v, ok := value.(int64)
  6220. if !ok {
  6221. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6222. }
  6223. m.AddOrganizationID(v)
  6224. return nil
  6225. }
  6226. return fmt.Errorf("unknown Category numeric field %s", name)
  6227. }
  6228. // ClearedFields returns all nullable fields that were cleared during this
  6229. // mutation.
  6230. func (m *CategoryMutation) ClearedFields() []string {
  6231. var fields []string
  6232. if m.FieldCleared(category.FieldDeletedAt) {
  6233. fields = append(fields, category.FieldDeletedAt)
  6234. }
  6235. return fields
  6236. }
  6237. // FieldCleared returns a boolean indicating if a field with the given name was
  6238. // cleared in this mutation.
  6239. func (m *CategoryMutation) FieldCleared(name string) bool {
  6240. _, ok := m.clearedFields[name]
  6241. return ok
  6242. }
  6243. // ClearField clears the value of the field with the given name. It returns an
  6244. // error if the field is not defined in the schema.
  6245. func (m *CategoryMutation) ClearField(name string) error {
  6246. switch name {
  6247. case category.FieldDeletedAt:
  6248. m.ClearDeletedAt()
  6249. return nil
  6250. }
  6251. return fmt.Errorf("unknown Category nullable field %s", name)
  6252. }
  6253. // ResetField resets all changes in the mutation for the field with the given name.
  6254. // It returns an error if the field is not defined in the schema.
  6255. func (m *CategoryMutation) ResetField(name string) error {
  6256. switch name {
  6257. case category.FieldCreatedAt:
  6258. m.ResetCreatedAt()
  6259. return nil
  6260. case category.FieldUpdatedAt:
  6261. m.ResetUpdatedAt()
  6262. return nil
  6263. case category.FieldDeletedAt:
  6264. m.ResetDeletedAt()
  6265. return nil
  6266. case category.FieldName:
  6267. m.ResetName()
  6268. return nil
  6269. case category.FieldOrganizationID:
  6270. m.ResetOrganizationID()
  6271. return nil
  6272. }
  6273. return fmt.Errorf("unknown Category field %s", name)
  6274. }
  6275. // AddedEdges returns all edge names that were set/added in this mutation.
  6276. func (m *CategoryMutation) AddedEdges() []string {
  6277. edges := make([]string, 0, 0)
  6278. return edges
  6279. }
  6280. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  6281. // name in this mutation.
  6282. func (m *CategoryMutation) AddedIDs(name string) []ent.Value {
  6283. return nil
  6284. }
  6285. // RemovedEdges returns all edge names that were removed in this mutation.
  6286. func (m *CategoryMutation) RemovedEdges() []string {
  6287. edges := make([]string, 0, 0)
  6288. return edges
  6289. }
  6290. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  6291. // the given name in this mutation.
  6292. func (m *CategoryMutation) RemovedIDs(name string) []ent.Value {
  6293. return nil
  6294. }
  6295. // ClearedEdges returns all edge names that were cleared in this mutation.
  6296. func (m *CategoryMutation) ClearedEdges() []string {
  6297. edges := make([]string, 0, 0)
  6298. return edges
  6299. }
  6300. // EdgeCleared returns a boolean which indicates if the edge with the given name
  6301. // was cleared in this mutation.
  6302. func (m *CategoryMutation) EdgeCleared(name string) bool {
  6303. return false
  6304. }
  6305. // ClearEdge clears the value of the edge with the given name. It returns an error
  6306. // if that edge is not defined in the schema.
  6307. func (m *CategoryMutation) ClearEdge(name string) error {
  6308. return fmt.Errorf("unknown Category unique edge %s", name)
  6309. }
  6310. // ResetEdge resets all changes to the edge with the given name in this mutation.
  6311. // It returns an error if the edge is not defined in the schema.
  6312. func (m *CategoryMutation) ResetEdge(name string) error {
  6313. return fmt.Errorf("unknown Category edge %s", name)
  6314. }
  6315. // ChatRecordsMutation represents an operation that mutates the ChatRecords nodes in the graph.
  6316. type ChatRecordsMutation struct {
  6317. config
  6318. op Op
  6319. typ string
  6320. id *uint64
  6321. created_at *time.Time
  6322. updated_at *time.Time
  6323. deleted_at *time.Time
  6324. content *string
  6325. content_type *uint8
  6326. addcontent_type *int8
  6327. session_id *uint64
  6328. addsession_id *int64
  6329. user_id *uint64
  6330. adduser_id *int64
  6331. bot_id *uint64
  6332. addbot_id *int64
  6333. bot_type *uint8
  6334. addbot_type *int8
  6335. clearedFields map[string]struct{}
  6336. done bool
  6337. oldValue func(context.Context) (*ChatRecords, error)
  6338. predicates []predicate.ChatRecords
  6339. }
  6340. var _ ent.Mutation = (*ChatRecordsMutation)(nil)
  6341. // chatrecordsOption allows management of the mutation configuration using functional options.
  6342. type chatrecordsOption func(*ChatRecordsMutation)
  6343. // newChatRecordsMutation creates new mutation for the ChatRecords entity.
  6344. func newChatRecordsMutation(c config, op Op, opts ...chatrecordsOption) *ChatRecordsMutation {
  6345. m := &ChatRecordsMutation{
  6346. config: c,
  6347. op: op,
  6348. typ: TypeChatRecords,
  6349. clearedFields: make(map[string]struct{}),
  6350. }
  6351. for _, opt := range opts {
  6352. opt(m)
  6353. }
  6354. return m
  6355. }
  6356. // withChatRecordsID sets the ID field of the mutation.
  6357. func withChatRecordsID(id uint64) chatrecordsOption {
  6358. return func(m *ChatRecordsMutation) {
  6359. var (
  6360. err error
  6361. once sync.Once
  6362. value *ChatRecords
  6363. )
  6364. m.oldValue = func(ctx context.Context) (*ChatRecords, error) {
  6365. once.Do(func() {
  6366. if m.done {
  6367. err = errors.New("querying old values post mutation is not allowed")
  6368. } else {
  6369. value, err = m.Client().ChatRecords.Get(ctx, id)
  6370. }
  6371. })
  6372. return value, err
  6373. }
  6374. m.id = &id
  6375. }
  6376. }
  6377. // withChatRecords sets the old ChatRecords of the mutation.
  6378. func withChatRecords(node *ChatRecords) chatrecordsOption {
  6379. return func(m *ChatRecordsMutation) {
  6380. m.oldValue = func(context.Context) (*ChatRecords, error) {
  6381. return node, nil
  6382. }
  6383. m.id = &node.ID
  6384. }
  6385. }
  6386. // Client returns a new `ent.Client` from the mutation. If the mutation was
  6387. // executed in a transaction (ent.Tx), a transactional client is returned.
  6388. func (m ChatRecordsMutation) Client() *Client {
  6389. client := &Client{config: m.config}
  6390. client.init()
  6391. return client
  6392. }
  6393. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  6394. // it returns an error otherwise.
  6395. func (m ChatRecordsMutation) Tx() (*Tx, error) {
  6396. if _, ok := m.driver.(*txDriver); !ok {
  6397. return nil, errors.New("ent: mutation is not running in a transaction")
  6398. }
  6399. tx := &Tx{config: m.config}
  6400. tx.init()
  6401. return tx, nil
  6402. }
  6403. // SetID sets the value of the id field. Note that this
  6404. // operation is only accepted on creation of ChatRecords entities.
  6405. func (m *ChatRecordsMutation) SetID(id uint64) {
  6406. m.id = &id
  6407. }
  6408. // ID returns the ID value in the mutation. Note that the ID is only available
  6409. // if it was provided to the builder or after it was returned from the database.
  6410. func (m *ChatRecordsMutation) ID() (id uint64, exists bool) {
  6411. if m.id == nil {
  6412. return
  6413. }
  6414. return *m.id, true
  6415. }
  6416. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  6417. // That means, if the mutation is applied within a transaction with an isolation level such
  6418. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  6419. // or updated by the mutation.
  6420. func (m *ChatRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  6421. switch {
  6422. case m.op.Is(OpUpdateOne | OpDeleteOne):
  6423. id, exists := m.ID()
  6424. if exists {
  6425. return []uint64{id}, nil
  6426. }
  6427. fallthrough
  6428. case m.op.Is(OpUpdate | OpDelete):
  6429. return m.Client().ChatRecords.Query().Where(m.predicates...).IDs(ctx)
  6430. default:
  6431. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  6432. }
  6433. }
  6434. // SetCreatedAt sets the "created_at" field.
  6435. func (m *ChatRecordsMutation) SetCreatedAt(t time.Time) {
  6436. m.created_at = &t
  6437. }
  6438. // CreatedAt returns the value of the "created_at" field in the mutation.
  6439. func (m *ChatRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  6440. v := m.created_at
  6441. if v == nil {
  6442. return
  6443. }
  6444. return *v, true
  6445. }
  6446. // OldCreatedAt returns the old "created_at" field's value of the ChatRecords entity.
  6447. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6448. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6449. func (m *ChatRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  6450. if !m.op.Is(OpUpdateOne) {
  6451. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  6452. }
  6453. if m.id == nil || m.oldValue == nil {
  6454. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  6455. }
  6456. oldValue, err := m.oldValue(ctx)
  6457. if err != nil {
  6458. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  6459. }
  6460. return oldValue.CreatedAt, nil
  6461. }
  6462. // ResetCreatedAt resets all changes to the "created_at" field.
  6463. func (m *ChatRecordsMutation) ResetCreatedAt() {
  6464. m.created_at = nil
  6465. }
  6466. // SetUpdatedAt sets the "updated_at" field.
  6467. func (m *ChatRecordsMutation) SetUpdatedAt(t time.Time) {
  6468. m.updated_at = &t
  6469. }
  6470. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  6471. func (m *ChatRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  6472. v := m.updated_at
  6473. if v == nil {
  6474. return
  6475. }
  6476. return *v, true
  6477. }
  6478. // OldUpdatedAt returns the old "updated_at" field's value of the ChatRecords entity.
  6479. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6480. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6481. func (m *ChatRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  6482. if !m.op.Is(OpUpdateOne) {
  6483. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  6484. }
  6485. if m.id == nil || m.oldValue == nil {
  6486. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  6487. }
  6488. oldValue, err := m.oldValue(ctx)
  6489. if err != nil {
  6490. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  6491. }
  6492. return oldValue.UpdatedAt, nil
  6493. }
  6494. // ResetUpdatedAt resets all changes to the "updated_at" field.
  6495. func (m *ChatRecordsMutation) ResetUpdatedAt() {
  6496. m.updated_at = nil
  6497. }
  6498. // SetDeletedAt sets the "deleted_at" field.
  6499. func (m *ChatRecordsMutation) SetDeletedAt(t time.Time) {
  6500. m.deleted_at = &t
  6501. }
  6502. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  6503. func (m *ChatRecordsMutation) DeletedAt() (r time.Time, exists bool) {
  6504. v := m.deleted_at
  6505. if v == nil {
  6506. return
  6507. }
  6508. return *v, true
  6509. }
  6510. // OldDeletedAt returns the old "deleted_at" field's value of the ChatRecords entity.
  6511. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6512. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6513. func (m *ChatRecordsMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  6514. if !m.op.Is(OpUpdateOne) {
  6515. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  6516. }
  6517. if m.id == nil || m.oldValue == nil {
  6518. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  6519. }
  6520. oldValue, err := m.oldValue(ctx)
  6521. if err != nil {
  6522. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  6523. }
  6524. return oldValue.DeletedAt, nil
  6525. }
  6526. // ClearDeletedAt clears the value of the "deleted_at" field.
  6527. func (m *ChatRecordsMutation) ClearDeletedAt() {
  6528. m.deleted_at = nil
  6529. m.clearedFields[chatrecords.FieldDeletedAt] = struct{}{}
  6530. }
  6531. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  6532. func (m *ChatRecordsMutation) DeletedAtCleared() bool {
  6533. _, ok := m.clearedFields[chatrecords.FieldDeletedAt]
  6534. return ok
  6535. }
  6536. // ResetDeletedAt resets all changes to the "deleted_at" field.
  6537. func (m *ChatRecordsMutation) ResetDeletedAt() {
  6538. m.deleted_at = nil
  6539. delete(m.clearedFields, chatrecords.FieldDeletedAt)
  6540. }
  6541. // SetContent sets the "content" field.
  6542. func (m *ChatRecordsMutation) SetContent(s string) {
  6543. m.content = &s
  6544. }
  6545. // Content returns the value of the "content" field in the mutation.
  6546. func (m *ChatRecordsMutation) Content() (r string, exists bool) {
  6547. v := m.content
  6548. if v == nil {
  6549. return
  6550. }
  6551. return *v, true
  6552. }
  6553. // OldContent returns the old "content" field's value of the ChatRecords entity.
  6554. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6555. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6556. func (m *ChatRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  6557. if !m.op.Is(OpUpdateOne) {
  6558. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  6559. }
  6560. if m.id == nil || m.oldValue == nil {
  6561. return v, errors.New("OldContent requires an ID field in the mutation")
  6562. }
  6563. oldValue, err := m.oldValue(ctx)
  6564. if err != nil {
  6565. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  6566. }
  6567. return oldValue.Content, nil
  6568. }
  6569. // ResetContent resets all changes to the "content" field.
  6570. func (m *ChatRecordsMutation) ResetContent() {
  6571. m.content = nil
  6572. }
  6573. // SetContentType sets the "content_type" field.
  6574. func (m *ChatRecordsMutation) SetContentType(u uint8) {
  6575. m.content_type = &u
  6576. m.addcontent_type = nil
  6577. }
  6578. // ContentType returns the value of the "content_type" field in the mutation.
  6579. func (m *ChatRecordsMutation) ContentType() (r uint8, exists bool) {
  6580. v := m.content_type
  6581. if v == nil {
  6582. return
  6583. }
  6584. return *v, true
  6585. }
  6586. // OldContentType returns the old "content_type" field's value of the ChatRecords entity.
  6587. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6588. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6589. func (m *ChatRecordsMutation) OldContentType(ctx context.Context) (v uint8, err error) {
  6590. if !m.op.Is(OpUpdateOne) {
  6591. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  6592. }
  6593. if m.id == nil || m.oldValue == nil {
  6594. return v, errors.New("OldContentType requires an ID field in the mutation")
  6595. }
  6596. oldValue, err := m.oldValue(ctx)
  6597. if err != nil {
  6598. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  6599. }
  6600. return oldValue.ContentType, nil
  6601. }
  6602. // AddContentType adds u to the "content_type" field.
  6603. func (m *ChatRecordsMutation) AddContentType(u int8) {
  6604. if m.addcontent_type != nil {
  6605. *m.addcontent_type += u
  6606. } else {
  6607. m.addcontent_type = &u
  6608. }
  6609. }
  6610. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  6611. func (m *ChatRecordsMutation) AddedContentType() (r int8, exists bool) {
  6612. v := m.addcontent_type
  6613. if v == nil {
  6614. return
  6615. }
  6616. return *v, true
  6617. }
  6618. // ResetContentType resets all changes to the "content_type" field.
  6619. func (m *ChatRecordsMutation) ResetContentType() {
  6620. m.content_type = nil
  6621. m.addcontent_type = nil
  6622. }
  6623. // SetSessionID sets the "session_id" field.
  6624. func (m *ChatRecordsMutation) SetSessionID(u uint64) {
  6625. m.session_id = &u
  6626. m.addsession_id = nil
  6627. }
  6628. // SessionID returns the value of the "session_id" field in the mutation.
  6629. func (m *ChatRecordsMutation) SessionID() (r uint64, exists bool) {
  6630. v := m.session_id
  6631. if v == nil {
  6632. return
  6633. }
  6634. return *v, true
  6635. }
  6636. // OldSessionID returns the old "session_id" field's value of the ChatRecords entity.
  6637. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6638. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6639. func (m *ChatRecordsMutation) OldSessionID(ctx context.Context) (v uint64, err error) {
  6640. if !m.op.Is(OpUpdateOne) {
  6641. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  6642. }
  6643. if m.id == nil || m.oldValue == nil {
  6644. return v, errors.New("OldSessionID requires an ID field in the mutation")
  6645. }
  6646. oldValue, err := m.oldValue(ctx)
  6647. if err != nil {
  6648. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  6649. }
  6650. return oldValue.SessionID, nil
  6651. }
  6652. // AddSessionID adds u to the "session_id" field.
  6653. func (m *ChatRecordsMutation) AddSessionID(u int64) {
  6654. if m.addsession_id != nil {
  6655. *m.addsession_id += u
  6656. } else {
  6657. m.addsession_id = &u
  6658. }
  6659. }
  6660. // AddedSessionID returns the value that was added to the "session_id" field in this mutation.
  6661. func (m *ChatRecordsMutation) AddedSessionID() (r int64, exists bool) {
  6662. v := m.addsession_id
  6663. if v == nil {
  6664. return
  6665. }
  6666. return *v, true
  6667. }
  6668. // ResetSessionID resets all changes to the "session_id" field.
  6669. func (m *ChatRecordsMutation) ResetSessionID() {
  6670. m.session_id = nil
  6671. m.addsession_id = nil
  6672. }
  6673. // SetUserID sets the "user_id" field.
  6674. func (m *ChatRecordsMutation) SetUserID(u uint64) {
  6675. m.user_id = &u
  6676. m.adduser_id = nil
  6677. }
  6678. // UserID returns the value of the "user_id" field in the mutation.
  6679. func (m *ChatRecordsMutation) UserID() (r uint64, exists bool) {
  6680. v := m.user_id
  6681. if v == nil {
  6682. return
  6683. }
  6684. return *v, true
  6685. }
  6686. // OldUserID returns the old "user_id" field's value of the ChatRecords entity.
  6687. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6688. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6689. func (m *ChatRecordsMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  6690. if !m.op.Is(OpUpdateOne) {
  6691. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  6692. }
  6693. if m.id == nil || m.oldValue == nil {
  6694. return v, errors.New("OldUserID requires an ID field in the mutation")
  6695. }
  6696. oldValue, err := m.oldValue(ctx)
  6697. if err != nil {
  6698. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  6699. }
  6700. return oldValue.UserID, nil
  6701. }
  6702. // AddUserID adds u to the "user_id" field.
  6703. func (m *ChatRecordsMutation) AddUserID(u int64) {
  6704. if m.adduser_id != nil {
  6705. *m.adduser_id += u
  6706. } else {
  6707. m.adduser_id = &u
  6708. }
  6709. }
  6710. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  6711. func (m *ChatRecordsMutation) AddedUserID() (r int64, exists bool) {
  6712. v := m.adduser_id
  6713. if v == nil {
  6714. return
  6715. }
  6716. return *v, true
  6717. }
  6718. // ResetUserID resets all changes to the "user_id" field.
  6719. func (m *ChatRecordsMutation) ResetUserID() {
  6720. m.user_id = nil
  6721. m.adduser_id = nil
  6722. }
  6723. // SetBotID sets the "bot_id" field.
  6724. func (m *ChatRecordsMutation) SetBotID(u uint64) {
  6725. m.bot_id = &u
  6726. m.addbot_id = nil
  6727. }
  6728. // BotID returns the value of the "bot_id" field in the mutation.
  6729. func (m *ChatRecordsMutation) BotID() (r uint64, exists bool) {
  6730. v := m.bot_id
  6731. if v == nil {
  6732. return
  6733. }
  6734. return *v, true
  6735. }
  6736. // OldBotID returns the old "bot_id" field's value of the ChatRecords entity.
  6737. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6738. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6739. func (m *ChatRecordsMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  6740. if !m.op.Is(OpUpdateOne) {
  6741. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  6742. }
  6743. if m.id == nil || m.oldValue == nil {
  6744. return v, errors.New("OldBotID requires an ID field in the mutation")
  6745. }
  6746. oldValue, err := m.oldValue(ctx)
  6747. if err != nil {
  6748. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  6749. }
  6750. return oldValue.BotID, nil
  6751. }
  6752. // AddBotID adds u to the "bot_id" field.
  6753. func (m *ChatRecordsMutation) AddBotID(u int64) {
  6754. if m.addbot_id != nil {
  6755. *m.addbot_id += u
  6756. } else {
  6757. m.addbot_id = &u
  6758. }
  6759. }
  6760. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  6761. func (m *ChatRecordsMutation) AddedBotID() (r int64, exists bool) {
  6762. v := m.addbot_id
  6763. if v == nil {
  6764. return
  6765. }
  6766. return *v, true
  6767. }
  6768. // ResetBotID resets all changes to the "bot_id" field.
  6769. func (m *ChatRecordsMutation) ResetBotID() {
  6770. m.bot_id = nil
  6771. m.addbot_id = nil
  6772. }
  6773. // SetBotType sets the "bot_type" field.
  6774. func (m *ChatRecordsMutation) SetBotType(u uint8) {
  6775. m.bot_type = &u
  6776. m.addbot_type = nil
  6777. }
  6778. // BotType returns the value of the "bot_type" field in the mutation.
  6779. func (m *ChatRecordsMutation) BotType() (r uint8, exists bool) {
  6780. v := m.bot_type
  6781. if v == nil {
  6782. return
  6783. }
  6784. return *v, true
  6785. }
  6786. // OldBotType returns the old "bot_type" field's value of the ChatRecords entity.
  6787. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6788. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6789. func (m *ChatRecordsMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  6790. if !m.op.Is(OpUpdateOne) {
  6791. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  6792. }
  6793. if m.id == nil || m.oldValue == nil {
  6794. return v, errors.New("OldBotType requires an ID field in the mutation")
  6795. }
  6796. oldValue, err := m.oldValue(ctx)
  6797. if err != nil {
  6798. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  6799. }
  6800. return oldValue.BotType, nil
  6801. }
  6802. // AddBotType adds u to the "bot_type" field.
  6803. func (m *ChatRecordsMutation) AddBotType(u int8) {
  6804. if m.addbot_type != nil {
  6805. *m.addbot_type += u
  6806. } else {
  6807. m.addbot_type = &u
  6808. }
  6809. }
  6810. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  6811. func (m *ChatRecordsMutation) AddedBotType() (r int8, exists bool) {
  6812. v := m.addbot_type
  6813. if v == nil {
  6814. return
  6815. }
  6816. return *v, true
  6817. }
  6818. // ResetBotType resets all changes to the "bot_type" field.
  6819. func (m *ChatRecordsMutation) ResetBotType() {
  6820. m.bot_type = nil
  6821. m.addbot_type = nil
  6822. }
  6823. // Where appends a list predicates to the ChatRecordsMutation builder.
  6824. func (m *ChatRecordsMutation) Where(ps ...predicate.ChatRecords) {
  6825. m.predicates = append(m.predicates, ps...)
  6826. }
  6827. // WhereP appends storage-level predicates to the ChatRecordsMutation builder. Using this method,
  6828. // users can use type-assertion to append predicates that do not depend on any generated package.
  6829. func (m *ChatRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  6830. p := make([]predicate.ChatRecords, len(ps))
  6831. for i := range ps {
  6832. p[i] = ps[i]
  6833. }
  6834. m.Where(p...)
  6835. }
  6836. // Op returns the operation name.
  6837. func (m *ChatRecordsMutation) Op() Op {
  6838. return m.op
  6839. }
  6840. // SetOp allows setting the mutation operation.
  6841. func (m *ChatRecordsMutation) SetOp(op Op) {
  6842. m.op = op
  6843. }
  6844. // Type returns the node type of this mutation (ChatRecords).
  6845. func (m *ChatRecordsMutation) Type() string {
  6846. return m.typ
  6847. }
  6848. // Fields returns all fields that were changed during this mutation. Note that in
  6849. // order to get all numeric fields that were incremented/decremented, call
  6850. // AddedFields().
  6851. func (m *ChatRecordsMutation) Fields() []string {
  6852. fields := make([]string, 0, 9)
  6853. if m.created_at != nil {
  6854. fields = append(fields, chatrecords.FieldCreatedAt)
  6855. }
  6856. if m.updated_at != nil {
  6857. fields = append(fields, chatrecords.FieldUpdatedAt)
  6858. }
  6859. if m.deleted_at != nil {
  6860. fields = append(fields, chatrecords.FieldDeletedAt)
  6861. }
  6862. if m.content != nil {
  6863. fields = append(fields, chatrecords.FieldContent)
  6864. }
  6865. if m.content_type != nil {
  6866. fields = append(fields, chatrecords.FieldContentType)
  6867. }
  6868. if m.session_id != nil {
  6869. fields = append(fields, chatrecords.FieldSessionID)
  6870. }
  6871. if m.user_id != nil {
  6872. fields = append(fields, chatrecords.FieldUserID)
  6873. }
  6874. if m.bot_id != nil {
  6875. fields = append(fields, chatrecords.FieldBotID)
  6876. }
  6877. if m.bot_type != nil {
  6878. fields = append(fields, chatrecords.FieldBotType)
  6879. }
  6880. return fields
  6881. }
  6882. // Field returns the value of a field with the given name. The second boolean
  6883. // return value indicates that this field was not set, or was not defined in the
  6884. // schema.
  6885. func (m *ChatRecordsMutation) Field(name string) (ent.Value, bool) {
  6886. switch name {
  6887. case chatrecords.FieldCreatedAt:
  6888. return m.CreatedAt()
  6889. case chatrecords.FieldUpdatedAt:
  6890. return m.UpdatedAt()
  6891. case chatrecords.FieldDeletedAt:
  6892. return m.DeletedAt()
  6893. case chatrecords.FieldContent:
  6894. return m.Content()
  6895. case chatrecords.FieldContentType:
  6896. return m.ContentType()
  6897. case chatrecords.FieldSessionID:
  6898. return m.SessionID()
  6899. case chatrecords.FieldUserID:
  6900. return m.UserID()
  6901. case chatrecords.FieldBotID:
  6902. return m.BotID()
  6903. case chatrecords.FieldBotType:
  6904. return m.BotType()
  6905. }
  6906. return nil, false
  6907. }
  6908. // OldField returns the old value of the field from the database. An error is
  6909. // returned if the mutation operation is not UpdateOne, or the query to the
  6910. // database failed.
  6911. func (m *ChatRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  6912. switch name {
  6913. case chatrecords.FieldCreatedAt:
  6914. return m.OldCreatedAt(ctx)
  6915. case chatrecords.FieldUpdatedAt:
  6916. return m.OldUpdatedAt(ctx)
  6917. case chatrecords.FieldDeletedAt:
  6918. return m.OldDeletedAt(ctx)
  6919. case chatrecords.FieldContent:
  6920. return m.OldContent(ctx)
  6921. case chatrecords.FieldContentType:
  6922. return m.OldContentType(ctx)
  6923. case chatrecords.FieldSessionID:
  6924. return m.OldSessionID(ctx)
  6925. case chatrecords.FieldUserID:
  6926. return m.OldUserID(ctx)
  6927. case chatrecords.FieldBotID:
  6928. return m.OldBotID(ctx)
  6929. case chatrecords.FieldBotType:
  6930. return m.OldBotType(ctx)
  6931. }
  6932. return nil, fmt.Errorf("unknown ChatRecords field %s", name)
  6933. }
  6934. // SetField sets the value of a field with the given name. It returns an error if
  6935. // the field is not defined in the schema, or if the type mismatched the field
  6936. // type.
  6937. func (m *ChatRecordsMutation) SetField(name string, value ent.Value) error {
  6938. switch name {
  6939. case chatrecords.FieldCreatedAt:
  6940. v, ok := value.(time.Time)
  6941. if !ok {
  6942. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6943. }
  6944. m.SetCreatedAt(v)
  6945. return nil
  6946. case chatrecords.FieldUpdatedAt:
  6947. v, ok := value.(time.Time)
  6948. if !ok {
  6949. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6950. }
  6951. m.SetUpdatedAt(v)
  6952. return nil
  6953. case chatrecords.FieldDeletedAt:
  6954. v, ok := value.(time.Time)
  6955. if !ok {
  6956. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6957. }
  6958. m.SetDeletedAt(v)
  6959. return nil
  6960. case chatrecords.FieldContent:
  6961. v, ok := value.(string)
  6962. if !ok {
  6963. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6964. }
  6965. m.SetContent(v)
  6966. return nil
  6967. case chatrecords.FieldContentType:
  6968. v, ok := value.(uint8)
  6969. if !ok {
  6970. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6971. }
  6972. m.SetContentType(v)
  6973. return nil
  6974. case chatrecords.FieldSessionID:
  6975. v, ok := value.(uint64)
  6976. if !ok {
  6977. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6978. }
  6979. m.SetSessionID(v)
  6980. return nil
  6981. case chatrecords.FieldUserID:
  6982. v, ok := value.(uint64)
  6983. if !ok {
  6984. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6985. }
  6986. m.SetUserID(v)
  6987. return nil
  6988. case chatrecords.FieldBotID:
  6989. v, ok := value.(uint64)
  6990. if !ok {
  6991. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6992. }
  6993. m.SetBotID(v)
  6994. return nil
  6995. case chatrecords.FieldBotType:
  6996. v, ok := value.(uint8)
  6997. if !ok {
  6998. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6999. }
  7000. m.SetBotType(v)
  7001. return nil
  7002. }
  7003. return fmt.Errorf("unknown ChatRecords field %s", name)
  7004. }
  7005. // AddedFields returns all numeric fields that were incremented/decremented during
  7006. // this mutation.
  7007. func (m *ChatRecordsMutation) AddedFields() []string {
  7008. var fields []string
  7009. if m.addcontent_type != nil {
  7010. fields = append(fields, chatrecords.FieldContentType)
  7011. }
  7012. if m.addsession_id != nil {
  7013. fields = append(fields, chatrecords.FieldSessionID)
  7014. }
  7015. if m.adduser_id != nil {
  7016. fields = append(fields, chatrecords.FieldUserID)
  7017. }
  7018. if m.addbot_id != nil {
  7019. fields = append(fields, chatrecords.FieldBotID)
  7020. }
  7021. if m.addbot_type != nil {
  7022. fields = append(fields, chatrecords.FieldBotType)
  7023. }
  7024. return fields
  7025. }
  7026. // AddedField returns the numeric value that was incremented/decremented on a field
  7027. // with the given name. The second boolean return value indicates that this field
  7028. // was not set, or was not defined in the schema.
  7029. func (m *ChatRecordsMutation) AddedField(name string) (ent.Value, bool) {
  7030. switch name {
  7031. case chatrecords.FieldContentType:
  7032. return m.AddedContentType()
  7033. case chatrecords.FieldSessionID:
  7034. return m.AddedSessionID()
  7035. case chatrecords.FieldUserID:
  7036. return m.AddedUserID()
  7037. case chatrecords.FieldBotID:
  7038. return m.AddedBotID()
  7039. case chatrecords.FieldBotType:
  7040. return m.AddedBotType()
  7041. }
  7042. return nil, false
  7043. }
  7044. // AddField adds the value to the field with the given name. It returns an error if
  7045. // the field is not defined in the schema, or if the type mismatched the field
  7046. // type.
  7047. func (m *ChatRecordsMutation) AddField(name string, value ent.Value) error {
  7048. switch name {
  7049. case chatrecords.FieldContentType:
  7050. v, ok := value.(int8)
  7051. if !ok {
  7052. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7053. }
  7054. m.AddContentType(v)
  7055. return nil
  7056. case chatrecords.FieldSessionID:
  7057. v, ok := value.(int64)
  7058. if !ok {
  7059. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7060. }
  7061. m.AddSessionID(v)
  7062. return nil
  7063. case chatrecords.FieldUserID:
  7064. v, ok := value.(int64)
  7065. if !ok {
  7066. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7067. }
  7068. m.AddUserID(v)
  7069. return nil
  7070. case chatrecords.FieldBotID:
  7071. v, ok := value.(int64)
  7072. if !ok {
  7073. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7074. }
  7075. m.AddBotID(v)
  7076. return nil
  7077. case chatrecords.FieldBotType:
  7078. v, ok := value.(int8)
  7079. if !ok {
  7080. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7081. }
  7082. m.AddBotType(v)
  7083. return nil
  7084. }
  7085. return fmt.Errorf("unknown ChatRecords numeric field %s", name)
  7086. }
  7087. // ClearedFields returns all nullable fields that were cleared during this
  7088. // mutation.
  7089. func (m *ChatRecordsMutation) ClearedFields() []string {
  7090. var fields []string
  7091. if m.FieldCleared(chatrecords.FieldDeletedAt) {
  7092. fields = append(fields, chatrecords.FieldDeletedAt)
  7093. }
  7094. return fields
  7095. }
  7096. // FieldCleared returns a boolean indicating if a field with the given name was
  7097. // cleared in this mutation.
  7098. func (m *ChatRecordsMutation) FieldCleared(name string) bool {
  7099. _, ok := m.clearedFields[name]
  7100. return ok
  7101. }
  7102. // ClearField clears the value of the field with the given name. It returns an
  7103. // error if the field is not defined in the schema.
  7104. func (m *ChatRecordsMutation) ClearField(name string) error {
  7105. switch name {
  7106. case chatrecords.FieldDeletedAt:
  7107. m.ClearDeletedAt()
  7108. return nil
  7109. }
  7110. return fmt.Errorf("unknown ChatRecords nullable field %s", name)
  7111. }
  7112. // ResetField resets all changes in the mutation for the field with the given name.
  7113. // It returns an error if the field is not defined in the schema.
  7114. func (m *ChatRecordsMutation) ResetField(name string) error {
  7115. switch name {
  7116. case chatrecords.FieldCreatedAt:
  7117. m.ResetCreatedAt()
  7118. return nil
  7119. case chatrecords.FieldUpdatedAt:
  7120. m.ResetUpdatedAt()
  7121. return nil
  7122. case chatrecords.FieldDeletedAt:
  7123. m.ResetDeletedAt()
  7124. return nil
  7125. case chatrecords.FieldContent:
  7126. m.ResetContent()
  7127. return nil
  7128. case chatrecords.FieldContentType:
  7129. m.ResetContentType()
  7130. return nil
  7131. case chatrecords.FieldSessionID:
  7132. m.ResetSessionID()
  7133. return nil
  7134. case chatrecords.FieldUserID:
  7135. m.ResetUserID()
  7136. return nil
  7137. case chatrecords.FieldBotID:
  7138. m.ResetBotID()
  7139. return nil
  7140. case chatrecords.FieldBotType:
  7141. m.ResetBotType()
  7142. return nil
  7143. }
  7144. return fmt.Errorf("unknown ChatRecords field %s", name)
  7145. }
  7146. // AddedEdges returns all edge names that were set/added in this mutation.
  7147. func (m *ChatRecordsMutation) AddedEdges() []string {
  7148. edges := make([]string, 0, 0)
  7149. return edges
  7150. }
  7151. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  7152. // name in this mutation.
  7153. func (m *ChatRecordsMutation) AddedIDs(name string) []ent.Value {
  7154. return nil
  7155. }
  7156. // RemovedEdges returns all edge names that were removed in this mutation.
  7157. func (m *ChatRecordsMutation) RemovedEdges() []string {
  7158. edges := make([]string, 0, 0)
  7159. return edges
  7160. }
  7161. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  7162. // the given name in this mutation.
  7163. func (m *ChatRecordsMutation) RemovedIDs(name string) []ent.Value {
  7164. return nil
  7165. }
  7166. // ClearedEdges returns all edge names that were cleared in this mutation.
  7167. func (m *ChatRecordsMutation) ClearedEdges() []string {
  7168. edges := make([]string, 0, 0)
  7169. return edges
  7170. }
  7171. // EdgeCleared returns a boolean which indicates if the edge with the given name
  7172. // was cleared in this mutation.
  7173. func (m *ChatRecordsMutation) EdgeCleared(name string) bool {
  7174. return false
  7175. }
  7176. // ClearEdge clears the value of the edge with the given name. It returns an error
  7177. // if that edge is not defined in the schema.
  7178. func (m *ChatRecordsMutation) ClearEdge(name string) error {
  7179. return fmt.Errorf("unknown ChatRecords unique edge %s", name)
  7180. }
  7181. // ResetEdge resets all changes to the edge with the given name in this mutation.
  7182. // It returns an error if the edge is not defined in the schema.
  7183. func (m *ChatRecordsMutation) ResetEdge(name string) error {
  7184. return fmt.Errorf("unknown ChatRecords edge %s", name)
  7185. }
  7186. // ChatSessionMutation represents an operation that mutates the ChatSession nodes in the graph.
  7187. type ChatSessionMutation struct {
  7188. config
  7189. op Op
  7190. typ string
  7191. id *uint64
  7192. created_at *time.Time
  7193. updated_at *time.Time
  7194. deleted_at *time.Time
  7195. name *string
  7196. user_id *uint64
  7197. adduser_id *int64
  7198. bot_id *uint64
  7199. addbot_id *int64
  7200. bot_type *uint8
  7201. addbot_type *int8
  7202. clearedFields map[string]struct{}
  7203. done bool
  7204. oldValue func(context.Context) (*ChatSession, error)
  7205. predicates []predicate.ChatSession
  7206. }
  7207. var _ ent.Mutation = (*ChatSessionMutation)(nil)
  7208. // chatsessionOption allows management of the mutation configuration using functional options.
  7209. type chatsessionOption func(*ChatSessionMutation)
  7210. // newChatSessionMutation creates new mutation for the ChatSession entity.
  7211. func newChatSessionMutation(c config, op Op, opts ...chatsessionOption) *ChatSessionMutation {
  7212. m := &ChatSessionMutation{
  7213. config: c,
  7214. op: op,
  7215. typ: TypeChatSession,
  7216. clearedFields: make(map[string]struct{}),
  7217. }
  7218. for _, opt := range opts {
  7219. opt(m)
  7220. }
  7221. return m
  7222. }
  7223. // withChatSessionID sets the ID field of the mutation.
  7224. func withChatSessionID(id uint64) chatsessionOption {
  7225. return func(m *ChatSessionMutation) {
  7226. var (
  7227. err error
  7228. once sync.Once
  7229. value *ChatSession
  7230. )
  7231. m.oldValue = func(ctx context.Context) (*ChatSession, error) {
  7232. once.Do(func() {
  7233. if m.done {
  7234. err = errors.New("querying old values post mutation is not allowed")
  7235. } else {
  7236. value, err = m.Client().ChatSession.Get(ctx, id)
  7237. }
  7238. })
  7239. return value, err
  7240. }
  7241. m.id = &id
  7242. }
  7243. }
  7244. // withChatSession sets the old ChatSession of the mutation.
  7245. func withChatSession(node *ChatSession) chatsessionOption {
  7246. return func(m *ChatSessionMutation) {
  7247. m.oldValue = func(context.Context) (*ChatSession, error) {
  7248. return node, nil
  7249. }
  7250. m.id = &node.ID
  7251. }
  7252. }
  7253. // Client returns a new `ent.Client` from the mutation. If the mutation was
  7254. // executed in a transaction (ent.Tx), a transactional client is returned.
  7255. func (m ChatSessionMutation) Client() *Client {
  7256. client := &Client{config: m.config}
  7257. client.init()
  7258. return client
  7259. }
  7260. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  7261. // it returns an error otherwise.
  7262. func (m ChatSessionMutation) Tx() (*Tx, error) {
  7263. if _, ok := m.driver.(*txDriver); !ok {
  7264. return nil, errors.New("ent: mutation is not running in a transaction")
  7265. }
  7266. tx := &Tx{config: m.config}
  7267. tx.init()
  7268. return tx, nil
  7269. }
  7270. // SetID sets the value of the id field. Note that this
  7271. // operation is only accepted on creation of ChatSession entities.
  7272. func (m *ChatSessionMutation) SetID(id uint64) {
  7273. m.id = &id
  7274. }
  7275. // ID returns the ID value in the mutation. Note that the ID is only available
  7276. // if it was provided to the builder or after it was returned from the database.
  7277. func (m *ChatSessionMutation) ID() (id uint64, exists bool) {
  7278. if m.id == nil {
  7279. return
  7280. }
  7281. return *m.id, true
  7282. }
  7283. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  7284. // That means, if the mutation is applied within a transaction with an isolation level such
  7285. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  7286. // or updated by the mutation.
  7287. func (m *ChatSessionMutation) IDs(ctx context.Context) ([]uint64, error) {
  7288. switch {
  7289. case m.op.Is(OpUpdateOne | OpDeleteOne):
  7290. id, exists := m.ID()
  7291. if exists {
  7292. return []uint64{id}, nil
  7293. }
  7294. fallthrough
  7295. case m.op.Is(OpUpdate | OpDelete):
  7296. return m.Client().ChatSession.Query().Where(m.predicates...).IDs(ctx)
  7297. default:
  7298. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  7299. }
  7300. }
  7301. // SetCreatedAt sets the "created_at" field.
  7302. func (m *ChatSessionMutation) SetCreatedAt(t time.Time) {
  7303. m.created_at = &t
  7304. }
  7305. // CreatedAt returns the value of the "created_at" field in the mutation.
  7306. func (m *ChatSessionMutation) CreatedAt() (r time.Time, exists bool) {
  7307. v := m.created_at
  7308. if v == nil {
  7309. return
  7310. }
  7311. return *v, true
  7312. }
  7313. // OldCreatedAt returns the old "created_at" field's value of the ChatSession entity.
  7314. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7315. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7316. func (m *ChatSessionMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  7317. if !m.op.Is(OpUpdateOne) {
  7318. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  7319. }
  7320. if m.id == nil || m.oldValue == nil {
  7321. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  7322. }
  7323. oldValue, err := m.oldValue(ctx)
  7324. if err != nil {
  7325. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  7326. }
  7327. return oldValue.CreatedAt, nil
  7328. }
  7329. // ResetCreatedAt resets all changes to the "created_at" field.
  7330. func (m *ChatSessionMutation) ResetCreatedAt() {
  7331. m.created_at = nil
  7332. }
  7333. // SetUpdatedAt sets the "updated_at" field.
  7334. func (m *ChatSessionMutation) SetUpdatedAt(t time.Time) {
  7335. m.updated_at = &t
  7336. }
  7337. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  7338. func (m *ChatSessionMutation) UpdatedAt() (r time.Time, exists bool) {
  7339. v := m.updated_at
  7340. if v == nil {
  7341. return
  7342. }
  7343. return *v, true
  7344. }
  7345. // OldUpdatedAt returns the old "updated_at" field's value of the ChatSession entity.
  7346. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7347. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7348. func (m *ChatSessionMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  7349. if !m.op.Is(OpUpdateOne) {
  7350. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  7351. }
  7352. if m.id == nil || m.oldValue == nil {
  7353. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  7354. }
  7355. oldValue, err := m.oldValue(ctx)
  7356. if err != nil {
  7357. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  7358. }
  7359. return oldValue.UpdatedAt, nil
  7360. }
  7361. // ResetUpdatedAt resets all changes to the "updated_at" field.
  7362. func (m *ChatSessionMutation) ResetUpdatedAt() {
  7363. m.updated_at = nil
  7364. }
  7365. // SetDeletedAt sets the "deleted_at" field.
  7366. func (m *ChatSessionMutation) SetDeletedAt(t time.Time) {
  7367. m.deleted_at = &t
  7368. }
  7369. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  7370. func (m *ChatSessionMutation) DeletedAt() (r time.Time, exists bool) {
  7371. v := m.deleted_at
  7372. if v == nil {
  7373. return
  7374. }
  7375. return *v, true
  7376. }
  7377. // OldDeletedAt returns the old "deleted_at" field's value of the ChatSession entity.
  7378. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7379. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7380. func (m *ChatSessionMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  7381. if !m.op.Is(OpUpdateOne) {
  7382. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  7383. }
  7384. if m.id == nil || m.oldValue == nil {
  7385. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  7386. }
  7387. oldValue, err := m.oldValue(ctx)
  7388. if err != nil {
  7389. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  7390. }
  7391. return oldValue.DeletedAt, nil
  7392. }
  7393. // ClearDeletedAt clears the value of the "deleted_at" field.
  7394. func (m *ChatSessionMutation) ClearDeletedAt() {
  7395. m.deleted_at = nil
  7396. m.clearedFields[chatsession.FieldDeletedAt] = struct{}{}
  7397. }
  7398. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  7399. func (m *ChatSessionMutation) DeletedAtCleared() bool {
  7400. _, ok := m.clearedFields[chatsession.FieldDeletedAt]
  7401. return ok
  7402. }
  7403. // ResetDeletedAt resets all changes to the "deleted_at" field.
  7404. func (m *ChatSessionMutation) ResetDeletedAt() {
  7405. m.deleted_at = nil
  7406. delete(m.clearedFields, chatsession.FieldDeletedAt)
  7407. }
  7408. // SetName sets the "name" field.
  7409. func (m *ChatSessionMutation) SetName(s string) {
  7410. m.name = &s
  7411. }
  7412. // Name returns the value of the "name" field in the mutation.
  7413. func (m *ChatSessionMutation) Name() (r string, exists bool) {
  7414. v := m.name
  7415. if v == nil {
  7416. return
  7417. }
  7418. return *v, true
  7419. }
  7420. // OldName returns the old "name" field's value of the ChatSession entity.
  7421. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7422. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7423. func (m *ChatSessionMutation) OldName(ctx context.Context) (v string, err error) {
  7424. if !m.op.Is(OpUpdateOne) {
  7425. return v, errors.New("OldName is only allowed on UpdateOne operations")
  7426. }
  7427. if m.id == nil || m.oldValue == nil {
  7428. return v, errors.New("OldName requires an ID field in the mutation")
  7429. }
  7430. oldValue, err := m.oldValue(ctx)
  7431. if err != nil {
  7432. return v, fmt.Errorf("querying old value for OldName: %w", err)
  7433. }
  7434. return oldValue.Name, nil
  7435. }
  7436. // ResetName resets all changes to the "name" field.
  7437. func (m *ChatSessionMutation) ResetName() {
  7438. m.name = nil
  7439. }
  7440. // SetUserID sets the "user_id" field.
  7441. func (m *ChatSessionMutation) SetUserID(u uint64) {
  7442. m.user_id = &u
  7443. m.adduser_id = nil
  7444. }
  7445. // UserID returns the value of the "user_id" field in the mutation.
  7446. func (m *ChatSessionMutation) UserID() (r uint64, exists bool) {
  7447. v := m.user_id
  7448. if v == nil {
  7449. return
  7450. }
  7451. return *v, true
  7452. }
  7453. // OldUserID returns the old "user_id" field's value of the ChatSession entity.
  7454. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7455. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7456. func (m *ChatSessionMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  7457. if !m.op.Is(OpUpdateOne) {
  7458. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  7459. }
  7460. if m.id == nil || m.oldValue == nil {
  7461. return v, errors.New("OldUserID requires an ID field in the mutation")
  7462. }
  7463. oldValue, err := m.oldValue(ctx)
  7464. if err != nil {
  7465. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  7466. }
  7467. return oldValue.UserID, nil
  7468. }
  7469. // AddUserID adds u to the "user_id" field.
  7470. func (m *ChatSessionMutation) AddUserID(u int64) {
  7471. if m.adduser_id != nil {
  7472. *m.adduser_id += u
  7473. } else {
  7474. m.adduser_id = &u
  7475. }
  7476. }
  7477. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  7478. func (m *ChatSessionMutation) AddedUserID() (r int64, exists bool) {
  7479. v := m.adduser_id
  7480. if v == nil {
  7481. return
  7482. }
  7483. return *v, true
  7484. }
  7485. // ResetUserID resets all changes to the "user_id" field.
  7486. func (m *ChatSessionMutation) ResetUserID() {
  7487. m.user_id = nil
  7488. m.adduser_id = nil
  7489. }
  7490. // SetBotID sets the "bot_id" field.
  7491. func (m *ChatSessionMutation) SetBotID(u uint64) {
  7492. m.bot_id = &u
  7493. m.addbot_id = nil
  7494. }
  7495. // BotID returns the value of the "bot_id" field in the mutation.
  7496. func (m *ChatSessionMutation) BotID() (r uint64, exists bool) {
  7497. v := m.bot_id
  7498. if v == nil {
  7499. return
  7500. }
  7501. return *v, true
  7502. }
  7503. // OldBotID returns the old "bot_id" field's value of the ChatSession entity.
  7504. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7505. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7506. func (m *ChatSessionMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  7507. if !m.op.Is(OpUpdateOne) {
  7508. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  7509. }
  7510. if m.id == nil || m.oldValue == nil {
  7511. return v, errors.New("OldBotID requires an ID field in the mutation")
  7512. }
  7513. oldValue, err := m.oldValue(ctx)
  7514. if err != nil {
  7515. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  7516. }
  7517. return oldValue.BotID, nil
  7518. }
  7519. // AddBotID adds u to the "bot_id" field.
  7520. func (m *ChatSessionMutation) AddBotID(u int64) {
  7521. if m.addbot_id != nil {
  7522. *m.addbot_id += u
  7523. } else {
  7524. m.addbot_id = &u
  7525. }
  7526. }
  7527. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  7528. func (m *ChatSessionMutation) AddedBotID() (r int64, exists bool) {
  7529. v := m.addbot_id
  7530. if v == nil {
  7531. return
  7532. }
  7533. return *v, true
  7534. }
  7535. // ResetBotID resets all changes to the "bot_id" field.
  7536. func (m *ChatSessionMutation) ResetBotID() {
  7537. m.bot_id = nil
  7538. m.addbot_id = nil
  7539. }
  7540. // SetBotType sets the "bot_type" field.
  7541. func (m *ChatSessionMutation) SetBotType(u uint8) {
  7542. m.bot_type = &u
  7543. m.addbot_type = nil
  7544. }
  7545. // BotType returns the value of the "bot_type" field in the mutation.
  7546. func (m *ChatSessionMutation) BotType() (r uint8, exists bool) {
  7547. v := m.bot_type
  7548. if v == nil {
  7549. return
  7550. }
  7551. return *v, true
  7552. }
  7553. // OldBotType returns the old "bot_type" field's value of the ChatSession entity.
  7554. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7555. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7556. func (m *ChatSessionMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  7557. if !m.op.Is(OpUpdateOne) {
  7558. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  7559. }
  7560. if m.id == nil || m.oldValue == nil {
  7561. return v, errors.New("OldBotType requires an ID field in the mutation")
  7562. }
  7563. oldValue, err := m.oldValue(ctx)
  7564. if err != nil {
  7565. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  7566. }
  7567. return oldValue.BotType, nil
  7568. }
  7569. // AddBotType adds u to the "bot_type" field.
  7570. func (m *ChatSessionMutation) AddBotType(u int8) {
  7571. if m.addbot_type != nil {
  7572. *m.addbot_type += u
  7573. } else {
  7574. m.addbot_type = &u
  7575. }
  7576. }
  7577. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  7578. func (m *ChatSessionMutation) AddedBotType() (r int8, exists bool) {
  7579. v := m.addbot_type
  7580. if v == nil {
  7581. return
  7582. }
  7583. return *v, true
  7584. }
  7585. // ResetBotType resets all changes to the "bot_type" field.
  7586. func (m *ChatSessionMutation) ResetBotType() {
  7587. m.bot_type = nil
  7588. m.addbot_type = nil
  7589. }
  7590. // Where appends a list predicates to the ChatSessionMutation builder.
  7591. func (m *ChatSessionMutation) Where(ps ...predicate.ChatSession) {
  7592. m.predicates = append(m.predicates, ps...)
  7593. }
  7594. // WhereP appends storage-level predicates to the ChatSessionMutation builder. Using this method,
  7595. // users can use type-assertion to append predicates that do not depend on any generated package.
  7596. func (m *ChatSessionMutation) WhereP(ps ...func(*sql.Selector)) {
  7597. p := make([]predicate.ChatSession, len(ps))
  7598. for i := range ps {
  7599. p[i] = ps[i]
  7600. }
  7601. m.Where(p...)
  7602. }
  7603. // Op returns the operation name.
  7604. func (m *ChatSessionMutation) Op() Op {
  7605. return m.op
  7606. }
  7607. // SetOp allows setting the mutation operation.
  7608. func (m *ChatSessionMutation) SetOp(op Op) {
  7609. m.op = op
  7610. }
  7611. // Type returns the node type of this mutation (ChatSession).
  7612. func (m *ChatSessionMutation) Type() string {
  7613. return m.typ
  7614. }
  7615. // Fields returns all fields that were changed during this mutation. Note that in
  7616. // order to get all numeric fields that were incremented/decremented, call
  7617. // AddedFields().
  7618. func (m *ChatSessionMutation) Fields() []string {
  7619. fields := make([]string, 0, 7)
  7620. if m.created_at != nil {
  7621. fields = append(fields, chatsession.FieldCreatedAt)
  7622. }
  7623. if m.updated_at != nil {
  7624. fields = append(fields, chatsession.FieldUpdatedAt)
  7625. }
  7626. if m.deleted_at != nil {
  7627. fields = append(fields, chatsession.FieldDeletedAt)
  7628. }
  7629. if m.name != nil {
  7630. fields = append(fields, chatsession.FieldName)
  7631. }
  7632. if m.user_id != nil {
  7633. fields = append(fields, chatsession.FieldUserID)
  7634. }
  7635. if m.bot_id != nil {
  7636. fields = append(fields, chatsession.FieldBotID)
  7637. }
  7638. if m.bot_type != nil {
  7639. fields = append(fields, chatsession.FieldBotType)
  7640. }
  7641. return fields
  7642. }
  7643. // Field returns the value of a field with the given name. The second boolean
  7644. // return value indicates that this field was not set, or was not defined in the
  7645. // schema.
  7646. func (m *ChatSessionMutation) Field(name string) (ent.Value, bool) {
  7647. switch name {
  7648. case chatsession.FieldCreatedAt:
  7649. return m.CreatedAt()
  7650. case chatsession.FieldUpdatedAt:
  7651. return m.UpdatedAt()
  7652. case chatsession.FieldDeletedAt:
  7653. return m.DeletedAt()
  7654. case chatsession.FieldName:
  7655. return m.Name()
  7656. case chatsession.FieldUserID:
  7657. return m.UserID()
  7658. case chatsession.FieldBotID:
  7659. return m.BotID()
  7660. case chatsession.FieldBotType:
  7661. return m.BotType()
  7662. }
  7663. return nil, false
  7664. }
  7665. // OldField returns the old value of the field from the database. An error is
  7666. // returned if the mutation operation is not UpdateOne, or the query to the
  7667. // database failed.
  7668. func (m *ChatSessionMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  7669. switch name {
  7670. case chatsession.FieldCreatedAt:
  7671. return m.OldCreatedAt(ctx)
  7672. case chatsession.FieldUpdatedAt:
  7673. return m.OldUpdatedAt(ctx)
  7674. case chatsession.FieldDeletedAt:
  7675. return m.OldDeletedAt(ctx)
  7676. case chatsession.FieldName:
  7677. return m.OldName(ctx)
  7678. case chatsession.FieldUserID:
  7679. return m.OldUserID(ctx)
  7680. case chatsession.FieldBotID:
  7681. return m.OldBotID(ctx)
  7682. case chatsession.FieldBotType:
  7683. return m.OldBotType(ctx)
  7684. }
  7685. return nil, fmt.Errorf("unknown ChatSession field %s", name)
  7686. }
  7687. // SetField sets the value of a field with the given name. It returns an error if
  7688. // the field is not defined in the schema, or if the type mismatched the field
  7689. // type.
  7690. func (m *ChatSessionMutation) SetField(name string, value ent.Value) error {
  7691. switch name {
  7692. case chatsession.FieldCreatedAt:
  7693. v, ok := value.(time.Time)
  7694. if !ok {
  7695. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7696. }
  7697. m.SetCreatedAt(v)
  7698. return nil
  7699. case chatsession.FieldUpdatedAt:
  7700. v, ok := value.(time.Time)
  7701. if !ok {
  7702. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7703. }
  7704. m.SetUpdatedAt(v)
  7705. return nil
  7706. case chatsession.FieldDeletedAt:
  7707. v, ok := value.(time.Time)
  7708. if !ok {
  7709. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7710. }
  7711. m.SetDeletedAt(v)
  7712. return nil
  7713. case chatsession.FieldName:
  7714. v, ok := value.(string)
  7715. if !ok {
  7716. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7717. }
  7718. m.SetName(v)
  7719. return nil
  7720. case chatsession.FieldUserID:
  7721. v, ok := value.(uint64)
  7722. if !ok {
  7723. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7724. }
  7725. m.SetUserID(v)
  7726. return nil
  7727. case chatsession.FieldBotID:
  7728. v, ok := value.(uint64)
  7729. if !ok {
  7730. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7731. }
  7732. m.SetBotID(v)
  7733. return nil
  7734. case chatsession.FieldBotType:
  7735. v, ok := value.(uint8)
  7736. if !ok {
  7737. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7738. }
  7739. m.SetBotType(v)
  7740. return nil
  7741. }
  7742. return fmt.Errorf("unknown ChatSession field %s", name)
  7743. }
  7744. // AddedFields returns all numeric fields that were incremented/decremented during
  7745. // this mutation.
  7746. func (m *ChatSessionMutation) AddedFields() []string {
  7747. var fields []string
  7748. if m.adduser_id != nil {
  7749. fields = append(fields, chatsession.FieldUserID)
  7750. }
  7751. if m.addbot_id != nil {
  7752. fields = append(fields, chatsession.FieldBotID)
  7753. }
  7754. if m.addbot_type != nil {
  7755. fields = append(fields, chatsession.FieldBotType)
  7756. }
  7757. return fields
  7758. }
  7759. // AddedField returns the numeric value that was incremented/decremented on a field
  7760. // with the given name. The second boolean return value indicates that this field
  7761. // was not set, or was not defined in the schema.
  7762. func (m *ChatSessionMutation) AddedField(name string) (ent.Value, bool) {
  7763. switch name {
  7764. case chatsession.FieldUserID:
  7765. return m.AddedUserID()
  7766. case chatsession.FieldBotID:
  7767. return m.AddedBotID()
  7768. case chatsession.FieldBotType:
  7769. return m.AddedBotType()
  7770. }
  7771. return nil, false
  7772. }
  7773. // AddField adds the value to the field with the given name. It returns an error if
  7774. // the field is not defined in the schema, or if the type mismatched the field
  7775. // type.
  7776. func (m *ChatSessionMutation) AddField(name string, value ent.Value) error {
  7777. switch name {
  7778. case chatsession.FieldUserID:
  7779. v, ok := value.(int64)
  7780. if !ok {
  7781. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7782. }
  7783. m.AddUserID(v)
  7784. return nil
  7785. case chatsession.FieldBotID:
  7786. v, ok := value.(int64)
  7787. if !ok {
  7788. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7789. }
  7790. m.AddBotID(v)
  7791. return nil
  7792. case chatsession.FieldBotType:
  7793. v, ok := value.(int8)
  7794. if !ok {
  7795. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7796. }
  7797. m.AddBotType(v)
  7798. return nil
  7799. }
  7800. return fmt.Errorf("unknown ChatSession numeric field %s", name)
  7801. }
  7802. // ClearedFields returns all nullable fields that were cleared during this
  7803. // mutation.
  7804. func (m *ChatSessionMutation) ClearedFields() []string {
  7805. var fields []string
  7806. if m.FieldCleared(chatsession.FieldDeletedAt) {
  7807. fields = append(fields, chatsession.FieldDeletedAt)
  7808. }
  7809. return fields
  7810. }
  7811. // FieldCleared returns a boolean indicating if a field with the given name was
  7812. // cleared in this mutation.
  7813. func (m *ChatSessionMutation) FieldCleared(name string) bool {
  7814. _, ok := m.clearedFields[name]
  7815. return ok
  7816. }
  7817. // ClearField clears the value of the field with the given name. It returns an
  7818. // error if the field is not defined in the schema.
  7819. func (m *ChatSessionMutation) ClearField(name string) error {
  7820. switch name {
  7821. case chatsession.FieldDeletedAt:
  7822. m.ClearDeletedAt()
  7823. return nil
  7824. }
  7825. return fmt.Errorf("unknown ChatSession nullable field %s", name)
  7826. }
  7827. // ResetField resets all changes in the mutation for the field with the given name.
  7828. // It returns an error if the field is not defined in the schema.
  7829. func (m *ChatSessionMutation) ResetField(name string) error {
  7830. switch name {
  7831. case chatsession.FieldCreatedAt:
  7832. m.ResetCreatedAt()
  7833. return nil
  7834. case chatsession.FieldUpdatedAt:
  7835. m.ResetUpdatedAt()
  7836. return nil
  7837. case chatsession.FieldDeletedAt:
  7838. m.ResetDeletedAt()
  7839. return nil
  7840. case chatsession.FieldName:
  7841. m.ResetName()
  7842. return nil
  7843. case chatsession.FieldUserID:
  7844. m.ResetUserID()
  7845. return nil
  7846. case chatsession.FieldBotID:
  7847. m.ResetBotID()
  7848. return nil
  7849. case chatsession.FieldBotType:
  7850. m.ResetBotType()
  7851. return nil
  7852. }
  7853. return fmt.Errorf("unknown ChatSession field %s", name)
  7854. }
  7855. // AddedEdges returns all edge names that were set/added in this mutation.
  7856. func (m *ChatSessionMutation) AddedEdges() []string {
  7857. edges := make([]string, 0, 0)
  7858. return edges
  7859. }
  7860. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  7861. // name in this mutation.
  7862. func (m *ChatSessionMutation) AddedIDs(name string) []ent.Value {
  7863. return nil
  7864. }
  7865. // RemovedEdges returns all edge names that were removed in this mutation.
  7866. func (m *ChatSessionMutation) RemovedEdges() []string {
  7867. edges := make([]string, 0, 0)
  7868. return edges
  7869. }
  7870. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  7871. // the given name in this mutation.
  7872. func (m *ChatSessionMutation) RemovedIDs(name string) []ent.Value {
  7873. return nil
  7874. }
  7875. // ClearedEdges returns all edge names that were cleared in this mutation.
  7876. func (m *ChatSessionMutation) ClearedEdges() []string {
  7877. edges := make([]string, 0, 0)
  7878. return edges
  7879. }
  7880. // EdgeCleared returns a boolean which indicates if the edge with the given name
  7881. // was cleared in this mutation.
  7882. func (m *ChatSessionMutation) EdgeCleared(name string) bool {
  7883. return false
  7884. }
  7885. // ClearEdge clears the value of the edge with the given name. It returns an error
  7886. // if that edge is not defined in the schema.
  7887. func (m *ChatSessionMutation) ClearEdge(name string) error {
  7888. return fmt.Errorf("unknown ChatSession unique edge %s", name)
  7889. }
  7890. // ResetEdge resets all changes to the edge with the given name in this mutation.
  7891. // It returns an error if the edge is not defined in the schema.
  7892. func (m *ChatSessionMutation) ResetEdge(name string) error {
  7893. return fmt.Errorf("unknown ChatSession edge %s", name)
  7894. }
  7895. // ContactMutation represents an operation that mutates the Contact nodes in the graph.
  7896. type ContactMutation struct {
  7897. config
  7898. op Op
  7899. typ string
  7900. id *uint64
  7901. created_at *time.Time
  7902. updated_at *time.Time
  7903. status *uint8
  7904. addstatus *int8
  7905. deleted_at *time.Time
  7906. wx_wxid *string
  7907. _type *int
  7908. add_type *int
  7909. wxid *string
  7910. account *string
  7911. nickname *string
  7912. markname *string
  7913. headimg *string
  7914. sex *int
  7915. addsex *int
  7916. starrole *string
  7917. dontseeit *int
  7918. adddontseeit *int
  7919. dontseeme *int
  7920. adddontseeme *int
  7921. lag *string
  7922. gid *string
  7923. gname *string
  7924. v3 *string
  7925. organization_id *uint64
  7926. addorganization_id *int64
  7927. ctype *uint64
  7928. addctype *int64
  7929. cage *int
  7930. addcage *int
  7931. cname *string
  7932. carea *string
  7933. cbirthday *string
  7934. cbirtharea *string
  7935. cidcard_no *string
  7936. ctitle *string
  7937. cc *string
  7938. phone *string
  7939. clearedFields map[string]struct{}
  7940. contact_relationships map[uint64]struct{}
  7941. removedcontact_relationships map[uint64]struct{}
  7942. clearedcontact_relationships bool
  7943. contact_messages map[uint64]struct{}
  7944. removedcontact_messages map[uint64]struct{}
  7945. clearedcontact_messages bool
  7946. done bool
  7947. oldValue func(context.Context) (*Contact, error)
  7948. predicates []predicate.Contact
  7949. }
  7950. var _ ent.Mutation = (*ContactMutation)(nil)
  7951. // contactOption allows management of the mutation configuration using functional options.
  7952. type contactOption func(*ContactMutation)
  7953. // newContactMutation creates new mutation for the Contact entity.
  7954. func newContactMutation(c config, op Op, opts ...contactOption) *ContactMutation {
  7955. m := &ContactMutation{
  7956. config: c,
  7957. op: op,
  7958. typ: TypeContact,
  7959. clearedFields: make(map[string]struct{}),
  7960. }
  7961. for _, opt := range opts {
  7962. opt(m)
  7963. }
  7964. return m
  7965. }
  7966. // withContactID sets the ID field of the mutation.
  7967. func withContactID(id uint64) contactOption {
  7968. return func(m *ContactMutation) {
  7969. var (
  7970. err error
  7971. once sync.Once
  7972. value *Contact
  7973. )
  7974. m.oldValue = func(ctx context.Context) (*Contact, error) {
  7975. once.Do(func() {
  7976. if m.done {
  7977. err = errors.New("querying old values post mutation is not allowed")
  7978. } else {
  7979. value, err = m.Client().Contact.Get(ctx, id)
  7980. }
  7981. })
  7982. return value, err
  7983. }
  7984. m.id = &id
  7985. }
  7986. }
  7987. // withContact sets the old Contact of the mutation.
  7988. func withContact(node *Contact) contactOption {
  7989. return func(m *ContactMutation) {
  7990. m.oldValue = func(context.Context) (*Contact, error) {
  7991. return node, nil
  7992. }
  7993. m.id = &node.ID
  7994. }
  7995. }
  7996. // Client returns a new `ent.Client` from the mutation. If the mutation was
  7997. // executed in a transaction (ent.Tx), a transactional client is returned.
  7998. func (m ContactMutation) Client() *Client {
  7999. client := &Client{config: m.config}
  8000. client.init()
  8001. return client
  8002. }
  8003. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  8004. // it returns an error otherwise.
  8005. func (m ContactMutation) Tx() (*Tx, error) {
  8006. if _, ok := m.driver.(*txDriver); !ok {
  8007. return nil, errors.New("ent: mutation is not running in a transaction")
  8008. }
  8009. tx := &Tx{config: m.config}
  8010. tx.init()
  8011. return tx, nil
  8012. }
  8013. // SetID sets the value of the id field. Note that this
  8014. // operation is only accepted on creation of Contact entities.
  8015. func (m *ContactMutation) SetID(id uint64) {
  8016. m.id = &id
  8017. }
  8018. // ID returns the ID value in the mutation. Note that the ID is only available
  8019. // if it was provided to the builder or after it was returned from the database.
  8020. func (m *ContactMutation) ID() (id uint64, exists bool) {
  8021. if m.id == nil {
  8022. return
  8023. }
  8024. return *m.id, true
  8025. }
  8026. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  8027. // That means, if the mutation is applied within a transaction with an isolation level such
  8028. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  8029. // or updated by the mutation.
  8030. func (m *ContactMutation) IDs(ctx context.Context) ([]uint64, error) {
  8031. switch {
  8032. case m.op.Is(OpUpdateOne | OpDeleteOne):
  8033. id, exists := m.ID()
  8034. if exists {
  8035. return []uint64{id}, nil
  8036. }
  8037. fallthrough
  8038. case m.op.Is(OpUpdate | OpDelete):
  8039. return m.Client().Contact.Query().Where(m.predicates...).IDs(ctx)
  8040. default:
  8041. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  8042. }
  8043. }
  8044. // SetCreatedAt sets the "created_at" field.
  8045. func (m *ContactMutation) SetCreatedAt(t time.Time) {
  8046. m.created_at = &t
  8047. }
  8048. // CreatedAt returns the value of the "created_at" field in the mutation.
  8049. func (m *ContactMutation) CreatedAt() (r time.Time, exists bool) {
  8050. v := m.created_at
  8051. if v == nil {
  8052. return
  8053. }
  8054. return *v, true
  8055. }
  8056. // OldCreatedAt returns the old "created_at" field's value of the Contact entity.
  8057. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8058. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8059. func (m *ContactMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  8060. if !m.op.Is(OpUpdateOne) {
  8061. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  8062. }
  8063. if m.id == nil || m.oldValue == nil {
  8064. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  8065. }
  8066. oldValue, err := m.oldValue(ctx)
  8067. if err != nil {
  8068. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  8069. }
  8070. return oldValue.CreatedAt, nil
  8071. }
  8072. // ResetCreatedAt resets all changes to the "created_at" field.
  8073. func (m *ContactMutation) ResetCreatedAt() {
  8074. m.created_at = nil
  8075. }
  8076. // SetUpdatedAt sets the "updated_at" field.
  8077. func (m *ContactMutation) SetUpdatedAt(t time.Time) {
  8078. m.updated_at = &t
  8079. }
  8080. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  8081. func (m *ContactMutation) UpdatedAt() (r time.Time, exists bool) {
  8082. v := m.updated_at
  8083. if v == nil {
  8084. return
  8085. }
  8086. return *v, true
  8087. }
  8088. // OldUpdatedAt returns the old "updated_at" field's value of the Contact entity.
  8089. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8090. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8091. func (m *ContactMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  8092. if !m.op.Is(OpUpdateOne) {
  8093. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  8094. }
  8095. if m.id == nil || m.oldValue == nil {
  8096. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  8097. }
  8098. oldValue, err := m.oldValue(ctx)
  8099. if err != nil {
  8100. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  8101. }
  8102. return oldValue.UpdatedAt, nil
  8103. }
  8104. // ResetUpdatedAt resets all changes to the "updated_at" field.
  8105. func (m *ContactMutation) ResetUpdatedAt() {
  8106. m.updated_at = nil
  8107. }
  8108. // SetStatus sets the "status" field.
  8109. func (m *ContactMutation) SetStatus(u uint8) {
  8110. m.status = &u
  8111. m.addstatus = nil
  8112. }
  8113. // Status returns the value of the "status" field in the mutation.
  8114. func (m *ContactMutation) Status() (r uint8, exists bool) {
  8115. v := m.status
  8116. if v == nil {
  8117. return
  8118. }
  8119. return *v, true
  8120. }
  8121. // OldStatus returns the old "status" field's value of the Contact entity.
  8122. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8123. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8124. func (m *ContactMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  8125. if !m.op.Is(OpUpdateOne) {
  8126. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  8127. }
  8128. if m.id == nil || m.oldValue == nil {
  8129. return v, errors.New("OldStatus requires an ID field in the mutation")
  8130. }
  8131. oldValue, err := m.oldValue(ctx)
  8132. if err != nil {
  8133. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  8134. }
  8135. return oldValue.Status, nil
  8136. }
  8137. // AddStatus adds u to the "status" field.
  8138. func (m *ContactMutation) AddStatus(u int8) {
  8139. if m.addstatus != nil {
  8140. *m.addstatus += u
  8141. } else {
  8142. m.addstatus = &u
  8143. }
  8144. }
  8145. // AddedStatus returns the value that was added to the "status" field in this mutation.
  8146. func (m *ContactMutation) AddedStatus() (r int8, exists bool) {
  8147. v := m.addstatus
  8148. if v == nil {
  8149. return
  8150. }
  8151. return *v, true
  8152. }
  8153. // ClearStatus clears the value of the "status" field.
  8154. func (m *ContactMutation) ClearStatus() {
  8155. m.status = nil
  8156. m.addstatus = nil
  8157. m.clearedFields[contact.FieldStatus] = struct{}{}
  8158. }
  8159. // StatusCleared returns if the "status" field was cleared in this mutation.
  8160. func (m *ContactMutation) StatusCleared() bool {
  8161. _, ok := m.clearedFields[contact.FieldStatus]
  8162. return ok
  8163. }
  8164. // ResetStatus resets all changes to the "status" field.
  8165. func (m *ContactMutation) ResetStatus() {
  8166. m.status = nil
  8167. m.addstatus = nil
  8168. delete(m.clearedFields, contact.FieldStatus)
  8169. }
  8170. // SetDeletedAt sets the "deleted_at" field.
  8171. func (m *ContactMutation) SetDeletedAt(t time.Time) {
  8172. m.deleted_at = &t
  8173. }
  8174. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  8175. func (m *ContactMutation) DeletedAt() (r time.Time, exists bool) {
  8176. v := m.deleted_at
  8177. if v == nil {
  8178. return
  8179. }
  8180. return *v, true
  8181. }
  8182. // OldDeletedAt returns the old "deleted_at" field's value of the Contact entity.
  8183. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8184. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8185. func (m *ContactMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  8186. if !m.op.Is(OpUpdateOne) {
  8187. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  8188. }
  8189. if m.id == nil || m.oldValue == nil {
  8190. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  8191. }
  8192. oldValue, err := m.oldValue(ctx)
  8193. if err != nil {
  8194. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  8195. }
  8196. return oldValue.DeletedAt, nil
  8197. }
  8198. // ClearDeletedAt clears the value of the "deleted_at" field.
  8199. func (m *ContactMutation) ClearDeletedAt() {
  8200. m.deleted_at = nil
  8201. m.clearedFields[contact.FieldDeletedAt] = struct{}{}
  8202. }
  8203. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  8204. func (m *ContactMutation) DeletedAtCleared() bool {
  8205. _, ok := m.clearedFields[contact.FieldDeletedAt]
  8206. return ok
  8207. }
  8208. // ResetDeletedAt resets all changes to the "deleted_at" field.
  8209. func (m *ContactMutation) ResetDeletedAt() {
  8210. m.deleted_at = nil
  8211. delete(m.clearedFields, contact.FieldDeletedAt)
  8212. }
  8213. // SetWxWxid sets the "wx_wxid" field.
  8214. func (m *ContactMutation) SetWxWxid(s string) {
  8215. m.wx_wxid = &s
  8216. }
  8217. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  8218. func (m *ContactMutation) WxWxid() (r string, exists bool) {
  8219. v := m.wx_wxid
  8220. if v == nil {
  8221. return
  8222. }
  8223. return *v, true
  8224. }
  8225. // OldWxWxid returns the old "wx_wxid" field's value of the Contact entity.
  8226. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8227. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8228. func (m *ContactMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  8229. if !m.op.Is(OpUpdateOne) {
  8230. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  8231. }
  8232. if m.id == nil || m.oldValue == nil {
  8233. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  8234. }
  8235. oldValue, err := m.oldValue(ctx)
  8236. if err != nil {
  8237. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  8238. }
  8239. return oldValue.WxWxid, nil
  8240. }
  8241. // ResetWxWxid resets all changes to the "wx_wxid" field.
  8242. func (m *ContactMutation) ResetWxWxid() {
  8243. m.wx_wxid = nil
  8244. }
  8245. // SetType sets the "type" field.
  8246. func (m *ContactMutation) SetType(i int) {
  8247. m._type = &i
  8248. m.add_type = nil
  8249. }
  8250. // GetType returns the value of the "type" field in the mutation.
  8251. func (m *ContactMutation) GetType() (r int, exists bool) {
  8252. v := m._type
  8253. if v == nil {
  8254. return
  8255. }
  8256. return *v, true
  8257. }
  8258. // OldType returns the old "type" field's value of the Contact entity.
  8259. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8260. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8261. func (m *ContactMutation) OldType(ctx context.Context) (v int, err error) {
  8262. if !m.op.Is(OpUpdateOne) {
  8263. return v, errors.New("OldType is only allowed on UpdateOne operations")
  8264. }
  8265. if m.id == nil || m.oldValue == nil {
  8266. return v, errors.New("OldType requires an ID field in the mutation")
  8267. }
  8268. oldValue, err := m.oldValue(ctx)
  8269. if err != nil {
  8270. return v, fmt.Errorf("querying old value for OldType: %w", err)
  8271. }
  8272. return oldValue.Type, nil
  8273. }
  8274. // AddType adds i to the "type" field.
  8275. func (m *ContactMutation) AddType(i int) {
  8276. if m.add_type != nil {
  8277. *m.add_type += i
  8278. } else {
  8279. m.add_type = &i
  8280. }
  8281. }
  8282. // AddedType returns the value that was added to the "type" field in this mutation.
  8283. func (m *ContactMutation) AddedType() (r int, exists bool) {
  8284. v := m.add_type
  8285. if v == nil {
  8286. return
  8287. }
  8288. return *v, true
  8289. }
  8290. // ClearType clears the value of the "type" field.
  8291. func (m *ContactMutation) ClearType() {
  8292. m._type = nil
  8293. m.add_type = nil
  8294. m.clearedFields[contact.FieldType] = struct{}{}
  8295. }
  8296. // TypeCleared returns if the "type" field was cleared in this mutation.
  8297. func (m *ContactMutation) TypeCleared() bool {
  8298. _, ok := m.clearedFields[contact.FieldType]
  8299. return ok
  8300. }
  8301. // ResetType resets all changes to the "type" field.
  8302. func (m *ContactMutation) ResetType() {
  8303. m._type = nil
  8304. m.add_type = nil
  8305. delete(m.clearedFields, contact.FieldType)
  8306. }
  8307. // SetWxid sets the "wxid" field.
  8308. func (m *ContactMutation) SetWxid(s string) {
  8309. m.wxid = &s
  8310. }
  8311. // Wxid returns the value of the "wxid" field in the mutation.
  8312. func (m *ContactMutation) Wxid() (r string, exists bool) {
  8313. v := m.wxid
  8314. if v == nil {
  8315. return
  8316. }
  8317. return *v, true
  8318. }
  8319. // OldWxid returns the old "wxid" field's value of the Contact entity.
  8320. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8321. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8322. func (m *ContactMutation) OldWxid(ctx context.Context) (v string, err error) {
  8323. if !m.op.Is(OpUpdateOne) {
  8324. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  8325. }
  8326. if m.id == nil || m.oldValue == nil {
  8327. return v, errors.New("OldWxid requires an ID field in the mutation")
  8328. }
  8329. oldValue, err := m.oldValue(ctx)
  8330. if err != nil {
  8331. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  8332. }
  8333. return oldValue.Wxid, nil
  8334. }
  8335. // ResetWxid resets all changes to the "wxid" field.
  8336. func (m *ContactMutation) ResetWxid() {
  8337. m.wxid = nil
  8338. }
  8339. // SetAccount sets the "account" field.
  8340. func (m *ContactMutation) SetAccount(s string) {
  8341. m.account = &s
  8342. }
  8343. // Account returns the value of the "account" field in the mutation.
  8344. func (m *ContactMutation) Account() (r string, exists bool) {
  8345. v := m.account
  8346. if v == nil {
  8347. return
  8348. }
  8349. return *v, true
  8350. }
  8351. // OldAccount returns the old "account" field's value of the Contact entity.
  8352. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8353. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8354. func (m *ContactMutation) OldAccount(ctx context.Context) (v string, err error) {
  8355. if !m.op.Is(OpUpdateOne) {
  8356. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  8357. }
  8358. if m.id == nil || m.oldValue == nil {
  8359. return v, errors.New("OldAccount requires an ID field in the mutation")
  8360. }
  8361. oldValue, err := m.oldValue(ctx)
  8362. if err != nil {
  8363. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  8364. }
  8365. return oldValue.Account, nil
  8366. }
  8367. // ResetAccount resets all changes to the "account" field.
  8368. func (m *ContactMutation) ResetAccount() {
  8369. m.account = nil
  8370. }
  8371. // SetNickname sets the "nickname" field.
  8372. func (m *ContactMutation) SetNickname(s string) {
  8373. m.nickname = &s
  8374. }
  8375. // Nickname returns the value of the "nickname" field in the mutation.
  8376. func (m *ContactMutation) Nickname() (r string, exists bool) {
  8377. v := m.nickname
  8378. if v == nil {
  8379. return
  8380. }
  8381. return *v, true
  8382. }
  8383. // OldNickname returns the old "nickname" field's value of the Contact entity.
  8384. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8385. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8386. func (m *ContactMutation) OldNickname(ctx context.Context) (v string, err error) {
  8387. if !m.op.Is(OpUpdateOne) {
  8388. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  8389. }
  8390. if m.id == nil || m.oldValue == nil {
  8391. return v, errors.New("OldNickname requires an ID field in the mutation")
  8392. }
  8393. oldValue, err := m.oldValue(ctx)
  8394. if err != nil {
  8395. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  8396. }
  8397. return oldValue.Nickname, nil
  8398. }
  8399. // ResetNickname resets all changes to the "nickname" field.
  8400. func (m *ContactMutation) ResetNickname() {
  8401. m.nickname = nil
  8402. }
  8403. // SetMarkname sets the "markname" field.
  8404. func (m *ContactMutation) SetMarkname(s string) {
  8405. m.markname = &s
  8406. }
  8407. // Markname returns the value of the "markname" field in the mutation.
  8408. func (m *ContactMutation) Markname() (r string, exists bool) {
  8409. v := m.markname
  8410. if v == nil {
  8411. return
  8412. }
  8413. return *v, true
  8414. }
  8415. // OldMarkname returns the old "markname" field's value of the Contact entity.
  8416. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8417. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8418. func (m *ContactMutation) OldMarkname(ctx context.Context) (v string, err error) {
  8419. if !m.op.Is(OpUpdateOne) {
  8420. return v, errors.New("OldMarkname is only allowed on UpdateOne operations")
  8421. }
  8422. if m.id == nil || m.oldValue == nil {
  8423. return v, errors.New("OldMarkname requires an ID field in the mutation")
  8424. }
  8425. oldValue, err := m.oldValue(ctx)
  8426. if err != nil {
  8427. return v, fmt.Errorf("querying old value for OldMarkname: %w", err)
  8428. }
  8429. return oldValue.Markname, nil
  8430. }
  8431. // ResetMarkname resets all changes to the "markname" field.
  8432. func (m *ContactMutation) ResetMarkname() {
  8433. m.markname = nil
  8434. }
  8435. // SetHeadimg sets the "headimg" field.
  8436. func (m *ContactMutation) SetHeadimg(s string) {
  8437. m.headimg = &s
  8438. }
  8439. // Headimg returns the value of the "headimg" field in the mutation.
  8440. func (m *ContactMutation) Headimg() (r string, exists bool) {
  8441. v := m.headimg
  8442. if v == nil {
  8443. return
  8444. }
  8445. return *v, true
  8446. }
  8447. // OldHeadimg returns the old "headimg" field's value of the Contact entity.
  8448. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8449. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8450. func (m *ContactMutation) OldHeadimg(ctx context.Context) (v string, err error) {
  8451. if !m.op.Is(OpUpdateOne) {
  8452. return v, errors.New("OldHeadimg is only allowed on UpdateOne operations")
  8453. }
  8454. if m.id == nil || m.oldValue == nil {
  8455. return v, errors.New("OldHeadimg requires an ID field in the mutation")
  8456. }
  8457. oldValue, err := m.oldValue(ctx)
  8458. if err != nil {
  8459. return v, fmt.Errorf("querying old value for OldHeadimg: %w", err)
  8460. }
  8461. return oldValue.Headimg, nil
  8462. }
  8463. // ResetHeadimg resets all changes to the "headimg" field.
  8464. func (m *ContactMutation) ResetHeadimg() {
  8465. m.headimg = nil
  8466. }
  8467. // SetSex sets the "sex" field.
  8468. func (m *ContactMutation) SetSex(i int) {
  8469. m.sex = &i
  8470. m.addsex = nil
  8471. }
  8472. // Sex returns the value of the "sex" field in the mutation.
  8473. func (m *ContactMutation) Sex() (r int, exists bool) {
  8474. v := m.sex
  8475. if v == nil {
  8476. return
  8477. }
  8478. return *v, true
  8479. }
  8480. // OldSex returns the old "sex" field's value of the Contact entity.
  8481. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8482. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8483. func (m *ContactMutation) OldSex(ctx context.Context) (v int, err error) {
  8484. if !m.op.Is(OpUpdateOne) {
  8485. return v, errors.New("OldSex is only allowed on UpdateOne operations")
  8486. }
  8487. if m.id == nil || m.oldValue == nil {
  8488. return v, errors.New("OldSex requires an ID field in the mutation")
  8489. }
  8490. oldValue, err := m.oldValue(ctx)
  8491. if err != nil {
  8492. return v, fmt.Errorf("querying old value for OldSex: %w", err)
  8493. }
  8494. return oldValue.Sex, nil
  8495. }
  8496. // AddSex adds i to the "sex" field.
  8497. func (m *ContactMutation) AddSex(i int) {
  8498. if m.addsex != nil {
  8499. *m.addsex += i
  8500. } else {
  8501. m.addsex = &i
  8502. }
  8503. }
  8504. // AddedSex returns the value that was added to the "sex" field in this mutation.
  8505. func (m *ContactMutation) AddedSex() (r int, exists bool) {
  8506. v := m.addsex
  8507. if v == nil {
  8508. return
  8509. }
  8510. return *v, true
  8511. }
  8512. // ResetSex resets all changes to the "sex" field.
  8513. func (m *ContactMutation) ResetSex() {
  8514. m.sex = nil
  8515. m.addsex = nil
  8516. }
  8517. // SetStarrole sets the "starrole" field.
  8518. func (m *ContactMutation) SetStarrole(s string) {
  8519. m.starrole = &s
  8520. }
  8521. // Starrole returns the value of the "starrole" field in the mutation.
  8522. func (m *ContactMutation) Starrole() (r string, exists bool) {
  8523. v := m.starrole
  8524. if v == nil {
  8525. return
  8526. }
  8527. return *v, true
  8528. }
  8529. // OldStarrole returns the old "starrole" field's value of the Contact entity.
  8530. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8531. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8532. func (m *ContactMutation) OldStarrole(ctx context.Context) (v string, err error) {
  8533. if !m.op.Is(OpUpdateOne) {
  8534. return v, errors.New("OldStarrole is only allowed on UpdateOne operations")
  8535. }
  8536. if m.id == nil || m.oldValue == nil {
  8537. return v, errors.New("OldStarrole requires an ID field in the mutation")
  8538. }
  8539. oldValue, err := m.oldValue(ctx)
  8540. if err != nil {
  8541. return v, fmt.Errorf("querying old value for OldStarrole: %w", err)
  8542. }
  8543. return oldValue.Starrole, nil
  8544. }
  8545. // ResetStarrole resets all changes to the "starrole" field.
  8546. func (m *ContactMutation) ResetStarrole() {
  8547. m.starrole = nil
  8548. }
  8549. // SetDontseeit sets the "dontseeit" field.
  8550. func (m *ContactMutation) SetDontseeit(i int) {
  8551. m.dontseeit = &i
  8552. m.adddontseeit = nil
  8553. }
  8554. // Dontseeit returns the value of the "dontseeit" field in the mutation.
  8555. func (m *ContactMutation) Dontseeit() (r int, exists bool) {
  8556. v := m.dontseeit
  8557. if v == nil {
  8558. return
  8559. }
  8560. return *v, true
  8561. }
  8562. // OldDontseeit returns the old "dontseeit" field's value of the Contact entity.
  8563. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8564. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8565. func (m *ContactMutation) OldDontseeit(ctx context.Context) (v int, err error) {
  8566. if !m.op.Is(OpUpdateOne) {
  8567. return v, errors.New("OldDontseeit is only allowed on UpdateOne operations")
  8568. }
  8569. if m.id == nil || m.oldValue == nil {
  8570. return v, errors.New("OldDontseeit requires an ID field in the mutation")
  8571. }
  8572. oldValue, err := m.oldValue(ctx)
  8573. if err != nil {
  8574. return v, fmt.Errorf("querying old value for OldDontseeit: %w", err)
  8575. }
  8576. return oldValue.Dontseeit, nil
  8577. }
  8578. // AddDontseeit adds i to the "dontseeit" field.
  8579. func (m *ContactMutation) AddDontseeit(i int) {
  8580. if m.adddontseeit != nil {
  8581. *m.adddontseeit += i
  8582. } else {
  8583. m.adddontseeit = &i
  8584. }
  8585. }
  8586. // AddedDontseeit returns the value that was added to the "dontseeit" field in this mutation.
  8587. func (m *ContactMutation) AddedDontseeit() (r int, exists bool) {
  8588. v := m.adddontseeit
  8589. if v == nil {
  8590. return
  8591. }
  8592. return *v, true
  8593. }
  8594. // ResetDontseeit resets all changes to the "dontseeit" field.
  8595. func (m *ContactMutation) ResetDontseeit() {
  8596. m.dontseeit = nil
  8597. m.adddontseeit = nil
  8598. }
  8599. // SetDontseeme sets the "dontseeme" field.
  8600. func (m *ContactMutation) SetDontseeme(i int) {
  8601. m.dontseeme = &i
  8602. m.adddontseeme = nil
  8603. }
  8604. // Dontseeme returns the value of the "dontseeme" field in the mutation.
  8605. func (m *ContactMutation) Dontseeme() (r int, exists bool) {
  8606. v := m.dontseeme
  8607. if v == nil {
  8608. return
  8609. }
  8610. return *v, true
  8611. }
  8612. // OldDontseeme returns the old "dontseeme" field's value of the Contact entity.
  8613. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8614. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8615. func (m *ContactMutation) OldDontseeme(ctx context.Context) (v int, err error) {
  8616. if !m.op.Is(OpUpdateOne) {
  8617. return v, errors.New("OldDontseeme is only allowed on UpdateOne operations")
  8618. }
  8619. if m.id == nil || m.oldValue == nil {
  8620. return v, errors.New("OldDontseeme requires an ID field in the mutation")
  8621. }
  8622. oldValue, err := m.oldValue(ctx)
  8623. if err != nil {
  8624. return v, fmt.Errorf("querying old value for OldDontseeme: %w", err)
  8625. }
  8626. return oldValue.Dontseeme, nil
  8627. }
  8628. // AddDontseeme adds i to the "dontseeme" field.
  8629. func (m *ContactMutation) AddDontseeme(i int) {
  8630. if m.adddontseeme != nil {
  8631. *m.adddontseeme += i
  8632. } else {
  8633. m.adddontseeme = &i
  8634. }
  8635. }
  8636. // AddedDontseeme returns the value that was added to the "dontseeme" field in this mutation.
  8637. func (m *ContactMutation) AddedDontseeme() (r int, exists bool) {
  8638. v := m.adddontseeme
  8639. if v == nil {
  8640. return
  8641. }
  8642. return *v, true
  8643. }
  8644. // ResetDontseeme resets all changes to the "dontseeme" field.
  8645. func (m *ContactMutation) ResetDontseeme() {
  8646. m.dontseeme = nil
  8647. m.adddontseeme = nil
  8648. }
  8649. // SetLag sets the "lag" field.
  8650. func (m *ContactMutation) SetLag(s string) {
  8651. m.lag = &s
  8652. }
  8653. // Lag returns the value of the "lag" field in the mutation.
  8654. func (m *ContactMutation) Lag() (r string, exists bool) {
  8655. v := m.lag
  8656. if v == nil {
  8657. return
  8658. }
  8659. return *v, true
  8660. }
  8661. // OldLag returns the old "lag" field's value of the Contact entity.
  8662. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8663. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8664. func (m *ContactMutation) OldLag(ctx context.Context) (v string, err error) {
  8665. if !m.op.Is(OpUpdateOne) {
  8666. return v, errors.New("OldLag is only allowed on UpdateOne operations")
  8667. }
  8668. if m.id == nil || m.oldValue == nil {
  8669. return v, errors.New("OldLag requires an ID field in the mutation")
  8670. }
  8671. oldValue, err := m.oldValue(ctx)
  8672. if err != nil {
  8673. return v, fmt.Errorf("querying old value for OldLag: %w", err)
  8674. }
  8675. return oldValue.Lag, nil
  8676. }
  8677. // ResetLag resets all changes to the "lag" field.
  8678. func (m *ContactMutation) ResetLag() {
  8679. m.lag = nil
  8680. }
  8681. // SetGid sets the "gid" field.
  8682. func (m *ContactMutation) SetGid(s string) {
  8683. m.gid = &s
  8684. }
  8685. // Gid returns the value of the "gid" field in the mutation.
  8686. func (m *ContactMutation) Gid() (r string, exists bool) {
  8687. v := m.gid
  8688. if v == nil {
  8689. return
  8690. }
  8691. return *v, true
  8692. }
  8693. // OldGid returns the old "gid" field's value of the Contact entity.
  8694. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8695. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8696. func (m *ContactMutation) OldGid(ctx context.Context) (v string, err error) {
  8697. if !m.op.Is(OpUpdateOne) {
  8698. return v, errors.New("OldGid is only allowed on UpdateOne operations")
  8699. }
  8700. if m.id == nil || m.oldValue == nil {
  8701. return v, errors.New("OldGid requires an ID field in the mutation")
  8702. }
  8703. oldValue, err := m.oldValue(ctx)
  8704. if err != nil {
  8705. return v, fmt.Errorf("querying old value for OldGid: %w", err)
  8706. }
  8707. return oldValue.Gid, nil
  8708. }
  8709. // ResetGid resets all changes to the "gid" field.
  8710. func (m *ContactMutation) ResetGid() {
  8711. m.gid = nil
  8712. }
  8713. // SetGname sets the "gname" field.
  8714. func (m *ContactMutation) SetGname(s string) {
  8715. m.gname = &s
  8716. }
  8717. // Gname returns the value of the "gname" field in the mutation.
  8718. func (m *ContactMutation) Gname() (r string, exists bool) {
  8719. v := m.gname
  8720. if v == nil {
  8721. return
  8722. }
  8723. return *v, true
  8724. }
  8725. // OldGname returns the old "gname" field's value of the Contact entity.
  8726. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8727. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8728. func (m *ContactMutation) OldGname(ctx context.Context) (v string, err error) {
  8729. if !m.op.Is(OpUpdateOne) {
  8730. return v, errors.New("OldGname is only allowed on UpdateOne operations")
  8731. }
  8732. if m.id == nil || m.oldValue == nil {
  8733. return v, errors.New("OldGname requires an ID field in the mutation")
  8734. }
  8735. oldValue, err := m.oldValue(ctx)
  8736. if err != nil {
  8737. return v, fmt.Errorf("querying old value for OldGname: %w", err)
  8738. }
  8739. return oldValue.Gname, nil
  8740. }
  8741. // ResetGname resets all changes to the "gname" field.
  8742. func (m *ContactMutation) ResetGname() {
  8743. m.gname = nil
  8744. }
  8745. // SetV3 sets the "v3" field.
  8746. func (m *ContactMutation) SetV3(s string) {
  8747. m.v3 = &s
  8748. }
  8749. // V3 returns the value of the "v3" field in the mutation.
  8750. func (m *ContactMutation) V3() (r string, exists bool) {
  8751. v := m.v3
  8752. if v == nil {
  8753. return
  8754. }
  8755. return *v, true
  8756. }
  8757. // OldV3 returns the old "v3" field's value of the Contact entity.
  8758. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8759. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8760. func (m *ContactMutation) OldV3(ctx context.Context) (v string, err error) {
  8761. if !m.op.Is(OpUpdateOne) {
  8762. return v, errors.New("OldV3 is only allowed on UpdateOne operations")
  8763. }
  8764. if m.id == nil || m.oldValue == nil {
  8765. return v, errors.New("OldV3 requires an ID field in the mutation")
  8766. }
  8767. oldValue, err := m.oldValue(ctx)
  8768. if err != nil {
  8769. return v, fmt.Errorf("querying old value for OldV3: %w", err)
  8770. }
  8771. return oldValue.V3, nil
  8772. }
  8773. // ResetV3 resets all changes to the "v3" field.
  8774. func (m *ContactMutation) ResetV3() {
  8775. m.v3 = nil
  8776. }
  8777. // SetOrganizationID sets the "organization_id" field.
  8778. func (m *ContactMutation) SetOrganizationID(u uint64) {
  8779. m.organization_id = &u
  8780. m.addorganization_id = nil
  8781. }
  8782. // OrganizationID returns the value of the "organization_id" field in the mutation.
  8783. func (m *ContactMutation) OrganizationID() (r uint64, exists bool) {
  8784. v := m.organization_id
  8785. if v == nil {
  8786. return
  8787. }
  8788. return *v, true
  8789. }
  8790. // OldOrganizationID returns the old "organization_id" field's value of the Contact entity.
  8791. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8792. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8793. func (m *ContactMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  8794. if !m.op.Is(OpUpdateOne) {
  8795. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  8796. }
  8797. if m.id == nil || m.oldValue == nil {
  8798. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  8799. }
  8800. oldValue, err := m.oldValue(ctx)
  8801. if err != nil {
  8802. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  8803. }
  8804. return oldValue.OrganizationID, nil
  8805. }
  8806. // AddOrganizationID adds u to the "organization_id" field.
  8807. func (m *ContactMutation) AddOrganizationID(u int64) {
  8808. if m.addorganization_id != nil {
  8809. *m.addorganization_id += u
  8810. } else {
  8811. m.addorganization_id = &u
  8812. }
  8813. }
  8814. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  8815. func (m *ContactMutation) AddedOrganizationID() (r int64, exists bool) {
  8816. v := m.addorganization_id
  8817. if v == nil {
  8818. return
  8819. }
  8820. return *v, true
  8821. }
  8822. // ClearOrganizationID clears the value of the "organization_id" field.
  8823. func (m *ContactMutation) ClearOrganizationID() {
  8824. m.organization_id = nil
  8825. m.addorganization_id = nil
  8826. m.clearedFields[contact.FieldOrganizationID] = struct{}{}
  8827. }
  8828. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  8829. func (m *ContactMutation) OrganizationIDCleared() bool {
  8830. _, ok := m.clearedFields[contact.FieldOrganizationID]
  8831. return ok
  8832. }
  8833. // ResetOrganizationID resets all changes to the "organization_id" field.
  8834. func (m *ContactMutation) ResetOrganizationID() {
  8835. m.organization_id = nil
  8836. m.addorganization_id = nil
  8837. delete(m.clearedFields, contact.FieldOrganizationID)
  8838. }
  8839. // SetCtype sets the "ctype" field.
  8840. func (m *ContactMutation) SetCtype(u uint64) {
  8841. m.ctype = &u
  8842. m.addctype = nil
  8843. }
  8844. // Ctype returns the value of the "ctype" field in the mutation.
  8845. func (m *ContactMutation) Ctype() (r uint64, exists bool) {
  8846. v := m.ctype
  8847. if v == nil {
  8848. return
  8849. }
  8850. return *v, true
  8851. }
  8852. // OldCtype returns the old "ctype" field's value of the Contact entity.
  8853. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8854. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8855. func (m *ContactMutation) OldCtype(ctx context.Context) (v uint64, err error) {
  8856. if !m.op.Is(OpUpdateOne) {
  8857. return v, errors.New("OldCtype is only allowed on UpdateOne operations")
  8858. }
  8859. if m.id == nil || m.oldValue == nil {
  8860. return v, errors.New("OldCtype requires an ID field in the mutation")
  8861. }
  8862. oldValue, err := m.oldValue(ctx)
  8863. if err != nil {
  8864. return v, fmt.Errorf("querying old value for OldCtype: %w", err)
  8865. }
  8866. return oldValue.Ctype, nil
  8867. }
  8868. // AddCtype adds u to the "ctype" field.
  8869. func (m *ContactMutation) AddCtype(u int64) {
  8870. if m.addctype != nil {
  8871. *m.addctype += u
  8872. } else {
  8873. m.addctype = &u
  8874. }
  8875. }
  8876. // AddedCtype returns the value that was added to the "ctype" field in this mutation.
  8877. func (m *ContactMutation) AddedCtype() (r int64, exists bool) {
  8878. v := m.addctype
  8879. if v == nil {
  8880. return
  8881. }
  8882. return *v, true
  8883. }
  8884. // ResetCtype resets all changes to the "ctype" field.
  8885. func (m *ContactMutation) ResetCtype() {
  8886. m.ctype = nil
  8887. m.addctype = nil
  8888. }
  8889. // SetCage sets the "cage" field.
  8890. func (m *ContactMutation) SetCage(i int) {
  8891. m.cage = &i
  8892. m.addcage = nil
  8893. }
  8894. // Cage returns the value of the "cage" field in the mutation.
  8895. func (m *ContactMutation) Cage() (r int, exists bool) {
  8896. v := m.cage
  8897. if v == nil {
  8898. return
  8899. }
  8900. return *v, true
  8901. }
  8902. // OldCage returns the old "cage" field's value of the Contact entity.
  8903. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8904. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8905. func (m *ContactMutation) OldCage(ctx context.Context) (v int, err error) {
  8906. if !m.op.Is(OpUpdateOne) {
  8907. return v, errors.New("OldCage is only allowed on UpdateOne operations")
  8908. }
  8909. if m.id == nil || m.oldValue == nil {
  8910. return v, errors.New("OldCage requires an ID field in the mutation")
  8911. }
  8912. oldValue, err := m.oldValue(ctx)
  8913. if err != nil {
  8914. return v, fmt.Errorf("querying old value for OldCage: %w", err)
  8915. }
  8916. return oldValue.Cage, nil
  8917. }
  8918. // AddCage adds i to the "cage" field.
  8919. func (m *ContactMutation) AddCage(i int) {
  8920. if m.addcage != nil {
  8921. *m.addcage += i
  8922. } else {
  8923. m.addcage = &i
  8924. }
  8925. }
  8926. // AddedCage returns the value that was added to the "cage" field in this mutation.
  8927. func (m *ContactMutation) AddedCage() (r int, exists bool) {
  8928. v := m.addcage
  8929. if v == nil {
  8930. return
  8931. }
  8932. return *v, true
  8933. }
  8934. // ResetCage resets all changes to the "cage" field.
  8935. func (m *ContactMutation) ResetCage() {
  8936. m.cage = nil
  8937. m.addcage = nil
  8938. }
  8939. // SetCname sets the "cname" field.
  8940. func (m *ContactMutation) SetCname(s string) {
  8941. m.cname = &s
  8942. }
  8943. // Cname returns the value of the "cname" field in the mutation.
  8944. func (m *ContactMutation) Cname() (r string, exists bool) {
  8945. v := m.cname
  8946. if v == nil {
  8947. return
  8948. }
  8949. return *v, true
  8950. }
  8951. // OldCname returns the old "cname" field's value of the Contact entity.
  8952. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8953. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8954. func (m *ContactMutation) OldCname(ctx context.Context) (v string, err error) {
  8955. if !m.op.Is(OpUpdateOne) {
  8956. return v, errors.New("OldCname is only allowed on UpdateOne operations")
  8957. }
  8958. if m.id == nil || m.oldValue == nil {
  8959. return v, errors.New("OldCname requires an ID field in the mutation")
  8960. }
  8961. oldValue, err := m.oldValue(ctx)
  8962. if err != nil {
  8963. return v, fmt.Errorf("querying old value for OldCname: %w", err)
  8964. }
  8965. return oldValue.Cname, nil
  8966. }
  8967. // ResetCname resets all changes to the "cname" field.
  8968. func (m *ContactMutation) ResetCname() {
  8969. m.cname = nil
  8970. }
  8971. // SetCarea sets the "carea" field.
  8972. func (m *ContactMutation) SetCarea(s string) {
  8973. m.carea = &s
  8974. }
  8975. // Carea returns the value of the "carea" field in the mutation.
  8976. func (m *ContactMutation) Carea() (r string, exists bool) {
  8977. v := m.carea
  8978. if v == nil {
  8979. return
  8980. }
  8981. return *v, true
  8982. }
  8983. // OldCarea returns the old "carea" field's value of the Contact entity.
  8984. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8985. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8986. func (m *ContactMutation) OldCarea(ctx context.Context) (v string, err error) {
  8987. if !m.op.Is(OpUpdateOne) {
  8988. return v, errors.New("OldCarea is only allowed on UpdateOne operations")
  8989. }
  8990. if m.id == nil || m.oldValue == nil {
  8991. return v, errors.New("OldCarea requires an ID field in the mutation")
  8992. }
  8993. oldValue, err := m.oldValue(ctx)
  8994. if err != nil {
  8995. return v, fmt.Errorf("querying old value for OldCarea: %w", err)
  8996. }
  8997. return oldValue.Carea, nil
  8998. }
  8999. // ResetCarea resets all changes to the "carea" field.
  9000. func (m *ContactMutation) ResetCarea() {
  9001. m.carea = nil
  9002. }
  9003. // SetCbirthday sets the "cbirthday" field.
  9004. func (m *ContactMutation) SetCbirthday(s string) {
  9005. m.cbirthday = &s
  9006. }
  9007. // Cbirthday returns the value of the "cbirthday" field in the mutation.
  9008. func (m *ContactMutation) Cbirthday() (r string, exists bool) {
  9009. v := m.cbirthday
  9010. if v == nil {
  9011. return
  9012. }
  9013. return *v, true
  9014. }
  9015. // OldCbirthday returns the old "cbirthday" field's value of the Contact entity.
  9016. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9017. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9018. func (m *ContactMutation) OldCbirthday(ctx context.Context) (v string, err error) {
  9019. if !m.op.Is(OpUpdateOne) {
  9020. return v, errors.New("OldCbirthday is only allowed on UpdateOne operations")
  9021. }
  9022. if m.id == nil || m.oldValue == nil {
  9023. return v, errors.New("OldCbirthday requires an ID field in the mutation")
  9024. }
  9025. oldValue, err := m.oldValue(ctx)
  9026. if err != nil {
  9027. return v, fmt.Errorf("querying old value for OldCbirthday: %w", err)
  9028. }
  9029. return oldValue.Cbirthday, nil
  9030. }
  9031. // ResetCbirthday resets all changes to the "cbirthday" field.
  9032. func (m *ContactMutation) ResetCbirthday() {
  9033. m.cbirthday = nil
  9034. }
  9035. // SetCbirtharea sets the "cbirtharea" field.
  9036. func (m *ContactMutation) SetCbirtharea(s string) {
  9037. m.cbirtharea = &s
  9038. }
  9039. // Cbirtharea returns the value of the "cbirtharea" field in the mutation.
  9040. func (m *ContactMutation) Cbirtharea() (r string, exists bool) {
  9041. v := m.cbirtharea
  9042. if v == nil {
  9043. return
  9044. }
  9045. return *v, true
  9046. }
  9047. // OldCbirtharea returns the old "cbirtharea" field's value of the Contact entity.
  9048. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9049. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9050. func (m *ContactMutation) OldCbirtharea(ctx context.Context) (v string, err error) {
  9051. if !m.op.Is(OpUpdateOne) {
  9052. return v, errors.New("OldCbirtharea is only allowed on UpdateOne operations")
  9053. }
  9054. if m.id == nil || m.oldValue == nil {
  9055. return v, errors.New("OldCbirtharea requires an ID field in the mutation")
  9056. }
  9057. oldValue, err := m.oldValue(ctx)
  9058. if err != nil {
  9059. return v, fmt.Errorf("querying old value for OldCbirtharea: %w", err)
  9060. }
  9061. return oldValue.Cbirtharea, nil
  9062. }
  9063. // ResetCbirtharea resets all changes to the "cbirtharea" field.
  9064. func (m *ContactMutation) ResetCbirtharea() {
  9065. m.cbirtharea = nil
  9066. }
  9067. // SetCidcardNo sets the "cidcard_no" field.
  9068. func (m *ContactMutation) SetCidcardNo(s string) {
  9069. m.cidcard_no = &s
  9070. }
  9071. // CidcardNo returns the value of the "cidcard_no" field in the mutation.
  9072. func (m *ContactMutation) CidcardNo() (r string, exists bool) {
  9073. v := m.cidcard_no
  9074. if v == nil {
  9075. return
  9076. }
  9077. return *v, true
  9078. }
  9079. // OldCidcardNo returns the old "cidcard_no" field's value of the Contact entity.
  9080. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9081. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9082. func (m *ContactMutation) OldCidcardNo(ctx context.Context) (v string, err error) {
  9083. if !m.op.Is(OpUpdateOne) {
  9084. return v, errors.New("OldCidcardNo is only allowed on UpdateOne operations")
  9085. }
  9086. if m.id == nil || m.oldValue == nil {
  9087. return v, errors.New("OldCidcardNo requires an ID field in the mutation")
  9088. }
  9089. oldValue, err := m.oldValue(ctx)
  9090. if err != nil {
  9091. return v, fmt.Errorf("querying old value for OldCidcardNo: %w", err)
  9092. }
  9093. return oldValue.CidcardNo, nil
  9094. }
  9095. // ResetCidcardNo resets all changes to the "cidcard_no" field.
  9096. func (m *ContactMutation) ResetCidcardNo() {
  9097. m.cidcard_no = nil
  9098. }
  9099. // SetCtitle sets the "ctitle" field.
  9100. func (m *ContactMutation) SetCtitle(s string) {
  9101. m.ctitle = &s
  9102. }
  9103. // Ctitle returns the value of the "ctitle" field in the mutation.
  9104. func (m *ContactMutation) Ctitle() (r string, exists bool) {
  9105. v := m.ctitle
  9106. if v == nil {
  9107. return
  9108. }
  9109. return *v, true
  9110. }
  9111. // OldCtitle returns the old "ctitle" field's value of the Contact entity.
  9112. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9113. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9114. func (m *ContactMutation) OldCtitle(ctx context.Context) (v string, err error) {
  9115. if !m.op.Is(OpUpdateOne) {
  9116. return v, errors.New("OldCtitle is only allowed on UpdateOne operations")
  9117. }
  9118. if m.id == nil || m.oldValue == nil {
  9119. return v, errors.New("OldCtitle requires an ID field in the mutation")
  9120. }
  9121. oldValue, err := m.oldValue(ctx)
  9122. if err != nil {
  9123. return v, fmt.Errorf("querying old value for OldCtitle: %w", err)
  9124. }
  9125. return oldValue.Ctitle, nil
  9126. }
  9127. // ResetCtitle resets all changes to the "ctitle" field.
  9128. func (m *ContactMutation) ResetCtitle() {
  9129. m.ctitle = nil
  9130. }
  9131. // SetCc sets the "cc" field.
  9132. func (m *ContactMutation) SetCc(s string) {
  9133. m.cc = &s
  9134. }
  9135. // Cc returns the value of the "cc" field in the mutation.
  9136. func (m *ContactMutation) Cc() (r string, exists bool) {
  9137. v := m.cc
  9138. if v == nil {
  9139. return
  9140. }
  9141. return *v, true
  9142. }
  9143. // OldCc returns the old "cc" field's value of the Contact entity.
  9144. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9145. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9146. func (m *ContactMutation) OldCc(ctx context.Context) (v string, err error) {
  9147. if !m.op.Is(OpUpdateOne) {
  9148. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  9149. }
  9150. if m.id == nil || m.oldValue == nil {
  9151. return v, errors.New("OldCc requires an ID field in the mutation")
  9152. }
  9153. oldValue, err := m.oldValue(ctx)
  9154. if err != nil {
  9155. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  9156. }
  9157. return oldValue.Cc, nil
  9158. }
  9159. // ResetCc resets all changes to the "cc" field.
  9160. func (m *ContactMutation) ResetCc() {
  9161. m.cc = nil
  9162. }
  9163. // SetPhone sets the "phone" field.
  9164. func (m *ContactMutation) SetPhone(s string) {
  9165. m.phone = &s
  9166. }
  9167. // Phone returns the value of the "phone" field in the mutation.
  9168. func (m *ContactMutation) Phone() (r string, exists bool) {
  9169. v := m.phone
  9170. if v == nil {
  9171. return
  9172. }
  9173. return *v, true
  9174. }
  9175. // OldPhone returns the old "phone" field's value of the Contact entity.
  9176. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9177. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9178. func (m *ContactMutation) OldPhone(ctx context.Context) (v string, err error) {
  9179. if !m.op.Is(OpUpdateOne) {
  9180. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  9181. }
  9182. if m.id == nil || m.oldValue == nil {
  9183. return v, errors.New("OldPhone requires an ID field in the mutation")
  9184. }
  9185. oldValue, err := m.oldValue(ctx)
  9186. if err != nil {
  9187. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  9188. }
  9189. return oldValue.Phone, nil
  9190. }
  9191. // ResetPhone resets all changes to the "phone" field.
  9192. func (m *ContactMutation) ResetPhone() {
  9193. m.phone = nil
  9194. }
  9195. // AddContactRelationshipIDs adds the "contact_relationships" edge to the LabelRelationship entity by ids.
  9196. func (m *ContactMutation) AddContactRelationshipIDs(ids ...uint64) {
  9197. if m.contact_relationships == nil {
  9198. m.contact_relationships = make(map[uint64]struct{})
  9199. }
  9200. for i := range ids {
  9201. m.contact_relationships[ids[i]] = struct{}{}
  9202. }
  9203. }
  9204. // ClearContactRelationships clears the "contact_relationships" edge to the LabelRelationship entity.
  9205. func (m *ContactMutation) ClearContactRelationships() {
  9206. m.clearedcontact_relationships = true
  9207. }
  9208. // ContactRelationshipsCleared reports if the "contact_relationships" edge to the LabelRelationship entity was cleared.
  9209. func (m *ContactMutation) ContactRelationshipsCleared() bool {
  9210. return m.clearedcontact_relationships
  9211. }
  9212. // RemoveContactRelationshipIDs removes the "contact_relationships" edge to the LabelRelationship entity by IDs.
  9213. func (m *ContactMutation) RemoveContactRelationshipIDs(ids ...uint64) {
  9214. if m.removedcontact_relationships == nil {
  9215. m.removedcontact_relationships = make(map[uint64]struct{})
  9216. }
  9217. for i := range ids {
  9218. delete(m.contact_relationships, ids[i])
  9219. m.removedcontact_relationships[ids[i]] = struct{}{}
  9220. }
  9221. }
  9222. // RemovedContactRelationships returns the removed IDs of the "contact_relationships" edge to the LabelRelationship entity.
  9223. func (m *ContactMutation) RemovedContactRelationshipsIDs() (ids []uint64) {
  9224. for id := range m.removedcontact_relationships {
  9225. ids = append(ids, id)
  9226. }
  9227. return
  9228. }
  9229. // ContactRelationshipsIDs returns the "contact_relationships" edge IDs in the mutation.
  9230. func (m *ContactMutation) ContactRelationshipsIDs() (ids []uint64) {
  9231. for id := range m.contact_relationships {
  9232. ids = append(ids, id)
  9233. }
  9234. return
  9235. }
  9236. // ResetContactRelationships resets all changes to the "contact_relationships" edge.
  9237. func (m *ContactMutation) ResetContactRelationships() {
  9238. m.contact_relationships = nil
  9239. m.clearedcontact_relationships = false
  9240. m.removedcontact_relationships = nil
  9241. }
  9242. // AddContactMessageIDs adds the "contact_messages" edge to the MessageRecords entity by ids.
  9243. func (m *ContactMutation) AddContactMessageIDs(ids ...uint64) {
  9244. if m.contact_messages == nil {
  9245. m.contact_messages = make(map[uint64]struct{})
  9246. }
  9247. for i := range ids {
  9248. m.contact_messages[ids[i]] = struct{}{}
  9249. }
  9250. }
  9251. // ClearContactMessages clears the "contact_messages" edge to the MessageRecords entity.
  9252. func (m *ContactMutation) ClearContactMessages() {
  9253. m.clearedcontact_messages = true
  9254. }
  9255. // ContactMessagesCleared reports if the "contact_messages" edge to the MessageRecords entity was cleared.
  9256. func (m *ContactMutation) ContactMessagesCleared() bool {
  9257. return m.clearedcontact_messages
  9258. }
  9259. // RemoveContactMessageIDs removes the "contact_messages" edge to the MessageRecords entity by IDs.
  9260. func (m *ContactMutation) RemoveContactMessageIDs(ids ...uint64) {
  9261. if m.removedcontact_messages == nil {
  9262. m.removedcontact_messages = make(map[uint64]struct{})
  9263. }
  9264. for i := range ids {
  9265. delete(m.contact_messages, ids[i])
  9266. m.removedcontact_messages[ids[i]] = struct{}{}
  9267. }
  9268. }
  9269. // RemovedContactMessages returns the removed IDs of the "contact_messages" edge to the MessageRecords entity.
  9270. func (m *ContactMutation) RemovedContactMessagesIDs() (ids []uint64) {
  9271. for id := range m.removedcontact_messages {
  9272. ids = append(ids, id)
  9273. }
  9274. return
  9275. }
  9276. // ContactMessagesIDs returns the "contact_messages" edge IDs in the mutation.
  9277. func (m *ContactMutation) ContactMessagesIDs() (ids []uint64) {
  9278. for id := range m.contact_messages {
  9279. ids = append(ids, id)
  9280. }
  9281. return
  9282. }
  9283. // ResetContactMessages resets all changes to the "contact_messages" edge.
  9284. func (m *ContactMutation) ResetContactMessages() {
  9285. m.contact_messages = nil
  9286. m.clearedcontact_messages = false
  9287. m.removedcontact_messages = nil
  9288. }
  9289. // Where appends a list predicates to the ContactMutation builder.
  9290. func (m *ContactMutation) Where(ps ...predicate.Contact) {
  9291. m.predicates = append(m.predicates, ps...)
  9292. }
  9293. // WhereP appends storage-level predicates to the ContactMutation builder. Using this method,
  9294. // users can use type-assertion to append predicates that do not depend on any generated package.
  9295. func (m *ContactMutation) WhereP(ps ...func(*sql.Selector)) {
  9296. p := make([]predicate.Contact, len(ps))
  9297. for i := range ps {
  9298. p[i] = ps[i]
  9299. }
  9300. m.Where(p...)
  9301. }
  9302. // Op returns the operation name.
  9303. func (m *ContactMutation) Op() Op {
  9304. return m.op
  9305. }
  9306. // SetOp allows setting the mutation operation.
  9307. func (m *ContactMutation) SetOp(op Op) {
  9308. m.op = op
  9309. }
  9310. // Type returns the node type of this mutation (Contact).
  9311. func (m *ContactMutation) Type() string {
  9312. return m.typ
  9313. }
  9314. // Fields returns all fields that were changed during this mutation. Note that in
  9315. // order to get all numeric fields that were incremented/decremented, call
  9316. // AddedFields().
  9317. func (m *ContactMutation) Fields() []string {
  9318. fields := make([]string, 0, 30)
  9319. if m.created_at != nil {
  9320. fields = append(fields, contact.FieldCreatedAt)
  9321. }
  9322. if m.updated_at != nil {
  9323. fields = append(fields, contact.FieldUpdatedAt)
  9324. }
  9325. if m.status != nil {
  9326. fields = append(fields, contact.FieldStatus)
  9327. }
  9328. if m.deleted_at != nil {
  9329. fields = append(fields, contact.FieldDeletedAt)
  9330. }
  9331. if m.wx_wxid != nil {
  9332. fields = append(fields, contact.FieldWxWxid)
  9333. }
  9334. if m._type != nil {
  9335. fields = append(fields, contact.FieldType)
  9336. }
  9337. if m.wxid != nil {
  9338. fields = append(fields, contact.FieldWxid)
  9339. }
  9340. if m.account != nil {
  9341. fields = append(fields, contact.FieldAccount)
  9342. }
  9343. if m.nickname != nil {
  9344. fields = append(fields, contact.FieldNickname)
  9345. }
  9346. if m.markname != nil {
  9347. fields = append(fields, contact.FieldMarkname)
  9348. }
  9349. if m.headimg != nil {
  9350. fields = append(fields, contact.FieldHeadimg)
  9351. }
  9352. if m.sex != nil {
  9353. fields = append(fields, contact.FieldSex)
  9354. }
  9355. if m.starrole != nil {
  9356. fields = append(fields, contact.FieldStarrole)
  9357. }
  9358. if m.dontseeit != nil {
  9359. fields = append(fields, contact.FieldDontseeit)
  9360. }
  9361. if m.dontseeme != nil {
  9362. fields = append(fields, contact.FieldDontseeme)
  9363. }
  9364. if m.lag != nil {
  9365. fields = append(fields, contact.FieldLag)
  9366. }
  9367. if m.gid != nil {
  9368. fields = append(fields, contact.FieldGid)
  9369. }
  9370. if m.gname != nil {
  9371. fields = append(fields, contact.FieldGname)
  9372. }
  9373. if m.v3 != nil {
  9374. fields = append(fields, contact.FieldV3)
  9375. }
  9376. if m.organization_id != nil {
  9377. fields = append(fields, contact.FieldOrganizationID)
  9378. }
  9379. if m.ctype != nil {
  9380. fields = append(fields, contact.FieldCtype)
  9381. }
  9382. if m.cage != nil {
  9383. fields = append(fields, contact.FieldCage)
  9384. }
  9385. if m.cname != nil {
  9386. fields = append(fields, contact.FieldCname)
  9387. }
  9388. if m.carea != nil {
  9389. fields = append(fields, contact.FieldCarea)
  9390. }
  9391. if m.cbirthday != nil {
  9392. fields = append(fields, contact.FieldCbirthday)
  9393. }
  9394. if m.cbirtharea != nil {
  9395. fields = append(fields, contact.FieldCbirtharea)
  9396. }
  9397. if m.cidcard_no != nil {
  9398. fields = append(fields, contact.FieldCidcardNo)
  9399. }
  9400. if m.ctitle != nil {
  9401. fields = append(fields, contact.FieldCtitle)
  9402. }
  9403. if m.cc != nil {
  9404. fields = append(fields, contact.FieldCc)
  9405. }
  9406. if m.phone != nil {
  9407. fields = append(fields, contact.FieldPhone)
  9408. }
  9409. return fields
  9410. }
  9411. // Field returns the value of a field with the given name. The second boolean
  9412. // return value indicates that this field was not set, or was not defined in the
  9413. // schema.
  9414. func (m *ContactMutation) Field(name string) (ent.Value, bool) {
  9415. switch name {
  9416. case contact.FieldCreatedAt:
  9417. return m.CreatedAt()
  9418. case contact.FieldUpdatedAt:
  9419. return m.UpdatedAt()
  9420. case contact.FieldStatus:
  9421. return m.Status()
  9422. case contact.FieldDeletedAt:
  9423. return m.DeletedAt()
  9424. case contact.FieldWxWxid:
  9425. return m.WxWxid()
  9426. case contact.FieldType:
  9427. return m.GetType()
  9428. case contact.FieldWxid:
  9429. return m.Wxid()
  9430. case contact.FieldAccount:
  9431. return m.Account()
  9432. case contact.FieldNickname:
  9433. return m.Nickname()
  9434. case contact.FieldMarkname:
  9435. return m.Markname()
  9436. case contact.FieldHeadimg:
  9437. return m.Headimg()
  9438. case contact.FieldSex:
  9439. return m.Sex()
  9440. case contact.FieldStarrole:
  9441. return m.Starrole()
  9442. case contact.FieldDontseeit:
  9443. return m.Dontseeit()
  9444. case contact.FieldDontseeme:
  9445. return m.Dontseeme()
  9446. case contact.FieldLag:
  9447. return m.Lag()
  9448. case contact.FieldGid:
  9449. return m.Gid()
  9450. case contact.FieldGname:
  9451. return m.Gname()
  9452. case contact.FieldV3:
  9453. return m.V3()
  9454. case contact.FieldOrganizationID:
  9455. return m.OrganizationID()
  9456. case contact.FieldCtype:
  9457. return m.Ctype()
  9458. case contact.FieldCage:
  9459. return m.Cage()
  9460. case contact.FieldCname:
  9461. return m.Cname()
  9462. case contact.FieldCarea:
  9463. return m.Carea()
  9464. case contact.FieldCbirthday:
  9465. return m.Cbirthday()
  9466. case contact.FieldCbirtharea:
  9467. return m.Cbirtharea()
  9468. case contact.FieldCidcardNo:
  9469. return m.CidcardNo()
  9470. case contact.FieldCtitle:
  9471. return m.Ctitle()
  9472. case contact.FieldCc:
  9473. return m.Cc()
  9474. case contact.FieldPhone:
  9475. return m.Phone()
  9476. }
  9477. return nil, false
  9478. }
  9479. // OldField returns the old value of the field from the database. An error is
  9480. // returned if the mutation operation is not UpdateOne, or the query to the
  9481. // database failed.
  9482. func (m *ContactMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  9483. switch name {
  9484. case contact.FieldCreatedAt:
  9485. return m.OldCreatedAt(ctx)
  9486. case contact.FieldUpdatedAt:
  9487. return m.OldUpdatedAt(ctx)
  9488. case contact.FieldStatus:
  9489. return m.OldStatus(ctx)
  9490. case contact.FieldDeletedAt:
  9491. return m.OldDeletedAt(ctx)
  9492. case contact.FieldWxWxid:
  9493. return m.OldWxWxid(ctx)
  9494. case contact.FieldType:
  9495. return m.OldType(ctx)
  9496. case contact.FieldWxid:
  9497. return m.OldWxid(ctx)
  9498. case contact.FieldAccount:
  9499. return m.OldAccount(ctx)
  9500. case contact.FieldNickname:
  9501. return m.OldNickname(ctx)
  9502. case contact.FieldMarkname:
  9503. return m.OldMarkname(ctx)
  9504. case contact.FieldHeadimg:
  9505. return m.OldHeadimg(ctx)
  9506. case contact.FieldSex:
  9507. return m.OldSex(ctx)
  9508. case contact.FieldStarrole:
  9509. return m.OldStarrole(ctx)
  9510. case contact.FieldDontseeit:
  9511. return m.OldDontseeit(ctx)
  9512. case contact.FieldDontseeme:
  9513. return m.OldDontseeme(ctx)
  9514. case contact.FieldLag:
  9515. return m.OldLag(ctx)
  9516. case contact.FieldGid:
  9517. return m.OldGid(ctx)
  9518. case contact.FieldGname:
  9519. return m.OldGname(ctx)
  9520. case contact.FieldV3:
  9521. return m.OldV3(ctx)
  9522. case contact.FieldOrganizationID:
  9523. return m.OldOrganizationID(ctx)
  9524. case contact.FieldCtype:
  9525. return m.OldCtype(ctx)
  9526. case contact.FieldCage:
  9527. return m.OldCage(ctx)
  9528. case contact.FieldCname:
  9529. return m.OldCname(ctx)
  9530. case contact.FieldCarea:
  9531. return m.OldCarea(ctx)
  9532. case contact.FieldCbirthday:
  9533. return m.OldCbirthday(ctx)
  9534. case contact.FieldCbirtharea:
  9535. return m.OldCbirtharea(ctx)
  9536. case contact.FieldCidcardNo:
  9537. return m.OldCidcardNo(ctx)
  9538. case contact.FieldCtitle:
  9539. return m.OldCtitle(ctx)
  9540. case contact.FieldCc:
  9541. return m.OldCc(ctx)
  9542. case contact.FieldPhone:
  9543. return m.OldPhone(ctx)
  9544. }
  9545. return nil, fmt.Errorf("unknown Contact field %s", name)
  9546. }
  9547. // SetField sets the value of a field with the given name. It returns an error if
  9548. // the field is not defined in the schema, or if the type mismatched the field
  9549. // type.
  9550. func (m *ContactMutation) SetField(name string, value ent.Value) error {
  9551. switch name {
  9552. case contact.FieldCreatedAt:
  9553. v, ok := value.(time.Time)
  9554. if !ok {
  9555. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9556. }
  9557. m.SetCreatedAt(v)
  9558. return nil
  9559. case contact.FieldUpdatedAt:
  9560. v, ok := value.(time.Time)
  9561. if !ok {
  9562. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9563. }
  9564. m.SetUpdatedAt(v)
  9565. return nil
  9566. case contact.FieldStatus:
  9567. v, ok := value.(uint8)
  9568. if !ok {
  9569. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9570. }
  9571. m.SetStatus(v)
  9572. return nil
  9573. case contact.FieldDeletedAt:
  9574. v, ok := value.(time.Time)
  9575. if !ok {
  9576. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9577. }
  9578. m.SetDeletedAt(v)
  9579. return nil
  9580. case contact.FieldWxWxid:
  9581. v, ok := value.(string)
  9582. if !ok {
  9583. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9584. }
  9585. m.SetWxWxid(v)
  9586. return nil
  9587. case contact.FieldType:
  9588. v, ok := value.(int)
  9589. if !ok {
  9590. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9591. }
  9592. m.SetType(v)
  9593. return nil
  9594. case contact.FieldWxid:
  9595. v, ok := value.(string)
  9596. if !ok {
  9597. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9598. }
  9599. m.SetWxid(v)
  9600. return nil
  9601. case contact.FieldAccount:
  9602. v, ok := value.(string)
  9603. if !ok {
  9604. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9605. }
  9606. m.SetAccount(v)
  9607. return nil
  9608. case contact.FieldNickname:
  9609. v, ok := value.(string)
  9610. if !ok {
  9611. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9612. }
  9613. m.SetNickname(v)
  9614. return nil
  9615. case contact.FieldMarkname:
  9616. v, ok := value.(string)
  9617. if !ok {
  9618. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9619. }
  9620. m.SetMarkname(v)
  9621. return nil
  9622. case contact.FieldHeadimg:
  9623. v, ok := value.(string)
  9624. if !ok {
  9625. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9626. }
  9627. m.SetHeadimg(v)
  9628. return nil
  9629. case contact.FieldSex:
  9630. v, ok := value.(int)
  9631. if !ok {
  9632. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9633. }
  9634. m.SetSex(v)
  9635. return nil
  9636. case contact.FieldStarrole:
  9637. v, ok := value.(string)
  9638. if !ok {
  9639. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9640. }
  9641. m.SetStarrole(v)
  9642. return nil
  9643. case contact.FieldDontseeit:
  9644. v, ok := value.(int)
  9645. if !ok {
  9646. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9647. }
  9648. m.SetDontseeit(v)
  9649. return nil
  9650. case contact.FieldDontseeme:
  9651. v, ok := value.(int)
  9652. if !ok {
  9653. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9654. }
  9655. m.SetDontseeme(v)
  9656. return nil
  9657. case contact.FieldLag:
  9658. v, ok := value.(string)
  9659. if !ok {
  9660. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9661. }
  9662. m.SetLag(v)
  9663. return nil
  9664. case contact.FieldGid:
  9665. v, ok := value.(string)
  9666. if !ok {
  9667. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9668. }
  9669. m.SetGid(v)
  9670. return nil
  9671. case contact.FieldGname:
  9672. v, ok := value.(string)
  9673. if !ok {
  9674. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9675. }
  9676. m.SetGname(v)
  9677. return nil
  9678. case contact.FieldV3:
  9679. v, ok := value.(string)
  9680. if !ok {
  9681. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9682. }
  9683. m.SetV3(v)
  9684. return nil
  9685. case contact.FieldOrganizationID:
  9686. v, ok := value.(uint64)
  9687. if !ok {
  9688. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9689. }
  9690. m.SetOrganizationID(v)
  9691. return nil
  9692. case contact.FieldCtype:
  9693. v, ok := value.(uint64)
  9694. if !ok {
  9695. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9696. }
  9697. m.SetCtype(v)
  9698. return nil
  9699. case contact.FieldCage:
  9700. v, ok := value.(int)
  9701. if !ok {
  9702. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9703. }
  9704. m.SetCage(v)
  9705. return nil
  9706. case contact.FieldCname:
  9707. v, ok := value.(string)
  9708. if !ok {
  9709. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9710. }
  9711. m.SetCname(v)
  9712. return nil
  9713. case contact.FieldCarea:
  9714. v, ok := value.(string)
  9715. if !ok {
  9716. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9717. }
  9718. m.SetCarea(v)
  9719. return nil
  9720. case contact.FieldCbirthday:
  9721. v, ok := value.(string)
  9722. if !ok {
  9723. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9724. }
  9725. m.SetCbirthday(v)
  9726. return nil
  9727. case contact.FieldCbirtharea:
  9728. v, ok := value.(string)
  9729. if !ok {
  9730. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9731. }
  9732. m.SetCbirtharea(v)
  9733. return nil
  9734. case contact.FieldCidcardNo:
  9735. v, ok := value.(string)
  9736. if !ok {
  9737. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9738. }
  9739. m.SetCidcardNo(v)
  9740. return nil
  9741. case contact.FieldCtitle:
  9742. v, ok := value.(string)
  9743. if !ok {
  9744. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9745. }
  9746. m.SetCtitle(v)
  9747. return nil
  9748. case contact.FieldCc:
  9749. v, ok := value.(string)
  9750. if !ok {
  9751. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9752. }
  9753. m.SetCc(v)
  9754. return nil
  9755. case contact.FieldPhone:
  9756. v, ok := value.(string)
  9757. if !ok {
  9758. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9759. }
  9760. m.SetPhone(v)
  9761. return nil
  9762. }
  9763. return fmt.Errorf("unknown Contact field %s", name)
  9764. }
  9765. // AddedFields returns all numeric fields that were incremented/decremented during
  9766. // this mutation.
  9767. func (m *ContactMutation) AddedFields() []string {
  9768. var fields []string
  9769. if m.addstatus != nil {
  9770. fields = append(fields, contact.FieldStatus)
  9771. }
  9772. if m.add_type != nil {
  9773. fields = append(fields, contact.FieldType)
  9774. }
  9775. if m.addsex != nil {
  9776. fields = append(fields, contact.FieldSex)
  9777. }
  9778. if m.adddontseeit != nil {
  9779. fields = append(fields, contact.FieldDontseeit)
  9780. }
  9781. if m.adddontseeme != nil {
  9782. fields = append(fields, contact.FieldDontseeme)
  9783. }
  9784. if m.addorganization_id != nil {
  9785. fields = append(fields, contact.FieldOrganizationID)
  9786. }
  9787. if m.addctype != nil {
  9788. fields = append(fields, contact.FieldCtype)
  9789. }
  9790. if m.addcage != nil {
  9791. fields = append(fields, contact.FieldCage)
  9792. }
  9793. return fields
  9794. }
  9795. // AddedField returns the numeric value that was incremented/decremented on a field
  9796. // with the given name. The second boolean return value indicates that this field
  9797. // was not set, or was not defined in the schema.
  9798. func (m *ContactMutation) AddedField(name string) (ent.Value, bool) {
  9799. switch name {
  9800. case contact.FieldStatus:
  9801. return m.AddedStatus()
  9802. case contact.FieldType:
  9803. return m.AddedType()
  9804. case contact.FieldSex:
  9805. return m.AddedSex()
  9806. case contact.FieldDontseeit:
  9807. return m.AddedDontseeit()
  9808. case contact.FieldDontseeme:
  9809. return m.AddedDontseeme()
  9810. case contact.FieldOrganizationID:
  9811. return m.AddedOrganizationID()
  9812. case contact.FieldCtype:
  9813. return m.AddedCtype()
  9814. case contact.FieldCage:
  9815. return m.AddedCage()
  9816. }
  9817. return nil, false
  9818. }
  9819. // AddField adds the value to the field with the given name. It returns an error if
  9820. // the field is not defined in the schema, or if the type mismatched the field
  9821. // type.
  9822. func (m *ContactMutation) AddField(name string, value ent.Value) error {
  9823. switch name {
  9824. case contact.FieldStatus:
  9825. v, ok := value.(int8)
  9826. if !ok {
  9827. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9828. }
  9829. m.AddStatus(v)
  9830. return nil
  9831. case contact.FieldType:
  9832. v, ok := value.(int)
  9833. if !ok {
  9834. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9835. }
  9836. m.AddType(v)
  9837. return nil
  9838. case contact.FieldSex:
  9839. v, ok := value.(int)
  9840. if !ok {
  9841. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9842. }
  9843. m.AddSex(v)
  9844. return nil
  9845. case contact.FieldDontseeit:
  9846. v, ok := value.(int)
  9847. if !ok {
  9848. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9849. }
  9850. m.AddDontseeit(v)
  9851. return nil
  9852. case contact.FieldDontseeme:
  9853. v, ok := value.(int)
  9854. if !ok {
  9855. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9856. }
  9857. m.AddDontseeme(v)
  9858. return nil
  9859. case contact.FieldOrganizationID:
  9860. v, ok := value.(int64)
  9861. if !ok {
  9862. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9863. }
  9864. m.AddOrganizationID(v)
  9865. return nil
  9866. case contact.FieldCtype:
  9867. v, ok := value.(int64)
  9868. if !ok {
  9869. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9870. }
  9871. m.AddCtype(v)
  9872. return nil
  9873. case contact.FieldCage:
  9874. v, ok := value.(int)
  9875. if !ok {
  9876. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9877. }
  9878. m.AddCage(v)
  9879. return nil
  9880. }
  9881. return fmt.Errorf("unknown Contact numeric field %s", name)
  9882. }
  9883. // ClearedFields returns all nullable fields that were cleared during this
  9884. // mutation.
  9885. func (m *ContactMutation) ClearedFields() []string {
  9886. var fields []string
  9887. if m.FieldCleared(contact.FieldStatus) {
  9888. fields = append(fields, contact.FieldStatus)
  9889. }
  9890. if m.FieldCleared(contact.FieldDeletedAt) {
  9891. fields = append(fields, contact.FieldDeletedAt)
  9892. }
  9893. if m.FieldCleared(contact.FieldType) {
  9894. fields = append(fields, contact.FieldType)
  9895. }
  9896. if m.FieldCleared(contact.FieldOrganizationID) {
  9897. fields = append(fields, contact.FieldOrganizationID)
  9898. }
  9899. return fields
  9900. }
  9901. // FieldCleared returns a boolean indicating if a field with the given name was
  9902. // cleared in this mutation.
  9903. func (m *ContactMutation) FieldCleared(name string) bool {
  9904. _, ok := m.clearedFields[name]
  9905. return ok
  9906. }
  9907. // ClearField clears the value of the field with the given name. It returns an
  9908. // error if the field is not defined in the schema.
  9909. func (m *ContactMutation) ClearField(name string) error {
  9910. switch name {
  9911. case contact.FieldStatus:
  9912. m.ClearStatus()
  9913. return nil
  9914. case contact.FieldDeletedAt:
  9915. m.ClearDeletedAt()
  9916. return nil
  9917. case contact.FieldType:
  9918. m.ClearType()
  9919. return nil
  9920. case contact.FieldOrganizationID:
  9921. m.ClearOrganizationID()
  9922. return nil
  9923. }
  9924. return fmt.Errorf("unknown Contact nullable field %s", name)
  9925. }
  9926. // ResetField resets all changes in the mutation for the field with the given name.
  9927. // It returns an error if the field is not defined in the schema.
  9928. func (m *ContactMutation) ResetField(name string) error {
  9929. switch name {
  9930. case contact.FieldCreatedAt:
  9931. m.ResetCreatedAt()
  9932. return nil
  9933. case contact.FieldUpdatedAt:
  9934. m.ResetUpdatedAt()
  9935. return nil
  9936. case contact.FieldStatus:
  9937. m.ResetStatus()
  9938. return nil
  9939. case contact.FieldDeletedAt:
  9940. m.ResetDeletedAt()
  9941. return nil
  9942. case contact.FieldWxWxid:
  9943. m.ResetWxWxid()
  9944. return nil
  9945. case contact.FieldType:
  9946. m.ResetType()
  9947. return nil
  9948. case contact.FieldWxid:
  9949. m.ResetWxid()
  9950. return nil
  9951. case contact.FieldAccount:
  9952. m.ResetAccount()
  9953. return nil
  9954. case contact.FieldNickname:
  9955. m.ResetNickname()
  9956. return nil
  9957. case contact.FieldMarkname:
  9958. m.ResetMarkname()
  9959. return nil
  9960. case contact.FieldHeadimg:
  9961. m.ResetHeadimg()
  9962. return nil
  9963. case contact.FieldSex:
  9964. m.ResetSex()
  9965. return nil
  9966. case contact.FieldStarrole:
  9967. m.ResetStarrole()
  9968. return nil
  9969. case contact.FieldDontseeit:
  9970. m.ResetDontseeit()
  9971. return nil
  9972. case contact.FieldDontseeme:
  9973. m.ResetDontseeme()
  9974. return nil
  9975. case contact.FieldLag:
  9976. m.ResetLag()
  9977. return nil
  9978. case contact.FieldGid:
  9979. m.ResetGid()
  9980. return nil
  9981. case contact.FieldGname:
  9982. m.ResetGname()
  9983. return nil
  9984. case contact.FieldV3:
  9985. m.ResetV3()
  9986. return nil
  9987. case contact.FieldOrganizationID:
  9988. m.ResetOrganizationID()
  9989. return nil
  9990. case contact.FieldCtype:
  9991. m.ResetCtype()
  9992. return nil
  9993. case contact.FieldCage:
  9994. m.ResetCage()
  9995. return nil
  9996. case contact.FieldCname:
  9997. m.ResetCname()
  9998. return nil
  9999. case contact.FieldCarea:
  10000. m.ResetCarea()
  10001. return nil
  10002. case contact.FieldCbirthday:
  10003. m.ResetCbirthday()
  10004. return nil
  10005. case contact.FieldCbirtharea:
  10006. m.ResetCbirtharea()
  10007. return nil
  10008. case contact.FieldCidcardNo:
  10009. m.ResetCidcardNo()
  10010. return nil
  10011. case contact.FieldCtitle:
  10012. m.ResetCtitle()
  10013. return nil
  10014. case contact.FieldCc:
  10015. m.ResetCc()
  10016. return nil
  10017. case contact.FieldPhone:
  10018. m.ResetPhone()
  10019. return nil
  10020. }
  10021. return fmt.Errorf("unknown Contact field %s", name)
  10022. }
  10023. // AddedEdges returns all edge names that were set/added in this mutation.
  10024. func (m *ContactMutation) AddedEdges() []string {
  10025. edges := make([]string, 0, 2)
  10026. if m.contact_relationships != nil {
  10027. edges = append(edges, contact.EdgeContactRelationships)
  10028. }
  10029. if m.contact_messages != nil {
  10030. edges = append(edges, contact.EdgeContactMessages)
  10031. }
  10032. return edges
  10033. }
  10034. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  10035. // name in this mutation.
  10036. func (m *ContactMutation) AddedIDs(name string) []ent.Value {
  10037. switch name {
  10038. case contact.EdgeContactRelationships:
  10039. ids := make([]ent.Value, 0, len(m.contact_relationships))
  10040. for id := range m.contact_relationships {
  10041. ids = append(ids, id)
  10042. }
  10043. return ids
  10044. case contact.EdgeContactMessages:
  10045. ids := make([]ent.Value, 0, len(m.contact_messages))
  10046. for id := range m.contact_messages {
  10047. ids = append(ids, id)
  10048. }
  10049. return ids
  10050. }
  10051. return nil
  10052. }
  10053. // RemovedEdges returns all edge names that were removed in this mutation.
  10054. func (m *ContactMutation) RemovedEdges() []string {
  10055. edges := make([]string, 0, 2)
  10056. if m.removedcontact_relationships != nil {
  10057. edges = append(edges, contact.EdgeContactRelationships)
  10058. }
  10059. if m.removedcontact_messages != nil {
  10060. edges = append(edges, contact.EdgeContactMessages)
  10061. }
  10062. return edges
  10063. }
  10064. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  10065. // the given name in this mutation.
  10066. func (m *ContactMutation) RemovedIDs(name string) []ent.Value {
  10067. switch name {
  10068. case contact.EdgeContactRelationships:
  10069. ids := make([]ent.Value, 0, len(m.removedcontact_relationships))
  10070. for id := range m.removedcontact_relationships {
  10071. ids = append(ids, id)
  10072. }
  10073. return ids
  10074. case contact.EdgeContactMessages:
  10075. ids := make([]ent.Value, 0, len(m.removedcontact_messages))
  10076. for id := range m.removedcontact_messages {
  10077. ids = append(ids, id)
  10078. }
  10079. return ids
  10080. }
  10081. return nil
  10082. }
  10083. // ClearedEdges returns all edge names that were cleared in this mutation.
  10084. func (m *ContactMutation) ClearedEdges() []string {
  10085. edges := make([]string, 0, 2)
  10086. if m.clearedcontact_relationships {
  10087. edges = append(edges, contact.EdgeContactRelationships)
  10088. }
  10089. if m.clearedcontact_messages {
  10090. edges = append(edges, contact.EdgeContactMessages)
  10091. }
  10092. return edges
  10093. }
  10094. // EdgeCleared returns a boolean which indicates if the edge with the given name
  10095. // was cleared in this mutation.
  10096. func (m *ContactMutation) EdgeCleared(name string) bool {
  10097. switch name {
  10098. case contact.EdgeContactRelationships:
  10099. return m.clearedcontact_relationships
  10100. case contact.EdgeContactMessages:
  10101. return m.clearedcontact_messages
  10102. }
  10103. return false
  10104. }
  10105. // ClearEdge clears the value of the edge with the given name. It returns an error
  10106. // if that edge is not defined in the schema.
  10107. func (m *ContactMutation) ClearEdge(name string) error {
  10108. switch name {
  10109. }
  10110. return fmt.Errorf("unknown Contact unique edge %s", name)
  10111. }
  10112. // ResetEdge resets all changes to the edge with the given name in this mutation.
  10113. // It returns an error if the edge is not defined in the schema.
  10114. func (m *ContactMutation) ResetEdge(name string) error {
  10115. switch name {
  10116. case contact.EdgeContactRelationships:
  10117. m.ResetContactRelationships()
  10118. return nil
  10119. case contact.EdgeContactMessages:
  10120. m.ResetContactMessages()
  10121. return nil
  10122. }
  10123. return fmt.Errorf("unknown Contact edge %s", name)
  10124. }
  10125. // CreditBalanceMutation represents an operation that mutates the CreditBalance nodes in the graph.
  10126. type CreditBalanceMutation struct {
  10127. config
  10128. op Op
  10129. typ string
  10130. id *uint64
  10131. created_at *time.Time
  10132. updated_at *time.Time
  10133. deleted_at *time.Time
  10134. user_id *string
  10135. balance *float32
  10136. addbalance *float32
  10137. status *int
  10138. addstatus *int
  10139. organization_id *uint64
  10140. addorganization_id *int64
  10141. clearedFields map[string]struct{}
  10142. done bool
  10143. oldValue func(context.Context) (*CreditBalance, error)
  10144. predicates []predicate.CreditBalance
  10145. }
  10146. var _ ent.Mutation = (*CreditBalanceMutation)(nil)
  10147. // creditbalanceOption allows management of the mutation configuration using functional options.
  10148. type creditbalanceOption func(*CreditBalanceMutation)
  10149. // newCreditBalanceMutation creates new mutation for the CreditBalance entity.
  10150. func newCreditBalanceMutation(c config, op Op, opts ...creditbalanceOption) *CreditBalanceMutation {
  10151. m := &CreditBalanceMutation{
  10152. config: c,
  10153. op: op,
  10154. typ: TypeCreditBalance,
  10155. clearedFields: make(map[string]struct{}),
  10156. }
  10157. for _, opt := range opts {
  10158. opt(m)
  10159. }
  10160. return m
  10161. }
  10162. // withCreditBalanceID sets the ID field of the mutation.
  10163. func withCreditBalanceID(id uint64) creditbalanceOption {
  10164. return func(m *CreditBalanceMutation) {
  10165. var (
  10166. err error
  10167. once sync.Once
  10168. value *CreditBalance
  10169. )
  10170. m.oldValue = func(ctx context.Context) (*CreditBalance, error) {
  10171. once.Do(func() {
  10172. if m.done {
  10173. err = errors.New("querying old values post mutation is not allowed")
  10174. } else {
  10175. value, err = m.Client().CreditBalance.Get(ctx, id)
  10176. }
  10177. })
  10178. return value, err
  10179. }
  10180. m.id = &id
  10181. }
  10182. }
  10183. // withCreditBalance sets the old CreditBalance of the mutation.
  10184. func withCreditBalance(node *CreditBalance) creditbalanceOption {
  10185. return func(m *CreditBalanceMutation) {
  10186. m.oldValue = func(context.Context) (*CreditBalance, error) {
  10187. return node, nil
  10188. }
  10189. m.id = &node.ID
  10190. }
  10191. }
  10192. // Client returns a new `ent.Client` from the mutation. If the mutation was
  10193. // executed in a transaction (ent.Tx), a transactional client is returned.
  10194. func (m CreditBalanceMutation) Client() *Client {
  10195. client := &Client{config: m.config}
  10196. client.init()
  10197. return client
  10198. }
  10199. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  10200. // it returns an error otherwise.
  10201. func (m CreditBalanceMutation) Tx() (*Tx, error) {
  10202. if _, ok := m.driver.(*txDriver); !ok {
  10203. return nil, errors.New("ent: mutation is not running in a transaction")
  10204. }
  10205. tx := &Tx{config: m.config}
  10206. tx.init()
  10207. return tx, nil
  10208. }
  10209. // SetID sets the value of the id field. Note that this
  10210. // operation is only accepted on creation of CreditBalance entities.
  10211. func (m *CreditBalanceMutation) SetID(id uint64) {
  10212. m.id = &id
  10213. }
  10214. // ID returns the ID value in the mutation. Note that the ID is only available
  10215. // if it was provided to the builder or after it was returned from the database.
  10216. func (m *CreditBalanceMutation) ID() (id uint64, exists bool) {
  10217. if m.id == nil {
  10218. return
  10219. }
  10220. return *m.id, true
  10221. }
  10222. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  10223. // That means, if the mutation is applied within a transaction with an isolation level such
  10224. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  10225. // or updated by the mutation.
  10226. func (m *CreditBalanceMutation) IDs(ctx context.Context) ([]uint64, error) {
  10227. switch {
  10228. case m.op.Is(OpUpdateOne | OpDeleteOne):
  10229. id, exists := m.ID()
  10230. if exists {
  10231. return []uint64{id}, nil
  10232. }
  10233. fallthrough
  10234. case m.op.Is(OpUpdate | OpDelete):
  10235. return m.Client().CreditBalance.Query().Where(m.predicates...).IDs(ctx)
  10236. default:
  10237. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  10238. }
  10239. }
  10240. // SetCreatedAt sets the "created_at" field.
  10241. func (m *CreditBalanceMutation) SetCreatedAt(t time.Time) {
  10242. m.created_at = &t
  10243. }
  10244. // CreatedAt returns the value of the "created_at" field in the mutation.
  10245. func (m *CreditBalanceMutation) CreatedAt() (r time.Time, exists bool) {
  10246. v := m.created_at
  10247. if v == nil {
  10248. return
  10249. }
  10250. return *v, true
  10251. }
  10252. // OldCreatedAt returns the old "created_at" field's value of the CreditBalance entity.
  10253. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  10254. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10255. func (m *CreditBalanceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  10256. if !m.op.Is(OpUpdateOne) {
  10257. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  10258. }
  10259. if m.id == nil || m.oldValue == nil {
  10260. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  10261. }
  10262. oldValue, err := m.oldValue(ctx)
  10263. if err != nil {
  10264. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  10265. }
  10266. return oldValue.CreatedAt, nil
  10267. }
  10268. // ResetCreatedAt resets all changes to the "created_at" field.
  10269. func (m *CreditBalanceMutation) ResetCreatedAt() {
  10270. m.created_at = nil
  10271. }
  10272. // SetUpdatedAt sets the "updated_at" field.
  10273. func (m *CreditBalanceMutation) SetUpdatedAt(t time.Time) {
  10274. m.updated_at = &t
  10275. }
  10276. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  10277. func (m *CreditBalanceMutation) UpdatedAt() (r time.Time, exists bool) {
  10278. v := m.updated_at
  10279. if v == nil {
  10280. return
  10281. }
  10282. return *v, true
  10283. }
  10284. // OldUpdatedAt returns the old "updated_at" field's value of the CreditBalance entity.
  10285. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  10286. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10287. func (m *CreditBalanceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  10288. if !m.op.Is(OpUpdateOne) {
  10289. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  10290. }
  10291. if m.id == nil || m.oldValue == nil {
  10292. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  10293. }
  10294. oldValue, err := m.oldValue(ctx)
  10295. if err != nil {
  10296. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  10297. }
  10298. return oldValue.UpdatedAt, nil
  10299. }
  10300. // ResetUpdatedAt resets all changes to the "updated_at" field.
  10301. func (m *CreditBalanceMutation) ResetUpdatedAt() {
  10302. m.updated_at = nil
  10303. }
  10304. // SetDeletedAt sets the "deleted_at" field.
  10305. func (m *CreditBalanceMutation) SetDeletedAt(t time.Time) {
  10306. m.deleted_at = &t
  10307. }
  10308. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  10309. func (m *CreditBalanceMutation) DeletedAt() (r time.Time, exists bool) {
  10310. v := m.deleted_at
  10311. if v == nil {
  10312. return
  10313. }
  10314. return *v, true
  10315. }
  10316. // OldDeletedAt returns the old "deleted_at" field's value of the CreditBalance entity.
  10317. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  10318. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10319. func (m *CreditBalanceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  10320. if !m.op.Is(OpUpdateOne) {
  10321. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  10322. }
  10323. if m.id == nil || m.oldValue == nil {
  10324. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  10325. }
  10326. oldValue, err := m.oldValue(ctx)
  10327. if err != nil {
  10328. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  10329. }
  10330. return oldValue.DeletedAt, nil
  10331. }
  10332. // ClearDeletedAt clears the value of the "deleted_at" field.
  10333. func (m *CreditBalanceMutation) ClearDeletedAt() {
  10334. m.deleted_at = nil
  10335. m.clearedFields[creditbalance.FieldDeletedAt] = struct{}{}
  10336. }
  10337. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  10338. func (m *CreditBalanceMutation) DeletedAtCleared() bool {
  10339. _, ok := m.clearedFields[creditbalance.FieldDeletedAt]
  10340. return ok
  10341. }
  10342. // ResetDeletedAt resets all changes to the "deleted_at" field.
  10343. func (m *CreditBalanceMutation) ResetDeletedAt() {
  10344. m.deleted_at = nil
  10345. delete(m.clearedFields, creditbalance.FieldDeletedAt)
  10346. }
  10347. // SetUserID sets the "user_id" field.
  10348. func (m *CreditBalanceMutation) SetUserID(s string) {
  10349. m.user_id = &s
  10350. }
  10351. // UserID returns the value of the "user_id" field in the mutation.
  10352. func (m *CreditBalanceMutation) UserID() (r string, exists bool) {
  10353. v := m.user_id
  10354. if v == nil {
  10355. return
  10356. }
  10357. return *v, true
  10358. }
  10359. // OldUserID returns the old "user_id" field's value of the CreditBalance entity.
  10360. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  10361. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10362. func (m *CreditBalanceMutation) OldUserID(ctx context.Context) (v string, err error) {
  10363. if !m.op.Is(OpUpdateOne) {
  10364. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  10365. }
  10366. if m.id == nil || m.oldValue == nil {
  10367. return v, errors.New("OldUserID requires an ID field in the mutation")
  10368. }
  10369. oldValue, err := m.oldValue(ctx)
  10370. if err != nil {
  10371. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  10372. }
  10373. return oldValue.UserID, nil
  10374. }
  10375. // ClearUserID clears the value of the "user_id" field.
  10376. func (m *CreditBalanceMutation) ClearUserID() {
  10377. m.user_id = nil
  10378. m.clearedFields[creditbalance.FieldUserID] = struct{}{}
  10379. }
  10380. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  10381. func (m *CreditBalanceMutation) UserIDCleared() bool {
  10382. _, ok := m.clearedFields[creditbalance.FieldUserID]
  10383. return ok
  10384. }
  10385. // ResetUserID resets all changes to the "user_id" field.
  10386. func (m *CreditBalanceMutation) ResetUserID() {
  10387. m.user_id = nil
  10388. delete(m.clearedFields, creditbalance.FieldUserID)
  10389. }
  10390. // SetBalance sets the "balance" field.
  10391. func (m *CreditBalanceMutation) SetBalance(f float32) {
  10392. m.balance = &f
  10393. m.addbalance = nil
  10394. }
  10395. // Balance returns the value of the "balance" field in the mutation.
  10396. func (m *CreditBalanceMutation) Balance() (r float32, exists bool) {
  10397. v := m.balance
  10398. if v == nil {
  10399. return
  10400. }
  10401. return *v, true
  10402. }
  10403. // OldBalance returns the old "balance" field's value of the CreditBalance entity.
  10404. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  10405. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10406. func (m *CreditBalanceMutation) OldBalance(ctx context.Context) (v float32, err error) {
  10407. if !m.op.Is(OpUpdateOne) {
  10408. return v, errors.New("OldBalance is only allowed on UpdateOne operations")
  10409. }
  10410. if m.id == nil || m.oldValue == nil {
  10411. return v, errors.New("OldBalance requires an ID field in the mutation")
  10412. }
  10413. oldValue, err := m.oldValue(ctx)
  10414. if err != nil {
  10415. return v, fmt.Errorf("querying old value for OldBalance: %w", err)
  10416. }
  10417. return oldValue.Balance, nil
  10418. }
  10419. // AddBalance adds f to the "balance" field.
  10420. func (m *CreditBalanceMutation) AddBalance(f float32) {
  10421. if m.addbalance != nil {
  10422. *m.addbalance += f
  10423. } else {
  10424. m.addbalance = &f
  10425. }
  10426. }
  10427. // AddedBalance returns the value that was added to the "balance" field in this mutation.
  10428. func (m *CreditBalanceMutation) AddedBalance() (r float32, exists bool) {
  10429. v := m.addbalance
  10430. if v == nil {
  10431. return
  10432. }
  10433. return *v, true
  10434. }
  10435. // ResetBalance resets all changes to the "balance" field.
  10436. func (m *CreditBalanceMutation) ResetBalance() {
  10437. m.balance = nil
  10438. m.addbalance = nil
  10439. }
  10440. // SetStatus sets the "status" field.
  10441. func (m *CreditBalanceMutation) SetStatus(i int) {
  10442. m.status = &i
  10443. m.addstatus = nil
  10444. }
  10445. // Status returns the value of the "status" field in the mutation.
  10446. func (m *CreditBalanceMutation) Status() (r int, exists bool) {
  10447. v := m.status
  10448. if v == nil {
  10449. return
  10450. }
  10451. return *v, true
  10452. }
  10453. // OldStatus returns the old "status" field's value of the CreditBalance entity.
  10454. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  10455. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10456. func (m *CreditBalanceMutation) OldStatus(ctx context.Context) (v int, err error) {
  10457. if !m.op.Is(OpUpdateOne) {
  10458. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  10459. }
  10460. if m.id == nil || m.oldValue == nil {
  10461. return v, errors.New("OldStatus requires an ID field in the mutation")
  10462. }
  10463. oldValue, err := m.oldValue(ctx)
  10464. if err != nil {
  10465. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  10466. }
  10467. return oldValue.Status, nil
  10468. }
  10469. // AddStatus adds i to the "status" field.
  10470. func (m *CreditBalanceMutation) AddStatus(i int) {
  10471. if m.addstatus != nil {
  10472. *m.addstatus += i
  10473. } else {
  10474. m.addstatus = &i
  10475. }
  10476. }
  10477. // AddedStatus returns the value that was added to the "status" field in this mutation.
  10478. func (m *CreditBalanceMutation) AddedStatus() (r int, exists bool) {
  10479. v := m.addstatus
  10480. if v == nil {
  10481. return
  10482. }
  10483. return *v, true
  10484. }
  10485. // ClearStatus clears the value of the "status" field.
  10486. func (m *CreditBalanceMutation) ClearStatus() {
  10487. m.status = nil
  10488. m.addstatus = nil
  10489. m.clearedFields[creditbalance.FieldStatus] = struct{}{}
  10490. }
  10491. // StatusCleared returns if the "status" field was cleared in this mutation.
  10492. func (m *CreditBalanceMutation) StatusCleared() bool {
  10493. _, ok := m.clearedFields[creditbalance.FieldStatus]
  10494. return ok
  10495. }
  10496. // ResetStatus resets all changes to the "status" field.
  10497. func (m *CreditBalanceMutation) ResetStatus() {
  10498. m.status = nil
  10499. m.addstatus = nil
  10500. delete(m.clearedFields, creditbalance.FieldStatus)
  10501. }
  10502. // SetOrganizationID sets the "organization_id" field.
  10503. func (m *CreditBalanceMutation) SetOrganizationID(u uint64) {
  10504. m.organization_id = &u
  10505. m.addorganization_id = nil
  10506. }
  10507. // OrganizationID returns the value of the "organization_id" field in the mutation.
  10508. func (m *CreditBalanceMutation) OrganizationID() (r uint64, exists bool) {
  10509. v := m.organization_id
  10510. if v == nil {
  10511. return
  10512. }
  10513. return *v, true
  10514. }
  10515. // OldOrganizationID returns the old "organization_id" field's value of the CreditBalance entity.
  10516. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  10517. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10518. func (m *CreditBalanceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  10519. if !m.op.Is(OpUpdateOne) {
  10520. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  10521. }
  10522. if m.id == nil || m.oldValue == nil {
  10523. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  10524. }
  10525. oldValue, err := m.oldValue(ctx)
  10526. if err != nil {
  10527. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  10528. }
  10529. return oldValue.OrganizationID, nil
  10530. }
  10531. // AddOrganizationID adds u to the "organization_id" field.
  10532. func (m *CreditBalanceMutation) AddOrganizationID(u int64) {
  10533. if m.addorganization_id != nil {
  10534. *m.addorganization_id += u
  10535. } else {
  10536. m.addorganization_id = &u
  10537. }
  10538. }
  10539. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  10540. func (m *CreditBalanceMutation) AddedOrganizationID() (r int64, exists bool) {
  10541. v := m.addorganization_id
  10542. if v == nil {
  10543. return
  10544. }
  10545. return *v, true
  10546. }
  10547. // ClearOrganizationID clears the value of the "organization_id" field.
  10548. func (m *CreditBalanceMutation) ClearOrganizationID() {
  10549. m.organization_id = nil
  10550. m.addorganization_id = nil
  10551. m.clearedFields[creditbalance.FieldOrganizationID] = struct{}{}
  10552. }
  10553. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  10554. func (m *CreditBalanceMutation) OrganizationIDCleared() bool {
  10555. _, ok := m.clearedFields[creditbalance.FieldOrganizationID]
  10556. return ok
  10557. }
  10558. // ResetOrganizationID resets all changes to the "organization_id" field.
  10559. func (m *CreditBalanceMutation) ResetOrganizationID() {
  10560. m.organization_id = nil
  10561. m.addorganization_id = nil
  10562. delete(m.clearedFields, creditbalance.FieldOrganizationID)
  10563. }
  10564. // Where appends a list predicates to the CreditBalanceMutation builder.
  10565. func (m *CreditBalanceMutation) Where(ps ...predicate.CreditBalance) {
  10566. m.predicates = append(m.predicates, ps...)
  10567. }
  10568. // WhereP appends storage-level predicates to the CreditBalanceMutation builder. Using this method,
  10569. // users can use type-assertion to append predicates that do not depend on any generated package.
  10570. func (m *CreditBalanceMutation) WhereP(ps ...func(*sql.Selector)) {
  10571. p := make([]predicate.CreditBalance, len(ps))
  10572. for i := range ps {
  10573. p[i] = ps[i]
  10574. }
  10575. m.Where(p...)
  10576. }
  10577. // Op returns the operation name.
  10578. func (m *CreditBalanceMutation) Op() Op {
  10579. return m.op
  10580. }
  10581. // SetOp allows setting the mutation operation.
  10582. func (m *CreditBalanceMutation) SetOp(op Op) {
  10583. m.op = op
  10584. }
  10585. // Type returns the node type of this mutation (CreditBalance).
  10586. func (m *CreditBalanceMutation) Type() string {
  10587. return m.typ
  10588. }
  10589. // Fields returns all fields that were changed during this mutation. Note that in
  10590. // order to get all numeric fields that were incremented/decremented, call
  10591. // AddedFields().
  10592. func (m *CreditBalanceMutation) Fields() []string {
  10593. fields := make([]string, 0, 7)
  10594. if m.created_at != nil {
  10595. fields = append(fields, creditbalance.FieldCreatedAt)
  10596. }
  10597. if m.updated_at != nil {
  10598. fields = append(fields, creditbalance.FieldUpdatedAt)
  10599. }
  10600. if m.deleted_at != nil {
  10601. fields = append(fields, creditbalance.FieldDeletedAt)
  10602. }
  10603. if m.user_id != nil {
  10604. fields = append(fields, creditbalance.FieldUserID)
  10605. }
  10606. if m.balance != nil {
  10607. fields = append(fields, creditbalance.FieldBalance)
  10608. }
  10609. if m.status != nil {
  10610. fields = append(fields, creditbalance.FieldStatus)
  10611. }
  10612. if m.organization_id != nil {
  10613. fields = append(fields, creditbalance.FieldOrganizationID)
  10614. }
  10615. return fields
  10616. }
  10617. // Field returns the value of a field with the given name. The second boolean
  10618. // return value indicates that this field was not set, or was not defined in the
  10619. // schema.
  10620. func (m *CreditBalanceMutation) Field(name string) (ent.Value, bool) {
  10621. switch name {
  10622. case creditbalance.FieldCreatedAt:
  10623. return m.CreatedAt()
  10624. case creditbalance.FieldUpdatedAt:
  10625. return m.UpdatedAt()
  10626. case creditbalance.FieldDeletedAt:
  10627. return m.DeletedAt()
  10628. case creditbalance.FieldUserID:
  10629. return m.UserID()
  10630. case creditbalance.FieldBalance:
  10631. return m.Balance()
  10632. case creditbalance.FieldStatus:
  10633. return m.Status()
  10634. case creditbalance.FieldOrganizationID:
  10635. return m.OrganizationID()
  10636. }
  10637. return nil, false
  10638. }
  10639. // OldField returns the old value of the field from the database. An error is
  10640. // returned if the mutation operation is not UpdateOne, or the query to the
  10641. // database failed.
  10642. func (m *CreditBalanceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  10643. switch name {
  10644. case creditbalance.FieldCreatedAt:
  10645. return m.OldCreatedAt(ctx)
  10646. case creditbalance.FieldUpdatedAt:
  10647. return m.OldUpdatedAt(ctx)
  10648. case creditbalance.FieldDeletedAt:
  10649. return m.OldDeletedAt(ctx)
  10650. case creditbalance.FieldUserID:
  10651. return m.OldUserID(ctx)
  10652. case creditbalance.FieldBalance:
  10653. return m.OldBalance(ctx)
  10654. case creditbalance.FieldStatus:
  10655. return m.OldStatus(ctx)
  10656. case creditbalance.FieldOrganizationID:
  10657. return m.OldOrganizationID(ctx)
  10658. }
  10659. return nil, fmt.Errorf("unknown CreditBalance field %s", name)
  10660. }
  10661. // SetField sets the value of a field with the given name. It returns an error if
  10662. // the field is not defined in the schema, or if the type mismatched the field
  10663. // type.
  10664. func (m *CreditBalanceMutation) SetField(name string, value ent.Value) error {
  10665. switch name {
  10666. case creditbalance.FieldCreatedAt:
  10667. v, ok := value.(time.Time)
  10668. if !ok {
  10669. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10670. }
  10671. m.SetCreatedAt(v)
  10672. return nil
  10673. case creditbalance.FieldUpdatedAt:
  10674. v, ok := value.(time.Time)
  10675. if !ok {
  10676. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10677. }
  10678. m.SetUpdatedAt(v)
  10679. return nil
  10680. case creditbalance.FieldDeletedAt:
  10681. v, ok := value.(time.Time)
  10682. if !ok {
  10683. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10684. }
  10685. m.SetDeletedAt(v)
  10686. return nil
  10687. case creditbalance.FieldUserID:
  10688. v, ok := value.(string)
  10689. if !ok {
  10690. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10691. }
  10692. m.SetUserID(v)
  10693. return nil
  10694. case creditbalance.FieldBalance:
  10695. v, ok := value.(float32)
  10696. if !ok {
  10697. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10698. }
  10699. m.SetBalance(v)
  10700. return nil
  10701. case creditbalance.FieldStatus:
  10702. v, ok := value.(int)
  10703. if !ok {
  10704. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10705. }
  10706. m.SetStatus(v)
  10707. return nil
  10708. case creditbalance.FieldOrganizationID:
  10709. v, ok := value.(uint64)
  10710. if !ok {
  10711. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10712. }
  10713. m.SetOrganizationID(v)
  10714. return nil
  10715. }
  10716. return fmt.Errorf("unknown CreditBalance field %s", name)
  10717. }
  10718. // AddedFields returns all numeric fields that were incremented/decremented during
  10719. // this mutation.
  10720. func (m *CreditBalanceMutation) AddedFields() []string {
  10721. var fields []string
  10722. if m.addbalance != nil {
  10723. fields = append(fields, creditbalance.FieldBalance)
  10724. }
  10725. if m.addstatus != nil {
  10726. fields = append(fields, creditbalance.FieldStatus)
  10727. }
  10728. if m.addorganization_id != nil {
  10729. fields = append(fields, creditbalance.FieldOrganizationID)
  10730. }
  10731. return fields
  10732. }
  10733. // AddedField returns the numeric value that was incremented/decremented on a field
  10734. // with the given name. The second boolean return value indicates that this field
  10735. // was not set, or was not defined in the schema.
  10736. func (m *CreditBalanceMutation) AddedField(name string) (ent.Value, bool) {
  10737. switch name {
  10738. case creditbalance.FieldBalance:
  10739. return m.AddedBalance()
  10740. case creditbalance.FieldStatus:
  10741. return m.AddedStatus()
  10742. case creditbalance.FieldOrganizationID:
  10743. return m.AddedOrganizationID()
  10744. }
  10745. return nil, false
  10746. }
  10747. // AddField adds the value to the field with the given name. It returns an error if
  10748. // the field is not defined in the schema, or if the type mismatched the field
  10749. // type.
  10750. func (m *CreditBalanceMutation) AddField(name string, value ent.Value) error {
  10751. switch name {
  10752. case creditbalance.FieldBalance:
  10753. v, ok := value.(float32)
  10754. if !ok {
  10755. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10756. }
  10757. m.AddBalance(v)
  10758. return nil
  10759. case creditbalance.FieldStatus:
  10760. v, ok := value.(int)
  10761. if !ok {
  10762. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10763. }
  10764. m.AddStatus(v)
  10765. return nil
  10766. case creditbalance.FieldOrganizationID:
  10767. v, ok := value.(int64)
  10768. if !ok {
  10769. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10770. }
  10771. m.AddOrganizationID(v)
  10772. return nil
  10773. }
  10774. return fmt.Errorf("unknown CreditBalance numeric field %s", name)
  10775. }
  10776. // ClearedFields returns all nullable fields that were cleared during this
  10777. // mutation.
  10778. func (m *CreditBalanceMutation) ClearedFields() []string {
  10779. var fields []string
  10780. if m.FieldCleared(creditbalance.FieldDeletedAt) {
  10781. fields = append(fields, creditbalance.FieldDeletedAt)
  10782. }
  10783. if m.FieldCleared(creditbalance.FieldUserID) {
  10784. fields = append(fields, creditbalance.FieldUserID)
  10785. }
  10786. if m.FieldCleared(creditbalance.FieldStatus) {
  10787. fields = append(fields, creditbalance.FieldStatus)
  10788. }
  10789. if m.FieldCleared(creditbalance.FieldOrganizationID) {
  10790. fields = append(fields, creditbalance.FieldOrganizationID)
  10791. }
  10792. return fields
  10793. }
  10794. // FieldCleared returns a boolean indicating if a field with the given name was
  10795. // cleared in this mutation.
  10796. func (m *CreditBalanceMutation) FieldCleared(name string) bool {
  10797. _, ok := m.clearedFields[name]
  10798. return ok
  10799. }
  10800. // ClearField clears the value of the field with the given name. It returns an
  10801. // error if the field is not defined in the schema.
  10802. func (m *CreditBalanceMutation) ClearField(name string) error {
  10803. switch name {
  10804. case creditbalance.FieldDeletedAt:
  10805. m.ClearDeletedAt()
  10806. return nil
  10807. case creditbalance.FieldUserID:
  10808. m.ClearUserID()
  10809. return nil
  10810. case creditbalance.FieldStatus:
  10811. m.ClearStatus()
  10812. return nil
  10813. case creditbalance.FieldOrganizationID:
  10814. m.ClearOrganizationID()
  10815. return nil
  10816. }
  10817. return fmt.Errorf("unknown CreditBalance nullable field %s", name)
  10818. }
  10819. // ResetField resets all changes in the mutation for the field with the given name.
  10820. // It returns an error if the field is not defined in the schema.
  10821. func (m *CreditBalanceMutation) ResetField(name string) error {
  10822. switch name {
  10823. case creditbalance.FieldCreatedAt:
  10824. m.ResetCreatedAt()
  10825. return nil
  10826. case creditbalance.FieldUpdatedAt:
  10827. m.ResetUpdatedAt()
  10828. return nil
  10829. case creditbalance.FieldDeletedAt:
  10830. m.ResetDeletedAt()
  10831. return nil
  10832. case creditbalance.FieldUserID:
  10833. m.ResetUserID()
  10834. return nil
  10835. case creditbalance.FieldBalance:
  10836. m.ResetBalance()
  10837. return nil
  10838. case creditbalance.FieldStatus:
  10839. m.ResetStatus()
  10840. return nil
  10841. case creditbalance.FieldOrganizationID:
  10842. m.ResetOrganizationID()
  10843. return nil
  10844. }
  10845. return fmt.Errorf("unknown CreditBalance field %s", name)
  10846. }
  10847. // AddedEdges returns all edge names that were set/added in this mutation.
  10848. func (m *CreditBalanceMutation) AddedEdges() []string {
  10849. edges := make([]string, 0, 0)
  10850. return edges
  10851. }
  10852. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  10853. // name in this mutation.
  10854. func (m *CreditBalanceMutation) AddedIDs(name string) []ent.Value {
  10855. return nil
  10856. }
  10857. // RemovedEdges returns all edge names that were removed in this mutation.
  10858. func (m *CreditBalanceMutation) RemovedEdges() []string {
  10859. edges := make([]string, 0, 0)
  10860. return edges
  10861. }
  10862. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  10863. // the given name in this mutation.
  10864. func (m *CreditBalanceMutation) RemovedIDs(name string) []ent.Value {
  10865. return nil
  10866. }
  10867. // ClearedEdges returns all edge names that were cleared in this mutation.
  10868. func (m *CreditBalanceMutation) ClearedEdges() []string {
  10869. edges := make([]string, 0, 0)
  10870. return edges
  10871. }
  10872. // EdgeCleared returns a boolean which indicates if the edge with the given name
  10873. // was cleared in this mutation.
  10874. func (m *CreditBalanceMutation) EdgeCleared(name string) bool {
  10875. return false
  10876. }
  10877. // ClearEdge clears the value of the edge with the given name. It returns an error
  10878. // if that edge is not defined in the schema.
  10879. func (m *CreditBalanceMutation) ClearEdge(name string) error {
  10880. return fmt.Errorf("unknown CreditBalance unique edge %s", name)
  10881. }
  10882. // ResetEdge resets all changes to the edge with the given name in this mutation.
  10883. // It returns an error if the edge is not defined in the schema.
  10884. func (m *CreditBalanceMutation) ResetEdge(name string) error {
  10885. return fmt.Errorf("unknown CreditBalance edge %s", name)
  10886. }
  10887. // CreditUsageMutation represents an operation that mutates the CreditUsage nodes in the graph.
  10888. type CreditUsageMutation struct {
  10889. config
  10890. op Op
  10891. typ string
  10892. id *uint64
  10893. created_at *time.Time
  10894. updated_at *time.Time
  10895. deleted_at *time.Time
  10896. user_id *string
  10897. number *float32
  10898. addnumber *float32
  10899. status *int
  10900. addstatus *int
  10901. ntype *int
  10902. addntype *int
  10903. table *string
  10904. organization_id *uint64
  10905. addorganization_id *int64
  10906. nid *uint64
  10907. addnid *int64
  10908. reason *string
  10909. operator *string
  10910. clearedFields map[string]struct{}
  10911. done bool
  10912. oldValue func(context.Context) (*CreditUsage, error)
  10913. predicates []predicate.CreditUsage
  10914. }
  10915. var _ ent.Mutation = (*CreditUsageMutation)(nil)
  10916. // creditusageOption allows management of the mutation configuration using functional options.
  10917. type creditusageOption func(*CreditUsageMutation)
  10918. // newCreditUsageMutation creates new mutation for the CreditUsage entity.
  10919. func newCreditUsageMutation(c config, op Op, opts ...creditusageOption) *CreditUsageMutation {
  10920. m := &CreditUsageMutation{
  10921. config: c,
  10922. op: op,
  10923. typ: TypeCreditUsage,
  10924. clearedFields: make(map[string]struct{}),
  10925. }
  10926. for _, opt := range opts {
  10927. opt(m)
  10928. }
  10929. return m
  10930. }
  10931. // withCreditUsageID sets the ID field of the mutation.
  10932. func withCreditUsageID(id uint64) creditusageOption {
  10933. return func(m *CreditUsageMutation) {
  10934. var (
  10935. err error
  10936. once sync.Once
  10937. value *CreditUsage
  10938. )
  10939. m.oldValue = func(ctx context.Context) (*CreditUsage, error) {
  10940. once.Do(func() {
  10941. if m.done {
  10942. err = errors.New("querying old values post mutation is not allowed")
  10943. } else {
  10944. value, err = m.Client().CreditUsage.Get(ctx, id)
  10945. }
  10946. })
  10947. return value, err
  10948. }
  10949. m.id = &id
  10950. }
  10951. }
  10952. // withCreditUsage sets the old CreditUsage of the mutation.
  10953. func withCreditUsage(node *CreditUsage) creditusageOption {
  10954. return func(m *CreditUsageMutation) {
  10955. m.oldValue = func(context.Context) (*CreditUsage, error) {
  10956. return node, nil
  10957. }
  10958. m.id = &node.ID
  10959. }
  10960. }
  10961. // Client returns a new `ent.Client` from the mutation. If the mutation was
  10962. // executed in a transaction (ent.Tx), a transactional client is returned.
  10963. func (m CreditUsageMutation) Client() *Client {
  10964. client := &Client{config: m.config}
  10965. client.init()
  10966. return client
  10967. }
  10968. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  10969. // it returns an error otherwise.
  10970. func (m CreditUsageMutation) Tx() (*Tx, error) {
  10971. if _, ok := m.driver.(*txDriver); !ok {
  10972. return nil, errors.New("ent: mutation is not running in a transaction")
  10973. }
  10974. tx := &Tx{config: m.config}
  10975. tx.init()
  10976. return tx, nil
  10977. }
  10978. // SetID sets the value of the id field. Note that this
  10979. // operation is only accepted on creation of CreditUsage entities.
  10980. func (m *CreditUsageMutation) SetID(id uint64) {
  10981. m.id = &id
  10982. }
  10983. // ID returns the ID value in the mutation. Note that the ID is only available
  10984. // if it was provided to the builder or after it was returned from the database.
  10985. func (m *CreditUsageMutation) ID() (id uint64, exists bool) {
  10986. if m.id == nil {
  10987. return
  10988. }
  10989. return *m.id, true
  10990. }
  10991. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  10992. // That means, if the mutation is applied within a transaction with an isolation level such
  10993. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  10994. // or updated by the mutation.
  10995. func (m *CreditUsageMutation) IDs(ctx context.Context) ([]uint64, error) {
  10996. switch {
  10997. case m.op.Is(OpUpdateOne | OpDeleteOne):
  10998. id, exists := m.ID()
  10999. if exists {
  11000. return []uint64{id}, nil
  11001. }
  11002. fallthrough
  11003. case m.op.Is(OpUpdate | OpDelete):
  11004. return m.Client().CreditUsage.Query().Where(m.predicates...).IDs(ctx)
  11005. default:
  11006. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  11007. }
  11008. }
  11009. // SetCreatedAt sets the "created_at" field.
  11010. func (m *CreditUsageMutation) SetCreatedAt(t time.Time) {
  11011. m.created_at = &t
  11012. }
  11013. // CreatedAt returns the value of the "created_at" field in the mutation.
  11014. func (m *CreditUsageMutation) CreatedAt() (r time.Time, exists bool) {
  11015. v := m.created_at
  11016. if v == nil {
  11017. return
  11018. }
  11019. return *v, true
  11020. }
  11021. // OldCreatedAt returns the old "created_at" field's value of the CreditUsage entity.
  11022. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  11023. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11024. func (m *CreditUsageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  11025. if !m.op.Is(OpUpdateOne) {
  11026. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  11027. }
  11028. if m.id == nil || m.oldValue == nil {
  11029. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  11030. }
  11031. oldValue, err := m.oldValue(ctx)
  11032. if err != nil {
  11033. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  11034. }
  11035. return oldValue.CreatedAt, nil
  11036. }
  11037. // ResetCreatedAt resets all changes to the "created_at" field.
  11038. func (m *CreditUsageMutation) ResetCreatedAt() {
  11039. m.created_at = nil
  11040. }
  11041. // SetUpdatedAt sets the "updated_at" field.
  11042. func (m *CreditUsageMutation) SetUpdatedAt(t time.Time) {
  11043. m.updated_at = &t
  11044. }
  11045. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  11046. func (m *CreditUsageMutation) UpdatedAt() (r time.Time, exists bool) {
  11047. v := m.updated_at
  11048. if v == nil {
  11049. return
  11050. }
  11051. return *v, true
  11052. }
  11053. // OldUpdatedAt returns the old "updated_at" field's value of the CreditUsage entity.
  11054. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  11055. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11056. func (m *CreditUsageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  11057. if !m.op.Is(OpUpdateOne) {
  11058. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  11059. }
  11060. if m.id == nil || m.oldValue == nil {
  11061. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  11062. }
  11063. oldValue, err := m.oldValue(ctx)
  11064. if err != nil {
  11065. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  11066. }
  11067. return oldValue.UpdatedAt, nil
  11068. }
  11069. // ResetUpdatedAt resets all changes to the "updated_at" field.
  11070. func (m *CreditUsageMutation) ResetUpdatedAt() {
  11071. m.updated_at = nil
  11072. }
  11073. // SetDeletedAt sets the "deleted_at" field.
  11074. func (m *CreditUsageMutation) SetDeletedAt(t time.Time) {
  11075. m.deleted_at = &t
  11076. }
  11077. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  11078. func (m *CreditUsageMutation) DeletedAt() (r time.Time, exists bool) {
  11079. v := m.deleted_at
  11080. if v == nil {
  11081. return
  11082. }
  11083. return *v, true
  11084. }
  11085. // OldDeletedAt returns the old "deleted_at" field's value of the CreditUsage entity.
  11086. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  11087. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11088. func (m *CreditUsageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  11089. if !m.op.Is(OpUpdateOne) {
  11090. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  11091. }
  11092. if m.id == nil || m.oldValue == nil {
  11093. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  11094. }
  11095. oldValue, err := m.oldValue(ctx)
  11096. if err != nil {
  11097. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  11098. }
  11099. return oldValue.DeletedAt, nil
  11100. }
  11101. // ClearDeletedAt clears the value of the "deleted_at" field.
  11102. func (m *CreditUsageMutation) ClearDeletedAt() {
  11103. m.deleted_at = nil
  11104. m.clearedFields[creditusage.FieldDeletedAt] = struct{}{}
  11105. }
  11106. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  11107. func (m *CreditUsageMutation) DeletedAtCleared() bool {
  11108. _, ok := m.clearedFields[creditusage.FieldDeletedAt]
  11109. return ok
  11110. }
  11111. // ResetDeletedAt resets all changes to the "deleted_at" field.
  11112. func (m *CreditUsageMutation) ResetDeletedAt() {
  11113. m.deleted_at = nil
  11114. delete(m.clearedFields, creditusage.FieldDeletedAt)
  11115. }
  11116. // SetUserID sets the "user_id" field.
  11117. func (m *CreditUsageMutation) SetUserID(s string) {
  11118. m.user_id = &s
  11119. }
  11120. // UserID returns the value of the "user_id" field in the mutation.
  11121. func (m *CreditUsageMutation) UserID() (r string, exists bool) {
  11122. v := m.user_id
  11123. if v == nil {
  11124. return
  11125. }
  11126. return *v, true
  11127. }
  11128. // OldUserID returns the old "user_id" field's value of the CreditUsage entity.
  11129. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  11130. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11131. func (m *CreditUsageMutation) OldUserID(ctx context.Context) (v string, err error) {
  11132. if !m.op.Is(OpUpdateOne) {
  11133. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  11134. }
  11135. if m.id == nil || m.oldValue == nil {
  11136. return v, errors.New("OldUserID requires an ID field in the mutation")
  11137. }
  11138. oldValue, err := m.oldValue(ctx)
  11139. if err != nil {
  11140. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  11141. }
  11142. return oldValue.UserID, nil
  11143. }
  11144. // ClearUserID clears the value of the "user_id" field.
  11145. func (m *CreditUsageMutation) ClearUserID() {
  11146. m.user_id = nil
  11147. m.clearedFields[creditusage.FieldUserID] = struct{}{}
  11148. }
  11149. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  11150. func (m *CreditUsageMutation) UserIDCleared() bool {
  11151. _, ok := m.clearedFields[creditusage.FieldUserID]
  11152. return ok
  11153. }
  11154. // ResetUserID resets all changes to the "user_id" field.
  11155. func (m *CreditUsageMutation) ResetUserID() {
  11156. m.user_id = nil
  11157. delete(m.clearedFields, creditusage.FieldUserID)
  11158. }
  11159. // SetNumber sets the "number" field.
  11160. func (m *CreditUsageMutation) SetNumber(f float32) {
  11161. m.number = &f
  11162. m.addnumber = nil
  11163. }
  11164. // Number returns the value of the "number" field in the mutation.
  11165. func (m *CreditUsageMutation) Number() (r float32, exists bool) {
  11166. v := m.number
  11167. if v == nil {
  11168. return
  11169. }
  11170. return *v, true
  11171. }
  11172. // OldNumber returns the old "number" field's value of the CreditUsage entity.
  11173. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  11174. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11175. func (m *CreditUsageMutation) OldNumber(ctx context.Context) (v float32, err error) {
  11176. if !m.op.Is(OpUpdateOne) {
  11177. return v, errors.New("OldNumber is only allowed on UpdateOne operations")
  11178. }
  11179. if m.id == nil || m.oldValue == nil {
  11180. return v, errors.New("OldNumber requires an ID field in the mutation")
  11181. }
  11182. oldValue, err := m.oldValue(ctx)
  11183. if err != nil {
  11184. return v, fmt.Errorf("querying old value for OldNumber: %w", err)
  11185. }
  11186. return oldValue.Number, nil
  11187. }
  11188. // AddNumber adds f to the "number" field.
  11189. func (m *CreditUsageMutation) AddNumber(f float32) {
  11190. if m.addnumber != nil {
  11191. *m.addnumber += f
  11192. } else {
  11193. m.addnumber = &f
  11194. }
  11195. }
  11196. // AddedNumber returns the value that was added to the "number" field in this mutation.
  11197. func (m *CreditUsageMutation) AddedNumber() (r float32, exists bool) {
  11198. v := m.addnumber
  11199. if v == nil {
  11200. return
  11201. }
  11202. return *v, true
  11203. }
  11204. // ResetNumber resets all changes to the "number" field.
  11205. func (m *CreditUsageMutation) ResetNumber() {
  11206. m.number = nil
  11207. m.addnumber = nil
  11208. }
  11209. // SetStatus sets the "status" field.
  11210. func (m *CreditUsageMutation) SetStatus(i int) {
  11211. m.status = &i
  11212. m.addstatus = nil
  11213. }
  11214. // Status returns the value of the "status" field in the mutation.
  11215. func (m *CreditUsageMutation) Status() (r int, exists bool) {
  11216. v := m.status
  11217. if v == nil {
  11218. return
  11219. }
  11220. return *v, true
  11221. }
  11222. // OldStatus returns the old "status" field's value of the CreditUsage entity.
  11223. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  11224. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11225. func (m *CreditUsageMutation) OldStatus(ctx context.Context) (v int, err error) {
  11226. if !m.op.Is(OpUpdateOne) {
  11227. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  11228. }
  11229. if m.id == nil || m.oldValue == nil {
  11230. return v, errors.New("OldStatus requires an ID field in the mutation")
  11231. }
  11232. oldValue, err := m.oldValue(ctx)
  11233. if err != nil {
  11234. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  11235. }
  11236. return oldValue.Status, nil
  11237. }
  11238. // AddStatus adds i to the "status" field.
  11239. func (m *CreditUsageMutation) AddStatus(i int) {
  11240. if m.addstatus != nil {
  11241. *m.addstatus += i
  11242. } else {
  11243. m.addstatus = &i
  11244. }
  11245. }
  11246. // AddedStatus returns the value that was added to the "status" field in this mutation.
  11247. func (m *CreditUsageMutation) AddedStatus() (r int, exists bool) {
  11248. v := m.addstatus
  11249. if v == nil {
  11250. return
  11251. }
  11252. return *v, true
  11253. }
  11254. // ClearStatus clears the value of the "status" field.
  11255. func (m *CreditUsageMutation) ClearStatus() {
  11256. m.status = nil
  11257. m.addstatus = nil
  11258. m.clearedFields[creditusage.FieldStatus] = struct{}{}
  11259. }
  11260. // StatusCleared returns if the "status" field was cleared in this mutation.
  11261. func (m *CreditUsageMutation) StatusCleared() bool {
  11262. _, ok := m.clearedFields[creditusage.FieldStatus]
  11263. return ok
  11264. }
  11265. // ResetStatus resets all changes to the "status" field.
  11266. func (m *CreditUsageMutation) ResetStatus() {
  11267. m.status = nil
  11268. m.addstatus = nil
  11269. delete(m.clearedFields, creditusage.FieldStatus)
  11270. }
  11271. // SetNtype sets the "ntype" field.
  11272. func (m *CreditUsageMutation) SetNtype(i int) {
  11273. m.ntype = &i
  11274. m.addntype = nil
  11275. }
  11276. // Ntype returns the value of the "ntype" field in the mutation.
  11277. func (m *CreditUsageMutation) Ntype() (r int, exists bool) {
  11278. v := m.ntype
  11279. if v == nil {
  11280. return
  11281. }
  11282. return *v, true
  11283. }
  11284. // OldNtype returns the old "ntype" field's value of the CreditUsage entity.
  11285. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  11286. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11287. func (m *CreditUsageMutation) OldNtype(ctx context.Context) (v int, err error) {
  11288. if !m.op.Is(OpUpdateOne) {
  11289. return v, errors.New("OldNtype is only allowed on UpdateOne operations")
  11290. }
  11291. if m.id == nil || m.oldValue == nil {
  11292. return v, errors.New("OldNtype requires an ID field in the mutation")
  11293. }
  11294. oldValue, err := m.oldValue(ctx)
  11295. if err != nil {
  11296. return v, fmt.Errorf("querying old value for OldNtype: %w", err)
  11297. }
  11298. return oldValue.Ntype, nil
  11299. }
  11300. // AddNtype adds i to the "ntype" field.
  11301. func (m *CreditUsageMutation) AddNtype(i int) {
  11302. if m.addntype != nil {
  11303. *m.addntype += i
  11304. } else {
  11305. m.addntype = &i
  11306. }
  11307. }
  11308. // AddedNtype returns the value that was added to the "ntype" field in this mutation.
  11309. func (m *CreditUsageMutation) AddedNtype() (r int, exists bool) {
  11310. v := m.addntype
  11311. if v == nil {
  11312. return
  11313. }
  11314. return *v, true
  11315. }
  11316. // ResetNtype resets all changes to the "ntype" field.
  11317. func (m *CreditUsageMutation) ResetNtype() {
  11318. m.ntype = nil
  11319. m.addntype = nil
  11320. }
  11321. // SetTable sets the "table" field.
  11322. func (m *CreditUsageMutation) SetTable(s string) {
  11323. m.table = &s
  11324. }
  11325. // Table returns the value of the "table" field in the mutation.
  11326. func (m *CreditUsageMutation) Table() (r string, exists bool) {
  11327. v := m.table
  11328. if v == nil {
  11329. return
  11330. }
  11331. return *v, true
  11332. }
  11333. // OldTable returns the old "table" field's value of the CreditUsage entity.
  11334. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  11335. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11336. func (m *CreditUsageMutation) OldTable(ctx context.Context) (v string, err error) {
  11337. if !m.op.Is(OpUpdateOne) {
  11338. return v, errors.New("OldTable is only allowed on UpdateOne operations")
  11339. }
  11340. if m.id == nil || m.oldValue == nil {
  11341. return v, errors.New("OldTable requires an ID field in the mutation")
  11342. }
  11343. oldValue, err := m.oldValue(ctx)
  11344. if err != nil {
  11345. return v, fmt.Errorf("querying old value for OldTable: %w", err)
  11346. }
  11347. return oldValue.Table, nil
  11348. }
  11349. // ResetTable resets all changes to the "table" field.
  11350. func (m *CreditUsageMutation) ResetTable() {
  11351. m.table = nil
  11352. }
  11353. // SetOrganizationID sets the "organization_id" field.
  11354. func (m *CreditUsageMutation) SetOrganizationID(u uint64) {
  11355. m.organization_id = &u
  11356. m.addorganization_id = nil
  11357. }
  11358. // OrganizationID returns the value of the "organization_id" field in the mutation.
  11359. func (m *CreditUsageMutation) OrganizationID() (r uint64, exists bool) {
  11360. v := m.organization_id
  11361. if v == nil {
  11362. return
  11363. }
  11364. return *v, true
  11365. }
  11366. // OldOrganizationID returns the old "organization_id" field's value of the CreditUsage entity.
  11367. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  11368. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11369. func (m *CreditUsageMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  11370. if !m.op.Is(OpUpdateOne) {
  11371. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  11372. }
  11373. if m.id == nil || m.oldValue == nil {
  11374. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  11375. }
  11376. oldValue, err := m.oldValue(ctx)
  11377. if err != nil {
  11378. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  11379. }
  11380. return oldValue.OrganizationID, nil
  11381. }
  11382. // AddOrganizationID adds u to the "organization_id" field.
  11383. func (m *CreditUsageMutation) AddOrganizationID(u int64) {
  11384. if m.addorganization_id != nil {
  11385. *m.addorganization_id += u
  11386. } else {
  11387. m.addorganization_id = &u
  11388. }
  11389. }
  11390. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  11391. func (m *CreditUsageMutation) AddedOrganizationID() (r int64, exists bool) {
  11392. v := m.addorganization_id
  11393. if v == nil {
  11394. return
  11395. }
  11396. return *v, true
  11397. }
  11398. // ClearOrganizationID clears the value of the "organization_id" field.
  11399. func (m *CreditUsageMutation) ClearOrganizationID() {
  11400. m.organization_id = nil
  11401. m.addorganization_id = nil
  11402. m.clearedFields[creditusage.FieldOrganizationID] = struct{}{}
  11403. }
  11404. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  11405. func (m *CreditUsageMutation) OrganizationIDCleared() bool {
  11406. _, ok := m.clearedFields[creditusage.FieldOrganizationID]
  11407. return ok
  11408. }
  11409. // ResetOrganizationID resets all changes to the "organization_id" field.
  11410. func (m *CreditUsageMutation) ResetOrganizationID() {
  11411. m.organization_id = nil
  11412. m.addorganization_id = nil
  11413. delete(m.clearedFields, creditusage.FieldOrganizationID)
  11414. }
  11415. // SetNid sets the "nid" field.
  11416. func (m *CreditUsageMutation) SetNid(u uint64) {
  11417. m.nid = &u
  11418. m.addnid = nil
  11419. }
  11420. // Nid returns the value of the "nid" field in the mutation.
  11421. func (m *CreditUsageMutation) Nid() (r uint64, exists bool) {
  11422. v := m.nid
  11423. if v == nil {
  11424. return
  11425. }
  11426. return *v, true
  11427. }
  11428. // OldNid returns the old "nid" field's value of the CreditUsage entity.
  11429. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  11430. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11431. func (m *CreditUsageMutation) OldNid(ctx context.Context) (v uint64, err error) {
  11432. if !m.op.Is(OpUpdateOne) {
  11433. return v, errors.New("OldNid is only allowed on UpdateOne operations")
  11434. }
  11435. if m.id == nil || m.oldValue == nil {
  11436. return v, errors.New("OldNid requires an ID field in the mutation")
  11437. }
  11438. oldValue, err := m.oldValue(ctx)
  11439. if err != nil {
  11440. return v, fmt.Errorf("querying old value for OldNid: %w", err)
  11441. }
  11442. return oldValue.Nid, nil
  11443. }
  11444. // AddNid adds u to the "nid" field.
  11445. func (m *CreditUsageMutation) AddNid(u int64) {
  11446. if m.addnid != nil {
  11447. *m.addnid += u
  11448. } else {
  11449. m.addnid = &u
  11450. }
  11451. }
  11452. // AddedNid returns the value that was added to the "nid" field in this mutation.
  11453. func (m *CreditUsageMutation) AddedNid() (r int64, exists bool) {
  11454. v := m.addnid
  11455. if v == nil {
  11456. return
  11457. }
  11458. return *v, true
  11459. }
  11460. // ResetNid resets all changes to the "nid" field.
  11461. func (m *CreditUsageMutation) ResetNid() {
  11462. m.nid = nil
  11463. m.addnid = nil
  11464. }
  11465. // SetReason sets the "reason" field.
  11466. func (m *CreditUsageMutation) SetReason(s string) {
  11467. m.reason = &s
  11468. }
  11469. // Reason returns the value of the "reason" field in the mutation.
  11470. func (m *CreditUsageMutation) Reason() (r string, exists bool) {
  11471. v := m.reason
  11472. if v == nil {
  11473. return
  11474. }
  11475. return *v, true
  11476. }
  11477. // OldReason returns the old "reason" field's value of the CreditUsage entity.
  11478. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  11479. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11480. func (m *CreditUsageMutation) OldReason(ctx context.Context) (v string, err error) {
  11481. if !m.op.Is(OpUpdateOne) {
  11482. return v, errors.New("OldReason is only allowed on UpdateOne operations")
  11483. }
  11484. if m.id == nil || m.oldValue == nil {
  11485. return v, errors.New("OldReason requires an ID field in the mutation")
  11486. }
  11487. oldValue, err := m.oldValue(ctx)
  11488. if err != nil {
  11489. return v, fmt.Errorf("querying old value for OldReason: %w", err)
  11490. }
  11491. return oldValue.Reason, nil
  11492. }
  11493. // ResetReason resets all changes to the "reason" field.
  11494. func (m *CreditUsageMutation) ResetReason() {
  11495. m.reason = nil
  11496. }
  11497. // SetOperator sets the "operator" field.
  11498. func (m *CreditUsageMutation) SetOperator(s string) {
  11499. m.operator = &s
  11500. }
  11501. // Operator returns the value of the "operator" field in the mutation.
  11502. func (m *CreditUsageMutation) Operator() (r string, exists bool) {
  11503. v := m.operator
  11504. if v == nil {
  11505. return
  11506. }
  11507. return *v, true
  11508. }
  11509. // OldOperator returns the old "operator" field's value of the CreditUsage entity.
  11510. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  11511. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11512. func (m *CreditUsageMutation) OldOperator(ctx context.Context) (v string, err error) {
  11513. if !m.op.Is(OpUpdateOne) {
  11514. return v, errors.New("OldOperator is only allowed on UpdateOne operations")
  11515. }
  11516. if m.id == nil || m.oldValue == nil {
  11517. return v, errors.New("OldOperator requires an ID field in the mutation")
  11518. }
  11519. oldValue, err := m.oldValue(ctx)
  11520. if err != nil {
  11521. return v, fmt.Errorf("querying old value for OldOperator: %w", err)
  11522. }
  11523. return oldValue.Operator, nil
  11524. }
  11525. // ResetOperator resets all changes to the "operator" field.
  11526. func (m *CreditUsageMutation) ResetOperator() {
  11527. m.operator = nil
  11528. }
  11529. // Where appends a list predicates to the CreditUsageMutation builder.
  11530. func (m *CreditUsageMutation) Where(ps ...predicate.CreditUsage) {
  11531. m.predicates = append(m.predicates, ps...)
  11532. }
  11533. // WhereP appends storage-level predicates to the CreditUsageMutation builder. Using this method,
  11534. // users can use type-assertion to append predicates that do not depend on any generated package.
  11535. func (m *CreditUsageMutation) WhereP(ps ...func(*sql.Selector)) {
  11536. p := make([]predicate.CreditUsage, len(ps))
  11537. for i := range ps {
  11538. p[i] = ps[i]
  11539. }
  11540. m.Where(p...)
  11541. }
  11542. // Op returns the operation name.
  11543. func (m *CreditUsageMutation) Op() Op {
  11544. return m.op
  11545. }
  11546. // SetOp allows setting the mutation operation.
  11547. func (m *CreditUsageMutation) SetOp(op Op) {
  11548. m.op = op
  11549. }
  11550. // Type returns the node type of this mutation (CreditUsage).
  11551. func (m *CreditUsageMutation) Type() string {
  11552. return m.typ
  11553. }
  11554. // Fields returns all fields that were changed during this mutation. Note that in
  11555. // order to get all numeric fields that were incremented/decremented, call
  11556. // AddedFields().
  11557. func (m *CreditUsageMutation) Fields() []string {
  11558. fields := make([]string, 0, 12)
  11559. if m.created_at != nil {
  11560. fields = append(fields, creditusage.FieldCreatedAt)
  11561. }
  11562. if m.updated_at != nil {
  11563. fields = append(fields, creditusage.FieldUpdatedAt)
  11564. }
  11565. if m.deleted_at != nil {
  11566. fields = append(fields, creditusage.FieldDeletedAt)
  11567. }
  11568. if m.user_id != nil {
  11569. fields = append(fields, creditusage.FieldUserID)
  11570. }
  11571. if m.number != nil {
  11572. fields = append(fields, creditusage.FieldNumber)
  11573. }
  11574. if m.status != nil {
  11575. fields = append(fields, creditusage.FieldStatus)
  11576. }
  11577. if m.ntype != nil {
  11578. fields = append(fields, creditusage.FieldNtype)
  11579. }
  11580. if m.table != nil {
  11581. fields = append(fields, creditusage.FieldTable)
  11582. }
  11583. if m.organization_id != nil {
  11584. fields = append(fields, creditusage.FieldOrganizationID)
  11585. }
  11586. if m.nid != nil {
  11587. fields = append(fields, creditusage.FieldNid)
  11588. }
  11589. if m.reason != nil {
  11590. fields = append(fields, creditusage.FieldReason)
  11591. }
  11592. if m.operator != nil {
  11593. fields = append(fields, creditusage.FieldOperator)
  11594. }
  11595. return fields
  11596. }
  11597. // Field returns the value of a field with the given name. The second boolean
  11598. // return value indicates that this field was not set, or was not defined in the
  11599. // schema.
  11600. func (m *CreditUsageMutation) Field(name string) (ent.Value, bool) {
  11601. switch name {
  11602. case creditusage.FieldCreatedAt:
  11603. return m.CreatedAt()
  11604. case creditusage.FieldUpdatedAt:
  11605. return m.UpdatedAt()
  11606. case creditusage.FieldDeletedAt:
  11607. return m.DeletedAt()
  11608. case creditusage.FieldUserID:
  11609. return m.UserID()
  11610. case creditusage.FieldNumber:
  11611. return m.Number()
  11612. case creditusage.FieldStatus:
  11613. return m.Status()
  11614. case creditusage.FieldNtype:
  11615. return m.Ntype()
  11616. case creditusage.FieldTable:
  11617. return m.Table()
  11618. case creditusage.FieldOrganizationID:
  11619. return m.OrganizationID()
  11620. case creditusage.FieldNid:
  11621. return m.Nid()
  11622. case creditusage.FieldReason:
  11623. return m.Reason()
  11624. case creditusage.FieldOperator:
  11625. return m.Operator()
  11626. }
  11627. return nil, false
  11628. }
  11629. // OldField returns the old value of the field from the database. An error is
  11630. // returned if the mutation operation is not UpdateOne, or the query to the
  11631. // database failed.
  11632. func (m *CreditUsageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  11633. switch name {
  11634. case creditusage.FieldCreatedAt:
  11635. return m.OldCreatedAt(ctx)
  11636. case creditusage.FieldUpdatedAt:
  11637. return m.OldUpdatedAt(ctx)
  11638. case creditusage.FieldDeletedAt:
  11639. return m.OldDeletedAt(ctx)
  11640. case creditusage.FieldUserID:
  11641. return m.OldUserID(ctx)
  11642. case creditusage.FieldNumber:
  11643. return m.OldNumber(ctx)
  11644. case creditusage.FieldStatus:
  11645. return m.OldStatus(ctx)
  11646. case creditusage.FieldNtype:
  11647. return m.OldNtype(ctx)
  11648. case creditusage.FieldTable:
  11649. return m.OldTable(ctx)
  11650. case creditusage.FieldOrganizationID:
  11651. return m.OldOrganizationID(ctx)
  11652. case creditusage.FieldNid:
  11653. return m.OldNid(ctx)
  11654. case creditusage.FieldReason:
  11655. return m.OldReason(ctx)
  11656. case creditusage.FieldOperator:
  11657. return m.OldOperator(ctx)
  11658. }
  11659. return nil, fmt.Errorf("unknown CreditUsage field %s", name)
  11660. }
  11661. // SetField sets the value of a field with the given name. It returns an error if
  11662. // the field is not defined in the schema, or if the type mismatched the field
  11663. // type.
  11664. func (m *CreditUsageMutation) SetField(name string, value ent.Value) error {
  11665. switch name {
  11666. case creditusage.FieldCreatedAt:
  11667. v, ok := value.(time.Time)
  11668. if !ok {
  11669. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11670. }
  11671. m.SetCreatedAt(v)
  11672. return nil
  11673. case creditusage.FieldUpdatedAt:
  11674. v, ok := value.(time.Time)
  11675. if !ok {
  11676. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11677. }
  11678. m.SetUpdatedAt(v)
  11679. return nil
  11680. case creditusage.FieldDeletedAt:
  11681. v, ok := value.(time.Time)
  11682. if !ok {
  11683. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11684. }
  11685. m.SetDeletedAt(v)
  11686. return nil
  11687. case creditusage.FieldUserID:
  11688. v, ok := value.(string)
  11689. if !ok {
  11690. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11691. }
  11692. m.SetUserID(v)
  11693. return nil
  11694. case creditusage.FieldNumber:
  11695. v, ok := value.(float32)
  11696. if !ok {
  11697. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11698. }
  11699. m.SetNumber(v)
  11700. return nil
  11701. case creditusage.FieldStatus:
  11702. v, ok := value.(int)
  11703. if !ok {
  11704. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11705. }
  11706. m.SetStatus(v)
  11707. return nil
  11708. case creditusage.FieldNtype:
  11709. v, ok := value.(int)
  11710. if !ok {
  11711. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11712. }
  11713. m.SetNtype(v)
  11714. return nil
  11715. case creditusage.FieldTable:
  11716. v, ok := value.(string)
  11717. if !ok {
  11718. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11719. }
  11720. m.SetTable(v)
  11721. return nil
  11722. case creditusage.FieldOrganizationID:
  11723. v, ok := value.(uint64)
  11724. if !ok {
  11725. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11726. }
  11727. m.SetOrganizationID(v)
  11728. return nil
  11729. case creditusage.FieldNid:
  11730. v, ok := value.(uint64)
  11731. if !ok {
  11732. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11733. }
  11734. m.SetNid(v)
  11735. return nil
  11736. case creditusage.FieldReason:
  11737. v, ok := value.(string)
  11738. if !ok {
  11739. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11740. }
  11741. m.SetReason(v)
  11742. return nil
  11743. case creditusage.FieldOperator:
  11744. v, ok := value.(string)
  11745. if !ok {
  11746. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11747. }
  11748. m.SetOperator(v)
  11749. return nil
  11750. }
  11751. return fmt.Errorf("unknown CreditUsage field %s", name)
  11752. }
  11753. // AddedFields returns all numeric fields that were incremented/decremented during
  11754. // this mutation.
  11755. func (m *CreditUsageMutation) AddedFields() []string {
  11756. var fields []string
  11757. if m.addnumber != nil {
  11758. fields = append(fields, creditusage.FieldNumber)
  11759. }
  11760. if m.addstatus != nil {
  11761. fields = append(fields, creditusage.FieldStatus)
  11762. }
  11763. if m.addntype != nil {
  11764. fields = append(fields, creditusage.FieldNtype)
  11765. }
  11766. if m.addorganization_id != nil {
  11767. fields = append(fields, creditusage.FieldOrganizationID)
  11768. }
  11769. if m.addnid != nil {
  11770. fields = append(fields, creditusage.FieldNid)
  11771. }
  11772. return fields
  11773. }
  11774. // AddedField returns the numeric value that was incremented/decremented on a field
  11775. // with the given name. The second boolean return value indicates that this field
  11776. // was not set, or was not defined in the schema.
  11777. func (m *CreditUsageMutation) AddedField(name string) (ent.Value, bool) {
  11778. switch name {
  11779. case creditusage.FieldNumber:
  11780. return m.AddedNumber()
  11781. case creditusage.FieldStatus:
  11782. return m.AddedStatus()
  11783. case creditusage.FieldNtype:
  11784. return m.AddedNtype()
  11785. case creditusage.FieldOrganizationID:
  11786. return m.AddedOrganizationID()
  11787. case creditusage.FieldNid:
  11788. return m.AddedNid()
  11789. }
  11790. return nil, false
  11791. }
  11792. // AddField adds the value to the field with the given name. It returns an error if
  11793. // the field is not defined in the schema, or if the type mismatched the field
  11794. // type.
  11795. func (m *CreditUsageMutation) AddField(name string, value ent.Value) error {
  11796. switch name {
  11797. case creditusage.FieldNumber:
  11798. v, ok := value.(float32)
  11799. if !ok {
  11800. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11801. }
  11802. m.AddNumber(v)
  11803. return nil
  11804. case creditusage.FieldStatus:
  11805. v, ok := value.(int)
  11806. if !ok {
  11807. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11808. }
  11809. m.AddStatus(v)
  11810. return nil
  11811. case creditusage.FieldNtype:
  11812. v, ok := value.(int)
  11813. if !ok {
  11814. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11815. }
  11816. m.AddNtype(v)
  11817. return nil
  11818. case creditusage.FieldOrganizationID:
  11819. v, ok := value.(int64)
  11820. if !ok {
  11821. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11822. }
  11823. m.AddOrganizationID(v)
  11824. return nil
  11825. case creditusage.FieldNid:
  11826. v, ok := value.(int64)
  11827. if !ok {
  11828. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11829. }
  11830. m.AddNid(v)
  11831. return nil
  11832. }
  11833. return fmt.Errorf("unknown CreditUsage numeric field %s", name)
  11834. }
  11835. // ClearedFields returns all nullable fields that were cleared during this
  11836. // mutation.
  11837. func (m *CreditUsageMutation) ClearedFields() []string {
  11838. var fields []string
  11839. if m.FieldCleared(creditusage.FieldDeletedAt) {
  11840. fields = append(fields, creditusage.FieldDeletedAt)
  11841. }
  11842. if m.FieldCleared(creditusage.FieldUserID) {
  11843. fields = append(fields, creditusage.FieldUserID)
  11844. }
  11845. if m.FieldCleared(creditusage.FieldStatus) {
  11846. fields = append(fields, creditusage.FieldStatus)
  11847. }
  11848. if m.FieldCleared(creditusage.FieldOrganizationID) {
  11849. fields = append(fields, creditusage.FieldOrganizationID)
  11850. }
  11851. return fields
  11852. }
  11853. // FieldCleared returns a boolean indicating if a field with the given name was
  11854. // cleared in this mutation.
  11855. func (m *CreditUsageMutation) FieldCleared(name string) bool {
  11856. _, ok := m.clearedFields[name]
  11857. return ok
  11858. }
  11859. // ClearField clears the value of the field with the given name. It returns an
  11860. // error if the field is not defined in the schema.
  11861. func (m *CreditUsageMutation) ClearField(name string) error {
  11862. switch name {
  11863. case creditusage.FieldDeletedAt:
  11864. m.ClearDeletedAt()
  11865. return nil
  11866. case creditusage.FieldUserID:
  11867. m.ClearUserID()
  11868. return nil
  11869. case creditusage.FieldStatus:
  11870. m.ClearStatus()
  11871. return nil
  11872. case creditusage.FieldOrganizationID:
  11873. m.ClearOrganizationID()
  11874. return nil
  11875. }
  11876. return fmt.Errorf("unknown CreditUsage nullable field %s", name)
  11877. }
  11878. // ResetField resets all changes in the mutation for the field with the given name.
  11879. // It returns an error if the field is not defined in the schema.
  11880. func (m *CreditUsageMutation) ResetField(name string) error {
  11881. switch name {
  11882. case creditusage.FieldCreatedAt:
  11883. m.ResetCreatedAt()
  11884. return nil
  11885. case creditusage.FieldUpdatedAt:
  11886. m.ResetUpdatedAt()
  11887. return nil
  11888. case creditusage.FieldDeletedAt:
  11889. m.ResetDeletedAt()
  11890. return nil
  11891. case creditusage.FieldUserID:
  11892. m.ResetUserID()
  11893. return nil
  11894. case creditusage.FieldNumber:
  11895. m.ResetNumber()
  11896. return nil
  11897. case creditusage.FieldStatus:
  11898. m.ResetStatus()
  11899. return nil
  11900. case creditusage.FieldNtype:
  11901. m.ResetNtype()
  11902. return nil
  11903. case creditusage.FieldTable:
  11904. m.ResetTable()
  11905. return nil
  11906. case creditusage.FieldOrganizationID:
  11907. m.ResetOrganizationID()
  11908. return nil
  11909. case creditusage.FieldNid:
  11910. m.ResetNid()
  11911. return nil
  11912. case creditusage.FieldReason:
  11913. m.ResetReason()
  11914. return nil
  11915. case creditusage.FieldOperator:
  11916. m.ResetOperator()
  11917. return nil
  11918. }
  11919. return fmt.Errorf("unknown CreditUsage field %s", name)
  11920. }
  11921. // AddedEdges returns all edge names that were set/added in this mutation.
  11922. func (m *CreditUsageMutation) AddedEdges() []string {
  11923. edges := make([]string, 0, 0)
  11924. return edges
  11925. }
  11926. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  11927. // name in this mutation.
  11928. func (m *CreditUsageMutation) AddedIDs(name string) []ent.Value {
  11929. return nil
  11930. }
  11931. // RemovedEdges returns all edge names that were removed in this mutation.
  11932. func (m *CreditUsageMutation) RemovedEdges() []string {
  11933. edges := make([]string, 0, 0)
  11934. return edges
  11935. }
  11936. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  11937. // the given name in this mutation.
  11938. func (m *CreditUsageMutation) RemovedIDs(name string) []ent.Value {
  11939. return nil
  11940. }
  11941. // ClearedEdges returns all edge names that were cleared in this mutation.
  11942. func (m *CreditUsageMutation) ClearedEdges() []string {
  11943. edges := make([]string, 0, 0)
  11944. return edges
  11945. }
  11946. // EdgeCleared returns a boolean which indicates if the edge with the given name
  11947. // was cleared in this mutation.
  11948. func (m *CreditUsageMutation) EdgeCleared(name string) bool {
  11949. return false
  11950. }
  11951. // ClearEdge clears the value of the edge with the given name. It returns an error
  11952. // if that edge is not defined in the schema.
  11953. func (m *CreditUsageMutation) ClearEdge(name string) error {
  11954. return fmt.Errorf("unknown CreditUsage unique edge %s", name)
  11955. }
  11956. // ResetEdge resets all changes to the edge with the given name in this mutation.
  11957. // It returns an error if the edge is not defined in the schema.
  11958. func (m *CreditUsageMutation) ResetEdge(name string) error {
  11959. return fmt.Errorf("unknown CreditUsage edge %s", name)
  11960. }
  11961. // EmployeeMutation represents an operation that mutates the Employee nodes in the graph.
  11962. type EmployeeMutation struct {
  11963. config
  11964. op Op
  11965. typ string
  11966. id *uint64
  11967. created_at *time.Time
  11968. updated_at *time.Time
  11969. deleted_at *time.Time
  11970. title *string
  11971. avatar *string
  11972. tags *string
  11973. hire_count *int
  11974. addhire_count *int
  11975. service_count *int
  11976. addservice_count *int
  11977. achievement_count *int
  11978. addachievement_count *int
  11979. intro *string
  11980. estimate *string
  11981. skill *string
  11982. ability_type *string
  11983. scene *string
  11984. switch_in *string
  11985. video_url *string
  11986. organization_id *uint64
  11987. addorganization_id *int64
  11988. category_id *uint64
  11989. addcategory_id *int64
  11990. api_base *string
  11991. api_key *string
  11992. ai_info *string
  11993. is_vip *int
  11994. addis_vip *int
  11995. chat_url *string
  11996. clearedFields map[string]struct{}
  11997. em_work_experiences map[uint64]struct{}
  11998. removedem_work_experiences map[uint64]struct{}
  11999. clearedem_work_experiences bool
  12000. em_tutorial map[uint64]struct{}
  12001. removedem_tutorial map[uint64]struct{}
  12002. clearedem_tutorial bool
  12003. done bool
  12004. oldValue func(context.Context) (*Employee, error)
  12005. predicates []predicate.Employee
  12006. }
  12007. var _ ent.Mutation = (*EmployeeMutation)(nil)
  12008. // employeeOption allows management of the mutation configuration using functional options.
  12009. type employeeOption func(*EmployeeMutation)
  12010. // newEmployeeMutation creates new mutation for the Employee entity.
  12011. func newEmployeeMutation(c config, op Op, opts ...employeeOption) *EmployeeMutation {
  12012. m := &EmployeeMutation{
  12013. config: c,
  12014. op: op,
  12015. typ: TypeEmployee,
  12016. clearedFields: make(map[string]struct{}),
  12017. }
  12018. for _, opt := range opts {
  12019. opt(m)
  12020. }
  12021. return m
  12022. }
  12023. // withEmployeeID sets the ID field of the mutation.
  12024. func withEmployeeID(id uint64) employeeOption {
  12025. return func(m *EmployeeMutation) {
  12026. var (
  12027. err error
  12028. once sync.Once
  12029. value *Employee
  12030. )
  12031. m.oldValue = func(ctx context.Context) (*Employee, error) {
  12032. once.Do(func() {
  12033. if m.done {
  12034. err = errors.New("querying old values post mutation is not allowed")
  12035. } else {
  12036. value, err = m.Client().Employee.Get(ctx, id)
  12037. }
  12038. })
  12039. return value, err
  12040. }
  12041. m.id = &id
  12042. }
  12043. }
  12044. // withEmployee sets the old Employee of the mutation.
  12045. func withEmployee(node *Employee) employeeOption {
  12046. return func(m *EmployeeMutation) {
  12047. m.oldValue = func(context.Context) (*Employee, error) {
  12048. return node, nil
  12049. }
  12050. m.id = &node.ID
  12051. }
  12052. }
  12053. // Client returns a new `ent.Client` from the mutation. If the mutation was
  12054. // executed in a transaction (ent.Tx), a transactional client is returned.
  12055. func (m EmployeeMutation) Client() *Client {
  12056. client := &Client{config: m.config}
  12057. client.init()
  12058. return client
  12059. }
  12060. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  12061. // it returns an error otherwise.
  12062. func (m EmployeeMutation) Tx() (*Tx, error) {
  12063. if _, ok := m.driver.(*txDriver); !ok {
  12064. return nil, errors.New("ent: mutation is not running in a transaction")
  12065. }
  12066. tx := &Tx{config: m.config}
  12067. tx.init()
  12068. return tx, nil
  12069. }
  12070. // SetID sets the value of the id field. Note that this
  12071. // operation is only accepted on creation of Employee entities.
  12072. func (m *EmployeeMutation) SetID(id uint64) {
  12073. m.id = &id
  12074. }
  12075. // ID returns the ID value in the mutation. Note that the ID is only available
  12076. // if it was provided to the builder or after it was returned from the database.
  12077. func (m *EmployeeMutation) ID() (id uint64, exists bool) {
  12078. if m.id == nil {
  12079. return
  12080. }
  12081. return *m.id, true
  12082. }
  12083. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  12084. // That means, if the mutation is applied within a transaction with an isolation level such
  12085. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  12086. // or updated by the mutation.
  12087. func (m *EmployeeMutation) IDs(ctx context.Context) ([]uint64, error) {
  12088. switch {
  12089. case m.op.Is(OpUpdateOne | OpDeleteOne):
  12090. id, exists := m.ID()
  12091. if exists {
  12092. return []uint64{id}, nil
  12093. }
  12094. fallthrough
  12095. case m.op.Is(OpUpdate | OpDelete):
  12096. return m.Client().Employee.Query().Where(m.predicates...).IDs(ctx)
  12097. default:
  12098. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  12099. }
  12100. }
  12101. // SetCreatedAt sets the "created_at" field.
  12102. func (m *EmployeeMutation) SetCreatedAt(t time.Time) {
  12103. m.created_at = &t
  12104. }
  12105. // CreatedAt returns the value of the "created_at" field in the mutation.
  12106. func (m *EmployeeMutation) CreatedAt() (r time.Time, exists bool) {
  12107. v := m.created_at
  12108. if v == nil {
  12109. return
  12110. }
  12111. return *v, true
  12112. }
  12113. // OldCreatedAt returns the old "created_at" field's value of the Employee entity.
  12114. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12115. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12116. func (m *EmployeeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  12117. if !m.op.Is(OpUpdateOne) {
  12118. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  12119. }
  12120. if m.id == nil || m.oldValue == nil {
  12121. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  12122. }
  12123. oldValue, err := m.oldValue(ctx)
  12124. if err != nil {
  12125. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  12126. }
  12127. return oldValue.CreatedAt, nil
  12128. }
  12129. // ResetCreatedAt resets all changes to the "created_at" field.
  12130. func (m *EmployeeMutation) ResetCreatedAt() {
  12131. m.created_at = nil
  12132. }
  12133. // SetUpdatedAt sets the "updated_at" field.
  12134. func (m *EmployeeMutation) SetUpdatedAt(t time.Time) {
  12135. m.updated_at = &t
  12136. }
  12137. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  12138. func (m *EmployeeMutation) UpdatedAt() (r time.Time, exists bool) {
  12139. v := m.updated_at
  12140. if v == nil {
  12141. return
  12142. }
  12143. return *v, true
  12144. }
  12145. // OldUpdatedAt returns the old "updated_at" field's value of the Employee entity.
  12146. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12147. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12148. func (m *EmployeeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  12149. if !m.op.Is(OpUpdateOne) {
  12150. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  12151. }
  12152. if m.id == nil || m.oldValue == nil {
  12153. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  12154. }
  12155. oldValue, err := m.oldValue(ctx)
  12156. if err != nil {
  12157. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  12158. }
  12159. return oldValue.UpdatedAt, nil
  12160. }
  12161. // ResetUpdatedAt resets all changes to the "updated_at" field.
  12162. func (m *EmployeeMutation) ResetUpdatedAt() {
  12163. m.updated_at = nil
  12164. }
  12165. // SetDeletedAt sets the "deleted_at" field.
  12166. func (m *EmployeeMutation) SetDeletedAt(t time.Time) {
  12167. m.deleted_at = &t
  12168. }
  12169. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  12170. func (m *EmployeeMutation) DeletedAt() (r time.Time, exists bool) {
  12171. v := m.deleted_at
  12172. if v == nil {
  12173. return
  12174. }
  12175. return *v, true
  12176. }
  12177. // OldDeletedAt returns the old "deleted_at" field's value of the Employee entity.
  12178. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12179. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12180. func (m *EmployeeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  12181. if !m.op.Is(OpUpdateOne) {
  12182. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  12183. }
  12184. if m.id == nil || m.oldValue == nil {
  12185. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  12186. }
  12187. oldValue, err := m.oldValue(ctx)
  12188. if err != nil {
  12189. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  12190. }
  12191. return oldValue.DeletedAt, nil
  12192. }
  12193. // ClearDeletedAt clears the value of the "deleted_at" field.
  12194. func (m *EmployeeMutation) ClearDeletedAt() {
  12195. m.deleted_at = nil
  12196. m.clearedFields[employee.FieldDeletedAt] = struct{}{}
  12197. }
  12198. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  12199. func (m *EmployeeMutation) DeletedAtCleared() bool {
  12200. _, ok := m.clearedFields[employee.FieldDeletedAt]
  12201. return ok
  12202. }
  12203. // ResetDeletedAt resets all changes to the "deleted_at" field.
  12204. func (m *EmployeeMutation) ResetDeletedAt() {
  12205. m.deleted_at = nil
  12206. delete(m.clearedFields, employee.FieldDeletedAt)
  12207. }
  12208. // SetTitle sets the "title" field.
  12209. func (m *EmployeeMutation) SetTitle(s string) {
  12210. m.title = &s
  12211. }
  12212. // Title returns the value of the "title" field in the mutation.
  12213. func (m *EmployeeMutation) Title() (r string, exists bool) {
  12214. v := m.title
  12215. if v == nil {
  12216. return
  12217. }
  12218. return *v, true
  12219. }
  12220. // OldTitle returns the old "title" field's value of the Employee entity.
  12221. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12222. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12223. func (m *EmployeeMutation) OldTitle(ctx context.Context) (v string, err error) {
  12224. if !m.op.Is(OpUpdateOne) {
  12225. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  12226. }
  12227. if m.id == nil || m.oldValue == nil {
  12228. return v, errors.New("OldTitle requires an ID field in the mutation")
  12229. }
  12230. oldValue, err := m.oldValue(ctx)
  12231. if err != nil {
  12232. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  12233. }
  12234. return oldValue.Title, nil
  12235. }
  12236. // ResetTitle resets all changes to the "title" field.
  12237. func (m *EmployeeMutation) ResetTitle() {
  12238. m.title = nil
  12239. }
  12240. // SetAvatar sets the "avatar" field.
  12241. func (m *EmployeeMutation) SetAvatar(s string) {
  12242. m.avatar = &s
  12243. }
  12244. // Avatar returns the value of the "avatar" field in the mutation.
  12245. func (m *EmployeeMutation) Avatar() (r string, exists bool) {
  12246. v := m.avatar
  12247. if v == nil {
  12248. return
  12249. }
  12250. return *v, true
  12251. }
  12252. // OldAvatar returns the old "avatar" field's value of the Employee entity.
  12253. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12254. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12255. func (m *EmployeeMutation) OldAvatar(ctx context.Context) (v string, err error) {
  12256. if !m.op.Is(OpUpdateOne) {
  12257. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  12258. }
  12259. if m.id == nil || m.oldValue == nil {
  12260. return v, errors.New("OldAvatar requires an ID field in the mutation")
  12261. }
  12262. oldValue, err := m.oldValue(ctx)
  12263. if err != nil {
  12264. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  12265. }
  12266. return oldValue.Avatar, nil
  12267. }
  12268. // ResetAvatar resets all changes to the "avatar" field.
  12269. func (m *EmployeeMutation) ResetAvatar() {
  12270. m.avatar = nil
  12271. }
  12272. // SetTags sets the "tags" field.
  12273. func (m *EmployeeMutation) SetTags(s string) {
  12274. m.tags = &s
  12275. }
  12276. // Tags returns the value of the "tags" field in the mutation.
  12277. func (m *EmployeeMutation) Tags() (r string, exists bool) {
  12278. v := m.tags
  12279. if v == nil {
  12280. return
  12281. }
  12282. return *v, true
  12283. }
  12284. // OldTags returns the old "tags" field's value of the Employee entity.
  12285. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12286. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12287. func (m *EmployeeMutation) OldTags(ctx context.Context) (v string, err error) {
  12288. if !m.op.Is(OpUpdateOne) {
  12289. return v, errors.New("OldTags is only allowed on UpdateOne operations")
  12290. }
  12291. if m.id == nil || m.oldValue == nil {
  12292. return v, errors.New("OldTags requires an ID field in the mutation")
  12293. }
  12294. oldValue, err := m.oldValue(ctx)
  12295. if err != nil {
  12296. return v, fmt.Errorf("querying old value for OldTags: %w", err)
  12297. }
  12298. return oldValue.Tags, nil
  12299. }
  12300. // ResetTags resets all changes to the "tags" field.
  12301. func (m *EmployeeMutation) ResetTags() {
  12302. m.tags = nil
  12303. }
  12304. // SetHireCount sets the "hire_count" field.
  12305. func (m *EmployeeMutation) SetHireCount(i int) {
  12306. m.hire_count = &i
  12307. m.addhire_count = nil
  12308. }
  12309. // HireCount returns the value of the "hire_count" field in the mutation.
  12310. func (m *EmployeeMutation) HireCount() (r int, exists bool) {
  12311. v := m.hire_count
  12312. if v == nil {
  12313. return
  12314. }
  12315. return *v, true
  12316. }
  12317. // OldHireCount returns the old "hire_count" field's value of the Employee entity.
  12318. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12319. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12320. func (m *EmployeeMutation) OldHireCount(ctx context.Context) (v int, err error) {
  12321. if !m.op.Is(OpUpdateOne) {
  12322. return v, errors.New("OldHireCount is only allowed on UpdateOne operations")
  12323. }
  12324. if m.id == nil || m.oldValue == nil {
  12325. return v, errors.New("OldHireCount requires an ID field in the mutation")
  12326. }
  12327. oldValue, err := m.oldValue(ctx)
  12328. if err != nil {
  12329. return v, fmt.Errorf("querying old value for OldHireCount: %w", err)
  12330. }
  12331. return oldValue.HireCount, nil
  12332. }
  12333. // AddHireCount adds i to the "hire_count" field.
  12334. func (m *EmployeeMutation) AddHireCount(i int) {
  12335. if m.addhire_count != nil {
  12336. *m.addhire_count += i
  12337. } else {
  12338. m.addhire_count = &i
  12339. }
  12340. }
  12341. // AddedHireCount returns the value that was added to the "hire_count" field in this mutation.
  12342. func (m *EmployeeMutation) AddedHireCount() (r int, exists bool) {
  12343. v := m.addhire_count
  12344. if v == nil {
  12345. return
  12346. }
  12347. return *v, true
  12348. }
  12349. // ResetHireCount resets all changes to the "hire_count" field.
  12350. func (m *EmployeeMutation) ResetHireCount() {
  12351. m.hire_count = nil
  12352. m.addhire_count = nil
  12353. }
  12354. // SetServiceCount sets the "service_count" field.
  12355. func (m *EmployeeMutation) SetServiceCount(i int) {
  12356. m.service_count = &i
  12357. m.addservice_count = nil
  12358. }
  12359. // ServiceCount returns the value of the "service_count" field in the mutation.
  12360. func (m *EmployeeMutation) ServiceCount() (r int, exists bool) {
  12361. v := m.service_count
  12362. if v == nil {
  12363. return
  12364. }
  12365. return *v, true
  12366. }
  12367. // OldServiceCount returns the old "service_count" field's value of the Employee entity.
  12368. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12369. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12370. func (m *EmployeeMutation) OldServiceCount(ctx context.Context) (v int, err error) {
  12371. if !m.op.Is(OpUpdateOne) {
  12372. return v, errors.New("OldServiceCount is only allowed on UpdateOne operations")
  12373. }
  12374. if m.id == nil || m.oldValue == nil {
  12375. return v, errors.New("OldServiceCount requires an ID field in the mutation")
  12376. }
  12377. oldValue, err := m.oldValue(ctx)
  12378. if err != nil {
  12379. return v, fmt.Errorf("querying old value for OldServiceCount: %w", err)
  12380. }
  12381. return oldValue.ServiceCount, nil
  12382. }
  12383. // AddServiceCount adds i to the "service_count" field.
  12384. func (m *EmployeeMutation) AddServiceCount(i int) {
  12385. if m.addservice_count != nil {
  12386. *m.addservice_count += i
  12387. } else {
  12388. m.addservice_count = &i
  12389. }
  12390. }
  12391. // AddedServiceCount returns the value that was added to the "service_count" field in this mutation.
  12392. func (m *EmployeeMutation) AddedServiceCount() (r int, exists bool) {
  12393. v := m.addservice_count
  12394. if v == nil {
  12395. return
  12396. }
  12397. return *v, true
  12398. }
  12399. // ResetServiceCount resets all changes to the "service_count" field.
  12400. func (m *EmployeeMutation) ResetServiceCount() {
  12401. m.service_count = nil
  12402. m.addservice_count = nil
  12403. }
  12404. // SetAchievementCount sets the "achievement_count" field.
  12405. func (m *EmployeeMutation) SetAchievementCount(i int) {
  12406. m.achievement_count = &i
  12407. m.addachievement_count = nil
  12408. }
  12409. // AchievementCount returns the value of the "achievement_count" field in the mutation.
  12410. func (m *EmployeeMutation) AchievementCount() (r int, exists bool) {
  12411. v := m.achievement_count
  12412. if v == nil {
  12413. return
  12414. }
  12415. return *v, true
  12416. }
  12417. // OldAchievementCount returns the old "achievement_count" field's value of the Employee entity.
  12418. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12419. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12420. func (m *EmployeeMutation) OldAchievementCount(ctx context.Context) (v int, err error) {
  12421. if !m.op.Is(OpUpdateOne) {
  12422. return v, errors.New("OldAchievementCount is only allowed on UpdateOne operations")
  12423. }
  12424. if m.id == nil || m.oldValue == nil {
  12425. return v, errors.New("OldAchievementCount requires an ID field in the mutation")
  12426. }
  12427. oldValue, err := m.oldValue(ctx)
  12428. if err != nil {
  12429. return v, fmt.Errorf("querying old value for OldAchievementCount: %w", err)
  12430. }
  12431. return oldValue.AchievementCount, nil
  12432. }
  12433. // AddAchievementCount adds i to the "achievement_count" field.
  12434. func (m *EmployeeMutation) AddAchievementCount(i int) {
  12435. if m.addachievement_count != nil {
  12436. *m.addachievement_count += i
  12437. } else {
  12438. m.addachievement_count = &i
  12439. }
  12440. }
  12441. // AddedAchievementCount returns the value that was added to the "achievement_count" field in this mutation.
  12442. func (m *EmployeeMutation) AddedAchievementCount() (r int, exists bool) {
  12443. v := m.addachievement_count
  12444. if v == nil {
  12445. return
  12446. }
  12447. return *v, true
  12448. }
  12449. // ResetAchievementCount resets all changes to the "achievement_count" field.
  12450. func (m *EmployeeMutation) ResetAchievementCount() {
  12451. m.achievement_count = nil
  12452. m.addachievement_count = nil
  12453. }
  12454. // SetIntro sets the "intro" field.
  12455. func (m *EmployeeMutation) SetIntro(s string) {
  12456. m.intro = &s
  12457. }
  12458. // Intro returns the value of the "intro" field in the mutation.
  12459. func (m *EmployeeMutation) Intro() (r string, exists bool) {
  12460. v := m.intro
  12461. if v == nil {
  12462. return
  12463. }
  12464. return *v, true
  12465. }
  12466. // OldIntro returns the old "intro" field's value of the Employee entity.
  12467. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12468. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12469. func (m *EmployeeMutation) OldIntro(ctx context.Context) (v string, err error) {
  12470. if !m.op.Is(OpUpdateOne) {
  12471. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  12472. }
  12473. if m.id == nil || m.oldValue == nil {
  12474. return v, errors.New("OldIntro requires an ID field in the mutation")
  12475. }
  12476. oldValue, err := m.oldValue(ctx)
  12477. if err != nil {
  12478. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  12479. }
  12480. return oldValue.Intro, nil
  12481. }
  12482. // ResetIntro resets all changes to the "intro" field.
  12483. func (m *EmployeeMutation) ResetIntro() {
  12484. m.intro = nil
  12485. }
  12486. // SetEstimate sets the "estimate" field.
  12487. func (m *EmployeeMutation) SetEstimate(s string) {
  12488. m.estimate = &s
  12489. }
  12490. // Estimate returns the value of the "estimate" field in the mutation.
  12491. func (m *EmployeeMutation) Estimate() (r string, exists bool) {
  12492. v := m.estimate
  12493. if v == nil {
  12494. return
  12495. }
  12496. return *v, true
  12497. }
  12498. // OldEstimate returns the old "estimate" field's value of the Employee entity.
  12499. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12500. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12501. func (m *EmployeeMutation) OldEstimate(ctx context.Context) (v string, err error) {
  12502. if !m.op.Is(OpUpdateOne) {
  12503. return v, errors.New("OldEstimate is only allowed on UpdateOne operations")
  12504. }
  12505. if m.id == nil || m.oldValue == nil {
  12506. return v, errors.New("OldEstimate requires an ID field in the mutation")
  12507. }
  12508. oldValue, err := m.oldValue(ctx)
  12509. if err != nil {
  12510. return v, fmt.Errorf("querying old value for OldEstimate: %w", err)
  12511. }
  12512. return oldValue.Estimate, nil
  12513. }
  12514. // ResetEstimate resets all changes to the "estimate" field.
  12515. func (m *EmployeeMutation) ResetEstimate() {
  12516. m.estimate = nil
  12517. }
  12518. // SetSkill sets the "skill" field.
  12519. func (m *EmployeeMutation) SetSkill(s string) {
  12520. m.skill = &s
  12521. }
  12522. // Skill returns the value of the "skill" field in the mutation.
  12523. func (m *EmployeeMutation) Skill() (r string, exists bool) {
  12524. v := m.skill
  12525. if v == nil {
  12526. return
  12527. }
  12528. return *v, true
  12529. }
  12530. // OldSkill returns the old "skill" field's value of the Employee entity.
  12531. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12532. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12533. func (m *EmployeeMutation) OldSkill(ctx context.Context) (v string, err error) {
  12534. if !m.op.Is(OpUpdateOne) {
  12535. return v, errors.New("OldSkill is only allowed on UpdateOne operations")
  12536. }
  12537. if m.id == nil || m.oldValue == nil {
  12538. return v, errors.New("OldSkill requires an ID field in the mutation")
  12539. }
  12540. oldValue, err := m.oldValue(ctx)
  12541. if err != nil {
  12542. return v, fmt.Errorf("querying old value for OldSkill: %w", err)
  12543. }
  12544. return oldValue.Skill, nil
  12545. }
  12546. // ResetSkill resets all changes to the "skill" field.
  12547. func (m *EmployeeMutation) ResetSkill() {
  12548. m.skill = nil
  12549. }
  12550. // SetAbilityType sets the "ability_type" field.
  12551. func (m *EmployeeMutation) SetAbilityType(s string) {
  12552. m.ability_type = &s
  12553. }
  12554. // AbilityType returns the value of the "ability_type" field in the mutation.
  12555. func (m *EmployeeMutation) AbilityType() (r string, exists bool) {
  12556. v := m.ability_type
  12557. if v == nil {
  12558. return
  12559. }
  12560. return *v, true
  12561. }
  12562. // OldAbilityType returns the old "ability_type" field's value of the Employee entity.
  12563. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12564. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12565. func (m *EmployeeMutation) OldAbilityType(ctx context.Context) (v string, err error) {
  12566. if !m.op.Is(OpUpdateOne) {
  12567. return v, errors.New("OldAbilityType is only allowed on UpdateOne operations")
  12568. }
  12569. if m.id == nil || m.oldValue == nil {
  12570. return v, errors.New("OldAbilityType requires an ID field in the mutation")
  12571. }
  12572. oldValue, err := m.oldValue(ctx)
  12573. if err != nil {
  12574. return v, fmt.Errorf("querying old value for OldAbilityType: %w", err)
  12575. }
  12576. return oldValue.AbilityType, nil
  12577. }
  12578. // ResetAbilityType resets all changes to the "ability_type" field.
  12579. func (m *EmployeeMutation) ResetAbilityType() {
  12580. m.ability_type = nil
  12581. }
  12582. // SetScene sets the "scene" field.
  12583. func (m *EmployeeMutation) SetScene(s string) {
  12584. m.scene = &s
  12585. }
  12586. // Scene returns the value of the "scene" field in the mutation.
  12587. func (m *EmployeeMutation) Scene() (r string, exists bool) {
  12588. v := m.scene
  12589. if v == nil {
  12590. return
  12591. }
  12592. return *v, true
  12593. }
  12594. // OldScene returns the old "scene" field's value of the Employee entity.
  12595. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12596. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12597. func (m *EmployeeMutation) OldScene(ctx context.Context) (v string, err error) {
  12598. if !m.op.Is(OpUpdateOne) {
  12599. return v, errors.New("OldScene is only allowed on UpdateOne operations")
  12600. }
  12601. if m.id == nil || m.oldValue == nil {
  12602. return v, errors.New("OldScene requires an ID field in the mutation")
  12603. }
  12604. oldValue, err := m.oldValue(ctx)
  12605. if err != nil {
  12606. return v, fmt.Errorf("querying old value for OldScene: %w", err)
  12607. }
  12608. return oldValue.Scene, nil
  12609. }
  12610. // ResetScene resets all changes to the "scene" field.
  12611. func (m *EmployeeMutation) ResetScene() {
  12612. m.scene = nil
  12613. }
  12614. // SetSwitchIn sets the "switch_in" field.
  12615. func (m *EmployeeMutation) SetSwitchIn(s string) {
  12616. m.switch_in = &s
  12617. }
  12618. // SwitchIn returns the value of the "switch_in" field in the mutation.
  12619. func (m *EmployeeMutation) SwitchIn() (r string, exists bool) {
  12620. v := m.switch_in
  12621. if v == nil {
  12622. return
  12623. }
  12624. return *v, true
  12625. }
  12626. // OldSwitchIn returns the old "switch_in" field's value of the Employee entity.
  12627. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12628. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12629. func (m *EmployeeMutation) OldSwitchIn(ctx context.Context) (v string, err error) {
  12630. if !m.op.Is(OpUpdateOne) {
  12631. return v, errors.New("OldSwitchIn is only allowed on UpdateOne operations")
  12632. }
  12633. if m.id == nil || m.oldValue == nil {
  12634. return v, errors.New("OldSwitchIn requires an ID field in the mutation")
  12635. }
  12636. oldValue, err := m.oldValue(ctx)
  12637. if err != nil {
  12638. return v, fmt.Errorf("querying old value for OldSwitchIn: %w", err)
  12639. }
  12640. return oldValue.SwitchIn, nil
  12641. }
  12642. // ResetSwitchIn resets all changes to the "switch_in" field.
  12643. func (m *EmployeeMutation) ResetSwitchIn() {
  12644. m.switch_in = nil
  12645. }
  12646. // SetVideoURL sets the "video_url" field.
  12647. func (m *EmployeeMutation) SetVideoURL(s string) {
  12648. m.video_url = &s
  12649. }
  12650. // VideoURL returns the value of the "video_url" field in the mutation.
  12651. func (m *EmployeeMutation) VideoURL() (r string, exists bool) {
  12652. v := m.video_url
  12653. if v == nil {
  12654. return
  12655. }
  12656. return *v, true
  12657. }
  12658. // OldVideoURL returns the old "video_url" field's value of the Employee entity.
  12659. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12660. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12661. func (m *EmployeeMutation) OldVideoURL(ctx context.Context) (v string, err error) {
  12662. if !m.op.Is(OpUpdateOne) {
  12663. return v, errors.New("OldVideoURL is only allowed on UpdateOne operations")
  12664. }
  12665. if m.id == nil || m.oldValue == nil {
  12666. return v, errors.New("OldVideoURL requires an ID field in the mutation")
  12667. }
  12668. oldValue, err := m.oldValue(ctx)
  12669. if err != nil {
  12670. return v, fmt.Errorf("querying old value for OldVideoURL: %w", err)
  12671. }
  12672. return oldValue.VideoURL, nil
  12673. }
  12674. // ResetVideoURL resets all changes to the "video_url" field.
  12675. func (m *EmployeeMutation) ResetVideoURL() {
  12676. m.video_url = nil
  12677. }
  12678. // SetOrganizationID sets the "organization_id" field.
  12679. func (m *EmployeeMutation) SetOrganizationID(u uint64) {
  12680. m.organization_id = &u
  12681. m.addorganization_id = nil
  12682. }
  12683. // OrganizationID returns the value of the "organization_id" field in the mutation.
  12684. func (m *EmployeeMutation) OrganizationID() (r uint64, exists bool) {
  12685. v := m.organization_id
  12686. if v == nil {
  12687. return
  12688. }
  12689. return *v, true
  12690. }
  12691. // OldOrganizationID returns the old "organization_id" field's value of the Employee entity.
  12692. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12693. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12694. func (m *EmployeeMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  12695. if !m.op.Is(OpUpdateOne) {
  12696. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  12697. }
  12698. if m.id == nil || m.oldValue == nil {
  12699. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  12700. }
  12701. oldValue, err := m.oldValue(ctx)
  12702. if err != nil {
  12703. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  12704. }
  12705. return oldValue.OrganizationID, nil
  12706. }
  12707. // AddOrganizationID adds u to the "organization_id" field.
  12708. func (m *EmployeeMutation) AddOrganizationID(u int64) {
  12709. if m.addorganization_id != nil {
  12710. *m.addorganization_id += u
  12711. } else {
  12712. m.addorganization_id = &u
  12713. }
  12714. }
  12715. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  12716. func (m *EmployeeMutation) AddedOrganizationID() (r int64, exists bool) {
  12717. v := m.addorganization_id
  12718. if v == nil {
  12719. return
  12720. }
  12721. return *v, true
  12722. }
  12723. // ResetOrganizationID resets all changes to the "organization_id" field.
  12724. func (m *EmployeeMutation) ResetOrganizationID() {
  12725. m.organization_id = nil
  12726. m.addorganization_id = nil
  12727. }
  12728. // SetCategoryID sets the "category_id" field.
  12729. func (m *EmployeeMutation) SetCategoryID(u uint64) {
  12730. m.category_id = &u
  12731. m.addcategory_id = nil
  12732. }
  12733. // CategoryID returns the value of the "category_id" field in the mutation.
  12734. func (m *EmployeeMutation) CategoryID() (r uint64, exists bool) {
  12735. v := m.category_id
  12736. if v == nil {
  12737. return
  12738. }
  12739. return *v, true
  12740. }
  12741. // OldCategoryID returns the old "category_id" field's value of the Employee entity.
  12742. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12743. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12744. func (m *EmployeeMutation) OldCategoryID(ctx context.Context) (v uint64, err error) {
  12745. if !m.op.Is(OpUpdateOne) {
  12746. return v, errors.New("OldCategoryID is only allowed on UpdateOne operations")
  12747. }
  12748. if m.id == nil || m.oldValue == nil {
  12749. return v, errors.New("OldCategoryID requires an ID field in the mutation")
  12750. }
  12751. oldValue, err := m.oldValue(ctx)
  12752. if err != nil {
  12753. return v, fmt.Errorf("querying old value for OldCategoryID: %w", err)
  12754. }
  12755. return oldValue.CategoryID, nil
  12756. }
  12757. // AddCategoryID adds u to the "category_id" field.
  12758. func (m *EmployeeMutation) AddCategoryID(u int64) {
  12759. if m.addcategory_id != nil {
  12760. *m.addcategory_id += u
  12761. } else {
  12762. m.addcategory_id = &u
  12763. }
  12764. }
  12765. // AddedCategoryID returns the value that was added to the "category_id" field in this mutation.
  12766. func (m *EmployeeMutation) AddedCategoryID() (r int64, exists bool) {
  12767. v := m.addcategory_id
  12768. if v == nil {
  12769. return
  12770. }
  12771. return *v, true
  12772. }
  12773. // ResetCategoryID resets all changes to the "category_id" field.
  12774. func (m *EmployeeMutation) ResetCategoryID() {
  12775. m.category_id = nil
  12776. m.addcategory_id = nil
  12777. }
  12778. // SetAPIBase sets the "api_base" field.
  12779. func (m *EmployeeMutation) SetAPIBase(s string) {
  12780. m.api_base = &s
  12781. }
  12782. // APIBase returns the value of the "api_base" field in the mutation.
  12783. func (m *EmployeeMutation) APIBase() (r string, exists bool) {
  12784. v := m.api_base
  12785. if v == nil {
  12786. return
  12787. }
  12788. return *v, true
  12789. }
  12790. // OldAPIBase returns the old "api_base" field's value of the Employee entity.
  12791. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12792. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12793. func (m *EmployeeMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  12794. if !m.op.Is(OpUpdateOne) {
  12795. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  12796. }
  12797. if m.id == nil || m.oldValue == nil {
  12798. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  12799. }
  12800. oldValue, err := m.oldValue(ctx)
  12801. if err != nil {
  12802. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  12803. }
  12804. return oldValue.APIBase, nil
  12805. }
  12806. // ResetAPIBase resets all changes to the "api_base" field.
  12807. func (m *EmployeeMutation) ResetAPIBase() {
  12808. m.api_base = nil
  12809. }
  12810. // SetAPIKey sets the "api_key" field.
  12811. func (m *EmployeeMutation) SetAPIKey(s string) {
  12812. m.api_key = &s
  12813. }
  12814. // APIKey returns the value of the "api_key" field in the mutation.
  12815. func (m *EmployeeMutation) APIKey() (r string, exists bool) {
  12816. v := m.api_key
  12817. if v == nil {
  12818. return
  12819. }
  12820. return *v, true
  12821. }
  12822. // OldAPIKey returns the old "api_key" field's value of the Employee entity.
  12823. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12824. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12825. func (m *EmployeeMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  12826. if !m.op.Is(OpUpdateOne) {
  12827. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  12828. }
  12829. if m.id == nil || m.oldValue == nil {
  12830. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  12831. }
  12832. oldValue, err := m.oldValue(ctx)
  12833. if err != nil {
  12834. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  12835. }
  12836. return oldValue.APIKey, nil
  12837. }
  12838. // ResetAPIKey resets all changes to the "api_key" field.
  12839. func (m *EmployeeMutation) ResetAPIKey() {
  12840. m.api_key = nil
  12841. }
  12842. // SetAiInfo sets the "ai_info" field.
  12843. func (m *EmployeeMutation) SetAiInfo(s string) {
  12844. m.ai_info = &s
  12845. }
  12846. // AiInfo returns the value of the "ai_info" field in the mutation.
  12847. func (m *EmployeeMutation) AiInfo() (r string, exists bool) {
  12848. v := m.ai_info
  12849. if v == nil {
  12850. return
  12851. }
  12852. return *v, true
  12853. }
  12854. // OldAiInfo returns the old "ai_info" field's value of the Employee entity.
  12855. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12856. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12857. func (m *EmployeeMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  12858. if !m.op.Is(OpUpdateOne) {
  12859. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  12860. }
  12861. if m.id == nil || m.oldValue == nil {
  12862. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  12863. }
  12864. oldValue, err := m.oldValue(ctx)
  12865. if err != nil {
  12866. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  12867. }
  12868. return oldValue.AiInfo, nil
  12869. }
  12870. // ClearAiInfo clears the value of the "ai_info" field.
  12871. func (m *EmployeeMutation) ClearAiInfo() {
  12872. m.ai_info = nil
  12873. m.clearedFields[employee.FieldAiInfo] = struct{}{}
  12874. }
  12875. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  12876. func (m *EmployeeMutation) AiInfoCleared() bool {
  12877. _, ok := m.clearedFields[employee.FieldAiInfo]
  12878. return ok
  12879. }
  12880. // ResetAiInfo resets all changes to the "ai_info" field.
  12881. func (m *EmployeeMutation) ResetAiInfo() {
  12882. m.ai_info = nil
  12883. delete(m.clearedFields, employee.FieldAiInfo)
  12884. }
  12885. // SetIsVip sets the "is_vip" field.
  12886. func (m *EmployeeMutation) SetIsVip(i int) {
  12887. m.is_vip = &i
  12888. m.addis_vip = nil
  12889. }
  12890. // IsVip returns the value of the "is_vip" field in the mutation.
  12891. func (m *EmployeeMutation) IsVip() (r int, exists bool) {
  12892. v := m.is_vip
  12893. if v == nil {
  12894. return
  12895. }
  12896. return *v, true
  12897. }
  12898. // OldIsVip returns the old "is_vip" field's value of the Employee entity.
  12899. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12900. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12901. func (m *EmployeeMutation) OldIsVip(ctx context.Context) (v int, err error) {
  12902. if !m.op.Is(OpUpdateOne) {
  12903. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  12904. }
  12905. if m.id == nil || m.oldValue == nil {
  12906. return v, errors.New("OldIsVip requires an ID field in the mutation")
  12907. }
  12908. oldValue, err := m.oldValue(ctx)
  12909. if err != nil {
  12910. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  12911. }
  12912. return oldValue.IsVip, nil
  12913. }
  12914. // AddIsVip adds i to the "is_vip" field.
  12915. func (m *EmployeeMutation) AddIsVip(i int) {
  12916. if m.addis_vip != nil {
  12917. *m.addis_vip += i
  12918. } else {
  12919. m.addis_vip = &i
  12920. }
  12921. }
  12922. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  12923. func (m *EmployeeMutation) AddedIsVip() (r int, exists bool) {
  12924. v := m.addis_vip
  12925. if v == nil {
  12926. return
  12927. }
  12928. return *v, true
  12929. }
  12930. // ResetIsVip resets all changes to the "is_vip" field.
  12931. func (m *EmployeeMutation) ResetIsVip() {
  12932. m.is_vip = nil
  12933. m.addis_vip = nil
  12934. }
  12935. // SetChatURL sets the "chat_url" field.
  12936. func (m *EmployeeMutation) SetChatURL(s string) {
  12937. m.chat_url = &s
  12938. }
  12939. // ChatURL returns the value of the "chat_url" field in the mutation.
  12940. func (m *EmployeeMutation) ChatURL() (r string, exists bool) {
  12941. v := m.chat_url
  12942. if v == nil {
  12943. return
  12944. }
  12945. return *v, true
  12946. }
  12947. // OldChatURL returns the old "chat_url" field's value of the Employee entity.
  12948. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12949. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12950. func (m *EmployeeMutation) OldChatURL(ctx context.Context) (v string, err error) {
  12951. if !m.op.Is(OpUpdateOne) {
  12952. return v, errors.New("OldChatURL is only allowed on UpdateOne operations")
  12953. }
  12954. if m.id == nil || m.oldValue == nil {
  12955. return v, errors.New("OldChatURL requires an ID field in the mutation")
  12956. }
  12957. oldValue, err := m.oldValue(ctx)
  12958. if err != nil {
  12959. return v, fmt.Errorf("querying old value for OldChatURL: %w", err)
  12960. }
  12961. return oldValue.ChatURL, nil
  12962. }
  12963. // ResetChatURL resets all changes to the "chat_url" field.
  12964. func (m *EmployeeMutation) ResetChatURL() {
  12965. m.chat_url = nil
  12966. }
  12967. // AddEmWorkExperienceIDs adds the "em_work_experiences" edge to the WorkExperience entity by ids.
  12968. func (m *EmployeeMutation) AddEmWorkExperienceIDs(ids ...uint64) {
  12969. if m.em_work_experiences == nil {
  12970. m.em_work_experiences = make(map[uint64]struct{})
  12971. }
  12972. for i := range ids {
  12973. m.em_work_experiences[ids[i]] = struct{}{}
  12974. }
  12975. }
  12976. // ClearEmWorkExperiences clears the "em_work_experiences" edge to the WorkExperience entity.
  12977. func (m *EmployeeMutation) ClearEmWorkExperiences() {
  12978. m.clearedem_work_experiences = true
  12979. }
  12980. // EmWorkExperiencesCleared reports if the "em_work_experiences" edge to the WorkExperience entity was cleared.
  12981. func (m *EmployeeMutation) EmWorkExperiencesCleared() bool {
  12982. return m.clearedem_work_experiences
  12983. }
  12984. // RemoveEmWorkExperienceIDs removes the "em_work_experiences" edge to the WorkExperience entity by IDs.
  12985. func (m *EmployeeMutation) RemoveEmWorkExperienceIDs(ids ...uint64) {
  12986. if m.removedem_work_experiences == nil {
  12987. m.removedem_work_experiences = make(map[uint64]struct{})
  12988. }
  12989. for i := range ids {
  12990. delete(m.em_work_experiences, ids[i])
  12991. m.removedem_work_experiences[ids[i]] = struct{}{}
  12992. }
  12993. }
  12994. // RemovedEmWorkExperiences returns the removed IDs of the "em_work_experiences" edge to the WorkExperience entity.
  12995. func (m *EmployeeMutation) RemovedEmWorkExperiencesIDs() (ids []uint64) {
  12996. for id := range m.removedem_work_experiences {
  12997. ids = append(ids, id)
  12998. }
  12999. return
  13000. }
  13001. // EmWorkExperiencesIDs returns the "em_work_experiences" edge IDs in the mutation.
  13002. func (m *EmployeeMutation) EmWorkExperiencesIDs() (ids []uint64) {
  13003. for id := range m.em_work_experiences {
  13004. ids = append(ids, id)
  13005. }
  13006. return
  13007. }
  13008. // ResetEmWorkExperiences resets all changes to the "em_work_experiences" edge.
  13009. func (m *EmployeeMutation) ResetEmWorkExperiences() {
  13010. m.em_work_experiences = nil
  13011. m.clearedem_work_experiences = false
  13012. m.removedem_work_experiences = nil
  13013. }
  13014. // AddEmTutorialIDs adds the "em_tutorial" edge to the Tutorial entity by ids.
  13015. func (m *EmployeeMutation) AddEmTutorialIDs(ids ...uint64) {
  13016. if m.em_tutorial == nil {
  13017. m.em_tutorial = make(map[uint64]struct{})
  13018. }
  13019. for i := range ids {
  13020. m.em_tutorial[ids[i]] = struct{}{}
  13021. }
  13022. }
  13023. // ClearEmTutorial clears the "em_tutorial" edge to the Tutorial entity.
  13024. func (m *EmployeeMutation) ClearEmTutorial() {
  13025. m.clearedem_tutorial = true
  13026. }
  13027. // EmTutorialCleared reports if the "em_tutorial" edge to the Tutorial entity was cleared.
  13028. func (m *EmployeeMutation) EmTutorialCleared() bool {
  13029. return m.clearedem_tutorial
  13030. }
  13031. // RemoveEmTutorialIDs removes the "em_tutorial" edge to the Tutorial entity by IDs.
  13032. func (m *EmployeeMutation) RemoveEmTutorialIDs(ids ...uint64) {
  13033. if m.removedem_tutorial == nil {
  13034. m.removedem_tutorial = make(map[uint64]struct{})
  13035. }
  13036. for i := range ids {
  13037. delete(m.em_tutorial, ids[i])
  13038. m.removedem_tutorial[ids[i]] = struct{}{}
  13039. }
  13040. }
  13041. // RemovedEmTutorial returns the removed IDs of the "em_tutorial" edge to the Tutorial entity.
  13042. func (m *EmployeeMutation) RemovedEmTutorialIDs() (ids []uint64) {
  13043. for id := range m.removedem_tutorial {
  13044. ids = append(ids, id)
  13045. }
  13046. return
  13047. }
  13048. // EmTutorialIDs returns the "em_tutorial" edge IDs in the mutation.
  13049. func (m *EmployeeMutation) EmTutorialIDs() (ids []uint64) {
  13050. for id := range m.em_tutorial {
  13051. ids = append(ids, id)
  13052. }
  13053. return
  13054. }
  13055. // ResetEmTutorial resets all changes to the "em_tutorial" edge.
  13056. func (m *EmployeeMutation) ResetEmTutorial() {
  13057. m.em_tutorial = nil
  13058. m.clearedem_tutorial = false
  13059. m.removedem_tutorial = nil
  13060. }
  13061. // Where appends a list predicates to the EmployeeMutation builder.
  13062. func (m *EmployeeMutation) Where(ps ...predicate.Employee) {
  13063. m.predicates = append(m.predicates, ps...)
  13064. }
  13065. // WhereP appends storage-level predicates to the EmployeeMutation builder. Using this method,
  13066. // users can use type-assertion to append predicates that do not depend on any generated package.
  13067. func (m *EmployeeMutation) WhereP(ps ...func(*sql.Selector)) {
  13068. p := make([]predicate.Employee, len(ps))
  13069. for i := range ps {
  13070. p[i] = ps[i]
  13071. }
  13072. m.Where(p...)
  13073. }
  13074. // Op returns the operation name.
  13075. func (m *EmployeeMutation) Op() Op {
  13076. return m.op
  13077. }
  13078. // SetOp allows setting the mutation operation.
  13079. func (m *EmployeeMutation) SetOp(op Op) {
  13080. m.op = op
  13081. }
  13082. // Type returns the node type of this mutation (Employee).
  13083. func (m *EmployeeMutation) Type() string {
  13084. return m.typ
  13085. }
  13086. // Fields returns all fields that were changed during this mutation. Note that in
  13087. // order to get all numeric fields that were incremented/decremented, call
  13088. // AddedFields().
  13089. func (m *EmployeeMutation) Fields() []string {
  13090. fields := make([]string, 0, 23)
  13091. if m.created_at != nil {
  13092. fields = append(fields, employee.FieldCreatedAt)
  13093. }
  13094. if m.updated_at != nil {
  13095. fields = append(fields, employee.FieldUpdatedAt)
  13096. }
  13097. if m.deleted_at != nil {
  13098. fields = append(fields, employee.FieldDeletedAt)
  13099. }
  13100. if m.title != nil {
  13101. fields = append(fields, employee.FieldTitle)
  13102. }
  13103. if m.avatar != nil {
  13104. fields = append(fields, employee.FieldAvatar)
  13105. }
  13106. if m.tags != nil {
  13107. fields = append(fields, employee.FieldTags)
  13108. }
  13109. if m.hire_count != nil {
  13110. fields = append(fields, employee.FieldHireCount)
  13111. }
  13112. if m.service_count != nil {
  13113. fields = append(fields, employee.FieldServiceCount)
  13114. }
  13115. if m.achievement_count != nil {
  13116. fields = append(fields, employee.FieldAchievementCount)
  13117. }
  13118. if m.intro != nil {
  13119. fields = append(fields, employee.FieldIntro)
  13120. }
  13121. if m.estimate != nil {
  13122. fields = append(fields, employee.FieldEstimate)
  13123. }
  13124. if m.skill != nil {
  13125. fields = append(fields, employee.FieldSkill)
  13126. }
  13127. if m.ability_type != nil {
  13128. fields = append(fields, employee.FieldAbilityType)
  13129. }
  13130. if m.scene != nil {
  13131. fields = append(fields, employee.FieldScene)
  13132. }
  13133. if m.switch_in != nil {
  13134. fields = append(fields, employee.FieldSwitchIn)
  13135. }
  13136. if m.video_url != nil {
  13137. fields = append(fields, employee.FieldVideoURL)
  13138. }
  13139. if m.organization_id != nil {
  13140. fields = append(fields, employee.FieldOrganizationID)
  13141. }
  13142. if m.category_id != nil {
  13143. fields = append(fields, employee.FieldCategoryID)
  13144. }
  13145. if m.api_base != nil {
  13146. fields = append(fields, employee.FieldAPIBase)
  13147. }
  13148. if m.api_key != nil {
  13149. fields = append(fields, employee.FieldAPIKey)
  13150. }
  13151. if m.ai_info != nil {
  13152. fields = append(fields, employee.FieldAiInfo)
  13153. }
  13154. if m.is_vip != nil {
  13155. fields = append(fields, employee.FieldIsVip)
  13156. }
  13157. if m.chat_url != nil {
  13158. fields = append(fields, employee.FieldChatURL)
  13159. }
  13160. return fields
  13161. }
  13162. // Field returns the value of a field with the given name. The second boolean
  13163. // return value indicates that this field was not set, or was not defined in the
  13164. // schema.
  13165. func (m *EmployeeMutation) Field(name string) (ent.Value, bool) {
  13166. switch name {
  13167. case employee.FieldCreatedAt:
  13168. return m.CreatedAt()
  13169. case employee.FieldUpdatedAt:
  13170. return m.UpdatedAt()
  13171. case employee.FieldDeletedAt:
  13172. return m.DeletedAt()
  13173. case employee.FieldTitle:
  13174. return m.Title()
  13175. case employee.FieldAvatar:
  13176. return m.Avatar()
  13177. case employee.FieldTags:
  13178. return m.Tags()
  13179. case employee.FieldHireCount:
  13180. return m.HireCount()
  13181. case employee.FieldServiceCount:
  13182. return m.ServiceCount()
  13183. case employee.FieldAchievementCount:
  13184. return m.AchievementCount()
  13185. case employee.FieldIntro:
  13186. return m.Intro()
  13187. case employee.FieldEstimate:
  13188. return m.Estimate()
  13189. case employee.FieldSkill:
  13190. return m.Skill()
  13191. case employee.FieldAbilityType:
  13192. return m.AbilityType()
  13193. case employee.FieldScene:
  13194. return m.Scene()
  13195. case employee.FieldSwitchIn:
  13196. return m.SwitchIn()
  13197. case employee.FieldVideoURL:
  13198. return m.VideoURL()
  13199. case employee.FieldOrganizationID:
  13200. return m.OrganizationID()
  13201. case employee.FieldCategoryID:
  13202. return m.CategoryID()
  13203. case employee.FieldAPIBase:
  13204. return m.APIBase()
  13205. case employee.FieldAPIKey:
  13206. return m.APIKey()
  13207. case employee.FieldAiInfo:
  13208. return m.AiInfo()
  13209. case employee.FieldIsVip:
  13210. return m.IsVip()
  13211. case employee.FieldChatURL:
  13212. return m.ChatURL()
  13213. }
  13214. return nil, false
  13215. }
  13216. // OldField returns the old value of the field from the database. An error is
  13217. // returned if the mutation operation is not UpdateOne, or the query to the
  13218. // database failed.
  13219. func (m *EmployeeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  13220. switch name {
  13221. case employee.FieldCreatedAt:
  13222. return m.OldCreatedAt(ctx)
  13223. case employee.FieldUpdatedAt:
  13224. return m.OldUpdatedAt(ctx)
  13225. case employee.FieldDeletedAt:
  13226. return m.OldDeletedAt(ctx)
  13227. case employee.FieldTitle:
  13228. return m.OldTitle(ctx)
  13229. case employee.FieldAvatar:
  13230. return m.OldAvatar(ctx)
  13231. case employee.FieldTags:
  13232. return m.OldTags(ctx)
  13233. case employee.FieldHireCount:
  13234. return m.OldHireCount(ctx)
  13235. case employee.FieldServiceCount:
  13236. return m.OldServiceCount(ctx)
  13237. case employee.FieldAchievementCount:
  13238. return m.OldAchievementCount(ctx)
  13239. case employee.FieldIntro:
  13240. return m.OldIntro(ctx)
  13241. case employee.FieldEstimate:
  13242. return m.OldEstimate(ctx)
  13243. case employee.FieldSkill:
  13244. return m.OldSkill(ctx)
  13245. case employee.FieldAbilityType:
  13246. return m.OldAbilityType(ctx)
  13247. case employee.FieldScene:
  13248. return m.OldScene(ctx)
  13249. case employee.FieldSwitchIn:
  13250. return m.OldSwitchIn(ctx)
  13251. case employee.FieldVideoURL:
  13252. return m.OldVideoURL(ctx)
  13253. case employee.FieldOrganizationID:
  13254. return m.OldOrganizationID(ctx)
  13255. case employee.FieldCategoryID:
  13256. return m.OldCategoryID(ctx)
  13257. case employee.FieldAPIBase:
  13258. return m.OldAPIBase(ctx)
  13259. case employee.FieldAPIKey:
  13260. return m.OldAPIKey(ctx)
  13261. case employee.FieldAiInfo:
  13262. return m.OldAiInfo(ctx)
  13263. case employee.FieldIsVip:
  13264. return m.OldIsVip(ctx)
  13265. case employee.FieldChatURL:
  13266. return m.OldChatURL(ctx)
  13267. }
  13268. return nil, fmt.Errorf("unknown Employee field %s", name)
  13269. }
  13270. // SetField sets the value of a field with the given name. It returns an error if
  13271. // the field is not defined in the schema, or if the type mismatched the field
  13272. // type.
  13273. func (m *EmployeeMutation) SetField(name string, value ent.Value) error {
  13274. switch name {
  13275. case employee.FieldCreatedAt:
  13276. v, ok := value.(time.Time)
  13277. if !ok {
  13278. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13279. }
  13280. m.SetCreatedAt(v)
  13281. return nil
  13282. case employee.FieldUpdatedAt:
  13283. v, ok := value.(time.Time)
  13284. if !ok {
  13285. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13286. }
  13287. m.SetUpdatedAt(v)
  13288. return nil
  13289. case employee.FieldDeletedAt:
  13290. v, ok := value.(time.Time)
  13291. if !ok {
  13292. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13293. }
  13294. m.SetDeletedAt(v)
  13295. return nil
  13296. case employee.FieldTitle:
  13297. v, ok := value.(string)
  13298. if !ok {
  13299. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13300. }
  13301. m.SetTitle(v)
  13302. return nil
  13303. case employee.FieldAvatar:
  13304. v, ok := value.(string)
  13305. if !ok {
  13306. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13307. }
  13308. m.SetAvatar(v)
  13309. return nil
  13310. case employee.FieldTags:
  13311. v, ok := value.(string)
  13312. if !ok {
  13313. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13314. }
  13315. m.SetTags(v)
  13316. return nil
  13317. case employee.FieldHireCount:
  13318. v, ok := value.(int)
  13319. if !ok {
  13320. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13321. }
  13322. m.SetHireCount(v)
  13323. return nil
  13324. case employee.FieldServiceCount:
  13325. v, ok := value.(int)
  13326. if !ok {
  13327. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13328. }
  13329. m.SetServiceCount(v)
  13330. return nil
  13331. case employee.FieldAchievementCount:
  13332. v, ok := value.(int)
  13333. if !ok {
  13334. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13335. }
  13336. m.SetAchievementCount(v)
  13337. return nil
  13338. case employee.FieldIntro:
  13339. v, ok := value.(string)
  13340. if !ok {
  13341. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13342. }
  13343. m.SetIntro(v)
  13344. return nil
  13345. case employee.FieldEstimate:
  13346. v, ok := value.(string)
  13347. if !ok {
  13348. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13349. }
  13350. m.SetEstimate(v)
  13351. return nil
  13352. case employee.FieldSkill:
  13353. v, ok := value.(string)
  13354. if !ok {
  13355. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13356. }
  13357. m.SetSkill(v)
  13358. return nil
  13359. case employee.FieldAbilityType:
  13360. v, ok := value.(string)
  13361. if !ok {
  13362. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13363. }
  13364. m.SetAbilityType(v)
  13365. return nil
  13366. case employee.FieldScene:
  13367. v, ok := value.(string)
  13368. if !ok {
  13369. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13370. }
  13371. m.SetScene(v)
  13372. return nil
  13373. case employee.FieldSwitchIn:
  13374. v, ok := value.(string)
  13375. if !ok {
  13376. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13377. }
  13378. m.SetSwitchIn(v)
  13379. return nil
  13380. case employee.FieldVideoURL:
  13381. v, ok := value.(string)
  13382. if !ok {
  13383. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13384. }
  13385. m.SetVideoURL(v)
  13386. return nil
  13387. case employee.FieldOrganizationID:
  13388. v, ok := value.(uint64)
  13389. if !ok {
  13390. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13391. }
  13392. m.SetOrganizationID(v)
  13393. return nil
  13394. case employee.FieldCategoryID:
  13395. v, ok := value.(uint64)
  13396. if !ok {
  13397. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13398. }
  13399. m.SetCategoryID(v)
  13400. return nil
  13401. case employee.FieldAPIBase:
  13402. v, ok := value.(string)
  13403. if !ok {
  13404. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13405. }
  13406. m.SetAPIBase(v)
  13407. return nil
  13408. case employee.FieldAPIKey:
  13409. v, ok := value.(string)
  13410. if !ok {
  13411. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13412. }
  13413. m.SetAPIKey(v)
  13414. return nil
  13415. case employee.FieldAiInfo:
  13416. v, ok := value.(string)
  13417. if !ok {
  13418. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13419. }
  13420. m.SetAiInfo(v)
  13421. return nil
  13422. case employee.FieldIsVip:
  13423. v, ok := value.(int)
  13424. if !ok {
  13425. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13426. }
  13427. m.SetIsVip(v)
  13428. return nil
  13429. case employee.FieldChatURL:
  13430. v, ok := value.(string)
  13431. if !ok {
  13432. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13433. }
  13434. m.SetChatURL(v)
  13435. return nil
  13436. }
  13437. return fmt.Errorf("unknown Employee field %s", name)
  13438. }
  13439. // AddedFields returns all numeric fields that were incremented/decremented during
  13440. // this mutation.
  13441. func (m *EmployeeMutation) AddedFields() []string {
  13442. var fields []string
  13443. if m.addhire_count != nil {
  13444. fields = append(fields, employee.FieldHireCount)
  13445. }
  13446. if m.addservice_count != nil {
  13447. fields = append(fields, employee.FieldServiceCount)
  13448. }
  13449. if m.addachievement_count != nil {
  13450. fields = append(fields, employee.FieldAchievementCount)
  13451. }
  13452. if m.addorganization_id != nil {
  13453. fields = append(fields, employee.FieldOrganizationID)
  13454. }
  13455. if m.addcategory_id != nil {
  13456. fields = append(fields, employee.FieldCategoryID)
  13457. }
  13458. if m.addis_vip != nil {
  13459. fields = append(fields, employee.FieldIsVip)
  13460. }
  13461. return fields
  13462. }
  13463. // AddedField returns the numeric value that was incremented/decremented on a field
  13464. // with the given name. The second boolean return value indicates that this field
  13465. // was not set, or was not defined in the schema.
  13466. func (m *EmployeeMutation) AddedField(name string) (ent.Value, bool) {
  13467. switch name {
  13468. case employee.FieldHireCount:
  13469. return m.AddedHireCount()
  13470. case employee.FieldServiceCount:
  13471. return m.AddedServiceCount()
  13472. case employee.FieldAchievementCount:
  13473. return m.AddedAchievementCount()
  13474. case employee.FieldOrganizationID:
  13475. return m.AddedOrganizationID()
  13476. case employee.FieldCategoryID:
  13477. return m.AddedCategoryID()
  13478. case employee.FieldIsVip:
  13479. return m.AddedIsVip()
  13480. }
  13481. return nil, false
  13482. }
  13483. // AddField adds the value to the field with the given name. It returns an error if
  13484. // the field is not defined in the schema, or if the type mismatched the field
  13485. // type.
  13486. func (m *EmployeeMutation) AddField(name string, value ent.Value) error {
  13487. switch name {
  13488. case employee.FieldHireCount:
  13489. v, ok := value.(int)
  13490. if !ok {
  13491. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13492. }
  13493. m.AddHireCount(v)
  13494. return nil
  13495. case employee.FieldServiceCount:
  13496. v, ok := value.(int)
  13497. if !ok {
  13498. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13499. }
  13500. m.AddServiceCount(v)
  13501. return nil
  13502. case employee.FieldAchievementCount:
  13503. v, ok := value.(int)
  13504. if !ok {
  13505. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13506. }
  13507. m.AddAchievementCount(v)
  13508. return nil
  13509. case employee.FieldOrganizationID:
  13510. v, ok := value.(int64)
  13511. if !ok {
  13512. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13513. }
  13514. m.AddOrganizationID(v)
  13515. return nil
  13516. case employee.FieldCategoryID:
  13517. v, ok := value.(int64)
  13518. if !ok {
  13519. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13520. }
  13521. m.AddCategoryID(v)
  13522. return nil
  13523. case employee.FieldIsVip:
  13524. v, ok := value.(int)
  13525. if !ok {
  13526. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13527. }
  13528. m.AddIsVip(v)
  13529. return nil
  13530. }
  13531. return fmt.Errorf("unknown Employee numeric field %s", name)
  13532. }
  13533. // ClearedFields returns all nullable fields that were cleared during this
  13534. // mutation.
  13535. func (m *EmployeeMutation) ClearedFields() []string {
  13536. var fields []string
  13537. if m.FieldCleared(employee.FieldDeletedAt) {
  13538. fields = append(fields, employee.FieldDeletedAt)
  13539. }
  13540. if m.FieldCleared(employee.FieldAiInfo) {
  13541. fields = append(fields, employee.FieldAiInfo)
  13542. }
  13543. return fields
  13544. }
  13545. // FieldCleared returns a boolean indicating if a field with the given name was
  13546. // cleared in this mutation.
  13547. func (m *EmployeeMutation) FieldCleared(name string) bool {
  13548. _, ok := m.clearedFields[name]
  13549. return ok
  13550. }
  13551. // ClearField clears the value of the field with the given name. It returns an
  13552. // error if the field is not defined in the schema.
  13553. func (m *EmployeeMutation) ClearField(name string) error {
  13554. switch name {
  13555. case employee.FieldDeletedAt:
  13556. m.ClearDeletedAt()
  13557. return nil
  13558. case employee.FieldAiInfo:
  13559. m.ClearAiInfo()
  13560. return nil
  13561. }
  13562. return fmt.Errorf("unknown Employee nullable field %s", name)
  13563. }
  13564. // ResetField resets all changes in the mutation for the field with the given name.
  13565. // It returns an error if the field is not defined in the schema.
  13566. func (m *EmployeeMutation) ResetField(name string) error {
  13567. switch name {
  13568. case employee.FieldCreatedAt:
  13569. m.ResetCreatedAt()
  13570. return nil
  13571. case employee.FieldUpdatedAt:
  13572. m.ResetUpdatedAt()
  13573. return nil
  13574. case employee.FieldDeletedAt:
  13575. m.ResetDeletedAt()
  13576. return nil
  13577. case employee.FieldTitle:
  13578. m.ResetTitle()
  13579. return nil
  13580. case employee.FieldAvatar:
  13581. m.ResetAvatar()
  13582. return nil
  13583. case employee.FieldTags:
  13584. m.ResetTags()
  13585. return nil
  13586. case employee.FieldHireCount:
  13587. m.ResetHireCount()
  13588. return nil
  13589. case employee.FieldServiceCount:
  13590. m.ResetServiceCount()
  13591. return nil
  13592. case employee.FieldAchievementCount:
  13593. m.ResetAchievementCount()
  13594. return nil
  13595. case employee.FieldIntro:
  13596. m.ResetIntro()
  13597. return nil
  13598. case employee.FieldEstimate:
  13599. m.ResetEstimate()
  13600. return nil
  13601. case employee.FieldSkill:
  13602. m.ResetSkill()
  13603. return nil
  13604. case employee.FieldAbilityType:
  13605. m.ResetAbilityType()
  13606. return nil
  13607. case employee.FieldScene:
  13608. m.ResetScene()
  13609. return nil
  13610. case employee.FieldSwitchIn:
  13611. m.ResetSwitchIn()
  13612. return nil
  13613. case employee.FieldVideoURL:
  13614. m.ResetVideoURL()
  13615. return nil
  13616. case employee.FieldOrganizationID:
  13617. m.ResetOrganizationID()
  13618. return nil
  13619. case employee.FieldCategoryID:
  13620. m.ResetCategoryID()
  13621. return nil
  13622. case employee.FieldAPIBase:
  13623. m.ResetAPIBase()
  13624. return nil
  13625. case employee.FieldAPIKey:
  13626. m.ResetAPIKey()
  13627. return nil
  13628. case employee.FieldAiInfo:
  13629. m.ResetAiInfo()
  13630. return nil
  13631. case employee.FieldIsVip:
  13632. m.ResetIsVip()
  13633. return nil
  13634. case employee.FieldChatURL:
  13635. m.ResetChatURL()
  13636. return nil
  13637. }
  13638. return fmt.Errorf("unknown Employee field %s", name)
  13639. }
  13640. // AddedEdges returns all edge names that were set/added in this mutation.
  13641. func (m *EmployeeMutation) AddedEdges() []string {
  13642. edges := make([]string, 0, 2)
  13643. if m.em_work_experiences != nil {
  13644. edges = append(edges, employee.EdgeEmWorkExperiences)
  13645. }
  13646. if m.em_tutorial != nil {
  13647. edges = append(edges, employee.EdgeEmTutorial)
  13648. }
  13649. return edges
  13650. }
  13651. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  13652. // name in this mutation.
  13653. func (m *EmployeeMutation) AddedIDs(name string) []ent.Value {
  13654. switch name {
  13655. case employee.EdgeEmWorkExperiences:
  13656. ids := make([]ent.Value, 0, len(m.em_work_experiences))
  13657. for id := range m.em_work_experiences {
  13658. ids = append(ids, id)
  13659. }
  13660. return ids
  13661. case employee.EdgeEmTutorial:
  13662. ids := make([]ent.Value, 0, len(m.em_tutorial))
  13663. for id := range m.em_tutorial {
  13664. ids = append(ids, id)
  13665. }
  13666. return ids
  13667. }
  13668. return nil
  13669. }
  13670. // RemovedEdges returns all edge names that were removed in this mutation.
  13671. func (m *EmployeeMutation) RemovedEdges() []string {
  13672. edges := make([]string, 0, 2)
  13673. if m.removedem_work_experiences != nil {
  13674. edges = append(edges, employee.EdgeEmWorkExperiences)
  13675. }
  13676. if m.removedem_tutorial != nil {
  13677. edges = append(edges, employee.EdgeEmTutorial)
  13678. }
  13679. return edges
  13680. }
  13681. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  13682. // the given name in this mutation.
  13683. func (m *EmployeeMutation) RemovedIDs(name string) []ent.Value {
  13684. switch name {
  13685. case employee.EdgeEmWorkExperiences:
  13686. ids := make([]ent.Value, 0, len(m.removedem_work_experiences))
  13687. for id := range m.removedem_work_experiences {
  13688. ids = append(ids, id)
  13689. }
  13690. return ids
  13691. case employee.EdgeEmTutorial:
  13692. ids := make([]ent.Value, 0, len(m.removedem_tutorial))
  13693. for id := range m.removedem_tutorial {
  13694. ids = append(ids, id)
  13695. }
  13696. return ids
  13697. }
  13698. return nil
  13699. }
  13700. // ClearedEdges returns all edge names that were cleared in this mutation.
  13701. func (m *EmployeeMutation) ClearedEdges() []string {
  13702. edges := make([]string, 0, 2)
  13703. if m.clearedem_work_experiences {
  13704. edges = append(edges, employee.EdgeEmWorkExperiences)
  13705. }
  13706. if m.clearedem_tutorial {
  13707. edges = append(edges, employee.EdgeEmTutorial)
  13708. }
  13709. return edges
  13710. }
  13711. // EdgeCleared returns a boolean which indicates if the edge with the given name
  13712. // was cleared in this mutation.
  13713. func (m *EmployeeMutation) EdgeCleared(name string) bool {
  13714. switch name {
  13715. case employee.EdgeEmWorkExperiences:
  13716. return m.clearedem_work_experiences
  13717. case employee.EdgeEmTutorial:
  13718. return m.clearedem_tutorial
  13719. }
  13720. return false
  13721. }
  13722. // ClearEdge clears the value of the edge with the given name. It returns an error
  13723. // if that edge is not defined in the schema.
  13724. func (m *EmployeeMutation) ClearEdge(name string) error {
  13725. switch name {
  13726. }
  13727. return fmt.Errorf("unknown Employee unique edge %s", name)
  13728. }
  13729. // ResetEdge resets all changes to the edge with the given name in this mutation.
  13730. // It returns an error if the edge is not defined in the schema.
  13731. func (m *EmployeeMutation) ResetEdge(name string) error {
  13732. switch name {
  13733. case employee.EdgeEmWorkExperiences:
  13734. m.ResetEmWorkExperiences()
  13735. return nil
  13736. case employee.EdgeEmTutorial:
  13737. m.ResetEmTutorial()
  13738. return nil
  13739. }
  13740. return fmt.Errorf("unknown Employee edge %s", name)
  13741. }
  13742. // EmployeeConfigMutation represents an operation that mutates the EmployeeConfig nodes in the graph.
  13743. type EmployeeConfigMutation struct {
  13744. config
  13745. op Op
  13746. typ string
  13747. id *uint64
  13748. created_at *time.Time
  13749. updated_at *time.Time
  13750. deleted_at *time.Time
  13751. stype *string
  13752. title *string
  13753. photo *string
  13754. organization_id *uint64
  13755. addorganization_id *int64
  13756. clearedFields map[string]struct{}
  13757. done bool
  13758. oldValue func(context.Context) (*EmployeeConfig, error)
  13759. predicates []predicate.EmployeeConfig
  13760. }
  13761. var _ ent.Mutation = (*EmployeeConfigMutation)(nil)
  13762. // employeeconfigOption allows management of the mutation configuration using functional options.
  13763. type employeeconfigOption func(*EmployeeConfigMutation)
  13764. // newEmployeeConfigMutation creates new mutation for the EmployeeConfig entity.
  13765. func newEmployeeConfigMutation(c config, op Op, opts ...employeeconfigOption) *EmployeeConfigMutation {
  13766. m := &EmployeeConfigMutation{
  13767. config: c,
  13768. op: op,
  13769. typ: TypeEmployeeConfig,
  13770. clearedFields: make(map[string]struct{}),
  13771. }
  13772. for _, opt := range opts {
  13773. opt(m)
  13774. }
  13775. return m
  13776. }
  13777. // withEmployeeConfigID sets the ID field of the mutation.
  13778. func withEmployeeConfigID(id uint64) employeeconfigOption {
  13779. return func(m *EmployeeConfigMutation) {
  13780. var (
  13781. err error
  13782. once sync.Once
  13783. value *EmployeeConfig
  13784. )
  13785. m.oldValue = func(ctx context.Context) (*EmployeeConfig, error) {
  13786. once.Do(func() {
  13787. if m.done {
  13788. err = errors.New("querying old values post mutation is not allowed")
  13789. } else {
  13790. value, err = m.Client().EmployeeConfig.Get(ctx, id)
  13791. }
  13792. })
  13793. return value, err
  13794. }
  13795. m.id = &id
  13796. }
  13797. }
  13798. // withEmployeeConfig sets the old EmployeeConfig of the mutation.
  13799. func withEmployeeConfig(node *EmployeeConfig) employeeconfigOption {
  13800. return func(m *EmployeeConfigMutation) {
  13801. m.oldValue = func(context.Context) (*EmployeeConfig, error) {
  13802. return node, nil
  13803. }
  13804. m.id = &node.ID
  13805. }
  13806. }
  13807. // Client returns a new `ent.Client` from the mutation. If the mutation was
  13808. // executed in a transaction (ent.Tx), a transactional client is returned.
  13809. func (m EmployeeConfigMutation) Client() *Client {
  13810. client := &Client{config: m.config}
  13811. client.init()
  13812. return client
  13813. }
  13814. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  13815. // it returns an error otherwise.
  13816. func (m EmployeeConfigMutation) Tx() (*Tx, error) {
  13817. if _, ok := m.driver.(*txDriver); !ok {
  13818. return nil, errors.New("ent: mutation is not running in a transaction")
  13819. }
  13820. tx := &Tx{config: m.config}
  13821. tx.init()
  13822. return tx, nil
  13823. }
  13824. // SetID sets the value of the id field. Note that this
  13825. // operation is only accepted on creation of EmployeeConfig entities.
  13826. func (m *EmployeeConfigMutation) SetID(id uint64) {
  13827. m.id = &id
  13828. }
  13829. // ID returns the ID value in the mutation. Note that the ID is only available
  13830. // if it was provided to the builder or after it was returned from the database.
  13831. func (m *EmployeeConfigMutation) ID() (id uint64, exists bool) {
  13832. if m.id == nil {
  13833. return
  13834. }
  13835. return *m.id, true
  13836. }
  13837. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  13838. // That means, if the mutation is applied within a transaction with an isolation level such
  13839. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  13840. // or updated by the mutation.
  13841. func (m *EmployeeConfigMutation) IDs(ctx context.Context) ([]uint64, error) {
  13842. switch {
  13843. case m.op.Is(OpUpdateOne | OpDeleteOne):
  13844. id, exists := m.ID()
  13845. if exists {
  13846. return []uint64{id}, nil
  13847. }
  13848. fallthrough
  13849. case m.op.Is(OpUpdate | OpDelete):
  13850. return m.Client().EmployeeConfig.Query().Where(m.predicates...).IDs(ctx)
  13851. default:
  13852. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  13853. }
  13854. }
  13855. // SetCreatedAt sets the "created_at" field.
  13856. func (m *EmployeeConfigMutation) SetCreatedAt(t time.Time) {
  13857. m.created_at = &t
  13858. }
  13859. // CreatedAt returns the value of the "created_at" field in the mutation.
  13860. func (m *EmployeeConfigMutation) CreatedAt() (r time.Time, exists bool) {
  13861. v := m.created_at
  13862. if v == nil {
  13863. return
  13864. }
  13865. return *v, true
  13866. }
  13867. // OldCreatedAt returns the old "created_at" field's value of the EmployeeConfig entity.
  13868. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  13869. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13870. func (m *EmployeeConfigMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  13871. if !m.op.Is(OpUpdateOne) {
  13872. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  13873. }
  13874. if m.id == nil || m.oldValue == nil {
  13875. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  13876. }
  13877. oldValue, err := m.oldValue(ctx)
  13878. if err != nil {
  13879. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  13880. }
  13881. return oldValue.CreatedAt, nil
  13882. }
  13883. // ResetCreatedAt resets all changes to the "created_at" field.
  13884. func (m *EmployeeConfigMutation) ResetCreatedAt() {
  13885. m.created_at = nil
  13886. }
  13887. // SetUpdatedAt sets the "updated_at" field.
  13888. func (m *EmployeeConfigMutation) SetUpdatedAt(t time.Time) {
  13889. m.updated_at = &t
  13890. }
  13891. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  13892. func (m *EmployeeConfigMutation) UpdatedAt() (r time.Time, exists bool) {
  13893. v := m.updated_at
  13894. if v == nil {
  13895. return
  13896. }
  13897. return *v, true
  13898. }
  13899. // OldUpdatedAt returns the old "updated_at" field's value of the EmployeeConfig entity.
  13900. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  13901. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13902. func (m *EmployeeConfigMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  13903. if !m.op.Is(OpUpdateOne) {
  13904. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  13905. }
  13906. if m.id == nil || m.oldValue == nil {
  13907. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  13908. }
  13909. oldValue, err := m.oldValue(ctx)
  13910. if err != nil {
  13911. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  13912. }
  13913. return oldValue.UpdatedAt, nil
  13914. }
  13915. // ResetUpdatedAt resets all changes to the "updated_at" field.
  13916. func (m *EmployeeConfigMutation) ResetUpdatedAt() {
  13917. m.updated_at = nil
  13918. }
  13919. // SetDeletedAt sets the "deleted_at" field.
  13920. func (m *EmployeeConfigMutation) SetDeletedAt(t time.Time) {
  13921. m.deleted_at = &t
  13922. }
  13923. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  13924. func (m *EmployeeConfigMutation) DeletedAt() (r time.Time, exists bool) {
  13925. v := m.deleted_at
  13926. if v == nil {
  13927. return
  13928. }
  13929. return *v, true
  13930. }
  13931. // OldDeletedAt returns the old "deleted_at" field's value of the EmployeeConfig entity.
  13932. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  13933. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13934. func (m *EmployeeConfigMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  13935. if !m.op.Is(OpUpdateOne) {
  13936. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  13937. }
  13938. if m.id == nil || m.oldValue == nil {
  13939. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  13940. }
  13941. oldValue, err := m.oldValue(ctx)
  13942. if err != nil {
  13943. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  13944. }
  13945. return oldValue.DeletedAt, nil
  13946. }
  13947. // ClearDeletedAt clears the value of the "deleted_at" field.
  13948. func (m *EmployeeConfigMutation) ClearDeletedAt() {
  13949. m.deleted_at = nil
  13950. m.clearedFields[employeeconfig.FieldDeletedAt] = struct{}{}
  13951. }
  13952. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  13953. func (m *EmployeeConfigMutation) DeletedAtCleared() bool {
  13954. _, ok := m.clearedFields[employeeconfig.FieldDeletedAt]
  13955. return ok
  13956. }
  13957. // ResetDeletedAt resets all changes to the "deleted_at" field.
  13958. func (m *EmployeeConfigMutation) ResetDeletedAt() {
  13959. m.deleted_at = nil
  13960. delete(m.clearedFields, employeeconfig.FieldDeletedAt)
  13961. }
  13962. // SetStype sets the "stype" field.
  13963. func (m *EmployeeConfigMutation) SetStype(s string) {
  13964. m.stype = &s
  13965. }
  13966. // Stype returns the value of the "stype" field in the mutation.
  13967. func (m *EmployeeConfigMutation) Stype() (r string, exists bool) {
  13968. v := m.stype
  13969. if v == nil {
  13970. return
  13971. }
  13972. return *v, true
  13973. }
  13974. // OldStype returns the old "stype" field's value of the EmployeeConfig entity.
  13975. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  13976. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13977. func (m *EmployeeConfigMutation) OldStype(ctx context.Context) (v string, err error) {
  13978. if !m.op.Is(OpUpdateOne) {
  13979. return v, errors.New("OldStype is only allowed on UpdateOne operations")
  13980. }
  13981. if m.id == nil || m.oldValue == nil {
  13982. return v, errors.New("OldStype requires an ID field in the mutation")
  13983. }
  13984. oldValue, err := m.oldValue(ctx)
  13985. if err != nil {
  13986. return v, fmt.Errorf("querying old value for OldStype: %w", err)
  13987. }
  13988. return oldValue.Stype, nil
  13989. }
  13990. // ResetStype resets all changes to the "stype" field.
  13991. func (m *EmployeeConfigMutation) ResetStype() {
  13992. m.stype = nil
  13993. }
  13994. // SetTitle sets the "title" field.
  13995. func (m *EmployeeConfigMutation) SetTitle(s string) {
  13996. m.title = &s
  13997. }
  13998. // Title returns the value of the "title" field in the mutation.
  13999. func (m *EmployeeConfigMutation) Title() (r string, exists bool) {
  14000. v := m.title
  14001. if v == nil {
  14002. return
  14003. }
  14004. return *v, true
  14005. }
  14006. // OldTitle returns the old "title" field's value of the EmployeeConfig entity.
  14007. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  14008. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14009. func (m *EmployeeConfigMutation) OldTitle(ctx context.Context) (v string, err error) {
  14010. if !m.op.Is(OpUpdateOne) {
  14011. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  14012. }
  14013. if m.id == nil || m.oldValue == nil {
  14014. return v, errors.New("OldTitle requires an ID field in the mutation")
  14015. }
  14016. oldValue, err := m.oldValue(ctx)
  14017. if err != nil {
  14018. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  14019. }
  14020. return oldValue.Title, nil
  14021. }
  14022. // ResetTitle resets all changes to the "title" field.
  14023. func (m *EmployeeConfigMutation) ResetTitle() {
  14024. m.title = nil
  14025. }
  14026. // SetPhoto sets the "photo" field.
  14027. func (m *EmployeeConfigMutation) SetPhoto(s string) {
  14028. m.photo = &s
  14029. }
  14030. // Photo returns the value of the "photo" field in the mutation.
  14031. func (m *EmployeeConfigMutation) Photo() (r string, exists bool) {
  14032. v := m.photo
  14033. if v == nil {
  14034. return
  14035. }
  14036. return *v, true
  14037. }
  14038. // OldPhoto returns the old "photo" field's value of the EmployeeConfig entity.
  14039. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  14040. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14041. func (m *EmployeeConfigMutation) OldPhoto(ctx context.Context) (v string, err error) {
  14042. if !m.op.Is(OpUpdateOne) {
  14043. return v, errors.New("OldPhoto is only allowed on UpdateOne operations")
  14044. }
  14045. if m.id == nil || m.oldValue == nil {
  14046. return v, errors.New("OldPhoto requires an ID field in the mutation")
  14047. }
  14048. oldValue, err := m.oldValue(ctx)
  14049. if err != nil {
  14050. return v, fmt.Errorf("querying old value for OldPhoto: %w", err)
  14051. }
  14052. return oldValue.Photo, nil
  14053. }
  14054. // ResetPhoto resets all changes to the "photo" field.
  14055. func (m *EmployeeConfigMutation) ResetPhoto() {
  14056. m.photo = nil
  14057. }
  14058. // SetOrganizationID sets the "organization_id" field.
  14059. func (m *EmployeeConfigMutation) SetOrganizationID(u uint64) {
  14060. m.organization_id = &u
  14061. m.addorganization_id = nil
  14062. }
  14063. // OrganizationID returns the value of the "organization_id" field in the mutation.
  14064. func (m *EmployeeConfigMutation) OrganizationID() (r uint64, exists bool) {
  14065. v := m.organization_id
  14066. if v == nil {
  14067. return
  14068. }
  14069. return *v, true
  14070. }
  14071. // OldOrganizationID returns the old "organization_id" field's value of the EmployeeConfig entity.
  14072. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  14073. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14074. func (m *EmployeeConfigMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  14075. if !m.op.Is(OpUpdateOne) {
  14076. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  14077. }
  14078. if m.id == nil || m.oldValue == nil {
  14079. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  14080. }
  14081. oldValue, err := m.oldValue(ctx)
  14082. if err != nil {
  14083. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  14084. }
  14085. return oldValue.OrganizationID, nil
  14086. }
  14087. // AddOrganizationID adds u to the "organization_id" field.
  14088. func (m *EmployeeConfigMutation) AddOrganizationID(u int64) {
  14089. if m.addorganization_id != nil {
  14090. *m.addorganization_id += u
  14091. } else {
  14092. m.addorganization_id = &u
  14093. }
  14094. }
  14095. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  14096. func (m *EmployeeConfigMutation) AddedOrganizationID() (r int64, exists bool) {
  14097. v := m.addorganization_id
  14098. if v == nil {
  14099. return
  14100. }
  14101. return *v, true
  14102. }
  14103. // ClearOrganizationID clears the value of the "organization_id" field.
  14104. func (m *EmployeeConfigMutation) ClearOrganizationID() {
  14105. m.organization_id = nil
  14106. m.addorganization_id = nil
  14107. m.clearedFields[employeeconfig.FieldOrganizationID] = struct{}{}
  14108. }
  14109. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  14110. func (m *EmployeeConfigMutation) OrganizationIDCleared() bool {
  14111. _, ok := m.clearedFields[employeeconfig.FieldOrganizationID]
  14112. return ok
  14113. }
  14114. // ResetOrganizationID resets all changes to the "organization_id" field.
  14115. func (m *EmployeeConfigMutation) ResetOrganizationID() {
  14116. m.organization_id = nil
  14117. m.addorganization_id = nil
  14118. delete(m.clearedFields, employeeconfig.FieldOrganizationID)
  14119. }
  14120. // Where appends a list predicates to the EmployeeConfigMutation builder.
  14121. func (m *EmployeeConfigMutation) Where(ps ...predicate.EmployeeConfig) {
  14122. m.predicates = append(m.predicates, ps...)
  14123. }
  14124. // WhereP appends storage-level predicates to the EmployeeConfigMutation builder. Using this method,
  14125. // users can use type-assertion to append predicates that do not depend on any generated package.
  14126. func (m *EmployeeConfigMutation) WhereP(ps ...func(*sql.Selector)) {
  14127. p := make([]predicate.EmployeeConfig, len(ps))
  14128. for i := range ps {
  14129. p[i] = ps[i]
  14130. }
  14131. m.Where(p...)
  14132. }
  14133. // Op returns the operation name.
  14134. func (m *EmployeeConfigMutation) Op() Op {
  14135. return m.op
  14136. }
  14137. // SetOp allows setting the mutation operation.
  14138. func (m *EmployeeConfigMutation) SetOp(op Op) {
  14139. m.op = op
  14140. }
  14141. // Type returns the node type of this mutation (EmployeeConfig).
  14142. func (m *EmployeeConfigMutation) Type() string {
  14143. return m.typ
  14144. }
  14145. // Fields returns all fields that were changed during this mutation. Note that in
  14146. // order to get all numeric fields that were incremented/decremented, call
  14147. // AddedFields().
  14148. func (m *EmployeeConfigMutation) Fields() []string {
  14149. fields := make([]string, 0, 7)
  14150. if m.created_at != nil {
  14151. fields = append(fields, employeeconfig.FieldCreatedAt)
  14152. }
  14153. if m.updated_at != nil {
  14154. fields = append(fields, employeeconfig.FieldUpdatedAt)
  14155. }
  14156. if m.deleted_at != nil {
  14157. fields = append(fields, employeeconfig.FieldDeletedAt)
  14158. }
  14159. if m.stype != nil {
  14160. fields = append(fields, employeeconfig.FieldStype)
  14161. }
  14162. if m.title != nil {
  14163. fields = append(fields, employeeconfig.FieldTitle)
  14164. }
  14165. if m.photo != nil {
  14166. fields = append(fields, employeeconfig.FieldPhoto)
  14167. }
  14168. if m.organization_id != nil {
  14169. fields = append(fields, employeeconfig.FieldOrganizationID)
  14170. }
  14171. return fields
  14172. }
  14173. // Field returns the value of a field with the given name. The second boolean
  14174. // return value indicates that this field was not set, or was not defined in the
  14175. // schema.
  14176. func (m *EmployeeConfigMutation) Field(name string) (ent.Value, bool) {
  14177. switch name {
  14178. case employeeconfig.FieldCreatedAt:
  14179. return m.CreatedAt()
  14180. case employeeconfig.FieldUpdatedAt:
  14181. return m.UpdatedAt()
  14182. case employeeconfig.FieldDeletedAt:
  14183. return m.DeletedAt()
  14184. case employeeconfig.FieldStype:
  14185. return m.Stype()
  14186. case employeeconfig.FieldTitle:
  14187. return m.Title()
  14188. case employeeconfig.FieldPhoto:
  14189. return m.Photo()
  14190. case employeeconfig.FieldOrganizationID:
  14191. return m.OrganizationID()
  14192. }
  14193. return nil, false
  14194. }
  14195. // OldField returns the old value of the field from the database. An error is
  14196. // returned if the mutation operation is not UpdateOne, or the query to the
  14197. // database failed.
  14198. func (m *EmployeeConfigMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  14199. switch name {
  14200. case employeeconfig.FieldCreatedAt:
  14201. return m.OldCreatedAt(ctx)
  14202. case employeeconfig.FieldUpdatedAt:
  14203. return m.OldUpdatedAt(ctx)
  14204. case employeeconfig.FieldDeletedAt:
  14205. return m.OldDeletedAt(ctx)
  14206. case employeeconfig.FieldStype:
  14207. return m.OldStype(ctx)
  14208. case employeeconfig.FieldTitle:
  14209. return m.OldTitle(ctx)
  14210. case employeeconfig.FieldPhoto:
  14211. return m.OldPhoto(ctx)
  14212. case employeeconfig.FieldOrganizationID:
  14213. return m.OldOrganizationID(ctx)
  14214. }
  14215. return nil, fmt.Errorf("unknown EmployeeConfig field %s", name)
  14216. }
  14217. // SetField sets the value of a field with the given name. It returns an error if
  14218. // the field is not defined in the schema, or if the type mismatched the field
  14219. // type.
  14220. func (m *EmployeeConfigMutation) SetField(name string, value ent.Value) error {
  14221. switch name {
  14222. case employeeconfig.FieldCreatedAt:
  14223. v, ok := value.(time.Time)
  14224. if !ok {
  14225. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14226. }
  14227. m.SetCreatedAt(v)
  14228. return nil
  14229. case employeeconfig.FieldUpdatedAt:
  14230. v, ok := value.(time.Time)
  14231. if !ok {
  14232. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14233. }
  14234. m.SetUpdatedAt(v)
  14235. return nil
  14236. case employeeconfig.FieldDeletedAt:
  14237. v, ok := value.(time.Time)
  14238. if !ok {
  14239. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14240. }
  14241. m.SetDeletedAt(v)
  14242. return nil
  14243. case employeeconfig.FieldStype:
  14244. v, ok := value.(string)
  14245. if !ok {
  14246. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14247. }
  14248. m.SetStype(v)
  14249. return nil
  14250. case employeeconfig.FieldTitle:
  14251. v, ok := value.(string)
  14252. if !ok {
  14253. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14254. }
  14255. m.SetTitle(v)
  14256. return nil
  14257. case employeeconfig.FieldPhoto:
  14258. v, ok := value.(string)
  14259. if !ok {
  14260. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14261. }
  14262. m.SetPhoto(v)
  14263. return nil
  14264. case employeeconfig.FieldOrganizationID:
  14265. v, ok := value.(uint64)
  14266. if !ok {
  14267. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14268. }
  14269. m.SetOrganizationID(v)
  14270. return nil
  14271. }
  14272. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  14273. }
  14274. // AddedFields returns all numeric fields that were incremented/decremented during
  14275. // this mutation.
  14276. func (m *EmployeeConfigMutation) AddedFields() []string {
  14277. var fields []string
  14278. if m.addorganization_id != nil {
  14279. fields = append(fields, employeeconfig.FieldOrganizationID)
  14280. }
  14281. return fields
  14282. }
  14283. // AddedField returns the numeric value that was incremented/decremented on a field
  14284. // with the given name. The second boolean return value indicates that this field
  14285. // was not set, or was not defined in the schema.
  14286. func (m *EmployeeConfigMutation) AddedField(name string) (ent.Value, bool) {
  14287. switch name {
  14288. case employeeconfig.FieldOrganizationID:
  14289. return m.AddedOrganizationID()
  14290. }
  14291. return nil, false
  14292. }
  14293. // AddField adds the value to the field with the given name. It returns an error if
  14294. // the field is not defined in the schema, or if the type mismatched the field
  14295. // type.
  14296. func (m *EmployeeConfigMutation) AddField(name string, value ent.Value) error {
  14297. switch name {
  14298. case employeeconfig.FieldOrganizationID:
  14299. v, ok := value.(int64)
  14300. if !ok {
  14301. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14302. }
  14303. m.AddOrganizationID(v)
  14304. return nil
  14305. }
  14306. return fmt.Errorf("unknown EmployeeConfig numeric field %s", name)
  14307. }
  14308. // ClearedFields returns all nullable fields that were cleared during this
  14309. // mutation.
  14310. func (m *EmployeeConfigMutation) ClearedFields() []string {
  14311. var fields []string
  14312. if m.FieldCleared(employeeconfig.FieldDeletedAt) {
  14313. fields = append(fields, employeeconfig.FieldDeletedAt)
  14314. }
  14315. if m.FieldCleared(employeeconfig.FieldOrganizationID) {
  14316. fields = append(fields, employeeconfig.FieldOrganizationID)
  14317. }
  14318. return fields
  14319. }
  14320. // FieldCleared returns a boolean indicating if a field with the given name was
  14321. // cleared in this mutation.
  14322. func (m *EmployeeConfigMutation) FieldCleared(name string) bool {
  14323. _, ok := m.clearedFields[name]
  14324. return ok
  14325. }
  14326. // ClearField clears the value of the field with the given name. It returns an
  14327. // error if the field is not defined in the schema.
  14328. func (m *EmployeeConfigMutation) ClearField(name string) error {
  14329. switch name {
  14330. case employeeconfig.FieldDeletedAt:
  14331. m.ClearDeletedAt()
  14332. return nil
  14333. case employeeconfig.FieldOrganizationID:
  14334. m.ClearOrganizationID()
  14335. return nil
  14336. }
  14337. return fmt.Errorf("unknown EmployeeConfig nullable field %s", name)
  14338. }
  14339. // ResetField resets all changes in the mutation for the field with the given name.
  14340. // It returns an error if the field is not defined in the schema.
  14341. func (m *EmployeeConfigMutation) ResetField(name string) error {
  14342. switch name {
  14343. case employeeconfig.FieldCreatedAt:
  14344. m.ResetCreatedAt()
  14345. return nil
  14346. case employeeconfig.FieldUpdatedAt:
  14347. m.ResetUpdatedAt()
  14348. return nil
  14349. case employeeconfig.FieldDeletedAt:
  14350. m.ResetDeletedAt()
  14351. return nil
  14352. case employeeconfig.FieldStype:
  14353. m.ResetStype()
  14354. return nil
  14355. case employeeconfig.FieldTitle:
  14356. m.ResetTitle()
  14357. return nil
  14358. case employeeconfig.FieldPhoto:
  14359. m.ResetPhoto()
  14360. return nil
  14361. case employeeconfig.FieldOrganizationID:
  14362. m.ResetOrganizationID()
  14363. return nil
  14364. }
  14365. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  14366. }
  14367. // AddedEdges returns all edge names that were set/added in this mutation.
  14368. func (m *EmployeeConfigMutation) AddedEdges() []string {
  14369. edges := make([]string, 0, 0)
  14370. return edges
  14371. }
  14372. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  14373. // name in this mutation.
  14374. func (m *EmployeeConfigMutation) AddedIDs(name string) []ent.Value {
  14375. return nil
  14376. }
  14377. // RemovedEdges returns all edge names that were removed in this mutation.
  14378. func (m *EmployeeConfigMutation) RemovedEdges() []string {
  14379. edges := make([]string, 0, 0)
  14380. return edges
  14381. }
  14382. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  14383. // the given name in this mutation.
  14384. func (m *EmployeeConfigMutation) RemovedIDs(name string) []ent.Value {
  14385. return nil
  14386. }
  14387. // ClearedEdges returns all edge names that were cleared in this mutation.
  14388. func (m *EmployeeConfigMutation) ClearedEdges() []string {
  14389. edges := make([]string, 0, 0)
  14390. return edges
  14391. }
  14392. // EdgeCleared returns a boolean which indicates if the edge with the given name
  14393. // was cleared in this mutation.
  14394. func (m *EmployeeConfigMutation) EdgeCleared(name string) bool {
  14395. return false
  14396. }
  14397. // ClearEdge clears the value of the edge with the given name. It returns an error
  14398. // if that edge is not defined in the schema.
  14399. func (m *EmployeeConfigMutation) ClearEdge(name string) error {
  14400. return fmt.Errorf("unknown EmployeeConfig unique edge %s", name)
  14401. }
  14402. // ResetEdge resets all changes to the edge with the given name in this mutation.
  14403. // It returns an error if the edge is not defined in the schema.
  14404. func (m *EmployeeConfigMutation) ResetEdge(name string) error {
  14405. return fmt.Errorf("unknown EmployeeConfig edge %s", name)
  14406. }
  14407. // LabelMutation represents an operation that mutates the Label nodes in the graph.
  14408. type LabelMutation struct {
  14409. config
  14410. op Op
  14411. typ string
  14412. id *uint64
  14413. created_at *time.Time
  14414. updated_at *time.Time
  14415. status *uint8
  14416. addstatus *int8
  14417. _type *int
  14418. add_type *int
  14419. name *string
  14420. from *int
  14421. addfrom *int
  14422. mode *int
  14423. addmode *int
  14424. conditions *string
  14425. organization_id *uint64
  14426. addorganization_id *int64
  14427. ctype *uint64
  14428. addctype *int64
  14429. clearedFields map[string]struct{}
  14430. label_relationships map[uint64]struct{}
  14431. removedlabel_relationships map[uint64]struct{}
  14432. clearedlabel_relationships bool
  14433. done bool
  14434. oldValue func(context.Context) (*Label, error)
  14435. predicates []predicate.Label
  14436. }
  14437. var _ ent.Mutation = (*LabelMutation)(nil)
  14438. // labelOption allows management of the mutation configuration using functional options.
  14439. type labelOption func(*LabelMutation)
  14440. // newLabelMutation creates new mutation for the Label entity.
  14441. func newLabelMutation(c config, op Op, opts ...labelOption) *LabelMutation {
  14442. m := &LabelMutation{
  14443. config: c,
  14444. op: op,
  14445. typ: TypeLabel,
  14446. clearedFields: make(map[string]struct{}),
  14447. }
  14448. for _, opt := range opts {
  14449. opt(m)
  14450. }
  14451. return m
  14452. }
  14453. // withLabelID sets the ID field of the mutation.
  14454. func withLabelID(id uint64) labelOption {
  14455. return func(m *LabelMutation) {
  14456. var (
  14457. err error
  14458. once sync.Once
  14459. value *Label
  14460. )
  14461. m.oldValue = func(ctx context.Context) (*Label, error) {
  14462. once.Do(func() {
  14463. if m.done {
  14464. err = errors.New("querying old values post mutation is not allowed")
  14465. } else {
  14466. value, err = m.Client().Label.Get(ctx, id)
  14467. }
  14468. })
  14469. return value, err
  14470. }
  14471. m.id = &id
  14472. }
  14473. }
  14474. // withLabel sets the old Label of the mutation.
  14475. func withLabel(node *Label) labelOption {
  14476. return func(m *LabelMutation) {
  14477. m.oldValue = func(context.Context) (*Label, error) {
  14478. return node, nil
  14479. }
  14480. m.id = &node.ID
  14481. }
  14482. }
  14483. // Client returns a new `ent.Client` from the mutation. If the mutation was
  14484. // executed in a transaction (ent.Tx), a transactional client is returned.
  14485. func (m LabelMutation) Client() *Client {
  14486. client := &Client{config: m.config}
  14487. client.init()
  14488. return client
  14489. }
  14490. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  14491. // it returns an error otherwise.
  14492. func (m LabelMutation) Tx() (*Tx, error) {
  14493. if _, ok := m.driver.(*txDriver); !ok {
  14494. return nil, errors.New("ent: mutation is not running in a transaction")
  14495. }
  14496. tx := &Tx{config: m.config}
  14497. tx.init()
  14498. return tx, nil
  14499. }
  14500. // SetID sets the value of the id field. Note that this
  14501. // operation is only accepted on creation of Label entities.
  14502. func (m *LabelMutation) SetID(id uint64) {
  14503. m.id = &id
  14504. }
  14505. // ID returns the ID value in the mutation. Note that the ID is only available
  14506. // if it was provided to the builder or after it was returned from the database.
  14507. func (m *LabelMutation) ID() (id uint64, exists bool) {
  14508. if m.id == nil {
  14509. return
  14510. }
  14511. return *m.id, true
  14512. }
  14513. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  14514. // That means, if the mutation is applied within a transaction with an isolation level such
  14515. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  14516. // or updated by the mutation.
  14517. func (m *LabelMutation) IDs(ctx context.Context) ([]uint64, error) {
  14518. switch {
  14519. case m.op.Is(OpUpdateOne | OpDeleteOne):
  14520. id, exists := m.ID()
  14521. if exists {
  14522. return []uint64{id}, nil
  14523. }
  14524. fallthrough
  14525. case m.op.Is(OpUpdate | OpDelete):
  14526. return m.Client().Label.Query().Where(m.predicates...).IDs(ctx)
  14527. default:
  14528. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  14529. }
  14530. }
  14531. // SetCreatedAt sets the "created_at" field.
  14532. func (m *LabelMutation) SetCreatedAt(t time.Time) {
  14533. m.created_at = &t
  14534. }
  14535. // CreatedAt returns the value of the "created_at" field in the mutation.
  14536. func (m *LabelMutation) CreatedAt() (r time.Time, exists bool) {
  14537. v := m.created_at
  14538. if v == nil {
  14539. return
  14540. }
  14541. return *v, true
  14542. }
  14543. // OldCreatedAt returns the old "created_at" field's value of the Label entity.
  14544. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  14545. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14546. func (m *LabelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  14547. if !m.op.Is(OpUpdateOne) {
  14548. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  14549. }
  14550. if m.id == nil || m.oldValue == nil {
  14551. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  14552. }
  14553. oldValue, err := m.oldValue(ctx)
  14554. if err != nil {
  14555. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  14556. }
  14557. return oldValue.CreatedAt, nil
  14558. }
  14559. // ResetCreatedAt resets all changes to the "created_at" field.
  14560. func (m *LabelMutation) ResetCreatedAt() {
  14561. m.created_at = nil
  14562. }
  14563. // SetUpdatedAt sets the "updated_at" field.
  14564. func (m *LabelMutation) SetUpdatedAt(t time.Time) {
  14565. m.updated_at = &t
  14566. }
  14567. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  14568. func (m *LabelMutation) UpdatedAt() (r time.Time, exists bool) {
  14569. v := m.updated_at
  14570. if v == nil {
  14571. return
  14572. }
  14573. return *v, true
  14574. }
  14575. // OldUpdatedAt returns the old "updated_at" field's value of the Label entity.
  14576. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  14577. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14578. func (m *LabelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  14579. if !m.op.Is(OpUpdateOne) {
  14580. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  14581. }
  14582. if m.id == nil || m.oldValue == nil {
  14583. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  14584. }
  14585. oldValue, err := m.oldValue(ctx)
  14586. if err != nil {
  14587. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  14588. }
  14589. return oldValue.UpdatedAt, nil
  14590. }
  14591. // ResetUpdatedAt resets all changes to the "updated_at" field.
  14592. func (m *LabelMutation) ResetUpdatedAt() {
  14593. m.updated_at = nil
  14594. }
  14595. // SetStatus sets the "status" field.
  14596. func (m *LabelMutation) SetStatus(u uint8) {
  14597. m.status = &u
  14598. m.addstatus = nil
  14599. }
  14600. // Status returns the value of the "status" field in the mutation.
  14601. func (m *LabelMutation) Status() (r uint8, exists bool) {
  14602. v := m.status
  14603. if v == nil {
  14604. return
  14605. }
  14606. return *v, true
  14607. }
  14608. // OldStatus returns the old "status" field's value of the Label entity.
  14609. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  14610. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14611. func (m *LabelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  14612. if !m.op.Is(OpUpdateOne) {
  14613. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  14614. }
  14615. if m.id == nil || m.oldValue == nil {
  14616. return v, errors.New("OldStatus requires an ID field in the mutation")
  14617. }
  14618. oldValue, err := m.oldValue(ctx)
  14619. if err != nil {
  14620. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  14621. }
  14622. return oldValue.Status, nil
  14623. }
  14624. // AddStatus adds u to the "status" field.
  14625. func (m *LabelMutation) AddStatus(u int8) {
  14626. if m.addstatus != nil {
  14627. *m.addstatus += u
  14628. } else {
  14629. m.addstatus = &u
  14630. }
  14631. }
  14632. // AddedStatus returns the value that was added to the "status" field in this mutation.
  14633. func (m *LabelMutation) AddedStatus() (r int8, exists bool) {
  14634. v := m.addstatus
  14635. if v == nil {
  14636. return
  14637. }
  14638. return *v, true
  14639. }
  14640. // ClearStatus clears the value of the "status" field.
  14641. func (m *LabelMutation) ClearStatus() {
  14642. m.status = nil
  14643. m.addstatus = nil
  14644. m.clearedFields[label.FieldStatus] = struct{}{}
  14645. }
  14646. // StatusCleared returns if the "status" field was cleared in this mutation.
  14647. func (m *LabelMutation) StatusCleared() bool {
  14648. _, ok := m.clearedFields[label.FieldStatus]
  14649. return ok
  14650. }
  14651. // ResetStatus resets all changes to the "status" field.
  14652. func (m *LabelMutation) ResetStatus() {
  14653. m.status = nil
  14654. m.addstatus = nil
  14655. delete(m.clearedFields, label.FieldStatus)
  14656. }
  14657. // SetType sets the "type" field.
  14658. func (m *LabelMutation) SetType(i int) {
  14659. m._type = &i
  14660. m.add_type = nil
  14661. }
  14662. // GetType returns the value of the "type" field in the mutation.
  14663. func (m *LabelMutation) GetType() (r int, exists bool) {
  14664. v := m._type
  14665. if v == nil {
  14666. return
  14667. }
  14668. return *v, true
  14669. }
  14670. // OldType returns the old "type" field's value of the Label entity.
  14671. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  14672. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14673. func (m *LabelMutation) OldType(ctx context.Context) (v int, err error) {
  14674. if !m.op.Is(OpUpdateOne) {
  14675. return v, errors.New("OldType is only allowed on UpdateOne operations")
  14676. }
  14677. if m.id == nil || m.oldValue == nil {
  14678. return v, errors.New("OldType requires an ID field in the mutation")
  14679. }
  14680. oldValue, err := m.oldValue(ctx)
  14681. if err != nil {
  14682. return v, fmt.Errorf("querying old value for OldType: %w", err)
  14683. }
  14684. return oldValue.Type, nil
  14685. }
  14686. // AddType adds i to the "type" field.
  14687. func (m *LabelMutation) AddType(i int) {
  14688. if m.add_type != nil {
  14689. *m.add_type += i
  14690. } else {
  14691. m.add_type = &i
  14692. }
  14693. }
  14694. // AddedType returns the value that was added to the "type" field in this mutation.
  14695. func (m *LabelMutation) AddedType() (r int, exists bool) {
  14696. v := m.add_type
  14697. if v == nil {
  14698. return
  14699. }
  14700. return *v, true
  14701. }
  14702. // ResetType resets all changes to the "type" field.
  14703. func (m *LabelMutation) ResetType() {
  14704. m._type = nil
  14705. m.add_type = nil
  14706. }
  14707. // SetName sets the "name" field.
  14708. func (m *LabelMutation) SetName(s string) {
  14709. m.name = &s
  14710. }
  14711. // Name returns the value of the "name" field in the mutation.
  14712. func (m *LabelMutation) Name() (r string, exists bool) {
  14713. v := m.name
  14714. if v == nil {
  14715. return
  14716. }
  14717. return *v, true
  14718. }
  14719. // OldName returns the old "name" field's value of the Label entity.
  14720. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  14721. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14722. func (m *LabelMutation) OldName(ctx context.Context) (v string, err error) {
  14723. if !m.op.Is(OpUpdateOne) {
  14724. return v, errors.New("OldName is only allowed on UpdateOne operations")
  14725. }
  14726. if m.id == nil || m.oldValue == nil {
  14727. return v, errors.New("OldName requires an ID field in the mutation")
  14728. }
  14729. oldValue, err := m.oldValue(ctx)
  14730. if err != nil {
  14731. return v, fmt.Errorf("querying old value for OldName: %w", err)
  14732. }
  14733. return oldValue.Name, nil
  14734. }
  14735. // ResetName resets all changes to the "name" field.
  14736. func (m *LabelMutation) ResetName() {
  14737. m.name = nil
  14738. }
  14739. // SetFrom sets the "from" field.
  14740. func (m *LabelMutation) SetFrom(i int) {
  14741. m.from = &i
  14742. m.addfrom = nil
  14743. }
  14744. // From returns the value of the "from" field in the mutation.
  14745. func (m *LabelMutation) From() (r int, exists bool) {
  14746. v := m.from
  14747. if v == nil {
  14748. return
  14749. }
  14750. return *v, true
  14751. }
  14752. // OldFrom returns the old "from" field's value of the Label entity.
  14753. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  14754. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14755. func (m *LabelMutation) OldFrom(ctx context.Context) (v int, err error) {
  14756. if !m.op.Is(OpUpdateOne) {
  14757. return v, errors.New("OldFrom is only allowed on UpdateOne operations")
  14758. }
  14759. if m.id == nil || m.oldValue == nil {
  14760. return v, errors.New("OldFrom requires an ID field in the mutation")
  14761. }
  14762. oldValue, err := m.oldValue(ctx)
  14763. if err != nil {
  14764. return v, fmt.Errorf("querying old value for OldFrom: %w", err)
  14765. }
  14766. return oldValue.From, nil
  14767. }
  14768. // AddFrom adds i to the "from" field.
  14769. func (m *LabelMutation) AddFrom(i int) {
  14770. if m.addfrom != nil {
  14771. *m.addfrom += i
  14772. } else {
  14773. m.addfrom = &i
  14774. }
  14775. }
  14776. // AddedFrom returns the value that was added to the "from" field in this mutation.
  14777. func (m *LabelMutation) AddedFrom() (r int, exists bool) {
  14778. v := m.addfrom
  14779. if v == nil {
  14780. return
  14781. }
  14782. return *v, true
  14783. }
  14784. // ResetFrom resets all changes to the "from" field.
  14785. func (m *LabelMutation) ResetFrom() {
  14786. m.from = nil
  14787. m.addfrom = nil
  14788. }
  14789. // SetMode sets the "mode" field.
  14790. func (m *LabelMutation) SetMode(i int) {
  14791. m.mode = &i
  14792. m.addmode = nil
  14793. }
  14794. // Mode returns the value of the "mode" field in the mutation.
  14795. func (m *LabelMutation) Mode() (r int, exists bool) {
  14796. v := m.mode
  14797. if v == nil {
  14798. return
  14799. }
  14800. return *v, true
  14801. }
  14802. // OldMode returns the old "mode" field's value of the Label entity.
  14803. // If the Label 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 *LabelMutation) OldMode(ctx context.Context) (v int, err error) {
  14806. if !m.op.Is(OpUpdateOne) {
  14807. return v, errors.New("OldMode is only allowed on UpdateOne operations")
  14808. }
  14809. if m.id == nil || m.oldValue == nil {
  14810. return v, errors.New("OldMode 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 OldMode: %w", err)
  14815. }
  14816. return oldValue.Mode, nil
  14817. }
  14818. // AddMode adds i to the "mode" field.
  14819. func (m *LabelMutation) AddMode(i int) {
  14820. if m.addmode != nil {
  14821. *m.addmode += i
  14822. } else {
  14823. m.addmode = &i
  14824. }
  14825. }
  14826. // AddedMode returns the value that was added to the "mode" field in this mutation.
  14827. func (m *LabelMutation) AddedMode() (r int, exists bool) {
  14828. v := m.addmode
  14829. if v == nil {
  14830. return
  14831. }
  14832. return *v, true
  14833. }
  14834. // ResetMode resets all changes to the "mode" field.
  14835. func (m *LabelMutation) ResetMode() {
  14836. m.mode = nil
  14837. m.addmode = nil
  14838. }
  14839. // SetConditions sets the "conditions" field.
  14840. func (m *LabelMutation) SetConditions(s string) {
  14841. m.conditions = &s
  14842. }
  14843. // Conditions returns the value of the "conditions" field in the mutation.
  14844. func (m *LabelMutation) Conditions() (r string, exists bool) {
  14845. v := m.conditions
  14846. if v == nil {
  14847. return
  14848. }
  14849. return *v, true
  14850. }
  14851. // OldConditions returns the old "conditions" field's value of the Label entity.
  14852. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  14853. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14854. func (m *LabelMutation) OldConditions(ctx context.Context) (v string, err error) {
  14855. if !m.op.Is(OpUpdateOne) {
  14856. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  14857. }
  14858. if m.id == nil || m.oldValue == nil {
  14859. return v, errors.New("OldConditions requires an ID field in the mutation")
  14860. }
  14861. oldValue, err := m.oldValue(ctx)
  14862. if err != nil {
  14863. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  14864. }
  14865. return oldValue.Conditions, nil
  14866. }
  14867. // ClearConditions clears the value of the "conditions" field.
  14868. func (m *LabelMutation) ClearConditions() {
  14869. m.conditions = nil
  14870. m.clearedFields[label.FieldConditions] = struct{}{}
  14871. }
  14872. // ConditionsCleared returns if the "conditions" field was cleared in this mutation.
  14873. func (m *LabelMutation) ConditionsCleared() bool {
  14874. _, ok := m.clearedFields[label.FieldConditions]
  14875. return ok
  14876. }
  14877. // ResetConditions resets all changes to the "conditions" field.
  14878. func (m *LabelMutation) ResetConditions() {
  14879. m.conditions = nil
  14880. delete(m.clearedFields, label.FieldConditions)
  14881. }
  14882. // SetOrganizationID sets the "organization_id" field.
  14883. func (m *LabelMutation) SetOrganizationID(u uint64) {
  14884. m.organization_id = &u
  14885. m.addorganization_id = nil
  14886. }
  14887. // OrganizationID returns the value of the "organization_id" field in the mutation.
  14888. func (m *LabelMutation) OrganizationID() (r uint64, exists bool) {
  14889. v := m.organization_id
  14890. if v == nil {
  14891. return
  14892. }
  14893. return *v, true
  14894. }
  14895. // OldOrganizationID returns the old "organization_id" field's value of the Label entity.
  14896. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  14897. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14898. func (m *LabelMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  14899. if !m.op.Is(OpUpdateOne) {
  14900. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  14901. }
  14902. if m.id == nil || m.oldValue == nil {
  14903. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  14904. }
  14905. oldValue, err := m.oldValue(ctx)
  14906. if err != nil {
  14907. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  14908. }
  14909. return oldValue.OrganizationID, nil
  14910. }
  14911. // AddOrganizationID adds u to the "organization_id" field.
  14912. func (m *LabelMutation) AddOrganizationID(u int64) {
  14913. if m.addorganization_id != nil {
  14914. *m.addorganization_id += u
  14915. } else {
  14916. m.addorganization_id = &u
  14917. }
  14918. }
  14919. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  14920. func (m *LabelMutation) AddedOrganizationID() (r int64, exists bool) {
  14921. v := m.addorganization_id
  14922. if v == nil {
  14923. return
  14924. }
  14925. return *v, true
  14926. }
  14927. // ClearOrganizationID clears the value of the "organization_id" field.
  14928. func (m *LabelMutation) ClearOrganizationID() {
  14929. m.organization_id = nil
  14930. m.addorganization_id = nil
  14931. m.clearedFields[label.FieldOrganizationID] = struct{}{}
  14932. }
  14933. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  14934. func (m *LabelMutation) OrganizationIDCleared() bool {
  14935. _, ok := m.clearedFields[label.FieldOrganizationID]
  14936. return ok
  14937. }
  14938. // ResetOrganizationID resets all changes to the "organization_id" field.
  14939. func (m *LabelMutation) ResetOrganizationID() {
  14940. m.organization_id = nil
  14941. m.addorganization_id = nil
  14942. delete(m.clearedFields, label.FieldOrganizationID)
  14943. }
  14944. // SetCtype sets the "ctype" field.
  14945. func (m *LabelMutation) SetCtype(u uint64) {
  14946. m.ctype = &u
  14947. m.addctype = nil
  14948. }
  14949. // Ctype returns the value of the "ctype" field in the mutation.
  14950. func (m *LabelMutation) Ctype() (r uint64, exists bool) {
  14951. v := m.ctype
  14952. if v == nil {
  14953. return
  14954. }
  14955. return *v, true
  14956. }
  14957. // OldCtype returns the old "ctype" field's value of the Label entity.
  14958. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  14959. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14960. func (m *LabelMutation) OldCtype(ctx context.Context) (v uint64, err error) {
  14961. if !m.op.Is(OpUpdateOne) {
  14962. return v, errors.New("OldCtype is only allowed on UpdateOne operations")
  14963. }
  14964. if m.id == nil || m.oldValue == nil {
  14965. return v, errors.New("OldCtype requires an ID field in the mutation")
  14966. }
  14967. oldValue, err := m.oldValue(ctx)
  14968. if err != nil {
  14969. return v, fmt.Errorf("querying old value for OldCtype: %w", err)
  14970. }
  14971. return oldValue.Ctype, nil
  14972. }
  14973. // AddCtype adds u to the "ctype" field.
  14974. func (m *LabelMutation) AddCtype(u int64) {
  14975. if m.addctype != nil {
  14976. *m.addctype += u
  14977. } else {
  14978. m.addctype = &u
  14979. }
  14980. }
  14981. // AddedCtype returns the value that was added to the "ctype" field in this mutation.
  14982. func (m *LabelMutation) AddedCtype() (r int64, exists bool) {
  14983. v := m.addctype
  14984. if v == nil {
  14985. return
  14986. }
  14987. return *v, true
  14988. }
  14989. // ResetCtype resets all changes to the "ctype" field.
  14990. func (m *LabelMutation) ResetCtype() {
  14991. m.ctype = nil
  14992. m.addctype = nil
  14993. }
  14994. // AddLabelRelationshipIDs adds the "label_relationships" edge to the LabelRelationship entity by ids.
  14995. func (m *LabelMutation) AddLabelRelationshipIDs(ids ...uint64) {
  14996. if m.label_relationships == nil {
  14997. m.label_relationships = make(map[uint64]struct{})
  14998. }
  14999. for i := range ids {
  15000. m.label_relationships[ids[i]] = struct{}{}
  15001. }
  15002. }
  15003. // ClearLabelRelationships clears the "label_relationships" edge to the LabelRelationship entity.
  15004. func (m *LabelMutation) ClearLabelRelationships() {
  15005. m.clearedlabel_relationships = true
  15006. }
  15007. // LabelRelationshipsCleared reports if the "label_relationships" edge to the LabelRelationship entity was cleared.
  15008. func (m *LabelMutation) LabelRelationshipsCleared() bool {
  15009. return m.clearedlabel_relationships
  15010. }
  15011. // RemoveLabelRelationshipIDs removes the "label_relationships" edge to the LabelRelationship entity by IDs.
  15012. func (m *LabelMutation) RemoveLabelRelationshipIDs(ids ...uint64) {
  15013. if m.removedlabel_relationships == nil {
  15014. m.removedlabel_relationships = make(map[uint64]struct{})
  15015. }
  15016. for i := range ids {
  15017. delete(m.label_relationships, ids[i])
  15018. m.removedlabel_relationships[ids[i]] = struct{}{}
  15019. }
  15020. }
  15021. // RemovedLabelRelationships returns the removed IDs of the "label_relationships" edge to the LabelRelationship entity.
  15022. func (m *LabelMutation) RemovedLabelRelationshipsIDs() (ids []uint64) {
  15023. for id := range m.removedlabel_relationships {
  15024. ids = append(ids, id)
  15025. }
  15026. return
  15027. }
  15028. // LabelRelationshipsIDs returns the "label_relationships" edge IDs in the mutation.
  15029. func (m *LabelMutation) LabelRelationshipsIDs() (ids []uint64) {
  15030. for id := range m.label_relationships {
  15031. ids = append(ids, id)
  15032. }
  15033. return
  15034. }
  15035. // ResetLabelRelationships resets all changes to the "label_relationships" edge.
  15036. func (m *LabelMutation) ResetLabelRelationships() {
  15037. m.label_relationships = nil
  15038. m.clearedlabel_relationships = false
  15039. m.removedlabel_relationships = nil
  15040. }
  15041. // Where appends a list predicates to the LabelMutation builder.
  15042. func (m *LabelMutation) Where(ps ...predicate.Label) {
  15043. m.predicates = append(m.predicates, ps...)
  15044. }
  15045. // WhereP appends storage-level predicates to the LabelMutation builder. Using this method,
  15046. // users can use type-assertion to append predicates that do not depend on any generated package.
  15047. func (m *LabelMutation) WhereP(ps ...func(*sql.Selector)) {
  15048. p := make([]predicate.Label, len(ps))
  15049. for i := range ps {
  15050. p[i] = ps[i]
  15051. }
  15052. m.Where(p...)
  15053. }
  15054. // Op returns the operation name.
  15055. func (m *LabelMutation) Op() Op {
  15056. return m.op
  15057. }
  15058. // SetOp allows setting the mutation operation.
  15059. func (m *LabelMutation) SetOp(op Op) {
  15060. m.op = op
  15061. }
  15062. // Type returns the node type of this mutation (Label).
  15063. func (m *LabelMutation) Type() string {
  15064. return m.typ
  15065. }
  15066. // Fields returns all fields that were changed during this mutation. Note that in
  15067. // order to get all numeric fields that were incremented/decremented, call
  15068. // AddedFields().
  15069. func (m *LabelMutation) Fields() []string {
  15070. fields := make([]string, 0, 10)
  15071. if m.created_at != nil {
  15072. fields = append(fields, label.FieldCreatedAt)
  15073. }
  15074. if m.updated_at != nil {
  15075. fields = append(fields, label.FieldUpdatedAt)
  15076. }
  15077. if m.status != nil {
  15078. fields = append(fields, label.FieldStatus)
  15079. }
  15080. if m._type != nil {
  15081. fields = append(fields, label.FieldType)
  15082. }
  15083. if m.name != nil {
  15084. fields = append(fields, label.FieldName)
  15085. }
  15086. if m.from != nil {
  15087. fields = append(fields, label.FieldFrom)
  15088. }
  15089. if m.mode != nil {
  15090. fields = append(fields, label.FieldMode)
  15091. }
  15092. if m.conditions != nil {
  15093. fields = append(fields, label.FieldConditions)
  15094. }
  15095. if m.organization_id != nil {
  15096. fields = append(fields, label.FieldOrganizationID)
  15097. }
  15098. if m.ctype != nil {
  15099. fields = append(fields, label.FieldCtype)
  15100. }
  15101. return fields
  15102. }
  15103. // Field returns the value of a field with the given name. The second boolean
  15104. // return value indicates that this field was not set, or was not defined in the
  15105. // schema.
  15106. func (m *LabelMutation) Field(name string) (ent.Value, bool) {
  15107. switch name {
  15108. case label.FieldCreatedAt:
  15109. return m.CreatedAt()
  15110. case label.FieldUpdatedAt:
  15111. return m.UpdatedAt()
  15112. case label.FieldStatus:
  15113. return m.Status()
  15114. case label.FieldType:
  15115. return m.GetType()
  15116. case label.FieldName:
  15117. return m.Name()
  15118. case label.FieldFrom:
  15119. return m.From()
  15120. case label.FieldMode:
  15121. return m.Mode()
  15122. case label.FieldConditions:
  15123. return m.Conditions()
  15124. case label.FieldOrganizationID:
  15125. return m.OrganizationID()
  15126. case label.FieldCtype:
  15127. return m.Ctype()
  15128. }
  15129. return nil, false
  15130. }
  15131. // OldField returns the old value of the field from the database. An error is
  15132. // returned if the mutation operation is not UpdateOne, or the query to the
  15133. // database failed.
  15134. func (m *LabelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  15135. switch name {
  15136. case label.FieldCreatedAt:
  15137. return m.OldCreatedAt(ctx)
  15138. case label.FieldUpdatedAt:
  15139. return m.OldUpdatedAt(ctx)
  15140. case label.FieldStatus:
  15141. return m.OldStatus(ctx)
  15142. case label.FieldType:
  15143. return m.OldType(ctx)
  15144. case label.FieldName:
  15145. return m.OldName(ctx)
  15146. case label.FieldFrom:
  15147. return m.OldFrom(ctx)
  15148. case label.FieldMode:
  15149. return m.OldMode(ctx)
  15150. case label.FieldConditions:
  15151. return m.OldConditions(ctx)
  15152. case label.FieldOrganizationID:
  15153. return m.OldOrganizationID(ctx)
  15154. case label.FieldCtype:
  15155. return m.OldCtype(ctx)
  15156. }
  15157. return nil, fmt.Errorf("unknown Label field %s", name)
  15158. }
  15159. // SetField sets the value of a field with the given name. It returns an error if
  15160. // the field is not defined in the schema, or if the type mismatched the field
  15161. // type.
  15162. func (m *LabelMutation) SetField(name string, value ent.Value) error {
  15163. switch name {
  15164. case label.FieldCreatedAt:
  15165. v, ok := value.(time.Time)
  15166. if !ok {
  15167. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15168. }
  15169. m.SetCreatedAt(v)
  15170. return nil
  15171. case label.FieldUpdatedAt:
  15172. v, ok := value.(time.Time)
  15173. if !ok {
  15174. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15175. }
  15176. m.SetUpdatedAt(v)
  15177. return nil
  15178. case label.FieldStatus:
  15179. v, ok := value.(uint8)
  15180. if !ok {
  15181. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15182. }
  15183. m.SetStatus(v)
  15184. return nil
  15185. case label.FieldType:
  15186. v, ok := value.(int)
  15187. if !ok {
  15188. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15189. }
  15190. m.SetType(v)
  15191. return nil
  15192. case label.FieldName:
  15193. v, ok := value.(string)
  15194. if !ok {
  15195. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15196. }
  15197. m.SetName(v)
  15198. return nil
  15199. case label.FieldFrom:
  15200. v, ok := value.(int)
  15201. if !ok {
  15202. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15203. }
  15204. m.SetFrom(v)
  15205. return nil
  15206. case label.FieldMode:
  15207. v, ok := value.(int)
  15208. if !ok {
  15209. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15210. }
  15211. m.SetMode(v)
  15212. return nil
  15213. case label.FieldConditions:
  15214. v, ok := value.(string)
  15215. if !ok {
  15216. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15217. }
  15218. m.SetConditions(v)
  15219. return nil
  15220. case label.FieldOrganizationID:
  15221. v, ok := value.(uint64)
  15222. if !ok {
  15223. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15224. }
  15225. m.SetOrganizationID(v)
  15226. return nil
  15227. case label.FieldCtype:
  15228. v, ok := value.(uint64)
  15229. if !ok {
  15230. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15231. }
  15232. m.SetCtype(v)
  15233. return nil
  15234. }
  15235. return fmt.Errorf("unknown Label field %s", name)
  15236. }
  15237. // AddedFields returns all numeric fields that were incremented/decremented during
  15238. // this mutation.
  15239. func (m *LabelMutation) AddedFields() []string {
  15240. var fields []string
  15241. if m.addstatus != nil {
  15242. fields = append(fields, label.FieldStatus)
  15243. }
  15244. if m.add_type != nil {
  15245. fields = append(fields, label.FieldType)
  15246. }
  15247. if m.addfrom != nil {
  15248. fields = append(fields, label.FieldFrom)
  15249. }
  15250. if m.addmode != nil {
  15251. fields = append(fields, label.FieldMode)
  15252. }
  15253. if m.addorganization_id != nil {
  15254. fields = append(fields, label.FieldOrganizationID)
  15255. }
  15256. if m.addctype != nil {
  15257. fields = append(fields, label.FieldCtype)
  15258. }
  15259. return fields
  15260. }
  15261. // AddedField returns the numeric value that was incremented/decremented on a field
  15262. // with the given name. The second boolean return value indicates that this field
  15263. // was not set, or was not defined in the schema.
  15264. func (m *LabelMutation) AddedField(name string) (ent.Value, bool) {
  15265. switch name {
  15266. case label.FieldStatus:
  15267. return m.AddedStatus()
  15268. case label.FieldType:
  15269. return m.AddedType()
  15270. case label.FieldFrom:
  15271. return m.AddedFrom()
  15272. case label.FieldMode:
  15273. return m.AddedMode()
  15274. case label.FieldOrganizationID:
  15275. return m.AddedOrganizationID()
  15276. case label.FieldCtype:
  15277. return m.AddedCtype()
  15278. }
  15279. return nil, false
  15280. }
  15281. // AddField adds the value to the field with the given name. It returns an error if
  15282. // the field is not defined in the schema, or if the type mismatched the field
  15283. // type.
  15284. func (m *LabelMutation) AddField(name string, value ent.Value) error {
  15285. switch name {
  15286. case label.FieldStatus:
  15287. v, ok := value.(int8)
  15288. if !ok {
  15289. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15290. }
  15291. m.AddStatus(v)
  15292. return nil
  15293. case label.FieldType:
  15294. v, ok := value.(int)
  15295. if !ok {
  15296. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15297. }
  15298. m.AddType(v)
  15299. return nil
  15300. case label.FieldFrom:
  15301. v, ok := value.(int)
  15302. if !ok {
  15303. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15304. }
  15305. m.AddFrom(v)
  15306. return nil
  15307. case label.FieldMode:
  15308. v, ok := value.(int)
  15309. if !ok {
  15310. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15311. }
  15312. m.AddMode(v)
  15313. return nil
  15314. case label.FieldOrganizationID:
  15315. v, ok := value.(int64)
  15316. if !ok {
  15317. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15318. }
  15319. m.AddOrganizationID(v)
  15320. return nil
  15321. case label.FieldCtype:
  15322. v, ok := value.(int64)
  15323. if !ok {
  15324. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15325. }
  15326. m.AddCtype(v)
  15327. return nil
  15328. }
  15329. return fmt.Errorf("unknown Label numeric field %s", name)
  15330. }
  15331. // ClearedFields returns all nullable fields that were cleared during this
  15332. // mutation.
  15333. func (m *LabelMutation) ClearedFields() []string {
  15334. var fields []string
  15335. if m.FieldCleared(label.FieldStatus) {
  15336. fields = append(fields, label.FieldStatus)
  15337. }
  15338. if m.FieldCleared(label.FieldConditions) {
  15339. fields = append(fields, label.FieldConditions)
  15340. }
  15341. if m.FieldCleared(label.FieldOrganizationID) {
  15342. fields = append(fields, label.FieldOrganizationID)
  15343. }
  15344. return fields
  15345. }
  15346. // FieldCleared returns a boolean indicating if a field with the given name was
  15347. // cleared in this mutation.
  15348. func (m *LabelMutation) FieldCleared(name string) bool {
  15349. _, ok := m.clearedFields[name]
  15350. return ok
  15351. }
  15352. // ClearField clears the value of the field with the given name. It returns an
  15353. // error if the field is not defined in the schema.
  15354. func (m *LabelMutation) ClearField(name string) error {
  15355. switch name {
  15356. case label.FieldStatus:
  15357. m.ClearStatus()
  15358. return nil
  15359. case label.FieldConditions:
  15360. m.ClearConditions()
  15361. return nil
  15362. case label.FieldOrganizationID:
  15363. m.ClearOrganizationID()
  15364. return nil
  15365. }
  15366. return fmt.Errorf("unknown Label nullable field %s", name)
  15367. }
  15368. // ResetField resets all changes in the mutation for the field with the given name.
  15369. // It returns an error if the field is not defined in the schema.
  15370. func (m *LabelMutation) ResetField(name string) error {
  15371. switch name {
  15372. case label.FieldCreatedAt:
  15373. m.ResetCreatedAt()
  15374. return nil
  15375. case label.FieldUpdatedAt:
  15376. m.ResetUpdatedAt()
  15377. return nil
  15378. case label.FieldStatus:
  15379. m.ResetStatus()
  15380. return nil
  15381. case label.FieldType:
  15382. m.ResetType()
  15383. return nil
  15384. case label.FieldName:
  15385. m.ResetName()
  15386. return nil
  15387. case label.FieldFrom:
  15388. m.ResetFrom()
  15389. return nil
  15390. case label.FieldMode:
  15391. m.ResetMode()
  15392. return nil
  15393. case label.FieldConditions:
  15394. m.ResetConditions()
  15395. return nil
  15396. case label.FieldOrganizationID:
  15397. m.ResetOrganizationID()
  15398. return nil
  15399. case label.FieldCtype:
  15400. m.ResetCtype()
  15401. return nil
  15402. }
  15403. return fmt.Errorf("unknown Label field %s", name)
  15404. }
  15405. // AddedEdges returns all edge names that were set/added in this mutation.
  15406. func (m *LabelMutation) AddedEdges() []string {
  15407. edges := make([]string, 0, 1)
  15408. if m.label_relationships != nil {
  15409. edges = append(edges, label.EdgeLabelRelationships)
  15410. }
  15411. return edges
  15412. }
  15413. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  15414. // name in this mutation.
  15415. func (m *LabelMutation) AddedIDs(name string) []ent.Value {
  15416. switch name {
  15417. case label.EdgeLabelRelationships:
  15418. ids := make([]ent.Value, 0, len(m.label_relationships))
  15419. for id := range m.label_relationships {
  15420. ids = append(ids, id)
  15421. }
  15422. return ids
  15423. }
  15424. return nil
  15425. }
  15426. // RemovedEdges returns all edge names that were removed in this mutation.
  15427. func (m *LabelMutation) RemovedEdges() []string {
  15428. edges := make([]string, 0, 1)
  15429. if m.removedlabel_relationships != nil {
  15430. edges = append(edges, label.EdgeLabelRelationships)
  15431. }
  15432. return edges
  15433. }
  15434. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  15435. // the given name in this mutation.
  15436. func (m *LabelMutation) RemovedIDs(name string) []ent.Value {
  15437. switch name {
  15438. case label.EdgeLabelRelationships:
  15439. ids := make([]ent.Value, 0, len(m.removedlabel_relationships))
  15440. for id := range m.removedlabel_relationships {
  15441. ids = append(ids, id)
  15442. }
  15443. return ids
  15444. }
  15445. return nil
  15446. }
  15447. // ClearedEdges returns all edge names that were cleared in this mutation.
  15448. func (m *LabelMutation) ClearedEdges() []string {
  15449. edges := make([]string, 0, 1)
  15450. if m.clearedlabel_relationships {
  15451. edges = append(edges, label.EdgeLabelRelationships)
  15452. }
  15453. return edges
  15454. }
  15455. // EdgeCleared returns a boolean which indicates if the edge with the given name
  15456. // was cleared in this mutation.
  15457. func (m *LabelMutation) EdgeCleared(name string) bool {
  15458. switch name {
  15459. case label.EdgeLabelRelationships:
  15460. return m.clearedlabel_relationships
  15461. }
  15462. return false
  15463. }
  15464. // ClearEdge clears the value of the edge with the given name. It returns an error
  15465. // if that edge is not defined in the schema.
  15466. func (m *LabelMutation) ClearEdge(name string) error {
  15467. switch name {
  15468. }
  15469. return fmt.Errorf("unknown Label unique edge %s", name)
  15470. }
  15471. // ResetEdge resets all changes to the edge with the given name in this mutation.
  15472. // It returns an error if the edge is not defined in the schema.
  15473. func (m *LabelMutation) ResetEdge(name string) error {
  15474. switch name {
  15475. case label.EdgeLabelRelationships:
  15476. m.ResetLabelRelationships()
  15477. return nil
  15478. }
  15479. return fmt.Errorf("unknown Label edge %s", name)
  15480. }
  15481. // LabelRelationshipMutation represents an operation that mutates the LabelRelationship nodes in the graph.
  15482. type LabelRelationshipMutation struct {
  15483. config
  15484. op Op
  15485. typ string
  15486. id *uint64
  15487. created_at *time.Time
  15488. updated_at *time.Time
  15489. status *uint8
  15490. addstatus *int8
  15491. organization_id *uint64
  15492. addorganization_id *int64
  15493. ctype *uint64
  15494. addctype *int64
  15495. clearedFields map[string]struct{}
  15496. contacts *uint64
  15497. clearedcontacts bool
  15498. labels *uint64
  15499. clearedlabels bool
  15500. done bool
  15501. oldValue func(context.Context) (*LabelRelationship, error)
  15502. predicates []predicate.LabelRelationship
  15503. }
  15504. var _ ent.Mutation = (*LabelRelationshipMutation)(nil)
  15505. // labelrelationshipOption allows management of the mutation configuration using functional options.
  15506. type labelrelationshipOption func(*LabelRelationshipMutation)
  15507. // newLabelRelationshipMutation creates new mutation for the LabelRelationship entity.
  15508. func newLabelRelationshipMutation(c config, op Op, opts ...labelrelationshipOption) *LabelRelationshipMutation {
  15509. m := &LabelRelationshipMutation{
  15510. config: c,
  15511. op: op,
  15512. typ: TypeLabelRelationship,
  15513. clearedFields: make(map[string]struct{}),
  15514. }
  15515. for _, opt := range opts {
  15516. opt(m)
  15517. }
  15518. return m
  15519. }
  15520. // withLabelRelationshipID sets the ID field of the mutation.
  15521. func withLabelRelationshipID(id uint64) labelrelationshipOption {
  15522. return func(m *LabelRelationshipMutation) {
  15523. var (
  15524. err error
  15525. once sync.Once
  15526. value *LabelRelationship
  15527. )
  15528. m.oldValue = func(ctx context.Context) (*LabelRelationship, error) {
  15529. once.Do(func() {
  15530. if m.done {
  15531. err = errors.New("querying old values post mutation is not allowed")
  15532. } else {
  15533. value, err = m.Client().LabelRelationship.Get(ctx, id)
  15534. }
  15535. })
  15536. return value, err
  15537. }
  15538. m.id = &id
  15539. }
  15540. }
  15541. // withLabelRelationship sets the old LabelRelationship of the mutation.
  15542. func withLabelRelationship(node *LabelRelationship) labelrelationshipOption {
  15543. return func(m *LabelRelationshipMutation) {
  15544. m.oldValue = func(context.Context) (*LabelRelationship, error) {
  15545. return node, nil
  15546. }
  15547. m.id = &node.ID
  15548. }
  15549. }
  15550. // Client returns a new `ent.Client` from the mutation. If the mutation was
  15551. // executed in a transaction (ent.Tx), a transactional client is returned.
  15552. func (m LabelRelationshipMutation) Client() *Client {
  15553. client := &Client{config: m.config}
  15554. client.init()
  15555. return client
  15556. }
  15557. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  15558. // it returns an error otherwise.
  15559. func (m LabelRelationshipMutation) Tx() (*Tx, error) {
  15560. if _, ok := m.driver.(*txDriver); !ok {
  15561. return nil, errors.New("ent: mutation is not running in a transaction")
  15562. }
  15563. tx := &Tx{config: m.config}
  15564. tx.init()
  15565. return tx, nil
  15566. }
  15567. // SetID sets the value of the id field. Note that this
  15568. // operation is only accepted on creation of LabelRelationship entities.
  15569. func (m *LabelRelationshipMutation) SetID(id uint64) {
  15570. m.id = &id
  15571. }
  15572. // ID returns the ID value in the mutation. Note that the ID is only available
  15573. // if it was provided to the builder or after it was returned from the database.
  15574. func (m *LabelRelationshipMutation) ID() (id uint64, exists bool) {
  15575. if m.id == nil {
  15576. return
  15577. }
  15578. return *m.id, true
  15579. }
  15580. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  15581. // That means, if the mutation is applied within a transaction with an isolation level such
  15582. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  15583. // or updated by the mutation.
  15584. func (m *LabelRelationshipMutation) IDs(ctx context.Context) ([]uint64, error) {
  15585. switch {
  15586. case m.op.Is(OpUpdateOne | OpDeleteOne):
  15587. id, exists := m.ID()
  15588. if exists {
  15589. return []uint64{id}, nil
  15590. }
  15591. fallthrough
  15592. case m.op.Is(OpUpdate | OpDelete):
  15593. return m.Client().LabelRelationship.Query().Where(m.predicates...).IDs(ctx)
  15594. default:
  15595. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  15596. }
  15597. }
  15598. // SetCreatedAt sets the "created_at" field.
  15599. func (m *LabelRelationshipMutation) SetCreatedAt(t time.Time) {
  15600. m.created_at = &t
  15601. }
  15602. // CreatedAt returns the value of the "created_at" field in the mutation.
  15603. func (m *LabelRelationshipMutation) CreatedAt() (r time.Time, exists bool) {
  15604. v := m.created_at
  15605. if v == nil {
  15606. return
  15607. }
  15608. return *v, true
  15609. }
  15610. // OldCreatedAt returns the old "created_at" field's value of the LabelRelationship entity.
  15611. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  15612. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15613. func (m *LabelRelationshipMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  15614. if !m.op.Is(OpUpdateOne) {
  15615. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  15616. }
  15617. if m.id == nil || m.oldValue == nil {
  15618. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  15619. }
  15620. oldValue, err := m.oldValue(ctx)
  15621. if err != nil {
  15622. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  15623. }
  15624. return oldValue.CreatedAt, nil
  15625. }
  15626. // ResetCreatedAt resets all changes to the "created_at" field.
  15627. func (m *LabelRelationshipMutation) ResetCreatedAt() {
  15628. m.created_at = nil
  15629. }
  15630. // SetUpdatedAt sets the "updated_at" field.
  15631. func (m *LabelRelationshipMutation) SetUpdatedAt(t time.Time) {
  15632. m.updated_at = &t
  15633. }
  15634. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  15635. func (m *LabelRelationshipMutation) UpdatedAt() (r time.Time, exists bool) {
  15636. v := m.updated_at
  15637. if v == nil {
  15638. return
  15639. }
  15640. return *v, true
  15641. }
  15642. // OldUpdatedAt returns the old "updated_at" field's value of the LabelRelationship entity.
  15643. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  15644. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15645. func (m *LabelRelationshipMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  15646. if !m.op.Is(OpUpdateOne) {
  15647. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  15648. }
  15649. if m.id == nil || m.oldValue == nil {
  15650. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  15651. }
  15652. oldValue, err := m.oldValue(ctx)
  15653. if err != nil {
  15654. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  15655. }
  15656. return oldValue.UpdatedAt, nil
  15657. }
  15658. // ResetUpdatedAt resets all changes to the "updated_at" field.
  15659. func (m *LabelRelationshipMutation) ResetUpdatedAt() {
  15660. m.updated_at = nil
  15661. }
  15662. // SetStatus sets the "status" field.
  15663. func (m *LabelRelationshipMutation) SetStatus(u uint8) {
  15664. m.status = &u
  15665. m.addstatus = nil
  15666. }
  15667. // Status returns the value of the "status" field in the mutation.
  15668. func (m *LabelRelationshipMutation) Status() (r uint8, exists bool) {
  15669. v := m.status
  15670. if v == nil {
  15671. return
  15672. }
  15673. return *v, true
  15674. }
  15675. // OldStatus returns the old "status" field's value of the LabelRelationship entity.
  15676. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  15677. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15678. func (m *LabelRelationshipMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  15679. if !m.op.Is(OpUpdateOne) {
  15680. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  15681. }
  15682. if m.id == nil || m.oldValue == nil {
  15683. return v, errors.New("OldStatus requires an ID field in the mutation")
  15684. }
  15685. oldValue, err := m.oldValue(ctx)
  15686. if err != nil {
  15687. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  15688. }
  15689. return oldValue.Status, nil
  15690. }
  15691. // AddStatus adds u to the "status" field.
  15692. func (m *LabelRelationshipMutation) AddStatus(u int8) {
  15693. if m.addstatus != nil {
  15694. *m.addstatus += u
  15695. } else {
  15696. m.addstatus = &u
  15697. }
  15698. }
  15699. // AddedStatus returns the value that was added to the "status" field in this mutation.
  15700. func (m *LabelRelationshipMutation) AddedStatus() (r int8, exists bool) {
  15701. v := m.addstatus
  15702. if v == nil {
  15703. return
  15704. }
  15705. return *v, true
  15706. }
  15707. // ClearStatus clears the value of the "status" field.
  15708. func (m *LabelRelationshipMutation) ClearStatus() {
  15709. m.status = nil
  15710. m.addstatus = nil
  15711. m.clearedFields[labelrelationship.FieldStatus] = struct{}{}
  15712. }
  15713. // StatusCleared returns if the "status" field was cleared in this mutation.
  15714. func (m *LabelRelationshipMutation) StatusCleared() bool {
  15715. _, ok := m.clearedFields[labelrelationship.FieldStatus]
  15716. return ok
  15717. }
  15718. // ResetStatus resets all changes to the "status" field.
  15719. func (m *LabelRelationshipMutation) ResetStatus() {
  15720. m.status = nil
  15721. m.addstatus = nil
  15722. delete(m.clearedFields, labelrelationship.FieldStatus)
  15723. }
  15724. // SetLabelID sets the "label_id" field.
  15725. func (m *LabelRelationshipMutation) SetLabelID(u uint64) {
  15726. m.labels = &u
  15727. }
  15728. // LabelID returns the value of the "label_id" field in the mutation.
  15729. func (m *LabelRelationshipMutation) LabelID() (r uint64, exists bool) {
  15730. v := m.labels
  15731. if v == nil {
  15732. return
  15733. }
  15734. return *v, true
  15735. }
  15736. // OldLabelID returns the old "label_id" field's value of the LabelRelationship entity.
  15737. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  15738. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15739. func (m *LabelRelationshipMutation) OldLabelID(ctx context.Context) (v uint64, err error) {
  15740. if !m.op.Is(OpUpdateOne) {
  15741. return v, errors.New("OldLabelID is only allowed on UpdateOne operations")
  15742. }
  15743. if m.id == nil || m.oldValue == nil {
  15744. return v, errors.New("OldLabelID requires an ID field in the mutation")
  15745. }
  15746. oldValue, err := m.oldValue(ctx)
  15747. if err != nil {
  15748. return v, fmt.Errorf("querying old value for OldLabelID: %w", err)
  15749. }
  15750. return oldValue.LabelID, nil
  15751. }
  15752. // ResetLabelID resets all changes to the "label_id" field.
  15753. func (m *LabelRelationshipMutation) ResetLabelID() {
  15754. m.labels = nil
  15755. }
  15756. // SetContactID sets the "contact_id" field.
  15757. func (m *LabelRelationshipMutation) SetContactID(u uint64) {
  15758. m.contacts = &u
  15759. }
  15760. // ContactID returns the value of the "contact_id" field in the mutation.
  15761. func (m *LabelRelationshipMutation) ContactID() (r uint64, exists bool) {
  15762. v := m.contacts
  15763. if v == nil {
  15764. return
  15765. }
  15766. return *v, true
  15767. }
  15768. // OldContactID returns the old "contact_id" field's value of the LabelRelationship entity.
  15769. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  15770. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15771. func (m *LabelRelationshipMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  15772. if !m.op.Is(OpUpdateOne) {
  15773. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  15774. }
  15775. if m.id == nil || m.oldValue == nil {
  15776. return v, errors.New("OldContactID requires an ID field in the mutation")
  15777. }
  15778. oldValue, err := m.oldValue(ctx)
  15779. if err != nil {
  15780. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  15781. }
  15782. return oldValue.ContactID, nil
  15783. }
  15784. // ResetContactID resets all changes to the "contact_id" field.
  15785. func (m *LabelRelationshipMutation) ResetContactID() {
  15786. m.contacts = nil
  15787. }
  15788. // SetOrganizationID sets the "organization_id" field.
  15789. func (m *LabelRelationshipMutation) SetOrganizationID(u uint64) {
  15790. m.organization_id = &u
  15791. m.addorganization_id = nil
  15792. }
  15793. // OrganizationID returns the value of the "organization_id" field in the mutation.
  15794. func (m *LabelRelationshipMutation) OrganizationID() (r uint64, exists bool) {
  15795. v := m.organization_id
  15796. if v == nil {
  15797. return
  15798. }
  15799. return *v, true
  15800. }
  15801. // OldOrganizationID returns the old "organization_id" field's value of the LabelRelationship entity.
  15802. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  15803. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15804. func (m *LabelRelationshipMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  15805. if !m.op.Is(OpUpdateOne) {
  15806. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  15807. }
  15808. if m.id == nil || m.oldValue == nil {
  15809. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  15810. }
  15811. oldValue, err := m.oldValue(ctx)
  15812. if err != nil {
  15813. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  15814. }
  15815. return oldValue.OrganizationID, nil
  15816. }
  15817. // AddOrganizationID adds u to the "organization_id" field.
  15818. func (m *LabelRelationshipMutation) AddOrganizationID(u int64) {
  15819. if m.addorganization_id != nil {
  15820. *m.addorganization_id += u
  15821. } else {
  15822. m.addorganization_id = &u
  15823. }
  15824. }
  15825. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  15826. func (m *LabelRelationshipMutation) AddedOrganizationID() (r int64, exists bool) {
  15827. v := m.addorganization_id
  15828. if v == nil {
  15829. return
  15830. }
  15831. return *v, true
  15832. }
  15833. // ClearOrganizationID clears the value of the "organization_id" field.
  15834. func (m *LabelRelationshipMutation) ClearOrganizationID() {
  15835. m.organization_id = nil
  15836. m.addorganization_id = nil
  15837. m.clearedFields[labelrelationship.FieldOrganizationID] = struct{}{}
  15838. }
  15839. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  15840. func (m *LabelRelationshipMutation) OrganizationIDCleared() bool {
  15841. _, ok := m.clearedFields[labelrelationship.FieldOrganizationID]
  15842. return ok
  15843. }
  15844. // ResetOrganizationID resets all changes to the "organization_id" field.
  15845. func (m *LabelRelationshipMutation) ResetOrganizationID() {
  15846. m.organization_id = nil
  15847. m.addorganization_id = nil
  15848. delete(m.clearedFields, labelrelationship.FieldOrganizationID)
  15849. }
  15850. // SetCtype sets the "ctype" field.
  15851. func (m *LabelRelationshipMutation) SetCtype(u uint64) {
  15852. m.ctype = &u
  15853. m.addctype = nil
  15854. }
  15855. // Ctype returns the value of the "ctype" field in the mutation.
  15856. func (m *LabelRelationshipMutation) Ctype() (r uint64, exists bool) {
  15857. v := m.ctype
  15858. if v == nil {
  15859. return
  15860. }
  15861. return *v, true
  15862. }
  15863. // OldCtype returns the old "ctype" field's value of the LabelRelationship entity.
  15864. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  15865. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15866. func (m *LabelRelationshipMutation) OldCtype(ctx context.Context) (v uint64, err error) {
  15867. if !m.op.Is(OpUpdateOne) {
  15868. return v, errors.New("OldCtype is only allowed on UpdateOne operations")
  15869. }
  15870. if m.id == nil || m.oldValue == nil {
  15871. return v, errors.New("OldCtype requires an ID field in the mutation")
  15872. }
  15873. oldValue, err := m.oldValue(ctx)
  15874. if err != nil {
  15875. return v, fmt.Errorf("querying old value for OldCtype: %w", err)
  15876. }
  15877. return oldValue.Ctype, nil
  15878. }
  15879. // AddCtype adds u to the "ctype" field.
  15880. func (m *LabelRelationshipMutation) AddCtype(u int64) {
  15881. if m.addctype != nil {
  15882. *m.addctype += u
  15883. } else {
  15884. m.addctype = &u
  15885. }
  15886. }
  15887. // AddedCtype returns the value that was added to the "ctype" field in this mutation.
  15888. func (m *LabelRelationshipMutation) AddedCtype() (r int64, exists bool) {
  15889. v := m.addctype
  15890. if v == nil {
  15891. return
  15892. }
  15893. return *v, true
  15894. }
  15895. // ResetCtype resets all changes to the "ctype" field.
  15896. func (m *LabelRelationshipMutation) ResetCtype() {
  15897. m.ctype = nil
  15898. m.addctype = nil
  15899. }
  15900. // SetContactsID sets the "contacts" edge to the Contact entity by id.
  15901. func (m *LabelRelationshipMutation) SetContactsID(id uint64) {
  15902. m.contacts = &id
  15903. }
  15904. // ClearContacts clears the "contacts" edge to the Contact entity.
  15905. func (m *LabelRelationshipMutation) ClearContacts() {
  15906. m.clearedcontacts = true
  15907. m.clearedFields[labelrelationship.FieldContactID] = struct{}{}
  15908. }
  15909. // ContactsCleared reports if the "contacts" edge to the Contact entity was cleared.
  15910. func (m *LabelRelationshipMutation) ContactsCleared() bool {
  15911. return m.clearedcontacts
  15912. }
  15913. // ContactsID returns the "contacts" edge ID in the mutation.
  15914. func (m *LabelRelationshipMutation) ContactsID() (id uint64, exists bool) {
  15915. if m.contacts != nil {
  15916. return *m.contacts, true
  15917. }
  15918. return
  15919. }
  15920. // ContactsIDs returns the "contacts" edge IDs in the mutation.
  15921. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  15922. // ContactsID instead. It exists only for internal usage by the builders.
  15923. func (m *LabelRelationshipMutation) ContactsIDs() (ids []uint64) {
  15924. if id := m.contacts; id != nil {
  15925. ids = append(ids, *id)
  15926. }
  15927. return
  15928. }
  15929. // ResetContacts resets all changes to the "contacts" edge.
  15930. func (m *LabelRelationshipMutation) ResetContacts() {
  15931. m.contacts = nil
  15932. m.clearedcontacts = false
  15933. }
  15934. // SetLabelsID sets the "labels" edge to the Label entity by id.
  15935. func (m *LabelRelationshipMutation) SetLabelsID(id uint64) {
  15936. m.labels = &id
  15937. }
  15938. // ClearLabels clears the "labels" edge to the Label entity.
  15939. func (m *LabelRelationshipMutation) ClearLabels() {
  15940. m.clearedlabels = true
  15941. m.clearedFields[labelrelationship.FieldLabelID] = struct{}{}
  15942. }
  15943. // LabelsCleared reports if the "labels" edge to the Label entity was cleared.
  15944. func (m *LabelRelationshipMutation) LabelsCleared() bool {
  15945. return m.clearedlabels
  15946. }
  15947. // LabelsID returns the "labels" edge ID in the mutation.
  15948. func (m *LabelRelationshipMutation) LabelsID() (id uint64, exists bool) {
  15949. if m.labels != nil {
  15950. return *m.labels, true
  15951. }
  15952. return
  15953. }
  15954. // LabelsIDs returns the "labels" edge IDs in the mutation.
  15955. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  15956. // LabelsID instead. It exists only for internal usage by the builders.
  15957. func (m *LabelRelationshipMutation) LabelsIDs() (ids []uint64) {
  15958. if id := m.labels; id != nil {
  15959. ids = append(ids, *id)
  15960. }
  15961. return
  15962. }
  15963. // ResetLabels resets all changes to the "labels" edge.
  15964. func (m *LabelRelationshipMutation) ResetLabels() {
  15965. m.labels = nil
  15966. m.clearedlabels = false
  15967. }
  15968. // Where appends a list predicates to the LabelRelationshipMutation builder.
  15969. func (m *LabelRelationshipMutation) Where(ps ...predicate.LabelRelationship) {
  15970. m.predicates = append(m.predicates, ps...)
  15971. }
  15972. // WhereP appends storage-level predicates to the LabelRelationshipMutation builder. Using this method,
  15973. // users can use type-assertion to append predicates that do not depend on any generated package.
  15974. func (m *LabelRelationshipMutation) WhereP(ps ...func(*sql.Selector)) {
  15975. p := make([]predicate.LabelRelationship, len(ps))
  15976. for i := range ps {
  15977. p[i] = ps[i]
  15978. }
  15979. m.Where(p...)
  15980. }
  15981. // Op returns the operation name.
  15982. func (m *LabelRelationshipMutation) Op() Op {
  15983. return m.op
  15984. }
  15985. // SetOp allows setting the mutation operation.
  15986. func (m *LabelRelationshipMutation) SetOp(op Op) {
  15987. m.op = op
  15988. }
  15989. // Type returns the node type of this mutation (LabelRelationship).
  15990. func (m *LabelRelationshipMutation) Type() string {
  15991. return m.typ
  15992. }
  15993. // Fields returns all fields that were changed during this mutation. Note that in
  15994. // order to get all numeric fields that were incremented/decremented, call
  15995. // AddedFields().
  15996. func (m *LabelRelationshipMutation) Fields() []string {
  15997. fields := make([]string, 0, 7)
  15998. if m.created_at != nil {
  15999. fields = append(fields, labelrelationship.FieldCreatedAt)
  16000. }
  16001. if m.updated_at != nil {
  16002. fields = append(fields, labelrelationship.FieldUpdatedAt)
  16003. }
  16004. if m.status != nil {
  16005. fields = append(fields, labelrelationship.FieldStatus)
  16006. }
  16007. if m.labels != nil {
  16008. fields = append(fields, labelrelationship.FieldLabelID)
  16009. }
  16010. if m.contacts != nil {
  16011. fields = append(fields, labelrelationship.FieldContactID)
  16012. }
  16013. if m.organization_id != nil {
  16014. fields = append(fields, labelrelationship.FieldOrganizationID)
  16015. }
  16016. if m.ctype != nil {
  16017. fields = append(fields, labelrelationship.FieldCtype)
  16018. }
  16019. return fields
  16020. }
  16021. // Field returns the value of a field with the given name. The second boolean
  16022. // return value indicates that this field was not set, or was not defined in the
  16023. // schema.
  16024. func (m *LabelRelationshipMutation) Field(name string) (ent.Value, bool) {
  16025. switch name {
  16026. case labelrelationship.FieldCreatedAt:
  16027. return m.CreatedAt()
  16028. case labelrelationship.FieldUpdatedAt:
  16029. return m.UpdatedAt()
  16030. case labelrelationship.FieldStatus:
  16031. return m.Status()
  16032. case labelrelationship.FieldLabelID:
  16033. return m.LabelID()
  16034. case labelrelationship.FieldContactID:
  16035. return m.ContactID()
  16036. case labelrelationship.FieldOrganizationID:
  16037. return m.OrganizationID()
  16038. case labelrelationship.FieldCtype:
  16039. return m.Ctype()
  16040. }
  16041. return nil, false
  16042. }
  16043. // OldField returns the old value of the field from the database. An error is
  16044. // returned if the mutation operation is not UpdateOne, or the query to the
  16045. // database failed.
  16046. func (m *LabelRelationshipMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  16047. switch name {
  16048. case labelrelationship.FieldCreatedAt:
  16049. return m.OldCreatedAt(ctx)
  16050. case labelrelationship.FieldUpdatedAt:
  16051. return m.OldUpdatedAt(ctx)
  16052. case labelrelationship.FieldStatus:
  16053. return m.OldStatus(ctx)
  16054. case labelrelationship.FieldLabelID:
  16055. return m.OldLabelID(ctx)
  16056. case labelrelationship.FieldContactID:
  16057. return m.OldContactID(ctx)
  16058. case labelrelationship.FieldOrganizationID:
  16059. return m.OldOrganizationID(ctx)
  16060. case labelrelationship.FieldCtype:
  16061. return m.OldCtype(ctx)
  16062. }
  16063. return nil, fmt.Errorf("unknown LabelRelationship field %s", name)
  16064. }
  16065. // SetField sets the value of a field with the given name. It returns an error if
  16066. // the field is not defined in the schema, or if the type mismatched the field
  16067. // type.
  16068. func (m *LabelRelationshipMutation) SetField(name string, value ent.Value) error {
  16069. switch name {
  16070. case labelrelationship.FieldCreatedAt:
  16071. v, ok := value.(time.Time)
  16072. if !ok {
  16073. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16074. }
  16075. m.SetCreatedAt(v)
  16076. return nil
  16077. case labelrelationship.FieldUpdatedAt:
  16078. v, ok := value.(time.Time)
  16079. if !ok {
  16080. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16081. }
  16082. m.SetUpdatedAt(v)
  16083. return nil
  16084. case labelrelationship.FieldStatus:
  16085. v, ok := value.(uint8)
  16086. if !ok {
  16087. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16088. }
  16089. m.SetStatus(v)
  16090. return nil
  16091. case labelrelationship.FieldLabelID:
  16092. v, ok := value.(uint64)
  16093. if !ok {
  16094. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16095. }
  16096. m.SetLabelID(v)
  16097. return nil
  16098. case labelrelationship.FieldContactID:
  16099. v, ok := value.(uint64)
  16100. if !ok {
  16101. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16102. }
  16103. m.SetContactID(v)
  16104. return nil
  16105. case labelrelationship.FieldOrganizationID:
  16106. v, ok := value.(uint64)
  16107. if !ok {
  16108. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16109. }
  16110. m.SetOrganizationID(v)
  16111. return nil
  16112. case labelrelationship.FieldCtype:
  16113. v, ok := value.(uint64)
  16114. if !ok {
  16115. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16116. }
  16117. m.SetCtype(v)
  16118. return nil
  16119. }
  16120. return fmt.Errorf("unknown LabelRelationship field %s", name)
  16121. }
  16122. // AddedFields returns all numeric fields that were incremented/decremented during
  16123. // this mutation.
  16124. func (m *LabelRelationshipMutation) AddedFields() []string {
  16125. var fields []string
  16126. if m.addstatus != nil {
  16127. fields = append(fields, labelrelationship.FieldStatus)
  16128. }
  16129. if m.addorganization_id != nil {
  16130. fields = append(fields, labelrelationship.FieldOrganizationID)
  16131. }
  16132. if m.addctype != nil {
  16133. fields = append(fields, labelrelationship.FieldCtype)
  16134. }
  16135. return fields
  16136. }
  16137. // AddedField returns the numeric value that was incremented/decremented on a field
  16138. // with the given name. The second boolean return value indicates that this field
  16139. // was not set, or was not defined in the schema.
  16140. func (m *LabelRelationshipMutation) AddedField(name string) (ent.Value, bool) {
  16141. switch name {
  16142. case labelrelationship.FieldStatus:
  16143. return m.AddedStatus()
  16144. case labelrelationship.FieldOrganizationID:
  16145. return m.AddedOrganizationID()
  16146. case labelrelationship.FieldCtype:
  16147. return m.AddedCtype()
  16148. }
  16149. return nil, false
  16150. }
  16151. // AddField adds the value to the field with the given name. It returns an error if
  16152. // the field is not defined in the schema, or if the type mismatched the field
  16153. // type.
  16154. func (m *LabelRelationshipMutation) AddField(name string, value ent.Value) error {
  16155. switch name {
  16156. case labelrelationship.FieldStatus:
  16157. v, ok := value.(int8)
  16158. if !ok {
  16159. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16160. }
  16161. m.AddStatus(v)
  16162. return nil
  16163. case labelrelationship.FieldOrganizationID:
  16164. v, ok := value.(int64)
  16165. if !ok {
  16166. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16167. }
  16168. m.AddOrganizationID(v)
  16169. return nil
  16170. case labelrelationship.FieldCtype:
  16171. v, ok := value.(int64)
  16172. if !ok {
  16173. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16174. }
  16175. m.AddCtype(v)
  16176. return nil
  16177. }
  16178. return fmt.Errorf("unknown LabelRelationship numeric field %s", name)
  16179. }
  16180. // ClearedFields returns all nullable fields that were cleared during this
  16181. // mutation.
  16182. func (m *LabelRelationshipMutation) ClearedFields() []string {
  16183. var fields []string
  16184. if m.FieldCleared(labelrelationship.FieldStatus) {
  16185. fields = append(fields, labelrelationship.FieldStatus)
  16186. }
  16187. if m.FieldCleared(labelrelationship.FieldOrganizationID) {
  16188. fields = append(fields, labelrelationship.FieldOrganizationID)
  16189. }
  16190. return fields
  16191. }
  16192. // FieldCleared returns a boolean indicating if a field with the given name was
  16193. // cleared in this mutation.
  16194. func (m *LabelRelationshipMutation) FieldCleared(name string) bool {
  16195. _, ok := m.clearedFields[name]
  16196. return ok
  16197. }
  16198. // ClearField clears the value of the field with the given name. It returns an
  16199. // error if the field is not defined in the schema.
  16200. func (m *LabelRelationshipMutation) ClearField(name string) error {
  16201. switch name {
  16202. case labelrelationship.FieldStatus:
  16203. m.ClearStatus()
  16204. return nil
  16205. case labelrelationship.FieldOrganizationID:
  16206. m.ClearOrganizationID()
  16207. return nil
  16208. }
  16209. return fmt.Errorf("unknown LabelRelationship nullable field %s", name)
  16210. }
  16211. // ResetField resets all changes in the mutation for the field with the given name.
  16212. // It returns an error if the field is not defined in the schema.
  16213. func (m *LabelRelationshipMutation) ResetField(name string) error {
  16214. switch name {
  16215. case labelrelationship.FieldCreatedAt:
  16216. m.ResetCreatedAt()
  16217. return nil
  16218. case labelrelationship.FieldUpdatedAt:
  16219. m.ResetUpdatedAt()
  16220. return nil
  16221. case labelrelationship.FieldStatus:
  16222. m.ResetStatus()
  16223. return nil
  16224. case labelrelationship.FieldLabelID:
  16225. m.ResetLabelID()
  16226. return nil
  16227. case labelrelationship.FieldContactID:
  16228. m.ResetContactID()
  16229. return nil
  16230. case labelrelationship.FieldOrganizationID:
  16231. m.ResetOrganizationID()
  16232. return nil
  16233. case labelrelationship.FieldCtype:
  16234. m.ResetCtype()
  16235. return nil
  16236. }
  16237. return fmt.Errorf("unknown LabelRelationship field %s", name)
  16238. }
  16239. // AddedEdges returns all edge names that were set/added in this mutation.
  16240. func (m *LabelRelationshipMutation) AddedEdges() []string {
  16241. edges := make([]string, 0, 2)
  16242. if m.contacts != nil {
  16243. edges = append(edges, labelrelationship.EdgeContacts)
  16244. }
  16245. if m.labels != nil {
  16246. edges = append(edges, labelrelationship.EdgeLabels)
  16247. }
  16248. return edges
  16249. }
  16250. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  16251. // name in this mutation.
  16252. func (m *LabelRelationshipMutation) AddedIDs(name string) []ent.Value {
  16253. switch name {
  16254. case labelrelationship.EdgeContacts:
  16255. if id := m.contacts; id != nil {
  16256. return []ent.Value{*id}
  16257. }
  16258. case labelrelationship.EdgeLabels:
  16259. if id := m.labels; id != nil {
  16260. return []ent.Value{*id}
  16261. }
  16262. }
  16263. return nil
  16264. }
  16265. // RemovedEdges returns all edge names that were removed in this mutation.
  16266. func (m *LabelRelationshipMutation) RemovedEdges() []string {
  16267. edges := make([]string, 0, 2)
  16268. return edges
  16269. }
  16270. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  16271. // the given name in this mutation.
  16272. func (m *LabelRelationshipMutation) RemovedIDs(name string) []ent.Value {
  16273. return nil
  16274. }
  16275. // ClearedEdges returns all edge names that were cleared in this mutation.
  16276. func (m *LabelRelationshipMutation) ClearedEdges() []string {
  16277. edges := make([]string, 0, 2)
  16278. if m.clearedcontacts {
  16279. edges = append(edges, labelrelationship.EdgeContacts)
  16280. }
  16281. if m.clearedlabels {
  16282. edges = append(edges, labelrelationship.EdgeLabels)
  16283. }
  16284. return edges
  16285. }
  16286. // EdgeCleared returns a boolean which indicates if the edge with the given name
  16287. // was cleared in this mutation.
  16288. func (m *LabelRelationshipMutation) EdgeCleared(name string) bool {
  16289. switch name {
  16290. case labelrelationship.EdgeContacts:
  16291. return m.clearedcontacts
  16292. case labelrelationship.EdgeLabels:
  16293. return m.clearedlabels
  16294. }
  16295. return false
  16296. }
  16297. // ClearEdge clears the value of the edge with the given name. It returns an error
  16298. // if that edge is not defined in the schema.
  16299. func (m *LabelRelationshipMutation) ClearEdge(name string) error {
  16300. switch name {
  16301. case labelrelationship.EdgeContacts:
  16302. m.ClearContacts()
  16303. return nil
  16304. case labelrelationship.EdgeLabels:
  16305. m.ClearLabels()
  16306. return nil
  16307. }
  16308. return fmt.Errorf("unknown LabelRelationship unique edge %s", name)
  16309. }
  16310. // ResetEdge resets all changes to the edge with the given name in this mutation.
  16311. // It returns an error if the edge is not defined in the schema.
  16312. func (m *LabelRelationshipMutation) ResetEdge(name string) error {
  16313. switch name {
  16314. case labelrelationship.EdgeContacts:
  16315. m.ResetContacts()
  16316. return nil
  16317. case labelrelationship.EdgeLabels:
  16318. m.ResetLabels()
  16319. return nil
  16320. }
  16321. return fmt.Errorf("unknown LabelRelationship edge %s", name)
  16322. }
  16323. // LabelTaggingMutation represents an operation that mutates the LabelTagging nodes in the graph.
  16324. type LabelTaggingMutation struct {
  16325. config
  16326. op Op
  16327. typ string
  16328. id *uint64
  16329. created_at *time.Time
  16330. updated_at *time.Time
  16331. status *uint8
  16332. addstatus *int8
  16333. deleted_at *time.Time
  16334. organization_id *uint64
  16335. addorganization_id *int64
  16336. _type *int
  16337. add_type *int
  16338. conditions *string
  16339. action_label_add *[]uint64
  16340. appendaction_label_add []uint64
  16341. action_label_del *[]uint64
  16342. appendaction_label_del []uint64
  16343. clearedFields map[string]struct{}
  16344. done bool
  16345. oldValue func(context.Context) (*LabelTagging, error)
  16346. predicates []predicate.LabelTagging
  16347. }
  16348. var _ ent.Mutation = (*LabelTaggingMutation)(nil)
  16349. // labeltaggingOption allows management of the mutation configuration using functional options.
  16350. type labeltaggingOption func(*LabelTaggingMutation)
  16351. // newLabelTaggingMutation creates new mutation for the LabelTagging entity.
  16352. func newLabelTaggingMutation(c config, op Op, opts ...labeltaggingOption) *LabelTaggingMutation {
  16353. m := &LabelTaggingMutation{
  16354. config: c,
  16355. op: op,
  16356. typ: TypeLabelTagging,
  16357. clearedFields: make(map[string]struct{}),
  16358. }
  16359. for _, opt := range opts {
  16360. opt(m)
  16361. }
  16362. return m
  16363. }
  16364. // withLabelTaggingID sets the ID field of the mutation.
  16365. func withLabelTaggingID(id uint64) labeltaggingOption {
  16366. return func(m *LabelTaggingMutation) {
  16367. var (
  16368. err error
  16369. once sync.Once
  16370. value *LabelTagging
  16371. )
  16372. m.oldValue = func(ctx context.Context) (*LabelTagging, error) {
  16373. once.Do(func() {
  16374. if m.done {
  16375. err = errors.New("querying old values post mutation is not allowed")
  16376. } else {
  16377. value, err = m.Client().LabelTagging.Get(ctx, id)
  16378. }
  16379. })
  16380. return value, err
  16381. }
  16382. m.id = &id
  16383. }
  16384. }
  16385. // withLabelTagging sets the old LabelTagging of the mutation.
  16386. func withLabelTagging(node *LabelTagging) labeltaggingOption {
  16387. return func(m *LabelTaggingMutation) {
  16388. m.oldValue = func(context.Context) (*LabelTagging, error) {
  16389. return node, nil
  16390. }
  16391. m.id = &node.ID
  16392. }
  16393. }
  16394. // Client returns a new `ent.Client` from the mutation. If the mutation was
  16395. // executed in a transaction (ent.Tx), a transactional client is returned.
  16396. func (m LabelTaggingMutation) Client() *Client {
  16397. client := &Client{config: m.config}
  16398. client.init()
  16399. return client
  16400. }
  16401. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  16402. // it returns an error otherwise.
  16403. func (m LabelTaggingMutation) Tx() (*Tx, error) {
  16404. if _, ok := m.driver.(*txDriver); !ok {
  16405. return nil, errors.New("ent: mutation is not running in a transaction")
  16406. }
  16407. tx := &Tx{config: m.config}
  16408. tx.init()
  16409. return tx, nil
  16410. }
  16411. // SetID sets the value of the id field. Note that this
  16412. // operation is only accepted on creation of LabelTagging entities.
  16413. func (m *LabelTaggingMutation) SetID(id uint64) {
  16414. m.id = &id
  16415. }
  16416. // ID returns the ID value in the mutation. Note that the ID is only available
  16417. // if it was provided to the builder or after it was returned from the database.
  16418. func (m *LabelTaggingMutation) ID() (id uint64, exists bool) {
  16419. if m.id == nil {
  16420. return
  16421. }
  16422. return *m.id, true
  16423. }
  16424. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  16425. // That means, if the mutation is applied within a transaction with an isolation level such
  16426. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  16427. // or updated by the mutation.
  16428. func (m *LabelTaggingMutation) IDs(ctx context.Context) ([]uint64, error) {
  16429. switch {
  16430. case m.op.Is(OpUpdateOne | OpDeleteOne):
  16431. id, exists := m.ID()
  16432. if exists {
  16433. return []uint64{id}, nil
  16434. }
  16435. fallthrough
  16436. case m.op.Is(OpUpdate | OpDelete):
  16437. return m.Client().LabelTagging.Query().Where(m.predicates...).IDs(ctx)
  16438. default:
  16439. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  16440. }
  16441. }
  16442. // SetCreatedAt sets the "created_at" field.
  16443. func (m *LabelTaggingMutation) SetCreatedAt(t time.Time) {
  16444. m.created_at = &t
  16445. }
  16446. // CreatedAt returns the value of the "created_at" field in the mutation.
  16447. func (m *LabelTaggingMutation) CreatedAt() (r time.Time, exists bool) {
  16448. v := m.created_at
  16449. if v == nil {
  16450. return
  16451. }
  16452. return *v, true
  16453. }
  16454. // OldCreatedAt returns the old "created_at" field's value of the LabelTagging entity.
  16455. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  16456. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16457. func (m *LabelTaggingMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  16458. if !m.op.Is(OpUpdateOne) {
  16459. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  16460. }
  16461. if m.id == nil || m.oldValue == nil {
  16462. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  16463. }
  16464. oldValue, err := m.oldValue(ctx)
  16465. if err != nil {
  16466. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  16467. }
  16468. return oldValue.CreatedAt, nil
  16469. }
  16470. // ResetCreatedAt resets all changes to the "created_at" field.
  16471. func (m *LabelTaggingMutation) ResetCreatedAt() {
  16472. m.created_at = nil
  16473. }
  16474. // SetUpdatedAt sets the "updated_at" field.
  16475. func (m *LabelTaggingMutation) SetUpdatedAt(t time.Time) {
  16476. m.updated_at = &t
  16477. }
  16478. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  16479. func (m *LabelTaggingMutation) UpdatedAt() (r time.Time, exists bool) {
  16480. v := m.updated_at
  16481. if v == nil {
  16482. return
  16483. }
  16484. return *v, true
  16485. }
  16486. // OldUpdatedAt returns the old "updated_at" field's value of the LabelTagging entity.
  16487. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  16488. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16489. func (m *LabelTaggingMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  16490. if !m.op.Is(OpUpdateOne) {
  16491. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  16492. }
  16493. if m.id == nil || m.oldValue == nil {
  16494. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  16495. }
  16496. oldValue, err := m.oldValue(ctx)
  16497. if err != nil {
  16498. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  16499. }
  16500. return oldValue.UpdatedAt, nil
  16501. }
  16502. // ResetUpdatedAt resets all changes to the "updated_at" field.
  16503. func (m *LabelTaggingMutation) ResetUpdatedAt() {
  16504. m.updated_at = nil
  16505. }
  16506. // SetStatus sets the "status" field.
  16507. func (m *LabelTaggingMutation) SetStatus(u uint8) {
  16508. m.status = &u
  16509. m.addstatus = nil
  16510. }
  16511. // Status returns the value of the "status" field in the mutation.
  16512. func (m *LabelTaggingMutation) Status() (r uint8, exists bool) {
  16513. v := m.status
  16514. if v == nil {
  16515. return
  16516. }
  16517. return *v, true
  16518. }
  16519. // OldStatus returns the old "status" field's value of the LabelTagging entity.
  16520. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  16521. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16522. func (m *LabelTaggingMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  16523. if !m.op.Is(OpUpdateOne) {
  16524. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  16525. }
  16526. if m.id == nil || m.oldValue == nil {
  16527. return v, errors.New("OldStatus requires an ID field in the mutation")
  16528. }
  16529. oldValue, err := m.oldValue(ctx)
  16530. if err != nil {
  16531. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  16532. }
  16533. return oldValue.Status, nil
  16534. }
  16535. // AddStatus adds u to the "status" field.
  16536. func (m *LabelTaggingMutation) AddStatus(u int8) {
  16537. if m.addstatus != nil {
  16538. *m.addstatus += u
  16539. } else {
  16540. m.addstatus = &u
  16541. }
  16542. }
  16543. // AddedStatus returns the value that was added to the "status" field in this mutation.
  16544. func (m *LabelTaggingMutation) AddedStatus() (r int8, exists bool) {
  16545. v := m.addstatus
  16546. if v == nil {
  16547. return
  16548. }
  16549. return *v, true
  16550. }
  16551. // ClearStatus clears the value of the "status" field.
  16552. func (m *LabelTaggingMutation) ClearStatus() {
  16553. m.status = nil
  16554. m.addstatus = nil
  16555. m.clearedFields[labeltagging.FieldStatus] = struct{}{}
  16556. }
  16557. // StatusCleared returns if the "status" field was cleared in this mutation.
  16558. func (m *LabelTaggingMutation) StatusCleared() bool {
  16559. _, ok := m.clearedFields[labeltagging.FieldStatus]
  16560. return ok
  16561. }
  16562. // ResetStatus resets all changes to the "status" field.
  16563. func (m *LabelTaggingMutation) ResetStatus() {
  16564. m.status = nil
  16565. m.addstatus = nil
  16566. delete(m.clearedFields, labeltagging.FieldStatus)
  16567. }
  16568. // SetDeletedAt sets the "deleted_at" field.
  16569. func (m *LabelTaggingMutation) SetDeletedAt(t time.Time) {
  16570. m.deleted_at = &t
  16571. }
  16572. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  16573. func (m *LabelTaggingMutation) DeletedAt() (r time.Time, exists bool) {
  16574. v := m.deleted_at
  16575. if v == nil {
  16576. return
  16577. }
  16578. return *v, true
  16579. }
  16580. // OldDeletedAt returns the old "deleted_at" field's value of the LabelTagging entity.
  16581. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  16582. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16583. func (m *LabelTaggingMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  16584. if !m.op.Is(OpUpdateOne) {
  16585. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  16586. }
  16587. if m.id == nil || m.oldValue == nil {
  16588. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  16589. }
  16590. oldValue, err := m.oldValue(ctx)
  16591. if err != nil {
  16592. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  16593. }
  16594. return oldValue.DeletedAt, nil
  16595. }
  16596. // ClearDeletedAt clears the value of the "deleted_at" field.
  16597. func (m *LabelTaggingMutation) ClearDeletedAt() {
  16598. m.deleted_at = nil
  16599. m.clearedFields[labeltagging.FieldDeletedAt] = struct{}{}
  16600. }
  16601. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  16602. func (m *LabelTaggingMutation) DeletedAtCleared() bool {
  16603. _, ok := m.clearedFields[labeltagging.FieldDeletedAt]
  16604. return ok
  16605. }
  16606. // ResetDeletedAt resets all changes to the "deleted_at" field.
  16607. func (m *LabelTaggingMutation) ResetDeletedAt() {
  16608. m.deleted_at = nil
  16609. delete(m.clearedFields, labeltagging.FieldDeletedAt)
  16610. }
  16611. // SetOrganizationID sets the "organization_id" field.
  16612. func (m *LabelTaggingMutation) SetOrganizationID(u uint64) {
  16613. m.organization_id = &u
  16614. m.addorganization_id = nil
  16615. }
  16616. // OrganizationID returns the value of the "organization_id" field in the mutation.
  16617. func (m *LabelTaggingMutation) OrganizationID() (r uint64, exists bool) {
  16618. v := m.organization_id
  16619. if v == nil {
  16620. return
  16621. }
  16622. return *v, true
  16623. }
  16624. // OldOrganizationID returns the old "organization_id" field's value of the LabelTagging entity.
  16625. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  16626. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16627. func (m *LabelTaggingMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  16628. if !m.op.Is(OpUpdateOne) {
  16629. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  16630. }
  16631. if m.id == nil || m.oldValue == nil {
  16632. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  16633. }
  16634. oldValue, err := m.oldValue(ctx)
  16635. if err != nil {
  16636. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  16637. }
  16638. return oldValue.OrganizationID, nil
  16639. }
  16640. // AddOrganizationID adds u to the "organization_id" field.
  16641. func (m *LabelTaggingMutation) AddOrganizationID(u int64) {
  16642. if m.addorganization_id != nil {
  16643. *m.addorganization_id += u
  16644. } else {
  16645. m.addorganization_id = &u
  16646. }
  16647. }
  16648. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  16649. func (m *LabelTaggingMutation) AddedOrganizationID() (r int64, exists bool) {
  16650. v := m.addorganization_id
  16651. if v == nil {
  16652. return
  16653. }
  16654. return *v, true
  16655. }
  16656. // ResetOrganizationID resets all changes to the "organization_id" field.
  16657. func (m *LabelTaggingMutation) ResetOrganizationID() {
  16658. m.organization_id = nil
  16659. m.addorganization_id = nil
  16660. }
  16661. // SetType sets the "type" field.
  16662. func (m *LabelTaggingMutation) SetType(i int) {
  16663. m._type = &i
  16664. m.add_type = nil
  16665. }
  16666. // GetType returns the value of the "type" field in the mutation.
  16667. func (m *LabelTaggingMutation) GetType() (r int, exists bool) {
  16668. v := m._type
  16669. if v == nil {
  16670. return
  16671. }
  16672. return *v, true
  16673. }
  16674. // OldType returns the old "type" field's value of the LabelTagging entity.
  16675. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  16676. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16677. func (m *LabelTaggingMutation) OldType(ctx context.Context) (v int, err error) {
  16678. if !m.op.Is(OpUpdateOne) {
  16679. return v, errors.New("OldType is only allowed on UpdateOne operations")
  16680. }
  16681. if m.id == nil || m.oldValue == nil {
  16682. return v, errors.New("OldType requires an ID field in the mutation")
  16683. }
  16684. oldValue, err := m.oldValue(ctx)
  16685. if err != nil {
  16686. return v, fmt.Errorf("querying old value for OldType: %w", err)
  16687. }
  16688. return oldValue.Type, nil
  16689. }
  16690. // AddType adds i to the "type" field.
  16691. func (m *LabelTaggingMutation) AddType(i int) {
  16692. if m.add_type != nil {
  16693. *m.add_type += i
  16694. } else {
  16695. m.add_type = &i
  16696. }
  16697. }
  16698. // AddedType returns the value that was added to the "type" field in this mutation.
  16699. func (m *LabelTaggingMutation) AddedType() (r int, exists bool) {
  16700. v := m.add_type
  16701. if v == nil {
  16702. return
  16703. }
  16704. return *v, true
  16705. }
  16706. // ResetType resets all changes to the "type" field.
  16707. func (m *LabelTaggingMutation) ResetType() {
  16708. m._type = nil
  16709. m.add_type = nil
  16710. }
  16711. // SetConditions sets the "conditions" field.
  16712. func (m *LabelTaggingMutation) SetConditions(s string) {
  16713. m.conditions = &s
  16714. }
  16715. // Conditions returns the value of the "conditions" field in the mutation.
  16716. func (m *LabelTaggingMutation) Conditions() (r string, exists bool) {
  16717. v := m.conditions
  16718. if v == nil {
  16719. return
  16720. }
  16721. return *v, true
  16722. }
  16723. // OldConditions returns the old "conditions" field's value of the LabelTagging entity.
  16724. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  16725. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16726. func (m *LabelTaggingMutation) OldConditions(ctx context.Context) (v string, err error) {
  16727. if !m.op.Is(OpUpdateOne) {
  16728. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  16729. }
  16730. if m.id == nil || m.oldValue == nil {
  16731. return v, errors.New("OldConditions requires an ID field in the mutation")
  16732. }
  16733. oldValue, err := m.oldValue(ctx)
  16734. if err != nil {
  16735. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  16736. }
  16737. return oldValue.Conditions, nil
  16738. }
  16739. // ResetConditions resets all changes to the "conditions" field.
  16740. func (m *LabelTaggingMutation) ResetConditions() {
  16741. m.conditions = nil
  16742. }
  16743. // SetActionLabelAdd sets the "action_label_add" field.
  16744. func (m *LabelTaggingMutation) SetActionLabelAdd(u []uint64) {
  16745. m.action_label_add = &u
  16746. m.appendaction_label_add = nil
  16747. }
  16748. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  16749. func (m *LabelTaggingMutation) ActionLabelAdd() (r []uint64, exists bool) {
  16750. v := m.action_label_add
  16751. if v == nil {
  16752. return
  16753. }
  16754. return *v, true
  16755. }
  16756. // OldActionLabelAdd returns the old "action_label_add" field's value of the LabelTagging entity.
  16757. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  16758. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16759. func (m *LabelTaggingMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  16760. if !m.op.Is(OpUpdateOne) {
  16761. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  16762. }
  16763. if m.id == nil || m.oldValue == nil {
  16764. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  16765. }
  16766. oldValue, err := m.oldValue(ctx)
  16767. if err != nil {
  16768. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  16769. }
  16770. return oldValue.ActionLabelAdd, nil
  16771. }
  16772. // AppendActionLabelAdd adds u to the "action_label_add" field.
  16773. func (m *LabelTaggingMutation) AppendActionLabelAdd(u []uint64) {
  16774. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  16775. }
  16776. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  16777. func (m *LabelTaggingMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  16778. if len(m.appendaction_label_add) == 0 {
  16779. return nil, false
  16780. }
  16781. return m.appendaction_label_add, true
  16782. }
  16783. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  16784. func (m *LabelTaggingMutation) ClearActionLabelAdd() {
  16785. m.action_label_add = nil
  16786. m.appendaction_label_add = nil
  16787. m.clearedFields[labeltagging.FieldActionLabelAdd] = struct{}{}
  16788. }
  16789. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  16790. func (m *LabelTaggingMutation) ActionLabelAddCleared() bool {
  16791. _, ok := m.clearedFields[labeltagging.FieldActionLabelAdd]
  16792. return ok
  16793. }
  16794. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  16795. func (m *LabelTaggingMutation) ResetActionLabelAdd() {
  16796. m.action_label_add = nil
  16797. m.appendaction_label_add = nil
  16798. delete(m.clearedFields, labeltagging.FieldActionLabelAdd)
  16799. }
  16800. // SetActionLabelDel sets the "action_label_del" field.
  16801. func (m *LabelTaggingMutation) SetActionLabelDel(u []uint64) {
  16802. m.action_label_del = &u
  16803. m.appendaction_label_del = nil
  16804. }
  16805. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  16806. func (m *LabelTaggingMutation) ActionLabelDel() (r []uint64, exists bool) {
  16807. v := m.action_label_del
  16808. if v == nil {
  16809. return
  16810. }
  16811. return *v, true
  16812. }
  16813. // OldActionLabelDel returns the old "action_label_del" field's value of the LabelTagging entity.
  16814. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  16815. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16816. func (m *LabelTaggingMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  16817. if !m.op.Is(OpUpdateOne) {
  16818. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  16819. }
  16820. if m.id == nil || m.oldValue == nil {
  16821. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  16822. }
  16823. oldValue, err := m.oldValue(ctx)
  16824. if err != nil {
  16825. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  16826. }
  16827. return oldValue.ActionLabelDel, nil
  16828. }
  16829. // AppendActionLabelDel adds u to the "action_label_del" field.
  16830. func (m *LabelTaggingMutation) AppendActionLabelDel(u []uint64) {
  16831. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  16832. }
  16833. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  16834. func (m *LabelTaggingMutation) AppendedActionLabelDel() ([]uint64, bool) {
  16835. if len(m.appendaction_label_del) == 0 {
  16836. return nil, false
  16837. }
  16838. return m.appendaction_label_del, true
  16839. }
  16840. // ClearActionLabelDel clears the value of the "action_label_del" field.
  16841. func (m *LabelTaggingMutation) ClearActionLabelDel() {
  16842. m.action_label_del = nil
  16843. m.appendaction_label_del = nil
  16844. m.clearedFields[labeltagging.FieldActionLabelDel] = struct{}{}
  16845. }
  16846. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  16847. func (m *LabelTaggingMutation) ActionLabelDelCleared() bool {
  16848. _, ok := m.clearedFields[labeltagging.FieldActionLabelDel]
  16849. return ok
  16850. }
  16851. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  16852. func (m *LabelTaggingMutation) ResetActionLabelDel() {
  16853. m.action_label_del = nil
  16854. m.appendaction_label_del = nil
  16855. delete(m.clearedFields, labeltagging.FieldActionLabelDel)
  16856. }
  16857. // Where appends a list predicates to the LabelTaggingMutation builder.
  16858. func (m *LabelTaggingMutation) Where(ps ...predicate.LabelTagging) {
  16859. m.predicates = append(m.predicates, ps...)
  16860. }
  16861. // WhereP appends storage-level predicates to the LabelTaggingMutation builder. Using this method,
  16862. // users can use type-assertion to append predicates that do not depend on any generated package.
  16863. func (m *LabelTaggingMutation) WhereP(ps ...func(*sql.Selector)) {
  16864. p := make([]predicate.LabelTagging, len(ps))
  16865. for i := range ps {
  16866. p[i] = ps[i]
  16867. }
  16868. m.Where(p...)
  16869. }
  16870. // Op returns the operation name.
  16871. func (m *LabelTaggingMutation) Op() Op {
  16872. return m.op
  16873. }
  16874. // SetOp allows setting the mutation operation.
  16875. func (m *LabelTaggingMutation) SetOp(op Op) {
  16876. m.op = op
  16877. }
  16878. // Type returns the node type of this mutation (LabelTagging).
  16879. func (m *LabelTaggingMutation) Type() string {
  16880. return m.typ
  16881. }
  16882. // Fields returns all fields that were changed during this mutation. Note that in
  16883. // order to get all numeric fields that were incremented/decremented, call
  16884. // AddedFields().
  16885. func (m *LabelTaggingMutation) Fields() []string {
  16886. fields := make([]string, 0, 9)
  16887. if m.created_at != nil {
  16888. fields = append(fields, labeltagging.FieldCreatedAt)
  16889. }
  16890. if m.updated_at != nil {
  16891. fields = append(fields, labeltagging.FieldUpdatedAt)
  16892. }
  16893. if m.status != nil {
  16894. fields = append(fields, labeltagging.FieldStatus)
  16895. }
  16896. if m.deleted_at != nil {
  16897. fields = append(fields, labeltagging.FieldDeletedAt)
  16898. }
  16899. if m.organization_id != nil {
  16900. fields = append(fields, labeltagging.FieldOrganizationID)
  16901. }
  16902. if m._type != nil {
  16903. fields = append(fields, labeltagging.FieldType)
  16904. }
  16905. if m.conditions != nil {
  16906. fields = append(fields, labeltagging.FieldConditions)
  16907. }
  16908. if m.action_label_add != nil {
  16909. fields = append(fields, labeltagging.FieldActionLabelAdd)
  16910. }
  16911. if m.action_label_del != nil {
  16912. fields = append(fields, labeltagging.FieldActionLabelDel)
  16913. }
  16914. return fields
  16915. }
  16916. // Field returns the value of a field with the given name. The second boolean
  16917. // return value indicates that this field was not set, or was not defined in the
  16918. // schema.
  16919. func (m *LabelTaggingMutation) Field(name string) (ent.Value, bool) {
  16920. switch name {
  16921. case labeltagging.FieldCreatedAt:
  16922. return m.CreatedAt()
  16923. case labeltagging.FieldUpdatedAt:
  16924. return m.UpdatedAt()
  16925. case labeltagging.FieldStatus:
  16926. return m.Status()
  16927. case labeltagging.FieldDeletedAt:
  16928. return m.DeletedAt()
  16929. case labeltagging.FieldOrganizationID:
  16930. return m.OrganizationID()
  16931. case labeltagging.FieldType:
  16932. return m.GetType()
  16933. case labeltagging.FieldConditions:
  16934. return m.Conditions()
  16935. case labeltagging.FieldActionLabelAdd:
  16936. return m.ActionLabelAdd()
  16937. case labeltagging.FieldActionLabelDel:
  16938. return m.ActionLabelDel()
  16939. }
  16940. return nil, false
  16941. }
  16942. // OldField returns the old value of the field from the database. An error is
  16943. // returned if the mutation operation is not UpdateOne, or the query to the
  16944. // database failed.
  16945. func (m *LabelTaggingMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  16946. switch name {
  16947. case labeltagging.FieldCreatedAt:
  16948. return m.OldCreatedAt(ctx)
  16949. case labeltagging.FieldUpdatedAt:
  16950. return m.OldUpdatedAt(ctx)
  16951. case labeltagging.FieldStatus:
  16952. return m.OldStatus(ctx)
  16953. case labeltagging.FieldDeletedAt:
  16954. return m.OldDeletedAt(ctx)
  16955. case labeltagging.FieldOrganizationID:
  16956. return m.OldOrganizationID(ctx)
  16957. case labeltagging.FieldType:
  16958. return m.OldType(ctx)
  16959. case labeltagging.FieldConditions:
  16960. return m.OldConditions(ctx)
  16961. case labeltagging.FieldActionLabelAdd:
  16962. return m.OldActionLabelAdd(ctx)
  16963. case labeltagging.FieldActionLabelDel:
  16964. return m.OldActionLabelDel(ctx)
  16965. }
  16966. return nil, fmt.Errorf("unknown LabelTagging field %s", name)
  16967. }
  16968. // SetField sets the value of a field with the given name. It returns an error if
  16969. // the field is not defined in the schema, or if the type mismatched the field
  16970. // type.
  16971. func (m *LabelTaggingMutation) SetField(name string, value ent.Value) error {
  16972. switch name {
  16973. case labeltagging.FieldCreatedAt:
  16974. v, ok := value.(time.Time)
  16975. if !ok {
  16976. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16977. }
  16978. m.SetCreatedAt(v)
  16979. return nil
  16980. case labeltagging.FieldUpdatedAt:
  16981. v, ok := value.(time.Time)
  16982. if !ok {
  16983. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16984. }
  16985. m.SetUpdatedAt(v)
  16986. return nil
  16987. case labeltagging.FieldStatus:
  16988. v, ok := value.(uint8)
  16989. if !ok {
  16990. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16991. }
  16992. m.SetStatus(v)
  16993. return nil
  16994. case labeltagging.FieldDeletedAt:
  16995. v, ok := value.(time.Time)
  16996. if !ok {
  16997. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16998. }
  16999. m.SetDeletedAt(v)
  17000. return nil
  17001. case labeltagging.FieldOrganizationID:
  17002. v, ok := value.(uint64)
  17003. if !ok {
  17004. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17005. }
  17006. m.SetOrganizationID(v)
  17007. return nil
  17008. case labeltagging.FieldType:
  17009. v, ok := value.(int)
  17010. if !ok {
  17011. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17012. }
  17013. m.SetType(v)
  17014. return nil
  17015. case labeltagging.FieldConditions:
  17016. v, ok := value.(string)
  17017. if !ok {
  17018. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17019. }
  17020. m.SetConditions(v)
  17021. return nil
  17022. case labeltagging.FieldActionLabelAdd:
  17023. v, ok := value.([]uint64)
  17024. if !ok {
  17025. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17026. }
  17027. m.SetActionLabelAdd(v)
  17028. return nil
  17029. case labeltagging.FieldActionLabelDel:
  17030. v, ok := value.([]uint64)
  17031. if !ok {
  17032. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17033. }
  17034. m.SetActionLabelDel(v)
  17035. return nil
  17036. }
  17037. return fmt.Errorf("unknown LabelTagging field %s", name)
  17038. }
  17039. // AddedFields returns all numeric fields that were incremented/decremented during
  17040. // this mutation.
  17041. func (m *LabelTaggingMutation) AddedFields() []string {
  17042. var fields []string
  17043. if m.addstatus != nil {
  17044. fields = append(fields, labeltagging.FieldStatus)
  17045. }
  17046. if m.addorganization_id != nil {
  17047. fields = append(fields, labeltagging.FieldOrganizationID)
  17048. }
  17049. if m.add_type != nil {
  17050. fields = append(fields, labeltagging.FieldType)
  17051. }
  17052. return fields
  17053. }
  17054. // AddedField returns the numeric value that was incremented/decremented on a field
  17055. // with the given name. The second boolean return value indicates that this field
  17056. // was not set, or was not defined in the schema.
  17057. func (m *LabelTaggingMutation) AddedField(name string) (ent.Value, bool) {
  17058. switch name {
  17059. case labeltagging.FieldStatus:
  17060. return m.AddedStatus()
  17061. case labeltagging.FieldOrganizationID:
  17062. return m.AddedOrganizationID()
  17063. case labeltagging.FieldType:
  17064. return m.AddedType()
  17065. }
  17066. return nil, false
  17067. }
  17068. // AddField adds the value to the field with the given name. It returns an error if
  17069. // the field is not defined in the schema, or if the type mismatched the field
  17070. // type.
  17071. func (m *LabelTaggingMutation) AddField(name string, value ent.Value) error {
  17072. switch name {
  17073. case labeltagging.FieldStatus:
  17074. v, ok := value.(int8)
  17075. if !ok {
  17076. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17077. }
  17078. m.AddStatus(v)
  17079. return nil
  17080. case labeltagging.FieldOrganizationID:
  17081. v, ok := value.(int64)
  17082. if !ok {
  17083. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17084. }
  17085. m.AddOrganizationID(v)
  17086. return nil
  17087. case labeltagging.FieldType:
  17088. v, ok := value.(int)
  17089. if !ok {
  17090. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17091. }
  17092. m.AddType(v)
  17093. return nil
  17094. }
  17095. return fmt.Errorf("unknown LabelTagging numeric field %s", name)
  17096. }
  17097. // ClearedFields returns all nullable fields that were cleared during this
  17098. // mutation.
  17099. func (m *LabelTaggingMutation) ClearedFields() []string {
  17100. var fields []string
  17101. if m.FieldCleared(labeltagging.FieldStatus) {
  17102. fields = append(fields, labeltagging.FieldStatus)
  17103. }
  17104. if m.FieldCleared(labeltagging.FieldDeletedAt) {
  17105. fields = append(fields, labeltagging.FieldDeletedAt)
  17106. }
  17107. if m.FieldCleared(labeltagging.FieldActionLabelAdd) {
  17108. fields = append(fields, labeltagging.FieldActionLabelAdd)
  17109. }
  17110. if m.FieldCleared(labeltagging.FieldActionLabelDel) {
  17111. fields = append(fields, labeltagging.FieldActionLabelDel)
  17112. }
  17113. return fields
  17114. }
  17115. // FieldCleared returns a boolean indicating if a field with the given name was
  17116. // cleared in this mutation.
  17117. func (m *LabelTaggingMutation) FieldCleared(name string) bool {
  17118. _, ok := m.clearedFields[name]
  17119. return ok
  17120. }
  17121. // ClearField clears the value of the field with the given name. It returns an
  17122. // error if the field is not defined in the schema.
  17123. func (m *LabelTaggingMutation) ClearField(name string) error {
  17124. switch name {
  17125. case labeltagging.FieldStatus:
  17126. m.ClearStatus()
  17127. return nil
  17128. case labeltagging.FieldDeletedAt:
  17129. m.ClearDeletedAt()
  17130. return nil
  17131. case labeltagging.FieldActionLabelAdd:
  17132. m.ClearActionLabelAdd()
  17133. return nil
  17134. case labeltagging.FieldActionLabelDel:
  17135. m.ClearActionLabelDel()
  17136. return nil
  17137. }
  17138. return fmt.Errorf("unknown LabelTagging nullable field %s", name)
  17139. }
  17140. // ResetField resets all changes in the mutation for the field with the given name.
  17141. // It returns an error if the field is not defined in the schema.
  17142. func (m *LabelTaggingMutation) ResetField(name string) error {
  17143. switch name {
  17144. case labeltagging.FieldCreatedAt:
  17145. m.ResetCreatedAt()
  17146. return nil
  17147. case labeltagging.FieldUpdatedAt:
  17148. m.ResetUpdatedAt()
  17149. return nil
  17150. case labeltagging.FieldStatus:
  17151. m.ResetStatus()
  17152. return nil
  17153. case labeltagging.FieldDeletedAt:
  17154. m.ResetDeletedAt()
  17155. return nil
  17156. case labeltagging.FieldOrganizationID:
  17157. m.ResetOrganizationID()
  17158. return nil
  17159. case labeltagging.FieldType:
  17160. m.ResetType()
  17161. return nil
  17162. case labeltagging.FieldConditions:
  17163. m.ResetConditions()
  17164. return nil
  17165. case labeltagging.FieldActionLabelAdd:
  17166. m.ResetActionLabelAdd()
  17167. return nil
  17168. case labeltagging.FieldActionLabelDel:
  17169. m.ResetActionLabelDel()
  17170. return nil
  17171. }
  17172. return fmt.Errorf("unknown LabelTagging field %s", name)
  17173. }
  17174. // AddedEdges returns all edge names that were set/added in this mutation.
  17175. func (m *LabelTaggingMutation) AddedEdges() []string {
  17176. edges := make([]string, 0, 0)
  17177. return edges
  17178. }
  17179. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  17180. // name in this mutation.
  17181. func (m *LabelTaggingMutation) AddedIDs(name string) []ent.Value {
  17182. return nil
  17183. }
  17184. // RemovedEdges returns all edge names that were removed in this mutation.
  17185. func (m *LabelTaggingMutation) RemovedEdges() []string {
  17186. edges := make([]string, 0, 0)
  17187. return edges
  17188. }
  17189. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  17190. // the given name in this mutation.
  17191. func (m *LabelTaggingMutation) RemovedIDs(name string) []ent.Value {
  17192. return nil
  17193. }
  17194. // ClearedEdges returns all edge names that were cleared in this mutation.
  17195. func (m *LabelTaggingMutation) ClearedEdges() []string {
  17196. edges := make([]string, 0, 0)
  17197. return edges
  17198. }
  17199. // EdgeCleared returns a boolean which indicates if the edge with the given name
  17200. // was cleared in this mutation.
  17201. func (m *LabelTaggingMutation) EdgeCleared(name string) bool {
  17202. return false
  17203. }
  17204. // ClearEdge clears the value of the edge with the given name. It returns an error
  17205. // if that edge is not defined in the schema.
  17206. func (m *LabelTaggingMutation) ClearEdge(name string) error {
  17207. return fmt.Errorf("unknown LabelTagging unique edge %s", name)
  17208. }
  17209. // ResetEdge resets all changes to the edge with the given name in this mutation.
  17210. // It returns an error if the edge is not defined in the schema.
  17211. func (m *LabelTaggingMutation) ResetEdge(name string) error {
  17212. return fmt.Errorf("unknown LabelTagging edge %s", name)
  17213. }
  17214. // MessageMutation represents an operation that mutates the Message nodes in the graph.
  17215. type MessageMutation struct {
  17216. config
  17217. op Op
  17218. typ string
  17219. id *int
  17220. wx_wxid *string
  17221. wxid *string
  17222. content *string
  17223. clearedFields map[string]struct{}
  17224. done bool
  17225. oldValue func(context.Context) (*Message, error)
  17226. predicates []predicate.Message
  17227. }
  17228. var _ ent.Mutation = (*MessageMutation)(nil)
  17229. // messageOption allows management of the mutation configuration using functional options.
  17230. type messageOption func(*MessageMutation)
  17231. // newMessageMutation creates new mutation for the Message entity.
  17232. func newMessageMutation(c config, op Op, opts ...messageOption) *MessageMutation {
  17233. m := &MessageMutation{
  17234. config: c,
  17235. op: op,
  17236. typ: TypeMessage,
  17237. clearedFields: make(map[string]struct{}),
  17238. }
  17239. for _, opt := range opts {
  17240. opt(m)
  17241. }
  17242. return m
  17243. }
  17244. // withMessageID sets the ID field of the mutation.
  17245. func withMessageID(id int) messageOption {
  17246. return func(m *MessageMutation) {
  17247. var (
  17248. err error
  17249. once sync.Once
  17250. value *Message
  17251. )
  17252. m.oldValue = func(ctx context.Context) (*Message, error) {
  17253. once.Do(func() {
  17254. if m.done {
  17255. err = errors.New("querying old values post mutation is not allowed")
  17256. } else {
  17257. value, err = m.Client().Message.Get(ctx, id)
  17258. }
  17259. })
  17260. return value, err
  17261. }
  17262. m.id = &id
  17263. }
  17264. }
  17265. // withMessage sets the old Message of the mutation.
  17266. func withMessage(node *Message) messageOption {
  17267. return func(m *MessageMutation) {
  17268. m.oldValue = func(context.Context) (*Message, error) {
  17269. return node, nil
  17270. }
  17271. m.id = &node.ID
  17272. }
  17273. }
  17274. // Client returns a new `ent.Client` from the mutation. If the mutation was
  17275. // executed in a transaction (ent.Tx), a transactional client is returned.
  17276. func (m MessageMutation) Client() *Client {
  17277. client := &Client{config: m.config}
  17278. client.init()
  17279. return client
  17280. }
  17281. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  17282. // it returns an error otherwise.
  17283. func (m MessageMutation) Tx() (*Tx, error) {
  17284. if _, ok := m.driver.(*txDriver); !ok {
  17285. return nil, errors.New("ent: mutation is not running in a transaction")
  17286. }
  17287. tx := &Tx{config: m.config}
  17288. tx.init()
  17289. return tx, nil
  17290. }
  17291. // ID returns the ID value in the mutation. Note that the ID is only available
  17292. // if it was provided to the builder or after it was returned from the database.
  17293. func (m *MessageMutation) ID() (id int, exists bool) {
  17294. if m.id == nil {
  17295. return
  17296. }
  17297. return *m.id, true
  17298. }
  17299. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  17300. // That means, if the mutation is applied within a transaction with an isolation level such
  17301. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  17302. // or updated by the mutation.
  17303. func (m *MessageMutation) IDs(ctx context.Context) ([]int, error) {
  17304. switch {
  17305. case m.op.Is(OpUpdateOne | OpDeleteOne):
  17306. id, exists := m.ID()
  17307. if exists {
  17308. return []int{id}, nil
  17309. }
  17310. fallthrough
  17311. case m.op.Is(OpUpdate | OpDelete):
  17312. return m.Client().Message.Query().Where(m.predicates...).IDs(ctx)
  17313. default:
  17314. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  17315. }
  17316. }
  17317. // SetWxWxid sets the "wx_wxid" field.
  17318. func (m *MessageMutation) SetWxWxid(s string) {
  17319. m.wx_wxid = &s
  17320. }
  17321. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  17322. func (m *MessageMutation) WxWxid() (r string, exists bool) {
  17323. v := m.wx_wxid
  17324. if v == nil {
  17325. return
  17326. }
  17327. return *v, true
  17328. }
  17329. // OldWxWxid returns the old "wx_wxid" field's value of the Message entity.
  17330. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  17331. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17332. func (m *MessageMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  17333. if !m.op.Is(OpUpdateOne) {
  17334. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  17335. }
  17336. if m.id == nil || m.oldValue == nil {
  17337. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  17338. }
  17339. oldValue, err := m.oldValue(ctx)
  17340. if err != nil {
  17341. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  17342. }
  17343. return oldValue.WxWxid, nil
  17344. }
  17345. // ClearWxWxid clears the value of the "wx_wxid" field.
  17346. func (m *MessageMutation) ClearWxWxid() {
  17347. m.wx_wxid = nil
  17348. m.clearedFields[message.FieldWxWxid] = struct{}{}
  17349. }
  17350. // WxWxidCleared returns if the "wx_wxid" field was cleared in this mutation.
  17351. func (m *MessageMutation) WxWxidCleared() bool {
  17352. _, ok := m.clearedFields[message.FieldWxWxid]
  17353. return ok
  17354. }
  17355. // ResetWxWxid resets all changes to the "wx_wxid" field.
  17356. func (m *MessageMutation) ResetWxWxid() {
  17357. m.wx_wxid = nil
  17358. delete(m.clearedFields, message.FieldWxWxid)
  17359. }
  17360. // SetWxid sets the "wxid" field.
  17361. func (m *MessageMutation) SetWxid(s string) {
  17362. m.wxid = &s
  17363. }
  17364. // Wxid returns the value of the "wxid" field in the mutation.
  17365. func (m *MessageMutation) Wxid() (r string, exists bool) {
  17366. v := m.wxid
  17367. if v == nil {
  17368. return
  17369. }
  17370. return *v, true
  17371. }
  17372. // OldWxid returns the old "wxid" field's value of the Message entity.
  17373. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  17374. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17375. func (m *MessageMutation) OldWxid(ctx context.Context) (v string, err error) {
  17376. if !m.op.Is(OpUpdateOne) {
  17377. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  17378. }
  17379. if m.id == nil || m.oldValue == nil {
  17380. return v, errors.New("OldWxid requires an ID field in the mutation")
  17381. }
  17382. oldValue, err := m.oldValue(ctx)
  17383. if err != nil {
  17384. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  17385. }
  17386. return oldValue.Wxid, nil
  17387. }
  17388. // ResetWxid resets all changes to the "wxid" field.
  17389. func (m *MessageMutation) ResetWxid() {
  17390. m.wxid = nil
  17391. }
  17392. // SetContent sets the "content" field.
  17393. func (m *MessageMutation) SetContent(s string) {
  17394. m.content = &s
  17395. }
  17396. // Content returns the value of the "content" field in the mutation.
  17397. func (m *MessageMutation) Content() (r string, exists bool) {
  17398. v := m.content
  17399. if v == nil {
  17400. return
  17401. }
  17402. return *v, true
  17403. }
  17404. // OldContent returns the old "content" field's value of the Message entity.
  17405. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  17406. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17407. func (m *MessageMutation) OldContent(ctx context.Context) (v string, err error) {
  17408. if !m.op.Is(OpUpdateOne) {
  17409. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  17410. }
  17411. if m.id == nil || m.oldValue == nil {
  17412. return v, errors.New("OldContent requires an ID field in the mutation")
  17413. }
  17414. oldValue, err := m.oldValue(ctx)
  17415. if err != nil {
  17416. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  17417. }
  17418. return oldValue.Content, nil
  17419. }
  17420. // ResetContent resets all changes to the "content" field.
  17421. func (m *MessageMutation) ResetContent() {
  17422. m.content = nil
  17423. }
  17424. // Where appends a list predicates to the MessageMutation builder.
  17425. func (m *MessageMutation) Where(ps ...predicate.Message) {
  17426. m.predicates = append(m.predicates, ps...)
  17427. }
  17428. // WhereP appends storage-level predicates to the MessageMutation builder. Using this method,
  17429. // users can use type-assertion to append predicates that do not depend on any generated package.
  17430. func (m *MessageMutation) WhereP(ps ...func(*sql.Selector)) {
  17431. p := make([]predicate.Message, len(ps))
  17432. for i := range ps {
  17433. p[i] = ps[i]
  17434. }
  17435. m.Where(p...)
  17436. }
  17437. // Op returns the operation name.
  17438. func (m *MessageMutation) Op() Op {
  17439. return m.op
  17440. }
  17441. // SetOp allows setting the mutation operation.
  17442. func (m *MessageMutation) SetOp(op Op) {
  17443. m.op = op
  17444. }
  17445. // Type returns the node type of this mutation (Message).
  17446. func (m *MessageMutation) Type() string {
  17447. return m.typ
  17448. }
  17449. // Fields returns all fields that were changed during this mutation. Note that in
  17450. // order to get all numeric fields that were incremented/decremented, call
  17451. // AddedFields().
  17452. func (m *MessageMutation) Fields() []string {
  17453. fields := make([]string, 0, 3)
  17454. if m.wx_wxid != nil {
  17455. fields = append(fields, message.FieldWxWxid)
  17456. }
  17457. if m.wxid != nil {
  17458. fields = append(fields, message.FieldWxid)
  17459. }
  17460. if m.content != nil {
  17461. fields = append(fields, message.FieldContent)
  17462. }
  17463. return fields
  17464. }
  17465. // Field returns the value of a field with the given name. The second boolean
  17466. // return value indicates that this field was not set, or was not defined in the
  17467. // schema.
  17468. func (m *MessageMutation) Field(name string) (ent.Value, bool) {
  17469. switch name {
  17470. case message.FieldWxWxid:
  17471. return m.WxWxid()
  17472. case message.FieldWxid:
  17473. return m.Wxid()
  17474. case message.FieldContent:
  17475. return m.Content()
  17476. }
  17477. return nil, false
  17478. }
  17479. // OldField returns the old value of the field from the database. An error is
  17480. // returned if the mutation operation is not UpdateOne, or the query to the
  17481. // database failed.
  17482. func (m *MessageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  17483. switch name {
  17484. case message.FieldWxWxid:
  17485. return m.OldWxWxid(ctx)
  17486. case message.FieldWxid:
  17487. return m.OldWxid(ctx)
  17488. case message.FieldContent:
  17489. return m.OldContent(ctx)
  17490. }
  17491. return nil, fmt.Errorf("unknown Message field %s", name)
  17492. }
  17493. // SetField sets the value of a field with the given name. It returns an error if
  17494. // the field is not defined in the schema, or if the type mismatched the field
  17495. // type.
  17496. func (m *MessageMutation) SetField(name string, value ent.Value) error {
  17497. switch name {
  17498. case message.FieldWxWxid:
  17499. v, ok := value.(string)
  17500. if !ok {
  17501. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17502. }
  17503. m.SetWxWxid(v)
  17504. return nil
  17505. case message.FieldWxid:
  17506. v, ok := value.(string)
  17507. if !ok {
  17508. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17509. }
  17510. m.SetWxid(v)
  17511. return nil
  17512. case message.FieldContent:
  17513. v, ok := value.(string)
  17514. if !ok {
  17515. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17516. }
  17517. m.SetContent(v)
  17518. return nil
  17519. }
  17520. return fmt.Errorf("unknown Message field %s", name)
  17521. }
  17522. // AddedFields returns all numeric fields that were incremented/decremented during
  17523. // this mutation.
  17524. func (m *MessageMutation) AddedFields() []string {
  17525. return nil
  17526. }
  17527. // AddedField returns the numeric value that was incremented/decremented on a field
  17528. // with the given name. The second boolean return value indicates that this field
  17529. // was not set, or was not defined in the schema.
  17530. func (m *MessageMutation) AddedField(name string) (ent.Value, bool) {
  17531. return nil, false
  17532. }
  17533. // AddField adds the value to the field with the given name. It returns an error if
  17534. // the field is not defined in the schema, or if the type mismatched the field
  17535. // type.
  17536. func (m *MessageMutation) AddField(name string, value ent.Value) error {
  17537. switch name {
  17538. }
  17539. return fmt.Errorf("unknown Message numeric field %s", name)
  17540. }
  17541. // ClearedFields returns all nullable fields that were cleared during this
  17542. // mutation.
  17543. func (m *MessageMutation) ClearedFields() []string {
  17544. var fields []string
  17545. if m.FieldCleared(message.FieldWxWxid) {
  17546. fields = append(fields, message.FieldWxWxid)
  17547. }
  17548. return fields
  17549. }
  17550. // FieldCleared returns a boolean indicating if a field with the given name was
  17551. // cleared in this mutation.
  17552. func (m *MessageMutation) FieldCleared(name string) bool {
  17553. _, ok := m.clearedFields[name]
  17554. return ok
  17555. }
  17556. // ClearField clears the value of the field with the given name. It returns an
  17557. // error if the field is not defined in the schema.
  17558. func (m *MessageMutation) ClearField(name string) error {
  17559. switch name {
  17560. case message.FieldWxWxid:
  17561. m.ClearWxWxid()
  17562. return nil
  17563. }
  17564. return fmt.Errorf("unknown Message nullable field %s", name)
  17565. }
  17566. // ResetField resets all changes in the mutation for the field with the given name.
  17567. // It returns an error if the field is not defined in the schema.
  17568. func (m *MessageMutation) ResetField(name string) error {
  17569. switch name {
  17570. case message.FieldWxWxid:
  17571. m.ResetWxWxid()
  17572. return nil
  17573. case message.FieldWxid:
  17574. m.ResetWxid()
  17575. return nil
  17576. case message.FieldContent:
  17577. m.ResetContent()
  17578. return nil
  17579. }
  17580. return fmt.Errorf("unknown Message field %s", name)
  17581. }
  17582. // AddedEdges returns all edge names that were set/added in this mutation.
  17583. func (m *MessageMutation) AddedEdges() []string {
  17584. edges := make([]string, 0, 0)
  17585. return edges
  17586. }
  17587. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  17588. // name in this mutation.
  17589. func (m *MessageMutation) AddedIDs(name string) []ent.Value {
  17590. return nil
  17591. }
  17592. // RemovedEdges returns all edge names that were removed in this mutation.
  17593. func (m *MessageMutation) RemovedEdges() []string {
  17594. edges := make([]string, 0, 0)
  17595. return edges
  17596. }
  17597. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  17598. // the given name in this mutation.
  17599. func (m *MessageMutation) RemovedIDs(name string) []ent.Value {
  17600. return nil
  17601. }
  17602. // ClearedEdges returns all edge names that were cleared in this mutation.
  17603. func (m *MessageMutation) ClearedEdges() []string {
  17604. edges := make([]string, 0, 0)
  17605. return edges
  17606. }
  17607. // EdgeCleared returns a boolean which indicates if the edge with the given name
  17608. // was cleared in this mutation.
  17609. func (m *MessageMutation) EdgeCleared(name string) bool {
  17610. return false
  17611. }
  17612. // ClearEdge clears the value of the edge with the given name. It returns an error
  17613. // if that edge is not defined in the schema.
  17614. func (m *MessageMutation) ClearEdge(name string) error {
  17615. return fmt.Errorf("unknown Message unique edge %s", name)
  17616. }
  17617. // ResetEdge resets all changes to the edge with the given name in this mutation.
  17618. // It returns an error if the edge is not defined in the schema.
  17619. func (m *MessageMutation) ResetEdge(name string) error {
  17620. return fmt.Errorf("unknown Message edge %s", name)
  17621. }
  17622. // MessageRecordsMutation represents an operation that mutates the MessageRecords nodes in the graph.
  17623. type MessageRecordsMutation struct {
  17624. config
  17625. op Op
  17626. typ string
  17627. id *uint64
  17628. created_at *time.Time
  17629. updated_at *time.Time
  17630. status *uint8
  17631. addstatus *int8
  17632. bot_wxid *string
  17633. contact_type *int
  17634. addcontact_type *int
  17635. contact_wxid *string
  17636. content_type *int
  17637. addcontent_type *int
  17638. content *string
  17639. meta *custom_types.Meta
  17640. error_detail *string
  17641. send_time *time.Time
  17642. source_type *int
  17643. addsource_type *int
  17644. organization_id *uint64
  17645. addorganization_id *int64
  17646. clearedFields map[string]struct{}
  17647. sop_stage *uint64
  17648. clearedsop_stage bool
  17649. sop_node *uint64
  17650. clearedsop_node bool
  17651. message_contact *uint64
  17652. clearedmessage_contact bool
  17653. done bool
  17654. oldValue func(context.Context) (*MessageRecords, error)
  17655. predicates []predicate.MessageRecords
  17656. }
  17657. var _ ent.Mutation = (*MessageRecordsMutation)(nil)
  17658. // messagerecordsOption allows management of the mutation configuration using functional options.
  17659. type messagerecordsOption func(*MessageRecordsMutation)
  17660. // newMessageRecordsMutation creates new mutation for the MessageRecords entity.
  17661. func newMessageRecordsMutation(c config, op Op, opts ...messagerecordsOption) *MessageRecordsMutation {
  17662. m := &MessageRecordsMutation{
  17663. config: c,
  17664. op: op,
  17665. typ: TypeMessageRecords,
  17666. clearedFields: make(map[string]struct{}),
  17667. }
  17668. for _, opt := range opts {
  17669. opt(m)
  17670. }
  17671. return m
  17672. }
  17673. // withMessageRecordsID sets the ID field of the mutation.
  17674. func withMessageRecordsID(id uint64) messagerecordsOption {
  17675. return func(m *MessageRecordsMutation) {
  17676. var (
  17677. err error
  17678. once sync.Once
  17679. value *MessageRecords
  17680. )
  17681. m.oldValue = func(ctx context.Context) (*MessageRecords, error) {
  17682. once.Do(func() {
  17683. if m.done {
  17684. err = errors.New("querying old values post mutation is not allowed")
  17685. } else {
  17686. value, err = m.Client().MessageRecords.Get(ctx, id)
  17687. }
  17688. })
  17689. return value, err
  17690. }
  17691. m.id = &id
  17692. }
  17693. }
  17694. // withMessageRecords sets the old MessageRecords of the mutation.
  17695. func withMessageRecords(node *MessageRecords) messagerecordsOption {
  17696. return func(m *MessageRecordsMutation) {
  17697. m.oldValue = func(context.Context) (*MessageRecords, error) {
  17698. return node, nil
  17699. }
  17700. m.id = &node.ID
  17701. }
  17702. }
  17703. // Client returns a new `ent.Client` from the mutation. If the mutation was
  17704. // executed in a transaction (ent.Tx), a transactional client is returned.
  17705. func (m MessageRecordsMutation) Client() *Client {
  17706. client := &Client{config: m.config}
  17707. client.init()
  17708. return client
  17709. }
  17710. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  17711. // it returns an error otherwise.
  17712. func (m MessageRecordsMutation) Tx() (*Tx, error) {
  17713. if _, ok := m.driver.(*txDriver); !ok {
  17714. return nil, errors.New("ent: mutation is not running in a transaction")
  17715. }
  17716. tx := &Tx{config: m.config}
  17717. tx.init()
  17718. return tx, nil
  17719. }
  17720. // SetID sets the value of the id field. Note that this
  17721. // operation is only accepted on creation of MessageRecords entities.
  17722. func (m *MessageRecordsMutation) SetID(id uint64) {
  17723. m.id = &id
  17724. }
  17725. // ID returns the ID value in the mutation. Note that the ID is only available
  17726. // if it was provided to the builder or after it was returned from the database.
  17727. func (m *MessageRecordsMutation) ID() (id uint64, exists bool) {
  17728. if m.id == nil {
  17729. return
  17730. }
  17731. return *m.id, true
  17732. }
  17733. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  17734. // That means, if the mutation is applied within a transaction with an isolation level such
  17735. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  17736. // or updated by the mutation.
  17737. func (m *MessageRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  17738. switch {
  17739. case m.op.Is(OpUpdateOne | OpDeleteOne):
  17740. id, exists := m.ID()
  17741. if exists {
  17742. return []uint64{id}, nil
  17743. }
  17744. fallthrough
  17745. case m.op.Is(OpUpdate | OpDelete):
  17746. return m.Client().MessageRecords.Query().Where(m.predicates...).IDs(ctx)
  17747. default:
  17748. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  17749. }
  17750. }
  17751. // SetCreatedAt sets the "created_at" field.
  17752. func (m *MessageRecordsMutation) SetCreatedAt(t time.Time) {
  17753. m.created_at = &t
  17754. }
  17755. // CreatedAt returns the value of the "created_at" field in the mutation.
  17756. func (m *MessageRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  17757. v := m.created_at
  17758. if v == nil {
  17759. return
  17760. }
  17761. return *v, true
  17762. }
  17763. // OldCreatedAt returns the old "created_at" field's value of the MessageRecords entity.
  17764. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17765. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17766. func (m *MessageRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  17767. if !m.op.Is(OpUpdateOne) {
  17768. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  17769. }
  17770. if m.id == nil || m.oldValue == nil {
  17771. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  17772. }
  17773. oldValue, err := m.oldValue(ctx)
  17774. if err != nil {
  17775. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  17776. }
  17777. return oldValue.CreatedAt, nil
  17778. }
  17779. // ResetCreatedAt resets all changes to the "created_at" field.
  17780. func (m *MessageRecordsMutation) ResetCreatedAt() {
  17781. m.created_at = nil
  17782. }
  17783. // SetUpdatedAt sets the "updated_at" field.
  17784. func (m *MessageRecordsMutation) SetUpdatedAt(t time.Time) {
  17785. m.updated_at = &t
  17786. }
  17787. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  17788. func (m *MessageRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  17789. v := m.updated_at
  17790. if v == nil {
  17791. return
  17792. }
  17793. return *v, true
  17794. }
  17795. // OldUpdatedAt returns the old "updated_at" field's value of the MessageRecords entity.
  17796. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17797. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17798. func (m *MessageRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  17799. if !m.op.Is(OpUpdateOne) {
  17800. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  17801. }
  17802. if m.id == nil || m.oldValue == nil {
  17803. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  17804. }
  17805. oldValue, err := m.oldValue(ctx)
  17806. if err != nil {
  17807. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  17808. }
  17809. return oldValue.UpdatedAt, nil
  17810. }
  17811. // ResetUpdatedAt resets all changes to the "updated_at" field.
  17812. func (m *MessageRecordsMutation) ResetUpdatedAt() {
  17813. m.updated_at = nil
  17814. }
  17815. // SetStatus sets the "status" field.
  17816. func (m *MessageRecordsMutation) SetStatus(u uint8) {
  17817. m.status = &u
  17818. m.addstatus = nil
  17819. }
  17820. // Status returns the value of the "status" field in the mutation.
  17821. func (m *MessageRecordsMutation) Status() (r uint8, exists bool) {
  17822. v := m.status
  17823. if v == nil {
  17824. return
  17825. }
  17826. return *v, true
  17827. }
  17828. // OldStatus returns the old "status" field's value of the MessageRecords entity.
  17829. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17830. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17831. func (m *MessageRecordsMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  17832. if !m.op.Is(OpUpdateOne) {
  17833. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  17834. }
  17835. if m.id == nil || m.oldValue == nil {
  17836. return v, errors.New("OldStatus requires an ID field in the mutation")
  17837. }
  17838. oldValue, err := m.oldValue(ctx)
  17839. if err != nil {
  17840. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  17841. }
  17842. return oldValue.Status, nil
  17843. }
  17844. // AddStatus adds u to the "status" field.
  17845. func (m *MessageRecordsMutation) AddStatus(u int8) {
  17846. if m.addstatus != nil {
  17847. *m.addstatus += u
  17848. } else {
  17849. m.addstatus = &u
  17850. }
  17851. }
  17852. // AddedStatus returns the value that was added to the "status" field in this mutation.
  17853. func (m *MessageRecordsMutation) AddedStatus() (r int8, exists bool) {
  17854. v := m.addstatus
  17855. if v == nil {
  17856. return
  17857. }
  17858. return *v, true
  17859. }
  17860. // ClearStatus clears the value of the "status" field.
  17861. func (m *MessageRecordsMutation) ClearStatus() {
  17862. m.status = nil
  17863. m.addstatus = nil
  17864. m.clearedFields[messagerecords.FieldStatus] = struct{}{}
  17865. }
  17866. // StatusCleared returns if the "status" field was cleared in this mutation.
  17867. func (m *MessageRecordsMutation) StatusCleared() bool {
  17868. _, ok := m.clearedFields[messagerecords.FieldStatus]
  17869. return ok
  17870. }
  17871. // ResetStatus resets all changes to the "status" field.
  17872. func (m *MessageRecordsMutation) ResetStatus() {
  17873. m.status = nil
  17874. m.addstatus = nil
  17875. delete(m.clearedFields, messagerecords.FieldStatus)
  17876. }
  17877. // SetBotWxid sets the "bot_wxid" field.
  17878. func (m *MessageRecordsMutation) SetBotWxid(s string) {
  17879. m.bot_wxid = &s
  17880. }
  17881. // BotWxid returns the value of the "bot_wxid" field in the mutation.
  17882. func (m *MessageRecordsMutation) BotWxid() (r string, exists bool) {
  17883. v := m.bot_wxid
  17884. if v == nil {
  17885. return
  17886. }
  17887. return *v, true
  17888. }
  17889. // OldBotWxid returns the old "bot_wxid" field's value of the MessageRecords entity.
  17890. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17891. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17892. func (m *MessageRecordsMutation) OldBotWxid(ctx context.Context) (v string, err error) {
  17893. if !m.op.Is(OpUpdateOne) {
  17894. return v, errors.New("OldBotWxid is only allowed on UpdateOne operations")
  17895. }
  17896. if m.id == nil || m.oldValue == nil {
  17897. return v, errors.New("OldBotWxid requires an ID field in the mutation")
  17898. }
  17899. oldValue, err := m.oldValue(ctx)
  17900. if err != nil {
  17901. return v, fmt.Errorf("querying old value for OldBotWxid: %w", err)
  17902. }
  17903. return oldValue.BotWxid, nil
  17904. }
  17905. // ResetBotWxid resets all changes to the "bot_wxid" field.
  17906. func (m *MessageRecordsMutation) ResetBotWxid() {
  17907. m.bot_wxid = nil
  17908. }
  17909. // SetContactID sets the "contact_id" field.
  17910. func (m *MessageRecordsMutation) SetContactID(u uint64) {
  17911. m.message_contact = &u
  17912. }
  17913. // ContactID returns the value of the "contact_id" field in the mutation.
  17914. func (m *MessageRecordsMutation) ContactID() (r uint64, exists bool) {
  17915. v := m.message_contact
  17916. if v == nil {
  17917. return
  17918. }
  17919. return *v, true
  17920. }
  17921. // OldContactID returns the old "contact_id" field's value of the MessageRecords entity.
  17922. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17923. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17924. func (m *MessageRecordsMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  17925. if !m.op.Is(OpUpdateOne) {
  17926. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  17927. }
  17928. if m.id == nil || m.oldValue == nil {
  17929. return v, errors.New("OldContactID requires an ID field in the mutation")
  17930. }
  17931. oldValue, err := m.oldValue(ctx)
  17932. if err != nil {
  17933. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  17934. }
  17935. return oldValue.ContactID, nil
  17936. }
  17937. // ClearContactID clears the value of the "contact_id" field.
  17938. func (m *MessageRecordsMutation) ClearContactID() {
  17939. m.message_contact = nil
  17940. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  17941. }
  17942. // ContactIDCleared returns if the "contact_id" field was cleared in this mutation.
  17943. func (m *MessageRecordsMutation) ContactIDCleared() bool {
  17944. _, ok := m.clearedFields[messagerecords.FieldContactID]
  17945. return ok
  17946. }
  17947. // ResetContactID resets all changes to the "contact_id" field.
  17948. func (m *MessageRecordsMutation) ResetContactID() {
  17949. m.message_contact = nil
  17950. delete(m.clearedFields, messagerecords.FieldContactID)
  17951. }
  17952. // SetContactType sets the "contact_type" field.
  17953. func (m *MessageRecordsMutation) SetContactType(i int) {
  17954. m.contact_type = &i
  17955. m.addcontact_type = nil
  17956. }
  17957. // ContactType returns the value of the "contact_type" field in the mutation.
  17958. func (m *MessageRecordsMutation) ContactType() (r int, exists bool) {
  17959. v := m.contact_type
  17960. if v == nil {
  17961. return
  17962. }
  17963. return *v, true
  17964. }
  17965. // OldContactType returns the old "contact_type" field's value of the MessageRecords entity.
  17966. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17967. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17968. func (m *MessageRecordsMutation) OldContactType(ctx context.Context) (v int, err error) {
  17969. if !m.op.Is(OpUpdateOne) {
  17970. return v, errors.New("OldContactType is only allowed on UpdateOne operations")
  17971. }
  17972. if m.id == nil || m.oldValue == nil {
  17973. return v, errors.New("OldContactType requires an ID field in the mutation")
  17974. }
  17975. oldValue, err := m.oldValue(ctx)
  17976. if err != nil {
  17977. return v, fmt.Errorf("querying old value for OldContactType: %w", err)
  17978. }
  17979. return oldValue.ContactType, nil
  17980. }
  17981. // AddContactType adds i to the "contact_type" field.
  17982. func (m *MessageRecordsMutation) AddContactType(i int) {
  17983. if m.addcontact_type != nil {
  17984. *m.addcontact_type += i
  17985. } else {
  17986. m.addcontact_type = &i
  17987. }
  17988. }
  17989. // AddedContactType returns the value that was added to the "contact_type" field in this mutation.
  17990. func (m *MessageRecordsMutation) AddedContactType() (r int, exists bool) {
  17991. v := m.addcontact_type
  17992. if v == nil {
  17993. return
  17994. }
  17995. return *v, true
  17996. }
  17997. // ResetContactType resets all changes to the "contact_type" field.
  17998. func (m *MessageRecordsMutation) ResetContactType() {
  17999. m.contact_type = nil
  18000. m.addcontact_type = nil
  18001. }
  18002. // SetContactWxid sets the "contact_wxid" field.
  18003. func (m *MessageRecordsMutation) SetContactWxid(s string) {
  18004. m.contact_wxid = &s
  18005. }
  18006. // ContactWxid returns the value of the "contact_wxid" field in the mutation.
  18007. func (m *MessageRecordsMutation) ContactWxid() (r string, exists bool) {
  18008. v := m.contact_wxid
  18009. if v == nil {
  18010. return
  18011. }
  18012. return *v, true
  18013. }
  18014. // OldContactWxid returns the old "contact_wxid" field's value of the MessageRecords entity.
  18015. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  18016. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18017. func (m *MessageRecordsMutation) OldContactWxid(ctx context.Context) (v string, err error) {
  18018. if !m.op.Is(OpUpdateOne) {
  18019. return v, errors.New("OldContactWxid is only allowed on UpdateOne operations")
  18020. }
  18021. if m.id == nil || m.oldValue == nil {
  18022. return v, errors.New("OldContactWxid requires an ID field in the mutation")
  18023. }
  18024. oldValue, err := m.oldValue(ctx)
  18025. if err != nil {
  18026. return v, fmt.Errorf("querying old value for OldContactWxid: %w", err)
  18027. }
  18028. return oldValue.ContactWxid, nil
  18029. }
  18030. // ResetContactWxid resets all changes to the "contact_wxid" field.
  18031. func (m *MessageRecordsMutation) ResetContactWxid() {
  18032. m.contact_wxid = nil
  18033. }
  18034. // SetContentType sets the "content_type" field.
  18035. func (m *MessageRecordsMutation) SetContentType(i int) {
  18036. m.content_type = &i
  18037. m.addcontent_type = nil
  18038. }
  18039. // ContentType returns the value of the "content_type" field in the mutation.
  18040. func (m *MessageRecordsMutation) ContentType() (r int, exists bool) {
  18041. v := m.content_type
  18042. if v == nil {
  18043. return
  18044. }
  18045. return *v, true
  18046. }
  18047. // OldContentType returns the old "content_type" field's value of the MessageRecords entity.
  18048. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  18049. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18050. func (m *MessageRecordsMutation) OldContentType(ctx context.Context) (v int, err error) {
  18051. if !m.op.Is(OpUpdateOne) {
  18052. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  18053. }
  18054. if m.id == nil || m.oldValue == nil {
  18055. return v, errors.New("OldContentType requires an ID field in the mutation")
  18056. }
  18057. oldValue, err := m.oldValue(ctx)
  18058. if err != nil {
  18059. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  18060. }
  18061. return oldValue.ContentType, nil
  18062. }
  18063. // AddContentType adds i to the "content_type" field.
  18064. func (m *MessageRecordsMutation) AddContentType(i int) {
  18065. if m.addcontent_type != nil {
  18066. *m.addcontent_type += i
  18067. } else {
  18068. m.addcontent_type = &i
  18069. }
  18070. }
  18071. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  18072. func (m *MessageRecordsMutation) AddedContentType() (r int, exists bool) {
  18073. v := m.addcontent_type
  18074. if v == nil {
  18075. return
  18076. }
  18077. return *v, true
  18078. }
  18079. // ResetContentType resets all changes to the "content_type" field.
  18080. func (m *MessageRecordsMutation) ResetContentType() {
  18081. m.content_type = nil
  18082. m.addcontent_type = nil
  18083. }
  18084. // SetContent sets the "content" field.
  18085. func (m *MessageRecordsMutation) SetContent(s string) {
  18086. m.content = &s
  18087. }
  18088. // Content returns the value of the "content" field in the mutation.
  18089. func (m *MessageRecordsMutation) Content() (r string, exists bool) {
  18090. v := m.content
  18091. if v == nil {
  18092. return
  18093. }
  18094. return *v, true
  18095. }
  18096. // OldContent returns the old "content" field's value of the MessageRecords entity.
  18097. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  18098. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18099. func (m *MessageRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  18100. if !m.op.Is(OpUpdateOne) {
  18101. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  18102. }
  18103. if m.id == nil || m.oldValue == nil {
  18104. return v, errors.New("OldContent requires an ID field in the mutation")
  18105. }
  18106. oldValue, err := m.oldValue(ctx)
  18107. if err != nil {
  18108. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  18109. }
  18110. return oldValue.Content, nil
  18111. }
  18112. // ResetContent resets all changes to the "content" field.
  18113. func (m *MessageRecordsMutation) ResetContent() {
  18114. m.content = nil
  18115. }
  18116. // SetMeta sets the "meta" field.
  18117. func (m *MessageRecordsMutation) SetMeta(ct custom_types.Meta) {
  18118. m.meta = &ct
  18119. }
  18120. // Meta returns the value of the "meta" field in the mutation.
  18121. func (m *MessageRecordsMutation) Meta() (r custom_types.Meta, exists bool) {
  18122. v := m.meta
  18123. if v == nil {
  18124. return
  18125. }
  18126. return *v, true
  18127. }
  18128. // OldMeta returns the old "meta" field's value of the MessageRecords entity.
  18129. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  18130. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18131. func (m *MessageRecordsMutation) OldMeta(ctx context.Context) (v custom_types.Meta, err error) {
  18132. if !m.op.Is(OpUpdateOne) {
  18133. return v, errors.New("OldMeta is only allowed on UpdateOne operations")
  18134. }
  18135. if m.id == nil || m.oldValue == nil {
  18136. return v, errors.New("OldMeta requires an ID field in the mutation")
  18137. }
  18138. oldValue, err := m.oldValue(ctx)
  18139. if err != nil {
  18140. return v, fmt.Errorf("querying old value for OldMeta: %w", err)
  18141. }
  18142. return oldValue.Meta, nil
  18143. }
  18144. // ClearMeta clears the value of the "meta" field.
  18145. func (m *MessageRecordsMutation) ClearMeta() {
  18146. m.meta = nil
  18147. m.clearedFields[messagerecords.FieldMeta] = struct{}{}
  18148. }
  18149. // MetaCleared returns if the "meta" field was cleared in this mutation.
  18150. func (m *MessageRecordsMutation) MetaCleared() bool {
  18151. _, ok := m.clearedFields[messagerecords.FieldMeta]
  18152. return ok
  18153. }
  18154. // ResetMeta resets all changes to the "meta" field.
  18155. func (m *MessageRecordsMutation) ResetMeta() {
  18156. m.meta = nil
  18157. delete(m.clearedFields, messagerecords.FieldMeta)
  18158. }
  18159. // SetErrorDetail sets the "error_detail" field.
  18160. func (m *MessageRecordsMutation) SetErrorDetail(s string) {
  18161. m.error_detail = &s
  18162. }
  18163. // ErrorDetail returns the value of the "error_detail" field in the mutation.
  18164. func (m *MessageRecordsMutation) ErrorDetail() (r string, exists bool) {
  18165. v := m.error_detail
  18166. if v == nil {
  18167. return
  18168. }
  18169. return *v, true
  18170. }
  18171. // OldErrorDetail returns the old "error_detail" field's value of the MessageRecords entity.
  18172. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  18173. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18174. func (m *MessageRecordsMutation) OldErrorDetail(ctx context.Context) (v string, err error) {
  18175. if !m.op.Is(OpUpdateOne) {
  18176. return v, errors.New("OldErrorDetail is only allowed on UpdateOne operations")
  18177. }
  18178. if m.id == nil || m.oldValue == nil {
  18179. return v, errors.New("OldErrorDetail requires an ID field in the mutation")
  18180. }
  18181. oldValue, err := m.oldValue(ctx)
  18182. if err != nil {
  18183. return v, fmt.Errorf("querying old value for OldErrorDetail: %w", err)
  18184. }
  18185. return oldValue.ErrorDetail, nil
  18186. }
  18187. // ResetErrorDetail resets all changes to the "error_detail" field.
  18188. func (m *MessageRecordsMutation) ResetErrorDetail() {
  18189. m.error_detail = nil
  18190. }
  18191. // SetSendTime sets the "send_time" field.
  18192. func (m *MessageRecordsMutation) SetSendTime(t time.Time) {
  18193. m.send_time = &t
  18194. }
  18195. // SendTime returns the value of the "send_time" field in the mutation.
  18196. func (m *MessageRecordsMutation) SendTime() (r time.Time, exists bool) {
  18197. v := m.send_time
  18198. if v == nil {
  18199. return
  18200. }
  18201. return *v, true
  18202. }
  18203. // OldSendTime returns the old "send_time" field's value of the MessageRecords entity.
  18204. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  18205. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18206. func (m *MessageRecordsMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  18207. if !m.op.Is(OpUpdateOne) {
  18208. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  18209. }
  18210. if m.id == nil || m.oldValue == nil {
  18211. return v, errors.New("OldSendTime requires an ID field in the mutation")
  18212. }
  18213. oldValue, err := m.oldValue(ctx)
  18214. if err != nil {
  18215. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  18216. }
  18217. return oldValue.SendTime, nil
  18218. }
  18219. // ClearSendTime clears the value of the "send_time" field.
  18220. func (m *MessageRecordsMutation) ClearSendTime() {
  18221. m.send_time = nil
  18222. m.clearedFields[messagerecords.FieldSendTime] = struct{}{}
  18223. }
  18224. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  18225. func (m *MessageRecordsMutation) SendTimeCleared() bool {
  18226. _, ok := m.clearedFields[messagerecords.FieldSendTime]
  18227. return ok
  18228. }
  18229. // ResetSendTime resets all changes to the "send_time" field.
  18230. func (m *MessageRecordsMutation) ResetSendTime() {
  18231. m.send_time = nil
  18232. delete(m.clearedFields, messagerecords.FieldSendTime)
  18233. }
  18234. // SetSourceType sets the "source_type" field.
  18235. func (m *MessageRecordsMutation) SetSourceType(i int) {
  18236. m.source_type = &i
  18237. m.addsource_type = nil
  18238. }
  18239. // SourceType returns the value of the "source_type" field in the mutation.
  18240. func (m *MessageRecordsMutation) SourceType() (r int, exists bool) {
  18241. v := m.source_type
  18242. if v == nil {
  18243. return
  18244. }
  18245. return *v, true
  18246. }
  18247. // OldSourceType returns the old "source_type" field's value of the MessageRecords entity.
  18248. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  18249. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18250. func (m *MessageRecordsMutation) OldSourceType(ctx context.Context) (v int, err error) {
  18251. if !m.op.Is(OpUpdateOne) {
  18252. return v, errors.New("OldSourceType is only allowed on UpdateOne operations")
  18253. }
  18254. if m.id == nil || m.oldValue == nil {
  18255. return v, errors.New("OldSourceType requires an ID field in the mutation")
  18256. }
  18257. oldValue, err := m.oldValue(ctx)
  18258. if err != nil {
  18259. return v, fmt.Errorf("querying old value for OldSourceType: %w", err)
  18260. }
  18261. return oldValue.SourceType, nil
  18262. }
  18263. // AddSourceType adds i to the "source_type" field.
  18264. func (m *MessageRecordsMutation) AddSourceType(i int) {
  18265. if m.addsource_type != nil {
  18266. *m.addsource_type += i
  18267. } else {
  18268. m.addsource_type = &i
  18269. }
  18270. }
  18271. // AddedSourceType returns the value that was added to the "source_type" field in this mutation.
  18272. func (m *MessageRecordsMutation) AddedSourceType() (r int, exists bool) {
  18273. v := m.addsource_type
  18274. if v == nil {
  18275. return
  18276. }
  18277. return *v, true
  18278. }
  18279. // ResetSourceType resets all changes to the "source_type" field.
  18280. func (m *MessageRecordsMutation) ResetSourceType() {
  18281. m.source_type = nil
  18282. m.addsource_type = nil
  18283. }
  18284. // SetSourceID sets the "source_id" field.
  18285. func (m *MessageRecordsMutation) SetSourceID(u uint64) {
  18286. m.sop_stage = &u
  18287. }
  18288. // SourceID returns the value of the "source_id" field in the mutation.
  18289. func (m *MessageRecordsMutation) SourceID() (r uint64, exists bool) {
  18290. v := m.sop_stage
  18291. if v == nil {
  18292. return
  18293. }
  18294. return *v, true
  18295. }
  18296. // OldSourceID returns the old "source_id" field's value of the MessageRecords entity.
  18297. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  18298. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18299. func (m *MessageRecordsMutation) OldSourceID(ctx context.Context) (v uint64, err error) {
  18300. if !m.op.Is(OpUpdateOne) {
  18301. return v, errors.New("OldSourceID is only allowed on UpdateOne operations")
  18302. }
  18303. if m.id == nil || m.oldValue == nil {
  18304. return v, errors.New("OldSourceID requires an ID field in the mutation")
  18305. }
  18306. oldValue, err := m.oldValue(ctx)
  18307. if err != nil {
  18308. return v, fmt.Errorf("querying old value for OldSourceID: %w", err)
  18309. }
  18310. return oldValue.SourceID, nil
  18311. }
  18312. // ClearSourceID clears the value of the "source_id" field.
  18313. func (m *MessageRecordsMutation) ClearSourceID() {
  18314. m.sop_stage = nil
  18315. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  18316. }
  18317. // SourceIDCleared returns if the "source_id" field was cleared in this mutation.
  18318. func (m *MessageRecordsMutation) SourceIDCleared() bool {
  18319. _, ok := m.clearedFields[messagerecords.FieldSourceID]
  18320. return ok
  18321. }
  18322. // ResetSourceID resets all changes to the "source_id" field.
  18323. func (m *MessageRecordsMutation) ResetSourceID() {
  18324. m.sop_stage = nil
  18325. delete(m.clearedFields, messagerecords.FieldSourceID)
  18326. }
  18327. // SetSubSourceID sets the "sub_source_id" field.
  18328. func (m *MessageRecordsMutation) SetSubSourceID(u uint64) {
  18329. m.sop_node = &u
  18330. }
  18331. // SubSourceID returns the value of the "sub_source_id" field in the mutation.
  18332. func (m *MessageRecordsMutation) SubSourceID() (r uint64, exists bool) {
  18333. v := m.sop_node
  18334. if v == nil {
  18335. return
  18336. }
  18337. return *v, true
  18338. }
  18339. // OldSubSourceID returns the old "sub_source_id" field's value of the MessageRecords entity.
  18340. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  18341. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18342. func (m *MessageRecordsMutation) OldSubSourceID(ctx context.Context) (v uint64, err error) {
  18343. if !m.op.Is(OpUpdateOne) {
  18344. return v, errors.New("OldSubSourceID is only allowed on UpdateOne operations")
  18345. }
  18346. if m.id == nil || m.oldValue == nil {
  18347. return v, errors.New("OldSubSourceID requires an ID field in the mutation")
  18348. }
  18349. oldValue, err := m.oldValue(ctx)
  18350. if err != nil {
  18351. return v, fmt.Errorf("querying old value for OldSubSourceID: %w", err)
  18352. }
  18353. return oldValue.SubSourceID, nil
  18354. }
  18355. // ClearSubSourceID clears the value of the "sub_source_id" field.
  18356. func (m *MessageRecordsMutation) ClearSubSourceID() {
  18357. m.sop_node = nil
  18358. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  18359. }
  18360. // SubSourceIDCleared returns if the "sub_source_id" field was cleared in this mutation.
  18361. func (m *MessageRecordsMutation) SubSourceIDCleared() bool {
  18362. _, ok := m.clearedFields[messagerecords.FieldSubSourceID]
  18363. return ok
  18364. }
  18365. // ResetSubSourceID resets all changes to the "sub_source_id" field.
  18366. func (m *MessageRecordsMutation) ResetSubSourceID() {
  18367. m.sop_node = nil
  18368. delete(m.clearedFields, messagerecords.FieldSubSourceID)
  18369. }
  18370. // SetOrganizationID sets the "organization_id" field.
  18371. func (m *MessageRecordsMutation) SetOrganizationID(u uint64) {
  18372. m.organization_id = &u
  18373. m.addorganization_id = nil
  18374. }
  18375. // OrganizationID returns the value of the "organization_id" field in the mutation.
  18376. func (m *MessageRecordsMutation) OrganizationID() (r uint64, exists bool) {
  18377. v := m.organization_id
  18378. if v == nil {
  18379. return
  18380. }
  18381. return *v, true
  18382. }
  18383. // OldOrganizationID returns the old "organization_id" field's value of the MessageRecords entity.
  18384. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  18385. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18386. func (m *MessageRecordsMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  18387. if !m.op.Is(OpUpdateOne) {
  18388. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  18389. }
  18390. if m.id == nil || m.oldValue == nil {
  18391. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  18392. }
  18393. oldValue, err := m.oldValue(ctx)
  18394. if err != nil {
  18395. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  18396. }
  18397. return oldValue.OrganizationID, nil
  18398. }
  18399. // AddOrganizationID adds u to the "organization_id" field.
  18400. func (m *MessageRecordsMutation) AddOrganizationID(u int64) {
  18401. if m.addorganization_id != nil {
  18402. *m.addorganization_id += u
  18403. } else {
  18404. m.addorganization_id = &u
  18405. }
  18406. }
  18407. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  18408. func (m *MessageRecordsMutation) AddedOrganizationID() (r int64, exists bool) {
  18409. v := m.addorganization_id
  18410. if v == nil {
  18411. return
  18412. }
  18413. return *v, true
  18414. }
  18415. // ClearOrganizationID clears the value of the "organization_id" field.
  18416. func (m *MessageRecordsMutation) ClearOrganizationID() {
  18417. m.organization_id = nil
  18418. m.addorganization_id = nil
  18419. m.clearedFields[messagerecords.FieldOrganizationID] = struct{}{}
  18420. }
  18421. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  18422. func (m *MessageRecordsMutation) OrganizationIDCleared() bool {
  18423. _, ok := m.clearedFields[messagerecords.FieldOrganizationID]
  18424. return ok
  18425. }
  18426. // ResetOrganizationID resets all changes to the "organization_id" field.
  18427. func (m *MessageRecordsMutation) ResetOrganizationID() {
  18428. m.organization_id = nil
  18429. m.addorganization_id = nil
  18430. delete(m.clearedFields, messagerecords.FieldOrganizationID)
  18431. }
  18432. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  18433. func (m *MessageRecordsMutation) SetSopStageID(id uint64) {
  18434. m.sop_stage = &id
  18435. }
  18436. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  18437. func (m *MessageRecordsMutation) ClearSopStage() {
  18438. m.clearedsop_stage = true
  18439. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  18440. }
  18441. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  18442. func (m *MessageRecordsMutation) SopStageCleared() bool {
  18443. return m.SourceIDCleared() || m.clearedsop_stage
  18444. }
  18445. // SopStageID returns the "sop_stage" edge ID in the mutation.
  18446. func (m *MessageRecordsMutation) SopStageID() (id uint64, exists bool) {
  18447. if m.sop_stage != nil {
  18448. return *m.sop_stage, true
  18449. }
  18450. return
  18451. }
  18452. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  18453. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  18454. // SopStageID instead. It exists only for internal usage by the builders.
  18455. func (m *MessageRecordsMutation) SopStageIDs() (ids []uint64) {
  18456. if id := m.sop_stage; id != nil {
  18457. ids = append(ids, *id)
  18458. }
  18459. return
  18460. }
  18461. // ResetSopStage resets all changes to the "sop_stage" edge.
  18462. func (m *MessageRecordsMutation) ResetSopStage() {
  18463. m.sop_stage = nil
  18464. m.clearedsop_stage = false
  18465. }
  18466. // SetSopNodeID sets the "sop_node" edge to the SopNode entity by id.
  18467. func (m *MessageRecordsMutation) SetSopNodeID(id uint64) {
  18468. m.sop_node = &id
  18469. }
  18470. // ClearSopNode clears the "sop_node" edge to the SopNode entity.
  18471. func (m *MessageRecordsMutation) ClearSopNode() {
  18472. m.clearedsop_node = true
  18473. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  18474. }
  18475. // SopNodeCleared reports if the "sop_node" edge to the SopNode entity was cleared.
  18476. func (m *MessageRecordsMutation) SopNodeCleared() bool {
  18477. return m.SubSourceIDCleared() || m.clearedsop_node
  18478. }
  18479. // SopNodeID returns the "sop_node" edge ID in the mutation.
  18480. func (m *MessageRecordsMutation) SopNodeID() (id uint64, exists bool) {
  18481. if m.sop_node != nil {
  18482. return *m.sop_node, true
  18483. }
  18484. return
  18485. }
  18486. // SopNodeIDs returns the "sop_node" edge IDs in the mutation.
  18487. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  18488. // SopNodeID instead. It exists only for internal usage by the builders.
  18489. func (m *MessageRecordsMutation) SopNodeIDs() (ids []uint64) {
  18490. if id := m.sop_node; id != nil {
  18491. ids = append(ids, *id)
  18492. }
  18493. return
  18494. }
  18495. // ResetSopNode resets all changes to the "sop_node" edge.
  18496. func (m *MessageRecordsMutation) ResetSopNode() {
  18497. m.sop_node = nil
  18498. m.clearedsop_node = false
  18499. }
  18500. // SetMessageContactID sets the "message_contact" edge to the Contact entity by id.
  18501. func (m *MessageRecordsMutation) SetMessageContactID(id uint64) {
  18502. m.message_contact = &id
  18503. }
  18504. // ClearMessageContact clears the "message_contact" edge to the Contact entity.
  18505. func (m *MessageRecordsMutation) ClearMessageContact() {
  18506. m.clearedmessage_contact = true
  18507. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  18508. }
  18509. // MessageContactCleared reports if the "message_contact" edge to the Contact entity was cleared.
  18510. func (m *MessageRecordsMutation) MessageContactCleared() bool {
  18511. return m.ContactIDCleared() || m.clearedmessage_contact
  18512. }
  18513. // MessageContactID returns the "message_contact" edge ID in the mutation.
  18514. func (m *MessageRecordsMutation) MessageContactID() (id uint64, exists bool) {
  18515. if m.message_contact != nil {
  18516. return *m.message_contact, true
  18517. }
  18518. return
  18519. }
  18520. // MessageContactIDs returns the "message_contact" edge IDs in the mutation.
  18521. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  18522. // MessageContactID instead. It exists only for internal usage by the builders.
  18523. func (m *MessageRecordsMutation) MessageContactIDs() (ids []uint64) {
  18524. if id := m.message_contact; id != nil {
  18525. ids = append(ids, *id)
  18526. }
  18527. return
  18528. }
  18529. // ResetMessageContact resets all changes to the "message_contact" edge.
  18530. func (m *MessageRecordsMutation) ResetMessageContact() {
  18531. m.message_contact = nil
  18532. m.clearedmessage_contact = false
  18533. }
  18534. // Where appends a list predicates to the MessageRecordsMutation builder.
  18535. func (m *MessageRecordsMutation) Where(ps ...predicate.MessageRecords) {
  18536. m.predicates = append(m.predicates, ps...)
  18537. }
  18538. // WhereP appends storage-level predicates to the MessageRecordsMutation builder. Using this method,
  18539. // users can use type-assertion to append predicates that do not depend on any generated package.
  18540. func (m *MessageRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  18541. p := make([]predicate.MessageRecords, len(ps))
  18542. for i := range ps {
  18543. p[i] = ps[i]
  18544. }
  18545. m.Where(p...)
  18546. }
  18547. // Op returns the operation name.
  18548. func (m *MessageRecordsMutation) Op() Op {
  18549. return m.op
  18550. }
  18551. // SetOp allows setting the mutation operation.
  18552. func (m *MessageRecordsMutation) SetOp(op Op) {
  18553. m.op = op
  18554. }
  18555. // Type returns the node type of this mutation (MessageRecords).
  18556. func (m *MessageRecordsMutation) Type() string {
  18557. return m.typ
  18558. }
  18559. // Fields returns all fields that were changed during this mutation. Note that in
  18560. // order to get all numeric fields that were incremented/decremented, call
  18561. // AddedFields().
  18562. func (m *MessageRecordsMutation) Fields() []string {
  18563. fields := make([]string, 0, 16)
  18564. if m.created_at != nil {
  18565. fields = append(fields, messagerecords.FieldCreatedAt)
  18566. }
  18567. if m.updated_at != nil {
  18568. fields = append(fields, messagerecords.FieldUpdatedAt)
  18569. }
  18570. if m.status != nil {
  18571. fields = append(fields, messagerecords.FieldStatus)
  18572. }
  18573. if m.bot_wxid != nil {
  18574. fields = append(fields, messagerecords.FieldBotWxid)
  18575. }
  18576. if m.message_contact != nil {
  18577. fields = append(fields, messagerecords.FieldContactID)
  18578. }
  18579. if m.contact_type != nil {
  18580. fields = append(fields, messagerecords.FieldContactType)
  18581. }
  18582. if m.contact_wxid != nil {
  18583. fields = append(fields, messagerecords.FieldContactWxid)
  18584. }
  18585. if m.content_type != nil {
  18586. fields = append(fields, messagerecords.FieldContentType)
  18587. }
  18588. if m.content != nil {
  18589. fields = append(fields, messagerecords.FieldContent)
  18590. }
  18591. if m.meta != nil {
  18592. fields = append(fields, messagerecords.FieldMeta)
  18593. }
  18594. if m.error_detail != nil {
  18595. fields = append(fields, messagerecords.FieldErrorDetail)
  18596. }
  18597. if m.send_time != nil {
  18598. fields = append(fields, messagerecords.FieldSendTime)
  18599. }
  18600. if m.source_type != nil {
  18601. fields = append(fields, messagerecords.FieldSourceType)
  18602. }
  18603. if m.sop_stage != nil {
  18604. fields = append(fields, messagerecords.FieldSourceID)
  18605. }
  18606. if m.sop_node != nil {
  18607. fields = append(fields, messagerecords.FieldSubSourceID)
  18608. }
  18609. if m.organization_id != nil {
  18610. fields = append(fields, messagerecords.FieldOrganizationID)
  18611. }
  18612. return fields
  18613. }
  18614. // Field returns the value of a field with the given name. The second boolean
  18615. // return value indicates that this field was not set, or was not defined in the
  18616. // schema.
  18617. func (m *MessageRecordsMutation) Field(name string) (ent.Value, bool) {
  18618. switch name {
  18619. case messagerecords.FieldCreatedAt:
  18620. return m.CreatedAt()
  18621. case messagerecords.FieldUpdatedAt:
  18622. return m.UpdatedAt()
  18623. case messagerecords.FieldStatus:
  18624. return m.Status()
  18625. case messagerecords.FieldBotWxid:
  18626. return m.BotWxid()
  18627. case messagerecords.FieldContactID:
  18628. return m.ContactID()
  18629. case messagerecords.FieldContactType:
  18630. return m.ContactType()
  18631. case messagerecords.FieldContactWxid:
  18632. return m.ContactWxid()
  18633. case messagerecords.FieldContentType:
  18634. return m.ContentType()
  18635. case messagerecords.FieldContent:
  18636. return m.Content()
  18637. case messagerecords.FieldMeta:
  18638. return m.Meta()
  18639. case messagerecords.FieldErrorDetail:
  18640. return m.ErrorDetail()
  18641. case messagerecords.FieldSendTime:
  18642. return m.SendTime()
  18643. case messagerecords.FieldSourceType:
  18644. return m.SourceType()
  18645. case messagerecords.FieldSourceID:
  18646. return m.SourceID()
  18647. case messagerecords.FieldSubSourceID:
  18648. return m.SubSourceID()
  18649. case messagerecords.FieldOrganizationID:
  18650. return m.OrganizationID()
  18651. }
  18652. return nil, false
  18653. }
  18654. // OldField returns the old value of the field from the database. An error is
  18655. // returned if the mutation operation is not UpdateOne, or the query to the
  18656. // database failed.
  18657. func (m *MessageRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  18658. switch name {
  18659. case messagerecords.FieldCreatedAt:
  18660. return m.OldCreatedAt(ctx)
  18661. case messagerecords.FieldUpdatedAt:
  18662. return m.OldUpdatedAt(ctx)
  18663. case messagerecords.FieldStatus:
  18664. return m.OldStatus(ctx)
  18665. case messagerecords.FieldBotWxid:
  18666. return m.OldBotWxid(ctx)
  18667. case messagerecords.FieldContactID:
  18668. return m.OldContactID(ctx)
  18669. case messagerecords.FieldContactType:
  18670. return m.OldContactType(ctx)
  18671. case messagerecords.FieldContactWxid:
  18672. return m.OldContactWxid(ctx)
  18673. case messagerecords.FieldContentType:
  18674. return m.OldContentType(ctx)
  18675. case messagerecords.FieldContent:
  18676. return m.OldContent(ctx)
  18677. case messagerecords.FieldMeta:
  18678. return m.OldMeta(ctx)
  18679. case messagerecords.FieldErrorDetail:
  18680. return m.OldErrorDetail(ctx)
  18681. case messagerecords.FieldSendTime:
  18682. return m.OldSendTime(ctx)
  18683. case messagerecords.FieldSourceType:
  18684. return m.OldSourceType(ctx)
  18685. case messagerecords.FieldSourceID:
  18686. return m.OldSourceID(ctx)
  18687. case messagerecords.FieldSubSourceID:
  18688. return m.OldSubSourceID(ctx)
  18689. case messagerecords.FieldOrganizationID:
  18690. return m.OldOrganizationID(ctx)
  18691. }
  18692. return nil, fmt.Errorf("unknown MessageRecords field %s", name)
  18693. }
  18694. // SetField sets the value of a field with the given name. It returns an error if
  18695. // the field is not defined in the schema, or if the type mismatched the field
  18696. // type.
  18697. func (m *MessageRecordsMutation) SetField(name string, value ent.Value) error {
  18698. switch name {
  18699. case messagerecords.FieldCreatedAt:
  18700. v, ok := value.(time.Time)
  18701. if !ok {
  18702. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18703. }
  18704. m.SetCreatedAt(v)
  18705. return nil
  18706. case messagerecords.FieldUpdatedAt:
  18707. v, ok := value.(time.Time)
  18708. if !ok {
  18709. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18710. }
  18711. m.SetUpdatedAt(v)
  18712. return nil
  18713. case messagerecords.FieldStatus:
  18714. v, ok := value.(uint8)
  18715. if !ok {
  18716. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18717. }
  18718. m.SetStatus(v)
  18719. return nil
  18720. case messagerecords.FieldBotWxid:
  18721. v, ok := value.(string)
  18722. if !ok {
  18723. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18724. }
  18725. m.SetBotWxid(v)
  18726. return nil
  18727. case messagerecords.FieldContactID:
  18728. v, ok := value.(uint64)
  18729. if !ok {
  18730. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18731. }
  18732. m.SetContactID(v)
  18733. return nil
  18734. case messagerecords.FieldContactType:
  18735. v, ok := value.(int)
  18736. if !ok {
  18737. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18738. }
  18739. m.SetContactType(v)
  18740. return nil
  18741. case messagerecords.FieldContactWxid:
  18742. v, ok := value.(string)
  18743. if !ok {
  18744. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18745. }
  18746. m.SetContactWxid(v)
  18747. return nil
  18748. case messagerecords.FieldContentType:
  18749. v, ok := value.(int)
  18750. if !ok {
  18751. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18752. }
  18753. m.SetContentType(v)
  18754. return nil
  18755. case messagerecords.FieldContent:
  18756. v, ok := value.(string)
  18757. if !ok {
  18758. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18759. }
  18760. m.SetContent(v)
  18761. return nil
  18762. case messagerecords.FieldMeta:
  18763. v, ok := value.(custom_types.Meta)
  18764. if !ok {
  18765. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18766. }
  18767. m.SetMeta(v)
  18768. return nil
  18769. case messagerecords.FieldErrorDetail:
  18770. v, ok := value.(string)
  18771. if !ok {
  18772. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18773. }
  18774. m.SetErrorDetail(v)
  18775. return nil
  18776. case messagerecords.FieldSendTime:
  18777. v, ok := value.(time.Time)
  18778. if !ok {
  18779. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18780. }
  18781. m.SetSendTime(v)
  18782. return nil
  18783. case messagerecords.FieldSourceType:
  18784. v, ok := value.(int)
  18785. if !ok {
  18786. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18787. }
  18788. m.SetSourceType(v)
  18789. return nil
  18790. case messagerecords.FieldSourceID:
  18791. v, ok := value.(uint64)
  18792. if !ok {
  18793. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18794. }
  18795. m.SetSourceID(v)
  18796. return nil
  18797. case messagerecords.FieldSubSourceID:
  18798. v, ok := value.(uint64)
  18799. if !ok {
  18800. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18801. }
  18802. m.SetSubSourceID(v)
  18803. return nil
  18804. case messagerecords.FieldOrganizationID:
  18805. v, ok := value.(uint64)
  18806. if !ok {
  18807. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18808. }
  18809. m.SetOrganizationID(v)
  18810. return nil
  18811. }
  18812. return fmt.Errorf("unknown MessageRecords field %s", name)
  18813. }
  18814. // AddedFields returns all numeric fields that were incremented/decremented during
  18815. // this mutation.
  18816. func (m *MessageRecordsMutation) AddedFields() []string {
  18817. var fields []string
  18818. if m.addstatus != nil {
  18819. fields = append(fields, messagerecords.FieldStatus)
  18820. }
  18821. if m.addcontact_type != nil {
  18822. fields = append(fields, messagerecords.FieldContactType)
  18823. }
  18824. if m.addcontent_type != nil {
  18825. fields = append(fields, messagerecords.FieldContentType)
  18826. }
  18827. if m.addsource_type != nil {
  18828. fields = append(fields, messagerecords.FieldSourceType)
  18829. }
  18830. if m.addorganization_id != nil {
  18831. fields = append(fields, messagerecords.FieldOrganizationID)
  18832. }
  18833. return fields
  18834. }
  18835. // AddedField returns the numeric value that was incremented/decremented on a field
  18836. // with the given name. The second boolean return value indicates that this field
  18837. // was not set, or was not defined in the schema.
  18838. func (m *MessageRecordsMutation) AddedField(name string) (ent.Value, bool) {
  18839. switch name {
  18840. case messagerecords.FieldStatus:
  18841. return m.AddedStatus()
  18842. case messagerecords.FieldContactType:
  18843. return m.AddedContactType()
  18844. case messagerecords.FieldContentType:
  18845. return m.AddedContentType()
  18846. case messagerecords.FieldSourceType:
  18847. return m.AddedSourceType()
  18848. case messagerecords.FieldOrganizationID:
  18849. return m.AddedOrganizationID()
  18850. }
  18851. return nil, false
  18852. }
  18853. // AddField adds the value to the field with the given name. It returns an error if
  18854. // the field is not defined in the schema, or if the type mismatched the field
  18855. // type.
  18856. func (m *MessageRecordsMutation) AddField(name string, value ent.Value) error {
  18857. switch name {
  18858. case messagerecords.FieldStatus:
  18859. v, ok := value.(int8)
  18860. if !ok {
  18861. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18862. }
  18863. m.AddStatus(v)
  18864. return nil
  18865. case messagerecords.FieldContactType:
  18866. v, ok := value.(int)
  18867. if !ok {
  18868. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18869. }
  18870. m.AddContactType(v)
  18871. return nil
  18872. case messagerecords.FieldContentType:
  18873. v, ok := value.(int)
  18874. if !ok {
  18875. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18876. }
  18877. m.AddContentType(v)
  18878. return nil
  18879. case messagerecords.FieldSourceType:
  18880. v, ok := value.(int)
  18881. if !ok {
  18882. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18883. }
  18884. m.AddSourceType(v)
  18885. return nil
  18886. case messagerecords.FieldOrganizationID:
  18887. v, ok := value.(int64)
  18888. if !ok {
  18889. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18890. }
  18891. m.AddOrganizationID(v)
  18892. return nil
  18893. }
  18894. return fmt.Errorf("unknown MessageRecords numeric field %s", name)
  18895. }
  18896. // ClearedFields returns all nullable fields that were cleared during this
  18897. // mutation.
  18898. func (m *MessageRecordsMutation) ClearedFields() []string {
  18899. var fields []string
  18900. if m.FieldCleared(messagerecords.FieldStatus) {
  18901. fields = append(fields, messagerecords.FieldStatus)
  18902. }
  18903. if m.FieldCleared(messagerecords.FieldContactID) {
  18904. fields = append(fields, messagerecords.FieldContactID)
  18905. }
  18906. if m.FieldCleared(messagerecords.FieldMeta) {
  18907. fields = append(fields, messagerecords.FieldMeta)
  18908. }
  18909. if m.FieldCleared(messagerecords.FieldSendTime) {
  18910. fields = append(fields, messagerecords.FieldSendTime)
  18911. }
  18912. if m.FieldCleared(messagerecords.FieldSourceID) {
  18913. fields = append(fields, messagerecords.FieldSourceID)
  18914. }
  18915. if m.FieldCleared(messagerecords.FieldSubSourceID) {
  18916. fields = append(fields, messagerecords.FieldSubSourceID)
  18917. }
  18918. if m.FieldCleared(messagerecords.FieldOrganizationID) {
  18919. fields = append(fields, messagerecords.FieldOrganizationID)
  18920. }
  18921. return fields
  18922. }
  18923. // FieldCleared returns a boolean indicating if a field with the given name was
  18924. // cleared in this mutation.
  18925. func (m *MessageRecordsMutation) FieldCleared(name string) bool {
  18926. _, ok := m.clearedFields[name]
  18927. return ok
  18928. }
  18929. // ClearField clears the value of the field with the given name. It returns an
  18930. // error if the field is not defined in the schema.
  18931. func (m *MessageRecordsMutation) ClearField(name string) error {
  18932. switch name {
  18933. case messagerecords.FieldStatus:
  18934. m.ClearStatus()
  18935. return nil
  18936. case messagerecords.FieldContactID:
  18937. m.ClearContactID()
  18938. return nil
  18939. case messagerecords.FieldMeta:
  18940. m.ClearMeta()
  18941. return nil
  18942. case messagerecords.FieldSendTime:
  18943. m.ClearSendTime()
  18944. return nil
  18945. case messagerecords.FieldSourceID:
  18946. m.ClearSourceID()
  18947. return nil
  18948. case messagerecords.FieldSubSourceID:
  18949. m.ClearSubSourceID()
  18950. return nil
  18951. case messagerecords.FieldOrganizationID:
  18952. m.ClearOrganizationID()
  18953. return nil
  18954. }
  18955. return fmt.Errorf("unknown MessageRecords nullable field %s", name)
  18956. }
  18957. // ResetField resets all changes in the mutation for the field with the given name.
  18958. // It returns an error if the field is not defined in the schema.
  18959. func (m *MessageRecordsMutation) ResetField(name string) error {
  18960. switch name {
  18961. case messagerecords.FieldCreatedAt:
  18962. m.ResetCreatedAt()
  18963. return nil
  18964. case messagerecords.FieldUpdatedAt:
  18965. m.ResetUpdatedAt()
  18966. return nil
  18967. case messagerecords.FieldStatus:
  18968. m.ResetStatus()
  18969. return nil
  18970. case messagerecords.FieldBotWxid:
  18971. m.ResetBotWxid()
  18972. return nil
  18973. case messagerecords.FieldContactID:
  18974. m.ResetContactID()
  18975. return nil
  18976. case messagerecords.FieldContactType:
  18977. m.ResetContactType()
  18978. return nil
  18979. case messagerecords.FieldContactWxid:
  18980. m.ResetContactWxid()
  18981. return nil
  18982. case messagerecords.FieldContentType:
  18983. m.ResetContentType()
  18984. return nil
  18985. case messagerecords.FieldContent:
  18986. m.ResetContent()
  18987. return nil
  18988. case messagerecords.FieldMeta:
  18989. m.ResetMeta()
  18990. return nil
  18991. case messagerecords.FieldErrorDetail:
  18992. m.ResetErrorDetail()
  18993. return nil
  18994. case messagerecords.FieldSendTime:
  18995. m.ResetSendTime()
  18996. return nil
  18997. case messagerecords.FieldSourceType:
  18998. m.ResetSourceType()
  18999. return nil
  19000. case messagerecords.FieldSourceID:
  19001. m.ResetSourceID()
  19002. return nil
  19003. case messagerecords.FieldSubSourceID:
  19004. m.ResetSubSourceID()
  19005. return nil
  19006. case messagerecords.FieldOrganizationID:
  19007. m.ResetOrganizationID()
  19008. return nil
  19009. }
  19010. return fmt.Errorf("unknown MessageRecords field %s", name)
  19011. }
  19012. // AddedEdges returns all edge names that were set/added in this mutation.
  19013. func (m *MessageRecordsMutation) AddedEdges() []string {
  19014. edges := make([]string, 0, 3)
  19015. if m.sop_stage != nil {
  19016. edges = append(edges, messagerecords.EdgeSopStage)
  19017. }
  19018. if m.sop_node != nil {
  19019. edges = append(edges, messagerecords.EdgeSopNode)
  19020. }
  19021. if m.message_contact != nil {
  19022. edges = append(edges, messagerecords.EdgeMessageContact)
  19023. }
  19024. return edges
  19025. }
  19026. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  19027. // name in this mutation.
  19028. func (m *MessageRecordsMutation) AddedIDs(name string) []ent.Value {
  19029. switch name {
  19030. case messagerecords.EdgeSopStage:
  19031. if id := m.sop_stage; id != nil {
  19032. return []ent.Value{*id}
  19033. }
  19034. case messagerecords.EdgeSopNode:
  19035. if id := m.sop_node; id != nil {
  19036. return []ent.Value{*id}
  19037. }
  19038. case messagerecords.EdgeMessageContact:
  19039. if id := m.message_contact; id != nil {
  19040. return []ent.Value{*id}
  19041. }
  19042. }
  19043. return nil
  19044. }
  19045. // RemovedEdges returns all edge names that were removed in this mutation.
  19046. func (m *MessageRecordsMutation) RemovedEdges() []string {
  19047. edges := make([]string, 0, 3)
  19048. return edges
  19049. }
  19050. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  19051. // the given name in this mutation.
  19052. func (m *MessageRecordsMutation) RemovedIDs(name string) []ent.Value {
  19053. return nil
  19054. }
  19055. // ClearedEdges returns all edge names that were cleared in this mutation.
  19056. func (m *MessageRecordsMutation) ClearedEdges() []string {
  19057. edges := make([]string, 0, 3)
  19058. if m.clearedsop_stage {
  19059. edges = append(edges, messagerecords.EdgeSopStage)
  19060. }
  19061. if m.clearedsop_node {
  19062. edges = append(edges, messagerecords.EdgeSopNode)
  19063. }
  19064. if m.clearedmessage_contact {
  19065. edges = append(edges, messagerecords.EdgeMessageContact)
  19066. }
  19067. return edges
  19068. }
  19069. // EdgeCleared returns a boolean which indicates if the edge with the given name
  19070. // was cleared in this mutation.
  19071. func (m *MessageRecordsMutation) EdgeCleared(name string) bool {
  19072. switch name {
  19073. case messagerecords.EdgeSopStage:
  19074. return m.clearedsop_stage
  19075. case messagerecords.EdgeSopNode:
  19076. return m.clearedsop_node
  19077. case messagerecords.EdgeMessageContact:
  19078. return m.clearedmessage_contact
  19079. }
  19080. return false
  19081. }
  19082. // ClearEdge clears the value of the edge with the given name. It returns an error
  19083. // if that edge is not defined in the schema.
  19084. func (m *MessageRecordsMutation) ClearEdge(name string) error {
  19085. switch name {
  19086. case messagerecords.EdgeSopStage:
  19087. m.ClearSopStage()
  19088. return nil
  19089. case messagerecords.EdgeSopNode:
  19090. m.ClearSopNode()
  19091. return nil
  19092. case messagerecords.EdgeMessageContact:
  19093. m.ClearMessageContact()
  19094. return nil
  19095. }
  19096. return fmt.Errorf("unknown MessageRecords unique edge %s", name)
  19097. }
  19098. // ResetEdge resets all changes to the edge with the given name in this mutation.
  19099. // It returns an error if the edge is not defined in the schema.
  19100. func (m *MessageRecordsMutation) ResetEdge(name string) error {
  19101. switch name {
  19102. case messagerecords.EdgeSopStage:
  19103. m.ResetSopStage()
  19104. return nil
  19105. case messagerecords.EdgeSopNode:
  19106. m.ResetSopNode()
  19107. return nil
  19108. case messagerecords.EdgeMessageContact:
  19109. m.ResetMessageContact()
  19110. return nil
  19111. }
  19112. return fmt.Errorf("unknown MessageRecords edge %s", name)
  19113. }
  19114. // MsgMutation represents an operation that mutates the Msg nodes in the graph.
  19115. type MsgMutation struct {
  19116. config
  19117. op Op
  19118. typ string
  19119. id *uint64
  19120. created_at *time.Time
  19121. updated_at *time.Time
  19122. deleted_at *time.Time
  19123. status *uint8
  19124. addstatus *int8
  19125. fromwxid *string
  19126. toid *string
  19127. msgtype *int32
  19128. addmsgtype *int32
  19129. msg *string
  19130. batch_no *string
  19131. ctype *uint64
  19132. addctype *int64
  19133. cc *string
  19134. phone *string
  19135. clearedFields map[string]struct{}
  19136. done bool
  19137. oldValue func(context.Context) (*Msg, error)
  19138. predicates []predicate.Msg
  19139. }
  19140. var _ ent.Mutation = (*MsgMutation)(nil)
  19141. // msgOption allows management of the mutation configuration using functional options.
  19142. type msgOption func(*MsgMutation)
  19143. // newMsgMutation creates new mutation for the Msg entity.
  19144. func newMsgMutation(c config, op Op, opts ...msgOption) *MsgMutation {
  19145. m := &MsgMutation{
  19146. config: c,
  19147. op: op,
  19148. typ: TypeMsg,
  19149. clearedFields: make(map[string]struct{}),
  19150. }
  19151. for _, opt := range opts {
  19152. opt(m)
  19153. }
  19154. return m
  19155. }
  19156. // withMsgID sets the ID field of the mutation.
  19157. func withMsgID(id uint64) msgOption {
  19158. return func(m *MsgMutation) {
  19159. var (
  19160. err error
  19161. once sync.Once
  19162. value *Msg
  19163. )
  19164. m.oldValue = func(ctx context.Context) (*Msg, error) {
  19165. once.Do(func() {
  19166. if m.done {
  19167. err = errors.New("querying old values post mutation is not allowed")
  19168. } else {
  19169. value, err = m.Client().Msg.Get(ctx, id)
  19170. }
  19171. })
  19172. return value, err
  19173. }
  19174. m.id = &id
  19175. }
  19176. }
  19177. // withMsg sets the old Msg of the mutation.
  19178. func withMsg(node *Msg) msgOption {
  19179. return func(m *MsgMutation) {
  19180. m.oldValue = func(context.Context) (*Msg, error) {
  19181. return node, nil
  19182. }
  19183. m.id = &node.ID
  19184. }
  19185. }
  19186. // Client returns a new `ent.Client` from the mutation. If the mutation was
  19187. // executed in a transaction (ent.Tx), a transactional client is returned.
  19188. func (m MsgMutation) Client() *Client {
  19189. client := &Client{config: m.config}
  19190. client.init()
  19191. return client
  19192. }
  19193. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  19194. // it returns an error otherwise.
  19195. func (m MsgMutation) Tx() (*Tx, error) {
  19196. if _, ok := m.driver.(*txDriver); !ok {
  19197. return nil, errors.New("ent: mutation is not running in a transaction")
  19198. }
  19199. tx := &Tx{config: m.config}
  19200. tx.init()
  19201. return tx, nil
  19202. }
  19203. // SetID sets the value of the id field. Note that this
  19204. // operation is only accepted on creation of Msg entities.
  19205. func (m *MsgMutation) SetID(id uint64) {
  19206. m.id = &id
  19207. }
  19208. // ID returns the ID value in the mutation. Note that the ID is only available
  19209. // if it was provided to the builder or after it was returned from the database.
  19210. func (m *MsgMutation) ID() (id uint64, exists bool) {
  19211. if m.id == nil {
  19212. return
  19213. }
  19214. return *m.id, true
  19215. }
  19216. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  19217. // That means, if the mutation is applied within a transaction with an isolation level such
  19218. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  19219. // or updated by the mutation.
  19220. func (m *MsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  19221. switch {
  19222. case m.op.Is(OpUpdateOne | OpDeleteOne):
  19223. id, exists := m.ID()
  19224. if exists {
  19225. return []uint64{id}, nil
  19226. }
  19227. fallthrough
  19228. case m.op.Is(OpUpdate | OpDelete):
  19229. return m.Client().Msg.Query().Where(m.predicates...).IDs(ctx)
  19230. default:
  19231. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  19232. }
  19233. }
  19234. // SetCreatedAt sets the "created_at" field.
  19235. func (m *MsgMutation) SetCreatedAt(t time.Time) {
  19236. m.created_at = &t
  19237. }
  19238. // CreatedAt returns the value of the "created_at" field in the mutation.
  19239. func (m *MsgMutation) CreatedAt() (r time.Time, exists bool) {
  19240. v := m.created_at
  19241. if v == nil {
  19242. return
  19243. }
  19244. return *v, true
  19245. }
  19246. // OldCreatedAt returns the old "created_at" field's value of the Msg entity.
  19247. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  19248. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19249. func (m *MsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  19250. if !m.op.Is(OpUpdateOne) {
  19251. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  19252. }
  19253. if m.id == nil || m.oldValue == nil {
  19254. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  19255. }
  19256. oldValue, err := m.oldValue(ctx)
  19257. if err != nil {
  19258. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  19259. }
  19260. return oldValue.CreatedAt, nil
  19261. }
  19262. // ResetCreatedAt resets all changes to the "created_at" field.
  19263. func (m *MsgMutation) ResetCreatedAt() {
  19264. m.created_at = nil
  19265. }
  19266. // SetUpdatedAt sets the "updated_at" field.
  19267. func (m *MsgMutation) SetUpdatedAt(t time.Time) {
  19268. m.updated_at = &t
  19269. }
  19270. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  19271. func (m *MsgMutation) UpdatedAt() (r time.Time, exists bool) {
  19272. v := m.updated_at
  19273. if v == nil {
  19274. return
  19275. }
  19276. return *v, true
  19277. }
  19278. // OldUpdatedAt returns the old "updated_at" field's value of the Msg entity.
  19279. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  19280. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19281. func (m *MsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  19282. if !m.op.Is(OpUpdateOne) {
  19283. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  19284. }
  19285. if m.id == nil || m.oldValue == nil {
  19286. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  19287. }
  19288. oldValue, err := m.oldValue(ctx)
  19289. if err != nil {
  19290. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  19291. }
  19292. return oldValue.UpdatedAt, nil
  19293. }
  19294. // ResetUpdatedAt resets all changes to the "updated_at" field.
  19295. func (m *MsgMutation) ResetUpdatedAt() {
  19296. m.updated_at = nil
  19297. }
  19298. // SetDeletedAt sets the "deleted_at" field.
  19299. func (m *MsgMutation) SetDeletedAt(t time.Time) {
  19300. m.deleted_at = &t
  19301. }
  19302. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  19303. func (m *MsgMutation) DeletedAt() (r time.Time, exists bool) {
  19304. v := m.deleted_at
  19305. if v == nil {
  19306. return
  19307. }
  19308. return *v, true
  19309. }
  19310. // OldDeletedAt returns the old "deleted_at" field's value of the Msg entity.
  19311. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  19312. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19313. func (m *MsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  19314. if !m.op.Is(OpUpdateOne) {
  19315. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  19316. }
  19317. if m.id == nil || m.oldValue == nil {
  19318. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  19319. }
  19320. oldValue, err := m.oldValue(ctx)
  19321. if err != nil {
  19322. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  19323. }
  19324. return oldValue.DeletedAt, nil
  19325. }
  19326. // ClearDeletedAt clears the value of the "deleted_at" field.
  19327. func (m *MsgMutation) ClearDeletedAt() {
  19328. m.deleted_at = nil
  19329. m.clearedFields[msg.FieldDeletedAt] = struct{}{}
  19330. }
  19331. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  19332. func (m *MsgMutation) DeletedAtCleared() bool {
  19333. _, ok := m.clearedFields[msg.FieldDeletedAt]
  19334. return ok
  19335. }
  19336. // ResetDeletedAt resets all changes to the "deleted_at" field.
  19337. func (m *MsgMutation) ResetDeletedAt() {
  19338. m.deleted_at = nil
  19339. delete(m.clearedFields, msg.FieldDeletedAt)
  19340. }
  19341. // SetStatus sets the "status" field.
  19342. func (m *MsgMutation) SetStatus(u uint8) {
  19343. m.status = &u
  19344. m.addstatus = nil
  19345. }
  19346. // Status returns the value of the "status" field in the mutation.
  19347. func (m *MsgMutation) Status() (r uint8, exists bool) {
  19348. v := m.status
  19349. if v == nil {
  19350. return
  19351. }
  19352. return *v, true
  19353. }
  19354. // OldStatus returns the old "status" field's value of the Msg entity.
  19355. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  19356. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19357. func (m *MsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  19358. if !m.op.Is(OpUpdateOne) {
  19359. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  19360. }
  19361. if m.id == nil || m.oldValue == nil {
  19362. return v, errors.New("OldStatus requires an ID field in the mutation")
  19363. }
  19364. oldValue, err := m.oldValue(ctx)
  19365. if err != nil {
  19366. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  19367. }
  19368. return oldValue.Status, nil
  19369. }
  19370. // AddStatus adds u to the "status" field.
  19371. func (m *MsgMutation) AddStatus(u int8) {
  19372. if m.addstatus != nil {
  19373. *m.addstatus += u
  19374. } else {
  19375. m.addstatus = &u
  19376. }
  19377. }
  19378. // AddedStatus returns the value that was added to the "status" field in this mutation.
  19379. func (m *MsgMutation) AddedStatus() (r int8, exists bool) {
  19380. v := m.addstatus
  19381. if v == nil {
  19382. return
  19383. }
  19384. return *v, true
  19385. }
  19386. // ClearStatus clears the value of the "status" field.
  19387. func (m *MsgMutation) ClearStatus() {
  19388. m.status = nil
  19389. m.addstatus = nil
  19390. m.clearedFields[msg.FieldStatus] = struct{}{}
  19391. }
  19392. // StatusCleared returns if the "status" field was cleared in this mutation.
  19393. func (m *MsgMutation) StatusCleared() bool {
  19394. _, ok := m.clearedFields[msg.FieldStatus]
  19395. return ok
  19396. }
  19397. // ResetStatus resets all changes to the "status" field.
  19398. func (m *MsgMutation) ResetStatus() {
  19399. m.status = nil
  19400. m.addstatus = nil
  19401. delete(m.clearedFields, msg.FieldStatus)
  19402. }
  19403. // SetFromwxid sets the "fromwxid" field.
  19404. func (m *MsgMutation) SetFromwxid(s string) {
  19405. m.fromwxid = &s
  19406. }
  19407. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  19408. func (m *MsgMutation) Fromwxid() (r string, exists bool) {
  19409. v := m.fromwxid
  19410. if v == nil {
  19411. return
  19412. }
  19413. return *v, true
  19414. }
  19415. // OldFromwxid returns the old "fromwxid" field's value of the Msg entity.
  19416. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  19417. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19418. func (m *MsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  19419. if !m.op.Is(OpUpdateOne) {
  19420. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  19421. }
  19422. if m.id == nil || m.oldValue == nil {
  19423. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  19424. }
  19425. oldValue, err := m.oldValue(ctx)
  19426. if err != nil {
  19427. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  19428. }
  19429. return oldValue.Fromwxid, nil
  19430. }
  19431. // ClearFromwxid clears the value of the "fromwxid" field.
  19432. func (m *MsgMutation) ClearFromwxid() {
  19433. m.fromwxid = nil
  19434. m.clearedFields[msg.FieldFromwxid] = struct{}{}
  19435. }
  19436. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  19437. func (m *MsgMutation) FromwxidCleared() bool {
  19438. _, ok := m.clearedFields[msg.FieldFromwxid]
  19439. return ok
  19440. }
  19441. // ResetFromwxid resets all changes to the "fromwxid" field.
  19442. func (m *MsgMutation) ResetFromwxid() {
  19443. m.fromwxid = nil
  19444. delete(m.clearedFields, msg.FieldFromwxid)
  19445. }
  19446. // SetToid sets the "toid" field.
  19447. func (m *MsgMutation) SetToid(s string) {
  19448. m.toid = &s
  19449. }
  19450. // Toid returns the value of the "toid" field in the mutation.
  19451. func (m *MsgMutation) Toid() (r string, exists bool) {
  19452. v := m.toid
  19453. if v == nil {
  19454. return
  19455. }
  19456. return *v, true
  19457. }
  19458. // OldToid returns the old "toid" field's value of the Msg entity.
  19459. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  19460. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19461. func (m *MsgMutation) OldToid(ctx context.Context) (v string, err error) {
  19462. if !m.op.Is(OpUpdateOne) {
  19463. return v, errors.New("OldToid is only allowed on UpdateOne operations")
  19464. }
  19465. if m.id == nil || m.oldValue == nil {
  19466. return v, errors.New("OldToid requires an ID field in the mutation")
  19467. }
  19468. oldValue, err := m.oldValue(ctx)
  19469. if err != nil {
  19470. return v, fmt.Errorf("querying old value for OldToid: %w", err)
  19471. }
  19472. return oldValue.Toid, nil
  19473. }
  19474. // ClearToid clears the value of the "toid" field.
  19475. func (m *MsgMutation) ClearToid() {
  19476. m.toid = nil
  19477. m.clearedFields[msg.FieldToid] = struct{}{}
  19478. }
  19479. // ToidCleared returns if the "toid" field was cleared in this mutation.
  19480. func (m *MsgMutation) ToidCleared() bool {
  19481. _, ok := m.clearedFields[msg.FieldToid]
  19482. return ok
  19483. }
  19484. // ResetToid resets all changes to the "toid" field.
  19485. func (m *MsgMutation) ResetToid() {
  19486. m.toid = nil
  19487. delete(m.clearedFields, msg.FieldToid)
  19488. }
  19489. // SetMsgtype sets the "msgtype" field.
  19490. func (m *MsgMutation) SetMsgtype(i int32) {
  19491. m.msgtype = &i
  19492. m.addmsgtype = nil
  19493. }
  19494. // Msgtype returns the value of the "msgtype" field in the mutation.
  19495. func (m *MsgMutation) Msgtype() (r int32, exists bool) {
  19496. v := m.msgtype
  19497. if v == nil {
  19498. return
  19499. }
  19500. return *v, true
  19501. }
  19502. // OldMsgtype returns the old "msgtype" field's value of the Msg entity.
  19503. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  19504. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19505. func (m *MsgMutation) OldMsgtype(ctx context.Context) (v int32, err error) {
  19506. if !m.op.Is(OpUpdateOne) {
  19507. return v, errors.New("OldMsgtype is only allowed on UpdateOne operations")
  19508. }
  19509. if m.id == nil || m.oldValue == nil {
  19510. return v, errors.New("OldMsgtype requires an ID field in the mutation")
  19511. }
  19512. oldValue, err := m.oldValue(ctx)
  19513. if err != nil {
  19514. return v, fmt.Errorf("querying old value for OldMsgtype: %w", err)
  19515. }
  19516. return oldValue.Msgtype, nil
  19517. }
  19518. // AddMsgtype adds i to the "msgtype" field.
  19519. func (m *MsgMutation) AddMsgtype(i int32) {
  19520. if m.addmsgtype != nil {
  19521. *m.addmsgtype += i
  19522. } else {
  19523. m.addmsgtype = &i
  19524. }
  19525. }
  19526. // AddedMsgtype returns the value that was added to the "msgtype" field in this mutation.
  19527. func (m *MsgMutation) AddedMsgtype() (r int32, exists bool) {
  19528. v := m.addmsgtype
  19529. if v == nil {
  19530. return
  19531. }
  19532. return *v, true
  19533. }
  19534. // ClearMsgtype clears the value of the "msgtype" field.
  19535. func (m *MsgMutation) ClearMsgtype() {
  19536. m.msgtype = nil
  19537. m.addmsgtype = nil
  19538. m.clearedFields[msg.FieldMsgtype] = struct{}{}
  19539. }
  19540. // MsgtypeCleared returns if the "msgtype" field was cleared in this mutation.
  19541. func (m *MsgMutation) MsgtypeCleared() bool {
  19542. _, ok := m.clearedFields[msg.FieldMsgtype]
  19543. return ok
  19544. }
  19545. // ResetMsgtype resets all changes to the "msgtype" field.
  19546. func (m *MsgMutation) ResetMsgtype() {
  19547. m.msgtype = nil
  19548. m.addmsgtype = nil
  19549. delete(m.clearedFields, msg.FieldMsgtype)
  19550. }
  19551. // SetMsg sets the "msg" field.
  19552. func (m *MsgMutation) SetMsg(s string) {
  19553. m.msg = &s
  19554. }
  19555. // Msg returns the value of the "msg" field in the mutation.
  19556. func (m *MsgMutation) Msg() (r string, exists bool) {
  19557. v := m.msg
  19558. if v == nil {
  19559. return
  19560. }
  19561. return *v, true
  19562. }
  19563. // OldMsg returns the old "msg" field's value of the Msg entity.
  19564. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  19565. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19566. func (m *MsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  19567. if !m.op.Is(OpUpdateOne) {
  19568. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  19569. }
  19570. if m.id == nil || m.oldValue == nil {
  19571. return v, errors.New("OldMsg requires an ID field in the mutation")
  19572. }
  19573. oldValue, err := m.oldValue(ctx)
  19574. if err != nil {
  19575. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  19576. }
  19577. return oldValue.Msg, nil
  19578. }
  19579. // ClearMsg clears the value of the "msg" field.
  19580. func (m *MsgMutation) ClearMsg() {
  19581. m.msg = nil
  19582. m.clearedFields[msg.FieldMsg] = struct{}{}
  19583. }
  19584. // MsgCleared returns if the "msg" field was cleared in this mutation.
  19585. func (m *MsgMutation) MsgCleared() bool {
  19586. _, ok := m.clearedFields[msg.FieldMsg]
  19587. return ok
  19588. }
  19589. // ResetMsg resets all changes to the "msg" field.
  19590. func (m *MsgMutation) ResetMsg() {
  19591. m.msg = nil
  19592. delete(m.clearedFields, msg.FieldMsg)
  19593. }
  19594. // SetBatchNo sets the "batch_no" field.
  19595. func (m *MsgMutation) SetBatchNo(s string) {
  19596. m.batch_no = &s
  19597. }
  19598. // BatchNo returns the value of the "batch_no" field in the mutation.
  19599. func (m *MsgMutation) BatchNo() (r string, exists bool) {
  19600. v := m.batch_no
  19601. if v == nil {
  19602. return
  19603. }
  19604. return *v, true
  19605. }
  19606. // OldBatchNo returns the old "batch_no" field's value of the Msg entity.
  19607. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  19608. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19609. func (m *MsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  19610. if !m.op.Is(OpUpdateOne) {
  19611. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  19612. }
  19613. if m.id == nil || m.oldValue == nil {
  19614. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  19615. }
  19616. oldValue, err := m.oldValue(ctx)
  19617. if err != nil {
  19618. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  19619. }
  19620. return oldValue.BatchNo, nil
  19621. }
  19622. // ClearBatchNo clears the value of the "batch_no" field.
  19623. func (m *MsgMutation) ClearBatchNo() {
  19624. m.batch_no = nil
  19625. m.clearedFields[msg.FieldBatchNo] = struct{}{}
  19626. }
  19627. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  19628. func (m *MsgMutation) BatchNoCleared() bool {
  19629. _, ok := m.clearedFields[msg.FieldBatchNo]
  19630. return ok
  19631. }
  19632. // ResetBatchNo resets all changes to the "batch_no" field.
  19633. func (m *MsgMutation) ResetBatchNo() {
  19634. m.batch_no = nil
  19635. delete(m.clearedFields, msg.FieldBatchNo)
  19636. }
  19637. // SetCtype sets the "ctype" field.
  19638. func (m *MsgMutation) SetCtype(u uint64) {
  19639. m.ctype = &u
  19640. m.addctype = nil
  19641. }
  19642. // Ctype returns the value of the "ctype" field in the mutation.
  19643. func (m *MsgMutation) Ctype() (r uint64, exists bool) {
  19644. v := m.ctype
  19645. if v == nil {
  19646. return
  19647. }
  19648. return *v, true
  19649. }
  19650. // OldCtype returns the old "ctype" field's value of the Msg entity.
  19651. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  19652. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19653. func (m *MsgMutation) OldCtype(ctx context.Context) (v uint64, err error) {
  19654. if !m.op.Is(OpUpdateOne) {
  19655. return v, errors.New("OldCtype is only allowed on UpdateOne operations")
  19656. }
  19657. if m.id == nil || m.oldValue == nil {
  19658. return v, errors.New("OldCtype requires an ID field in the mutation")
  19659. }
  19660. oldValue, err := m.oldValue(ctx)
  19661. if err != nil {
  19662. return v, fmt.Errorf("querying old value for OldCtype: %w", err)
  19663. }
  19664. return oldValue.Ctype, nil
  19665. }
  19666. // AddCtype adds u to the "ctype" field.
  19667. func (m *MsgMutation) AddCtype(u int64) {
  19668. if m.addctype != nil {
  19669. *m.addctype += u
  19670. } else {
  19671. m.addctype = &u
  19672. }
  19673. }
  19674. // AddedCtype returns the value that was added to the "ctype" field in this mutation.
  19675. func (m *MsgMutation) AddedCtype() (r int64, exists bool) {
  19676. v := m.addctype
  19677. if v == nil {
  19678. return
  19679. }
  19680. return *v, true
  19681. }
  19682. // ResetCtype resets all changes to the "ctype" field.
  19683. func (m *MsgMutation) ResetCtype() {
  19684. m.ctype = nil
  19685. m.addctype = nil
  19686. }
  19687. // SetCc sets the "cc" field.
  19688. func (m *MsgMutation) SetCc(s string) {
  19689. m.cc = &s
  19690. }
  19691. // Cc returns the value of the "cc" field in the mutation.
  19692. func (m *MsgMutation) Cc() (r string, exists bool) {
  19693. v := m.cc
  19694. if v == nil {
  19695. return
  19696. }
  19697. return *v, true
  19698. }
  19699. // OldCc returns the old "cc" field's value of the Msg entity.
  19700. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  19701. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19702. func (m *MsgMutation) OldCc(ctx context.Context) (v string, err error) {
  19703. if !m.op.Is(OpUpdateOne) {
  19704. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  19705. }
  19706. if m.id == nil || m.oldValue == nil {
  19707. return v, errors.New("OldCc requires an ID field in the mutation")
  19708. }
  19709. oldValue, err := m.oldValue(ctx)
  19710. if err != nil {
  19711. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  19712. }
  19713. return oldValue.Cc, nil
  19714. }
  19715. // ResetCc resets all changes to the "cc" field.
  19716. func (m *MsgMutation) ResetCc() {
  19717. m.cc = nil
  19718. }
  19719. // SetPhone sets the "phone" field.
  19720. func (m *MsgMutation) SetPhone(s string) {
  19721. m.phone = &s
  19722. }
  19723. // Phone returns the value of the "phone" field in the mutation.
  19724. func (m *MsgMutation) Phone() (r string, exists bool) {
  19725. v := m.phone
  19726. if v == nil {
  19727. return
  19728. }
  19729. return *v, true
  19730. }
  19731. // OldPhone returns the old "phone" field's value of the Msg entity.
  19732. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  19733. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19734. func (m *MsgMutation) OldPhone(ctx context.Context) (v string, err error) {
  19735. if !m.op.Is(OpUpdateOne) {
  19736. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  19737. }
  19738. if m.id == nil || m.oldValue == nil {
  19739. return v, errors.New("OldPhone requires an ID field in the mutation")
  19740. }
  19741. oldValue, err := m.oldValue(ctx)
  19742. if err != nil {
  19743. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  19744. }
  19745. return oldValue.Phone, nil
  19746. }
  19747. // ResetPhone resets all changes to the "phone" field.
  19748. func (m *MsgMutation) ResetPhone() {
  19749. m.phone = nil
  19750. }
  19751. // Where appends a list predicates to the MsgMutation builder.
  19752. func (m *MsgMutation) Where(ps ...predicate.Msg) {
  19753. m.predicates = append(m.predicates, ps...)
  19754. }
  19755. // WhereP appends storage-level predicates to the MsgMutation builder. Using this method,
  19756. // users can use type-assertion to append predicates that do not depend on any generated package.
  19757. func (m *MsgMutation) WhereP(ps ...func(*sql.Selector)) {
  19758. p := make([]predicate.Msg, len(ps))
  19759. for i := range ps {
  19760. p[i] = ps[i]
  19761. }
  19762. m.Where(p...)
  19763. }
  19764. // Op returns the operation name.
  19765. func (m *MsgMutation) Op() Op {
  19766. return m.op
  19767. }
  19768. // SetOp allows setting the mutation operation.
  19769. func (m *MsgMutation) SetOp(op Op) {
  19770. m.op = op
  19771. }
  19772. // Type returns the node type of this mutation (Msg).
  19773. func (m *MsgMutation) Type() string {
  19774. return m.typ
  19775. }
  19776. // Fields returns all fields that were changed during this mutation. Note that in
  19777. // order to get all numeric fields that were incremented/decremented, call
  19778. // AddedFields().
  19779. func (m *MsgMutation) Fields() []string {
  19780. fields := make([]string, 0, 12)
  19781. if m.created_at != nil {
  19782. fields = append(fields, msg.FieldCreatedAt)
  19783. }
  19784. if m.updated_at != nil {
  19785. fields = append(fields, msg.FieldUpdatedAt)
  19786. }
  19787. if m.deleted_at != nil {
  19788. fields = append(fields, msg.FieldDeletedAt)
  19789. }
  19790. if m.status != nil {
  19791. fields = append(fields, msg.FieldStatus)
  19792. }
  19793. if m.fromwxid != nil {
  19794. fields = append(fields, msg.FieldFromwxid)
  19795. }
  19796. if m.toid != nil {
  19797. fields = append(fields, msg.FieldToid)
  19798. }
  19799. if m.msgtype != nil {
  19800. fields = append(fields, msg.FieldMsgtype)
  19801. }
  19802. if m.msg != nil {
  19803. fields = append(fields, msg.FieldMsg)
  19804. }
  19805. if m.batch_no != nil {
  19806. fields = append(fields, msg.FieldBatchNo)
  19807. }
  19808. if m.ctype != nil {
  19809. fields = append(fields, msg.FieldCtype)
  19810. }
  19811. if m.cc != nil {
  19812. fields = append(fields, msg.FieldCc)
  19813. }
  19814. if m.phone != nil {
  19815. fields = append(fields, msg.FieldPhone)
  19816. }
  19817. return fields
  19818. }
  19819. // Field returns the value of a field with the given name. The second boolean
  19820. // return value indicates that this field was not set, or was not defined in the
  19821. // schema.
  19822. func (m *MsgMutation) Field(name string) (ent.Value, bool) {
  19823. switch name {
  19824. case msg.FieldCreatedAt:
  19825. return m.CreatedAt()
  19826. case msg.FieldUpdatedAt:
  19827. return m.UpdatedAt()
  19828. case msg.FieldDeletedAt:
  19829. return m.DeletedAt()
  19830. case msg.FieldStatus:
  19831. return m.Status()
  19832. case msg.FieldFromwxid:
  19833. return m.Fromwxid()
  19834. case msg.FieldToid:
  19835. return m.Toid()
  19836. case msg.FieldMsgtype:
  19837. return m.Msgtype()
  19838. case msg.FieldMsg:
  19839. return m.Msg()
  19840. case msg.FieldBatchNo:
  19841. return m.BatchNo()
  19842. case msg.FieldCtype:
  19843. return m.Ctype()
  19844. case msg.FieldCc:
  19845. return m.Cc()
  19846. case msg.FieldPhone:
  19847. return m.Phone()
  19848. }
  19849. return nil, false
  19850. }
  19851. // OldField returns the old value of the field from the database. An error is
  19852. // returned if the mutation operation is not UpdateOne, or the query to the
  19853. // database failed.
  19854. func (m *MsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  19855. switch name {
  19856. case msg.FieldCreatedAt:
  19857. return m.OldCreatedAt(ctx)
  19858. case msg.FieldUpdatedAt:
  19859. return m.OldUpdatedAt(ctx)
  19860. case msg.FieldDeletedAt:
  19861. return m.OldDeletedAt(ctx)
  19862. case msg.FieldStatus:
  19863. return m.OldStatus(ctx)
  19864. case msg.FieldFromwxid:
  19865. return m.OldFromwxid(ctx)
  19866. case msg.FieldToid:
  19867. return m.OldToid(ctx)
  19868. case msg.FieldMsgtype:
  19869. return m.OldMsgtype(ctx)
  19870. case msg.FieldMsg:
  19871. return m.OldMsg(ctx)
  19872. case msg.FieldBatchNo:
  19873. return m.OldBatchNo(ctx)
  19874. case msg.FieldCtype:
  19875. return m.OldCtype(ctx)
  19876. case msg.FieldCc:
  19877. return m.OldCc(ctx)
  19878. case msg.FieldPhone:
  19879. return m.OldPhone(ctx)
  19880. }
  19881. return nil, fmt.Errorf("unknown Msg field %s", name)
  19882. }
  19883. // SetField sets the value of a field with the given name. It returns an error if
  19884. // the field is not defined in the schema, or if the type mismatched the field
  19885. // type.
  19886. func (m *MsgMutation) SetField(name string, value ent.Value) error {
  19887. switch name {
  19888. case msg.FieldCreatedAt:
  19889. v, ok := value.(time.Time)
  19890. if !ok {
  19891. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19892. }
  19893. m.SetCreatedAt(v)
  19894. return nil
  19895. case msg.FieldUpdatedAt:
  19896. v, ok := value.(time.Time)
  19897. if !ok {
  19898. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19899. }
  19900. m.SetUpdatedAt(v)
  19901. return nil
  19902. case msg.FieldDeletedAt:
  19903. v, ok := value.(time.Time)
  19904. if !ok {
  19905. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19906. }
  19907. m.SetDeletedAt(v)
  19908. return nil
  19909. case msg.FieldStatus:
  19910. v, ok := value.(uint8)
  19911. if !ok {
  19912. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19913. }
  19914. m.SetStatus(v)
  19915. return nil
  19916. case msg.FieldFromwxid:
  19917. v, ok := value.(string)
  19918. if !ok {
  19919. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19920. }
  19921. m.SetFromwxid(v)
  19922. return nil
  19923. case msg.FieldToid:
  19924. v, ok := value.(string)
  19925. if !ok {
  19926. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19927. }
  19928. m.SetToid(v)
  19929. return nil
  19930. case msg.FieldMsgtype:
  19931. v, ok := value.(int32)
  19932. if !ok {
  19933. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19934. }
  19935. m.SetMsgtype(v)
  19936. return nil
  19937. case msg.FieldMsg:
  19938. v, ok := value.(string)
  19939. if !ok {
  19940. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19941. }
  19942. m.SetMsg(v)
  19943. return nil
  19944. case msg.FieldBatchNo:
  19945. v, ok := value.(string)
  19946. if !ok {
  19947. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19948. }
  19949. m.SetBatchNo(v)
  19950. return nil
  19951. case msg.FieldCtype:
  19952. v, ok := value.(uint64)
  19953. if !ok {
  19954. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19955. }
  19956. m.SetCtype(v)
  19957. return nil
  19958. case msg.FieldCc:
  19959. v, ok := value.(string)
  19960. if !ok {
  19961. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19962. }
  19963. m.SetCc(v)
  19964. return nil
  19965. case msg.FieldPhone:
  19966. v, ok := value.(string)
  19967. if !ok {
  19968. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19969. }
  19970. m.SetPhone(v)
  19971. return nil
  19972. }
  19973. return fmt.Errorf("unknown Msg field %s", name)
  19974. }
  19975. // AddedFields returns all numeric fields that were incremented/decremented during
  19976. // this mutation.
  19977. func (m *MsgMutation) AddedFields() []string {
  19978. var fields []string
  19979. if m.addstatus != nil {
  19980. fields = append(fields, msg.FieldStatus)
  19981. }
  19982. if m.addmsgtype != nil {
  19983. fields = append(fields, msg.FieldMsgtype)
  19984. }
  19985. if m.addctype != nil {
  19986. fields = append(fields, msg.FieldCtype)
  19987. }
  19988. return fields
  19989. }
  19990. // AddedField returns the numeric value that was incremented/decremented on a field
  19991. // with the given name. The second boolean return value indicates that this field
  19992. // was not set, or was not defined in the schema.
  19993. func (m *MsgMutation) AddedField(name string) (ent.Value, bool) {
  19994. switch name {
  19995. case msg.FieldStatus:
  19996. return m.AddedStatus()
  19997. case msg.FieldMsgtype:
  19998. return m.AddedMsgtype()
  19999. case msg.FieldCtype:
  20000. return m.AddedCtype()
  20001. }
  20002. return nil, false
  20003. }
  20004. // AddField adds the value to the field with the given name. It returns an error if
  20005. // the field is not defined in the schema, or if the type mismatched the field
  20006. // type.
  20007. func (m *MsgMutation) AddField(name string, value ent.Value) error {
  20008. switch name {
  20009. case msg.FieldStatus:
  20010. v, ok := value.(int8)
  20011. if !ok {
  20012. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20013. }
  20014. m.AddStatus(v)
  20015. return nil
  20016. case msg.FieldMsgtype:
  20017. v, ok := value.(int32)
  20018. if !ok {
  20019. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20020. }
  20021. m.AddMsgtype(v)
  20022. return nil
  20023. case msg.FieldCtype:
  20024. v, ok := value.(int64)
  20025. if !ok {
  20026. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20027. }
  20028. m.AddCtype(v)
  20029. return nil
  20030. }
  20031. return fmt.Errorf("unknown Msg numeric field %s", name)
  20032. }
  20033. // ClearedFields returns all nullable fields that were cleared during this
  20034. // mutation.
  20035. func (m *MsgMutation) ClearedFields() []string {
  20036. var fields []string
  20037. if m.FieldCleared(msg.FieldDeletedAt) {
  20038. fields = append(fields, msg.FieldDeletedAt)
  20039. }
  20040. if m.FieldCleared(msg.FieldStatus) {
  20041. fields = append(fields, msg.FieldStatus)
  20042. }
  20043. if m.FieldCleared(msg.FieldFromwxid) {
  20044. fields = append(fields, msg.FieldFromwxid)
  20045. }
  20046. if m.FieldCleared(msg.FieldToid) {
  20047. fields = append(fields, msg.FieldToid)
  20048. }
  20049. if m.FieldCleared(msg.FieldMsgtype) {
  20050. fields = append(fields, msg.FieldMsgtype)
  20051. }
  20052. if m.FieldCleared(msg.FieldMsg) {
  20053. fields = append(fields, msg.FieldMsg)
  20054. }
  20055. if m.FieldCleared(msg.FieldBatchNo) {
  20056. fields = append(fields, msg.FieldBatchNo)
  20057. }
  20058. return fields
  20059. }
  20060. // FieldCleared returns a boolean indicating if a field with the given name was
  20061. // cleared in this mutation.
  20062. func (m *MsgMutation) FieldCleared(name string) bool {
  20063. _, ok := m.clearedFields[name]
  20064. return ok
  20065. }
  20066. // ClearField clears the value of the field with the given name. It returns an
  20067. // error if the field is not defined in the schema.
  20068. func (m *MsgMutation) ClearField(name string) error {
  20069. switch name {
  20070. case msg.FieldDeletedAt:
  20071. m.ClearDeletedAt()
  20072. return nil
  20073. case msg.FieldStatus:
  20074. m.ClearStatus()
  20075. return nil
  20076. case msg.FieldFromwxid:
  20077. m.ClearFromwxid()
  20078. return nil
  20079. case msg.FieldToid:
  20080. m.ClearToid()
  20081. return nil
  20082. case msg.FieldMsgtype:
  20083. m.ClearMsgtype()
  20084. return nil
  20085. case msg.FieldMsg:
  20086. m.ClearMsg()
  20087. return nil
  20088. case msg.FieldBatchNo:
  20089. m.ClearBatchNo()
  20090. return nil
  20091. }
  20092. return fmt.Errorf("unknown Msg nullable field %s", name)
  20093. }
  20094. // ResetField resets all changes in the mutation for the field with the given name.
  20095. // It returns an error if the field is not defined in the schema.
  20096. func (m *MsgMutation) ResetField(name string) error {
  20097. switch name {
  20098. case msg.FieldCreatedAt:
  20099. m.ResetCreatedAt()
  20100. return nil
  20101. case msg.FieldUpdatedAt:
  20102. m.ResetUpdatedAt()
  20103. return nil
  20104. case msg.FieldDeletedAt:
  20105. m.ResetDeletedAt()
  20106. return nil
  20107. case msg.FieldStatus:
  20108. m.ResetStatus()
  20109. return nil
  20110. case msg.FieldFromwxid:
  20111. m.ResetFromwxid()
  20112. return nil
  20113. case msg.FieldToid:
  20114. m.ResetToid()
  20115. return nil
  20116. case msg.FieldMsgtype:
  20117. m.ResetMsgtype()
  20118. return nil
  20119. case msg.FieldMsg:
  20120. m.ResetMsg()
  20121. return nil
  20122. case msg.FieldBatchNo:
  20123. m.ResetBatchNo()
  20124. return nil
  20125. case msg.FieldCtype:
  20126. m.ResetCtype()
  20127. return nil
  20128. case msg.FieldCc:
  20129. m.ResetCc()
  20130. return nil
  20131. case msg.FieldPhone:
  20132. m.ResetPhone()
  20133. return nil
  20134. }
  20135. return fmt.Errorf("unknown Msg field %s", name)
  20136. }
  20137. // AddedEdges returns all edge names that were set/added in this mutation.
  20138. func (m *MsgMutation) AddedEdges() []string {
  20139. edges := make([]string, 0, 0)
  20140. return edges
  20141. }
  20142. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  20143. // name in this mutation.
  20144. func (m *MsgMutation) AddedIDs(name string) []ent.Value {
  20145. return nil
  20146. }
  20147. // RemovedEdges returns all edge names that were removed in this mutation.
  20148. func (m *MsgMutation) RemovedEdges() []string {
  20149. edges := make([]string, 0, 0)
  20150. return edges
  20151. }
  20152. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  20153. // the given name in this mutation.
  20154. func (m *MsgMutation) RemovedIDs(name string) []ent.Value {
  20155. return nil
  20156. }
  20157. // ClearedEdges returns all edge names that were cleared in this mutation.
  20158. func (m *MsgMutation) ClearedEdges() []string {
  20159. edges := make([]string, 0, 0)
  20160. return edges
  20161. }
  20162. // EdgeCleared returns a boolean which indicates if the edge with the given name
  20163. // was cleared in this mutation.
  20164. func (m *MsgMutation) EdgeCleared(name string) bool {
  20165. return false
  20166. }
  20167. // ClearEdge clears the value of the edge with the given name. It returns an error
  20168. // if that edge is not defined in the schema.
  20169. func (m *MsgMutation) ClearEdge(name string) error {
  20170. return fmt.Errorf("unknown Msg unique edge %s", name)
  20171. }
  20172. // ResetEdge resets all changes to the edge with the given name in this mutation.
  20173. // It returns an error if the edge is not defined in the schema.
  20174. func (m *MsgMutation) ResetEdge(name string) error {
  20175. return fmt.Errorf("unknown Msg edge %s", name)
  20176. }
  20177. // PayRechargeMutation represents an operation that mutates the PayRecharge nodes in the graph.
  20178. type PayRechargeMutation struct {
  20179. config
  20180. op Op
  20181. typ string
  20182. id *uint64
  20183. created_at *time.Time
  20184. updated_at *time.Time
  20185. deleted_at *time.Time
  20186. user_id *string
  20187. number *float32
  20188. addnumber *float32
  20189. status *int
  20190. addstatus *int
  20191. money *float32
  20192. addmoney *float32
  20193. out_trade_no *string
  20194. organization_id *uint64
  20195. addorganization_id *int64
  20196. clearedFields map[string]struct{}
  20197. done bool
  20198. oldValue func(context.Context) (*PayRecharge, error)
  20199. predicates []predicate.PayRecharge
  20200. }
  20201. var _ ent.Mutation = (*PayRechargeMutation)(nil)
  20202. // payrechargeOption allows management of the mutation configuration using functional options.
  20203. type payrechargeOption func(*PayRechargeMutation)
  20204. // newPayRechargeMutation creates new mutation for the PayRecharge entity.
  20205. func newPayRechargeMutation(c config, op Op, opts ...payrechargeOption) *PayRechargeMutation {
  20206. m := &PayRechargeMutation{
  20207. config: c,
  20208. op: op,
  20209. typ: TypePayRecharge,
  20210. clearedFields: make(map[string]struct{}),
  20211. }
  20212. for _, opt := range opts {
  20213. opt(m)
  20214. }
  20215. return m
  20216. }
  20217. // withPayRechargeID sets the ID field of the mutation.
  20218. func withPayRechargeID(id uint64) payrechargeOption {
  20219. return func(m *PayRechargeMutation) {
  20220. var (
  20221. err error
  20222. once sync.Once
  20223. value *PayRecharge
  20224. )
  20225. m.oldValue = func(ctx context.Context) (*PayRecharge, error) {
  20226. once.Do(func() {
  20227. if m.done {
  20228. err = errors.New("querying old values post mutation is not allowed")
  20229. } else {
  20230. value, err = m.Client().PayRecharge.Get(ctx, id)
  20231. }
  20232. })
  20233. return value, err
  20234. }
  20235. m.id = &id
  20236. }
  20237. }
  20238. // withPayRecharge sets the old PayRecharge of the mutation.
  20239. func withPayRecharge(node *PayRecharge) payrechargeOption {
  20240. return func(m *PayRechargeMutation) {
  20241. m.oldValue = func(context.Context) (*PayRecharge, error) {
  20242. return node, nil
  20243. }
  20244. m.id = &node.ID
  20245. }
  20246. }
  20247. // Client returns a new `ent.Client` from the mutation. If the mutation was
  20248. // executed in a transaction (ent.Tx), a transactional client is returned.
  20249. func (m PayRechargeMutation) Client() *Client {
  20250. client := &Client{config: m.config}
  20251. client.init()
  20252. return client
  20253. }
  20254. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  20255. // it returns an error otherwise.
  20256. func (m PayRechargeMutation) Tx() (*Tx, error) {
  20257. if _, ok := m.driver.(*txDriver); !ok {
  20258. return nil, errors.New("ent: mutation is not running in a transaction")
  20259. }
  20260. tx := &Tx{config: m.config}
  20261. tx.init()
  20262. return tx, nil
  20263. }
  20264. // SetID sets the value of the id field. Note that this
  20265. // operation is only accepted on creation of PayRecharge entities.
  20266. func (m *PayRechargeMutation) SetID(id uint64) {
  20267. m.id = &id
  20268. }
  20269. // ID returns the ID value in the mutation. Note that the ID is only available
  20270. // if it was provided to the builder or after it was returned from the database.
  20271. func (m *PayRechargeMutation) ID() (id uint64, exists bool) {
  20272. if m.id == nil {
  20273. return
  20274. }
  20275. return *m.id, true
  20276. }
  20277. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  20278. // That means, if the mutation is applied within a transaction with an isolation level such
  20279. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  20280. // or updated by the mutation.
  20281. func (m *PayRechargeMutation) IDs(ctx context.Context) ([]uint64, error) {
  20282. switch {
  20283. case m.op.Is(OpUpdateOne | OpDeleteOne):
  20284. id, exists := m.ID()
  20285. if exists {
  20286. return []uint64{id}, nil
  20287. }
  20288. fallthrough
  20289. case m.op.Is(OpUpdate | OpDelete):
  20290. return m.Client().PayRecharge.Query().Where(m.predicates...).IDs(ctx)
  20291. default:
  20292. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  20293. }
  20294. }
  20295. // SetCreatedAt sets the "created_at" field.
  20296. func (m *PayRechargeMutation) SetCreatedAt(t time.Time) {
  20297. m.created_at = &t
  20298. }
  20299. // CreatedAt returns the value of the "created_at" field in the mutation.
  20300. func (m *PayRechargeMutation) CreatedAt() (r time.Time, exists bool) {
  20301. v := m.created_at
  20302. if v == nil {
  20303. return
  20304. }
  20305. return *v, true
  20306. }
  20307. // OldCreatedAt returns the old "created_at" field's value of the PayRecharge entity.
  20308. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  20309. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20310. func (m *PayRechargeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  20311. if !m.op.Is(OpUpdateOne) {
  20312. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  20313. }
  20314. if m.id == nil || m.oldValue == nil {
  20315. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  20316. }
  20317. oldValue, err := m.oldValue(ctx)
  20318. if err != nil {
  20319. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  20320. }
  20321. return oldValue.CreatedAt, nil
  20322. }
  20323. // ResetCreatedAt resets all changes to the "created_at" field.
  20324. func (m *PayRechargeMutation) ResetCreatedAt() {
  20325. m.created_at = nil
  20326. }
  20327. // SetUpdatedAt sets the "updated_at" field.
  20328. func (m *PayRechargeMutation) SetUpdatedAt(t time.Time) {
  20329. m.updated_at = &t
  20330. }
  20331. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  20332. func (m *PayRechargeMutation) UpdatedAt() (r time.Time, exists bool) {
  20333. v := m.updated_at
  20334. if v == nil {
  20335. return
  20336. }
  20337. return *v, true
  20338. }
  20339. // OldUpdatedAt returns the old "updated_at" field's value of the PayRecharge entity.
  20340. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  20341. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20342. func (m *PayRechargeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  20343. if !m.op.Is(OpUpdateOne) {
  20344. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  20345. }
  20346. if m.id == nil || m.oldValue == nil {
  20347. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  20348. }
  20349. oldValue, err := m.oldValue(ctx)
  20350. if err != nil {
  20351. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  20352. }
  20353. return oldValue.UpdatedAt, nil
  20354. }
  20355. // ResetUpdatedAt resets all changes to the "updated_at" field.
  20356. func (m *PayRechargeMutation) ResetUpdatedAt() {
  20357. m.updated_at = nil
  20358. }
  20359. // SetDeletedAt sets the "deleted_at" field.
  20360. func (m *PayRechargeMutation) SetDeletedAt(t time.Time) {
  20361. m.deleted_at = &t
  20362. }
  20363. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  20364. func (m *PayRechargeMutation) DeletedAt() (r time.Time, exists bool) {
  20365. v := m.deleted_at
  20366. if v == nil {
  20367. return
  20368. }
  20369. return *v, true
  20370. }
  20371. // OldDeletedAt returns the old "deleted_at" field's value of the PayRecharge entity.
  20372. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  20373. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20374. func (m *PayRechargeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  20375. if !m.op.Is(OpUpdateOne) {
  20376. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  20377. }
  20378. if m.id == nil || m.oldValue == nil {
  20379. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  20380. }
  20381. oldValue, err := m.oldValue(ctx)
  20382. if err != nil {
  20383. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  20384. }
  20385. return oldValue.DeletedAt, nil
  20386. }
  20387. // ClearDeletedAt clears the value of the "deleted_at" field.
  20388. func (m *PayRechargeMutation) ClearDeletedAt() {
  20389. m.deleted_at = nil
  20390. m.clearedFields[payrecharge.FieldDeletedAt] = struct{}{}
  20391. }
  20392. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  20393. func (m *PayRechargeMutation) DeletedAtCleared() bool {
  20394. _, ok := m.clearedFields[payrecharge.FieldDeletedAt]
  20395. return ok
  20396. }
  20397. // ResetDeletedAt resets all changes to the "deleted_at" field.
  20398. func (m *PayRechargeMutation) ResetDeletedAt() {
  20399. m.deleted_at = nil
  20400. delete(m.clearedFields, payrecharge.FieldDeletedAt)
  20401. }
  20402. // SetUserID sets the "user_id" field.
  20403. func (m *PayRechargeMutation) SetUserID(s string) {
  20404. m.user_id = &s
  20405. }
  20406. // UserID returns the value of the "user_id" field in the mutation.
  20407. func (m *PayRechargeMutation) UserID() (r string, exists bool) {
  20408. v := m.user_id
  20409. if v == nil {
  20410. return
  20411. }
  20412. return *v, true
  20413. }
  20414. // OldUserID returns the old "user_id" field's value of the PayRecharge entity.
  20415. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  20416. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20417. func (m *PayRechargeMutation) OldUserID(ctx context.Context) (v string, err error) {
  20418. if !m.op.Is(OpUpdateOne) {
  20419. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  20420. }
  20421. if m.id == nil || m.oldValue == nil {
  20422. return v, errors.New("OldUserID requires an ID field in the mutation")
  20423. }
  20424. oldValue, err := m.oldValue(ctx)
  20425. if err != nil {
  20426. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  20427. }
  20428. return oldValue.UserID, nil
  20429. }
  20430. // ResetUserID resets all changes to the "user_id" field.
  20431. func (m *PayRechargeMutation) ResetUserID() {
  20432. m.user_id = nil
  20433. }
  20434. // SetNumber sets the "number" field.
  20435. func (m *PayRechargeMutation) SetNumber(f float32) {
  20436. m.number = &f
  20437. m.addnumber = nil
  20438. }
  20439. // Number returns the value of the "number" field in the mutation.
  20440. func (m *PayRechargeMutation) Number() (r float32, exists bool) {
  20441. v := m.number
  20442. if v == nil {
  20443. return
  20444. }
  20445. return *v, true
  20446. }
  20447. // OldNumber returns the old "number" field's value of the PayRecharge entity.
  20448. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  20449. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20450. func (m *PayRechargeMutation) OldNumber(ctx context.Context) (v float32, err error) {
  20451. if !m.op.Is(OpUpdateOne) {
  20452. return v, errors.New("OldNumber is only allowed on UpdateOne operations")
  20453. }
  20454. if m.id == nil || m.oldValue == nil {
  20455. return v, errors.New("OldNumber requires an ID field in the mutation")
  20456. }
  20457. oldValue, err := m.oldValue(ctx)
  20458. if err != nil {
  20459. return v, fmt.Errorf("querying old value for OldNumber: %w", err)
  20460. }
  20461. return oldValue.Number, nil
  20462. }
  20463. // AddNumber adds f to the "number" field.
  20464. func (m *PayRechargeMutation) AddNumber(f float32) {
  20465. if m.addnumber != nil {
  20466. *m.addnumber += f
  20467. } else {
  20468. m.addnumber = &f
  20469. }
  20470. }
  20471. // AddedNumber returns the value that was added to the "number" field in this mutation.
  20472. func (m *PayRechargeMutation) AddedNumber() (r float32, exists bool) {
  20473. v := m.addnumber
  20474. if v == nil {
  20475. return
  20476. }
  20477. return *v, true
  20478. }
  20479. // ResetNumber resets all changes to the "number" field.
  20480. func (m *PayRechargeMutation) ResetNumber() {
  20481. m.number = nil
  20482. m.addnumber = nil
  20483. }
  20484. // SetStatus sets the "status" field.
  20485. func (m *PayRechargeMutation) SetStatus(i int) {
  20486. m.status = &i
  20487. m.addstatus = nil
  20488. }
  20489. // Status returns the value of the "status" field in the mutation.
  20490. func (m *PayRechargeMutation) Status() (r int, exists bool) {
  20491. v := m.status
  20492. if v == nil {
  20493. return
  20494. }
  20495. return *v, true
  20496. }
  20497. // OldStatus returns the old "status" field's value of the PayRecharge entity.
  20498. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  20499. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20500. func (m *PayRechargeMutation) OldStatus(ctx context.Context) (v int, err error) {
  20501. if !m.op.Is(OpUpdateOne) {
  20502. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  20503. }
  20504. if m.id == nil || m.oldValue == nil {
  20505. return v, errors.New("OldStatus requires an ID field in the mutation")
  20506. }
  20507. oldValue, err := m.oldValue(ctx)
  20508. if err != nil {
  20509. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  20510. }
  20511. return oldValue.Status, nil
  20512. }
  20513. // AddStatus adds i to the "status" field.
  20514. func (m *PayRechargeMutation) AddStatus(i int) {
  20515. if m.addstatus != nil {
  20516. *m.addstatus += i
  20517. } else {
  20518. m.addstatus = &i
  20519. }
  20520. }
  20521. // AddedStatus returns the value that was added to the "status" field in this mutation.
  20522. func (m *PayRechargeMutation) AddedStatus() (r int, exists bool) {
  20523. v := m.addstatus
  20524. if v == nil {
  20525. return
  20526. }
  20527. return *v, true
  20528. }
  20529. // ClearStatus clears the value of the "status" field.
  20530. func (m *PayRechargeMutation) ClearStatus() {
  20531. m.status = nil
  20532. m.addstatus = nil
  20533. m.clearedFields[payrecharge.FieldStatus] = struct{}{}
  20534. }
  20535. // StatusCleared returns if the "status" field was cleared in this mutation.
  20536. func (m *PayRechargeMutation) StatusCleared() bool {
  20537. _, ok := m.clearedFields[payrecharge.FieldStatus]
  20538. return ok
  20539. }
  20540. // ResetStatus resets all changes to the "status" field.
  20541. func (m *PayRechargeMutation) ResetStatus() {
  20542. m.status = nil
  20543. m.addstatus = nil
  20544. delete(m.clearedFields, payrecharge.FieldStatus)
  20545. }
  20546. // SetMoney sets the "money" field.
  20547. func (m *PayRechargeMutation) SetMoney(f float32) {
  20548. m.money = &f
  20549. m.addmoney = nil
  20550. }
  20551. // Money returns the value of the "money" field in the mutation.
  20552. func (m *PayRechargeMutation) Money() (r float32, exists bool) {
  20553. v := m.money
  20554. if v == nil {
  20555. return
  20556. }
  20557. return *v, true
  20558. }
  20559. // OldMoney returns the old "money" field's value of the PayRecharge entity.
  20560. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  20561. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20562. func (m *PayRechargeMutation) OldMoney(ctx context.Context) (v float32, err error) {
  20563. if !m.op.Is(OpUpdateOne) {
  20564. return v, errors.New("OldMoney is only allowed on UpdateOne operations")
  20565. }
  20566. if m.id == nil || m.oldValue == nil {
  20567. return v, errors.New("OldMoney requires an ID field in the mutation")
  20568. }
  20569. oldValue, err := m.oldValue(ctx)
  20570. if err != nil {
  20571. return v, fmt.Errorf("querying old value for OldMoney: %w", err)
  20572. }
  20573. return oldValue.Money, nil
  20574. }
  20575. // AddMoney adds f to the "money" field.
  20576. func (m *PayRechargeMutation) AddMoney(f float32) {
  20577. if m.addmoney != nil {
  20578. *m.addmoney += f
  20579. } else {
  20580. m.addmoney = &f
  20581. }
  20582. }
  20583. // AddedMoney returns the value that was added to the "money" field in this mutation.
  20584. func (m *PayRechargeMutation) AddedMoney() (r float32, exists bool) {
  20585. v := m.addmoney
  20586. if v == nil {
  20587. return
  20588. }
  20589. return *v, true
  20590. }
  20591. // ClearMoney clears the value of the "money" field.
  20592. func (m *PayRechargeMutation) ClearMoney() {
  20593. m.money = nil
  20594. m.addmoney = nil
  20595. m.clearedFields[payrecharge.FieldMoney] = struct{}{}
  20596. }
  20597. // MoneyCleared returns if the "money" field was cleared in this mutation.
  20598. func (m *PayRechargeMutation) MoneyCleared() bool {
  20599. _, ok := m.clearedFields[payrecharge.FieldMoney]
  20600. return ok
  20601. }
  20602. // ResetMoney resets all changes to the "money" field.
  20603. func (m *PayRechargeMutation) ResetMoney() {
  20604. m.money = nil
  20605. m.addmoney = nil
  20606. delete(m.clearedFields, payrecharge.FieldMoney)
  20607. }
  20608. // SetOutTradeNo sets the "out_trade_no" field.
  20609. func (m *PayRechargeMutation) SetOutTradeNo(s string) {
  20610. m.out_trade_no = &s
  20611. }
  20612. // OutTradeNo returns the value of the "out_trade_no" field in the mutation.
  20613. func (m *PayRechargeMutation) OutTradeNo() (r string, exists bool) {
  20614. v := m.out_trade_no
  20615. if v == nil {
  20616. return
  20617. }
  20618. return *v, true
  20619. }
  20620. // OldOutTradeNo returns the old "out_trade_no" field's value of the PayRecharge entity.
  20621. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  20622. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20623. func (m *PayRechargeMutation) OldOutTradeNo(ctx context.Context) (v string, err error) {
  20624. if !m.op.Is(OpUpdateOne) {
  20625. return v, errors.New("OldOutTradeNo is only allowed on UpdateOne operations")
  20626. }
  20627. if m.id == nil || m.oldValue == nil {
  20628. return v, errors.New("OldOutTradeNo requires an ID field in the mutation")
  20629. }
  20630. oldValue, err := m.oldValue(ctx)
  20631. if err != nil {
  20632. return v, fmt.Errorf("querying old value for OldOutTradeNo: %w", err)
  20633. }
  20634. return oldValue.OutTradeNo, nil
  20635. }
  20636. // ClearOutTradeNo clears the value of the "out_trade_no" field.
  20637. func (m *PayRechargeMutation) ClearOutTradeNo() {
  20638. m.out_trade_no = nil
  20639. m.clearedFields[payrecharge.FieldOutTradeNo] = struct{}{}
  20640. }
  20641. // OutTradeNoCleared returns if the "out_trade_no" field was cleared in this mutation.
  20642. func (m *PayRechargeMutation) OutTradeNoCleared() bool {
  20643. _, ok := m.clearedFields[payrecharge.FieldOutTradeNo]
  20644. return ok
  20645. }
  20646. // ResetOutTradeNo resets all changes to the "out_trade_no" field.
  20647. func (m *PayRechargeMutation) ResetOutTradeNo() {
  20648. m.out_trade_no = nil
  20649. delete(m.clearedFields, payrecharge.FieldOutTradeNo)
  20650. }
  20651. // SetOrganizationID sets the "organization_id" field.
  20652. func (m *PayRechargeMutation) SetOrganizationID(u uint64) {
  20653. m.organization_id = &u
  20654. m.addorganization_id = nil
  20655. }
  20656. // OrganizationID returns the value of the "organization_id" field in the mutation.
  20657. func (m *PayRechargeMutation) OrganizationID() (r uint64, exists bool) {
  20658. v := m.organization_id
  20659. if v == nil {
  20660. return
  20661. }
  20662. return *v, true
  20663. }
  20664. // OldOrganizationID returns the old "organization_id" field's value of the PayRecharge entity.
  20665. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  20666. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20667. func (m *PayRechargeMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  20668. if !m.op.Is(OpUpdateOne) {
  20669. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  20670. }
  20671. if m.id == nil || m.oldValue == nil {
  20672. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  20673. }
  20674. oldValue, err := m.oldValue(ctx)
  20675. if err != nil {
  20676. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  20677. }
  20678. return oldValue.OrganizationID, nil
  20679. }
  20680. // AddOrganizationID adds u to the "organization_id" field.
  20681. func (m *PayRechargeMutation) AddOrganizationID(u int64) {
  20682. if m.addorganization_id != nil {
  20683. *m.addorganization_id += u
  20684. } else {
  20685. m.addorganization_id = &u
  20686. }
  20687. }
  20688. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  20689. func (m *PayRechargeMutation) AddedOrganizationID() (r int64, exists bool) {
  20690. v := m.addorganization_id
  20691. if v == nil {
  20692. return
  20693. }
  20694. return *v, true
  20695. }
  20696. // ResetOrganizationID resets all changes to the "organization_id" field.
  20697. func (m *PayRechargeMutation) ResetOrganizationID() {
  20698. m.organization_id = nil
  20699. m.addorganization_id = nil
  20700. }
  20701. // Where appends a list predicates to the PayRechargeMutation builder.
  20702. func (m *PayRechargeMutation) Where(ps ...predicate.PayRecharge) {
  20703. m.predicates = append(m.predicates, ps...)
  20704. }
  20705. // WhereP appends storage-level predicates to the PayRechargeMutation builder. Using this method,
  20706. // users can use type-assertion to append predicates that do not depend on any generated package.
  20707. func (m *PayRechargeMutation) WhereP(ps ...func(*sql.Selector)) {
  20708. p := make([]predicate.PayRecharge, len(ps))
  20709. for i := range ps {
  20710. p[i] = ps[i]
  20711. }
  20712. m.Where(p...)
  20713. }
  20714. // Op returns the operation name.
  20715. func (m *PayRechargeMutation) Op() Op {
  20716. return m.op
  20717. }
  20718. // SetOp allows setting the mutation operation.
  20719. func (m *PayRechargeMutation) SetOp(op Op) {
  20720. m.op = op
  20721. }
  20722. // Type returns the node type of this mutation (PayRecharge).
  20723. func (m *PayRechargeMutation) Type() string {
  20724. return m.typ
  20725. }
  20726. // Fields returns all fields that were changed during this mutation. Note that in
  20727. // order to get all numeric fields that were incremented/decremented, call
  20728. // AddedFields().
  20729. func (m *PayRechargeMutation) Fields() []string {
  20730. fields := make([]string, 0, 9)
  20731. if m.created_at != nil {
  20732. fields = append(fields, payrecharge.FieldCreatedAt)
  20733. }
  20734. if m.updated_at != nil {
  20735. fields = append(fields, payrecharge.FieldUpdatedAt)
  20736. }
  20737. if m.deleted_at != nil {
  20738. fields = append(fields, payrecharge.FieldDeletedAt)
  20739. }
  20740. if m.user_id != nil {
  20741. fields = append(fields, payrecharge.FieldUserID)
  20742. }
  20743. if m.number != nil {
  20744. fields = append(fields, payrecharge.FieldNumber)
  20745. }
  20746. if m.status != nil {
  20747. fields = append(fields, payrecharge.FieldStatus)
  20748. }
  20749. if m.money != nil {
  20750. fields = append(fields, payrecharge.FieldMoney)
  20751. }
  20752. if m.out_trade_no != nil {
  20753. fields = append(fields, payrecharge.FieldOutTradeNo)
  20754. }
  20755. if m.organization_id != nil {
  20756. fields = append(fields, payrecharge.FieldOrganizationID)
  20757. }
  20758. return fields
  20759. }
  20760. // Field returns the value of a field with the given name. The second boolean
  20761. // return value indicates that this field was not set, or was not defined in the
  20762. // schema.
  20763. func (m *PayRechargeMutation) Field(name string) (ent.Value, bool) {
  20764. switch name {
  20765. case payrecharge.FieldCreatedAt:
  20766. return m.CreatedAt()
  20767. case payrecharge.FieldUpdatedAt:
  20768. return m.UpdatedAt()
  20769. case payrecharge.FieldDeletedAt:
  20770. return m.DeletedAt()
  20771. case payrecharge.FieldUserID:
  20772. return m.UserID()
  20773. case payrecharge.FieldNumber:
  20774. return m.Number()
  20775. case payrecharge.FieldStatus:
  20776. return m.Status()
  20777. case payrecharge.FieldMoney:
  20778. return m.Money()
  20779. case payrecharge.FieldOutTradeNo:
  20780. return m.OutTradeNo()
  20781. case payrecharge.FieldOrganizationID:
  20782. return m.OrganizationID()
  20783. }
  20784. return nil, false
  20785. }
  20786. // OldField returns the old value of the field from the database. An error is
  20787. // returned if the mutation operation is not UpdateOne, or the query to the
  20788. // database failed.
  20789. func (m *PayRechargeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  20790. switch name {
  20791. case payrecharge.FieldCreatedAt:
  20792. return m.OldCreatedAt(ctx)
  20793. case payrecharge.FieldUpdatedAt:
  20794. return m.OldUpdatedAt(ctx)
  20795. case payrecharge.FieldDeletedAt:
  20796. return m.OldDeletedAt(ctx)
  20797. case payrecharge.FieldUserID:
  20798. return m.OldUserID(ctx)
  20799. case payrecharge.FieldNumber:
  20800. return m.OldNumber(ctx)
  20801. case payrecharge.FieldStatus:
  20802. return m.OldStatus(ctx)
  20803. case payrecharge.FieldMoney:
  20804. return m.OldMoney(ctx)
  20805. case payrecharge.FieldOutTradeNo:
  20806. return m.OldOutTradeNo(ctx)
  20807. case payrecharge.FieldOrganizationID:
  20808. return m.OldOrganizationID(ctx)
  20809. }
  20810. return nil, fmt.Errorf("unknown PayRecharge field %s", name)
  20811. }
  20812. // SetField sets the value of a field with the given name. It returns an error if
  20813. // the field is not defined in the schema, or if the type mismatched the field
  20814. // type.
  20815. func (m *PayRechargeMutation) SetField(name string, value ent.Value) error {
  20816. switch name {
  20817. case payrecharge.FieldCreatedAt:
  20818. v, ok := value.(time.Time)
  20819. if !ok {
  20820. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20821. }
  20822. m.SetCreatedAt(v)
  20823. return nil
  20824. case payrecharge.FieldUpdatedAt:
  20825. v, ok := value.(time.Time)
  20826. if !ok {
  20827. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20828. }
  20829. m.SetUpdatedAt(v)
  20830. return nil
  20831. case payrecharge.FieldDeletedAt:
  20832. v, ok := value.(time.Time)
  20833. if !ok {
  20834. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20835. }
  20836. m.SetDeletedAt(v)
  20837. return nil
  20838. case payrecharge.FieldUserID:
  20839. v, ok := value.(string)
  20840. if !ok {
  20841. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20842. }
  20843. m.SetUserID(v)
  20844. return nil
  20845. case payrecharge.FieldNumber:
  20846. v, ok := value.(float32)
  20847. if !ok {
  20848. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20849. }
  20850. m.SetNumber(v)
  20851. return nil
  20852. case payrecharge.FieldStatus:
  20853. v, ok := value.(int)
  20854. if !ok {
  20855. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20856. }
  20857. m.SetStatus(v)
  20858. return nil
  20859. case payrecharge.FieldMoney:
  20860. v, ok := value.(float32)
  20861. if !ok {
  20862. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20863. }
  20864. m.SetMoney(v)
  20865. return nil
  20866. case payrecharge.FieldOutTradeNo:
  20867. v, ok := value.(string)
  20868. if !ok {
  20869. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20870. }
  20871. m.SetOutTradeNo(v)
  20872. return nil
  20873. case payrecharge.FieldOrganizationID:
  20874. v, ok := value.(uint64)
  20875. if !ok {
  20876. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20877. }
  20878. m.SetOrganizationID(v)
  20879. return nil
  20880. }
  20881. return fmt.Errorf("unknown PayRecharge field %s", name)
  20882. }
  20883. // AddedFields returns all numeric fields that were incremented/decremented during
  20884. // this mutation.
  20885. func (m *PayRechargeMutation) AddedFields() []string {
  20886. var fields []string
  20887. if m.addnumber != nil {
  20888. fields = append(fields, payrecharge.FieldNumber)
  20889. }
  20890. if m.addstatus != nil {
  20891. fields = append(fields, payrecharge.FieldStatus)
  20892. }
  20893. if m.addmoney != nil {
  20894. fields = append(fields, payrecharge.FieldMoney)
  20895. }
  20896. if m.addorganization_id != nil {
  20897. fields = append(fields, payrecharge.FieldOrganizationID)
  20898. }
  20899. return fields
  20900. }
  20901. // AddedField returns the numeric value that was incremented/decremented on a field
  20902. // with the given name. The second boolean return value indicates that this field
  20903. // was not set, or was not defined in the schema.
  20904. func (m *PayRechargeMutation) AddedField(name string) (ent.Value, bool) {
  20905. switch name {
  20906. case payrecharge.FieldNumber:
  20907. return m.AddedNumber()
  20908. case payrecharge.FieldStatus:
  20909. return m.AddedStatus()
  20910. case payrecharge.FieldMoney:
  20911. return m.AddedMoney()
  20912. case payrecharge.FieldOrganizationID:
  20913. return m.AddedOrganizationID()
  20914. }
  20915. return nil, false
  20916. }
  20917. // AddField adds the value to the field with the given name. It returns an error if
  20918. // the field is not defined in the schema, or if the type mismatched the field
  20919. // type.
  20920. func (m *PayRechargeMutation) AddField(name string, value ent.Value) error {
  20921. switch name {
  20922. case payrecharge.FieldNumber:
  20923. v, ok := value.(float32)
  20924. if !ok {
  20925. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20926. }
  20927. m.AddNumber(v)
  20928. return nil
  20929. case payrecharge.FieldStatus:
  20930. v, ok := value.(int)
  20931. if !ok {
  20932. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20933. }
  20934. m.AddStatus(v)
  20935. return nil
  20936. case payrecharge.FieldMoney:
  20937. v, ok := value.(float32)
  20938. if !ok {
  20939. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20940. }
  20941. m.AddMoney(v)
  20942. return nil
  20943. case payrecharge.FieldOrganizationID:
  20944. v, ok := value.(int64)
  20945. if !ok {
  20946. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20947. }
  20948. m.AddOrganizationID(v)
  20949. return nil
  20950. }
  20951. return fmt.Errorf("unknown PayRecharge numeric field %s", name)
  20952. }
  20953. // ClearedFields returns all nullable fields that were cleared during this
  20954. // mutation.
  20955. func (m *PayRechargeMutation) ClearedFields() []string {
  20956. var fields []string
  20957. if m.FieldCleared(payrecharge.FieldDeletedAt) {
  20958. fields = append(fields, payrecharge.FieldDeletedAt)
  20959. }
  20960. if m.FieldCleared(payrecharge.FieldStatus) {
  20961. fields = append(fields, payrecharge.FieldStatus)
  20962. }
  20963. if m.FieldCleared(payrecharge.FieldMoney) {
  20964. fields = append(fields, payrecharge.FieldMoney)
  20965. }
  20966. if m.FieldCleared(payrecharge.FieldOutTradeNo) {
  20967. fields = append(fields, payrecharge.FieldOutTradeNo)
  20968. }
  20969. return fields
  20970. }
  20971. // FieldCleared returns a boolean indicating if a field with the given name was
  20972. // cleared in this mutation.
  20973. func (m *PayRechargeMutation) FieldCleared(name string) bool {
  20974. _, ok := m.clearedFields[name]
  20975. return ok
  20976. }
  20977. // ClearField clears the value of the field with the given name. It returns an
  20978. // error if the field is not defined in the schema.
  20979. func (m *PayRechargeMutation) ClearField(name string) error {
  20980. switch name {
  20981. case payrecharge.FieldDeletedAt:
  20982. m.ClearDeletedAt()
  20983. return nil
  20984. case payrecharge.FieldStatus:
  20985. m.ClearStatus()
  20986. return nil
  20987. case payrecharge.FieldMoney:
  20988. m.ClearMoney()
  20989. return nil
  20990. case payrecharge.FieldOutTradeNo:
  20991. m.ClearOutTradeNo()
  20992. return nil
  20993. }
  20994. return fmt.Errorf("unknown PayRecharge nullable field %s", name)
  20995. }
  20996. // ResetField resets all changes in the mutation for the field with the given name.
  20997. // It returns an error if the field is not defined in the schema.
  20998. func (m *PayRechargeMutation) ResetField(name string) error {
  20999. switch name {
  21000. case payrecharge.FieldCreatedAt:
  21001. m.ResetCreatedAt()
  21002. return nil
  21003. case payrecharge.FieldUpdatedAt:
  21004. m.ResetUpdatedAt()
  21005. return nil
  21006. case payrecharge.FieldDeletedAt:
  21007. m.ResetDeletedAt()
  21008. return nil
  21009. case payrecharge.FieldUserID:
  21010. m.ResetUserID()
  21011. return nil
  21012. case payrecharge.FieldNumber:
  21013. m.ResetNumber()
  21014. return nil
  21015. case payrecharge.FieldStatus:
  21016. m.ResetStatus()
  21017. return nil
  21018. case payrecharge.FieldMoney:
  21019. m.ResetMoney()
  21020. return nil
  21021. case payrecharge.FieldOutTradeNo:
  21022. m.ResetOutTradeNo()
  21023. return nil
  21024. case payrecharge.FieldOrganizationID:
  21025. m.ResetOrganizationID()
  21026. return nil
  21027. }
  21028. return fmt.Errorf("unknown PayRecharge field %s", name)
  21029. }
  21030. // AddedEdges returns all edge names that were set/added in this mutation.
  21031. func (m *PayRechargeMutation) AddedEdges() []string {
  21032. edges := make([]string, 0, 0)
  21033. return edges
  21034. }
  21035. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  21036. // name in this mutation.
  21037. func (m *PayRechargeMutation) AddedIDs(name string) []ent.Value {
  21038. return nil
  21039. }
  21040. // RemovedEdges returns all edge names that were removed in this mutation.
  21041. func (m *PayRechargeMutation) RemovedEdges() []string {
  21042. edges := make([]string, 0, 0)
  21043. return edges
  21044. }
  21045. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  21046. // the given name in this mutation.
  21047. func (m *PayRechargeMutation) RemovedIDs(name string) []ent.Value {
  21048. return nil
  21049. }
  21050. // ClearedEdges returns all edge names that were cleared in this mutation.
  21051. func (m *PayRechargeMutation) ClearedEdges() []string {
  21052. edges := make([]string, 0, 0)
  21053. return edges
  21054. }
  21055. // EdgeCleared returns a boolean which indicates if the edge with the given name
  21056. // was cleared in this mutation.
  21057. func (m *PayRechargeMutation) EdgeCleared(name string) bool {
  21058. return false
  21059. }
  21060. // ClearEdge clears the value of the edge with the given name. It returns an error
  21061. // if that edge is not defined in the schema.
  21062. func (m *PayRechargeMutation) ClearEdge(name string) error {
  21063. return fmt.Errorf("unknown PayRecharge unique edge %s", name)
  21064. }
  21065. // ResetEdge resets all changes to the edge with the given name in this mutation.
  21066. // It returns an error if the edge is not defined in the schema.
  21067. func (m *PayRechargeMutation) ResetEdge(name string) error {
  21068. return fmt.Errorf("unknown PayRecharge edge %s", name)
  21069. }
  21070. // ServerMutation represents an operation that mutates the Server nodes in the graph.
  21071. type ServerMutation struct {
  21072. config
  21073. op Op
  21074. typ string
  21075. id *uint64
  21076. created_at *time.Time
  21077. updated_at *time.Time
  21078. status *uint8
  21079. addstatus *int8
  21080. deleted_at *time.Time
  21081. name *string
  21082. public_ip *string
  21083. private_ip *string
  21084. admin_port *string
  21085. clearedFields map[string]struct{}
  21086. wxs map[uint64]struct{}
  21087. removedwxs map[uint64]struct{}
  21088. clearedwxs bool
  21089. done bool
  21090. oldValue func(context.Context) (*Server, error)
  21091. predicates []predicate.Server
  21092. }
  21093. var _ ent.Mutation = (*ServerMutation)(nil)
  21094. // serverOption allows management of the mutation configuration using functional options.
  21095. type serverOption func(*ServerMutation)
  21096. // newServerMutation creates new mutation for the Server entity.
  21097. func newServerMutation(c config, op Op, opts ...serverOption) *ServerMutation {
  21098. m := &ServerMutation{
  21099. config: c,
  21100. op: op,
  21101. typ: TypeServer,
  21102. clearedFields: make(map[string]struct{}),
  21103. }
  21104. for _, opt := range opts {
  21105. opt(m)
  21106. }
  21107. return m
  21108. }
  21109. // withServerID sets the ID field of the mutation.
  21110. func withServerID(id uint64) serverOption {
  21111. return func(m *ServerMutation) {
  21112. var (
  21113. err error
  21114. once sync.Once
  21115. value *Server
  21116. )
  21117. m.oldValue = func(ctx context.Context) (*Server, error) {
  21118. once.Do(func() {
  21119. if m.done {
  21120. err = errors.New("querying old values post mutation is not allowed")
  21121. } else {
  21122. value, err = m.Client().Server.Get(ctx, id)
  21123. }
  21124. })
  21125. return value, err
  21126. }
  21127. m.id = &id
  21128. }
  21129. }
  21130. // withServer sets the old Server of the mutation.
  21131. func withServer(node *Server) serverOption {
  21132. return func(m *ServerMutation) {
  21133. m.oldValue = func(context.Context) (*Server, error) {
  21134. return node, nil
  21135. }
  21136. m.id = &node.ID
  21137. }
  21138. }
  21139. // Client returns a new `ent.Client` from the mutation. If the mutation was
  21140. // executed in a transaction (ent.Tx), a transactional client is returned.
  21141. func (m ServerMutation) Client() *Client {
  21142. client := &Client{config: m.config}
  21143. client.init()
  21144. return client
  21145. }
  21146. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  21147. // it returns an error otherwise.
  21148. func (m ServerMutation) Tx() (*Tx, error) {
  21149. if _, ok := m.driver.(*txDriver); !ok {
  21150. return nil, errors.New("ent: mutation is not running in a transaction")
  21151. }
  21152. tx := &Tx{config: m.config}
  21153. tx.init()
  21154. return tx, nil
  21155. }
  21156. // SetID sets the value of the id field. Note that this
  21157. // operation is only accepted on creation of Server entities.
  21158. func (m *ServerMutation) SetID(id uint64) {
  21159. m.id = &id
  21160. }
  21161. // ID returns the ID value in the mutation. Note that the ID is only available
  21162. // if it was provided to the builder or after it was returned from the database.
  21163. func (m *ServerMutation) ID() (id uint64, exists bool) {
  21164. if m.id == nil {
  21165. return
  21166. }
  21167. return *m.id, true
  21168. }
  21169. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  21170. // That means, if the mutation is applied within a transaction with an isolation level such
  21171. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  21172. // or updated by the mutation.
  21173. func (m *ServerMutation) IDs(ctx context.Context) ([]uint64, error) {
  21174. switch {
  21175. case m.op.Is(OpUpdateOne | OpDeleteOne):
  21176. id, exists := m.ID()
  21177. if exists {
  21178. return []uint64{id}, nil
  21179. }
  21180. fallthrough
  21181. case m.op.Is(OpUpdate | OpDelete):
  21182. return m.Client().Server.Query().Where(m.predicates...).IDs(ctx)
  21183. default:
  21184. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  21185. }
  21186. }
  21187. // SetCreatedAt sets the "created_at" field.
  21188. func (m *ServerMutation) SetCreatedAt(t time.Time) {
  21189. m.created_at = &t
  21190. }
  21191. // CreatedAt returns the value of the "created_at" field in the mutation.
  21192. func (m *ServerMutation) CreatedAt() (r time.Time, exists bool) {
  21193. v := m.created_at
  21194. if v == nil {
  21195. return
  21196. }
  21197. return *v, true
  21198. }
  21199. // OldCreatedAt returns the old "created_at" field's value of the Server entity.
  21200. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  21201. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21202. func (m *ServerMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  21203. if !m.op.Is(OpUpdateOne) {
  21204. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  21205. }
  21206. if m.id == nil || m.oldValue == nil {
  21207. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  21208. }
  21209. oldValue, err := m.oldValue(ctx)
  21210. if err != nil {
  21211. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  21212. }
  21213. return oldValue.CreatedAt, nil
  21214. }
  21215. // ResetCreatedAt resets all changes to the "created_at" field.
  21216. func (m *ServerMutation) ResetCreatedAt() {
  21217. m.created_at = nil
  21218. }
  21219. // SetUpdatedAt sets the "updated_at" field.
  21220. func (m *ServerMutation) SetUpdatedAt(t time.Time) {
  21221. m.updated_at = &t
  21222. }
  21223. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  21224. func (m *ServerMutation) UpdatedAt() (r time.Time, exists bool) {
  21225. v := m.updated_at
  21226. if v == nil {
  21227. return
  21228. }
  21229. return *v, true
  21230. }
  21231. // OldUpdatedAt returns the old "updated_at" field's value of the Server entity.
  21232. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  21233. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21234. func (m *ServerMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  21235. if !m.op.Is(OpUpdateOne) {
  21236. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  21237. }
  21238. if m.id == nil || m.oldValue == nil {
  21239. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  21240. }
  21241. oldValue, err := m.oldValue(ctx)
  21242. if err != nil {
  21243. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  21244. }
  21245. return oldValue.UpdatedAt, nil
  21246. }
  21247. // ResetUpdatedAt resets all changes to the "updated_at" field.
  21248. func (m *ServerMutation) ResetUpdatedAt() {
  21249. m.updated_at = nil
  21250. }
  21251. // SetStatus sets the "status" field.
  21252. func (m *ServerMutation) SetStatus(u uint8) {
  21253. m.status = &u
  21254. m.addstatus = nil
  21255. }
  21256. // Status returns the value of the "status" field in the mutation.
  21257. func (m *ServerMutation) Status() (r uint8, exists bool) {
  21258. v := m.status
  21259. if v == nil {
  21260. return
  21261. }
  21262. return *v, true
  21263. }
  21264. // OldStatus returns the old "status" field's value of the Server entity.
  21265. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  21266. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21267. func (m *ServerMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  21268. if !m.op.Is(OpUpdateOne) {
  21269. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  21270. }
  21271. if m.id == nil || m.oldValue == nil {
  21272. return v, errors.New("OldStatus requires an ID field in the mutation")
  21273. }
  21274. oldValue, err := m.oldValue(ctx)
  21275. if err != nil {
  21276. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  21277. }
  21278. return oldValue.Status, nil
  21279. }
  21280. // AddStatus adds u to the "status" field.
  21281. func (m *ServerMutation) AddStatus(u int8) {
  21282. if m.addstatus != nil {
  21283. *m.addstatus += u
  21284. } else {
  21285. m.addstatus = &u
  21286. }
  21287. }
  21288. // AddedStatus returns the value that was added to the "status" field in this mutation.
  21289. func (m *ServerMutation) AddedStatus() (r int8, exists bool) {
  21290. v := m.addstatus
  21291. if v == nil {
  21292. return
  21293. }
  21294. return *v, true
  21295. }
  21296. // ClearStatus clears the value of the "status" field.
  21297. func (m *ServerMutation) ClearStatus() {
  21298. m.status = nil
  21299. m.addstatus = nil
  21300. m.clearedFields[server.FieldStatus] = struct{}{}
  21301. }
  21302. // StatusCleared returns if the "status" field was cleared in this mutation.
  21303. func (m *ServerMutation) StatusCleared() bool {
  21304. _, ok := m.clearedFields[server.FieldStatus]
  21305. return ok
  21306. }
  21307. // ResetStatus resets all changes to the "status" field.
  21308. func (m *ServerMutation) ResetStatus() {
  21309. m.status = nil
  21310. m.addstatus = nil
  21311. delete(m.clearedFields, server.FieldStatus)
  21312. }
  21313. // SetDeletedAt sets the "deleted_at" field.
  21314. func (m *ServerMutation) SetDeletedAt(t time.Time) {
  21315. m.deleted_at = &t
  21316. }
  21317. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  21318. func (m *ServerMutation) DeletedAt() (r time.Time, exists bool) {
  21319. v := m.deleted_at
  21320. if v == nil {
  21321. return
  21322. }
  21323. return *v, true
  21324. }
  21325. // OldDeletedAt returns the old "deleted_at" field's value of the Server entity.
  21326. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  21327. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21328. func (m *ServerMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  21329. if !m.op.Is(OpUpdateOne) {
  21330. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  21331. }
  21332. if m.id == nil || m.oldValue == nil {
  21333. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  21334. }
  21335. oldValue, err := m.oldValue(ctx)
  21336. if err != nil {
  21337. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  21338. }
  21339. return oldValue.DeletedAt, nil
  21340. }
  21341. // ClearDeletedAt clears the value of the "deleted_at" field.
  21342. func (m *ServerMutation) ClearDeletedAt() {
  21343. m.deleted_at = nil
  21344. m.clearedFields[server.FieldDeletedAt] = struct{}{}
  21345. }
  21346. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  21347. func (m *ServerMutation) DeletedAtCleared() bool {
  21348. _, ok := m.clearedFields[server.FieldDeletedAt]
  21349. return ok
  21350. }
  21351. // ResetDeletedAt resets all changes to the "deleted_at" field.
  21352. func (m *ServerMutation) ResetDeletedAt() {
  21353. m.deleted_at = nil
  21354. delete(m.clearedFields, server.FieldDeletedAt)
  21355. }
  21356. // SetName sets the "name" field.
  21357. func (m *ServerMutation) SetName(s string) {
  21358. m.name = &s
  21359. }
  21360. // Name returns the value of the "name" field in the mutation.
  21361. func (m *ServerMutation) Name() (r string, exists bool) {
  21362. v := m.name
  21363. if v == nil {
  21364. return
  21365. }
  21366. return *v, true
  21367. }
  21368. // OldName returns the old "name" field's value of the Server entity.
  21369. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  21370. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21371. func (m *ServerMutation) OldName(ctx context.Context) (v string, err error) {
  21372. if !m.op.Is(OpUpdateOne) {
  21373. return v, errors.New("OldName is only allowed on UpdateOne operations")
  21374. }
  21375. if m.id == nil || m.oldValue == nil {
  21376. return v, errors.New("OldName requires an ID field in the mutation")
  21377. }
  21378. oldValue, err := m.oldValue(ctx)
  21379. if err != nil {
  21380. return v, fmt.Errorf("querying old value for OldName: %w", err)
  21381. }
  21382. return oldValue.Name, nil
  21383. }
  21384. // ResetName resets all changes to the "name" field.
  21385. func (m *ServerMutation) ResetName() {
  21386. m.name = nil
  21387. }
  21388. // SetPublicIP sets the "public_ip" field.
  21389. func (m *ServerMutation) SetPublicIP(s string) {
  21390. m.public_ip = &s
  21391. }
  21392. // PublicIP returns the value of the "public_ip" field in the mutation.
  21393. func (m *ServerMutation) PublicIP() (r string, exists bool) {
  21394. v := m.public_ip
  21395. if v == nil {
  21396. return
  21397. }
  21398. return *v, true
  21399. }
  21400. // OldPublicIP returns the old "public_ip" field's value of the Server entity.
  21401. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  21402. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21403. func (m *ServerMutation) OldPublicIP(ctx context.Context) (v string, err error) {
  21404. if !m.op.Is(OpUpdateOne) {
  21405. return v, errors.New("OldPublicIP is only allowed on UpdateOne operations")
  21406. }
  21407. if m.id == nil || m.oldValue == nil {
  21408. return v, errors.New("OldPublicIP requires an ID field in the mutation")
  21409. }
  21410. oldValue, err := m.oldValue(ctx)
  21411. if err != nil {
  21412. return v, fmt.Errorf("querying old value for OldPublicIP: %w", err)
  21413. }
  21414. return oldValue.PublicIP, nil
  21415. }
  21416. // ResetPublicIP resets all changes to the "public_ip" field.
  21417. func (m *ServerMutation) ResetPublicIP() {
  21418. m.public_ip = nil
  21419. }
  21420. // SetPrivateIP sets the "private_ip" field.
  21421. func (m *ServerMutation) SetPrivateIP(s string) {
  21422. m.private_ip = &s
  21423. }
  21424. // PrivateIP returns the value of the "private_ip" field in the mutation.
  21425. func (m *ServerMutation) PrivateIP() (r string, exists bool) {
  21426. v := m.private_ip
  21427. if v == nil {
  21428. return
  21429. }
  21430. return *v, true
  21431. }
  21432. // OldPrivateIP returns the old "private_ip" field's value of the Server entity.
  21433. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  21434. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21435. func (m *ServerMutation) OldPrivateIP(ctx context.Context) (v string, err error) {
  21436. if !m.op.Is(OpUpdateOne) {
  21437. return v, errors.New("OldPrivateIP is only allowed on UpdateOne operations")
  21438. }
  21439. if m.id == nil || m.oldValue == nil {
  21440. return v, errors.New("OldPrivateIP requires an ID field in the mutation")
  21441. }
  21442. oldValue, err := m.oldValue(ctx)
  21443. if err != nil {
  21444. return v, fmt.Errorf("querying old value for OldPrivateIP: %w", err)
  21445. }
  21446. return oldValue.PrivateIP, nil
  21447. }
  21448. // ResetPrivateIP resets all changes to the "private_ip" field.
  21449. func (m *ServerMutation) ResetPrivateIP() {
  21450. m.private_ip = nil
  21451. }
  21452. // SetAdminPort sets the "admin_port" field.
  21453. func (m *ServerMutation) SetAdminPort(s string) {
  21454. m.admin_port = &s
  21455. }
  21456. // AdminPort returns the value of the "admin_port" field in the mutation.
  21457. func (m *ServerMutation) AdminPort() (r string, exists bool) {
  21458. v := m.admin_port
  21459. if v == nil {
  21460. return
  21461. }
  21462. return *v, true
  21463. }
  21464. // OldAdminPort returns the old "admin_port" field's value of the Server entity.
  21465. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  21466. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21467. func (m *ServerMutation) OldAdminPort(ctx context.Context) (v string, err error) {
  21468. if !m.op.Is(OpUpdateOne) {
  21469. return v, errors.New("OldAdminPort is only allowed on UpdateOne operations")
  21470. }
  21471. if m.id == nil || m.oldValue == nil {
  21472. return v, errors.New("OldAdminPort requires an ID field in the mutation")
  21473. }
  21474. oldValue, err := m.oldValue(ctx)
  21475. if err != nil {
  21476. return v, fmt.Errorf("querying old value for OldAdminPort: %w", err)
  21477. }
  21478. return oldValue.AdminPort, nil
  21479. }
  21480. // ResetAdminPort resets all changes to the "admin_port" field.
  21481. func (m *ServerMutation) ResetAdminPort() {
  21482. m.admin_port = nil
  21483. }
  21484. // AddWxIDs adds the "wxs" edge to the Wx entity by ids.
  21485. func (m *ServerMutation) AddWxIDs(ids ...uint64) {
  21486. if m.wxs == nil {
  21487. m.wxs = make(map[uint64]struct{})
  21488. }
  21489. for i := range ids {
  21490. m.wxs[ids[i]] = struct{}{}
  21491. }
  21492. }
  21493. // ClearWxs clears the "wxs" edge to the Wx entity.
  21494. func (m *ServerMutation) ClearWxs() {
  21495. m.clearedwxs = true
  21496. }
  21497. // WxsCleared reports if the "wxs" edge to the Wx entity was cleared.
  21498. func (m *ServerMutation) WxsCleared() bool {
  21499. return m.clearedwxs
  21500. }
  21501. // RemoveWxIDs removes the "wxs" edge to the Wx entity by IDs.
  21502. func (m *ServerMutation) RemoveWxIDs(ids ...uint64) {
  21503. if m.removedwxs == nil {
  21504. m.removedwxs = make(map[uint64]struct{})
  21505. }
  21506. for i := range ids {
  21507. delete(m.wxs, ids[i])
  21508. m.removedwxs[ids[i]] = struct{}{}
  21509. }
  21510. }
  21511. // RemovedWxs returns the removed IDs of the "wxs" edge to the Wx entity.
  21512. func (m *ServerMutation) RemovedWxsIDs() (ids []uint64) {
  21513. for id := range m.removedwxs {
  21514. ids = append(ids, id)
  21515. }
  21516. return
  21517. }
  21518. // WxsIDs returns the "wxs" edge IDs in the mutation.
  21519. func (m *ServerMutation) WxsIDs() (ids []uint64) {
  21520. for id := range m.wxs {
  21521. ids = append(ids, id)
  21522. }
  21523. return
  21524. }
  21525. // ResetWxs resets all changes to the "wxs" edge.
  21526. func (m *ServerMutation) ResetWxs() {
  21527. m.wxs = nil
  21528. m.clearedwxs = false
  21529. m.removedwxs = nil
  21530. }
  21531. // Where appends a list predicates to the ServerMutation builder.
  21532. func (m *ServerMutation) Where(ps ...predicate.Server) {
  21533. m.predicates = append(m.predicates, ps...)
  21534. }
  21535. // WhereP appends storage-level predicates to the ServerMutation builder. Using this method,
  21536. // users can use type-assertion to append predicates that do not depend on any generated package.
  21537. func (m *ServerMutation) WhereP(ps ...func(*sql.Selector)) {
  21538. p := make([]predicate.Server, len(ps))
  21539. for i := range ps {
  21540. p[i] = ps[i]
  21541. }
  21542. m.Where(p...)
  21543. }
  21544. // Op returns the operation name.
  21545. func (m *ServerMutation) Op() Op {
  21546. return m.op
  21547. }
  21548. // SetOp allows setting the mutation operation.
  21549. func (m *ServerMutation) SetOp(op Op) {
  21550. m.op = op
  21551. }
  21552. // Type returns the node type of this mutation (Server).
  21553. func (m *ServerMutation) Type() string {
  21554. return m.typ
  21555. }
  21556. // Fields returns all fields that were changed during this mutation. Note that in
  21557. // order to get all numeric fields that were incremented/decremented, call
  21558. // AddedFields().
  21559. func (m *ServerMutation) Fields() []string {
  21560. fields := make([]string, 0, 8)
  21561. if m.created_at != nil {
  21562. fields = append(fields, server.FieldCreatedAt)
  21563. }
  21564. if m.updated_at != nil {
  21565. fields = append(fields, server.FieldUpdatedAt)
  21566. }
  21567. if m.status != nil {
  21568. fields = append(fields, server.FieldStatus)
  21569. }
  21570. if m.deleted_at != nil {
  21571. fields = append(fields, server.FieldDeletedAt)
  21572. }
  21573. if m.name != nil {
  21574. fields = append(fields, server.FieldName)
  21575. }
  21576. if m.public_ip != nil {
  21577. fields = append(fields, server.FieldPublicIP)
  21578. }
  21579. if m.private_ip != nil {
  21580. fields = append(fields, server.FieldPrivateIP)
  21581. }
  21582. if m.admin_port != nil {
  21583. fields = append(fields, server.FieldAdminPort)
  21584. }
  21585. return fields
  21586. }
  21587. // Field returns the value of a field with the given name. The second boolean
  21588. // return value indicates that this field was not set, or was not defined in the
  21589. // schema.
  21590. func (m *ServerMutation) Field(name string) (ent.Value, bool) {
  21591. switch name {
  21592. case server.FieldCreatedAt:
  21593. return m.CreatedAt()
  21594. case server.FieldUpdatedAt:
  21595. return m.UpdatedAt()
  21596. case server.FieldStatus:
  21597. return m.Status()
  21598. case server.FieldDeletedAt:
  21599. return m.DeletedAt()
  21600. case server.FieldName:
  21601. return m.Name()
  21602. case server.FieldPublicIP:
  21603. return m.PublicIP()
  21604. case server.FieldPrivateIP:
  21605. return m.PrivateIP()
  21606. case server.FieldAdminPort:
  21607. return m.AdminPort()
  21608. }
  21609. return nil, false
  21610. }
  21611. // OldField returns the old value of the field from the database. An error is
  21612. // returned if the mutation operation is not UpdateOne, or the query to the
  21613. // database failed.
  21614. func (m *ServerMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  21615. switch name {
  21616. case server.FieldCreatedAt:
  21617. return m.OldCreatedAt(ctx)
  21618. case server.FieldUpdatedAt:
  21619. return m.OldUpdatedAt(ctx)
  21620. case server.FieldStatus:
  21621. return m.OldStatus(ctx)
  21622. case server.FieldDeletedAt:
  21623. return m.OldDeletedAt(ctx)
  21624. case server.FieldName:
  21625. return m.OldName(ctx)
  21626. case server.FieldPublicIP:
  21627. return m.OldPublicIP(ctx)
  21628. case server.FieldPrivateIP:
  21629. return m.OldPrivateIP(ctx)
  21630. case server.FieldAdminPort:
  21631. return m.OldAdminPort(ctx)
  21632. }
  21633. return nil, fmt.Errorf("unknown Server field %s", name)
  21634. }
  21635. // SetField sets the value of a field with the given name. It returns an error if
  21636. // the field is not defined in the schema, or if the type mismatched the field
  21637. // type.
  21638. func (m *ServerMutation) SetField(name string, value ent.Value) error {
  21639. switch name {
  21640. case server.FieldCreatedAt:
  21641. v, ok := value.(time.Time)
  21642. if !ok {
  21643. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21644. }
  21645. m.SetCreatedAt(v)
  21646. return nil
  21647. case server.FieldUpdatedAt:
  21648. v, ok := value.(time.Time)
  21649. if !ok {
  21650. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21651. }
  21652. m.SetUpdatedAt(v)
  21653. return nil
  21654. case server.FieldStatus:
  21655. v, ok := value.(uint8)
  21656. if !ok {
  21657. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21658. }
  21659. m.SetStatus(v)
  21660. return nil
  21661. case server.FieldDeletedAt:
  21662. v, ok := value.(time.Time)
  21663. if !ok {
  21664. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21665. }
  21666. m.SetDeletedAt(v)
  21667. return nil
  21668. case server.FieldName:
  21669. v, ok := value.(string)
  21670. if !ok {
  21671. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21672. }
  21673. m.SetName(v)
  21674. return nil
  21675. case server.FieldPublicIP:
  21676. v, ok := value.(string)
  21677. if !ok {
  21678. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21679. }
  21680. m.SetPublicIP(v)
  21681. return nil
  21682. case server.FieldPrivateIP:
  21683. v, ok := value.(string)
  21684. if !ok {
  21685. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21686. }
  21687. m.SetPrivateIP(v)
  21688. return nil
  21689. case server.FieldAdminPort:
  21690. v, ok := value.(string)
  21691. if !ok {
  21692. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21693. }
  21694. m.SetAdminPort(v)
  21695. return nil
  21696. }
  21697. return fmt.Errorf("unknown Server field %s", name)
  21698. }
  21699. // AddedFields returns all numeric fields that were incremented/decremented during
  21700. // this mutation.
  21701. func (m *ServerMutation) AddedFields() []string {
  21702. var fields []string
  21703. if m.addstatus != nil {
  21704. fields = append(fields, server.FieldStatus)
  21705. }
  21706. return fields
  21707. }
  21708. // AddedField returns the numeric value that was incremented/decremented on a field
  21709. // with the given name. The second boolean return value indicates that this field
  21710. // was not set, or was not defined in the schema.
  21711. func (m *ServerMutation) AddedField(name string) (ent.Value, bool) {
  21712. switch name {
  21713. case server.FieldStatus:
  21714. return m.AddedStatus()
  21715. }
  21716. return nil, false
  21717. }
  21718. // AddField adds the value to the field with the given name. It returns an error if
  21719. // the field is not defined in the schema, or if the type mismatched the field
  21720. // type.
  21721. func (m *ServerMutation) AddField(name string, value ent.Value) error {
  21722. switch name {
  21723. case server.FieldStatus:
  21724. v, ok := value.(int8)
  21725. if !ok {
  21726. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21727. }
  21728. m.AddStatus(v)
  21729. return nil
  21730. }
  21731. return fmt.Errorf("unknown Server numeric field %s", name)
  21732. }
  21733. // ClearedFields returns all nullable fields that were cleared during this
  21734. // mutation.
  21735. func (m *ServerMutation) ClearedFields() []string {
  21736. var fields []string
  21737. if m.FieldCleared(server.FieldStatus) {
  21738. fields = append(fields, server.FieldStatus)
  21739. }
  21740. if m.FieldCleared(server.FieldDeletedAt) {
  21741. fields = append(fields, server.FieldDeletedAt)
  21742. }
  21743. return fields
  21744. }
  21745. // FieldCleared returns a boolean indicating if a field with the given name was
  21746. // cleared in this mutation.
  21747. func (m *ServerMutation) FieldCleared(name string) bool {
  21748. _, ok := m.clearedFields[name]
  21749. return ok
  21750. }
  21751. // ClearField clears the value of the field with the given name. It returns an
  21752. // error if the field is not defined in the schema.
  21753. func (m *ServerMutation) ClearField(name string) error {
  21754. switch name {
  21755. case server.FieldStatus:
  21756. m.ClearStatus()
  21757. return nil
  21758. case server.FieldDeletedAt:
  21759. m.ClearDeletedAt()
  21760. return nil
  21761. }
  21762. return fmt.Errorf("unknown Server nullable field %s", name)
  21763. }
  21764. // ResetField resets all changes in the mutation for the field with the given name.
  21765. // It returns an error if the field is not defined in the schema.
  21766. func (m *ServerMutation) ResetField(name string) error {
  21767. switch name {
  21768. case server.FieldCreatedAt:
  21769. m.ResetCreatedAt()
  21770. return nil
  21771. case server.FieldUpdatedAt:
  21772. m.ResetUpdatedAt()
  21773. return nil
  21774. case server.FieldStatus:
  21775. m.ResetStatus()
  21776. return nil
  21777. case server.FieldDeletedAt:
  21778. m.ResetDeletedAt()
  21779. return nil
  21780. case server.FieldName:
  21781. m.ResetName()
  21782. return nil
  21783. case server.FieldPublicIP:
  21784. m.ResetPublicIP()
  21785. return nil
  21786. case server.FieldPrivateIP:
  21787. m.ResetPrivateIP()
  21788. return nil
  21789. case server.FieldAdminPort:
  21790. m.ResetAdminPort()
  21791. return nil
  21792. }
  21793. return fmt.Errorf("unknown Server field %s", name)
  21794. }
  21795. // AddedEdges returns all edge names that were set/added in this mutation.
  21796. func (m *ServerMutation) AddedEdges() []string {
  21797. edges := make([]string, 0, 1)
  21798. if m.wxs != nil {
  21799. edges = append(edges, server.EdgeWxs)
  21800. }
  21801. return edges
  21802. }
  21803. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  21804. // name in this mutation.
  21805. func (m *ServerMutation) AddedIDs(name string) []ent.Value {
  21806. switch name {
  21807. case server.EdgeWxs:
  21808. ids := make([]ent.Value, 0, len(m.wxs))
  21809. for id := range m.wxs {
  21810. ids = append(ids, id)
  21811. }
  21812. return ids
  21813. }
  21814. return nil
  21815. }
  21816. // RemovedEdges returns all edge names that were removed in this mutation.
  21817. func (m *ServerMutation) RemovedEdges() []string {
  21818. edges := make([]string, 0, 1)
  21819. if m.removedwxs != nil {
  21820. edges = append(edges, server.EdgeWxs)
  21821. }
  21822. return edges
  21823. }
  21824. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  21825. // the given name in this mutation.
  21826. func (m *ServerMutation) RemovedIDs(name string) []ent.Value {
  21827. switch name {
  21828. case server.EdgeWxs:
  21829. ids := make([]ent.Value, 0, len(m.removedwxs))
  21830. for id := range m.removedwxs {
  21831. ids = append(ids, id)
  21832. }
  21833. return ids
  21834. }
  21835. return nil
  21836. }
  21837. // ClearedEdges returns all edge names that were cleared in this mutation.
  21838. func (m *ServerMutation) ClearedEdges() []string {
  21839. edges := make([]string, 0, 1)
  21840. if m.clearedwxs {
  21841. edges = append(edges, server.EdgeWxs)
  21842. }
  21843. return edges
  21844. }
  21845. // EdgeCleared returns a boolean which indicates if the edge with the given name
  21846. // was cleared in this mutation.
  21847. func (m *ServerMutation) EdgeCleared(name string) bool {
  21848. switch name {
  21849. case server.EdgeWxs:
  21850. return m.clearedwxs
  21851. }
  21852. return false
  21853. }
  21854. // ClearEdge clears the value of the edge with the given name. It returns an error
  21855. // if that edge is not defined in the schema.
  21856. func (m *ServerMutation) ClearEdge(name string) error {
  21857. switch name {
  21858. }
  21859. return fmt.Errorf("unknown Server unique edge %s", name)
  21860. }
  21861. // ResetEdge resets all changes to the edge with the given name in this mutation.
  21862. // It returns an error if the edge is not defined in the schema.
  21863. func (m *ServerMutation) ResetEdge(name string) error {
  21864. switch name {
  21865. case server.EdgeWxs:
  21866. m.ResetWxs()
  21867. return nil
  21868. }
  21869. return fmt.Errorf("unknown Server edge %s", name)
  21870. }
  21871. // SopNodeMutation represents an operation that mutates the SopNode nodes in the graph.
  21872. type SopNodeMutation struct {
  21873. config
  21874. op Op
  21875. typ string
  21876. id *uint64
  21877. created_at *time.Time
  21878. updated_at *time.Time
  21879. status *uint8
  21880. addstatus *int8
  21881. deleted_at *time.Time
  21882. parent_id *uint64
  21883. addparent_id *int64
  21884. name *string
  21885. condition_type *int
  21886. addcondition_type *int
  21887. condition_list *[]string
  21888. appendcondition_list []string
  21889. no_reply_condition *uint64
  21890. addno_reply_condition *int64
  21891. no_reply_unit *string
  21892. action_message *[]custom_types.Action
  21893. appendaction_message []custom_types.Action
  21894. action_label_add *[]uint64
  21895. appendaction_label_add []uint64
  21896. action_label_del *[]uint64
  21897. appendaction_label_del []uint64
  21898. action_forward **custom_types.ActionForward
  21899. clearedFields map[string]struct{}
  21900. sop_stage *uint64
  21901. clearedsop_stage bool
  21902. node_messages map[uint64]struct{}
  21903. removednode_messages map[uint64]struct{}
  21904. clearednode_messages bool
  21905. done bool
  21906. oldValue func(context.Context) (*SopNode, error)
  21907. predicates []predicate.SopNode
  21908. }
  21909. var _ ent.Mutation = (*SopNodeMutation)(nil)
  21910. // sopnodeOption allows management of the mutation configuration using functional options.
  21911. type sopnodeOption func(*SopNodeMutation)
  21912. // newSopNodeMutation creates new mutation for the SopNode entity.
  21913. func newSopNodeMutation(c config, op Op, opts ...sopnodeOption) *SopNodeMutation {
  21914. m := &SopNodeMutation{
  21915. config: c,
  21916. op: op,
  21917. typ: TypeSopNode,
  21918. clearedFields: make(map[string]struct{}),
  21919. }
  21920. for _, opt := range opts {
  21921. opt(m)
  21922. }
  21923. return m
  21924. }
  21925. // withSopNodeID sets the ID field of the mutation.
  21926. func withSopNodeID(id uint64) sopnodeOption {
  21927. return func(m *SopNodeMutation) {
  21928. var (
  21929. err error
  21930. once sync.Once
  21931. value *SopNode
  21932. )
  21933. m.oldValue = func(ctx context.Context) (*SopNode, error) {
  21934. once.Do(func() {
  21935. if m.done {
  21936. err = errors.New("querying old values post mutation is not allowed")
  21937. } else {
  21938. value, err = m.Client().SopNode.Get(ctx, id)
  21939. }
  21940. })
  21941. return value, err
  21942. }
  21943. m.id = &id
  21944. }
  21945. }
  21946. // withSopNode sets the old SopNode of the mutation.
  21947. func withSopNode(node *SopNode) sopnodeOption {
  21948. return func(m *SopNodeMutation) {
  21949. m.oldValue = func(context.Context) (*SopNode, error) {
  21950. return node, nil
  21951. }
  21952. m.id = &node.ID
  21953. }
  21954. }
  21955. // Client returns a new `ent.Client` from the mutation. If the mutation was
  21956. // executed in a transaction (ent.Tx), a transactional client is returned.
  21957. func (m SopNodeMutation) Client() *Client {
  21958. client := &Client{config: m.config}
  21959. client.init()
  21960. return client
  21961. }
  21962. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  21963. // it returns an error otherwise.
  21964. func (m SopNodeMutation) Tx() (*Tx, error) {
  21965. if _, ok := m.driver.(*txDriver); !ok {
  21966. return nil, errors.New("ent: mutation is not running in a transaction")
  21967. }
  21968. tx := &Tx{config: m.config}
  21969. tx.init()
  21970. return tx, nil
  21971. }
  21972. // SetID sets the value of the id field. Note that this
  21973. // operation is only accepted on creation of SopNode entities.
  21974. func (m *SopNodeMutation) SetID(id uint64) {
  21975. m.id = &id
  21976. }
  21977. // ID returns the ID value in the mutation. Note that the ID is only available
  21978. // if it was provided to the builder or after it was returned from the database.
  21979. func (m *SopNodeMutation) ID() (id uint64, exists bool) {
  21980. if m.id == nil {
  21981. return
  21982. }
  21983. return *m.id, true
  21984. }
  21985. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  21986. // That means, if the mutation is applied within a transaction with an isolation level such
  21987. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  21988. // or updated by the mutation.
  21989. func (m *SopNodeMutation) IDs(ctx context.Context) ([]uint64, error) {
  21990. switch {
  21991. case m.op.Is(OpUpdateOne | OpDeleteOne):
  21992. id, exists := m.ID()
  21993. if exists {
  21994. return []uint64{id}, nil
  21995. }
  21996. fallthrough
  21997. case m.op.Is(OpUpdate | OpDelete):
  21998. return m.Client().SopNode.Query().Where(m.predicates...).IDs(ctx)
  21999. default:
  22000. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  22001. }
  22002. }
  22003. // SetCreatedAt sets the "created_at" field.
  22004. func (m *SopNodeMutation) SetCreatedAt(t time.Time) {
  22005. m.created_at = &t
  22006. }
  22007. // CreatedAt returns the value of the "created_at" field in the mutation.
  22008. func (m *SopNodeMutation) CreatedAt() (r time.Time, exists bool) {
  22009. v := m.created_at
  22010. if v == nil {
  22011. return
  22012. }
  22013. return *v, true
  22014. }
  22015. // OldCreatedAt returns the old "created_at" field's value of the SopNode entity.
  22016. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  22017. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22018. func (m *SopNodeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  22019. if !m.op.Is(OpUpdateOne) {
  22020. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  22021. }
  22022. if m.id == nil || m.oldValue == nil {
  22023. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  22024. }
  22025. oldValue, err := m.oldValue(ctx)
  22026. if err != nil {
  22027. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  22028. }
  22029. return oldValue.CreatedAt, nil
  22030. }
  22031. // ResetCreatedAt resets all changes to the "created_at" field.
  22032. func (m *SopNodeMutation) ResetCreatedAt() {
  22033. m.created_at = nil
  22034. }
  22035. // SetUpdatedAt sets the "updated_at" field.
  22036. func (m *SopNodeMutation) SetUpdatedAt(t time.Time) {
  22037. m.updated_at = &t
  22038. }
  22039. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  22040. func (m *SopNodeMutation) UpdatedAt() (r time.Time, exists bool) {
  22041. v := m.updated_at
  22042. if v == nil {
  22043. return
  22044. }
  22045. return *v, true
  22046. }
  22047. // OldUpdatedAt returns the old "updated_at" field's value of the SopNode entity.
  22048. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  22049. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22050. func (m *SopNodeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  22051. if !m.op.Is(OpUpdateOne) {
  22052. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  22053. }
  22054. if m.id == nil || m.oldValue == nil {
  22055. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  22056. }
  22057. oldValue, err := m.oldValue(ctx)
  22058. if err != nil {
  22059. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  22060. }
  22061. return oldValue.UpdatedAt, nil
  22062. }
  22063. // ResetUpdatedAt resets all changes to the "updated_at" field.
  22064. func (m *SopNodeMutation) ResetUpdatedAt() {
  22065. m.updated_at = nil
  22066. }
  22067. // SetStatus sets the "status" field.
  22068. func (m *SopNodeMutation) SetStatus(u uint8) {
  22069. m.status = &u
  22070. m.addstatus = nil
  22071. }
  22072. // Status returns the value of the "status" field in the mutation.
  22073. func (m *SopNodeMutation) Status() (r uint8, exists bool) {
  22074. v := m.status
  22075. if v == nil {
  22076. return
  22077. }
  22078. return *v, true
  22079. }
  22080. // OldStatus returns the old "status" field's value of the SopNode entity.
  22081. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  22082. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22083. func (m *SopNodeMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  22084. if !m.op.Is(OpUpdateOne) {
  22085. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  22086. }
  22087. if m.id == nil || m.oldValue == nil {
  22088. return v, errors.New("OldStatus requires an ID field in the mutation")
  22089. }
  22090. oldValue, err := m.oldValue(ctx)
  22091. if err != nil {
  22092. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  22093. }
  22094. return oldValue.Status, nil
  22095. }
  22096. // AddStatus adds u to the "status" field.
  22097. func (m *SopNodeMutation) AddStatus(u int8) {
  22098. if m.addstatus != nil {
  22099. *m.addstatus += u
  22100. } else {
  22101. m.addstatus = &u
  22102. }
  22103. }
  22104. // AddedStatus returns the value that was added to the "status" field in this mutation.
  22105. func (m *SopNodeMutation) AddedStatus() (r int8, exists bool) {
  22106. v := m.addstatus
  22107. if v == nil {
  22108. return
  22109. }
  22110. return *v, true
  22111. }
  22112. // ClearStatus clears the value of the "status" field.
  22113. func (m *SopNodeMutation) ClearStatus() {
  22114. m.status = nil
  22115. m.addstatus = nil
  22116. m.clearedFields[sopnode.FieldStatus] = struct{}{}
  22117. }
  22118. // StatusCleared returns if the "status" field was cleared in this mutation.
  22119. func (m *SopNodeMutation) StatusCleared() bool {
  22120. _, ok := m.clearedFields[sopnode.FieldStatus]
  22121. return ok
  22122. }
  22123. // ResetStatus resets all changes to the "status" field.
  22124. func (m *SopNodeMutation) ResetStatus() {
  22125. m.status = nil
  22126. m.addstatus = nil
  22127. delete(m.clearedFields, sopnode.FieldStatus)
  22128. }
  22129. // SetDeletedAt sets the "deleted_at" field.
  22130. func (m *SopNodeMutation) SetDeletedAt(t time.Time) {
  22131. m.deleted_at = &t
  22132. }
  22133. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  22134. func (m *SopNodeMutation) DeletedAt() (r time.Time, exists bool) {
  22135. v := m.deleted_at
  22136. if v == nil {
  22137. return
  22138. }
  22139. return *v, true
  22140. }
  22141. // OldDeletedAt returns the old "deleted_at" field's value of the SopNode entity.
  22142. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  22143. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22144. func (m *SopNodeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  22145. if !m.op.Is(OpUpdateOne) {
  22146. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  22147. }
  22148. if m.id == nil || m.oldValue == nil {
  22149. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  22150. }
  22151. oldValue, err := m.oldValue(ctx)
  22152. if err != nil {
  22153. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  22154. }
  22155. return oldValue.DeletedAt, nil
  22156. }
  22157. // ClearDeletedAt clears the value of the "deleted_at" field.
  22158. func (m *SopNodeMutation) ClearDeletedAt() {
  22159. m.deleted_at = nil
  22160. m.clearedFields[sopnode.FieldDeletedAt] = struct{}{}
  22161. }
  22162. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  22163. func (m *SopNodeMutation) DeletedAtCleared() bool {
  22164. _, ok := m.clearedFields[sopnode.FieldDeletedAt]
  22165. return ok
  22166. }
  22167. // ResetDeletedAt resets all changes to the "deleted_at" field.
  22168. func (m *SopNodeMutation) ResetDeletedAt() {
  22169. m.deleted_at = nil
  22170. delete(m.clearedFields, sopnode.FieldDeletedAt)
  22171. }
  22172. // SetStageID sets the "stage_id" field.
  22173. func (m *SopNodeMutation) SetStageID(u uint64) {
  22174. m.sop_stage = &u
  22175. }
  22176. // StageID returns the value of the "stage_id" field in the mutation.
  22177. func (m *SopNodeMutation) StageID() (r uint64, exists bool) {
  22178. v := m.sop_stage
  22179. if v == nil {
  22180. return
  22181. }
  22182. return *v, true
  22183. }
  22184. // OldStageID returns the old "stage_id" field's value of the SopNode entity.
  22185. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  22186. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22187. func (m *SopNodeMutation) OldStageID(ctx context.Context) (v uint64, err error) {
  22188. if !m.op.Is(OpUpdateOne) {
  22189. return v, errors.New("OldStageID is only allowed on UpdateOne operations")
  22190. }
  22191. if m.id == nil || m.oldValue == nil {
  22192. return v, errors.New("OldStageID requires an ID field in the mutation")
  22193. }
  22194. oldValue, err := m.oldValue(ctx)
  22195. if err != nil {
  22196. return v, fmt.Errorf("querying old value for OldStageID: %w", err)
  22197. }
  22198. return oldValue.StageID, nil
  22199. }
  22200. // ResetStageID resets all changes to the "stage_id" field.
  22201. func (m *SopNodeMutation) ResetStageID() {
  22202. m.sop_stage = nil
  22203. }
  22204. // SetParentID sets the "parent_id" field.
  22205. func (m *SopNodeMutation) SetParentID(u uint64) {
  22206. m.parent_id = &u
  22207. m.addparent_id = nil
  22208. }
  22209. // ParentID returns the value of the "parent_id" field in the mutation.
  22210. func (m *SopNodeMutation) ParentID() (r uint64, exists bool) {
  22211. v := m.parent_id
  22212. if v == nil {
  22213. return
  22214. }
  22215. return *v, true
  22216. }
  22217. // OldParentID returns the old "parent_id" field's value of the SopNode entity.
  22218. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  22219. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22220. func (m *SopNodeMutation) OldParentID(ctx context.Context) (v uint64, err error) {
  22221. if !m.op.Is(OpUpdateOne) {
  22222. return v, errors.New("OldParentID is only allowed on UpdateOne operations")
  22223. }
  22224. if m.id == nil || m.oldValue == nil {
  22225. return v, errors.New("OldParentID requires an ID field in the mutation")
  22226. }
  22227. oldValue, err := m.oldValue(ctx)
  22228. if err != nil {
  22229. return v, fmt.Errorf("querying old value for OldParentID: %w", err)
  22230. }
  22231. return oldValue.ParentID, nil
  22232. }
  22233. // AddParentID adds u to the "parent_id" field.
  22234. func (m *SopNodeMutation) AddParentID(u int64) {
  22235. if m.addparent_id != nil {
  22236. *m.addparent_id += u
  22237. } else {
  22238. m.addparent_id = &u
  22239. }
  22240. }
  22241. // AddedParentID returns the value that was added to the "parent_id" field in this mutation.
  22242. func (m *SopNodeMutation) AddedParentID() (r int64, exists bool) {
  22243. v := m.addparent_id
  22244. if v == nil {
  22245. return
  22246. }
  22247. return *v, true
  22248. }
  22249. // ResetParentID resets all changes to the "parent_id" field.
  22250. func (m *SopNodeMutation) ResetParentID() {
  22251. m.parent_id = nil
  22252. m.addparent_id = nil
  22253. }
  22254. // SetName sets the "name" field.
  22255. func (m *SopNodeMutation) SetName(s string) {
  22256. m.name = &s
  22257. }
  22258. // Name returns the value of the "name" field in the mutation.
  22259. func (m *SopNodeMutation) Name() (r string, exists bool) {
  22260. v := m.name
  22261. if v == nil {
  22262. return
  22263. }
  22264. return *v, true
  22265. }
  22266. // OldName returns the old "name" field's value of the SopNode entity.
  22267. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  22268. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22269. func (m *SopNodeMutation) OldName(ctx context.Context) (v string, err error) {
  22270. if !m.op.Is(OpUpdateOne) {
  22271. return v, errors.New("OldName is only allowed on UpdateOne operations")
  22272. }
  22273. if m.id == nil || m.oldValue == nil {
  22274. return v, errors.New("OldName requires an ID field in the mutation")
  22275. }
  22276. oldValue, err := m.oldValue(ctx)
  22277. if err != nil {
  22278. return v, fmt.Errorf("querying old value for OldName: %w", err)
  22279. }
  22280. return oldValue.Name, nil
  22281. }
  22282. // ResetName resets all changes to the "name" field.
  22283. func (m *SopNodeMutation) ResetName() {
  22284. m.name = nil
  22285. }
  22286. // SetConditionType sets the "condition_type" field.
  22287. func (m *SopNodeMutation) SetConditionType(i int) {
  22288. m.condition_type = &i
  22289. m.addcondition_type = nil
  22290. }
  22291. // ConditionType returns the value of the "condition_type" field in the mutation.
  22292. func (m *SopNodeMutation) ConditionType() (r int, exists bool) {
  22293. v := m.condition_type
  22294. if v == nil {
  22295. return
  22296. }
  22297. return *v, true
  22298. }
  22299. // OldConditionType returns the old "condition_type" field's value of the SopNode entity.
  22300. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  22301. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22302. func (m *SopNodeMutation) OldConditionType(ctx context.Context) (v int, err error) {
  22303. if !m.op.Is(OpUpdateOne) {
  22304. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  22305. }
  22306. if m.id == nil || m.oldValue == nil {
  22307. return v, errors.New("OldConditionType requires an ID field in the mutation")
  22308. }
  22309. oldValue, err := m.oldValue(ctx)
  22310. if err != nil {
  22311. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  22312. }
  22313. return oldValue.ConditionType, nil
  22314. }
  22315. // AddConditionType adds i to the "condition_type" field.
  22316. func (m *SopNodeMutation) AddConditionType(i int) {
  22317. if m.addcondition_type != nil {
  22318. *m.addcondition_type += i
  22319. } else {
  22320. m.addcondition_type = &i
  22321. }
  22322. }
  22323. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  22324. func (m *SopNodeMutation) AddedConditionType() (r int, exists bool) {
  22325. v := m.addcondition_type
  22326. if v == nil {
  22327. return
  22328. }
  22329. return *v, true
  22330. }
  22331. // ResetConditionType resets all changes to the "condition_type" field.
  22332. func (m *SopNodeMutation) ResetConditionType() {
  22333. m.condition_type = nil
  22334. m.addcondition_type = nil
  22335. }
  22336. // SetConditionList sets the "condition_list" field.
  22337. func (m *SopNodeMutation) SetConditionList(s []string) {
  22338. m.condition_list = &s
  22339. m.appendcondition_list = nil
  22340. }
  22341. // ConditionList returns the value of the "condition_list" field in the mutation.
  22342. func (m *SopNodeMutation) ConditionList() (r []string, exists bool) {
  22343. v := m.condition_list
  22344. if v == nil {
  22345. return
  22346. }
  22347. return *v, true
  22348. }
  22349. // OldConditionList returns the old "condition_list" field's value of the SopNode entity.
  22350. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  22351. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22352. func (m *SopNodeMutation) OldConditionList(ctx context.Context) (v []string, err error) {
  22353. if !m.op.Is(OpUpdateOne) {
  22354. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  22355. }
  22356. if m.id == nil || m.oldValue == nil {
  22357. return v, errors.New("OldConditionList requires an ID field in the mutation")
  22358. }
  22359. oldValue, err := m.oldValue(ctx)
  22360. if err != nil {
  22361. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  22362. }
  22363. return oldValue.ConditionList, nil
  22364. }
  22365. // AppendConditionList adds s to the "condition_list" field.
  22366. func (m *SopNodeMutation) AppendConditionList(s []string) {
  22367. m.appendcondition_list = append(m.appendcondition_list, s...)
  22368. }
  22369. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  22370. func (m *SopNodeMutation) AppendedConditionList() ([]string, bool) {
  22371. if len(m.appendcondition_list) == 0 {
  22372. return nil, false
  22373. }
  22374. return m.appendcondition_list, true
  22375. }
  22376. // ClearConditionList clears the value of the "condition_list" field.
  22377. func (m *SopNodeMutation) ClearConditionList() {
  22378. m.condition_list = nil
  22379. m.appendcondition_list = nil
  22380. m.clearedFields[sopnode.FieldConditionList] = struct{}{}
  22381. }
  22382. // ConditionListCleared returns if the "condition_list" field was cleared in this mutation.
  22383. func (m *SopNodeMutation) ConditionListCleared() bool {
  22384. _, ok := m.clearedFields[sopnode.FieldConditionList]
  22385. return ok
  22386. }
  22387. // ResetConditionList resets all changes to the "condition_list" field.
  22388. func (m *SopNodeMutation) ResetConditionList() {
  22389. m.condition_list = nil
  22390. m.appendcondition_list = nil
  22391. delete(m.clearedFields, sopnode.FieldConditionList)
  22392. }
  22393. // SetNoReplyCondition sets the "no_reply_condition" field.
  22394. func (m *SopNodeMutation) SetNoReplyCondition(u uint64) {
  22395. m.no_reply_condition = &u
  22396. m.addno_reply_condition = nil
  22397. }
  22398. // NoReplyCondition returns the value of the "no_reply_condition" field in the mutation.
  22399. func (m *SopNodeMutation) NoReplyCondition() (r uint64, exists bool) {
  22400. v := m.no_reply_condition
  22401. if v == nil {
  22402. return
  22403. }
  22404. return *v, true
  22405. }
  22406. // OldNoReplyCondition returns the old "no_reply_condition" field's value of the SopNode entity.
  22407. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  22408. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22409. func (m *SopNodeMutation) OldNoReplyCondition(ctx context.Context) (v uint64, err error) {
  22410. if !m.op.Is(OpUpdateOne) {
  22411. return v, errors.New("OldNoReplyCondition is only allowed on UpdateOne operations")
  22412. }
  22413. if m.id == nil || m.oldValue == nil {
  22414. return v, errors.New("OldNoReplyCondition requires an ID field in the mutation")
  22415. }
  22416. oldValue, err := m.oldValue(ctx)
  22417. if err != nil {
  22418. return v, fmt.Errorf("querying old value for OldNoReplyCondition: %w", err)
  22419. }
  22420. return oldValue.NoReplyCondition, nil
  22421. }
  22422. // AddNoReplyCondition adds u to the "no_reply_condition" field.
  22423. func (m *SopNodeMutation) AddNoReplyCondition(u int64) {
  22424. if m.addno_reply_condition != nil {
  22425. *m.addno_reply_condition += u
  22426. } else {
  22427. m.addno_reply_condition = &u
  22428. }
  22429. }
  22430. // AddedNoReplyCondition returns the value that was added to the "no_reply_condition" field in this mutation.
  22431. func (m *SopNodeMutation) AddedNoReplyCondition() (r int64, exists bool) {
  22432. v := m.addno_reply_condition
  22433. if v == nil {
  22434. return
  22435. }
  22436. return *v, true
  22437. }
  22438. // ResetNoReplyCondition resets all changes to the "no_reply_condition" field.
  22439. func (m *SopNodeMutation) ResetNoReplyCondition() {
  22440. m.no_reply_condition = nil
  22441. m.addno_reply_condition = nil
  22442. }
  22443. // SetNoReplyUnit sets the "no_reply_unit" field.
  22444. func (m *SopNodeMutation) SetNoReplyUnit(s string) {
  22445. m.no_reply_unit = &s
  22446. }
  22447. // NoReplyUnit returns the value of the "no_reply_unit" field in the mutation.
  22448. func (m *SopNodeMutation) NoReplyUnit() (r string, exists bool) {
  22449. v := m.no_reply_unit
  22450. if v == nil {
  22451. return
  22452. }
  22453. return *v, true
  22454. }
  22455. // OldNoReplyUnit returns the old "no_reply_unit" field's value of the SopNode entity.
  22456. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  22457. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22458. func (m *SopNodeMutation) OldNoReplyUnit(ctx context.Context) (v string, err error) {
  22459. if !m.op.Is(OpUpdateOne) {
  22460. return v, errors.New("OldNoReplyUnit is only allowed on UpdateOne operations")
  22461. }
  22462. if m.id == nil || m.oldValue == nil {
  22463. return v, errors.New("OldNoReplyUnit requires an ID field in the mutation")
  22464. }
  22465. oldValue, err := m.oldValue(ctx)
  22466. if err != nil {
  22467. return v, fmt.Errorf("querying old value for OldNoReplyUnit: %w", err)
  22468. }
  22469. return oldValue.NoReplyUnit, nil
  22470. }
  22471. // ResetNoReplyUnit resets all changes to the "no_reply_unit" field.
  22472. func (m *SopNodeMutation) ResetNoReplyUnit() {
  22473. m.no_reply_unit = nil
  22474. }
  22475. // SetActionMessage sets the "action_message" field.
  22476. func (m *SopNodeMutation) SetActionMessage(ct []custom_types.Action) {
  22477. m.action_message = &ct
  22478. m.appendaction_message = nil
  22479. }
  22480. // ActionMessage returns the value of the "action_message" field in the mutation.
  22481. func (m *SopNodeMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  22482. v := m.action_message
  22483. if v == nil {
  22484. return
  22485. }
  22486. return *v, true
  22487. }
  22488. // OldActionMessage returns the old "action_message" field's value of the SopNode entity.
  22489. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  22490. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22491. func (m *SopNodeMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  22492. if !m.op.Is(OpUpdateOne) {
  22493. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  22494. }
  22495. if m.id == nil || m.oldValue == nil {
  22496. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  22497. }
  22498. oldValue, err := m.oldValue(ctx)
  22499. if err != nil {
  22500. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  22501. }
  22502. return oldValue.ActionMessage, nil
  22503. }
  22504. // AppendActionMessage adds ct to the "action_message" field.
  22505. func (m *SopNodeMutation) AppendActionMessage(ct []custom_types.Action) {
  22506. m.appendaction_message = append(m.appendaction_message, ct...)
  22507. }
  22508. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  22509. func (m *SopNodeMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  22510. if len(m.appendaction_message) == 0 {
  22511. return nil, false
  22512. }
  22513. return m.appendaction_message, true
  22514. }
  22515. // ClearActionMessage clears the value of the "action_message" field.
  22516. func (m *SopNodeMutation) ClearActionMessage() {
  22517. m.action_message = nil
  22518. m.appendaction_message = nil
  22519. m.clearedFields[sopnode.FieldActionMessage] = struct{}{}
  22520. }
  22521. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  22522. func (m *SopNodeMutation) ActionMessageCleared() bool {
  22523. _, ok := m.clearedFields[sopnode.FieldActionMessage]
  22524. return ok
  22525. }
  22526. // ResetActionMessage resets all changes to the "action_message" field.
  22527. func (m *SopNodeMutation) ResetActionMessage() {
  22528. m.action_message = nil
  22529. m.appendaction_message = nil
  22530. delete(m.clearedFields, sopnode.FieldActionMessage)
  22531. }
  22532. // SetActionLabelAdd sets the "action_label_add" field.
  22533. func (m *SopNodeMutation) SetActionLabelAdd(u []uint64) {
  22534. m.action_label_add = &u
  22535. m.appendaction_label_add = nil
  22536. }
  22537. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  22538. func (m *SopNodeMutation) ActionLabelAdd() (r []uint64, exists bool) {
  22539. v := m.action_label_add
  22540. if v == nil {
  22541. return
  22542. }
  22543. return *v, true
  22544. }
  22545. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopNode entity.
  22546. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  22547. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22548. func (m *SopNodeMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  22549. if !m.op.Is(OpUpdateOne) {
  22550. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  22551. }
  22552. if m.id == nil || m.oldValue == nil {
  22553. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  22554. }
  22555. oldValue, err := m.oldValue(ctx)
  22556. if err != nil {
  22557. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  22558. }
  22559. return oldValue.ActionLabelAdd, nil
  22560. }
  22561. // AppendActionLabelAdd adds u to the "action_label_add" field.
  22562. func (m *SopNodeMutation) AppendActionLabelAdd(u []uint64) {
  22563. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  22564. }
  22565. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  22566. func (m *SopNodeMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  22567. if len(m.appendaction_label_add) == 0 {
  22568. return nil, false
  22569. }
  22570. return m.appendaction_label_add, true
  22571. }
  22572. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  22573. func (m *SopNodeMutation) ClearActionLabelAdd() {
  22574. m.action_label_add = nil
  22575. m.appendaction_label_add = nil
  22576. m.clearedFields[sopnode.FieldActionLabelAdd] = struct{}{}
  22577. }
  22578. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  22579. func (m *SopNodeMutation) ActionLabelAddCleared() bool {
  22580. _, ok := m.clearedFields[sopnode.FieldActionLabelAdd]
  22581. return ok
  22582. }
  22583. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  22584. func (m *SopNodeMutation) ResetActionLabelAdd() {
  22585. m.action_label_add = nil
  22586. m.appendaction_label_add = nil
  22587. delete(m.clearedFields, sopnode.FieldActionLabelAdd)
  22588. }
  22589. // SetActionLabelDel sets the "action_label_del" field.
  22590. func (m *SopNodeMutation) SetActionLabelDel(u []uint64) {
  22591. m.action_label_del = &u
  22592. m.appendaction_label_del = nil
  22593. }
  22594. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  22595. func (m *SopNodeMutation) ActionLabelDel() (r []uint64, exists bool) {
  22596. v := m.action_label_del
  22597. if v == nil {
  22598. return
  22599. }
  22600. return *v, true
  22601. }
  22602. // OldActionLabelDel returns the old "action_label_del" field's value of the SopNode entity.
  22603. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  22604. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22605. func (m *SopNodeMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  22606. if !m.op.Is(OpUpdateOne) {
  22607. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  22608. }
  22609. if m.id == nil || m.oldValue == nil {
  22610. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  22611. }
  22612. oldValue, err := m.oldValue(ctx)
  22613. if err != nil {
  22614. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  22615. }
  22616. return oldValue.ActionLabelDel, nil
  22617. }
  22618. // AppendActionLabelDel adds u to the "action_label_del" field.
  22619. func (m *SopNodeMutation) AppendActionLabelDel(u []uint64) {
  22620. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  22621. }
  22622. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  22623. func (m *SopNodeMutation) AppendedActionLabelDel() ([]uint64, bool) {
  22624. if len(m.appendaction_label_del) == 0 {
  22625. return nil, false
  22626. }
  22627. return m.appendaction_label_del, true
  22628. }
  22629. // ClearActionLabelDel clears the value of the "action_label_del" field.
  22630. func (m *SopNodeMutation) ClearActionLabelDel() {
  22631. m.action_label_del = nil
  22632. m.appendaction_label_del = nil
  22633. m.clearedFields[sopnode.FieldActionLabelDel] = struct{}{}
  22634. }
  22635. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  22636. func (m *SopNodeMutation) ActionLabelDelCleared() bool {
  22637. _, ok := m.clearedFields[sopnode.FieldActionLabelDel]
  22638. return ok
  22639. }
  22640. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  22641. func (m *SopNodeMutation) ResetActionLabelDel() {
  22642. m.action_label_del = nil
  22643. m.appendaction_label_del = nil
  22644. delete(m.clearedFields, sopnode.FieldActionLabelDel)
  22645. }
  22646. // SetActionForward sets the "action_forward" field.
  22647. func (m *SopNodeMutation) SetActionForward(ctf *custom_types.ActionForward) {
  22648. m.action_forward = &ctf
  22649. }
  22650. // ActionForward returns the value of the "action_forward" field in the mutation.
  22651. func (m *SopNodeMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  22652. v := m.action_forward
  22653. if v == nil {
  22654. return
  22655. }
  22656. return *v, true
  22657. }
  22658. // OldActionForward returns the old "action_forward" field's value of the SopNode entity.
  22659. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  22660. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22661. func (m *SopNodeMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  22662. if !m.op.Is(OpUpdateOne) {
  22663. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  22664. }
  22665. if m.id == nil || m.oldValue == nil {
  22666. return v, errors.New("OldActionForward requires an ID field in the mutation")
  22667. }
  22668. oldValue, err := m.oldValue(ctx)
  22669. if err != nil {
  22670. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  22671. }
  22672. return oldValue.ActionForward, nil
  22673. }
  22674. // ClearActionForward clears the value of the "action_forward" field.
  22675. func (m *SopNodeMutation) ClearActionForward() {
  22676. m.action_forward = nil
  22677. m.clearedFields[sopnode.FieldActionForward] = struct{}{}
  22678. }
  22679. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  22680. func (m *SopNodeMutation) ActionForwardCleared() bool {
  22681. _, ok := m.clearedFields[sopnode.FieldActionForward]
  22682. return ok
  22683. }
  22684. // ResetActionForward resets all changes to the "action_forward" field.
  22685. func (m *SopNodeMutation) ResetActionForward() {
  22686. m.action_forward = nil
  22687. delete(m.clearedFields, sopnode.FieldActionForward)
  22688. }
  22689. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  22690. func (m *SopNodeMutation) SetSopStageID(id uint64) {
  22691. m.sop_stage = &id
  22692. }
  22693. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  22694. func (m *SopNodeMutation) ClearSopStage() {
  22695. m.clearedsop_stage = true
  22696. m.clearedFields[sopnode.FieldStageID] = struct{}{}
  22697. }
  22698. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  22699. func (m *SopNodeMutation) SopStageCleared() bool {
  22700. return m.clearedsop_stage
  22701. }
  22702. // SopStageID returns the "sop_stage" edge ID in the mutation.
  22703. func (m *SopNodeMutation) SopStageID() (id uint64, exists bool) {
  22704. if m.sop_stage != nil {
  22705. return *m.sop_stage, true
  22706. }
  22707. return
  22708. }
  22709. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  22710. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  22711. // SopStageID instead. It exists only for internal usage by the builders.
  22712. func (m *SopNodeMutation) SopStageIDs() (ids []uint64) {
  22713. if id := m.sop_stage; id != nil {
  22714. ids = append(ids, *id)
  22715. }
  22716. return
  22717. }
  22718. // ResetSopStage resets all changes to the "sop_stage" edge.
  22719. func (m *SopNodeMutation) ResetSopStage() {
  22720. m.sop_stage = nil
  22721. m.clearedsop_stage = false
  22722. }
  22723. // AddNodeMessageIDs adds the "node_messages" edge to the MessageRecords entity by ids.
  22724. func (m *SopNodeMutation) AddNodeMessageIDs(ids ...uint64) {
  22725. if m.node_messages == nil {
  22726. m.node_messages = make(map[uint64]struct{})
  22727. }
  22728. for i := range ids {
  22729. m.node_messages[ids[i]] = struct{}{}
  22730. }
  22731. }
  22732. // ClearNodeMessages clears the "node_messages" edge to the MessageRecords entity.
  22733. func (m *SopNodeMutation) ClearNodeMessages() {
  22734. m.clearednode_messages = true
  22735. }
  22736. // NodeMessagesCleared reports if the "node_messages" edge to the MessageRecords entity was cleared.
  22737. func (m *SopNodeMutation) NodeMessagesCleared() bool {
  22738. return m.clearednode_messages
  22739. }
  22740. // RemoveNodeMessageIDs removes the "node_messages" edge to the MessageRecords entity by IDs.
  22741. func (m *SopNodeMutation) RemoveNodeMessageIDs(ids ...uint64) {
  22742. if m.removednode_messages == nil {
  22743. m.removednode_messages = make(map[uint64]struct{})
  22744. }
  22745. for i := range ids {
  22746. delete(m.node_messages, ids[i])
  22747. m.removednode_messages[ids[i]] = struct{}{}
  22748. }
  22749. }
  22750. // RemovedNodeMessages returns the removed IDs of the "node_messages" edge to the MessageRecords entity.
  22751. func (m *SopNodeMutation) RemovedNodeMessagesIDs() (ids []uint64) {
  22752. for id := range m.removednode_messages {
  22753. ids = append(ids, id)
  22754. }
  22755. return
  22756. }
  22757. // NodeMessagesIDs returns the "node_messages" edge IDs in the mutation.
  22758. func (m *SopNodeMutation) NodeMessagesIDs() (ids []uint64) {
  22759. for id := range m.node_messages {
  22760. ids = append(ids, id)
  22761. }
  22762. return
  22763. }
  22764. // ResetNodeMessages resets all changes to the "node_messages" edge.
  22765. func (m *SopNodeMutation) ResetNodeMessages() {
  22766. m.node_messages = nil
  22767. m.clearednode_messages = false
  22768. m.removednode_messages = nil
  22769. }
  22770. // Where appends a list predicates to the SopNodeMutation builder.
  22771. func (m *SopNodeMutation) Where(ps ...predicate.SopNode) {
  22772. m.predicates = append(m.predicates, ps...)
  22773. }
  22774. // WhereP appends storage-level predicates to the SopNodeMutation builder. Using this method,
  22775. // users can use type-assertion to append predicates that do not depend on any generated package.
  22776. func (m *SopNodeMutation) WhereP(ps ...func(*sql.Selector)) {
  22777. p := make([]predicate.SopNode, len(ps))
  22778. for i := range ps {
  22779. p[i] = ps[i]
  22780. }
  22781. m.Where(p...)
  22782. }
  22783. // Op returns the operation name.
  22784. func (m *SopNodeMutation) Op() Op {
  22785. return m.op
  22786. }
  22787. // SetOp allows setting the mutation operation.
  22788. func (m *SopNodeMutation) SetOp(op Op) {
  22789. m.op = op
  22790. }
  22791. // Type returns the node type of this mutation (SopNode).
  22792. func (m *SopNodeMutation) Type() string {
  22793. return m.typ
  22794. }
  22795. // Fields returns all fields that were changed during this mutation. Note that in
  22796. // order to get all numeric fields that were incremented/decremented, call
  22797. // AddedFields().
  22798. func (m *SopNodeMutation) Fields() []string {
  22799. fields := make([]string, 0, 15)
  22800. if m.created_at != nil {
  22801. fields = append(fields, sopnode.FieldCreatedAt)
  22802. }
  22803. if m.updated_at != nil {
  22804. fields = append(fields, sopnode.FieldUpdatedAt)
  22805. }
  22806. if m.status != nil {
  22807. fields = append(fields, sopnode.FieldStatus)
  22808. }
  22809. if m.deleted_at != nil {
  22810. fields = append(fields, sopnode.FieldDeletedAt)
  22811. }
  22812. if m.sop_stage != nil {
  22813. fields = append(fields, sopnode.FieldStageID)
  22814. }
  22815. if m.parent_id != nil {
  22816. fields = append(fields, sopnode.FieldParentID)
  22817. }
  22818. if m.name != nil {
  22819. fields = append(fields, sopnode.FieldName)
  22820. }
  22821. if m.condition_type != nil {
  22822. fields = append(fields, sopnode.FieldConditionType)
  22823. }
  22824. if m.condition_list != nil {
  22825. fields = append(fields, sopnode.FieldConditionList)
  22826. }
  22827. if m.no_reply_condition != nil {
  22828. fields = append(fields, sopnode.FieldNoReplyCondition)
  22829. }
  22830. if m.no_reply_unit != nil {
  22831. fields = append(fields, sopnode.FieldNoReplyUnit)
  22832. }
  22833. if m.action_message != nil {
  22834. fields = append(fields, sopnode.FieldActionMessage)
  22835. }
  22836. if m.action_label_add != nil {
  22837. fields = append(fields, sopnode.FieldActionLabelAdd)
  22838. }
  22839. if m.action_label_del != nil {
  22840. fields = append(fields, sopnode.FieldActionLabelDel)
  22841. }
  22842. if m.action_forward != nil {
  22843. fields = append(fields, sopnode.FieldActionForward)
  22844. }
  22845. return fields
  22846. }
  22847. // Field returns the value of a field with the given name. The second boolean
  22848. // return value indicates that this field was not set, or was not defined in the
  22849. // schema.
  22850. func (m *SopNodeMutation) Field(name string) (ent.Value, bool) {
  22851. switch name {
  22852. case sopnode.FieldCreatedAt:
  22853. return m.CreatedAt()
  22854. case sopnode.FieldUpdatedAt:
  22855. return m.UpdatedAt()
  22856. case sopnode.FieldStatus:
  22857. return m.Status()
  22858. case sopnode.FieldDeletedAt:
  22859. return m.DeletedAt()
  22860. case sopnode.FieldStageID:
  22861. return m.StageID()
  22862. case sopnode.FieldParentID:
  22863. return m.ParentID()
  22864. case sopnode.FieldName:
  22865. return m.Name()
  22866. case sopnode.FieldConditionType:
  22867. return m.ConditionType()
  22868. case sopnode.FieldConditionList:
  22869. return m.ConditionList()
  22870. case sopnode.FieldNoReplyCondition:
  22871. return m.NoReplyCondition()
  22872. case sopnode.FieldNoReplyUnit:
  22873. return m.NoReplyUnit()
  22874. case sopnode.FieldActionMessage:
  22875. return m.ActionMessage()
  22876. case sopnode.FieldActionLabelAdd:
  22877. return m.ActionLabelAdd()
  22878. case sopnode.FieldActionLabelDel:
  22879. return m.ActionLabelDel()
  22880. case sopnode.FieldActionForward:
  22881. return m.ActionForward()
  22882. }
  22883. return nil, false
  22884. }
  22885. // OldField returns the old value of the field from the database. An error is
  22886. // returned if the mutation operation is not UpdateOne, or the query to the
  22887. // database failed.
  22888. func (m *SopNodeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  22889. switch name {
  22890. case sopnode.FieldCreatedAt:
  22891. return m.OldCreatedAt(ctx)
  22892. case sopnode.FieldUpdatedAt:
  22893. return m.OldUpdatedAt(ctx)
  22894. case sopnode.FieldStatus:
  22895. return m.OldStatus(ctx)
  22896. case sopnode.FieldDeletedAt:
  22897. return m.OldDeletedAt(ctx)
  22898. case sopnode.FieldStageID:
  22899. return m.OldStageID(ctx)
  22900. case sopnode.FieldParentID:
  22901. return m.OldParentID(ctx)
  22902. case sopnode.FieldName:
  22903. return m.OldName(ctx)
  22904. case sopnode.FieldConditionType:
  22905. return m.OldConditionType(ctx)
  22906. case sopnode.FieldConditionList:
  22907. return m.OldConditionList(ctx)
  22908. case sopnode.FieldNoReplyCondition:
  22909. return m.OldNoReplyCondition(ctx)
  22910. case sopnode.FieldNoReplyUnit:
  22911. return m.OldNoReplyUnit(ctx)
  22912. case sopnode.FieldActionMessage:
  22913. return m.OldActionMessage(ctx)
  22914. case sopnode.FieldActionLabelAdd:
  22915. return m.OldActionLabelAdd(ctx)
  22916. case sopnode.FieldActionLabelDel:
  22917. return m.OldActionLabelDel(ctx)
  22918. case sopnode.FieldActionForward:
  22919. return m.OldActionForward(ctx)
  22920. }
  22921. return nil, fmt.Errorf("unknown SopNode field %s", name)
  22922. }
  22923. // SetField sets the value of a field with the given name. It returns an error if
  22924. // the field is not defined in the schema, or if the type mismatched the field
  22925. // type.
  22926. func (m *SopNodeMutation) SetField(name string, value ent.Value) error {
  22927. switch name {
  22928. case sopnode.FieldCreatedAt:
  22929. v, ok := value.(time.Time)
  22930. if !ok {
  22931. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22932. }
  22933. m.SetCreatedAt(v)
  22934. return nil
  22935. case sopnode.FieldUpdatedAt:
  22936. v, ok := value.(time.Time)
  22937. if !ok {
  22938. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22939. }
  22940. m.SetUpdatedAt(v)
  22941. return nil
  22942. case sopnode.FieldStatus:
  22943. v, ok := value.(uint8)
  22944. if !ok {
  22945. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22946. }
  22947. m.SetStatus(v)
  22948. return nil
  22949. case sopnode.FieldDeletedAt:
  22950. v, ok := value.(time.Time)
  22951. if !ok {
  22952. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22953. }
  22954. m.SetDeletedAt(v)
  22955. return nil
  22956. case sopnode.FieldStageID:
  22957. v, ok := value.(uint64)
  22958. if !ok {
  22959. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22960. }
  22961. m.SetStageID(v)
  22962. return nil
  22963. case sopnode.FieldParentID:
  22964. v, ok := value.(uint64)
  22965. if !ok {
  22966. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22967. }
  22968. m.SetParentID(v)
  22969. return nil
  22970. case sopnode.FieldName:
  22971. v, ok := value.(string)
  22972. if !ok {
  22973. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22974. }
  22975. m.SetName(v)
  22976. return nil
  22977. case sopnode.FieldConditionType:
  22978. v, ok := value.(int)
  22979. if !ok {
  22980. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22981. }
  22982. m.SetConditionType(v)
  22983. return nil
  22984. case sopnode.FieldConditionList:
  22985. v, ok := value.([]string)
  22986. if !ok {
  22987. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22988. }
  22989. m.SetConditionList(v)
  22990. return nil
  22991. case sopnode.FieldNoReplyCondition:
  22992. v, ok := value.(uint64)
  22993. if !ok {
  22994. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22995. }
  22996. m.SetNoReplyCondition(v)
  22997. return nil
  22998. case sopnode.FieldNoReplyUnit:
  22999. v, ok := value.(string)
  23000. if !ok {
  23001. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23002. }
  23003. m.SetNoReplyUnit(v)
  23004. return nil
  23005. case sopnode.FieldActionMessage:
  23006. v, ok := value.([]custom_types.Action)
  23007. if !ok {
  23008. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23009. }
  23010. m.SetActionMessage(v)
  23011. return nil
  23012. case sopnode.FieldActionLabelAdd:
  23013. v, ok := value.([]uint64)
  23014. if !ok {
  23015. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23016. }
  23017. m.SetActionLabelAdd(v)
  23018. return nil
  23019. case sopnode.FieldActionLabelDel:
  23020. v, ok := value.([]uint64)
  23021. if !ok {
  23022. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23023. }
  23024. m.SetActionLabelDel(v)
  23025. return nil
  23026. case sopnode.FieldActionForward:
  23027. v, ok := value.(*custom_types.ActionForward)
  23028. if !ok {
  23029. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23030. }
  23031. m.SetActionForward(v)
  23032. return nil
  23033. }
  23034. return fmt.Errorf("unknown SopNode field %s", name)
  23035. }
  23036. // AddedFields returns all numeric fields that were incremented/decremented during
  23037. // this mutation.
  23038. func (m *SopNodeMutation) AddedFields() []string {
  23039. var fields []string
  23040. if m.addstatus != nil {
  23041. fields = append(fields, sopnode.FieldStatus)
  23042. }
  23043. if m.addparent_id != nil {
  23044. fields = append(fields, sopnode.FieldParentID)
  23045. }
  23046. if m.addcondition_type != nil {
  23047. fields = append(fields, sopnode.FieldConditionType)
  23048. }
  23049. if m.addno_reply_condition != nil {
  23050. fields = append(fields, sopnode.FieldNoReplyCondition)
  23051. }
  23052. return fields
  23053. }
  23054. // AddedField returns the numeric value that was incremented/decremented on a field
  23055. // with the given name. The second boolean return value indicates that this field
  23056. // was not set, or was not defined in the schema.
  23057. func (m *SopNodeMutation) AddedField(name string) (ent.Value, bool) {
  23058. switch name {
  23059. case sopnode.FieldStatus:
  23060. return m.AddedStatus()
  23061. case sopnode.FieldParentID:
  23062. return m.AddedParentID()
  23063. case sopnode.FieldConditionType:
  23064. return m.AddedConditionType()
  23065. case sopnode.FieldNoReplyCondition:
  23066. return m.AddedNoReplyCondition()
  23067. }
  23068. return nil, false
  23069. }
  23070. // AddField adds the value to the field with the given name. It returns an error if
  23071. // the field is not defined in the schema, or if the type mismatched the field
  23072. // type.
  23073. func (m *SopNodeMutation) AddField(name string, value ent.Value) error {
  23074. switch name {
  23075. case sopnode.FieldStatus:
  23076. v, ok := value.(int8)
  23077. if !ok {
  23078. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23079. }
  23080. m.AddStatus(v)
  23081. return nil
  23082. case sopnode.FieldParentID:
  23083. v, ok := value.(int64)
  23084. if !ok {
  23085. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23086. }
  23087. m.AddParentID(v)
  23088. return nil
  23089. case sopnode.FieldConditionType:
  23090. v, ok := value.(int)
  23091. if !ok {
  23092. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23093. }
  23094. m.AddConditionType(v)
  23095. return nil
  23096. case sopnode.FieldNoReplyCondition:
  23097. v, ok := value.(int64)
  23098. if !ok {
  23099. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23100. }
  23101. m.AddNoReplyCondition(v)
  23102. return nil
  23103. }
  23104. return fmt.Errorf("unknown SopNode numeric field %s", name)
  23105. }
  23106. // ClearedFields returns all nullable fields that were cleared during this
  23107. // mutation.
  23108. func (m *SopNodeMutation) ClearedFields() []string {
  23109. var fields []string
  23110. if m.FieldCleared(sopnode.FieldStatus) {
  23111. fields = append(fields, sopnode.FieldStatus)
  23112. }
  23113. if m.FieldCleared(sopnode.FieldDeletedAt) {
  23114. fields = append(fields, sopnode.FieldDeletedAt)
  23115. }
  23116. if m.FieldCleared(sopnode.FieldConditionList) {
  23117. fields = append(fields, sopnode.FieldConditionList)
  23118. }
  23119. if m.FieldCleared(sopnode.FieldActionMessage) {
  23120. fields = append(fields, sopnode.FieldActionMessage)
  23121. }
  23122. if m.FieldCleared(sopnode.FieldActionLabelAdd) {
  23123. fields = append(fields, sopnode.FieldActionLabelAdd)
  23124. }
  23125. if m.FieldCleared(sopnode.FieldActionLabelDel) {
  23126. fields = append(fields, sopnode.FieldActionLabelDel)
  23127. }
  23128. if m.FieldCleared(sopnode.FieldActionForward) {
  23129. fields = append(fields, sopnode.FieldActionForward)
  23130. }
  23131. return fields
  23132. }
  23133. // FieldCleared returns a boolean indicating if a field with the given name was
  23134. // cleared in this mutation.
  23135. func (m *SopNodeMutation) FieldCleared(name string) bool {
  23136. _, ok := m.clearedFields[name]
  23137. return ok
  23138. }
  23139. // ClearField clears the value of the field with the given name. It returns an
  23140. // error if the field is not defined in the schema.
  23141. func (m *SopNodeMutation) ClearField(name string) error {
  23142. switch name {
  23143. case sopnode.FieldStatus:
  23144. m.ClearStatus()
  23145. return nil
  23146. case sopnode.FieldDeletedAt:
  23147. m.ClearDeletedAt()
  23148. return nil
  23149. case sopnode.FieldConditionList:
  23150. m.ClearConditionList()
  23151. return nil
  23152. case sopnode.FieldActionMessage:
  23153. m.ClearActionMessage()
  23154. return nil
  23155. case sopnode.FieldActionLabelAdd:
  23156. m.ClearActionLabelAdd()
  23157. return nil
  23158. case sopnode.FieldActionLabelDel:
  23159. m.ClearActionLabelDel()
  23160. return nil
  23161. case sopnode.FieldActionForward:
  23162. m.ClearActionForward()
  23163. return nil
  23164. }
  23165. return fmt.Errorf("unknown SopNode nullable field %s", name)
  23166. }
  23167. // ResetField resets all changes in the mutation for the field with the given name.
  23168. // It returns an error if the field is not defined in the schema.
  23169. func (m *SopNodeMutation) ResetField(name string) error {
  23170. switch name {
  23171. case sopnode.FieldCreatedAt:
  23172. m.ResetCreatedAt()
  23173. return nil
  23174. case sopnode.FieldUpdatedAt:
  23175. m.ResetUpdatedAt()
  23176. return nil
  23177. case sopnode.FieldStatus:
  23178. m.ResetStatus()
  23179. return nil
  23180. case sopnode.FieldDeletedAt:
  23181. m.ResetDeletedAt()
  23182. return nil
  23183. case sopnode.FieldStageID:
  23184. m.ResetStageID()
  23185. return nil
  23186. case sopnode.FieldParentID:
  23187. m.ResetParentID()
  23188. return nil
  23189. case sopnode.FieldName:
  23190. m.ResetName()
  23191. return nil
  23192. case sopnode.FieldConditionType:
  23193. m.ResetConditionType()
  23194. return nil
  23195. case sopnode.FieldConditionList:
  23196. m.ResetConditionList()
  23197. return nil
  23198. case sopnode.FieldNoReplyCondition:
  23199. m.ResetNoReplyCondition()
  23200. return nil
  23201. case sopnode.FieldNoReplyUnit:
  23202. m.ResetNoReplyUnit()
  23203. return nil
  23204. case sopnode.FieldActionMessage:
  23205. m.ResetActionMessage()
  23206. return nil
  23207. case sopnode.FieldActionLabelAdd:
  23208. m.ResetActionLabelAdd()
  23209. return nil
  23210. case sopnode.FieldActionLabelDel:
  23211. m.ResetActionLabelDel()
  23212. return nil
  23213. case sopnode.FieldActionForward:
  23214. m.ResetActionForward()
  23215. return nil
  23216. }
  23217. return fmt.Errorf("unknown SopNode field %s", name)
  23218. }
  23219. // AddedEdges returns all edge names that were set/added in this mutation.
  23220. func (m *SopNodeMutation) AddedEdges() []string {
  23221. edges := make([]string, 0, 2)
  23222. if m.sop_stage != nil {
  23223. edges = append(edges, sopnode.EdgeSopStage)
  23224. }
  23225. if m.node_messages != nil {
  23226. edges = append(edges, sopnode.EdgeNodeMessages)
  23227. }
  23228. return edges
  23229. }
  23230. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  23231. // name in this mutation.
  23232. func (m *SopNodeMutation) AddedIDs(name string) []ent.Value {
  23233. switch name {
  23234. case sopnode.EdgeSopStage:
  23235. if id := m.sop_stage; id != nil {
  23236. return []ent.Value{*id}
  23237. }
  23238. case sopnode.EdgeNodeMessages:
  23239. ids := make([]ent.Value, 0, len(m.node_messages))
  23240. for id := range m.node_messages {
  23241. ids = append(ids, id)
  23242. }
  23243. return ids
  23244. }
  23245. return nil
  23246. }
  23247. // RemovedEdges returns all edge names that were removed in this mutation.
  23248. func (m *SopNodeMutation) RemovedEdges() []string {
  23249. edges := make([]string, 0, 2)
  23250. if m.removednode_messages != nil {
  23251. edges = append(edges, sopnode.EdgeNodeMessages)
  23252. }
  23253. return edges
  23254. }
  23255. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  23256. // the given name in this mutation.
  23257. func (m *SopNodeMutation) RemovedIDs(name string) []ent.Value {
  23258. switch name {
  23259. case sopnode.EdgeNodeMessages:
  23260. ids := make([]ent.Value, 0, len(m.removednode_messages))
  23261. for id := range m.removednode_messages {
  23262. ids = append(ids, id)
  23263. }
  23264. return ids
  23265. }
  23266. return nil
  23267. }
  23268. // ClearedEdges returns all edge names that were cleared in this mutation.
  23269. func (m *SopNodeMutation) ClearedEdges() []string {
  23270. edges := make([]string, 0, 2)
  23271. if m.clearedsop_stage {
  23272. edges = append(edges, sopnode.EdgeSopStage)
  23273. }
  23274. if m.clearednode_messages {
  23275. edges = append(edges, sopnode.EdgeNodeMessages)
  23276. }
  23277. return edges
  23278. }
  23279. // EdgeCleared returns a boolean which indicates if the edge with the given name
  23280. // was cleared in this mutation.
  23281. func (m *SopNodeMutation) EdgeCleared(name string) bool {
  23282. switch name {
  23283. case sopnode.EdgeSopStage:
  23284. return m.clearedsop_stage
  23285. case sopnode.EdgeNodeMessages:
  23286. return m.clearednode_messages
  23287. }
  23288. return false
  23289. }
  23290. // ClearEdge clears the value of the edge with the given name. It returns an error
  23291. // if that edge is not defined in the schema.
  23292. func (m *SopNodeMutation) ClearEdge(name string) error {
  23293. switch name {
  23294. case sopnode.EdgeSopStage:
  23295. m.ClearSopStage()
  23296. return nil
  23297. }
  23298. return fmt.Errorf("unknown SopNode unique edge %s", name)
  23299. }
  23300. // ResetEdge resets all changes to the edge with the given name in this mutation.
  23301. // It returns an error if the edge is not defined in the schema.
  23302. func (m *SopNodeMutation) ResetEdge(name string) error {
  23303. switch name {
  23304. case sopnode.EdgeSopStage:
  23305. m.ResetSopStage()
  23306. return nil
  23307. case sopnode.EdgeNodeMessages:
  23308. m.ResetNodeMessages()
  23309. return nil
  23310. }
  23311. return fmt.Errorf("unknown SopNode edge %s", name)
  23312. }
  23313. // SopStageMutation represents an operation that mutates the SopStage nodes in the graph.
  23314. type SopStageMutation struct {
  23315. config
  23316. op Op
  23317. typ string
  23318. id *uint64
  23319. created_at *time.Time
  23320. updated_at *time.Time
  23321. status *uint8
  23322. addstatus *int8
  23323. deleted_at *time.Time
  23324. name *string
  23325. condition_type *int
  23326. addcondition_type *int
  23327. condition_operator *int
  23328. addcondition_operator *int
  23329. condition_list *[]custom_types.Condition
  23330. appendcondition_list []custom_types.Condition
  23331. action_message *[]custom_types.Action
  23332. appendaction_message []custom_types.Action
  23333. action_label_add *[]uint64
  23334. appendaction_label_add []uint64
  23335. action_label_del *[]uint64
  23336. appendaction_label_del []uint64
  23337. action_forward **custom_types.ActionForward
  23338. index_sort *int
  23339. addindex_sort *int
  23340. clearedFields map[string]struct{}
  23341. sop_task *uint64
  23342. clearedsop_task bool
  23343. stage_nodes map[uint64]struct{}
  23344. removedstage_nodes map[uint64]struct{}
  23345. clearedstage_nodes bool
  23346. stage_messages map[uint64]struct{}
  23347. removedstage_messages map[uint64]struct{}
  23348. clearedstage_messages bool
  23349. done bool
  23350. oldValue func(context.Context) (*SopStage, error)
  23351. predicates []predicate.SopStage
  23352. }
  23353. var _ ent.Mutation = (*SopStageMutation)(nil)
  23354. // sopstageOption allows management of the mutation configuration using functional options.
  23355. type sopstageOption func(*SopStageMutation)
  23356. // newSopStageMutation creates new mutation for the SopStage entity.
  23357. func newSopStageMutation(c config, op Op, opts ...sopstageOption) *SopStageMutation {
  23358. m := &SopStageMutation{
  23359. config: c,
  23360. op: op,
  23361. typ: TypeSopStage,
  23362. clearedFields: make(map[string]struct{}),
  23363. }
  23364. for _, opt := range opts {
  23365. opt(m)
  23366. }
  23367. return m
  23368. }
  23369. // withSopStageID sets the ID field of the mutation.
  23370. func withSopStageID(id uint64) sopstageOption {
  23371. return func(m *SopStageMutation) {
  23372. var (
  23373. err error
  23374. once sync.Once
  23375. value *SopStage
  23376. )
  23377. m.oldValue = func(ctx context.Context) (*SopStage, error) {
  23378. once.Do(func() {
  23379. if m.done {
  23380. err = errors.New("querying old values post mutation is not allowed")
  23381. } else {
  23382. value, err = m.Client().SopStage.Get(ctx, id)
  23383. }
  23384. })
  23385. return value, err
  23386. }
  23387. m.id = &id
  23388. }
  23389. }
  23390. // withSopStage sets the old SopStage of the mutation.
  23391. func withSopStage(node *SopStage) sopstageOption {
  23392. return func(m *SopStageMutation) {
  23393. m.oldValue = func(context.Context) (*SopStage, error) {
  23394. return node, nil
  23395. }
  23396. m.id = &node.ID
  23397. }
  23398. }
  23399. // Client returns a new `ent.Client` from the mutation. If the mutation was
  23400. // executed in a transaction (ent.Tx), a transactional client is returned.
  23401. func (m SopStageMutation) Client() *Client {
  23402. client := &Client{config: m.config}
  23403. client.init()
  23404. return client
  23405. }
  23406. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  23407. // it returns an error otherwise.
  23408. func (m SopStageMutation) Tx() (*Tx, error) {
  23409. if _, ok := m.driver.(*txDriver); !ok {
  23410. return nil, errors.New("ent: mutation is not running in a transaction")
  23411. }
  23412. tx := &Tx{config: m.config}
  23413. tx.init()
  23414. return tx, nil
  23415. }
  23416. // SetID sets the value of the id field. Note that this
  23417. // operation is only accepted on creation of SopStage entities.
  23418. func (m *SopStageMutation) SetID(id uint64) {
  23419. m.id = &id
  23420. }
  23421. // ID returns the ID value in the mutation. Note that the ID is only available
  23422. // if it was provided to the builder or after it was returned from the database.
  23423. func (m *SopStageMutation) ID() (id uint64, exists bool) {
  23424. if m.id == nil {
  23425. return
  23426. }
  23427. return *m.id, true
  23428. }
  23429. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  23430. // That means, if the mutation is applied within a transaction with an isolation level such
  23431. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  23432. // or updated by the mutation.
  23433. func (m *SopStageMutation) IDs(ctx context.Context) ([]uint64, error) {
  23434. switch {
  23435. case m.op.Is(OpUpdateOne | OpDeleteOne):
  23436. id, exists := m.ID()
  23437. if exists {
  23438. return []uint64{id}, nil
  23439. }
  23440. fallthrough
  23441. case m.op.Is(OpUpdate | OpDelete):
  23442. return m.Client().SopStage.Query().Where(m.predicates...).IDs(ctx)
  23443. default:
  23444. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  23445. }
  23446. }
  23447. // SetCreatedAt sets the "created_at" field.
  23448. func (m *SopStageMutation) SetCreatedAt(t time.Time) {
  23449. m.created_at = &t
  23450. }
  23451. // CreatedAt returns the value of the "created_at" field in the mutation.
  23452. func (m *SopStageMutation) CreatedAt() (r time.Time, exists bool) {
  23453. v := m.created_at
  23454. if v == nil {
  23455. return
  23456. }
  23457. return *v, true
  23458. }
  23459. // OldCreatedAt returns the old "created_at" field's value of the SopStage entity.
  23460. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  23461. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23462. func (m *SopStageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  23463. if !m.op.Is(OpUpdateOne) {
  23464. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  23465. }
  23466. if m.id == nil || m.oldValue == nil {
  23467. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  23468. }
  23469. oldValue, err := m.oldValue(ctx)
  23470. if err != nil {
  23471. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  23472. }
  23473. return oldValue.CreatedAt, nil
  23474. }
  23475. // ResetCreatedAt resets all changes to the "created_at" field.
  23476. func (m *SopStageMutation) ResetCreatedAt() {
  23477. m.created_at = nil
  23478. }
  23479. // SetUpdatedAt sets the "updated_at" field.
  23480. func (m *SopStageMutation) SetUpdatedAt(t time.Time) {
  23481. m.updated_at = &t
  23482. }
  23483. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  23484. func (m *SopStageMutation) UpdatedAt() (r time.Time, exists bool) {
  23485. v := m.updated_at
  23486. if v == nil {
  23487. return
  23488. }
  23489. return *v, true
  23490. }
  23491. // OldUpdatedAt returns the old "updated_at" field's value of the SopStage entity.
  23492. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  23493. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23494. func (m *SopStageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  23495. if !m.op.Is(OpUpdateOne) {
  23496. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  23497. }
  23498. if m.id == nil || m.oldValue == nil {
  23499. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  23500. }
  23501. oldValue, err := m.oldValue(ctx)
  23502. if err != nil {
  23503. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  23504. }
  23505. return oldValue.UpdatedAt, nil
  23506. }
  23507. // ResetUpdatedAt resets all changes to the "updated_at" field.
  23508. func (m *SopStageMutation) ResetUpdatedAt() {
  23509. m.updated_at = nil
  23510. }
  23511. // SetStatus sets the "status" field.
  23512. func (m *SopStageMutation) SetStatus(u uint8) {
  23513. m.status = &u
  23514. m.addstatus = nil
  23515. }
  23516. // Status returns the value of the "status" field in the mutation.
  23517. func (m *SopStageMutation) Status() (r uint8, exists bool) {
  23518. v := m.status
  23519. if v == nil {
  23520. return
  23521. }
  23522. return *v, true
  23523. }
  23524. // OldStatus returns the old "status" field's value of the SopStage entity.
  23525. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  23526. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23527. func (m *SopStageMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  23528. if !m.op.Is(OpUpdateOne) {
  23529. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  23530. }
  23531. if m.id == nil || m.oldValue == nil {
  23532. return v, errors.New("OldStatus requires an ID field in the mutation")
  23533. }
  23534. oldValue, err := m.oldValue(ctx)
  23535. if err != nil {
  23536. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  23537. }
  23538. return oldValue.Status, nil
  23539. }
  23540. // AddStatus adds u to the "status" field.
  23541. func (m *SopStageMutation) AddStatus(u int8) {
  23542. if m.addstatus != nil {
  23543. *m.addstatus += u
  23544. } else {
  23545. m.addstatus = &u
  23546. }
  23547. }
  23548. // AddedStatus returns the value that was added to the "status" field in this mutation.
  23549. func (m *SopStageMutation) AddedStatus() (r int8, exists bool) {
  23550. v := m.addstatus
  23551. if v == nil {
  23552. return
  23553. }
  23554. return *v, true
  23555. }
  23556. // ClearStatus clears the value of the "status" field.
  23557. func (m *SopStageMutation) ClearStatus() {
  23558. m.status = nil
  23559. m.addstatus = nil
  23560. m.clearedFields[sopstage.FieldStatus] = struct{}{}
  23561. }
  23562. // StatusCleared returns if the "status" field was cleared in this mutation.
  23563. func (m *SopStageMutation) StatusCleared() bool {
  23564. _, ok := m.clearedFields[sopstage.FieldStatus]
  23565. return ok
  23566. }
  23567. // ResetStatus resets all changes to the "status" field.
  23568. func (m *SopStageMutation) ResetStatus() {
  23569. m.status = nil
  23570. m.addstatus = nil
  23571. delete(m.clearedFields, sopstage.FieldStatus)
  23572. }
  23573. // SetDeletedAt sets the "deleted_at" field.
  23574. func (m *SopStageMutation) SetDeletedAt(t time.Time) {
  23575. m.deleted_at = &t
  23576. }
  23577. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  23578. func (m *SopStageMutation) DeletedAt() (r time.Time, exists bool) {
  23579. v := m.deleted_at
  23580. if v == nil {
  23581. return
  23582. }
  23583. return *v, true
  23584. }
  23585. // OldDeletedAt returns the old "deleted_at" field's value of the SopStage entity.
  23586. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  23587. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23588. func (m *SopStageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  23589. if !m.op.Is(OpUpdateOne) {
  23590. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  23591. }
  23592. if m.id == nil || m.oldValue == nil {
  23593. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  23594. }
  23595. oldValue, err := m.oldValue(ctx)
  23596. if err != nil {
  23597. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  23598. }
  23599. return oldValue.DeletedAt, nil
  23600. }
  23601. // ClearDeletedAt clears the value of the "deleted_at" field.
  23602. func (m *SopStageMutation) ClearDeletedAt() {
  23603. m.deleted_at = nil
  23604. m.clearedFields[sopstage.FieldDeletedAt] = struct{}{}
  23605. }
  23606. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  23607. func (m *SopStageMutation) DeletedAtCleared() bool {
  23608. _, ok := m.clearedFields[sopstage.FieldDeletedAt]
  23609. return ok
  23610. }
  23611. // ResetDeletedAt resets all changes to the "deleted_at" field.
  23612. func (m *SopStageMutation) ResetDeletedAt() {
  23613. m.deleted_at = nil
  23614. delete(m.clearedFields, sopstage.FieldDeletedAt)
  23615. }
  23616. // SetTaskID sets the "task_id" field.
  23617. func (m *SopStageMutation) SetTaskID(u uint64) {
  23618. m.sop_task = &u
  23619. }
  23620. // TaskID returns the value of the "task_id" field in the mutation.
  23621. func (m *SopStageMutation) TaskID() (r uint64, exists bool) {
  23622. v := m.sop_task
  23623. if v == nil {
  23624. return
  23625. }
  23626. return *v, true
  23627. }
  23628. // OldTaskID returns the old "task_id" field's value of the SopStage entity.
  23629. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  23630. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23631. func (m *SopStageMutation) OldTaskID(ctx context.Context) (v uint64, err error) {
  23632. if !m.op.Is(OpUpdateOne) {
  23633. return v, errors.New("OldTaskID is only allowed on UpdateOne operations")
  23634. }
  23635. if m.id == nil || m.oldValue == nil {
  23636. return v, errors.New("OldTaskID requires an ID field in the mutation")
  23637. }
  23638. oldValue, err := m.oldValue(ctx)
  23639. if err != nil {
  23640. return v, fmt.Errorf("querying old value for OldTaskID: %w", err)
  23641. }
  23642. return oldValue.TaskID, nil
  23643. }
  23644. // ResetTaskID resets all changes to the "task_id" field.
  23645. func (m *SopStageMutation) ResetTaskID() {
  23646. m.sop_task = nil
  23647. }
  23648. // SetName sets the "name" field.
  23649. func (m *SopStageMutation) SetName(s string) {
  23650. m.name = &s
  23651. }
  23652. // Name returns the value of the "name" field in the mutation.
  23653. func (m *SopStageMutation) Name() (r string, exists bool) {
  23654. v := m.name
  23655. if v == nil {
  23656. return
  23657. }
  23658. return *v, true
  23659. }
  23660. // OldName returns the old "name" field's value of the SopStage entity.
  23661. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  23662. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23663. func (m *SopStageMutation) OldName(ctx context.Context) (v string, err error) {
  23664. if !m.op.Is(OpUpdateOne) {
  23665. return v, errors.New("OldName is only allowed on UpdateOne operations")
  23666. }
  23667. if m.id == nil || m.oldValue == nil {
  23668. return v, errors.New("OldName requires an ID field in the mutation")
  23669. }
  23670. oldValue, err := m.oldValue(ctx)
  23671. if err != nil {
  23672. return v, fmt.Errorf("querying old value for OldName: %w", err)
  23673. }
  23674. return oldValue.Name, nil
  23675. }
  23676. // ResetName resets all changes to the "name" field.
  23677. func (m *SopStageMutation) ResetName() {
  23678. m.name = nil
  23679. }
  23680. // SetConditionType sets the "condition_type" field.
  23681. func (m *SopStageMutation) SetConditionType(i int) {
  23682. m.condition_type = &i
  23683. m.addcondition_type = nil
  23684. }
  23685. // ConditionType returns the value of the "condition_type" field in the mutation.
  23686. func (m *SopStageMutation) ConditionType() (r int, exists bool) {
  23687. v := m.condition_type
  23688. if v == nil {
  23689. return
  23690. }
  23691. return *v, true
  23692. }
  23693. // OldConditionType returns the old "condition_type" field's value of the SopStage entity.
  23694. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  23695. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23696. func (m *SopStageMutation) OldConditionType(ctx context.Context) (v int, err error) {
  23697. if !m.op.Is(OpUpdateOne) {
  23698. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  23699. }
  23700. if m.id == nil || m.oldValue == nil {
  23701. return v, errors.New("OldConditionType requires an ID field in the mutation")
  23702. }
  23703. oldValue, err := m.oldValue(ctx)
  23704. if err != nil {
  23705. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  23706. }
  23707. return oldValue.ConditionType, nil
  23708. }
  23709. // AddConditionType adds i to the "condition_type" field.
  23710. func (m *SopStageMutation) AddConditionType(i int) {
  23711. if m.addcondition_type != nil {
  23712. *m.addcondition_type += i
  23713. } else {
  23714. m.addcondition_type = &i
  23715. }
  23716. }
  23717. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  23718. func (m *SopStageMutation) AddedConditionType() (r int, exists bool) {
  23719. v := m.addcondition_type
  23720. if v == nil {
  23721. return
  23722. }
  23723. return *v, true
  23724. }
  23725. // ResetConditionType resets all changes to the "condition_type" field.
  23726. func (m *SopStageMutation) ResetConditionType() {
  23727. m.condition_type = nil
  23728. m.addcondition_type = nil
  23729. }
  23730. // SetConditionOperator sets the "condition_operator" field.
  23731. func (m *SopStageMutation) SetConditionOperator(i int) {
  23732. m.condition_operator = &i
  23733. m.addcondition_operator = nil
  23734. }
  23735. // ConditionOperator returns the value of the "condition_operator" field in the mutation.
  23736. func (m *SopStageMutation) ConditionOperator() (r int, exists bool) {
  23737. v := m.condition_operator
  23738. if v == nil {
  23739. return
  23740. }
  23741. return *v, true
  23742. }
  23743. // OldConditionOperator returns the old "condition_operator" field's value of the SopStage entity.
  23744. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  23745. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23746. func (m *SopStageMutation) OldConditionOperator(ctx context.Context) (v int, err error) {
  23747. if !m.op.Is(OpUpdateOne) {
  23748. return v, errors.New("OldConditionOperator is only allowed on UpdateOne operations")
  23749. }
  23750. if m.id == nil || m.oldValue == nil {
  23751. return v, errors.New("OldConditionOperator requires an ID field in the mutation")
  23752. }
  23753. oldValue, err := m.oldValue(ctx)
  23754. if err != nil {
  23755. return v, fmt.Errorf("querying old value for OldConditionOperator: %w", err)
  23756. }
  23757. return oldValue.ConditionOperator, nil
  23758. }
  23759. // AddConditionOperator adds i to the "condition_operator" field.
  23760. func (m *SopStageMutation) AddConditionOperator(i int) {
  23761. if m.addcondition_operator != nil {
  23762. *m.addcondition_operator += i
  23763. } else {
  23764. m.addcondition_operator = &i
  23765. }
  23766. }
  23767. // AddedConditionOperator returns the value that was added to the "condition_operator" field in this mutation.
  23768. func (m *SopStageMutation) AddedConditionOperator() (r int, exists bool) {
  23769. v := m.addcondition_operator
  23770. if v == nil {
  23771. return
  23772. }
  23773. return *v, true
  23774. }
  23775. // ResetConditionOperator resets all changes to the "condition_operator" field.
  23776. func (m *SopStageMutation) ResetConditionOperator() {
  23777. m.condition_operator = nil
  23778. m.addcondition_operator = nil
  23779. }
  23780. // SetConditionList sets the "condition_list" field.
  23781. func (m *SopStageMutation) SetConditionList(ct []custom_types.Condition) {
  23782. m.condition_list = &ct
  23783. m.appendcondition_list = nil
  23784. }
  23785. // ConditionList returns the value of the "condition_list" field in the mutation.
  23786. func (m *SopStageMutation) ConditionList() (r []custom_types.Condition, exists bool) {
  23787. v := m.condition_list
  23788. if v == nil {
  23789. return
  23790. }
  23791. return *v, true
  23792. }
  23793. // OldConditionList returns the old "condition_list" field's value of the SopStage entity.
  23794. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  23795. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23796. func (m *SopStageMutation) OldConditionList(ctx context.Context) (v []custom_types.Condition, err error) {
  23797. if !m.op.Is(OpUpdateOne) {
  23798. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  23799. }
  23800. if m.id == nil || m.oldValue == nil {
  23801. return v, errors.New("OldConditionList requires an ID field in the mutation")
  23802. }
  23803. oldValue, err := m.oldValue(ctx)
  23804. if err != nil {
  23805. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  23806. }
  23807. return oldValue.ConditionList, nil
  23808. }
  23809. // AppendConditionList adds ct to the "condition_list" field.
  23810. func (m *SopStageMutation) AppendConditionList(ct []custom_types.Condition) {
  23811. m.appendcondition_list = append(m.appendcondition_list, ct...)
  23812. }
  23813. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  23814. func (m *SopStageMutation) AppendedConditionList() ([]custom_types.Condition, bool) {
  23815. if len(m.appendcondition_list) == 0 {
  23816. return nil, false
  23817. }
  23818. return m.appendcondition_list, true
  23819. }
  23820. // ResetConditionList resets all changes to the "condition_list" field.
  23821. func (m *SopStageMutation) ResetConditionList() {
  23822. m.condition_list = nil
  23823. m.appendcondition_list = nil
  23824. }
  23825. // SetActionMessage sets the "action_message" field.
  23826. func (m *SopStageMutation) SetActionMessage(ct []custom_types.Action) {
  23827. m.action_message = &ct
  23828. m.appendaction_message = nil
  23829. }
  23830. // ActionMessage returns the value of the "action_message" field in the mutation.
  23831. func (m *SopStageMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  23832. v := m.action_message
  23833. if v == nil {
  23834. return
  23835. }
  23836. return *v, true
  23837. }
  23838. // OldActionMessage returns the old "action_message" field's value of the SopStage entity.
  23839. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  23840. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23841. func (m *SopStageMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  23842. if !m.op.Is(OpUpdateOne) {
  23843. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  23844. }
  23845. if m.id == nil || m.oldValue == nil {
  23846. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  23847. }
  23848. oldValue, err := m.oldValue(ctx)
  23849. if err != nil {
  23850. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  23851. }
  23852. return oldValue.ActionMessage, nil
  23853. }
  23854. // AppendActionMessage adds ct to the "action_message" field.
  23855. func (m *SopStageMutation) AppendActionMessage(ct []custom_types.Action) {
  23856. m.appendaction_message = append(m.appendaction_message, ct...)
  23857. }
  23858. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  23859. func (m *SopStageMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  23860. if len(m.appendaction_message) == 0 {
  23861. return nil, false
  23862. }
  23863. return m.appendaction_message, true
  23864. }
  23865. // ClearActionMessage clears the value of the "action_message" field.
  23866. func (m *SopStageMutation) ClearActionMessage() {
  23867. m.action_message = nil
  23868. m.appendaction_message = nil
  23869. m.clearedFields[sopstage.FieldActionMessage] = struct{}{}
  23870. }
  23871. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  23872. func (m *SopStageMutation) ActionMessageCleared() bool {
  23873. _, ok := m.clearedFields[sopstage.FieldActionMessage]
  23874. return ok
  23875. }
  23876. // ResetActionMessage resets all changes to the "action_message" field.
  23877. func (m *SopStageMutation) ResetActionMessage() {
  23878. m.action_message = nil
  23879. m.appendaction_message = nil
  23880. delete(m.clearedFields, sopstage.FieldActionMessage)
  23881. }
  23882. // SetActionLabelAdd sets the "action_label_add" field.
  23883. func (m *SopStageMutation) SetActionLabelAdd(u []uint64) {
  23884. m.action_label_add = &u
  23885. m.appendaction_label_add = nil
  23886. }
  23887. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  23888. func (m *SopStageMutation) ActionLabelAdd() (r []uint64, exists bool) {
  23889. v := m.action_label_add
  23890. if v == nil {
  23891. return
  23892. }
  23893. return *v, true
  23894. }
  23895. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopStage entity.
  23896. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  23897. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23898. func (m *SopStageMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  23899. if !m.op.Is(OpUpdateOne) {
  23900. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  23901. }
  23902. if m.id == nil || m.oldValue == nil {
  23903. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  23904. }
  23905. oldValue, err := m.oldValue(ctx)
  23906. if err != nil {
  23907. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  23908. }
  23909. return oldValue.ActionLabelAdd, nil
  23910. }
  23911. // AppendActionLabelAdd adds u to the "action_label_add" field.
  23912. func (m *SopStageMutation) AppendActionLabelAdd(u []uint64) {
  23913. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  23914. }
  23915. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  23916. func (m *SopStageMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  23917. if len(m.appendaction_label_add) == 0 {
  23918. return nil, false
  23919. }
  23920. return m.appendaction_label_add, true
  23921. }
  23922. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  23923. func (m *SopStageMutation) ClearActionLabelAdd() {
  23924. m.action_label_add = nil
  23925. m.appendaction_label_add = nil
  23926. m.clearedFields[sopstage.FieldActionLabelAdd] = struct{}{}
  23927. }
  23928. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  23929. func (m *SopStageMutation) ActionLabelAddCleared() bool {
  23930. _, ok := m.clearedFields[sopstage.FieldActionLabelAdd]
  23931. return ok
  23932. }
  23933. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  23934. func (m *SopStageMutation) ResetActionLabelAdd() {
  23935. m.action_label_add = nil
  23936. m.appendaction_label_add = nil
  23937. delete(m.clearedFields, sopstage.FieldActionLabelAdd)
  23938. }
  23939. // SetActionLabelDel sets the "action_label_del" field.
  23940. func (m *SopStageMutation) SetActionLabelDel(u []uint64) {
  23941. m.action_label_del = &u
  23942. m.appendaction_label_del = nil
  23943. }
  23944. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  23945. func (m *SopStageMutation) ActionLabelDel() (r []uint64, exists bool) {
  23946. v := m.action_label_del
  23947. if v == nil {
  23948. return
  23949. }
  23950. return *v, true
  23951. }
  23952. // OldActionLabelDel returns the old "action_label_del" field's value of the SopStage entity.
  23953. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  23954. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23955. func (m *SopStageMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  23956. if !m.op.Is(OpUpdateOne) {
  23957. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  23958. }
  23959. if m.id == nil || m.oldValue == nil {
  23960. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  23961. }
  23962. oldValue, err := m.oldValue(ctx)
  23963. if err != nil {
  23964. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  23965. }
  23966. return oldValue.ActionLabelDel, nil
  23967. }
  23968. // AppendActionLabelDel adds u to the "action_label_del" field.
  23969. func (m *SopStageMutation) AppendActionLabelDel(u []uint64) {
  23970. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  23971. }
  23972. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  23973. func (m *SopStageMutation) AppendedActionLabelDel() ([]uint64, bool) {
  23974. if len(m.appendaction_label_del) == 0 {
  23975. return nil, false
  23976. }
  23977. return m.appendaction_label_del, true
  23978. }
  23979. // ClearActionLabelDel clears the value of the "action_label_del" field.
  23980. func (m *SopStageMutation) ClearActionLabelDel() {
  23981. m.action_label_del = nil
  23982. m.appendaction_label_del = nil
  23983. m.clearedFields[sopstage.FieldActionLabelDel] = struct{}{}
  23984. }
  23985. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  23986. func (m *SopStageMutation) ActionLabelDelCleared() bool {
  23987. _, ok := m.clearedFields[sopstage.FieldActionLabelDel]
  23988. return ok
  23989. }
  23990. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  23991. func (m *SopStageMutation) ResetActionLabelDel() {
  23992. m.action_label_del = nil
  23993. m.appendaction_label_del = nil
  23994. delete(m.clearedFields, sopstage.FieldActionLabelDel)
  23995. }
  23996. // SetActionForward sets the "action_forward" field.
  23997. func (m *SopStageMutation) SetActionForward(ctf *custom_types.ActionForward) {
  23998. m.action_forward = &ctf
  23999. }
  24000. // ActionForward returns the value of the "action_forward" field in the mutation.
  24001. func (m *SopStageMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  24002. v := m.action_forward
  24003. if v == nil {
  24004. return
  24005. }
  24006. return *v, true
  24007. }
  24008. // OldActionForward returns the old "action_forward" field's value of the SopStage entity.
  24009. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  24010. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24011. func (m *SopStageMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  24012. if !m.op.Is(OpUpdateOne) {
  24013. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  24014. }
  24015. if m.id == nil || m.oldValue == nil {
  24016. return v, errors.New("OldActionForward requires an ID field in the mutation")
  24017. }
  24018. oldValue, err := m.oldValue(ctx)
  24019. if err != nil {
  24020. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  24021. }
  24022. return oldValue.ActionForward, nil
  24023. }
  24024. // ClearActionForward clears the value of the "action_forward" field.
  24025. func (m *SopStageMutation) ClearActionForward() {
  24026. m.action_forward = nil
  24027. m.clearedFields[sopstage.FieldActionForward] = struct{}{}
  24028. }
  24029. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  24030. func (m *SopStageMutation) ActionForwardCleared() bool {
  24031. _, ok := m.clearedFields[sopstage.FieldActionForward]
  24032. return ok
  24033. }
  24034. // ResetActionForward resets all changes to the "action_forward" field.
  24035. func (m *SopStageMutation) ResetActionForward() {
  24036. m.action_forward = nil
  24037. delete(m.clearedFields, sopstage.FieldActionForward)
  24038. }
  24039. // SetIndexSort sets the "index_sort" field.
  24040. func (m *SopStageMutation) SetIndexSort(i int) {
  24041. m.index_sort = &i
  24042. m.addindex_sort = nil
  24043. }
  24044. // IndexSort returns the value of the "index_sort" field in the mutation.
  24045. func (m *SopStageMutation) IndexSort() (r int, exists bool) {
  24046. v := m.index_sort
  24047. if v == nil {
  24048. return
  24049. }
  24050. return *v, true
  24051. }
  24052. // OldIndexSort returns the old "index_sort" field's value of the SopStage entity.
  24053. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  24054. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24055. func (m *SopStageMutation) OldIndexSort(ctx context.Context) (v int, err error) {
  24056. if !m.op.Is(OpUpdateOne) {
  24057. return v, errors.New("OldIndexSort is only allowed on UpdateOne operations")
  24058. }
  24059. if m.id == nil || m.oldValue == nil {
  24060. return v, errors.New("OldIndexSort requires an ID field in the mutation")
  24061. }
  24062. oldValue, err := m.oldValue(ctx)
  24063. if err != nil {
  24064. return v, fmt.Errorf("querying old value for OldIndexSort: %w", err)
  24065. }
  24066. return oldValue.IndexSort, nil
  24067. }
  24068. // AddIndexSort adds i to the "index_sort" field.
  24069. func (m *SopStageMutation) AddIndexSort(i int) {
  24070. if m.addindex_sort != nil {
  24071. *m.addindex_sort += i
  24072. } else {
  24073. m.addindex_sort = &i
  24074. }
  24075. }
  24076. // AddedIndexSort returns the value that was added to the "index_sort" field in this mutation.
  24077. func (m *SopStageMutation) AddedIndexSort() (r int, exists bool) {
  24078. v := m.addindex_sort
  24079. if v == nil {
  24080. return
  24081. }
  24082. return *v, true
  24083. }
  24084. // ClearIndexSort clears the value of the "index_sort" field.
  24085. func (m *SopStageMutation) ClearIndexSort() {
  24086. m.index_sort = nil
  24087. m.addindex_sort = nil
  24088. m.clearedFields[sopstage.FieldIndexSort] = struct{}{}
  24089. }
  24090. // IndexSortCleared returns if the "index_sort" field was cleared in this mutation.
  24091. func (m *SopStageMutation) IndexSortCleared() bool {
  24092. _, ok := m.clearedFields[sopstage.FieldIndexSort]
  24093. return ok
  24094. }
  24095. // ResetIndexSort resets all changes to the "index_sort" field.
  24096. func (m *SopStageMutation) ResetIndexSort() {
  24097. m.index_sort = nil
  24098. m.addindex_sort = nil
  24099. delete(m.clearedFields, sopstage.FieldIndexSort)
  24100. }
  24101. // SetSopTaskID sets the "sop_task" edge to the SopTask entity by id.
  24102. func (m *SopStageMutation) SetSopTaskID(id uint64) {
  24103. m.sop_task = &id
  24104. }
  24105. // ClearSopTask clears the "sop_task" edge to the SopTask entity.
  24106. func (m *SopStageMutation) ClearSopTask() {
  24107. m.clearedsop_task = true
  24108. m.clearedFields[sopstage.FieldTaskID] = struct{}{}
  24109. }
  24110. // SopTaskCleared reports if the "sop_task" edge to the SopTask entity was cleared.
  24111. func (m *SopStageMutation) SopTaskCleared() bool {
  24112. return m.clearedsop_task
  24113. }
  24114. // SopTaskID returns the "sop_task" edge ID in the mutation.
  24115. func (m *SopStageMutation) SopTaskID() (id uint64, exists bool) {
  24116. if m.sop_task != nil {
  24117. return *m.sop_task, true
  24118. }
  24119. return
  24120. }
  24121. // SopTaskIDs returns the "sop_task" edge IDs in the mutation.
  24122. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  24123. // SopTaskID instead. It exists only for internal usage by the builders.
  24124. func (m *SopStageMutation) SopTaskIDs() (ids []uint64) {
  24125. if id := m.sop_task; id != nil {
  24126. ids = append(ids, *id)
  24127. }
  24128. return
  24129. }
  24130. // ResetSopTask resets all changes to the "sop_task" edge.
  24131. func (m *SopStageMutation) ResetSopTask() {
  24132. m.sop_task = nil
  24133. m.clearedsop_task = false
  24134. }
  24135. // AddStageNodeIDs adds the "stage_nodes" edge to the SopNode entity by ids.
  24136. func (m *SopStageMutation) AddStageNodeIDs(ids ...uint64) {
  24137. if m.stage_nodes == nil {
  24138. m.stage_nodes = make(map[uint64]struct{})
  24139. }
  24140. for i := range ids {
  24141. m.stage_nodes[ids[i]] = struct{}{}
  24142. }
  24143. }
  24144. // ClearStageNodes clears the "stage_nodes" edge to the SopNode entity.
  24145. func (m *SopStageMutation) ClearStageNodes() {
  24146. m.clearedstage_nodes = true
  24147. }
  24148. // StageNodesCleared reports if the "stage_nodes" edge to the SopNode entity was cleared.
  24149. func (m *SopStageMutation) StageNodesCleared() bool {
  24150. return m.clearedstage_nodes
  24151. }
  24152. // RemoveStageNodeIDs removes the "stage_nodes" edge to the SopNode entity by IDs.
  24153. func (m *SopStageMutation) RemoveStageNodeIDs(ids ...uint64) {
  24154. if m.removedstage_nodes == nil {
  24155. m.removedstage_nodes = make(map[uint64]struct{})
  24156. }
  24157. for i := range ids {
  24158. delete(m.stage_nodes, ids[i])
  24159. m.removedstage_nodes[ids[i]] = struct{}{}
  24160. }
  24161. }
  24162. // RemovedStageNodes returns the removed IDs of the "stage_nodes" edge to the SopNode entity.
  24163. func (m *SopStageMutation) RemovedStageNodesIDs() (ids []uint64) {
  24164. for id := range m.removedstage_nodes {
  24165. ids = append(ids, id)
  24166. }
  24167. return
  24168. }
  24169. // StageNodesIDs returns the "stage_nodes" edge IDs in the mutation.
  24170. func (m *SopStageMutation) StageNodesIDs() (ids []uint64) {
  24171. for id := range m.stage_nodes {
  24172. ids = append(ids, id)
  24173. }
  24174. return
  24175. }
  24176. // ResetStageNodes resets all changes to the "stage_nodes" edge.
  24177. func (m *SopStageMutation) ResetStageNodes() {
  24178. m.stage_nodes = nil
  24179. m.clearedstage_nodes = false
  24180. m.removedstage_nodes = nil
  24181. }
  24182. // AddStageMessageIDs adds the "stage_messages" edge to the MessageRecords entity by ids.
  24183. func (m *SopStageMutation) AddStageMessageIDs(ids ...uint64) {
  24184. if m.stage_messages == nil {
  24185. m.stage_messages = make(map[uint64]struct{})
  24186. }
  24187. for i := range ids {
  24188. m.stage_messages[ids[i]] = struct{}{}
  24189. }
  24190. }
  24191. // ClearStageMessages clears the "stage_messages" edge to the MessageRecords entity.
  24192. func (m *SopStageMutation) ClearStageMessages() {
  24193. m.clearedstage_messages = true
  24194. }
  24195. // StageMessagesCleared reports if the "stage_messages" edge to the MessageRecords entity was cleared.
  24196. func (m *SopStageMutation) StageMessagesCleared() bool {
  24197. return m.clearedstage_messages
  24198. }
  24199. // RemoveStageMessageIDs removes the "stage_messages" edge to the MessageRecords entity by IDs.
  24200. func (m *SopStageMutation) RemoveStageMessageIDs(ids ...uint64) {
  24201. if m.removedstage_messages == nil {
  24202. m.removedstage_messages = make(map[uint64]struct{})
  24203. }
  24204. for i := range ids {
  24205. delete(m.stage_messages, ids[i])
  24206. m.removedstage_messages[ids[i]] = struct{}{}
  24207. }
  24208. }
  24209. // RemovedStageMessages returns the removed IDs of the "stage_messages" edge to the MessageRecords entity.
  24210. func (m *SopStageMutation) RemovedStageMessagesIDs() (ids []uint64) {
  24211. for id := range m.removedstage_messages {
  24212. ids = append(ids, id)
  24213. }
  24214. return
  24215. }
  24216. // StageMessagesIDs returns the "stage_messages" edge IDs in the mutation.
  24217. func (m *SopStageMutation) StageMessagesIDs() (ids []uint64) {
  24218. for id := range m.stage_messages {
  24219. ids = append(ids, id)
  24220. }
  24221. return
  24222. }
  24223. // ResetStageMessages resets all changes to the "stage_messages" edge.
  24224. func (m *SopStageMutation) ResetStageMessages() {
  24225. m.stage_messages = nil
  24226. m.clearedstage_messages = false
  24227. m.removedstage_messages = nil
  24228. }
  24229. // Where appends a list predicates to the SopStageMutation builder.
  24230. func (m *SopStageMutation) Where(ps ...predicate.SopStage) {
  24231. m.predicates = append(m.predicates, ps...)
  24232. }
  24233. // WhereP appends storage-level predicates to the SopStageMutation builder. Using this method,
  24234. // users can use type-assertion to append predicates that do not depend on any generated package.
  24235. func (m *SopStageMutation) WhereP(ps ...func(*sql.Selector)) {
  24236. p := make([]predicate.SopStage, len(ps))
  24237. for i := range ps {
  24238. p[i] = ps[i]
  24239. }
  24240. m.Where(p...)
  24241. }
  24242. // Op returns the operation name.
  24243. func (m *SopStageMutation) Op() Op {
  24244. return m.op
  24245. }
  24246. // SetOp allows setting the mutation operation.
  24247. func (m *SopStageMutation) SetOp(op Op) {
  24248. m.op = op
  24249. }
  24250. // Type returns the node type of this mutation (SopStage).
  24251. func (m *SopStageMutation) Type() string {
  24252. return m.typ
  24253. }
  24254. // Fields returns all fields that were changed during this mutation. Note that in
  24255. // order to get all numeric fields that were incremented/decremented, call
  24256. // AddedFields().
  24257. func (m *SopStageMutation) Fields() []string {
  24258. fields := make([]string, 0, 14)
  24259. if m.created_at != nil {
  24260. fields = append(fields, sopstage.FieldCreatedAt)
  24261. }
  24262. if m.updated_at != nil {
  24263. fields = append(fields, sopstage.FieldUpdatedAt)
  24264. }
  24265. if m.status != nil {
  24266. fields = append(fields, sopstage.FieldStatus)
  24267. }
  24268. if m.deleted_at != nil {
  24269. fields = append(fields, sopstage.FieldDeletedAt)
  24270. }
  24271. if m.sop_task != nil {
  24272. fields = append(fields, sopstage.FieldTaskID)
  24273. }
  24274. if m.name != nil {
  24275. fields = append(fields, sopstage.FieldName)
  24276. }
  24277. if m.condition_type != nil {
  24278. fields = append(fields, sopstage.FieldConditionType)
  24279. }
  24280. if m.condition_operator != nil {
  24281. fields = append(fields, sopstage.FieldConditionOperator)
  24282. }
  24283. if m.condition_list != nil {
  24284. fields = append(fields, sopstage.FieldConditionList)
  24285. }
  24286. if m.action_message != nil {
  24287. fields = append(fields, sopstage.FieldActionMessage)
  24288. }
  24289. if m.action_label_add != nil {
  24290. fields = append(fields, sopstage.FieldActionLabelAdd)
  24291. }
  24292. if m.action_label_del != nil {
  24293. fields = append(fields, sopstage.FieldActionLabelDel)
  24294. }
  24295. if m.action_forward != nil {
  24296. fields = append(fields, sopstage.FieldActionForward)
  24297. }
  24298. if m.index_sort != nil {
  24299. fields = append(fields, sopstage.FieldIndexSort)
  24300. }
  24301. return fields
  24302. }
  24303. // Field returns the value of a field with the given name. The second boolean
  24304. // return value indicates that this field was not set, or was not defined in the
  24305. // schema.
  24306. func (m *SopStageMutation) Field(name string) (ent.Value, bool) {
  24307. switch name {
  24308. case sopstage.FieldCreatedAt:
  24309. return m.CreatedAt()
  24310. case sopstage.FieldUpdatedAt:
  24311. return m.UpdatedAt()
  24312. case sopstage.FieldStatus:
  24313. return m.Status()
  24314. case sopstage.FieldDeletedAt:
  24315. return m.DeletedAt()
  24316. case sopstage.FieldTaskID:
  24317. return m.TaskID()
  24318. case sopstage.FieldName:
  24319. return m.Name()
  24320. case sopstage.FieldConditionType:
  24321. return m.ConditionType()
  24322. case sopstage.FieldConditionOperator:
  24323. return m.ConditionOperator()
  24324. case sopstage.FieldConditionList:
  24325. return m.ConditionList()
  24326. case sopstage.FieldActionMessage:
  24327. return m.ActionMessage()
  24328. case sopstage.FieldActionLabelAdd:
  24329. return m.ActionLabelAdd()
  24330. case sopstage.FieldActionLabelDel:
  24331. return m.ActionLabelDel()
  24332. case sopstage.FieldActionForward:
  24333. return m.ActionForward()
  24334. case sopstage.FieldIndexSort:
  24335. return m.IndexSort()
  24336. }
  24337. return nil, false
  24338. }
  24339. // OldField returns the old value of the field from the database. An error is
  24340. // returned if the mutation operation is not UpdateOne, or the query to the
  24341. // database failed.
  24342. func (m *SopStageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  24343. switch name {
  24344. case sopstage.FieldCreatedAt:
  24345. return m.OldCreatedAt(ctx)
  24346. case sopstage.FieldUpdatedAt:
  24347. return m.OldUpdatedAt(ctx)
  24348. case sopstage.FieldStatus:
  24349. return m.OldStatus(ctx)
  24350. case sopstage.FieldDeletedAt:
  24351. return m.OldDeletedAt(ctx)
  24352. case sopstage.FieldTaskID:
  24353. return m.OldTaskID(ctx)
  24354. case sopstage.FieldName:
  24355. return m.OldName(ctx)
  24356. case sopstage.FieldConditionType:
  24357. return m.OldConditionType(ctx)
  24358. case sopstage.FieldConditionOperator:
  24359. return m.OldConditionOperator(ctx)
  24360. case sopstage.FieldConditionList:
  24361. return m.OldConditionList(ctx)
  24362. case sopstage.FieldActionMessage:
  24363. return m.OldActionMessage(ctx)
  24364. case sopstage.FieldActionLabelAdd:
  24365. return m.OldActionLabelAdd(ctx)
  24366. case sopstage.FieldActionLabelDel:
  24367. return m.OldActionLabelDel(ctx)
  24368. case sopstage.FieldActionForward:
  24369. return m.OldActionForward(ctx)
  24370. case sopstage.FieldIndexSort:
  24371. return m.OldIndexSort(ctx)
  24372. }
  24373. return nil, fmt.Errorf("unknown SopStage field %s", name)
  24374. }
  24375. // SetField sets the value of a field with the given name. It returns an error if
  24376. // the field is not defined in the schema, or if the type mismatched the field
  24377. // type.
  24378. func (m *SopStageMutation) SetField(name string, value ent.Value) error {
  24379. switch name {
  24380. case sopstage.FieldCreatedAt:
  24381. v, ok := value.(time.Time)
  24382. if !ok {
  24383. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24384. }
  24385. m.SetCreatedAt(v)
  24386. return nil
  24387. case sopstage.FieldUpdatedAt:
  24388. v, ok := value.(time.Time)
  24389. if !ok {
  24390. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24391. }
  24392. m.SetUpdatedAt(v)
  24393. return nil
  24394. case sopstage.FieldStatus:
  24395. v, ok := value.(uint8)
  24396. if !ok {
  24397. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24398. }
  24399. m.SetStatus(v)
  24400. return nil
  24401. case sopstage.FieldDeletedAt:
  24402. v, ok := value.(time.Time)
  24403. if !ok {
  24404. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24405. }
  24406. m.SetDeletedAt(v)
  24407. return nil
  24408. case sopstage.FieldTaskID:
  24409. v, ok := value.(uint64)
  24410. if !ok {
  24411. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24412. }
  24413. m.SetTaskID(v)
  24414. return nil
  24415. case sopstage.FieldName:
  24416. v, ok := value.(string)
  24417. if !ok {
  24418. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24419. }
  24420. m.SetName(v)
  24421. return nil
  24422. case sopstage.FieldConditionType:
  24423. v, ok := value.(int)
  24424. if !ok {
  24425. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24426. }
  24427. m.SetConditionType(v)
  24428. return nil
  24429. case sopstage.FieldConditionOperator:
  24430. v, ok := value.(int)
  24431. if !ok {
  24432. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24433. }
  24434. m.SetConditionOperator(v)
  24435. return nil
  24436. case sopstage.FieldConditionList:
  24437. v, ok := value.([]custom_types.Condition)
  24438. if !ok {
  24439. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24440. }
  24441. m.SetConditionList(v)
  24442. return nil
  24443. case sopstage.FieldActionMessage:
  24444. v, ok := value.([]custom_types.Action)
  24445. if !ok {
  24446. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24447. }
  24448. m.SetActionMessage(v)
  24449. return nil
  24450. case sopstage.FieldActionLabelAdd:
  24451. v, ok := value.([]uint64)
  24452. if !ok {
  24453. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24454. }
  24455. m.SetActionLabelAdd(v)
  24456. return nil
  24457. case sopstage.FieldActionLabelDel:
  24458. v, ok := value.([]uint64)
  24459. if !ok {
  24460. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24461. }
  24462. m.SetActionLabelDel(v)
  24463. return nil
  24464. case sopstage.FieldActionForward:
  24465. v, ok := value.(*custom_types.ActionForward)
  24466. if !ok {
  24467. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24468. }
  24469. m.SetActionForward(v)
  24470. return nil
  24471. case sopstage.FieldIndexSort:
  24472. v, ok := value.(int)
  24473. if !ok {
  24474. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24475. }
  24476. m.SetIndexSort(v)
  24477. return nil
  24478. }
  24479. return fmt.Errorf("unknown SopStage field %s", name)
  24480. }
  24481. // AddedFields returns all numeric fields that were incremented/decremented during
  24482. // this mutation.
  24483. func (m *SopStageMutation) AddedFields() []string {
  24484. var fields []string
  24485. if m.addstatus != nil {
  24486. fields = append(fields, sopstage.FieldStatus)
  24487. }
  24488. if m.addcondition_type != nil {
  24489. fields = append(fields, sopstage.FieldConditionType)
  24490. }
  24491. if m.addcondition_operator != nil {
  24492. fields = append(fields, sopstage.FieldConditionOperator)
  24493. }
  24494. if m.addindex_sort != nil {
  24495. fields = append(fields, sopstage.FieldIndexSort)
  24496. }
  24497. return fields
  24498. }
  24499. // AddedField returns the numeric value that was incremented/decremented on a field
  24500. // with the given name. The second boolean return value indicates that this field
  24501. // was not set, or was not defined in the schema.
  24502. func (m *SopStageMutation) AddedField(name string) (ent.Value, bool) {
  24503. switch name {
  24504. case sopstage.FieldStatus:
  24505. return m.AddedStatus()
  24506. case sopstage.FieldConditionType:
  24507. return m.AddedConditionType()
  24508. case sopstage.FieldConditionOperator:
  24509. return m.AddedConditionOperator()
  24510. case sopstage.FieldIndexSort:
  24511. return m.AddedIndexSort()
  24512. }
  24513. return nil, false
  24514. }
  24515. // AddField adds the value to the field with the given name. It returns an error if
  24516. // the field is not defined in the schema, or if the type mismatched the field
  24517. // type.
  24518. func (m *SopStageMutation) AddField(name string, value ent.Value) error {
  24519. switch name {
  24520. case sopstage.FieldStatus:
  24521. v, ok := value.(int8)
  24522. if !ok {
  24523. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24524. }
  24525. m.AddStatus(v)
  24526. return nil
  24527. case sopstage.FieldConditionType:
  24528. v, ok := value.(int)
  24529. if !ok {
  24530. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24531. }
  24532. m.AddConditionType(v)
  24533. return nil
  24534. case sopstage.FieldConditionOperator:
  24535. v, ok := value.(int)
  24536. if !ok {
  24537. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24538. }
  24539. m.AddConditionOperator(v)
  24540. return nil
  24541. case sopstage.FieldIndexSort:
  24542. v, ok := value.(int)
  24543. if !ok {
  24544. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24545. }
  24546. m.AddIndexSort(v)
  24547. return nil
  24548. }
  24549. return fmt.Errorf("unknown SopStage numeric field %s", name)
  24550. }
  24551. // ClearedFields returns all nullable fields that were cleared during this
  24552. // mutation.
  24553. func (m *SopStageMutation) ClearedFields() []string {
  24554. var fields []string
  24555. if m.FieldCleared(sopstage.FieldStatus) {
  24556. fields = append(fields, sopstage.FieldStatus)
  24557. }
  24558. if m.FieldCleared(sopstage.FieldDeletedAt) {
  24559. fields = append(fields, sopstage.FieldDeletedAt)
  24560. }
  24561. if m.FieldCleared(sopstage.FieldActionMessage) {
  24562. fields = append(fields, sopstage.FieldActionMessage)
  24563. }
  24564. if m.FieldCleared(sopstage.FieldActionLabelAdd) {
  24565. fields = append(fields, sopstage.FieldActionLabelAdd)
  24566. }
  24567. if m.FieldCleared(sopstage.FieldActionLabelDel) {
  24568. fields = append(fields, sopstage.FieldActionLabelDel)
  24569. }
  24570. if m.FieldCleared(sopstage.FieldActionForward) {
  24571. fields = append(fields, sopstage.FieldActionForward)
  24572. }
  24573. if m.FieldCleared(sopstage.FieldIndexSort) {
  24574. fields = append(fields, sopstage.FieldIndexSort)
  24575. }
  24576. return fields
  24577. }
  24578. // FieldCleared returns a boolean indicating if a field with the given name was
  24579. // cleared in this mutation.
  24580. func (m *SopStageMutation) FieldCleared(name string) bool {
  24581. _, ok := m.clearedFields[name]
  24582. return ok
  24583. }
  24584. // ClearField clears the value of the field with the given name. It returns an
  24585. // error if the field is not defined in the schema.
  24586. func (m *SopStageMutation) ClearField(name string) error {
  24587. switch name {
  24588. case sopstage.FieldStatus:
  24589. m.ClearStatus()
  24590. return nil
  24591. case sopstage.FieldDeletedAt:
  24592. m.ClearDeletedAt()
  24593. return nil
  24594. case sopstage.FieldActionMessage:
  24595. m.ClearActionMessage()
  24596. return nil
  24597. case sopstage.FieldActionLabelAdd:
  24598. m.ClearActionLabelAdd()
  24599. return nil
  24600. case sopstage.FieldActionLabelDel:
  24601. m.ClearActionLabelDel()
  24602. return nil
  24603. case sopstage.FieldActionForward:
  24604. m.ClearActionForward()
  24605. return nil
  24606. case sopstage.FieldIndexSort:
  24607. m.ClearIndexSort()
  24608. return nil
  24609. }
  24610. return fmt.Errorf("unknown SopStage nullable field %s", name)
  24611. }
  24612. // ResetField resets all changes in the mutation for the field with the given name.
  24613. // It returns an error if the field is not defined in the schema.
  24614. func (m *SopStageMutation) ResetField(name string) error {
  24615. switch name {
  24616. case sopstage.FieldCreatedAt:
  24617. m.ResetCreatedAt()
  24618. return nil
  24619. case sopstage.FieldUpdatedAt:
  24620. m.ResetUpdatedAt()
  24621. return nil
  24622. case sopstage.FieldStatus:
  24623. m.ResetStatus()
  24624. return nil
  24625. case sopstage.FieldDeletedAt:
  24626. m.ResetDeletedAt()
  24627. return nil
  24628. case sopstage.FieldTaskID:
  24629. m.ResetTaskID()
  24630. return nil
  24631. case sopstage.FieldName:
  24632. m.ResetName()
  24633. return nil
  24634. case sopstage.FieldConditionType:
  24635. m.ResetConditionType()
  24636. return nil
  24637. case sopstage.FieldConditionOperator:
  24638. m.ResetConditionOperator()
  24639. return nil
  24640. case sopstage.FieldConditionList:
  24641. m.ResetConditionList()
  24642. return nil
  24643. case sopstage.FieldActionMessage:
  24644. m.ResetActionMessage()
  24645. return nil
  24646. case sopstage.FieldActionLabelAdd:
  24647. m.ResetActionLabelAdd()
  24648. return nil
  24649. case sopstage.FieldActionLabelDel:
  24650. m.ResetActionLabelDel()
  24651. return nil
  24652. case sopstage.FieldActionForward:
  24653. m.ResetActionForward()
  24654. return nil
  24655. case sopstage.FieldIndexSort:
  24656. m.ResetIndexSort()
  24657. return nil
  24658. }
  24659. return fmt.Errorf("unknown SopStage field %s", name)
  24660. }
  24661. // AddedEdges returns all edge names that were set/added in this mutation.
  24662. func (m *SopStageMutation) AddedEdges() []string {
  24663. edges := make([]string, 0, 3)
  24664. if m.sop_task != nil {
  24665. edges = append(edges, sopstage.EdgeSopTask)
  24666. }
  24667. if m.stage_nodes != nil {
  24668. edges = append(edges, sopstage.EdgeStageNodes)
  24669. }
  24670. if m.stage_messages != nil {
  24671. edges = append(edges, sopstage.EdgeStageMessages)
  24672. }
  24673. return edges
  24674. }
  24675. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  24676. // name in this mutation.
  24677. func (m *SopStageMutation) AddedIDs(name string) []ent.Value {
  24678. switch name {
  24679. case sopstage.EdgeSopTask:
  24680. if id := m.sop_task; id != nil {
  24681. return []ent.Value{*id}
  24682. }
  24683. case sopstage.EdgeStageNodes:
  24684. ids := make([]ent.Value, 0, len(m.stage_nodes))
  24685. for id := range m.stage_nodes {
  24686. ids = append(ids, id)
  24687. }
  24688. return ids
  24689. case sopstage.EdgeStageMessages:
  24690. ids := make([]ent.Value, 0, len(m.stage_messages))
  24691. for id := range m.stage_messages {
  24692. ids = append(ids, id)
  24693. }
  24694. return ids
  24695. }
  24696. return nil
  24697. }
  24698. // RemovedEdges returns all edge names that were removed in this mutation.
  24699. func (m *SopStageMutation) RemovedEdges() []string {
  24700. edges := make([]string, 0, 3)
  24701. if m.removedstage_nodes != nil {
  24702. edges = append(edges, sopstage.EdgeStageNodes)
  24703. }
  24704. if m.removedstage_messages != nil {
  24705. edges = append(edges, sopstage.EdgeStageMessages)
  24706. }
  24707. return edges
  24708. }
  24709. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  24710. // the given name in this mutation.
  24711. func (m *SopStageMutation) RemovedIDs(name string) []ent.Value {
  24712. switch name {
  24713. case sopstage.EdgeStageNodes:
  24714. ids := make([]ent.Value, 0, len(m.removedstage_nodes))
  24715. for id := range m.removedstage_nodes {
  24716. ids = append(ids, id)
  24717. }
  24718. return ids
  24719. case sopstage.EdgeStageMessages:
  24720. ids := make([]ent.Value, 0, len(m.removedstage_messages))
  24721. for id := range m.removedstage_messages {
  24722. ids = append(ids, id)
  24723. }
  24724. return ids
  24725. }
  24726. return nil
  24727. }
  24728. // ClearedEdges returns all edge names that were cleared in this mutation.
  24729. func (m *SopStageMutation) ClearedEdges() []string {
  24730. edges := make([]string, 0, 3)
  24731. if m.clearedsop_task {
  24732. edges = append(edges, sopstage.EdgeSopTask)
  24733. }
  24734. if m.clearedstage_nodes {
  24735. edges = append(edges, sopstage.EdgeStageNodes)
  24736. }
  24737. if m.clearedstage_messages {
  24738. edges = append(edges, sopstage.EdgeStageMessages)
  24739. }
  24740. return edges
  24741. }
  24742. // EdgeCleared returns a boolean which indicates if the edge with the given name
  24743. // was cleared in this mutation.
  24744. func (m *SopStageMutation) EdgeCleared(name string) bool {
  24745. switch name {
  24746. case sopstage.EdgeSopTask:
  24747. return m.clearedsop_task
  24748. case sopstage.EdgeStageNodes:
  24749. return m.clearedstage_nodes
  24750. case sopstage.EdgeStageMessages:
  24751. return m.clearedstage_messages
  24752. }
  24753. return false
  24754. }
  24755. // ClearEdge clears the value of the edge with the given name. It returns an error
  24756. // if that edge is not defined in the schema.
  24757. func (m *SopStageMutation) ClearEdge(name string) error {
  24758. switch name {
  24759. case sopstage.EdgeSopTask:
  24760. m.ClearSopTask()
  24761. return nil
  24762. }
  24763. return fmt.Errorf("unknown SopStage unique edge %s", name)
  24764. }
  24765. // ResetEdge resets all changes to the edge with the given name in this mutation.
  24766. // It returns an error if the edge is not defined in the schema.
  24767. func (m *SopStageMutation) ResetEdge(name string) error {
  24768. switch name {
  24769. case sopstage.EdgeSopTask:
  24770. m.ResetSopTask()
  24771. return nil
  24772. case sopstage.EdgeStageNodes:
  24773. m.ResetStageNodes()
  24774. return nil
  24775. case sopstage.EdgeStageMessages:
  24776. m.ResetStageMessages()
  24777. return nil
  24778. }
  24779. return fmt.Errorf("unknown SopStage edge %s", name)
  24780. }
  24781. // SopTaskMutation represents an operation that mutates the SopTask nodes in the graph.
  24782. type SopTaskMutation struct {
  24783. config
  24784. op Op
  24785. typ string
  24786. id *uint64
  24787. created_at *time.Time
  24788. updated_at *time.Time
  24789. status *uint8
  24790. addstatus *int8
  24791. deleted_at *time.Time
  24792. name *string
  24793. bot_wxid_list *[]string
  24794. appendbot_wxid_list []string
  24795. _type *int
  24796. add_type *int
  24797. plan_start_time *time.Time
  24798. plan_end_time *time.Time
  24799. creator_id *string
  24800. organization_id *uint64
  24801. addorganization_id *int64
  24802. token *[]string
  24803. appendtoken []string
  24804. clearedFields map[string]struct{}
  24805. task_stages map[uint64]struct{}
  24806. removedtask_stages map[uint64]struct{}
  24807. clearedtask_stages bool
  24808. done bool
  24809. oldValue func(context.Context) (*SopTask, error)
  24810. predicates []predicate.SopTask
  24811. }
  24812. var _ ent.Mutation = (*SopTaskMutation)(nil)
  24813. // soptaskOption allows management of the mutation configuration using functional options.
  24814. type soptaskOption func(*SopTaskMutation)
  24815. // newSopTaskMutation creates new mutation for the SopTask entity.
  24816. func newSopTaskMutation(c config, op Op, opts ...soptaskOption) *SopTaskMutation {
  24817. m := &SopTaskMutation{
  24818. config: c,
  24819. op: op,
  24820. typ: TypeSopTask,
  24821. clearedFields: make(map[string]struct{}),
  24822. }
  24823. for _, opt := range opts {
  24824. opt(m)
  24825. }
  24826. return m
  24827. }
  24828. // withSopTaskID sets the ID field of the mutation.
  24829. func withSopTaskID(id uint64) soptaskOption {
  24830. return func(m *SopTaskMutation) {
  24831. var (
  24832. err error
  24833. once sync.Once
  24834. value *SopTask
  24835. )
  24836. m.oldValue = func(ctx context.Context) (*SopTask, error) {
  24837. once.Do(func() {
  24838. if m.done {
  24839. err = errors.New("querying old values post mutation is not allowed")
  24840. } else {
  24841. value, err = m.Client().SopTask.Get(ctx, id)
  24842. }
  24843. })
  24844. return value, err
  24845. }
  24846. m.id = &id
  24847. }
  24848. }
  24849. // withSopTask sets the old SopTask of the mutation.
  24850. func withSopTask(node *SopTask) soptaskOption {
  24851. return func(m *SopTaskMutation) {
  24852. m.oldValue = func(context.Context) (*SopTask, error) {
  24853. return node, nil
  24854. }
  24855. m.id = &node.ID
  24856. }
  24857. }
  24858. // Client returns a new `ent.Client` from the mutation. If the mutation was
  24859. // executed in a transaction (ent.Tx), a transactional client is returned.
  24860. func (m SopTaskMutation) Client() *Client {
  24861. client := &Client{config: m.config}
  24862. client.init()
  24863. return client
  24864. }
  24865. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  24866. // it returns an error otherwise.
  24867. func (m SopTaskMutation) Tx() (*Tx, error) {
  24868. if _, ok := m.driver.(*txDriver); !ok {
  24869. return nil, errors.New("ent: mutation is not running in a transaction")
  24870. }
  24871. tx := &Tx{config: m.config}
  24872. tx.init()
  24873. return tx, nil
  24874. }
  24875. // SetID sets the value of the id field. Note that this
  24876. // operation is only accepted on creation of SopTask entities.
  24877. func (m *SopTaskMutation) SetID(id uint64) {
  24878. m.id = &id
  24879. }
  24880. // ID returns the ID value in the mutation. Note that the ID is only available
  24881. // if it was provided to the builder or after it was returned from the database.
  24882. func (m *SopTaskMutation) ID() (id uint64, exists bool) {
  24883. if m.id == nil {
  24884. return
  24885. }
  24886. return *m.id, true
  24887. }
  24888. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  24889. // That means, if the mutation is applied within a transaction with an isolation level such
  24890. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  24891. // or updated by the mutation.
  24892. func (m *SopTaskMutation) IDs(ctx context.Context) ([]uint64, error) {
  24893. switch {
  24894. case m.op.Is(OpUpdateOne | OpDeleteOne):
  24895. id, exists := m.ID()
  24896. if exists {
  24897. return []uint64{id}, nil
  24898. }
  24899. fallthrough
  24900. case m.op.Is(OpUpdate | OpDelete):
  24901. return m.Client().SopTask.Query().Where(m.predicates...).IDs(ctx)
  24902. default:
  24903. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  24904. }
  24905. }
  24906. // SetCreatedAt sets the "created_at" field.
  24907. func (m *SopTaskMutation) SetCreatedAt(t time.Time) {
  24908. m.created_at = &t
  24909. }
  24910. // CreatedAt returns the value of the "created_at" field in the mutation.
  24911. func (m *SopTaskMutation) CreatedAt() (r time.Time, exists bool) {
  24912. v := m.created_at
  24913. if v == nil {
  24914. return
  24915. }
  24916. return *v, true
  24917. }
  24918. // OldCreatedAt returns the old "created_at" field's value of the SopTask entity.
  24919. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  24920. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24921. func (m *SopTaskMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  24922. if !m.op.Is(OpUpdateOne) {
  24923. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  24924. }
  24925. if m.id == nil || m.oldValue == nil {
  24926. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  24927. }
  24928. oldValue, err := m.oldValue(ctx)
  24929. if err != nil {
  24930. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  24931. }
  24932. return oldValue.CreatedAt, nil
  24933. }
  24934. // ResetCreatedAt resets all changes to the "created_at" field.
  24935. func (m *SopTaskMutation) ResetCreatedAt() {
  24936. m.created_at = nil
  24937. }
  24938. // SetUpdatedAt sets the "updated_at" field.
  24939. func (m *SopTaskMutation) SetUpdatedAt(t time.Time) {
  24940. m.updated_at = &t
  24941. }
  24942. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  24943. func (m *SopTaskMutation) UpdatedAt() (r time.Time, exists bool) {
  24944. v := m.updated_at
  24945. if v == nil {
  24946. return
  24947. }
  24948. return *v, true
  24949. }
  24950. // OldUpdatedAt returns the old "updated_at" field's value of the SopTask entity.
  24951. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  24952. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24953. func (m *SopTaskMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  24954. if !m.op.Is(OpUpdateOne) {
  24955. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  24956. }
  24957. if m.id == nil || m.oldValue == nil {
  24958. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  24959. }
  24960. oldValue, err := m.oldValue(ctx)
  24961. if err != nil {
  24962. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  24963. }
  24964. return oldValue.UpdatedAt, nil
  24965. }
  24966. // ResetUpdatedAt resets all changes to the "updated_at" field.
  24967. func (m *SopTaskMutation) ResetUpdatedAt() {
  24968. m.updated_at = nil
  24969. }
  24970. // SetStatus sets the "status" field.
  24971. func (m *SopTaskMutation) SetStatus(u uint8) {
  24972. m.status = &u
  24973. m.addstatus = nil
  24974. }
  24975. // Status returns the value of the "status" field in the mutation.
  24976. func (m *SopTaskMutation) Status() (r uint8, exists bool) {
  24977. v := m.status
  24978. if v == nil {
  24979. return
  24980. }
  24981. return *v, true
  24982. }
  24983. // OldStatus returns the old "status" field's value of the SopTask entity.
  24984. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  24985. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24986. func (m *SopTaskMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  24987. if !m.op.Is(OpUpdateOne) {
  24988. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  24989. }
  24990. if m.id == nil || m.oldValue == nil {
  24991. return v, errors.New("OldStatus requires an ID field in the mutation")
  24992. }
  24993. oldValue, err := m.oldValue(ctx)
  24994. if err != nil {
  24995. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  24996. }
  24997. return oldValue.Status, nil
  24998. }
  24999. // AddStatus adds u to the "status" field.
  25000. func (m *SopTaskMutation) AddStatus(u int8) {
  25001. if m.addstatus != nil {
  25002. *m.addstatus += u
  25003. } else {
  25004. m.addstatus = &u
  25005. }
  25006. }
  25007. // AddedStatus returns the value that was added to the "status" field in this mutation.
  25008. func (m *SopTaskMutation) AddedStatus() (r int8, exists bool) {
  25009. v := m.addstatus
  25010. if v == nil {
  25011. return
  25012. }
  25013. return *v, true
  25014. }
  25015. // ClearStatus clears the value of the "status" field.
  25016. func (m *SopTaskMutation) ClearStatus() {
  25017. m.status = nil
  25018. m.addstatus = nil
  25019. m.clearedFields[soptask.FieldStatus] = struct{}{}
  25020. }
  25021. // StatusCleared returns if the "status" field was cleared in this mutation.
  25022. func (m *SopTaskMutation) StatusCleared() bool {
  25023. _, ok := m.clearedFields[soptask.FieldStatus]
  25024. return ok
  25025. }
  25026. // ResetStatus resets all changes to the "status" field.
  25027. func (m *SopTaskMutation) ResetStatus() {
  25028. m.status = nil
  25029. m.addstatus = nil
  25030. delete(m.clearedFields, soptask.FieldStatus)
  25031. }
  25032. // SetDeletedAt sets the "deleted_at" field.
  25033. func (m *SopTaskMutation) SetDeletedAt(t time.Time) {
  25034. m.deleted_at = &t
  25035. }
  25036. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  25037. func (m *SopTaskMutation) DeletedAt() (r time.Time, exists bool) {
  25038. v := m.deleted_at
  25039. if v == nil {
  25040. return
  25041. }
  25042. return *v, true
  25043. }
  25044. // OldDeletedAt returns the old "deleted_at" field's value of the SopTask entity.
  25045. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  25046. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25047. func (m *SopTaskMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  25048. if !m.op.Is(OpUpdateOne) {
  25049. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  25050. }
  25051. if m.id == nil || m.oldValue == nil {
  25052. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  25053. }
  25054. oldValue, err := m.oldValue(ctx)
  25055. if err != nil {
  25056. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  25057. }
  25058. return oldValue.DeletedAt, nil
  25059. }
  25060. // ClearDeletedAt clears the value of the "deleted_at" field.
  25061. func (m *SopTaskMutation) ClearDeletedAt() {
  25062. m.deleted_at = nil
  25063. m.clearedFields[soptask.FieldDeletedAt] = struct{}{}
  25064. }
  25065. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  25066. func (m *SopTaskMutation) DeletedAtCleared() bool {
  25067. _, ok := m.clearedFields[soptask.FieldDeletedAt]
  25068. return ok
  25069. }
  25070. // ResetDeletedAt resets all changes to the "deleted_at" field.
  25071. func (m *SopTaskMutation) ResetDeletedAt() {
  25072. m.deleted_at = nil
  25073. delete(m.clearedFields, soptask.FieldDeletedAt)
  25074. }
  25075. // SetName sets the "name" field.
  25076. func (m *SopTaskMutation) SetName(s string) {
  25077. m.name = &s
  25078. }
  25079. // Name returns the value of the "name" field in the mutation.
  25080. func (m *SopTaskMutation) Name() (r string, exists bool) {
  25081. v := m.name
  25082. if v == nil {
  25083. return
  25084. }
  25085. return *v, true
  25086. }
  25087. // OldName returns the old "name" field's value of the SopTask entity.
  25088. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  25089. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25090. func (m *SopTaskMutation) OldName(ctx context.Context) (v string, err error) {
  25091. if !m.op.Is(OpUpdateOne) {
  25092. return v, errors.New("OldName is only allowed on UpdateOne operations")
  25093. }
  25094. if m.id == nil || m.oldValue == nil {
  25095. return v, errors.New("OldName requires an ID field in the mutation")
  25096. }
  25097. oldValue, err := m.oldValue(ctx)
  25098. if err != nil {
  25099. return v, fmt.Errorf("querying old value for OldName: %w", err)
  25100. }
  25101. return oldValue.Name, nil
  25102. }
  25103. // ResetName resets all changes to the "name" field.
  25104. func (m *SopTaskMutation) ResetName() {
  25105. m.name = nil
  25106. }
  25107. // SetBotWxidList sets the "bot_wxid_list" field.
  25108. func (m *SopTaskMutation) SetBotWxidList(s []string) {
  25109. m.bot_wxid_list = &s
  25110. m.appendbot_wxid_list = nil
  25111. }
  25112. // BotWxidList returns the value of the "bot_wxid_list" field in the mutation.
  25113. func (m *SopTaskMutation) BotWxidList() (r []string, exists bool) {
  25114. v := m.bot_wxid_list
  25115. if v == nil {
  25116. return
  25117. }
  25118. return *v, true
  25119. }
  25120. // OldBotWxidList returns the old "bot_wxid_list" field's value of the SopTask entity.
  25121. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  25122. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25123. func (m *SopTaskMutation) OldBotWxidList(ctx context.Context) (v []string, err error) {
  25124. if !m.op.Is(OpUpdateOne) {
  25125. return v, errors.New("OldBotWxidList is only allowed on UpdateOne operations")
  25126. }
  25127. if m.id == nil || m.oldValue == nil {
  25128. return v, errors.New("OldBotWxidList requires an ID field in the mutation")
  25129. }
  25130. oldValue, err := m.oldValue(ctx)
  25131. if err != nil {
  25132. return v, fmt.Errorf("querying old value for OldBotWxidList: %w", err)
  25133. }
  25134. return oldValue.BotWxidList, nil
  25135. }
  25136. // AppendBotWxidList adds s to the "bot_wxid_list" field.
  25137. func (m *SopTaskMutation) AppendBotWxidList(s []string) {
  25138. m.appendbot_wxid_list = append(m.appendbot_wxid_list, s...)
  25139. }
  25140. // AppendedBotWxidList returns the list of values that were appended to the "bot_wxid_list" field in this mutation.
  25141. func (m *SopTaskMutation) AppendedBotWxidList() ([]string, bool) {
  25142. if len(m.appendbot_wxid_list) == 0 {
  25143. return nil, false
  25144. }
  25145. return m.appendbot_wxid_list, true
  25146. }
  25147. // ClearBotWxidList clears the value of the "bot_wxid_list" field.
  25148. func (m *SopTaskMutation) ClearBotWxidList() {
  25149. m.bot_wxid_list = nil
  25150. m.appendbot_wxid_list = nil
  25151. m.clearedFields[soptask.FieldBotWxidList] = struct{}{}
  25152. }
  25153. // BotWxidListCleared returns if the "bot_wxid_list" field was cleared in this mutation.
  25154. func (m *SopTaskMutation) BotWxidListCleared() bool {
  25155. _, ok := m.clearedFields[soptask.FieldBotWxidList]
  25156. return ok
  25157. }
  25158. // ResetBotWxidList resets all changes to the "bot_wxid_list" field.
  25159. func (m *SopTaskMutation) ResetBotWxidList() {
  25160. m.bot_wxid_list = nil
  25161. m.appendbot_wxid_list = nil
  25162. delete(m.clearedFields, soptask.FieldBotWxidList)
  25163. }
  25164. // SetType sets the "type" field.
  25165. func (m *SopTaskMutation) SetType(i int) {
  25166. m._type = &i
  25167. m.add_type = nil
  25168. }
  25169. // GetType returns the value of the "type" field in the mutation.
  25170. func (m *SopTaskMutation) GetType() (r int, exists bool) {
  25171. v := m._type
  25172. if v == nil {
  25173. return
  25174. }
  25175. return *v, true
  25176. }
  25177. // OldType returns the old "type" field's value of the SopTask entity.
  25178. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  25179. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25180. func (m *SopTaskMutation) OldType(ctx context.Context) (v int, err error) {
  25181. if !m.op.Is(OpUpdateOne) {
  25182. return v, errors.New("OldType is only allowed on UpdateOne operations")
  25183. }
  25184. if m.id == nil || m.oldValue == nil {
  25185. return v, errors.New("OldType requires an ID field in the mutation")
  25186. }
  25187. oldValue, err := m.oldValue(ctx)
  25188. if err != nil {
  25189. return v, fmt.Errorf("querying old value for OldType: %w", err)
  25190. }
  25191. return oldValue.Type, nil
  25192. }
  25193. // AddType adds i to the "type" field.
  25194. func (m *SopTaskMutation) AddType(i int) {
  25195. if m.add_type != nil {
  25196. *m.add_type += i
  25197. } else {
  25198. m.add_type = &i
  25199. }
  25200. }
  25201. // AddedType returns the value that was added to the "type" field in this mutation.
  25202. func (m *SopTaskMutation) AddedType() (r int, exists bool) {
  25203. v := m.add_type
  25204. if v == nil {
  25205. return
  25206. }
  25207. return *v, true
  25208. }
  25209. // ResetType resets all changes to the "type" field.
  25210. func (m *SopTaskMutation) ResetType() {
  25211. m._type = nil
  25212. m.add_type = nil
  25213. }
  25214. // SetPlanStartTime sets the "plan_start_time" field.
  25215. func (m *SopTaskMutation) SetPlanStartTime(t time.Time) {
  25216. m.plan_start_time = &t
  25217. }
  25218. // PlanStartTime returns the value of the "plan_start_time" field in the mutation.
  25219. func (m *SopTaskMutation) PlanStartTime() (r time.Time, exists bool) {
  25220. v := m.plan_start_time
  25221. if v == nil {
  25222. return
  25223. }
  25224. return *v, true
  25225. }
  25226. // OldPlanStartTime returns the old "plan_start_time" field's value of the SopTask entity.
  25227. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  25228. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25229. func (m *SopTaskMutation) OldPlanStartTime(ctx context.Context) (v time.Time, err error) {
  25230. if !m.op.Is(OpUpdateOne) {
  25231. return v, errors.New("OldPlanStartTime is only allowed on UpdateOne operations")
  25232. }
  25233. if m.id == nil || m.oldValue == nil {
  25234. return v, errors.New("OldPlanStartTime requires an ID field in the mutation")
  25235. }
  25236. oldValue, err := m.oldValue(ctx)
  25237. if err != nil {
  25238. return v, fmt.Errorf("querying old value for OldPlanStartTime: %w", err)
  25239. }
  25240. return oldValue.PlanStartTime, nil
  25241. }
  25242. // ClearPlanStartTime clears the value of the "plan_start_time" field.
  25243. func (m *SopTaskMutation) ClearPlanStartTime() {
  25244. m.plan_start_time = nil
  25245. m.clearedFields[soptask.FieldPlanStartTime] = struct{}{}
  25246. }
  25247. // PlanStartTimeCleared returns if the "plan_start_time" field was cleared in this mutation.
  25248. func (m *SopTaskMutation) PlanStartTimeCleared() bool {
  25249. _, ok := m.clearedFields[soptask.FieldPlanStartTime]
  25250. return ok
  25251. }
  25252. // ResetPlanStartTime resets all changes to the "plan_start_time" field.
  25253. func (m *SopTaskMutation) ResetPlanStartTime() {
  25254. m.plan_start_time = nil
  25255. delete(m.clearedFields, soptask.FieldPlanStartTime)
  25256. }
  25257. // SetPlanEndTime sets the "plan_end_time" field.
  25258. func (m *SopTaskMutation) SetPlanEndTime(t time.Time) {
  25259. m.plan_end_time = &t
  25260. }
  25261. // PlanEndTime returns the value of the "plan_end_time" field in the mutation.
  25262. func (m *SopTaskMutation) PlanEndTime() (r time.Time, exists bool) {
  25263. v := m.plan_end_time
  25264. if v == nil {
  25265. return
  25266. }
  25267. return *v, true
  25268. }
  25269. // OldPlanEndTime returns the old "plan_end_time" field's value of the SopTask entity.
  25270. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  25271. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25272. func (m *SopTaskMutation) OldPlanEndTime(ctx context.Context) (v time.Time, err error) {
  25273. if !m.op.Is(OpUpdateOne) {
  25274. return v, errors.New("OldPlanEndTime is only allowed on UpdateOne operations")
  25275. }
  25276. if m.id == nil || m.oldValue == nil {
  25277. return v, errors.New("OldPlanEndTime requires an ID field in the mutation")
  25278. }
  25279. oldValue, err := m.oldValue(ctx)
  25280. if err != nil {
  25281. return v, fmt.Errorf("querying old value for OldPlanEndTime: %w", err)
  25282. }
  25283. return oldValue.PlanEndTime, nil
  25284. }
  25285. // ClearPlanEndTime clears the value of the "plan_end_time" field.
  25286. func (m *SopTaskMutation) ClearPlanEndTime() {
  25287. m.plan_end_time = nil
  25288. m.clearedFields[soptask.FieldPlanEndTime] = struct{}{}
  25289. }
  25290. // PlanEndTimeCleared returns if the "plan_end_time" field was cleared in this mutation.
  25291. func (m *SopTaskMutation) PlanEndTimeCleared() bool {
  25292. _, ok := m.clearedFields[soptask.FieldPlanEndTime]
  25293. return ok
  25294. }
  25295. // ResetPlanEndTime resets all changes to the "plan_end_time" field.
  25296. func (m *SopTaskMutation) ResetPlanEndTime() {
  25297. m.plan_end_time = nil
  25298. delete(m.clearedFields, soptask.FieldPlanEndTime)
  25299. }
  25300. // SetCreatorID sets the "creator_id" field.
  25301. func (m *SopTaskMutation) SetCreatorID(s string) {
  25302. m.creator_id = &s
  25303. }
  25304. // CreatorID returns the value of the "creator_id" field in the mutation.
  25305. func (m *SopTaskMutation) CreatorID() (r string, exists bool) {
  25306. v := m.creator_id
  25307. if v == nil {
  25308. return
  25309. }
  25310. return *v, true
  25311. }
  25312. // OldCreatorID returns the old "creator_id" field's value of the SopTask entity.
  25313. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  25314. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25315. func (m *SopTaskMutation) OldCreatorID(ctx context.Context) (v string, err error) {
  25316. if !m.op.Is(OpUpdateOne) {
  25317. return v, errors.New("OldCreatorID is only allowed on UpdateOne operations")
  25318. }
  25319. if m.id == nil || m.oldValue == nil {
  25320. return v, errors.New("OldCreatorID requires an ID field in the mutation")
  25321. }
  25322. oldValue, err := m.oldValue(ctx)
  25323. if err != nil {
  25324. return v, fmt.Errorf("querying old value for OldCreatorID: %w", err)
  25325. }
  25326. return oldValue.CreatorID, nil
  25327. }
  25328. // ClearCreatorID clears the value of the "creator_id" field.
  25329. func (m *SopTaskMutation) ClearCreatorID() {
  25330. m.creator_id = nil
  25331. m.clearedFields[soptask.FieldCreatorID] = struct{}{}
  25332. }
  25333. // CreatorIDCleared returns if the "creator_id" field was cleared in this mutation.
  25334. func (m *SopTaskMutation) CreatorIDCleared() bool {
  25335. _, ok := m.clearedFields[soptask.FieldCreatorID]
  25336. return ok
  25337. }
  25338. // ResetCreatorID resets all changes to the "creator_id" field.
  25339. func (m *SopTaskMutation) ResetCreatorID() {
  25340. m.creator_id = nil
  25341. delete(m.clearedFields, soptask.FieldCreatorID)
  25342. }
  25343. // SetOrganizationID sets the "organization_id" field.
  25344. func (m *SopTaskMutation) SetOrganizationID(u uint64) {
  25345. m.organization_id = &u
  25346. m.addorganization_id = nil
  25347. }
  25348. // OrganizationID returns the value of the "organization_id" field in the mutation.
  25349. func (m *SopTaskMutation) OrganizationID() (r uint64, exists bool) {
  25350. v := m.organization_id
  25351. if v == nil {
  25352. return
  25353. }
  25354. return *v, true
  25355. }
  25356. // OldOrganizationID returns the old "organization_id" field's value of the SopTask entity.
  25357. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  25358. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25359. func (m *SopTaskMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  25360. if !m.op.Is(OpUpdateOne) {
  25361. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  25362. }
  25363. if m.id == nil || m.oldValue == nil {
  25364. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  25365. }
  25366. oldValue, err := m.oldValue(ctx)
  25367. if err != nil {
  25368. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  25369. }
  25370. return oldValue.OrganizationID, nil
  25371. }
  25372. // AddOrganizationID adds u to the "organization_id" field.
  25373. func (m *SopTaskMutation) AddOrganizationID(u int64) {
  25374. if m.addorganization_id != nil {
  25375. *m.addorganization_id += u
  25376. } else {
  25377. m.addorganization_id = &u
  25378. }
  25379. }
  25380. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  25381. func (m *SopTaskMutation) AddedOrganizationID() (r int64, exists bool) {
  25382. v := m.addorganization_id
  25383. if v == nil {
  25384. return
  25385. }
  25386. return *v, true
  25387. }
  25388. // ClearOrganizationID clears the value of the "organization_id" field.
  25389. func (m *SopTaskMutation) ClearOrganizationID() {
  25390. m.organization_id = nil
  25391. m.addorganization_id = nil
  25392. m.clearedFields[soptask.FieldOrganizationID] = struct{}{}
  25393. }
  25394. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  25395. func (m *SopTaskMutation) OrganizationIDCleared() bool {
  25396. _, ok := m.clearedFields[soptask.FieldOrganizationID]
  25397. return ok
  25398. }
  25399. // ResetOrganizationID resets all changes to the "organization_id" field.
  25400. func (m *SopTaskMutation) ResetOrganizationID() {
  25401. m.organization_id = nil
  25402. m.addorganization_id = nil
  25403. delete(m.clearedFields, soptask.FieldOrganizationID)
  25404. }
  25405. // SetToken sets the "token" field.
  25406. func (m *SopTaskMutation) SetToken(s []string) {
  25407. m.token = &s
  25408. m.appendtoken = nil
  25409. }
  25410. // Token returns the value of the "token" field in the mutation.
  25411. func (m *SopTaskMutation) Token() (r []string, exists bool) {
  25412. v := m.token
  25413. if v == nil {
  25414. return
  25415. }
  25416. return *v, true
  25417. }
  25418. // OldToken returns the old "token" field's value of the SopTask entity.
  25419. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  25420. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25421. func (m *SopTaskMutation) OldToken(ctx context.Context) (v []string, err error) {
  25422. if !m.op.Is(OpUpdateOne) {
  25423. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  25424. }
  25425. if m.id == nil || m.oldValue == nil {
  25426. return v, errors.New("OldToken requires an ID field in the mutation")
  25427. }
  25428. oldValue, err := m.oldValue(ctx)
  25429. if err != nil {
  25430. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  25431. }
  25432. return oldValue.Token, nil
  25433. }
  25434. // AppendToken adds s to the "token" field.
  25435. func (m *SopTaskMutation) AppendToken(s []string) {
  25436. m.appendtoken = append(m.appendtoken, s...)
  25437. }
  25438. // AppendedToken returns the list of values that were appended to the "token" field in this mutation.
  25439. func (m *SopTaskMutation) AppendedToken() ([]string, bool) {
  25440. if len(m.appendtoken) == 0 {
  25441. return nil, false
  25442. }
  25443. return m.appendtoken, true
  25444. }
  25445. // ClearToken clears the value of the "token" field.
  25446. func (m *SopTaskMutation) ClearToken() {
  25447. m.token = nil
  25448. m.appendtoken = nil
  25449. m.clearedFields[soptask.FieldToken] = struct{}{}
  25450. }
  25451. // TokenCleared returns if the "token" field was cleared in this mutation.
  25452. func (m *SopTaskMutation) TokenCleared() bool {
  25453. _, ok := m.clearedFields[soptask.FieldToken]
  25454. return ok
  25455. }
  25456. // ResetToken resets all changes to the "token" field.
  25457. func (m *SopTaskMutation) ResetToken() {
  25458. m.token = nil
  25459. m.appendtoken = nil
  25460. delete(m.clearedFields, soptask.FieldToken)
  25461. }
  25462. // AddTaskStageIDs adds the "task_stages" edge to the SopStage entity by ids.
  25463. func (m *SopTaskMutation) AddTaskStageIDs(ids ...uint64) {
  25464. if m.task_stages == nil {
  25465. m.task_stages = make(map[uint64]struct{})
  25466. }
  25467. for i := range ids {
  25468. m.task_stages[ids[i]] = struct{}{}
  25469. }
  25470. }
  25471. // ClearTaskStages clears the "task_stages" edge to the SopStage entity.
  25472. func (m *SopTaskMutation) ClearTaskStages() {
  25473. m.clearedtask_stages = true
  25474. }
  25475. // TaskStagesCleared reports if the "task_stages" edge to the SopStage entity was cleared.
  25476. func (m *SopTaskMutation) TaskStagesCleared() bool {
  25477. return m.clearedtask_stages
  25478. }
  25479. // RemoveTaskStageIDs removes the "task_stages" edge to the SopStage entity by IDs.
  25480. func (m *SopTaskMutation) RemoveTaskStageIDs(ids ...uint64) {
  25481. if m.removedtask_stages == nil {
  25482. m.removedtask_stages = make(map[uint64]struct{})
  25483. }
  25484. for i := range ids {
  25485. delete(m.task_stages, ids[i])
  25486. m.removedtask_stages[ids[i]] = struct{}{}
  25487. }
  25488. }
  25489. // RemovedTaskStages returns the removed IDs of the "task_stages" edge to the SopStage entity.
  25490. func (m *SopTaskMutation) RemovedTaskStagesIDs() (ids []uint64) {
  25491. for id := range m.removedtask_stages {
  25492. ids = append(ids, id)
  25493. }
  25494. return
  25495. }
  25496. // TaskStagesIDs returns the "task_stages" edge IDs in the mutation.
  25497. func (m *SopTaskMutation) TaskStagesIDs() (ids []uint64) {
  25498. for id := range m.task_stages {
  25499. ids = append(ids, id)
  25500. }
  25501. return
  25502. }
  25503. // ResetTaskStages resets all changes to the "task_stages" edge.
  25504. func (m *SopTaskMutation) ResetTaskStages() {
  25505. m.task_stages = nil
  25506. m.clearedtask_stages = false
  25507. m.removedtask_stages = nil
  25508. }
  25509. // Where appends a list predicates to the SopTaskMutation builder.
  25510. func (m *SopTaskMutation) Where(ps ...predicate.SopTask) {
  25511. m.predicates = append(m.predicates, ps...)
  25512. }
  25513. // WhereP appends storage-level predicates to the SopTaskMutation builder. Using this method,
  25514. // users can use type-assertion to append predicates that do not depend on any generated package.
  25515. func (m *SopTaskMutation) WhereP(ps ...func(*sql.Selector)) {
  25516. p := make([]predicate.SopTask, len(ps))
  25517. for i := range ps {
  25518. p[i] = ps[i]
  25519. }
  25520. m.Where(p...)
  25521. }
  25522. // Op returns the operation name.
  25523. func (m *SopTaskMutation) Op() Op {
  25524. return m.op
  25525. }
  25526. // SetOp allows setting the mutation operation.
  25527. func (m *SopTaskMutation) SetOp(op Op) {
  25528. m.op = op
  25529. }
  25530. // Type returns the node type of this mutation (SopTask).
  25531. func (m *SopTaskMutation) Type() string {
  25532. return m.typ
  25533. }
  25534. // Fields returns all fields that were changed during this mutation. Note that in
  25535. // order to get all numeric fields that were incremented/decremented, call
  25536. // AddedFields().
  25537. func (m *SopTaskMutation) Fields() []string {
  25538. fields := make([]string, 0, 12)
  25539. if m.created_at != nil {
  25540. fields = append(fields, soptask.FieldCreatedAt)
  25541. }
  25542. if m.updated_at != nil {
  25543. fields = append(fields, soptask.FieldUpdatedAt)
  25544. }
  25545. if m.status != nil {
  25546. fields = append(fields, soptask.FieldStatus)
  25547. }
  25548. if m.deleted_at != nil {
  25549. fields = append(fields, soptask.FieldDeletedAt)
  25550. }
  25551. if m.name != nil {
  25552. fields = append(fields, soptask.FieldName)
  25553. }
  25554. if m.bot_wxid_list != nil {
  25555. fields = append(fields, soptask.FieldBotWxidList)
  25556. }
  25557. if m._type != nil {
  25558. fields = append(fields, soptask.FieldType)
  25559. }
  25560. if m.plan_start_time != nil {
  25561. fields = append(fields, soptask.FieldPlanStartTime)
  25562. }
  25563. if m.plan_end_time != nil {
  25564. fields = append(fields, soptask.FieldPlanEndTime)
  25565. }
  25566. if m.creator_id != nil {
  25567. fields = append(fields, soptask.FieldCreatorID)
  25568. }
  25569. if m.organization_id != nil {
  25570. fields = append(fields, soptask.FieldOrganizationID)
  25571. }
  25572. if m.token != nil {
  25573. fields = append(fields, soptask.FieldToken)
  25574. }
  25575. return fields
  25576. }
  25577. // Field returns the value of a field with the given name. The second boolean
  25578. // return value indicates that this field was not set, or was not defined in the
  25579. // schema.
  25580. func (m *SopTaskMutation) Field(name string) (ent.Value, bool) {
  25581. switch name {
  25582. case soptask.FieldCreatedAt:
  25583. return m.CreatedAt()
  25584. case soptask.FieldUpdatedAt:
  25585. return m.UpdatedAt()
  25586. case soptask.FieldStatus:
  25587. return m.Status()
  25588. case soptask.FieldDeletedAt:
  25589. return m.DeletedAt()
  25590. case soptask.FieldName:
  25591. return m.Name()
  25592. case soptask.FieldBotWxidList:
  25593. return m.BotWxidList()
  25594. case soptask.FieldType:
  25595. return m.GetType()
  25596. case soptask.FieldPlanStartTime:
  25597. return m.PlanStartTime()
  25598. case soptask.FieldPlanEndTime:
  25599. return m.PlanEndTime()
  25600. case soptask.FieldCreatorID:
  25601. return m.CreatorID()
  25602. case soptask.FieldOrganizationID:
  25603. return m.OrganizationID()
  25604. case soptask.FieldToken:
  25605. return m.Token()
  25606. }
  25607. return nil, false
  25608. }
  25609. // OldField returns the old value of the field from the database. An error is
  25610. // returned if the mutation operation is not UpdateOne, or the query to the
  25611. // database failed.
  25612. func (m *SopTaskMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  25613. switch name {
  25614. case soptask.FieldCreatedAt:
  25615. return m.OldCreatedAt(ctx)
  25616. case soptask.FieldUpdatedAt:
  25617. return m.OldUpdatedAt(ctx)
  25618. case soptask.FieldStatus:
  25619. return m.OldStatus(ctx)
  25620. case soptask.FieldDeletedAt:
  25621. return m.OldDeletedAt(ctx)
  25622. case soptask.FieldName:
  25623. return m.OldName(ctx)
  25624. case soptask.FieldBotWxidList:
  25625. return m.OldBotWxidList(ctx)
  25626. case soptask.FieldType:
  25627. return m.OldType(ctx)
  25628. case soptask.FieldPlanStartTime:
  25629. return m.OldPlanStartTime(ctx)
  25630. case soptask.FieldPlanEndTime:
  25631. return m.OldPlanEndTime(ctx)
  25632. case soptask.FieldCreatorID:
  25633. return m.OldCreatorID(ctx)
  25634. case soptask.FieldOrganizationID:
  25635. return m.OldOrganizationID(ctx)
  25636. case soptask.FieldToken:
  25637. return m.OldToken(ctx)
  25638. }
  25639. return nil, fmt.Errorf("unknown SopTask field %s", name)
  25640. }
  25641. // SetField sets the value of a field with the given name. It returns an error if
  25642. // the field is not defined in the schema, or if the type mismatched the field
  25643. // type.
  25644. func (m *SopTaskMutation) SetField(name string, value ent.Value) error {
  25645. switch name {
  25646. case soptask.FieldCreatedAt:
  25647. v, ok := value.(time.Time)
  25648. if !ok {
  25649. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25650. }
  25651. m.SetCreatedAt(v)
  25652. return nil
  25653. case soptask.FieldUpdatedAt:
  25654. v, ok := value.(time.Time)
  25655. if !ok {
  25656. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25657. }
  25658. m.SetUpdatedAt(v)
  25659. return nil
  25660. case soptask.FieldStatus:
  25661. v, ok := value.(uint8)
  25662. if !ok {
  25663. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25664. }
  25665. m.SetStatus(v)
  25666. return nil
  25667. case soptask.FieldDeletedAt:
  25668. v, ok := value.(time.Time)
  25669. if !ok {
  25670. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25671. }
  25672. m.SetDeletedAt(v)
  25673. return nil
  25674. case soptask.FieldName:
  25675. v, ok := value.(string)
  25676. if !ok {
  25677. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25678. }
  25679. m.SetName(v)
  25680. return nil
  25681. case soptask.FieldBotWxidList:
  25682. v, ok := value.([]string)
  25683. if !ok {
  25684. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25685. }
  25686. m.SetBotWxidList(v)
  25687. return nil
  25688. case soptask.FieldType:
  25689. v, ok := value.(int)
  25690. if !ok {
  25691. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25692. }
  25693. m.SetType(v)
  25694. return nil
  25695. case soptask.FieldPlanStartTime:
  25696. v, ok := value.(time.Time)
  25697. if !ok {
  25698. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25699. }
  25700. m.SetPlanStartTime(v)
  25701. return nil
  25702. case soptask.FieldPlanEndTime:
  25703. v, ok := value.(time.Time)
  25704. if !ok {
  25705. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25706. }
  25707. m.SetPlanEndTime(v)
  25708. return nil
  25709. case soptask.FieldCreatorID:
  25710. v, ok := value.(string)
  25711. if !ok {
  25712. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25713. }
  25714. m.SetCreatorID(v)
  25715. return nil
  25716. case soptask.FieldOrganizationID:
  25717. v, ok := value.(uint64)
  25718. if !ok {
  25719. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25720. }
  25721. m.SetOrganizationID(v)
  25722. return nil
  25723. case soptask.FieldToken:
  25724. v, ok := value.([]string)
  25725. if !ok {
  25726. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25727. }
  25728. m.SetToken(v)
  25729. return nil
  25730. }
  25731. return fmt.Errorf("unknown SopTask field %s", name)
  25732. }
  25733. // AddedFields returns all numeric fields that were incremented/decremented during
  25734. // this mutation.
  25735. func (m *SopTaskMutation) AddedFields() []string {
  25736. var fields []string
  25737. if m.addstatus != nil {
  25738. fields = append(fields, soptask.FieldStatus)
  25739. }
  25740. if m.add_type != nil {
  25741. fields = append(fields, soptask.FieldType)
  25742. }
  25743. if m.addorganization_id != nil {
  25744. fields = append(fields, soptask.FieldOrganizationID)
  25745. }
  25746. return fields
  25747. }
  25748. // AddedField returns the numeric value that was incremented/decremented on a field
  25749. // with the given name. The second boolean return value indicates that this field
  25750. // was not set, or was not defined in the schema.
  25751. func (m *SopTaskMutation) AddedField(name string) (ent.Value, bool) {
  25752. switch name {
  25753. case soptask.FieldStatus:
  25754. return m.AddedStatus()
  25755. case soptask.FieldType:
  25756. return m.AddedType()
  25757. case soptask.FieldOrganizationID:
  25758. return m.AddedOrganizationID()
  25759. }
  25760. return nil, false
  25761. }
  25762. // AddField adds the value to the field with the given name. It returns an error if
  25763. // the field is not defined in the schema, or if the type mismatched the field
  25764. // type.
  25765. func (m *SopTaskMutation) AddField(name string, value ent.Value) error {
  25766. switch name {
  25767. case soptask.FieldStatus:
  25768. v, ok := value.(int8)
  25769. if !ok {
  25770. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25771. }
  25772. m.AddStatus(v)
  25773. return nil
  25774. case soptask.FieldType:
  25775. v, ok := value.(int)
  25776. if !ok {
  25777. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25778. }
  25779. m.AddType(v)
  25780. return nil
  25781. case soptask.FieldOrganizationID:
  25782. v, ok := value.(int64)
  25783. if !ok {
  25784. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25785. }
  25786. m.AddOrganizationID(v)
  25787. return nil
  25788. }
  25789. return fmt.Errorf("unknown SopTask numeric field %s", name)
  25790. }
  25791. // ClearedFields returns all nullable fields that were cleared during this
  25792. // mutation.
  25793. func (m *SopTaskMutation) ClearedFields() []string {
  25794. var fields []string
  25795. if m.FieldCleared(soptask.FieldStatus) {
  25796. fields = append(fields, soptask.FieldStatus)
  25797. }
  25798. if m.FieldCleared(soptask.FieldDeletedAt) {
  25799. fields = append(fields, soptask.FieldDeletedAt)
  25800. }
  25801. if m.FieldCleared(soptask.FieldBotWxidList) {
  25802. fields = append(fields, soptask.FieldBotWxidList)
  25803. }
  25804. if m.FieldCleared(soptask.FieldPlanStartTime) {
  25805. fields = append(fields, soptask.FieldPlanStartTime)
  25806. }
  25807. if m.FieldCleared(soptask.FieldPlanEndTime) {
  25808. fields = append(fields, soptask.FieldPlanEndTime)
  25809. }
  25810. if m.FieldCleared(soptask.FieldCreatorID) {
  25811. fields = append(fields, soptask.FieldCreatorID)
  25812. }
  25813. if m.FieldCleared(soptask.FieldOrganizationID) {
  25814. fields = append(fields, soptask.FieldOrganizationID)
  25815. }
  25816. if m.FieldCleared(soptask.FieldToken) {
  25817. fields = append(fields, soptask.FieldToken)
  25818. }
  25819. return fields
  25820. }
  25821. // FieldCleared returns a boolean indicating if a field with the given name was
  25822. // cleared in this mutation.
  25823. func (m *SopTaskMutation) FieldCleared(name string) bool {
  25824. _, ok := m.clearedFields[name]
  25825. return ok
  25826. }
  25827. // ClearField clears the value of the field with the given name. It returns an
  25828. // error if the field is not defined in the schema.
  25829. func (m *SopTaskMutation) ClearField(name string) error {
  25830. switch name {
  25831. case soptask.FieldStatus:
  25832. m.ClearStatus()
  25833. return nil
  25834. case soptask.FieldDeletedAt:
  25835. m.ClearDeletedAt()
  25836. return nil
  25837. case soptask.FieldBotWxidList:
  25838. m.ClearBotWxidList()
  25839. return nil
  25840. case soptask.FieldPlanStartTime:
  25841. m.ClearPlanStartTime()
  25842. return nil
  25843. case soptask.FieldPlanEndTime:
  25844. m.ClearPlanEndTime()
  25845. return nil
  25846. case soptask.FieldCreatorID:
  25847. m.ClearCreatorID()
  25848. return nil
  25849. case soptask.FieldOrganizationID:
  25850. m.ClearOrganizationID()
  25851. return nil
  25852. case soptask.FieldToken:
  25853. m.ClearToken()
  25854. return nil
  25855. }
  25856. return fmt.Errorf("unknown SopTask nullable field %s", name)
  25857. }
  25858. // ResetField resets all changes in the mutation for the field with the given name.
  25859. // It returns an error if the field is not defined in the schema.
  25860. func (m *SopTaskMutation) ResetField(name string) error {
  25861. switch name {
  25862. case soptask.FieldCreatedAt:
  25863. m.ResetCreatedAt()
  25864. return nil
  25865. case soptask.FieldUpdatedAt:
  25866. m.ResetUpdatedAt()
  25867. return nil
  25868. case soptask.FieldStatus:
  25869. m.ResetStatus()
  25870. return nil
  25871. case soptask.FieldDeletedAt:
  25872. m.ResetDeletedAt()
  25873. return nil
  25874. case soptask.FieldName:
  25875. m.ResetName()
  25876. return nil
  25877. case soptask.FieldBotWxidList:
  25878. m.ResetBotWxidList()
  25879. return nil
  25880. case soptask.FieldType:
  25881. m.ResetType()
  25882. return nil
  25883. case soptask.FieldPlanStartTime:
  25884. m.ResetPlanStartTime()
  25885. return nil
  25886. case soptask.FieldPlanEndTime:
  25887. m.ResetPlanEndTime()
  25888. return nil
  25889. case soptask.FieldCreatorID:
  25890. m.ResetCreatorID()
  25891. return nil
  25892. case soptask.FieldOrganizationID:
  25893. m.ResetOrganizationID()
  25894. return nil
  25895. case soptask.FieldToken:
  25896. m.ResetToken()
  25897. return nil
  25898. }
  25899. return fmt.Errorf("unknown SopTask field %s", name)
  25900. }
  25901. // AddedEdges returns all edge names that were set/added in this mutation.
  25902. func (m *SopTaskMutation) AddedEdges() []string {
  25903. edges := make([]string, 0, 1)
  25904. if m.task_stages != nil {
  25905. edges = append(edges, soptask.EdgeTaskStages)
  25906. }
  25907. return edges
  25908. }
  25909. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  25910. // name in this mutation.
  25911. func (m *SopTaskMutation) AddedIDs(name string) []ent.Value {
  25912. switch name {
  25913. case soptask.EdgeTaskStages:
  25914. ids := make([]ent.Value, 0, len(m.task_stages))
  25915. for id := range m.task_stages {
  25916. ids = append(ids, id)
  25917. }
  25918. return ids
  25919. }
  25920. return nil
  25921. }
  25922. // RemovedEdges returns all edge names that were removed in this mutation.
  25923. func (m *SopTaskMutation) RemovedEdges() []string {
  25924. edges := make([]string, 0, 1)
  25925. if m.removedtask_stages != nil {
  25926. edges = append(edges, soptask.EdgeTaskStages)
  25927. }
  25928. return edges
  25929. }
  25930. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  25931. // the given name in this mutation.
  25932. func (m *SopTaskMutation) RemovedIDs(name string) []ent.Value {
  25933. switch name {
  25934. case soptask.EdgeTaskStages:
  25935. ids := make([]ent.Value, 0, len(m.removedtask_stages))
  25936. for id := range m.removedtask_stages {
  25937. ids = append(ids, id)
  25938. }
  25939. return ids
  25940. }
  25941. return nil
  25942. }
  25943. // ClearedEdges returns all edge names that were cleared in this mutation.
  25944. func (m *SopTaskMutation) ClearedEdges() []string {
  25945. edges := make([]string, 0, 1)
  25946. if m.clearedtask_stages {
  25947. edges = append(edges, soptask.EdgeTaskStages)
  25948. }
  25949. return edges
  25950. }
  25951. // EdgeCleared returns a boolean which indicates if the edge with the given name
  25952. // was cleared in this mutation.
  25953. func (m *SopTaskMutation) EdgeCleared(name string) bool {
  25954. switch name {
  25955. case soptask.EdgeTaskStages:
  25956. return m.clearedtask_stages
  25957. }
  25958. return false
  25959. }
  25960. // ClearEdge clears the value of the edge with the given name. It returns an error
  25961. // if that edge is not defined in the schema.
  25962. func (m *SopTaskMutation) ClearEdge(name string) error {
  25963. switch name {
  25964. }
  25965. return fmt.Errorf("unknown SopTask unique edge %s", name)
  25966. }
  25967. // ResetEdge resets all changes to the edge with the given name in this mutation.
  25968. // It returns an error if the edge is not defined in the schema.
  25969. func (m *SopTaskMutation) ResetEdge(name string) error {
  25970. switch name {
  25971. case soptask.EdgeTaskStages:
  25972. m.ResetTaskStages()
  25973. return nil
  25974. }
  25975. return fmt.Errorf("unknown SopTask edge %s", name)
  25976. }
  25977. // TokenMutation represents an operation that mutates the Token nodes in the graph.
  25978. type TokenMutation struct {
  25979. config
  25980. op Op
  25981. typ string
  25982. id *uint64
  25983. created_at *time.Time
  25984. updated_at *time.Time
  25985. deleted_at *time.Time
  25986. expire_at *time.Time
  25987. token *string
  25988. mac *string
  25989. organization_id *uint64
  25990. addorganization_id *int64
  25991. custom_agent_base *string
  25992. custom_agent_key *string
  25993. openai_base *string
  25994. openai_key *string
  25995. clearedFields map[string]struct{}
  25996. agent *uint64
  25997. clearedagent bool
  25998. done bool
  25999. oldValue func(context.Context) (*Token, error)
  26000. predicates []predicate.Token
  26001. }
  26002. var _ ent.Mutation = (*TokenMutation)(nil)
  26003. // tokenOption allows management of the mutation configuration using functional options.
  26004. type tokenOption func(*TokenMutation)
  26005. // newTokenMutation creates new mutation for the Token entity.
  26006. func newTokenMutation(c config, op Op, opts ...tokenOption) *TokenMutation {
  26007. m := &TokenMutation{
  26008. config: c,
  26009. op: op,
  26010. typ: TypeToken,
  26011. clearedFields: make(map[string]struct{}),
  26012. }
  26013. for _, opt := range opts {
  26014. opt(m)
  26015. }
  26016. return m
  26017. }
  26018. // withTokenID sets the ID field of the mutation.
  26019. func withTokenID(id uint64) tokenOption {
  26020. return func(m *TokenMutation) {
  26021. var (
  26022. err error
  26023. once sync.Once
  26024. value *Token
  26025. )
  26026. m.oldValue = func(ctx context.Context) (*Token, error) {
  26027. once.Do(func() {
  26028. if m.done {
  26029. err = errors.New("querying old values post mutation is not allowed")
  26030. } else {
  26031. value, err = m.Client().Token.Get(ctx, id)
  26032. }
  26033. })
  26034. return value, err
  26035. }
  26036. m.id = &id
  26037. }
  26038. }
  26039. // withToken sets the old Token of the mutation.
  26040. func withToken(node *Token) tokenOption {
  26041. return func(m *TokenMutation) {
  26042. m.oldValue = func(context.Context) (*Token, error) {
  26043. return node, nil
  26044. }
  26045. m.id = &node.ID
  26046. }
  26047. }
  26048. // Client returns a new `ent.Client` from the mutation. If the mutation was
  26049. // executed in a transaction (ent.Tx), a transactional client is returned.
  26050. func (m TokenMutation) Client() *Client {
  26051. client := &Client{config: m.config}
  26052. client.init()
  26053. return client
  26054. }
  26055. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  26056. // it returns an error otherwise.
  26057. func (m TokenMutation) Tx() (*Tx, error) {
  26058. if _, ok := m.driver.(*txDriver); !ok {
  26059. return nil, errors.New("ent: mutation is not running in a transaction")
  26060. }
  26061. tx := &Tx{config: m.config}
  26062. tx.init()
  26063. return tx, nil
  26064. }
  26065. // SetID sets the value of the id field. Note that this
  26066. // operation is only accepted on creation of Token entities.
  26067. func (m *TokenMutation) SetID(id uint64) {
  26068. m.id = &id
  26069. }
  26070. // ID returns the ID value in the mutation. Note that the ID is only available
  26071. // if it was provided to the builder or after it was returned from the database.
  26072. func (m *TokenMutation) ID() (id uint64, exists bool) {
  26073. if m.id == nil {
  26074. return
  26075. }
  26076. return *m.id, true
  26077. }
  26078. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  26079. // That means, if the mutation is applied within a transaction with an isolation level such
  26080. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  26081. // or updated by the mutation.
  26082. func (m *TokenMutation) IDs(ctx context.Context) ([]uint64, error) {
  26083. switch {
  26084. case m.op.Is(OpUpdateOne | OpDeleteOne):
  26085. id, exists := m.ID()
  26086. if exists {
  26087. return []uint64{id}, nil
  26088. }
  26089. fallthrough
  26090. case m.op.Is(OpUpdate | OpDelete):
  26091. return m.Client().Token.Query().Where(m.predicates...).IDs(ctx)
  26092. default:
  26093. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  26094. }
  26095. }
  26096. // SetCreatedAt sets the "created_at" field.
  26097. func (m *TokenMutation) SetCreatedAt(t time.Time) {
  26098. m.created_at = &t
  26099. }
  26100. // CreatedAt returns the value of the "created_at" field in the mutation.
  26101. func (m *TokenMutation) CreatedAt() (r time.Time, exists bool) {
  26102. v := m.created_at
  26103. if v == nil {
  26104. return
  26105. }
  26106. return *v, true
  26107. }
  26108. // OldCreatedAt returns the old "created_at" field's value of the Token entity.
  26109. // If the Token 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 *TokenMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  26112. if !m.op.Is(OpUpdateOne) {
  26113. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  26114. }
  26115. if m.id == nil || m.oldValue == nil {
  26116. return v, errors.New("OldCreatedAt 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 OldCreatedAt: %w", err)
  26121. }
  26122. return oldValue.CreatedAt, nil
  26123. }
  26124. // ResetCreatedAt resets all changes to the "created_at" field.
  26125. func (m *TokenMutation) ResetCreatedAt() {
  26126. m.created_at = nil
  26127. }
  26128. // SetUpdatedAt sets the "updated_at" field.
  26129. func (m *TokenMutation) SetUpdatedAt(t time.Time) {
  26130. m.updated_at = &t
  26131. }
  26132. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  26133. func (m *TokenMutation) UpdatedAt() (r time.Time, exists bool) {
  26134. v := m.updated_at
  26135. if v == nil {
  26136. return
  26137. }
  26138. return *v, true
  26139. }
  26140. // OldUpdatedAt returns the old "updated_at" field's value of the Token entity.
  26141. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  26142. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26143. func (m *TokenMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  26144. if !m.op.Is(OpUpdateOne) {
  26145. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  26146. }
  26147. if m.id == nil || m.oldValue == nil {
  26148. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  26149. }
  26150. oldValue, err := m.oldValue(ctx)
  26151. if err != nil {
  26152. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  26153. }
  26154. return oldValue.UpdatedAt, nil
  26155. }
  26156. // ResetUpdatedAt resets all changes to the "updated_at" field.
  26157. func (m *TokenMutation) ResetUpdatedAt() {
  26158. m.updated_at = nil
  26159. }
  26160. // SetDeletedAt sets the "deleted_at" field.
  26161. func (m *TokenMutation) SetDeletedAt(t time.Time) {
  26162. m.deleted_at = &t
  26163. }
  26164. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  26165. func (m *TokenMutation) DeletedAt() (r time.Time, exists bool) {
  26166. v := m.deleted_at
  26167. if v == nil {
  26168. return
  26169. }
  26170. return *v, true
  26171. }
  26172. // OldDeletedAt returns the old "deleted_at" field's value of the Token entity.
  26173. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  26174. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26175. func (m *TokenMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  26176. if !m.op.Is(OpUpdateOne) {
  26177. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  26178. }
  26179. if m.id == nil || m.oldValue == nil {
  26180. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  26181. }
  26182. oldValue, err := m.oldValue(ctx)
  26183. if err != nil {
  26184. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  26185. }
  26186. return oldValue.DeletedAt, nil
  26187. }
  26188. // ClearDeletedAt clears the value of the "deleted_at" field.
  26189. func (m *TokenMutation) ClearDeletedAt() {
  26190. m.deleted_at = nil
  26191. m.clearedFields[token.FieldDeletedAt] = struct{}{}
  26192. }
  26193. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  26194. func (m *TokenMutation) DeletedAtCleared() bool {
  26195. _, ok := m.clearedFields[token.FieldDeletedAt]
  26196. return ok
  26197. }
  26198. // ResetDeletedAt resets all changes to the "deleted_at" field.
  26199. func (m *TokenMutation) ResetDeletedAt() {
  26200. m.deleted_at = nil
  26201. delete(m.clearedFields, token.FieldDeletedAt)
  26202. }
  26203. // SetExpireAt sets the "expire_at" field.
  26204. func (m *TokenMutation) SetExpireAt(t time.Time) {
  26205. m.expire_at = &t
  26206. }
  26207. // ExpireAt returns the value of the "expire_at" field in the mutation.
  26208. func (m *TokenMutation) ExpireAt() (r time.Time, exists bool) {
  26209. v := m.expire_at
  26210. if v == nil {
  26211. return
  26212. }
  26213. return *v, true
  26214. }
  26215. // OldExpireAt returns the old "expire_at" field's value of the Token entity.
  26216. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  26217. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26218. func (m *TokenMutation) OldExpireAt(ctx context.Context) (v time.Time, err error) {
  26219. if !m.op.Is(OpUpdateOne) {
  26220. return v, errors.New("OldExpireAt is only allowed on UpdateOne operations")
  26221. }
  26222. if m.id == nil || m.oldValue == nil {
  26223. return v, errors.New("OldExpireAt requires an ID field in the mutation")
  26224. }
  26225. oldValue, err := m.oldValue(ctx)
  26226. if err != nil {
  26227. return v, fmt.Errorf("querying old value for OldExpireAt: %w", err)
  26228. }
  26229. return oldValue.ExpireAt, nil
  26230. }
  26231. // ClearExpireAt clears the value of the "expire_at" field.
  26232. func (m *TokenMutation) ClearExpireAt() {
  26233. m.expire_at = nil
  26234. m.clearedFields[token.FieldExpireAt] = struct{}{}
  26235. }
  26236. // ExpireAtCleared returns if the "expire_at" field was cleared in this mutation.
  26237. func (m *TokenMutation) ExpireAtCleared() bool {
  26238. _, ok := m.clearedFields[token.FieldExpireAt]
  26239. return ok
  26240. }
  26241. // ResetExpireAt resets all changes to the "expire_at" field.
  26242. func (m *TokenMutation) ResetExpireAt() {
  26243. m.expire_at = nil
  26244. delete(m.clearedFields, token.FieldExpireAt)
  26245. }
  26246. // SetToken sets the "token" field.
  26247. func (m *TokenMutation) SetToken(s string) {
  26248. m.token = &s
  26249. }
  26250. // Token returns the value of the "token" field in the mutation.
  26251. func (m *TokenMutation) Token() (r string, exists bool) {
  26252. v := m.token
  26253. if v == nil {
  26254. return
  26255. }
  26256. return *v, true
  26257. }
  26258. // OldToken returns the old "token" field's value of the Token entity.
  26259. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  26260. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26261. func (m *TokenMutation) OldToken(ctx context.Context) (v string, err error) {
  26262. if !m.op.Is(OpUpdateOne) {
  26263. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  26264. }
  26265. if m.id == nil || m.oldValue == nil {
  26266. return v, errors.New("OldToken requires an ID field in the mutation")
  26267. }
  26268. oldValue, err := m.oldValue(ctx)
  26269. if err != nil {
  26270. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  26271. }
  26272. return oldValue.Token, nil
  26273. }
  26274. // ClearToken clears the value of the "token" field.
  26275. func (m *TokenMutation) ClearToken() {
  26276. m.token = nil
  26277. m.clearedFields[token.FieldToken] = struct{}{}
  26278. }
  26279. // TokenCleared returns if the "token" field was cleared in this mutation.
  26280. func (m *TokenMutation) TokenCleared() bool {
  26281. _, ok := m.clearedFields[token.FieldToken]
  26282. return ok
  26283. }
  26284. // ResetToken resets all changes to the "token" field.
  26285. func (m *TokenMutation) ResetToken() {
  26286. m.token = nil
  26287. delete(m.clearedFields, token.FieldToken)
  26288. }
  26289. // SetMAC sets the "mac" field.
  26290. func (m *TokenMutation) SetMAC(s string) {
  26291. m.mac = &s
  26292. }
  26293. // MAC returns the value of the "mac" field in the mutation.
  26294. func (m *TokenMutation) MAC() (r string, exists bool) {
  26295. v := m.mac
  26296. if v == nil {
  26297. return
  26298. }
  26299. return *v, true
  26300. }
  26301. // OldMAC returns the old "mac" field's value of the Token entity.
  26302. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  26303. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26304. func (m *TokenMutation) OldMAC(ctx context.Context) (v string, err error) {
  26305. if !m.op.Is(OpUpdateOne) {
  26306. return v, errors.New("OldMAC is only allowed on UpdateOne operations")
  26307. }
  26308. if m.id == nil || m.oldValue == nil {
  26309. return v, errors.New("OldMAC requires an ID field in the mutation")
  26310. }
  26311. oldValue, err := m.oldValue(ctx)
  26312. if err != nil {
  26313. return v, fmt.Errorf("querying old value for OldMAC: %w", err)
  26314. }
  26315. return oldValue.MAC, nil
  26316. }
  26317. // ClearMAC clears the value of the "mac" field.
  26318. func (m *TokenMutation) ClearMAC() {
  26319. m.mac = nil
  26320. m.clearedFields[token.FieldMAC] = struct{}{}
  26321. }
  26322. // MACCleared returns if the "mac" field was cleared in this mutation.
  26323. func (m *TokenMutation) MACCleared() bool {
  26324. _, ok := m.clearedFields[token.FieldMAC]
  26325. return ok
  26326. }
  26327. // ResetMAC resets all changes to the "mac" field.
  26328. func (m *TokenMutation) ResetMAC() {
  26329. m.mac = nil
  26330. delete(m.clearedFields, token.FieldMAC)
  26331. }
  26332. // SetOrganizationID sets the "organization_id" field.
  26333. func (m *TokenMutation) SetOrganizationID(u uint64) {
  26334. m.organization_id = &u
  26335. m.addorganization_id = nil
  26336. }
  26337. // OrganizationID returns the value of the "organization_id" field in the mutation.
  26338. func (m *TokenMutation) OrganizationID() (r uint64, exists bool) {
  26339. v := m.organization_id
  26340. if v == nil {
  26341. return
  26342. }
  26343. return *v, true
  26344. }
  26345. // OldOrganizationID returns the old "organization_id" field's value of the Token entity.
  26346. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  26347. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26348. func (m *TokenMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  26349. if !m.op.Is(OpUpdateOne) {
  26350. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  26351. }
  26352. if m.id == nil || m.oldValue == nil {
  26353. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  26354. }
  26355. oldValue, err := m.oldValue(ctx)
  26356. if err != nil {
  26357. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  26358. }
  26359. return oldValue.OrganizationID, nil
  26360. }
  26361. // AddOrganizationID adds u to the "organization_id" field.
  26362. func (m *TokenMutation) AddOrganizationID(u int64) {
  26363. if m.addorganization_id != nil {
  26364. *m.addorganization_id += u
  26365. } else {
  26366. m.addorganization_id = &u
  26367. }
  26368. }
  26369. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  26370. func (m *TokenMutation) AddedOrganizationID() (r int64, exists bool) {
  26371. v := m.addorganization_id
  26372. if v == nil {
  26373. return
  26374. }
  26375. return *v, true
  26376. }
  26377. // ResetOrganizationID resets all changes to the "organization_id" field.
  26378. func (m *TokenMutation) ResetOrganizationID() {
  26379. m.organization_id = nil
  26380. m.addorganization_id = nil
  26381. }
  26382. // SetAgentID sets the "agent_id" field.
  26383. func (m *TokenMutation) SetAgentID(u uint64) {
  26384. m.agent = &u
  26385. }
  26386. // AgentID returns the value of the "agent_id" field in the mutation.
  26387. func (m *TokenMutation) AgentID() (r uint64, exists bool) {
  26388. v := m.agent
  26389. if v == nil {
  26390. return
  26391. }
  26392. return *v, true
  26393. }
  26394. // OldAgentID returns the old "agent_id" field's value of the Token entity.
  26395. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  26396. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26397. func (m *TokenMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  26398. if !m.op.Is(OpUpdateOne) {
  26399. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  26400. }
  26401. if m.id == nil || m.oldValue == nil {
  26402. return v, errors.New("OldAgentID requires an ID field in the mutation")
  26403. }
  26404. oldValue, err := m.oldValue(ctx)
  26405. if err != nil {
  26406. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  26407. }
  26408. return oldValue.AgentID, nil
  26409. }
  26410. // ResetAgentID resets all changes to the "agent_id" field.
  26411. func (m *TokenMutation) ResetAgentID() {
  26412. m.agent = nil
  26413. }
  26414. // SetCustomAgentBase sets the "custom_agent_base" field.
  26415. func (m *TokenMutation) SetCustomAgentBase(s string) {
  26416. m.custom_agent_base = &s
  26417. }
  26418. // CustomAgentBase returns the value of the "custom_agent_base" field in the mutation.
  26419. func (m *TokenMutation) CustomAgentBase() (r string, exists bool) {
  26420. v := m.custom_agent_base
  26421. if v == nil {
  26422. return
  26423. }
  26424. return *v, true
  26425. }
  26426. // OldCustomAgentBase returns the old "custom_agent_base" field's value of the Token entity.
  26427. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  26428. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26429. func (m *TokenMutation) OldCustomAgentBase(ctx context.Context) (v string, err error) {
  26430. if !m.op.Is(OpUpdateOne) {
  26431. return v, errors.New("OldCustomAgentBase is only allowed on UpdateOne operations")
  26432. }
  26433. if m.id == nil || m.oldValue == nil {
  26434. return v, errors.New("OldCustomAgentBase requires an ID field in the mutation")
  26435. }
  26436. oldValue, err := m.oldValue(ctx)
  26437. if err != nil {
  26438. return v, fmt.Errorf("querying old value for OldCustomAgentBase: %w", err)
  26439. }
  26440. return oldValue.CustomAgentBase, nil
  26441. }
  26442. // ClearCustomAgentBase clears the value of the "custom_agent_base" field.
  26443. func (m *TokenMutation) ClearCustomAgentBase() {
  26444. m.custom_agent_base = nil
  26445. m.clearedFields[token.FieldCustomAgentBase] = struct{}{}
  26446. }
  26447. // CustomAgentBaseCleared returns if the "custom_agent_base" field was cleared in this mutation.
  26448. func (m *TokenMutation) CustomAgentBaseCleared() bool {
  26449. _, ok := m.clearedFields[token.FieldCustomAgentBase]
  26450. return ok
  26451. }
  26452. // ResetCustomAgentBase resets all changes to the "custom_agent_base" field.
  26453. func (m *TokenMutation) ResetCustomAgentBase() {
  26454. m.custom_agent_base = nil
  26455. delete(m.clearedFields, token.FieldCustomAgentBase)
  26456. }
  26457. // SetCustomAgentKey sets the "custom_agent_key" field.
  26458. func (m *TokenMutation) SetCustomAgentKey(s string) {
  26459. m.custom_agent_key = &s
  26460. }
  26461. // CustomAgentKey returns the value of the "custom_agent_key" field in the mutation.
  26462. func (m *TokenMutation) CustomAgentKey() (r string, exists bool) {
  26463. v := m.custom_agent_key
  26464. if v == nil {
  26465. return
  26466. }
  26467. return *v, true
  26468. }
  26469. // OldCustomAgentKey returns the old "custom_agent_key" field's value of the Token entity.
  26470. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  26471. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26472. func (m *TokenMutation) OldCustomAgentKey(ctx context.Context) (v string, err error) {
  26473. if !m.op.Is(OpUpdateOne) {
  26474. return v, errors.New("OldCustomAgentKey is only allowed on UpdateOne operations")
  26475. }
  26476. if m.id == nil || m.oldValue == nil {
  26477. return v, errors.New("OldCustomAgentKey requires an ID field in the mutation")
  26478. }
  26479. oldValue, err := m.oldValue(ctx)
  26480. if err != nil {
  26481. return v, fmt.Errorf("querying old value for OldCustomAgentKey: %w", err)
  26482. }
  26483. return oldValue.CustomAgentKey, nil
  26484. }
  26485. // ClearCustomAgentKey clears the value of the "custom_agent_key" field.
  26486. func (m *TokenMutation) ClearCustomAgentKey() {
  26487. m.custom_agent_key = nil
  26488. m.clearedFields[token.FieldCustomAgentKey] = struct{}{}
  26489. }
  26490. // CustomAgentKeyCleared returns if the "custom_agent_key" field was cleared in this mutation.
  26491. func (m *TokenMutation) CustomAgentKeyCleared() bool {
  26492. _, ok := m.clearedFields[token.FieldCustomAgentKey]
  26493. return ok
  26494. }
  26495. // ResetCustomAgentKey resets all changes to the "custom_agent_key" field.
  26496. func (m *TokenMutation) ResetCustomAgentKey() {
  26497. m.custom_agent_key = nil
  26498. delete(m.clearedFields, token.FieldCustomAgentKey)
  26499. }
  26500. // SetOpenaiBase sets the "openai_base" field.
  26501. func (m *TokenMutation) SetOpenaiBase(s string) {
  26502. m.openai_base = &s
  26503. }
  26504. // OpenaiBase returns the value of the "openai_base" field in the mutation.
  26505. func (m *TokenMutation) OpenaiBase() (r string, exists bool) {
  26506. v := m.openai_base
  26507. if v == nil {
  26508. return
  26509. }
  26510. return *v, true
  26511. }
  26512. // OldOpenaiBase returns the old "openai_base" field's value of the Token entity.
  26513. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  26514. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26515. func (m *TokenMutation) OldOpenaiBase(ctx context.Context) (v string, err error) {
  26516. if !m.op.Is(OpUpdateOne) {
  26517. return v, errors.New("OldOpenaiBase is only allowed on UpdateOne operations")
  26518. }
  26519. if m.id == nil || m.oldValue == nil {
  26520. return v, errors.New("OldOpenaiBase requires an ID field in the mutation")
  26521. }
  26522. oldValue, err := m.oldValue(ctx)
  26523. if err != nil {
  26524. return v, fmt.Errorf("querying old value for OldOpenaiBase: %w", err)
  26525. }
  26526. return oldValue.OpenaiBase, nil
  26527. }
  26528. // ClearOpenaiBase clears the value of the "openai_base" field.
  26529. func (m *TokenMutation) ClearOpenaiBase() {
  26530. m.openai_base = nil
  26531. m.clearedFields[token.FieldOpenaiBase] = struct{}{}
  26532. }
  26533. // OpenaiBaseCleared returns if the "openai_base" field was cleared in this mutation.
  26534. func (m *TokenMutation) OpenaiBaseCleared() bool {
  26535. _, ok := m.clearedFields[token.FieldOpenaiBase]
  26536. return ok
  26537. }
  26538. // ResetOpenaiBase resets all changes to the "openai_base" field.
  26539. func (m *TokenMutation) ResetOpenaiBase() {
  26540. m.openai_base = nil
  26541. delete(m.clearedFields, token.FieldOpenaiBase)
  26542. }
  26543. // SetOpenaiKey sets the "openai_key" field.
  26544. func (m *TokenMutation) SetOpenaiKey(s string) {
  26545. m.openai_key = &s
  26546. }
  26547. // OpenaiKey returns the value of the "openai_key" field in the mutation.
  26548. func (m *TokenMutation) OpenaiKey() (r string, exists bool) {
  26549. v := m.openai_key
  26550. if v == nil {
  26551. return
  26552. }
  26553. return *v, true
  26554. }
  26555. // OldOpenaiKey returns the old "openai_key" field's value of the Token entity.
  26556. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  26557. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26558. func (m *TokenMutation) OldOpenaiKey(ctx context.Context) (v string, err error) {
  26559. if !m.op.Is(OpUpdateOne) {
  26560. return v, errors.New("OldOpenaiKey is only allowed on UpdateOne operations")
  26561. }
  26562. if m.id == nil || m.oldValue == nil {
  26563. return v, errors.New("OldOpenaiKey requires an ID field in the mutation")
  26564. }
  26565. oldValue, err := m.oldValue(ctx)
  26566. if err != nil {
  26567. return v, fmt.Errorf("querying old value for OldOpenaiKey: %w", err)
  26568. }
  26569. return oldValue.OpenaiKey, nil
  26570. }
  26571. // ClearOpenaiKey clears the value of the "openai_key" field.
  26572. func (m *TokenMutation) ClearOpenaiKey() {
  26573. m.openai_key = nil
  26574. m.clearedFields[token.FieldOpenaiKey] = struct{}{}
  26575. }
  26576. // OpenaiKeyCleared returns if the "openai_key" field was cleared in this mutation.
  26577. func (m *TokenMutation) OpenaiKeyCleared() bool {
  26578. _, ok := m.clearedFields[token.FieldOpenaiKey]
  26579. return ok
  26580. }
  26581. // ResetOpenaiKey resets all changes to the "openai_key" field.
  26582. func (m *TokenMutation) ResetOpenaiKey() {
  26583. m.openai_key = nil
  26584. delete(m.clearedFields, token.FieldOpenaiKey)
  26585. }
  26586. // ClearAgent clears the "agent" edge to the Agent entity.
  26587. func (m *TokenMutation) ClearAgent() {
  26588. m.clearedagent = true
  26589. m.clearedFields[token.FieldAgentID] = struct{}{}
  26590. }
  26591. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  26592. func (m *TokenMutation) AgentCleared() bool {
  26593. return m.clearedagent
  26594. }
  26595. // AgentIDs returns the "agent" edge IDs in the mutation.
  26596. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  26597. // AgentID instead. It exists only for internal usage by the builders.
  26598. func (m *TokenMutation) AgentIDs() (ids []uint64) {
  26599. if id := m.agent; id != nil {
  26600. ids = append(ids, *id)
  26601. }
  26602. return
  26603. }
  26604. // ResetAgent resets all changes to the "agent" edge.
  26605. func (m *TokenMutation) ResetAgent() {
  26606. m.agent = nil
  26607. m.clearedagent = false
  26608. }
  26609. // Where appends a list predicates to the TokenMutation builder.
  26610. func (m *TokenMutation) Where(ps ...predicate.Token) {
  26611. m.predicates = append(m.predicates, ps...)
  26612. }
  26613. // WhereP appends storage-level predicates to the TokenMutation builder. Using this method,
  26614. // users can use type-assertion to append predicates that do not depend on any generated package.
  26615. func (m *TokenMutation) WhereP(ps ...func(*sql.Selector)) {
  26616. p := make([]predicate.Token, len(ps))
  26617. for i := range ps {
  26618. p[i] = ps[i]
  26619. }
  26620. m.Where(p...)
  26621. }
  26622. // Op returns the operation name.
  26623. func (m *TokenMutation) Op() Op {
  26624. return m.op
  26625. }
  26626. // SetOp allows setting the mutation operation.
  26627. func (m *TokenMutation) SetOp(op Op) {
  26628. m.op = op
  26629. }
  26630. // Type returns the node type of this mutation (Token).
  26631. func (m *TokenMutation) Type() string {
  26632. return m.typ
  26633. }
  26634. // Fields returns all fields that were changed during this mutation. Note that in
  26635. // order to get all numeric fields that were incremented/decremented, call
  26636. // AddedFields().
  26637. func (m *TokenMutation) Fields() []string {
  26638. fields := make([]string, 0, 12)
  26639. if m.created_at != nil {
  26640. fields = append(fields, token.FieldCreatedAt)
  26641. }
  26642. if m.updated_at != nil {
  26643. fields = append(fields, token.FieldUpdatedAt)
  26644. }
  26645. if m.deleted_at != nil {
  26646. fields = append(fields, token.FieldDeletedAt)
  26647. }
  26648. if m.expire_at != nil {
  26649. fields = append(fields, token.FieldExpireAt)
  26650. }
  26651. if m.token != nil {
  26652. fields = append(fields, token.FieldToken)
  26653. }
  26654. if m.mac != nil {
  26655. fields = append(fields, token.FieldMAC)
  26656. }
  26657. if m.organization_id != nil {
  26658. fields = append(fields, token.FieldOrganizationID)
  26659. }
  26660. if m.agent != nil {
  26661. fields = append(fields, token.FieldAgentID)
  26662. }
  26663. if m.custom_agent_base != nil {
  26664. fields = append(fields, token.FieldCustomAgentBase)
  26665. }
  26666. if m.custom_agent_key != nil {
  26667. fields = append(fields, token.FieldCustomAgentKey)
  26668. }
  26669. if m.openai_base != nil {
  26670. fields = append(fields, token.FieldOpenaiBase)
  26671. }
  26672. if m.openai_key != nil {
  26673. fields = append(fields, token.FieldOpenaiKey)
  26674. }
  26675. return fields
  26676. }
  26677. // Field returns the value of a field with the given name. The second boolean
  26678. // return value indicates that this field was not set, or was not defined in the
  26679. // schema.
  26680. func (m *TokenMutation) Field(name string) (ent.Value, bool) {
  26681. switch name {
  26682. case token.FieldCreatedAt:
  26683. return m.CreatedAt()
  26684. case token.FieldUpdatedAt:
  26685. return m.UpdatedAt()
  26686. case token.FieldDeletedAt:
  26687. return m.DeletedAt()
  26688. case token.FieldExpireAt:
  26689. return m.ExpireAt()
  26690. case token.FieldToken:
  26691. return m.Token()
  26692. case token.FieldMAC:
  26693. return m.MAC()
  26694. case token.FieldOrganizationID:
  26695. return m.OrganizationID()
  26696. case token.FieldAgentID:
  26697. return m.AgentID()
  26698. case token.FieldCustomAgentBase:
  26699. return m.CustomAgentBase()
  26700. case token.FieldCustomAgentKey:
  26701. return m.CustomAgentKey()
  26702. case token.FieldOpenaiBase:
  26703. return m.OpenaiBase()
  26704. case token.FieldOpenaiKey:
  26705. return m.OpenaiKey()
  26706. }
  26707. return nil, false
  26708. }
  26709. // OldField returns the old value of the field from the database. An error is
  26710. // returned if the mutation operation is not UpdateOne, or the query to the
  26711. // database failed.
  26712. func (m *TokenMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  26713. switch name {
  26714. case token.FieldCreatedAt:
  26715. return m.OldCreatedAt(ctx)
  26716. case token.FieldUpdatedAt:
  26717. return m.OldUpdatedAt(ctx)
  26718. case token.FieldDeletedAt:
  26719. return m.OldDeletedAt(ctx)
  26720. case token.FieldExpireAt:
  26721. return m.OldExpireAt(ctx)
  26722. case token.FieldToken:
  26723. return m.OldToken(ctx)
  26724. case token.FieldMAC:
  26725. return m.OldMAC(ctx)
  26726. case token.FieldOrganizationID:
  26727. return m.OldOrganizationID(ctx)
  26728. case token.FieldAgentID:
  26729. return m.OldAgentID(ctx)
  26730. case token.FieldCustomAgentBase:
  26731. return m.OldCustomAgentBase(ctx)
  26732. case token.FieldCustomAgentKey:
  26733. return m.OldCustomAgentKey(ctx)
  26734. case token.FieldOpenaiBase:
  26735. return m.OldOpenaiBase(ctx)
  26736. case token.FieldOpenaiKey:
  26737. return m.OldOpenaiKey(ctx)
  26738. }
  26739. return nil, fmt.Errorf("unknown Token field %s", name)
  26740. }
  26741. // SetField sets the value of a field with the given name. It returns an error if
  26742. // the field is not defined in the schema, or if the type mismatched the field
  26743. // type.
  26744. func (m *TokenMutation) SetField(name string, value ent.Value) error {
  26745. switch name {
  26746. case token.FieldCreatedAt:
  26747. v, ok := value.(time.Time)
  26748. if !ok {
  26749. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26750. }
  26751. m.SetCreatedAt(v)
  26752. return nil
  26753. case token.FieldUpdatedAt:
  26754. v, ok := value.(time.Time)
  26755. if !ok {
  26756. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26757. }
  26758. m.SetUpdatedAt(v)
  26759. return nil
  26760. case token.FieldDeletedAt:
  26761. v, ok := value.(time.Time)
  26762. if !ok {
  26763. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26764. }
  26765. m.SetDeletedAt(v)
  26766. return nil
  26767. case token.FieldExpireAt:
  26768. v, ok := value.(time.Time)
  26769. if !ok {
  26770. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26771. }
  26772. m.SetExpireAt(v)
  26773. return nil
  26774. case token.FieldToken:
  26775. v, ok := value.(string)
  26776. if !ok {
  26777. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26778. }
  26779. m.SetToken(v)
  26780. return nil
  26781. case token.FieldMAC:
  26782. v, ok := value.(string)
  26783. if !ok {
  26784. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26785. }
  26786. m.SetMAC(v)
  26787. return nil
  26788. case token.FieldOrganizationID:
  26789. v, ok := value.(uint64)
  26790. if !ok {
  26791. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26792. }
  26793. m.SetOrganizationID(v)
  26794. return nil
  26795. case token.FieldAgentID:
  26796. v, ok := value.(uint64)
  26797. if !ok {
  26798. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26799. }
  26800. m.SetAgentID(v)
  26801. return nil
  26802. case token.FieldCustomAgentBase:
  26803. v, ok := value.(string)
  26804. if !ok {
  26805. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26806. }
  26807. m.SetCustomAgentBase(v)
  26808. return nil
  26809. case token.FieldCustomAgentKey:
  26810. v, ok := value.(string)
  26811. if !ok {
  26812. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26813. }
  26814. m.SetCustomAgentKey(v)
  26815. return nil
  26816. case token.FieldOpenaiBase:
  26817. v, ok := value.(string)
  26818. if !ok {
  26819. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26820. }
  26821. m.SetOpenaiBase(v)
  26822. return nil
  26823. case token.FieldOpenaiKey:
  26824. v, ok := value.(string)
  26825. if !ok {
  26826. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26827. }
  26828. m.SetOpenaiKey(v)
  26829. return nil
  26830. }
  26831. return fmt.Errorf("unknown Token field %s", name)
  26832. }
  26833. // AddedFields returns all numeric fields that were incremented/decremented during
  26834. // this mutation.
  26835. func (m *TokenMutation) AddedFields() []string {
  26836. var fields []string
  26837. if m.addorganization_id != nil {
  26838. fields = append(fields, token.FieldOrganizationID)
  26839. }
  26840. return fields
  26841. }
  26842. // AddedField returns the numeric value that was incremented/decremented on a field
  26843. // with the given name. The second boolean return value indicates that this field
  26844. // was not set, or was not defined in the schema.
  26845. func (m *TokenMutation) AddedField(name string) (ent.Value, bool) {
  26846. switch name {
  26847. case token.FieldOrganizationID:
  26848. return m.AddedOrganizationID()
  26849. }
  26850. return nil, false
  26851. }
  26852. // AddField adds the value to the field with the given name. It returns an error if
  26853. // the field is not defined in the schema, or if the type mismatched the field
  26854. // type.
  26855. func (m *TokenMutation) AddField(name string, value ent.Value) error {
  26856. switch name {
  26857. case token.FieldOrganizationID:
  26858. v, ok := value.(int64)
  26859. if !ok {
  26860. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26861. }
  26862. m.AddOrganizationID(v)
  26863. return nil
  26864. }
  26865. return fmt.Errorf("unknown Token numeric field %s", name)
  26866. }
  26867. // ClearedFields returns all nullable fields that were cleared during this
  26868. // mutation.
  26869. func (m *TokenMutation) ClearedFields() []string {
  26870. var fields []string
  26871. if m.FieldCleared(token.FieldDeletedAt) {
  26872. fields = append(fields, token.FieldDeletedAt)
  26873. }
  26874. if m.FieldCleared(token.FieldExpireAt) {
  26875. fields = append(fields, token.FieldExpireAt)
  26876. }
  26877. if m.FieldCleared(token.FieldToken) {
  26878. fields = append(fields, token.FieldToken)
  26879. }
  26880. if m.FieldCleared(token.FieldMAC) {
  26881. fields = append(fields, token.FieldMAC)
  26882. }
  26883. if m.FieldCleared(token.FieldCustomAgentBase) {
  26884. fields = append(fields, token.FieldCustomAgentBase)
  26885. }
  26886. if m.FieldCleared(token.FieldCustomAgentKey) {
  26887. fields = append(fields, token.FieldCustomAgentKey)
  26888. }
  26889. if m.FieldCleared(token.FieldOpenaiBase) {
  26890. fields = append(fields, token.FieldOpenaiBase)
  26891. }
  26892. if m.FieldCleared(token.FieldOpenaiKey) {
  26893. fields = append(fields, token.FieldOpenaiKey)
  26894. }
  26895. return fields
  26896. }
  26897. // FieldCleared returns a boolean indicating if a field with the given name was
  26898. // cleared in this mutation.
  26899. func (m *TokenMutation) FieldCleared(name string) bool {
  26900. _, ok := m.clearedFields[name]
  26901. return ok
  26902. }
  26903. // ClearField clears the value of the field with the given name. It returns an
  26904. // error if the field is not defined in the schema.
  26905. func (m *TokenMutation) ClearField(name string) error {
  26906. switch name {
  26907. case token.FieldDeletedAt:
  26908. m.ClearDeletedAt()
  26909. return nil
  26910. case token.FieldExpireAt:
  26911. m.ClearExpireAt()
  26912. return nil
  26913. case token.FieldToken:
  26914. m.ClearToken()
  26915. return nil
  26916. case token.FieldMAC:
  26917. m.ClearMAC()
  26918. return nil
  26919. case token.FieldCustomAgentBase:
  26920. m.ClearCustomAgentBase()
  26921. return nil
  26922. case token.FieldCustomAgentKey:
  26923. m.ClearCustomAgentKey()
  26924. return nil
  26925. case token.FieldOpenaiBase:
  26926. m.ClearOpenaiBase()
  26927. return nil
  26928. case token.FieldOpenaiKey:
  26929. m.ClearOpenaiKey()
  26930. return nil
  26931. }
  26932. return fmt.Errorf("unknown Token nullable field %s", name)
  26933. }
  26934. // ResetField resets all changes in the mutation for the field with the given name.
  26935. // It returns an error if the field is not defined in the schema.
  26936. func (m *TokenMutation) ResetField(name string) error {
  26937. switch name {
  26938. case token.FieldCreatedAt:
  26939. m.ResetCreatedAt()
  26940. return nil
  26941. case token.FieldUpdatedAt:
  26942. m.ResetUpdatedAt()
  26943. return nil
  26944. case token.FieldDeletedAt:
  26945. m.ResetDeletedAt()
  26946. return nil
  26947. case token.FieldExpireAt:
  26948. m.ResetExpireAt()
  26949. return nil
  26950. case token.FieldToken:
  26951. m.ResetToken()
  26952. return nil
  26953. case token.FieldMAC:
  26954. m.ResetMAC()
  26955. return nil
  26956. case token.FieldOrganizationID:
  26957. m.ResetOrganizationID()
  26958. return nil
  26959. case token.FieldAgentID:
  26960. m.ResetAgentID()
  26961. return nil
  26962. case token.FieldCustomAgentBase:
  26963. m.ResetCustomAgentBase()
  26964. return nil
  26965. case token.FieldCustomAgentKey:
  26966. m.ResetCustomAgentKey()
  26967. return nil
  26968. case token.FieldOpenaiBase:
  26969. m.ResetOpenaiBase()
  26970. return nil
  26971. case token.FieldOpenaiKey:
  26972. m.ResetOpenaiKey()
  26973. return nil
  26974. }
  26975. return fmt.Errorf("unknown Token field %s", name)
  26976. }
  26977. // AddedEdges returns all edge names that were set/added in this mutation.
  26978. func (m *TokenMutation) AddedEdges() []string {
  26979. edges := make([]string, 0, 1)
  26980. if m.agent != nil {
  26981. edges = append(edges, token.EdgeAgent)
  26982. }
  26983. return edges
  26984. }
  26985. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  26986. // name in this mutation.
  26987. func (m *TokenMutation) AddedIDs(name string) []ent.Value {
  26988. switch name {
  26989. case token.EdgeAgent:
  26990. if id := m.agent; id != nil {
  26991. return []ent.Value{*id}
  26992. }
  26993. }
  26994. return nil
  26995. }
  26996. // RemovedEdges returns all edge names that were removed in this mutation.
  26997. func (m *TokenMutation) RemovedEdges() []string {
  26998. edges := make([]string, 0, 1)
  26999. return edges
  27000. }
  27001. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  27002. // the given name in this mutation.
  27003. func (m *TokenMutation) RemovedIDs(name string) []ent.Value {
  27004. return nil
  27005. }
  27006. // ClearedEdges returns all edge names that were cleared in this mutation.
  27007. func (m *TokenMutation) ClearedEdges() []string {
  27008. edges := make([]string, 0, 1)
  27009. if m.clearedagent {
  27010. edges = append(edges, token.EdgeAgent)
  27011. }
  27012. return edges
  27013. }
  27014. // EdgeCleared returns a boolean which indicates if the edge with the given name
  27015. // was cleared in this mutation.
  27016. func (m *TokenMutation) EdgeCleared(name string) bool {
  27017. switch name {
  27018. case token.EdgeAgent:
  27019. return m.clearedagent
  27020. }
  27021. return false
  27022. }
  27023. // ClearEdge clears the value of the edge with the given name. It returns an error
  27024. // if that edge is not defined in the schema.
  27025. func (m *TokenMutation) ClearEdge(name string) error {
  27026. switch name {
  27027. case token.EdgeAgent:
  27028. m.ClearAgent()
  27029. return nil
  27030. }
  27031. return fmt.Errorf("unknown Token unique edge %s", name)
  27032. }
  27033. // ResetEdge resets all changes to the edge with the given name in this mutation.
  27034. // It returns an error if the edge is not defined in the schema.
  27035. func (m *TokenMutation) ResetEdge(name string) error {
  27036. switch name {
  27037. case token.EdgeAgent:
  27038. m.ResetAgent()
  27039. return nil
  27040. }
  27041. return fmt.Errorf("unknown Token edge %s", name)
  27042. }
  27043. // TutorialMutation represents an operation that mutates the Tutorial nodes in the graph.
  27044. type TutorialMutation struct {
  27045. config
  27046. op Op
  27047. typ string
  27048. id *uint64
  27049. created_at *time.Time
  27050. updated_at *time.Time
  27051. deleted_at *time.Time
  27052. index *int
  27053. addindex *int
  27054. title *string
  27055. content *string
  27056. organization_id *uint64
  27057. addorganization_id *int64
  27058. clearedFields map[string]struct{}
  27059. employee *uint64
  27060. clearedemployee bool
  27061. done bool
  27062. oldValue func(context.Context) (*Tutorial, error)
  27063. predicates []predicate.Tutorial
  27064. }
  27065. var _ ent.Mutation = (*TutorialMutation)(nil)
  27066. // tutorialOption allows management of the mutation configuration using functional options.
  27067. type tutorialOption func(*TutorialMutation)
  27068. // newTutorialMutation creates new mutation for the Tutorial entity.
  27069. func newTutorialMutation(c config, op Op, opts ...tutorialOption) *TutorialMutation {
  27070. m := &TutorialMutation{
  27071. config: c,
  27072. op: op,
  27073. typ: TypeTutorial,
  27074. clearedFields: make(map[string]struct{}),
  27075. }
  27076. for _, opt := range opts {
  27077. opt(m)
  27078. }
  27079. return m
  27080. }
  27081. // withTutorialID sets the ID field of the mutation.
  27082. func withTutorialID(id uint64) tutorialOption {
  27083. return func(m *TutorialMutation) {
  27084. var (
  27085. err error
  27086. once sync.Once
  27087. value *Tutorial
  27088. )
  27089. m.oldValue = func(ctx context.Context) (*Tutorial, error) {
  27090. once.Do(func() {
  27091. if m.done {
  27092. err = errors.New("querying old values post mutation is not allowed")
  27093. } else {
  27094. value, err = m.Client().Tutorial.Get(ctx, id)
  27095. }
  27096. })
  27097. return value, err
  27098. }
  27099. m.id = &id
  27100. }
  27101. }
  27102. // withTutorial sets the old Tutorial of the mutation.
  27103. func withTutorial(node *Tutorial) tutorialOption {
  27104. return func(m *TutorialMutation) {
  27105. m.oldValue = func(context.Context) (*Tutorial, error) {
  27106. return node, nil
  27107. }
  27108. m.id = &node.ID
  27109. }
  27110. }
  27111. // Client returns a new `ent.Client` from the mutation. If the mutation was
  27112. // executed in a transaction (ent.Tx), a transactional client is returned.
  27113. func (m TutorialMutation) Client() *Client {
  27114. client := &Client{config: m.config}
  27115. client.init()
  27116. return client
  27117. }
  27118. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  27119. // it returns an error otherwise.
  27120. func (m TutorialMutation) Tx() (*Tx, error) {
  27121. if _, ok := m.driver.(*txDriver); !ok {
  27122. return nil, errors.New("ent: mutation is not running in a transaction")
  27123. }
  27124. tx := &Tx{config: m.config}
  27125. tx.init()
  27126. return tx, nil
  27127. }
  27128. // SetID sets the value of the id field. Note that this
  27129. // operation is only accepted on creation of Tutorial entities.
  27130. func (m *TutorialMutation) SetID(id uint64) {
  27131. m.id = &id
  27132. }
  27133. // ID returns the ID value in the mutation. Note that the ID is only available
  27134. // if it was provided to the builder or after it was returned from the database.
  27135. func (m *TutorialMutation) ID() (id uint64, exists bool) {
  27136. if m.id == nil {
  27137. return
  27138. }
  27139. return *m.id, true
  27140. }
  27141. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  27142. // That means, if the mutation is applied within a transaction with an isolation level such
  27143. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  27144. // or updated by the mutation.
  27145. func (m *TutorialMutation) IDs(ctx context.Context) ([]uint64, error) {
  27146. switch {
  27147. case m.op.Is(OpUpdateOne | OpDeleteOne):
  27148. id, exists := m.ID()
  27149. if exists {
  27150. return []uint64{id}, nil
  27151. }
  27152. fallthrough
  27153. case m.op.Is(OpUpdate | OpDelete):
  27154. return m.Client().Tutorial.Query().Where(m.predicates...).IDs(ctx)
  27155. default:
  27156. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  27157. }
  27158. }
  27159. // SetCreatedAt sets the "created_at" field.
  27160. func (m *TutorialMutation) SetCreatedAt(t time.Time) {
  27161. m.created_at = &t
  27162. }
  27163. // CreatedAt returns the value of the "created_at" field in the mutation.
  27164. func (m *TutorialMutation) CreatedAt() (r time.Time, exists bool) {
  27165. v := m.created_at
  27166. if v == nil {
  27167. return
  27168. }
  27169. return *v, true
  27170. }
  27171. // OldCreatedAt returns the old "created_at" field's value of the Tutorial entity.
  27172. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  27173. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27174. func (m *TutorialMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  27175. if !m.op.Is(OpUpdateOne) {
  27176. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  27177. }
  27178. if m.id == nil || m.oldValue == nil {
  27179. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  27180. }
  27181. oldValue, err := m.oldValue(ctx)
  27182. if err != nil {
  27183. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  27184. }
  27185. return oldValue.CreatedAt, nil
  27186. }
  27187. // ResetCreatedAt resets all changes to the "created_at" field.
  27188. func (m *TutorialMutation) ResetCreatedAt() {
  27189. m.created_at = nil
  27190. }
  27191. // SetUpdatedAt sets the "updated_at" field.
  27192. func (m *TutorialMutation) SetUpdatedAt(t time.Time) {
  27193. m.updated_at = &t
  27194. }
  27195. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  27196. func (m *TutorialMutation) UpdatedAt() (r time.Time, exists bool) {
  27197. v := m.updated_at
  27198. if v == nil {
  27199. return
  27200. }
  27201. return *v, true
  27202. }
  27203. // OldUpdatedAt returns the old "updated_at" field's value of the Tutorial entity.
  27204. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  27205. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27206. func (m *TutorialMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  27207. if !m.op.Is(OpUpdateOne) {
  27208. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  27209. }
  27210. if m.id == nil || m.oldValue == nil {
  27211. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  27212. }
  27213. oldValue, err := m.oldValue(ctx)
  27214. if err != nil {
  27215. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  27216. }
  27217. return oldValue.UpdatedAt, nil
  27218. }
  27219. // ResetUpdatedAt resets all changes to the "updated_at" field.
  27220. func (m *TutorialMutation) ResetUpdatedAt() {
  27221. m.updated_at = nil
  27222. }
  27223. // SetDeletedAt sets the "deleted_at" field.
  27224. func (m *TutorialMutation) SetDeletedAt(t time.Time) {
  27225. m.deleted_at = &t
  27226. }
  27227. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  27228. func (m *TutorialMutation) DeletedAt() (r time.Time, exists bool) {
  27229. v := m.deleted_at
  27230. if v == nil {
  27231. return
  27232. }
  27233. return *v, true
  27234. }
  27235. // OldDeletedAt returns the old "deleted_at" field's value of the Tutorial entity.
  27236. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  27237. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27238. func (m *TutorialMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  27239. if !m.op.Is(OpUpdateOne) {
  27240. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  27241. }
  27242. if m.id == nil || m.oldValue == nil {
  27243. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  27244. }
  27245. oldValue, err := m.oldValue(ctx)
  27246. if err != nil {
  27247. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  27248. }
  27249. return oldValue.DeletedAt, nil
  27250. }
  27251. // ClearDeletedAt clears the value of the "deleted_at" field.
  27252. func (m *TutorialMutation) ClearDeletedAt() {
  27253. m.deleted_at = nil
  27254. m.clearedFields[tutorial.FieldDeletedAt] = struct{}{}
  27255. }
  27256. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  27257. func (m *TutorialMutation) DeletedAtCleared() bool {
  27258. _, ok := m.clearedFields[tutorial.FieldDeletedAt]
  27259. return ok
  27260. }
  27261. // ResetDeletedAt resets all changes to the "deleted_at" field.
  27262. func (m *TutorialMutation) ResetDeletedAt() {
  27263. m.deleted_at = nil
  27264. delete(m.clearedFields, tutorial.FieldDeletedAt)
  27265. }
  27266. // SetEmployeeID sets the "employee_id" field.
  27267. func (m *TutorialMutation) SetEmployeeID(u uint64) {
  27268. m.employee = &u
  27269. }
  27270. // EmployeeID returns the value of the "employee_id" field in the mutation.
  27271. func (m *TutorialMutation) EmployeeID() (r uint64, exists bool) {
  27272. v := m.employee
  27273. if v == nil {
  27274. return
  27275. }
  27276. return *v, true
  27277. }
  27278. // OldEmployeeID returns the old "employee_id" field's value of the Tutorial entity.
  27279. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  27280. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27281. func (m *TutorialMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  27282. if !m.op.Is(OpUpdateOne) {
  27283. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  27284. }
  27285. if m.id == nil || m.oldValue == nil {
  27286. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  27287. }
  27288. oldValue, err := m.oldValue(ctx)
  27289. if err != nil {
  27290. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  27291. }
  27292. return oldValue.EmployeeID, nil
  27293. }
  27294. // ResetEmployeeID resets all changes to the "employee_id" field.
  27295. func (m *TutorialMutation) ResetEmployeeID() {
  27296. m.employee = nil
  27297. }
  27298. // SetIndex sets the "index" field.
  27299. func (m *TutorialMutation) SetIndex(i int) {
  27300. m.index = &i
  27301. m.addindex = nil
  27302. }
  27303. // Index returns the value of the "index" field in the mutation.
  27304. func (m *TutorialMutation) Index() (r int, exists bool) {
  27305. v := m.index
  27306. if v == nil {
  27307. return
  27308. }
  27309. return *v, true
  27310. }
  27311. // OldIndex returns the old "index" field's value of the Tutorial entity.
  27312. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  27313. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27314. func (m *TutorialMutation) OldIndex(ctx context.Context) (v int, err error) {
  27315. if !m.op.Is(OpUpdateOne) {
  27316. return v, errors.New("OldIndex is only allowed on UpdateOne operations")
  27317. }
  27318. if m.id == nil || m.oldValue == nil {
  27319. return v, errors.New("OldIndex requires an ID field in the mutation")
  27320. }
  27321. oldValue, err := m.oldValue(ctx)
  27322. if err != nil {
  27323. return v, fmt.Errorf("querying old value for OldIndex: %w", err)
  27324. }
  27325. return oldValue.Index, nil
  27326. }
  27327. // AddIndex adds i to the "index" field.
  27328. func (m *TutorialMutation) AddIndex(i int) {
  27329. if m.addindex != nil {
  27330. *m.addindex += i
  27331. } else {
  27332. m.addindex = &i
  27333. }
  27334. }
  27335. // AddedIndex returns the value that was added to the "index" field in this mutation.
  27336. func (m *TutorialMutation) AddedIndex() (r int, exists bool) {
  27337. v := m.addindex
  27338. if v == nil {
  27339. return
  27340. }
  27341. return *v, true
  27342. }
  27343. // ResetIndex resets all changes to the "index" field.
  27344. func (m *TutorialMutation) ResetIndex() {
  27345. m.index = nil
  27346. m.addindex = nil
  27347. }
  27348. // SetTitle sets the "title" field.
  27349. func (m *TutorialMutation) SetTitle(s string) {
  27350. m.title = &s
  27351. }
  27352. // Title returns the value of the "title" field in the mutation.
  27353. func (m *TutorialMutation) Title() (r string, exists bool) {
  27354. v := m.title
  27355. if v == nil {
  27356. return
  27357. }
  27358. return *v, true
  27359. }
  27360. // OldTitle returns the old "title" field's value of the Tutorial entity.
  27361. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  27362. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27363. func (m *TutorialMutation) OldTitle(ctx context.Context) (v string, err error) {
  27364. if !m.op.Is(OpUpdateOne) {
  27365. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  27366. }
  27367. if m.id == nil || m.oldValue == nil {
  27368. return v, errors.New("OldTitle requires an ID field in the mutation")
  27369. }
  27370. oldValue, err := m.oldValue(ctx)
  27371. if err != nil {
  27372. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  27373. }
  27374. return oldValue.Title, nil
  27375. }
  27376. // ResetTitle resets all changes to the "title" field.
  27377. func (m *TutorialMutation) ResetTitle() {
  27378. m.title = nil
  27379. }
  27380. // SetContent sets the "content" field.
  27381. func (m *TutorialMutation) SetContent(s string) {
  27382. m.content = &s
  27383. }
  27384. // Content returns the value of the "content" field in the mutation.
  27385. func (m *TutorialMutation) Content() (r string, exists bool) {
  27386. v := m.content
  27387. if v == nil {
  27388. return
  27389. }
  27390. return *v, true
  27391. }
  27392. // OldContent returns the old "content" field's value of the Tutorial entity.
  27393. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  27394. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27395. func (m *TutorialMutation) OldContent(ctx context.Context) (v string, err error) {
  27396. if !m.op.Is(OpUpdateOne) {
  27397. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  27398. }
  27399. if m.id == nil || m.oldValue == nil {
  27400. return v, errors.New("OldContent requires an ID field in the mutation")
  27401. }
  27402. oldValue, err := m.oldValue(ctx)
  27403. if err != nil {
  27404. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  27405. }
  27406. return oldValue.Content, nil
  27407. }
  27408. // ResetContent resets all changes to the "content" field.
  27409. func (m *TutorialMutation) ResetContent() {
  27410. m.content = nil
  27411. }
  27412. // SetOrganizationID sets the "organization_id" field.
  27413. func (m *TutorialMutation) SetOrganizationID(u uint64) {
  27414. m.organization_id = &u
  27415. m.addorganization_id = nil
  27416. }
  27417. // OrganizationID returns the value of the "organization_id" field in the mutation.
  27418. func (m *TutorialMutation) OrganizationID() (r uint64, exists bool) {
  27419. v := m.organization_id
  27420. if v == nil {
  27421. return
  27422. }
  27423. return *v, true
  27424. }
  27425. // OldOrganizationID returns the old "organization_id" field's value of the Tutorial entity.
  27426. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  27427. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27428. func (m *TutorialMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  27429. if !m.op.Is(OpUpdateOne) {
  27430. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  27431. }
  27432. if m.id == nil || m.oldValue == nil {
  27433. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  27434. }
  27435. oldValue, err := m.oldValue(ctx)
  27436. if err != nil {
  27437. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  27438. }
  27439. return oldValue.OrganizationID, nil
  27440. }
  27441. // AddOrganizationID adds u to the "organization_id" field.
  27442. func (m *TutorialMutation) AddOrganizationID(u int64) {
  27443. if m.addorganization_id != nil {
  27444. *m.addorganization_id += u
  27445. } else {
  27446. m.addorganization_id = &u
  27447. }
  27448. }
  27449. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  27450. func (m *TutorialMutation) AddedOrganizationID() (r int64, exists bool) {
  27451. v := m.addorganization_id
  27452. if v == nil {
  27453. return
  27454. }
  27455. return *v, true
  27456. }
  27457. // ResetOrganizationID resets all changes to the "organization_id" field.
  27458. func (m *TutorialMutation) ResetOrganizationID() {
  27459. m.organization_id = nil
  27460. m.addorganization_id = nil
  27461. }
  27462. // ClearEmployee clears the "employee" edge to the Employee entity.
  27463. func (m *TutorialMutation) ClearEmployee() {
  27464. m.clearedemployee = true
  27465. m.clearedFields[tutorial.FieldEmployeeID] = struct{}{}
  27466. }
  27467. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  27468. func (m *TutorialMutation) EmployeeCleared() bool {
  27469. return m.clearedemployee
  27470. }
  27471. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  27472. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  27473. // EmployeeID instead. It exists only for internal usage by the builders.
  27474. func (m *TutorialMutation) EmployeeIDs() (ids []uint64) {
  27475. if id := m.employee; id != nil {
  27476. ids = append(ids, *id)
  27477. }
  27478. return
  27479. }
  27480. // ResetEmployee resets all changes to the "employee" edge.
  27481. func (m *TutorialMutation) ResetEmployee() {
  27482. m.employee = nil
  27483. m.clearedemployee = false
  27484. }
  27485. // Where appends a list predicates to the TutorialMutation builder.
  27486. func (m *TutorialMutation) Where(ps ...predicate.Tutorial) {
  27487. m.predicates = append(m.predicates, ps...)
  27488. }
  27489. // WhereP appends storage-level predicates to the TutorialMutation builder. Using this method,
  27490. // users can use type-assertion to append predicates that do not depend on any generated package.
  27491. func (m *TutorialMutation) WhereP(ps ...func(*sql.Selector)) {
  27492. p := make([]predicate.Tutorial, len(ps))
  27493. for i := range ps {
  27494. p[i] = ps[i]
  27495. }
  27496. m.Where(p...)
  27497. }
  27498. // Op returns the operation name.
  27499. func (m *TutorialMutation) Op() Op {
  27500. return m.op
  27501. }
  27502. // SetOp allows setting the mutation operation.
  27503. func (m *TutorialMutation) SetOp(op Op) {
  27504. m.op = op
  27505. }
  27506. // Type returns the node type of this mutation (Tutorial).
  27507. func (m *TutorialMutation) Type() string {
  27508. return m.typ
  27509. }
  27510. // Fields returns all fields that were changed during this mutation. Note that in
  27511. // order to get all numeric fields that were incremented/decremented, call
  27512. // AddedFields().
  27513. func (m *TutorialMutation) Fields() []string {
  27514. fields := make([]string, 0, 8)
  27515. if m.created_at != nil {
  27516. fields = append(fields, tutorial.FieldCreatedAt)
  27517. }
  27518. if m.updated_at != nil {
  27519. fields = append(fields, tutorial.FieldUpdatedAt)
  27520. }
  27521. if m.deleted_at != nil {
  27522. fields = append(fields, tutorial.FieldDeletedAt)
  27523. }
  27524. if m.employee != nil {
  27525. fields = append(fields, tutorial.FieldEmployeeID)
  27526. }
  27527. if m.index != nil {
  27528. fields = append(fields, tutorial.FieldIndex)
  27529. }
  27530. if m.title != nil {
  27531. fields = append(fields, tutorial.FieldTitle)
  27532. }
  27533. if m.content != nil {
  27534. fields = append(fields, tutorial.FieldContent)
  27535. }
  27536. if m.organization_id != nil {
  27537. fields = append(fields, tutorial.FieldOrganizationID)
  27538. }
  27539. return fields
  27540. }
  27541. // Field returns the value of a field with the given name. The second boolean
  27542. // return value indicates that this field was not set, or was not defined in the
  27543. // schema.
  27544. func (m *TutorialMutation) Field(name string) (ent.Value, bool) {
  27545. switch name {
  27546. case tutorial.FieldCreatedAt:
  27547. return m.CreatedAt()
  27548. case tutorial.FieldUpdatedAt:
  27549. return m.UpdatedAt()
  27550. case tutorial.FieldDeletedAt:
  27551. return m.DeletedAt()
  27552. case tutorial.FieldEmployeeID:
  27553. return m.EmployeeID()
  27554. case tutorial.FieldIndex:
  27555. return m.Index()
  27556. case tutorial.FieldTitle:
  27557. return m.Title()
  27558. case tutorial.FieldContent:
  27559. return m.Content()
  27560. case tutorial.FieldOrganizationID:
  27561. return m.OrganizationID()
  27562. }
  27563. return nil, false
  27564. }
  27565. // OldField returns the old value of the field from the database. An error is
  27566. // returned if the mutation operation is not UpdateOne, or the query to the
  27567. // database failed.
  27568. func (m *TutorialMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  27569. switch name {
  27570. case tutorial.FieldCreatedAt:
  27571. return m.OldCreatedAt(ctx)
  27572. case tutorial.FieldUpdatedAt:
  27573. return m.OldUpdatedAt(ctx)
  27574. case tutorial.FieldDeletedAt:
  27575. return m.OldDeletedAt(ctx)
  27576. case tutorial.FieldEmployeeID:
  27577. return m.OldEmployeeID(ctx)
  27578. case tutorial.FieldIndex:
  27579. return m.OldIndex(ctx)
  27580. case tutorial.FieldTitle:
  27581. return m.OldTitle(ctx)
  27582. case tutorial.FieldContent:
  27583. return m.OldContent(ctx)
  27584. case tutorial.FieldOrganizationID:
  27585. return m.OldOrganizationID(ctx)
  27586. }
  27587. return nil, fmt.Errorf("unknown Tutorial field %s", name)
  27588. }
  27589. // SetField sets the value of a field with the given name. It returns an error if
  27590. // the field is not defined in the schema, or if the type mismatched the field
  27591. // type.
  27592. func (m *TutorialMutation) SetField(name string, value ent.Value) error {
  27593. switch name {
  27594. case tutorial.FieldCreatedAt:
  27595. v, ok := value.(time.Time)
  27596. if !ok {
  27597. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27598. }
  27599. m.SetCreatedAt(v)
  27600. return nil
  27601. case tutorial.FieldUpdatedAt:
  27602. v, ok := value.(time.Time)
  27603. if !ok {
  27604. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27605. }
  27606. m.SetUpdatedAt(v)
  27607. return nil
  27608. case tutorial.FieldDeletedAt:
  27609. v, ok := value.(time.Time)
  27610. if !ok {
  27611. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27612. }
  27613. m.SetDeletedAt(v)
  27614. return nil
  27615. case tutorial.FieldEmployeeID:
  27616. v, ok := value.(uint64)
  27617. if !ok {
  27618. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27619. }
  27620. m.SetEmployeeID(v)
  27621. return nil
  27622. case tutorial.FieldIndex:
  27623. v, ok := value.(int)
  27624. if !ok {
  27625. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27626. }
  27627. m.SetIndex(v)
  27628. return nil
  27629. case tutorial.FieldTitle:
  27630. v, ok := value.(string)
  27631. if !ok {
  27632. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27633. }
  27634. m.SetTitle(v)
  27635. return nil
  27636. case tutorial.FieldContent:
  27637. v, ok := value.(string)
  27638. if !ok {
  27639. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27640. }
  27641. m.SetContent(v)
  27642. return nil
  27643. case tutorial.FieldOrganizationID:
  27644. v, ok := value.(uint64)
  27645. if !ok {
  27646. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27647. }
  27648. m.SetOrganizationID(v)
  27649. return nil
  27650. }
  27651. return fmt.Errorf("unknown Tutorial field %s", name)
  27652. }
  27653. // AddedFields returns all numeric fields that were incremented/decremented during
  27654. // this mutation.
  27655. func (m *TutorialMutation) AddedFields() []string {
  27656. var fields []string
  27657. if m.addindex != nil {
  27658. fields = append(fields, tutorial.FieldIndex)
  27659. }
  27660. if m.addorganization_id != nil {
  27661. fields = append(fields, tutorial.FieldOrganizationID)
  27662. }
  27663. return fields
  27664. }
  27665. // AddedField returns the numeric value that was incremented/decremented on a field
  27666. // with the given name. The second boolean return value indicates that this field
  27667. // was not set, or was not defined in the schema.
  27668. func (m *TutorialMutation) AddedField(name string) (ent.Value, bool) {
  27669. switch name {
  27670. case tutorial.FieldIndex:
  27671. return m.AddedIndex()
  27672. case tutorial.FieldOrganizationID:
  27673. return m.AddedOrganizationID()
  27674. }
  27675. return nil, false
  27676. }
  27677. // AddField adds the value to the field with the given name. It returns an error if
  27678. // the field is not defined in the schema, or if the type mismatched the field
  27679. // type.
  27680. func (m *TutorialMutation) AddField(name string, value ent.Value) error {
  27681. switch name {
  27682. case tutorial.FieldIndex:
  27683. v, ok := value.(int)
  27684. if !ok {
  27685. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27686. }
  27687. m.AddIndex(v)
  27688. return nil
  27689. case tutorial.FieldOrganizationID:
  27690. v, ok := value.(int64)
  27691. if !ok {
  27692. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27693. }
  27694. m.AddOrganizationID(v)
  27695. return nil
  27696. }
  27697. return fmt.Errorf("unknown Tutorial numeric field %s", name)
  27698. }
  27699. // ClearedFields returns all nullable fields that were cleared during this
  27700. // mutation.
  27701. func (m *TutorialMutation) ClearedFields() []string {
  27702. var fields []string
  27703. if m.FieldCleared(tutorial.FieldDeletedAt) {
  27704. fields = append(fields, tutorial.FieldDeletedAt)
  27705. }
  27706. return fields
  27707. }
  27708. // FieldCleared returns a boolean indicating if a field with the given name was
  27709. // cleared in this mutation.
  27710. func (m *TutorialMutation) FieldCleared(name string) bool {
  27711. _, ok := m.clearedFields[name]
  27712. return ok
  27713. }
  27714. // ClearField clears the value of the field with the given name. It returns an
  27715. // error if the field is not defined in the schema.
  27716. func (m *TutorialMutation) ClearField(name string) error {
  27717. switch name {
  27718. case tutorial.FieldDeletedAt:
  27719. m.ClearDeletedAt()
  27720. return nil
  27721. }
  27722. return fmt.Errorf("unknown Tutorial nullable field %s", name)
  27723. }
  27724. // ResetField resets all changes in the mutation for the field with the given name.
  27725. // It returns an error if the field is not defined in the schema.
  27726. func (m *TutorialMutation) ResetField(name string) error {
  27727. switch name {
  27728. case tutorial.FieldCreatedAt:
  27729. m.ResetCreatedAt()
  27730. return nil
  27731. case tutorial.FieldUpdatedAt:
  27732. m.ResetUpdatedAt()
  27733. return nil
  27734. case tutorial.FieldDeletedAt:
  27735. m.ResetDeletedAt()
  27736. return nil
  27737. case tutorial.FieldEmployeeID:
  27738. m.ResetEmployeeID()
  27739. return nil
  27740. case tutorial.FieldIndex:
  27741. m.ResetIndex()
  27742. return nil
  27743. case tutorial.FieldTitle:
  27744. m.ResetTitle()
  27745. return nil
  27746. case tutorial.FieldContent:
  27747. m.ResetContent()
  27748. return nil
  27749. case tutorial.FieldOrganizationID:
  27750. m.ResetOrganizationID()
  27751. return nil
  27752. }
  27753. return fmt.Errorf("unknown Tutorial field %s", name)
  27754. }
  27755. // AddedEdges returns all edge names that were set/added in this mutation.
  27756. func (m *TutorialMutation) AddedEdges() []string {
  27757. edges := make([]string, 0, 1)
  27758. if m.employee != nil {
  27759. edges = append(edges, tutorial.EdgeEmployee)
  27760. }
  27761. return edges
  27762. }
  27763. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  27764. // name in this mutation.
  27765. func (m *TutorialMutation) AddedIDs(name string) []ent.Value {
  27766. switch name {
  27767. case tutorial.EdgeEmployee:
  27768. if id := m.employee; id != nil {
  27769. return []ent.Value{*id}
  27770. }
  27771. }
  27772. return nil
  27773. }
  27774. // RemovedEdges returns all edge names that were removed in this mutation.
  27775. func (m *TutorialMutation) RemovedEdges() []string {
  27776. edges := make([]string, 0, 1)
  27777. return edges
  27778. }
  27779. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  27780. // the given name in this mutation.
  27781. func (m *TutorialMutation) RemovedIDs(name string) []ent.Value {
  27782. return nil
  27783. }
  27784. // ClearedEdges returns all edge names that were cleared in this mutation.
  27785. func (m *TutorialMutation) ClearedEdges() []string {
  27786. edges := make([]string, 0, 1)
  27787. if m.clearedemployee {
  27788. edges = append(edges, tutorial.EdgeEmployee)
  27789. }
  27790. return edges
  27791. }
  27792. // EdgeCleared returns a boolean which indicates if the edge with the given name
  27793. // was cleared in this mutation.
  27794. func (m *TutorialMutation) EdgeCleared(name string) bool {
  27795. switch name {
  27796. case tutorial.EdgeEmployee:
  27797. return m.clearedemployee
  27798. }
  27799. return false
  27800. }
  27801. // ClearEdge clears the value of the edge with the given name. It returns an error
  27802. // if that edge is not defined in the schema.
  27803. func (m *TutorialMutation) ClearEdge(name string) error {
  27804. switch name {
  27805. case tutorial.EdgeEmployee:
  27806. m.ClearEmployee()
  27807. return nil
  27808. }
  27809. return fmt.Errorf("unknown Tutorial unique edge %s", name)
  27810. }
  27811. // ResetEdge resets all changes to the edge with the given name in this mutation.
  27812. // It returns an error if the edge is not defined in the schema.
  27813. func (m *TutorialMutation) ResetEdge(name string) error {
  27814. switch name {
  27815. case tutorial.EdgeEmployee:
  27816. m.ResetEmployee()
  27817. return nil
  27818. }
  27819. return fmt.Errorf("unknown Tutorial edge %s", name)
  27820. }
  27821. // UsageDetailMutation represents an operation that mutates the UsageDetail nodes in the graph.
  27822. type UsageDetailMutation struct {
  27823. config
  27824. op Op
  27825. typ string
  27826. id *uint64
  27827. created_at *time.Time
  27828. updated_at *time.Time
  27829. status *uint8
  27830. addstatus *int8
  27831. _type *int
  27832. add_type *int
  27833. bot_id *string
  27834. receiver_id *string
  27835. app *int
  27836. addapp *int
  27837. session_id *uint64
  27838. addsession_id *int64
  27839. request *string
  27840. response *string
  27841. original_data *custom_types.OriginalData
  27842. total_tokens *uint64
  27843. addtotal_tokens *int64
  27844. prompt_tokens *uint64
  27845. addprompt_tokens *int64
  27846. completion_tokens *uint64
  27847. addcompletion_tokens *int64
  27848. organization_id *uint64
  27849. addorganization_id *int64
  27850. clearedFields map[string]struct{}
  27851. done bool
  27852. oldValue func(context.Context) (*UsageDetail, error)
  27853. predicates []predicate.UsageDetail
  27854. }
  27855. var _ ent.Mutation = (*UsageDetailMutation)(nil)
  27856. // usagedetailOption allows management of the mutation configuration using functional options.
  27857. type usagedetailOption func(*UsageDetailMutation)
  27858. // newUsageDetailMutation creates new mutation for the UsageDetail entity.
  27859. func newUsageDetailMutation(c config, op Op, opts ...usagedetailOption) *UsageDetailMutation {
  27860. m := &UsageDetailMutation{
  27861. config: c,
  27862. op: op,
  27863. typ: TypeUsageDetail,
  27864. clearedFields: make(map[string]struct{}),
  27865. }
  27866. for _, opt := range opts {
  27867. opt(m)
  27868. }
  27869. return m
  27870. }
  27871. // withUsageDetailID sets the ID field of the mutation.
  27872. func withUsageDetailID(id uint64) usagedetailOption {
  27873. return func(m *UsageDetailMutation) {
  27874. var (
  27875. err error
  27876. once sync.Once
  27877. value *UsageDetail
  27878. )
  27879. m.oldValue = func(ctx context.Context) (*UsageDetail, error) {
  27880. once.Do(func() {
  27881. if m.done {
  27882. err = errors.New("querying old values post mutation is not allowed")
  27883. } else {
  27884. value, err = m.Client().UsageDetail.Get(ctx, id)
  27885. }
  27886. })
  27887. return value, err
  27888. }
  27889. m.id = &id
  27890. }
  27891. }
  27892. // withUsageDetail sets the old UsageDetail of the mutation.
  27893. func withUsageDetail(node *UsageDetail) usagedetailOption {
  27894. return func(m *UsageDetailMutation) {
  27895. m.oldValue = func(context.Context) (*UsageDetail, error) {
  27896. return node, nil
  27897. }
  27898. m.id = &node.ID
  27899. }
  27900. }
  27901. // Client returns a new `ent.Client` from the mutation. If the mutation was
  27902. // executed in a transaction (ent.Tx), a transactional client is returned.
  27903. func (m UsageDetailMutation) Client() *Client {
  27904. client := &Client{config: m.config}
  27905. client.init()
  27906. return client
  27907. }
  27908. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  27909. // it returns an error otherwise.
  27910. func (m UsageDetailMutation) Tx() (*Tx, error) {
  27911. if _, ok := m.driver.(*txDriver); !ok {
  27912. return nil, errors.New("ent: mutation is not running in a transaction")
  27913. }
  27914. tx := &Tx{config: m.config}
  27915. tx.init()
  27916. return tx, nil
  27917. }
  27918. // SetID sets the value of the id field. Note that this
  27919. // operation is only accepted on creation of UsageDetail entities.
  27920. func (m *UsageDetailMutation) SetID(id uint64) {
  27921. m.id = &id
  27922. }
  27923. // ID returns the ID value in the mutation. Note that the ID is only available
  27924. // if it was provided to the builder or after it was returned from the database.
  27925. func (m *UsageDetailMutation) ID() (id uint64, exists bool) {
  27926. if m.id == nil {
  27927. return
  27928. }
  27929. return *m.id, true
  27930. }
  27931. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  27932. // That means, if the mutation is applied within a transaction with an isolation level such
  27933. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  27934. // or updated by the mutation.
  27935. func (m *UsageDetailMutation) IDs(ctx context.Context) ([]uint64, error) {
  27936. switch {
  27937. case m.op.Is(OpUpdateOne | OpDeleteOne):
  27938. id, exists := m.ID()
  27939. if exists {
  27940. return []uint64{id}, nil
  27941. }
  27942. fallthrough
  27943. case m.op.Is(OpUpdate | OpDelete):
  27944. return m.Client().UsageDetail.Query().Where(m.predicates...).IDs(ctx)
  27945. default:
  27946. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  27947. }
  27948. }
  27949. // SetCreatedAt sets the "created_at" field.
  27950. func (m *UsageDetailMutation) SetCreatedAt(t time.Time) {
  27951. m.created_at = &t
  27952. }
  27953. // CreatedAt returns the value of the "created_at" field in the mutation.
  27954. func (m *UsageDetailMutation) CreatedAt() (r time.Time, exists bool) {
  27955. v := m.created_at
  27956. if v == nil {
  27957. return
  27958. }
  27959. return *v, true
  27960. }
  27961. // OldCreatedAt returns the old "created_at" field's value of the UsageDetail entity.
  27962. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27963. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27964. func (m *UsageDetailMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  27965. if !m.op.Is(OpUpdateOne) {
  27966. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  27967. }
  27968. if m.id == nil || m.oldValue == nil {
  27969. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  27970. }
  27971. oldValue, err := m.oldValue(ctx)
  27972. if err != nil {
  27973. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  27974. }
  27975. return oldValue.CreatedAt, nil
  27976. }
  27977. // ResetCreatedAt resets all changes to the "created_at" field.
  27978. func (m *UsageDetailMutation) ResetCreatedAt() {
  27979. m.created_at = nil
  27980. }
  27981. // SetUpdatedAt sets the "updated_at" field.
  27982. func (m *UsageDetailMutation) SetUpdatedAt(t time.Time) {
  27983. m.updated_at = &t
  27984. }
  27985. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  27986. func (m *UsageDetailMutation) UpdatedAt() (r time.Time, exists bool) {
  27987. v := m.updated_at
  27988. if v == nil {
  27989. return
  27990. }
  27991. return *v, true
  27992. }
  27993. // OldUpdatedAt returns the old "updated_at" field's value of the UsageDetail entity.
  27994. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27995. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27996. func (m *UsageDetailMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  27997. if !m.op.Is(OpUpdateOne) {
  27998. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  27999. }
  28000. if m.id == nil || m.oldValue == nil {
  28001. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  28002. }
  28003. oldValue, err := m.oldValue(ctx)
  28004. if err != nil {
  28005. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  28006. }
  28007. return oldValue.UpdatedAt, nil
  28008. }
  28009. // ResetUpdatedAt resets all changes to the "updated_at" field.
  28010. func (m *UsageDetailMutation) ResetUpdatedAt() {
  28011. m.updated_at = nil
  28012. }
  28013. // SetStatus sets the "status" field.
  28014. func (m *UsageDetailMutation) SetStatus(u uint8) {
  28015. m.status = &u
  28016. m.addstatus = nil
  28017. }
  28018. // Status returns the value of the "status" field in the mutation.
  28019. func (m *UsageDetailMutation) Status() (r uint8, exists bool) {
  28020. v := m.status
  28021. if v == nil {
  28022. return
  28023. }
  28024. return *v, true
  28025. }
  28026. // OldStatus returns the old "status" field's value of the UsageDetail entity.
  28027. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  28028. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28029. func (m *UsageDetailMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  28030. if !m.op.Is(OpUpdateOne) {
  28031. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  28032. }
  28033. if m.id == nil || m.oldValue == nil {
  28034. return v, errors.New("OldStatus requires an ID field in the mutation")
  28035. }
  28036. oldValue, err := m.oldValue(ctx)
  28037. if err != nil {
  28038. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  28039. }
  28040. return oldValue.Status, nil
  28041. }
  28042. // AddStatus adds u to the "status" field.
  28043. func (m *UsageDetailMutation) AddStatus(u int8) {
  28044. if m.addstatus != nil {
  28045. *m.addstatus += u
  28046. } else {
  28047. m.addstatus = &u
  28048. }
  28049. }
  28050. // AddedStatus returns the value that was added to the "status" field in this mutation.
  28051. func (m *UsageDetailMutation) AddedStatus() (r int8, exists bool) {
  28052. v := m.addstatus
  28053. if v == nil {
  28054. return
  28055. }
  28056. return *v, true
  28057. }
  28058. // ClearStatus clears the value of the "status" field.
  28059. func (m *UsageDetailMutation) ClearStatus() {
  28060. m.status = nil
  28061. m.addstatus = nil
  28062. m.clearedFields[usagedetail.FieldStatus] = struct{}{}
  28063. }
  28064. // StatusCleared returns if the "status" field was cleared in this mutation.
  28065. func (m *UsageDetailMutation) StatusCleared() bool {
  28066. _, ok := m.clearedFields[usagedetail.FieldStatus]
  28067. return ok
  28068. }
  28069. // ResetStatus resets all changes to the "status" field.
  28070. func (m *UsageDetailMutation) ResetStatus() {
  28071. m.status = nil
  28072. m.addstatus = nil
  28073. delete(m.clearedFields, usagedetail.FieldStatus)
  28074. }
  28075. // SetType sets the "type" field.
  28076. func (m *UsageDetailMutation) SetType(i int) {
  28077. m._type = &i
  28078. m.add_type = nil
  28079. }
  28080. // GetType returns the value of the "type" field in the mutation.
  28081. func (m *UsageDetailMutation) GetType() (r int, exists bool) {
  28082. v := m._type
  28083. if v == nil {
  28084. return
  28085. }
  28086. return *v, true
  28087. }
  28088. // OldType returns the old "type" field's value of the UsageDetail entity.
  28089. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  28090. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28091. func (m *UsageDetailMutation) OldType(ctx context.Context) (v int, err error) {
  28092. if !m.op.Is(OpUpdateOne) {
  28093. return v, errors.New("OldType is only allowed on UpdateOne operations")
  28094. }
  28095. if m.id == nil || m.oldValue == nil {
  28096. return v, errors.New("OldType requires an ID field in the mutation")
  28097. }
  28098. oldValue, err := m.oldValue(ctx)
  28099. if err != nil {
  28100. return v, fmt.Errorf("querying old value for OldType: %w", err)
  28101. }
  28102. return oldValue.Type, nil
  28103. }
  28104. // AddType adds i to the "type" field.
  28105. func (m *UsageDetailMutation) AddType(i int) {
  28106. if m.add_type != nil {
  28107. *m.add_type += i
  28108. } else {
  28109. m.add_type = &i
  28110. }
  28111. }
  28112. // AddedType returns the value that was added to the "type" field in this mutation.
  28113. func (m *UsageDetailMutation) AddedType() (r int, exists bool) {
  28114. v := m.add_type
  28115. if v == nil {
  28116. return
  28117. }
  28118. return *v, true
  28119. }
  28120. // ClearType clears the value of the "type" field.
  28121. func (m *UsageDetailMutation) ClearType() {
  28122. m._type = nil
  28123. m.add_type = nil
  28124. m.clearedFields[usagedetail.FieldType] = struct{}{}
  28125. }
  28126. // TypeCleared returns if the "type" field was cleared in this mutation.
  28127. func (m *UsageDetailMutation) TypeCleared() bool {
  28128. _, ok := m.clearedFields[usagedetail.FieldType]
  28129. return ok
  28130. }
  28131. // ResetType resets all changes to the "type" field.
  28132. func (m *UsageDetailMutation) ResetType() {
  28133. m._type = nil
  28134. m.add_type = nil
  28135. delete(m.clearedFields, usagedetail.FieldType)
  28136. }
  28137. // SetBotID sets the "bot_id" field.
  28138. func (m *UsageDetailMutation) SetBotID(s string) {
  28139. m.bot_id = &s
  28140. }
  28141. // BotID returns the value of the "bot_id" field in the mutation.
  28142. func (m *UsageDetailMutation) BotID() (r string, exists bool) {
  28143. v := m.bot_id
  28144. if v == nil {
  28145. return
  28146. }
  28147. return *v, true
  28148. }
  28149. // OldBotID returns the old "bot_id" field's value of the UsageDetail entity.
  28150. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  28151. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28152. func (m *UsageDetailMutation) OldBotID(ctx context.Context) (v string, err error) {
  28153. if !m.op.Is(OpUpdateOne) {
  28154. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  28155. }
  28156. if m.id == nil || m.oldValue == nil {
  28157. return v, errors.New("OldBotID requires an ID field in the mutation")
  28158. }
  28159. oldValue, err := m.oldValue(ctx)
  28160. if err != nil {
  28161. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  28162. }
  28163. return oldValue.BotID, nil
  28164. }
  28165. // ResetBotID resets all changes to the "bot_id" field.
  28166. func (m *UsageDetailMutation) ResetBotID() {
  28167. m.bot_id = nil
  28168. }
  28169. // SetReceiverID sets the "receiver_id" field.
  28170. func (m *UsageDetailMutation) SetReceiverID(s string) {
  28171. m.receiver_id = &s
  28172. }
  28173. // ReceiverID returns the value of the "receiver_id" field in the mutation.
  28174. func (m *UsageDetailMutation) ReceiverID() (r string, exists bool) {
  28175. v := m.receiver_id
  28176. if v == nil {
  28177. return
  28178. }
  28179. return *v, true
  28180. }
  28181. // OldReceiverID returns the old "receiver_id" field's value of the UsageDetail entity.
  28182. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  28183. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28184. func (m *UsageDetailMutation) OldReceiverID(ctx context.Context) (v string, err error) {
  28185. if !m.op.Is(OpUpdateOne) {
  28186. return v, errors.New("OldReceiverID is only allowed on UpdateOne operations")
  28187. }
  28188. if m.id == nil || m.oldValue == nil {
  28189. return v, errors.New("OldReceiverID requires an ID field in the mutation")
  28190. }
  28191. oldValue, err := m.oldValue(ctx)
  28192. if err != nil {
  28193. return v, fmt.Errorf("querying old value for OldReceiverID: %w", err)
  28194. }
  28195. return oldValue.ReceiverID, nil
  28196. }
  28197. // ResetReceiverID resets all changes to the "receiver_id" field.
  28198. func (m *UsageDetailMutation) ResetReceiverID() {
  28199. m.receiver_id = nil
  28200. }
  28201. // SetApp sets the "app" field.
  28202. func (m *UsageDetailMutation) SetApp(i int) {
  28203. m.app = &i
  28204. m.addapp = nil
  28205. }
  28206. // App returns the value of the "app" field in the mutation.
  28207. func (m *UsageDetailMutation) App() (r int, exists bool) {
  28208. v := m.app
  28209. if v == nil {
  28210. return
  28211. }
  28212. return *v, true
  28213. }
  28214. // OldApp returns the old "app" field's value of the UsageDetail entity.
  28215. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  28216. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28217. func (m *UsageDetailMutation) OldApp(ctx context.Context) (v int, err error) {
  28218. if !m.op.Is(OpUpdateOne) {
  28219. return v, errors.New("OldApp is only allowed on UpdateOne operations")
  28220. }
  28221. if m.id == nil || m.oldValue == nil {
  28222. return v, errors.New("OldApp requires an ID field in the mutation")
  28223. }
  28224. oldValue, err := m.oldValue(ctx)
  28225. if err != nil {
  28226. return v, fmt.Errorf("querying old value for OldApp: %w", err)
  28227. }
  28228. return oldValue.App, nil
  28229. }
  28230. // AddApp adds i to the "app" field.
  28231. func (m *UsageDetailMutation) AddApp(i int) {
  28232. if m.addapp != nil {
  28233. *m.addapp += i
  28234. } else {
  28235. m.addapp = &i
  28236. }
  28237. }
  28238. // AddedApp returns the value that was added to the "app" field in this mutation.
  28239. func (m *UsageDetailMutation) AddedApp() (r int, exists bool) {
  28240. v := m.addapp
  28241. if v == nil {
  28242. return
  28243. }
  28244. return *v, true
  28245. }
  28246. // ClearApp clears the value of the "app" field.
  28247. func (m *UsageDetailMutation) ClearApp() {
  28248. m.app = nil
  28249. m.addapp = nil
  28250. m.clearedFields[usagedetail.FieldApp] = struct{}{}
  28251. }
  28252. // AppCleared returns if the "app" field was cleared in this mutation.
  28253. func (m *UsageDetailMutation) AppCleared() bool {
  28254. _, ok := m.clearedFields[usagedetail.FieldApp]
  28255. return ok
  28256. }
  28257. // ResetApp resets all changes to the "app" field.
  28258. func (m *UsageDetailMutation) ResetApp() {
  28259. m.app = nil
  28260. m.addapp = nil
  28261. delete(m.clearedFields, usagedetail.FieldApp)
  28262. }
  28263. // SetSessionID sets the "session_id" field.
  28264. func (m *UsageDetailMutation) SetSessionID(u uint64) {
  28265. m.session_id = &u
  28266. m.addsession_id = nil
  28267. }
  28268. // SessionID returns the value of the "session_id" field in the mutation.
  28269. func (m *UsageDetailMutation) SessionID() (r uint64, exists bool) {
  28270. v := m.session_id
  28271. if v == nil {
  28272. return
  28273. }
  28274. return *v, true
  28275. }
  28276. // OldSessionID returns the old "session_id" field's value of the UsageDetail entity.
  28277. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  28278. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28279. func (m *UsageDetailMutation) OldSessionID(ctx context.Context) (v uint64, err error) {
  28280. if !m.op.Is(OpUpdateOne) {
  28281. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  28282. }
  28283. if m.id == nil || m.oldValue == nil {
  28284. return v, errors.New("OldSessionID requires an ID field in the mutation")
  28285. }
  28286. oldValue, err := m.oldValue(ctx)
  28287. if err != nil {
  28288. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  28289. }
  28290. return oldValue.SessionID, nil
  28291. }
  28292. // AddSessionID adds u to the "session_id" field.
  28293. func (m *UsageDetailMutation) AddSessionID(u int64) {
  28294. if m.addsession_id != nil {
  28295. *m.addsession_id += u
  28296. } else {
  28297. m.addsession_id = &u
  28298. }
  28299. }
  28300. // AddedSessionID returns the value that was added to the "session_id" field in this mutation.
  28301. func (m *UsageDetailMutation) AddedSessionID() (r int64, exists bool) {
  28302. v := m.addsession_id
  28303. if v == nil {
  28304. return
  28305. }
  28306. return *v, true
  28307. }
  28308. // ClearSessionID clears the value of the "session_id" field.
  28309. func (m *UsageDetailMutation) ClearSessionID() {
  28310. m.session_id = nil
  28311. m.addsession_id = nil
  28312. m.clearedFields[usagedetail.FieldSessionID] = struct{}{}
  28313. }
  28314. // SessionIDCleared returns if the "session_id" field was cleared in this mutation.
  28315. func (m *UsageDetailMutation) SessionIDCleared() bool {
  28316. _, ok := m.clearedFields[usagedetail.FieldSessionID]
  28317. return ok
  28318. }
  28319. // ResetSessionID resets all changes to the "session_id" field.
  28320. func (m *UsageDetailMutation) ResetSessionID() {
  28321. m.session_id = nil
  28322. m.addsession_id = nil
  28323. delete(m.clearedFields, usagedetail.FieldSessionID)
  28324. }
  28325. // SetRequest sets the "request" field.
  28326. func (m *UsageDetailMutation) SetRequest(s string) {
  28327. m.request = &s
  28328. }
  28329. // Request returns the value of the "request" field in the mutation.
  28330. func (m *UsageDetailMutation) Request() (r string, exists bool) {
  28331. v := m.request
  28332. if v == nil {
  28333. return
  28334. }
  28335. return *v, true
  28336. }
  28337. // OldRequest returns the old "request" field's value of the UsageDetail entity.
  28338. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  28339. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28340. func (m *UsageDetailMutation) OldRequest(ctx context.Context) (v string, err error) {
  28341. if !m.op.Is(OpUpdateOne) {
  28342. return v, errors.New("OldRequest is only allowed on UpdateOne operations")
  28343. }
  28344. if m.id == nil || m.oldValue == nil {
  28345. return v, errors.New("OldRequest requires an ID field in the mutation")
  28346. }
  28347. oldValue, err := m.oldValue(ctx)
  28348. if err != nil {
  28349. return v, fmt.Errorf("querying old value for OldRequest: %w", err)
  28350. }
  28351. return oldValue.Request, nil
  28352. }
  28353. // ResetRequest resets all changes to the "request" field.
  28354. func (m *UsageDetailMutation) ResetRequest() {
  28355. m.request = nil
  28356. }
  28357. // SetResponse sets the "response" field.
  28358. func (m *UsageDetailMutation) SetResponse(s string) {
  28359. m.response = &s
  28360. }
  28361. // Response returns the value of the "response" field in the mutation.
  28362. func (m *UsageDetailMutation) Response() (r string, exists bool) {
  28363. v := m.response
  28364. if v == nil {
  28365. return
  28366. }
  28367. return *v, true
  28368. }
  28369. // OldResponse returns the old "response" field's value of the UsageDetail entity.
  28370. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  28371. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28372. func (m *UsageDetailMutation) OldResponse(ctx context.Context) (v string, err error) {
  28373. if !m.op.Is(OpUpdateOne) {
  28374. return v, errors.New("OldResponse is only allowed on UpdateOne operations")
  28375. }
  28376. if m.id == nil || m.oldValue == nil {
  28377. return v, errors.New("OldResponse requires an ID field in the mutation")
  28378. }
  28379. oldValue, err := m.oldValue(ctx)
  28380. if err != nil {
  28381. return v, fmt.Errorf("querying old value for OldResponse: %w", err)
  28382. }
  28383. return oldValue.Response, nil
  28384. }
  28385. // ResetResponse resets all changes to the "response" field.
  28386. func (m *UsageDetailMutation) ResetResponse() {
  28387. m.response = nil
  28388. }
  28389. // SetOriginalData sets the "original_data" field.
  28390. func (m *UsageDetailMutation) SetOriginalData(ctd custom_types.OriginalData) {
  28391. m.original_data = &ctd
  28392. }
  28393. // OriginalData returns the value of the "original_data" field in the mutation.
  28394. func (m *UsageDetailMutation) OriginalData() (r custom_types.OriginalData, exists bool) {
  28395. v := m.original_data
  28396. if v == nil {
  28397. return
  28398. }
  28399. return *v, true
  28400. }
  28401. // OldOriginalData returns the old "original_data" field's value of the UsageDetail entity.
  28402. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  28403. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28404. func (m *UsageDetailMutation) OldOriginalData(ctx context.Context) (v custom_types.OriginalData, err error) {
  28405. if !m.op.Is(OpUpdateOne) {
  28406. return v, errors.New("OldOriginalData is only allowed on UpdateOne operations")
  28407. }
  28408. if m.id == nil || m.oldValue == nil {
  28409. return v, errors.New("OldOriginalData requires an ID field in the mutation")
  28410. }
  28411. oldValue, err := m.oldValue(ctx)
  28412. if err != nil {
  28413. return v, fmt.Errorf("querying old value for OldOriginalData: %w", err)
  28414. }
  28415. return oldValue.OriginalData, nil
  28416. }
  28417. // ResetOriginalData resets all changes to the "original_data" field.
  28418. func (m *UsageDetailMutation) ResetOriginalData() {
  28419. m.original_data = nil
  28420. }
  28421. // SetTotalTokens sets the "total_tokens" field.
  28422. func (m *UsageDetailMutation) SetTotalTokens(u uint64) {
  28423. m.total_tokens = &u
  28424. m.addtotal_tokens = nil
  28425. }
  28426. // TotalTokens returns the value of the "total_tokens" field in the mutation.
  28427. func (m *UsageDetailMutation) TotalTokens() (r uint64, exists bool) {
  28428. v := m.total_tokens
  28429. if v == nil {
  28430. return
  28431. }
  28432. return *v, true
  28433. }
  28434. // OldTotalTokens returns the old "total_tokens" field's value of the UsageDetail entity.
  28435. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  28436. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28437. func (m *UsageDetailMutation) OldTotalTokens(ctx context.Context) (v uint64, err error) {
  28438. if !m.op.Is(OpUpdateOne) {
  28439. return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
  28440. }
  28441. if m.id == nil || m.oldValue == nil {
  28442. return v, errors.New("OldTotalTokens requires an ID field in the mutation")
  28443. }
  28444. oldValue, err := m.oldValue(ctx)
  28445. if err != nil {
  28446. return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
  28447. }
  28448. return oldValue.TotalTokens, nil
  28449. }
  28450. // AddTotalTokens adds u to the "total_tokens" field.
  28451. func (m *UsageDetailMutation) AddTotalTokens(u int64) {
  28452. if m.addtotal_tokens != nil {
  28453. *m.addtotal_tokens += u
  28454. } else {
  28455. m.addtotal_tokens = &u
  28456. }
  28457. }
  28458. // AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
  28459. func (m *UsageDetailMutation) AddedTotalTokens() (r int64, exists bool) {
  28460. v := m.addtotal_tokens
  28461. if v == nil {
  28462. return
  28463. }
  28464. return *v, true
  28465. }
  28466. // ClearTotalTokens clears the value of the "total_tokens" field.
  28467. func (m *UsageDetailMutation) ClearTotalTokens() {
  28468. m.total_tokens = nil
  28469. m.addtotal_tokens = nil
  28470. m.clearedFields[usagedetail.FieldTotalTokens] = struct{}{}
  28471. }
  28472. // TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
  28473. func (m *UsageDetailMutation) TotalTokensCleared() bool {
  28474. _, ok := m.clearedFields[usagedetail.FieldTotalTokens]
  28475. return ok
  28476. }
  28477. // ResetTotalTokens resets all changes to the "total_tokens" field.
  28478. func (m *UsageDetailMutation) ResetTotalTokens() {
  28479. m.total_tokens = nil
  28480. m.addtotal_tokens = nil
  28481. delete(m.clearedFields, usagedetail.FieldTotalTokens)
  28482. }
  28483. // SetPromptTokens sets the "prompt_tokens" field.
  28484. func (m *UsageDetailMutation) SetPromptTokens(u uint64) {
  28485. m.prompt_tokens = &u
  28486. m.addprompt_tokens = nil
  28487. }
  28488. // PromptTokens returns the value of the "prompt_tokens" field in the mutation.
  28489. func (m *UsageDetailMutation) PromptTokens() (r uint64, exists bool) {
  28490. v := m.prompt_tokens
  28491. if v == nil {
  28492. return
  28493. }
  28494. return *v, true
  28495. }
  28496. // OldPromptTokens returns the old "prompt_tokens" field's value of the UsageDetail entity.
  28497. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  28498. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28499. func (m *UsageDetailMutation) OldPromptTokens(ctx context.Context) (v uint64, err error) {
  28500. if !m.op.Is(OpUpdateOne) {
  28501. return v, errors.New("OldPromptTokens is only allowed on UpdateOne operations")
  28502. }
  28503. if m.id == nil || m.oldValue == nil {
  28504. return v, errors.New("OldPromptTokens requires an ID field in the mutation")
  28505. }
  28506. oldValue, err := m.oldValue(ctx)
  28507. if err != nil {
  28508. return v, fmt.Errorf("querying old value for OldPromptTokens: %w", err)
  28509. }
  28510. return oldValue.PromptTokens, nil
  28511. }
  28512. // AddPromptTokens adds u to the "prompt_tokens" field.
  28513. func (m *UsageDetailMutation) AddPromptTokens(u int64) {
  28514. if m.addprompt_tokens != nil {
  28515. *m.addprompt_tokens += u
  28516. } else {
  28517. m.addprompt_tokens = &u
  28518. }
  28519. }
  28520. // AddedPromptTokens returns the value that was added to the "prompt_tokens" field in this mutation.
  28521. func (m *UsageDetailMutation) AddedPromptTokens() (r int64, exists bool) {
  28522. v := m.addprompt_tokens
  28523. if v == nil {
  28524. return
  28525. }
  28526. return *v, true
  28527. }
  28528. // ClearPromptTokens clears the value of the "prompt_tokens" field.
  28529. func (m *UsageDetailMutation) ClearPromptTokens() {
  28530. m.prompt_tokens = nil
  28531. m.addprompt_tokens = nil
  28532. m.clearedFields[usagedetail.FieldPromptTokens] = struct{}{}
  28533. }
  28534. // PromptTokensCleared returns if the "prompt_tokens" field was cleared in this mutation.
  28535. func (m *UsageDetailMutation) PromptTokensCleared() bool {
  28536. _, ok := m.clearedFields[usagedetail.FieldPromptTokens]
  28537. return ok
  28538. }
  28539. // ResetPromptTokens resets all changes to the "prompt_tokens" field.
  28540. func (m *UsageDetailMutation) ResetPromptTokens() {
  28541. m.prompt_tokens = nil
  28542. m.addprompt_tokens = nil
  28543. delete(m.clearedFields, usagedetail.FieldPromptTokens)
  28544. }
  28545. // SetCompletionTokens sets the "completion_tokens" field.
  28546. func (m *UsageDetailMutation) SetCompletionTokens(u uint64) {
  28547. m.completion_tokens = &u
  28548. m.addcompletion_tokens = nil
  28549. }
  28550. // CompletionTokens returns the value of the "completion_tokens" field in the mutation.
  28551. func (m *UsageDetailMutation) CompletionTokens() (r uint64, exists bool) {
  28552. v := m.completion_tokens
  28553. if v == nil {
  28554. return
  28555. }
  28556. return *v, true
  28557. }
  28558. // OldCompletionTokens returns the old "completion_tokens" field's value of the UsageDetail entity.
  28559. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  28560. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28561. func (m *UsageDetailMutation) OldCompletionTokens(ctx context.Context) (v uint64, err error) {
  28562. if !m.op.Is(OpUpdateOne) {
  28563. return v, errors.New("OldCompletionTokens is only allowed on UpdateOne operations")
  28564. }
  28565. if m.id == nil || m.oldValue == nil {
  28566. return v, errors.New("OldCompletionTokens requires an ID field in the mutation")
  28567. }
  28568. oldValue, err := m.oldValue(ctx)
  28569. if err != nil {
  28570. return v, fmt.Errorf("querying old value for OldCompletionTokens: %w", err)
  28571. }
  28572. return oldValue.CompletionTokens, nil
  28573. }
  28574. // AddCompletionTokens adds u to the "completion_tokens" field.
  28575. func (m *UsageDetailMutation) AddCompletionTokens(u int64) {
  28576. if m.addcompletion_tokens != nil {
  28577. *m.addcompletion_tokens += u
  28578. } else {
  28579. m.addcompletion_tokens = &u
  28580. }
  28581. }
  28582. // AddedCompletionTokens returns the value that was added to the "completion_tokens" field in this mutation.
  28583. func (m *UsageDetailMutation) AddedCompletionTokens() (r int64, exists bool) {
  28584. v := m.addcompletion_tokens
  28585. if v == nil {
  28586. return
  28587. }
  28588. return *v, true
  28589. }
  28590. // ClearCompletionTokens clears the value of the "completion_tokens" field.
  28591. func (m *UsageDetailMutation) ClearCompletionTokens() {
  28592. m.completion_tokens = nil
  28593. m.addcompletion_tokens = nil
  28594. m.clearedFields[usagedetail.FieldCompletionTokens] = struct{}{}
  28595. }
  28596. // CompletionTokensCleared returns if the "completion_tokens" field was cleared in this mutation.
  28597. func (m *UsageDetailMutation) CompletionTokensCleared() bool {
  28598. _, ok := m.clearedFields[usagedetail.FieldCompletionTokens]
  28599. return ok
  28600. }
  28601. // ResetCompletionTokens resets all changes to the "completion_tokens" field.
  28602. func (m *UsageDetailMutation) ResetCompletionTokens() {
  28603. m.completion_tokens = nil
  28604. m.addcompletion_tokens = nil
  28605. delete(m.clearedFields, usagedetail.FieldCompletionTokens)
  28606. }
  28607. // SetOrganizationID sets the "organization_id" field.
  28608. func (m *UsageDetailMutation) SetOrganizationID(u uint64) {
  28609. m.organization_id = &u
  28610. m.addorganization_id = nil
  28611. }
  28612. // OrganizationID returns the value of the "organization_id" field in the mutation.
  28613. func (m *UsageDetailMutation) OrganizationID() (r uint64, exists bool) {
  28614. v := m.organization_id
  28615. if v == nil {
  28616. return
  28617. }
  28618. return *v, true
  28619. }
  28620. // OldOrganizationID returns the old "organization_id" field's value of the UsageDetail entity.
  28621. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  28622. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28623. func (m *UsageDetailMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  28624. if !m.op.Is(OpUpdateOne) {
  28625. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  28626. }
  28627. if m.id == nil || m.oldValue == nil {
  28628. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  28629. }
  28630. oldValue, err := m.oldValue(ctx)
  28631. if err != nil {
  28632. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  28633. }
  28634. return oldValue.OrganizationID, nil
  28635. }
  28636. // AddOrganizationID adds u to the "organization_id" field.
  28637. func (m *UsageDetailMutation) AddOrganizationID(u int64) {
  28638. if m.addorganization_id != nil {
  28639. *m.addorganization_id += u
  28640. } else {
  28641. m.addorganization_id = &u
  28642. }
  28643. }
  28644. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  28645. func (m *UsageDetailMutation) AddedOrganizationID() (r int64, exists bool) {
  28646. v := m.addorganization_id
  28647. if v == nil {
  28648. return
  28649. }
  28650. return *v, true
  28651. }
  28652. // ClearOrganizationID clears the value of the "organization_id" field.
  28653. func (m *UsageDetailMutation) ClearOrganizationID() {
  28654. m.organization_id = nil
  28655. m.addorganization_id = nil
  28656. m.clearedFields[usagedetail.FieldOrganizationID] = struct{}{}
  28657. }
  28658. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  28659. func (m *UsageDetailMutation) OrganizationIDCleared() bool {
  28660. _, ok := m.clearedFields[usagedetail.FieldOrganizationID]
  28661. return ok
  28662. }
  28663. // ResetOrganizationID resets all changes to the "organization_id" field.
  28664. func (m *UsageDetailMutation) ResetOrganizationID() {
  28665. m.organization_id = nil
  28666. m.addorganization_id = nil
  28667. delete(m.clearedFields, usagedetail.FieldOrganizationID)
  28668. }
  28669. // Where appends a list predicates to the UsageDetailMutation builder.
  28670. func (m *UsageDetailMutation) Where(ps ...predicate.UsageDetail) {
  28671. m.predicates = append(m.predicates, ps...)
  28672. }
  28673. // WhereP appends storage-level predicates to the UsageDetailMutation builder. Using this method,
  28674. // users can use type-assertion to append predicates that do not depend on any generated package.
  28675. func (m *UsageDetailMutation) WhereP(ps ...func(*sql.Selector)) {
  28676. p := make([]predicate.UsageDetail, len(ps))
  28677. for i := range ps {
  28678. p[i] = ps[i]
  28679. }
  28680. m.Where(p...)
  28681. }
  28682. // Op returns the operation name.
  28683. func (m *UsageDetailMutation) Op() Op {
  28684. return m.op
  28685. }
  28686. // SetOp allows setting the mutation operation.
  28687. func (m *UsageDetailMutation) SetOp(op Op) {
  28688. m.op = op
  28689. }
  28690. // Type returns the node type of this mutation (UsageDetail).
  28691. func (m *UsageDetailMutation) Type() string {
  28692. return m.typ
  28693. }
  28694. // Fields returns all fields that were changed during this mutation. Note that in
  28695. // order to get all numeric fields that were incremented/decremented, call
  28696. // AddedFields().
  28697. func (m *UsageDetailMutation) Fields() []string {
  28698. fields := make([]string, 0, 15)
  28699. if m.created_at != nil {
  28700. fields = append(fields, usagedetail.FieldCreatedAt)
  28701. }
  28702. if m.updated_at != nil {
  28703. fields = append(fields, usagedetail.FieldUpdatedAt)
  28704. }
  28705. if m.status != nil {
  28706. fields = append(fields, usagedetail.FieldStatus)
  28707. }
  28708. if m._type != nil {
  28709. fields = append(fields, usagedetail.FieldType)
  28710. }
  28711. if m.bot_id != nil {
  28712. fields = append(fields, usagedetail.FieldBotID)
  28713. }
  28714. if m.receiver_id != nil {
  28715. fields = append(fields, usagedetail.FieldReceiverID)
  28716. }
  28717. if m.app != nil {
  28718. fields = append(fields, usagedetail.FieldApp)
  28719. }
  28720. if m.session_id != nil {
  28721. fields = append(fields, usagedetail.FieldSessionID)
  28722. }
  28723. if m.request != nil {
  28724. fields = append(fields, usagedetail.FieldRequest)
  28725. }
  28726. if m.response != nil {
  28727. fields = append(fields, usagedetail.FieldResponse)
  28728. }
  28729. if m.original_data != nil {
  28730. fields = append(fields, usagedetail.FieldOriginalData)
  28731. }
  28732. if m.total_tokens != nil {
  28733. fields = append(fields, usagedetail.FieldTotalTokens)
  28734. }
  28735. if m.prompt_tokens != nil {
  28736. fields = append(fields, usagedetail.FieldPromptTokens)
  28737. }
  28738. if m.completion_tokens != nil {
  28739. fields = append(fields, usagedetail.FieldCompletionTokens)
  28740. }
  28741. if m.organization_id != nil {
  28742. fields = append(fields, usagedetail.FieldOrganizationID)
  28743. }
  28744. return fields
  28745. }
  28746. // Field returns the value of a field with the given name. The second boolean
  28747. // return value indicates that this field was not set, or was not defined in the
  28748. // schema.
  28749. func (m *UsageDetailMutation) Field(name string) (ent.Value, bool) {
  28750. switch name {
  28751. case usagedetail.FieldCreatedAt:
  28752. return m.CreatedAt()
  28753. case usagedetail.FieldUpdatedAt:
  28754. return m.UpdatedAt()
  28755. case usagedetail.FieldStatus:
  28756. return m.Status()
  28757. case usagedetail.FieldType:
  28758. return m.GetType()
  28759. case usagedetail.FieldBotID:
  28760. return m.BotID()
  28761. case usagedetail.FieldReceiverID:
  28762. return m.ReceiverID()
  28763. case usagedetail.FieldApp:
  28764. return m.App()
  28765. case usagedetail.FieldSessionID:
  28766. return m.SessionID()
  28767. case usagedetail.FieldRequest:
  28768. return m.Request()
  28769. case usagedetail.FieldResponse:
  28770. return m.Response()
  28771. case usagedetail.FieldOriginalData:
  28772. return m.OriginalData()
  28773. case usagedetail.FieldTotalTokens:
  28774. return m.TotalTokens()
  28775. case usagedetail.FieldPromptTokens:
  28776. return m.PromptTokens()
  28777. case usagedetail.FieldCompletionTokens:
  28778. return m.CompletionTokens()
  28779. case usagedetail.FieldOrganizationID:
  28780. return m.OrganizationID()
  28781. }
  28782. return nil, false
  28783. }
  28784. // OldField returns the old value of the field from the database. An error is
  28785. // returned if the mutation operation is not UpdateOne, or the query to the
  28786. // database failed.
  28787. func (m *UsageDetailMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  28788. switch name {
  28789. case usagedetail.FieldCreatedAt:
  28790. return m.OldCreatedAt(ctx)
  28791. case usagedetail.FieldUpdatedAt:
  28792. return m.OldUpdatedAt(ctx)
  28793. case usagedetail.FieldStatus:
  28794. return m.OldStatus(ctx)
  28795. case usagedetail.FieldType:
  28796. return m.OldType(ctx)
  28797. case usagedetail.FieldBotID:
  28798. return m.OldBotID(ctx)
  28799. case usagedetail.FieldReceiverID:
  28800. return m.OldReceiverID(ctx)
  28801. case usagedetail.FieldApp:
  28802. return m.OldApp(ctx)
  28803. case usagedetail.FieldSessionID:
  28804. return m.OldSessionID(ctx)
  28805. case usagedetail.FieldRequest:
  28806. return m.OldRequest(ctx)
  28807. case usagedetail.FieldResponse:
  28808. return m.OldResponse(ctx)
  28809. case usagedetail.FieldOriginalData:
  28810. return m.OldOriginalData(ctx)
  28811. case usagedetail.FieldTotalTokens:
  28812. return m.OldTotalTokens(ctx)
  28813. case usagedetail.FieldPromptTokens:
  28814. return m.OldPromptTokens(ctx)
  28815. case usagedetail.FieldCompletionTokens:
  28816. return m.OldCompletionTokens(ctx)
  28817. case usagedetail.FieldOrganizationID:
  28818. return m.OldOrganizationID(ctx)
  28819. }
  28820. return nil, fmt.Errorf("unknown UsageDetail field %s", name)
  28821. }
  28822. // SetField sets the value of a field with the given name. It returns an error if
  28823. // the field is not defined in the schema, or if the type mismatched the field
  28824. // type.
  28825. func (m *UsageDetailMutation) SetField(name string, value ent.Value) error {
  28826. switch name {
  28827. case usagedetail.FieldCreatedAt:
  28828. v, ok := value.(time.Time)
  28829. if !ok {
  28830. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28831. }
  28832. m.SetCreatedAt(v)
  28833. return nil
  28834. case usagedetail.FieldUpdatedAt:
  28835. v, ok := value.(time.Time)
  28836. if !ok {
  28837. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28838. }
  28839. m.SetUpdatedAt(v)
  28840. return nil
  28841. case usagedetail.FieldStatus:
  28842. v, ok := value.(uint8)
  28843. if !ok {
  28844. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28845. }
  28846. m.SetStatus(v)
  28847. return nil
  28848. case usagedetail.FieldType:
  28849. v, ok := value.(int)
  28850. if !ok {
  28851. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28852. }
  28853. m.SetType(v)
  28854. return nil
  28855. case usagedetail.FieldBotID:
  28856. v, ok := value.(string)
  28857. if !ok {
  28858. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28859. }
  28860. m.SetBotID(v)
  28861. return nil
  28862. case usagedetail.FieldReceiverID:
  28863. v, ok := value.(string)
  28864. if !ok {
  28865. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28866. }
  28867. m.SetReceiverID(v)
  28868. return nil
  28869. case usagedetail.FieldApp:
  28870. v, ok := value.(int)
  28871. if !ok {
  28872. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28873. }
  28874. m.SetApp(v)
  28875. return nil
  28876. case usagedetail.FieldSessionID:
  28877. v, ok := value.(uint64)
  28878. if !ok {
  28879. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28880. }
  28881. m.SetSessionID(v)
  28882. return nil
  28883. case usagedetail.FieldRequest:
  28884. v, ok := value.(string)
  28885. if !ok {
  28886. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28887. }
  28888. m.SetRequest(v)
  28889. return nil
  28890. case usagedetail.FieldResponse:
  28891. v, ok := value.(string)
  28892. if !ok {
  28893. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28894. }
  28895. m.SetResponse(v)
  28896. return nil
  28897. case usagedetail.FieldOriginalData:
  28898. v, ok := value.(custom_types.OriginalData)
  28899. if !ok {
  28900. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28901. }
  28902. m.SetOriginalData(v)
  28903. return nil
  28904. case usagedetail.FieldTotalTokens:
  28905. v, ok := value.(uint64)
  28906. if !ok {
  28907. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28908. }
  28909. m.SetTotalTokens(v)
  28910. return nil
  28911. case usagedetail.FieldPromptTokens:
  28912. v, ok := value.(uint64)
  28913. if !ok {
  28914. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28915. }
  28916. m.SetPromptTokens(v)
  28917. return nil
  28918. case usagedetail.FieldCompletionTokens:
  28919. v, ok := value.(uint64)
  28920. if !ok {
  28921. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28922. }
  28923. m.SetCompletionTokens(v)
  28924. return nil
  28925. case usagedetail.FieldOrganizationID:
  28926. v, ok := value.(uint64)
  28927. if !ok {
  28928. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28929. }
  28930. m.SetOrganizationID(v)
  28931. return nil
  28932. }
  28933. return fmt.Errorf("unknown UsageDetail field %s", name)
  28934. }
  28935. // AddedFields returns all numeric fields that were incremented/decremented during
  28936. // this mutation.
  28937. func (m *UsageDetailMutation) AddedFields() []string {
  28938. var fields []string
  28939. if m.addstatus != nil {
  28940. fields = append(fields, usagedetail.FieldStatus)
  28941. }
  28942. if m.add_type != nil {
  28943. fields = append(fields, usagedetail.FieldType)
  28944. }
  28945. if m.addapp != nil {
  28946. fields = append(fields, usagedetail.FieldApp)
  28947. }
  28948. if m.addsession_id != nil {
  28949. fields = append(fields, usagedetail.FieldSessionID)
  28950. }
  28951. if m.addtotal_tokens != nil {
  28952. fields = append(fields, usagedetail.FieldTotalTokens)
  28953. }
  28954. if m.addprompt_tokens != nil {
  28955. fields = append(fields, usagedetail.FieldPromptTokens)
  28956. }
  28957. if m.addcompletion_tokens != nil {
  28958. fields = append(fields, usagedetail.FieldCompletionTokens)
  28959. }
  28960. if m.addorganization_id != nil {
  28961. fields = append(fields, usagedetail.FieldOrganizationID)
  28962. }
  28963. return fields
  28964. }
  28965. // AddedField returns the numeric value that was incremented/decremented on a field
  28966. // with the given name. The second boolean return value indicates that this field
  28967. // was not set, or was not defined in the schema.
  28968. func (m *UsageDetailMutation) AddedField(name string) (ent.Value, bool) {
  28969. switch name {
  28970. case usagedetail.FieldStatus:
  28971. return m.AddedStatus()
  28972. case usagedetail.FieldType:
  28973. return m.AddedType()
  28974. case usagedetail.FieldApp:
  28975. return m.AddedApp()
  28976. case usagedetail.FieldSessionID:
  28977. return m.AddedSessionID()
  28978. case usagedetail.FieldTotalTokens:
  28979. return m.AddedTotalTokens()
  28980. case usagedetail.FieldPromptTokens:
  28981. return m.AddedPromptTokens()
  28982. case usagedetail.FieldCompletionTokens:
  28983. return m.AddedCompletionTokens()
  28984. case usagedetail.FieldOrganizationID:
  28985. return m.AddedOrganizationID()
  28986. }
  28987. return nil, false
  28988. }
  28989. // AddField adds the value to the field with the given name. It returns an error if
  28990. // the field is not defined in the schema, or if the type mismatched the field
  28991. // type.
  28992. func (m *UsageDetailMutation) AddField(name string, value ent.Value) error {
  28993. switch name {
  28994. case usagedetail.FieldStatus:
  28995. v, ok := value.(int8)
  28996. if !ok {
  28997. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28998. }
  28999. m.AddStatus(v)
  29000. return nil
  29001. case usagedetail.FieldType:
  29002. v, ok := value.(int)
  29003. if !ok {
  29004. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29005. }
  29006. m.AddType(v)
  29007. return nil
  29008. case usagedetail.FieldApp:
  29009. v, ok := value.(int)
  29010. if !ok {
  29011. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29012. }
  29013. m.AddApp(v)
  29014. return nil
  29015. case usagedetail.FieldSessionID:
  29016. v, ok := value.(int64)
  29017. if !ok {
  29018. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29019. }
  29020. m.AddSessionID(v)
  29021. return nil
  29022. case usagedetail.FieldTotalTokens:
  29023. v, ok := value.(int64)
  29024. if !ok {
  29025. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29026. }
  29027. m.AddTotalTokens(v)
  29028. return nil
  29029. case usagedetail.FieldPromptTokens:
  29030. v, ok := value.(int64)
  29031. if !ok {
  29032. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29033. }
  29034. m.AddPromptTokens(v)
  29035. return nil
  29036. case usagedetail.FieldCompletionTokens:
  29037. v, ok := value.(int64)
  29038. if !ok {
  29039. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29040. }
  29041. m.AddCompletionTokens(v)
  29042. return nil
  29043. case usagedetail.FieldOrganizationID:
  29044. v, ok := value.(int64)
  29045. if !ok {
  29046. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29047. }
  29048. m.AddOrganizationID(v)
  29049. return nil
  29050. }
  29051. return fmt.Errorf("unknown UsageDetail numeric field %s", name)
  29052. }
  29053. // ClearedFields returns all nullable fields that were cleared during this
  29054. // mutation.
  29055. func (m *UsageDetailMutation) ClearedFields() []string {
  29056. var fields []string
  29057. if m.FieldCleared(usagedetail.FieldStatus) {
  29058. fields = append(fields, usagedetail.FieldStatus)
  29059. }
  29060. if m.FieldCleared(usagedetail.FieldType) {
  29061. fields = append(fields, usagedetail.FieldType)
  29062. }
  29063. if m.FieldCleared(usagedetail.FieldApp) {
  29064. fields = append(fields, usagedetail.FieldApp)
  29065. }
  29066. if m.FieldCleared(usagedetail.FieldSessionID) {
  29067. fields = append(fields, usagedetail.FieldSessionID)
  29068. }
  29069. if m.FieldCleared(usagedetail.FieldTotalTokens) {
  29070. fields = append(fields, usagedetail.FieldTotalTokens)
  29071. }
  29072. if m.FieldCleared(usagedetail.FieldPromptTokens) {
  29073. fields = append(fields, usagedetail.FieldPromptTokens)
  29074. }
  29075. if m.FieldCleared(usagedetail.FieldCompletionTokens) {
  29076. fields = append(fields, usagedetail.FieldCompletionTokens)
  29077. }
  29078. if m.FieldCleared(usagedetail.FieldOrganizationID) {
  29079. fields = append(fields, usagedetail.FieldOrganizationID)
  29080. }
  29081. return fields
  29082. }
  29083. // FieldCleared returns a boolean indicating if a field with the given name was
  29084. // cleared in this mutation.
  29085. func (m *UsageDetailMutation) FieldCleared(name string) bool {
  29086. _, ok := m.clearedFields[name]
  29087. return ok
  29088. }
  29089. // ClearField clears the value of the field with the given name. It returns an
  29090. // error if the field is not defined in the schema.
  29091. func (m *UsageDetailMutation) ClearField(name string) error {
  29092. switch name {
  29093. case usagedetail.FieldStatus:
  29094. m.ClearStatus()
  29095. return nil
  29096. case usagedetail.FieldType:
  29097. m.ClearType()
  29098. return nil
  29099. case usagedetail.FieldApp:
  29100. m.ClearApp()
  29101. return nil
  29102. case usagedetail.FieldSessionID:
  29103. m.ClearSessionID()
  29104. return nil
  29105. case usagedetail.FieldTotalTokens:
  29106. m.ClearTotalTokens()
  29107. return nil
  29108. case usagedetail.FieldPromptTokens:
  29109. m.ClearPromptTokens()
  29110. return nil
  29111. case usagedetail.FieldCompletionTokens:
  29112. m.ClearCompletionTokens()
  29113. return nil
  29114. case usagedetail.FieldOrganizationID:
  29115. m.ClearOrganizationID()
  29116. return nil
  29117. }
  29118. return fmt.Errorf("unknown UsageDetail nullable field %s", name)
  29119. }
  29120. // ResetField resets all changes in the mutation for the field with the given name.
  29121. // It returns an error if the field is not defined in the schema.
  29122. func (m *UsageDetailMutation) ResetField(name string) error {
  29123. switch name {
  29124. case usagedetail.FieldCreatedAt:
  29125. m.ResetCreatedAt()
  29126. return nil
  29127. case usagedetail.FieldUpdatedAt:
  29128. m.ResetUpdatedAt()
  29129. return nil
  29130. case usagedetail.FieldStatus:
  29131. m.ResetStatus()
  29132. return nil
  29133. case usagedetail.FieldType:
  29134. m.ResetType()
  29135. return nil
  29136. case usagedetail.FieldBotID:
  29137. m.ResetBotID()
  29138. return nil
  29139. case usagedetail.FieldReceiverID:
  29140. m.ResetReceiverID()
  29141. return nil
  29142. case usagedetail.FieldApp:
  29143. m.ResetApp()
  29144. return nil
  29145. case usagedetail.FieldSessionID:
  29146. m.ResetSessionID()
  29147. return nil
  29148. case usagedetail.FieldRequest:
  29149. m.ResetRequest()
  29150. return nil
  29151. case usagedetail.FieldResponse:
  29152. m.ResetResponse()
  29153. return nil
  29154. case usagedetail.FieldOriginalData:
  29155. m.ResetOriginalData()
  29156. return nil
  29157. case usagedetail.FieldTotalTokens:
  29158. m.ResetTotalTokens()
  29159. return nil
  29160. case usagedetail.FieldPromptTokens:
  29161. m.ResetPromptTokens()
  29162. return nil
  29163. case usagedetail.FieldCompletionTokens:
  29164. m.ResetCompletionTokens()
  29165. return nil
  29166. case usagedetail.FieldOrganizationID:
  29167. m.ResetOrganizationID()
  29168. return nil
  29169. }
  29170. return fmt.Errorf("unknown UsageDetail field %s", name)
  29171. }
  29172. // AddedEdges returns all edge names that were set/added in this mutation.
  29173. func (m *UsageDetailMutation) AddedEdges() []string {
  29174. edges := make([]string, 0, 0)
  29175. return edges
  29176. }
  29177. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  29178. // name in this mutation.
  29179. func (m *UsageDetailMutation) AddedIDs(name string) []ent.Value {
  29180. return nil
  29181. }
  29182. // RemovedEdges returns all edge names that were removed in this mutation.
  29183. func (m *UsageDetailMutation) RemovedEdges() []string {
  29184. edges := make([]string, 0, 0)
  29185. return edges
  29186. }
  29187. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  29188. // the given name in this mutation.
  29189. func (m *UsageDetailMutation) RemovedIDs(name string) []ent.Value {
  29190. return nil
  29191. }
  29192. // ClearedEdges returns all edge names that were cleared in this mutation.
  29193. func (m *UsageDetailMutation) ClearedEdges() []string {
  29194. edges := make([]string, 0, 0)
  29195. return edges
  29196. }
  29197. // EdgeCleared returns a boolean which indicates if the edge with the given name
  29198. // was cleared in this mutation.
  29199. func (m *UsageDetailMutation) EdgeCleared(name string) bool {
  29200. return false
  29201. }
  29202. // ClearEdge clears the value of the edge with the given name. It returns an error
  29203. // if that edge is not defined in the schema.
  29204. func (m *UsageDetailMutation) ClearEdge(name string) error {
  29205. return fmt.Errorf("unknown UsageDetail unique edge %s", name)
  29206. }
  29207. // ResetEdge resets all changes to the edge with the given name in this mutation.
  29208. // It returns an error if the edge is not defined in the schema.
  29209. func (m *UsageDetailMutation) ResetEdge(name string) error {
  29210. return fmt.Errorf("unknown UsageDetail edge %s", name)
  29211. }
  29212. // UsageStatisticDayMutation represents an operation that mutates the UsageStatisticDay nodes in the graph.
  29213. type UsageStatisticDayMutation struct {
  29214. config
  29215. op Op
  29216. typ string
  29217. id *uint64
  29218. created_at *time.Time
  29219. updated_at *time.Time
  29220. status *uint8
  29221. addstatus *int8
  29222. deleted_at *time.Time
  29223. addtime *uint64
  29224. addaddtime *int64
  29225. _type *int
  29226. add_type *int
  29227. bot_id *string
  29228. organization_id *uint64
  29229. addorganization_id *int64
  29230. ai_response *uint64
  29231. addai_response *int64
  29232. sop_run *uint64
  29233. addsop_run *int64
  29234. total_friend *uint64
  29235. addtotal_friend *int64
  29236. total_group *uint64
  29237. addtotal_group *int64
  29238. account_balance *uint64
  29239. addaccount_balance *int64
  29240. consume_token *uint64
  29241. addconsume_token *int64
  29242. active_user *uint64
  29243. addactive_user *int64
  29244. new_user *int64
  29245. addnew_user *int64
  29246. label_dist *[]custom_types.LabelDist
  29247. appendlabel_dist []custom_types.LabelDist
  29248. clearedFields map[string]struct{}
  29249. done bool
  29250. oldValue func(context.Context) (*UsageStatisticDay, error)
  29251. predicates []predicate.UsageStatisticDay
  29252. }
  29253. var _ ent.Mutation = (*UsageStatisticDayMutation)(nil)
  29254. // usagestatisticdayOption allows management of the mutation configuration using functional options.
  29255. type usagestatisticdayOption func(*UsageStatisticDayMutation)
  29256. // newUsageStatisticDayMutation creates new mutation for the UsageStatisticDay entity.
  29257. func newUsageStatisticDayMutation(c config, op Op, opts ...usagestatisticdayOption) *UsageStatisticDayMutation {
  29258. m := &UsageStatisticDayMutation{
  29259. config: c,
  29260. op: op,
  29261. typ: TypeUsageStatisticDay,
  29262. clearedFields: make(map[string]struct{}),
  29263. }
  29264. for _, opt := range opts {
  29265. opt(m)
  29266. }
  29267. return m
  29268. }
  29269. // withUsageStatisticDayID sets the ID field of the mutation.
  29270. func withUsageStatisticDayID(id uint64) usagestatisticdayOption {
  29271. return func(m *UsageStatisticDayMutation) {
  29272. var (
  29273. err error
  29274. once sync.Once
  29275. value *UsageStatisticDay
  29276. )
  29277. m.oldValue = func(ctx context.Context) (*UsageStatisticDay, error) {
  29278. once.Do(func() {
  29279. if m.done {
  29280. err = errors.New("querying old values post mutation is not allowed")
  29281. } else {
  29282. value, err = m.Client().UsageStatisticDay.Get(ctx, id)
  29283. }
  29284. })
  29285. return value, err
  29286. }
  29287. m.id = &id
  29288. }
  29289. }
  29290. // withUsageStatisticDay sets the old UsageStatisticDay of the mutation.
  29291. func withUsageStatisticDay(node *UsageStatisticDay) usagestatisticdayOption {
  29292. return func(m *UsageStatisticDayMutation) {
  29293. m.oldValue = func(context.Context) (*UsageStatisticDay, error) {
  29294. return node, nil
  29295. }
  29296. m.id = &node.ID
  29297. }
  29298. }
  29299. // Client returns a new `ent.Client` from the mutation. If the mutation was
  29300. // executed in a transaction (ent.Tx), a transactional client is returned.
  29301. func (m UsageStatisticDayMutation) Client() *Client {
  29302. client := &Client{config: m.config}
  29303. client.init()
  29304. return client
  29305. }
  29306. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  29307. // it returns an error otherwise.
  29308. func (m UsageStatisticDayMutation) Tx() (*Tx, error) {
  29309. if _, ok := m.driver.(*txDriver); !ok {
  29310. return nil, errors.New("ent: mutation is not running in a transaction")
  29311. }
  29312. tx := &Tx{config: m.config}
  29313. tx.init()
  29314. return tx, nil
  29315. }
  29316. // SetID sets the value of the id field. Note that this
  29317. // operation is only accepted on creation of UsageStatisticDay entities.
  29318. func (m *UsageStatisticDayMutation) SetID(id uint64) {
  29319. m.id = &id
  29320. }
  29321. // ID returns the ID value in the mutation. Note that the ID is only available
  29322. // if it was provided to the builder or after it was returned from the database.
  29323. func (m *UsageStatisticDayMutation) ID() (id uint64, exists bool) {
  29324. if m.id == nil {
  29325. return
  29326. }
  29327. return *m.id, true
  29328. }
  29329. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  29330. // That means, if the mutation is applied within a transaction with an isolation level such
  29331. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  29332. // or updated by the mutation.
  29333. func (m *UsageStatisticDayMutation) IDs(ctx context.Context) ([]uint64, error) {
  29334. switch {
  29335. case m.op.Is(OpUpdateOne | OpDeleteOne):
  29336. id, exists := m.ID()
  29337. if exists {
  29338. return []uint64{id}, nil
  29339. }
  29340. fallthrough
  29341. case m.op.Is(OpUpdate | OpDelete):
  29342. return m.Client().UsageStatisticDay.Query().Where(m.predicates...).IDs(ctx)
  29343. default:
  29344. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  29345. }
  29346. }
  29347. // SetCreatedAt sets the "created_at" field.
  29348. func (m *UsageStatisticDayMutation) SetCreatedAt(t time.Time) {
  29349. m.created_at = &t
  29350. }
  29351. // CreatedAt returns the value of the "created_at" field in the mutation.
  29352. func (m *UsageStatisticDayMutation) CreatedAt() (r time.Time, exists bool) {
  29353. v := m.created_at
  29354. if v == nil {
  29355. return
  29356. }
  29357. return *v, true
  29358. }
  29359. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticDay entity.
  29360. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  29361. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29362. func (m *UsageStatisticDayMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  29363. if !m.op.Is(OpUpdateOne) {
  29364. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  29365. }
  29366. if m.id == nil || m.oldValue == nil {
  29367. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  29368. }
  29369. oldValue, err := m.oldValue(ctx)
  29370. if err != nil {
  29371. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  29372. }
  29373. return oldValue.CreatedAt, nil
  29374. }
  29375. // ResetCreatedAt resets all changes to the "created_at" field.
  29376. func (m *UsageStatisticDayMutation) ResetCreatedAt() {
  29377. m.created_at = nil
  29378. }
  29379. // SetUpdatedAt sets the "updated_at" field.
  29380. func (m *UsageStatisticDayMutation) SetUpdatedAt(t time.Time) {
  29381. m.updated_at = &t
  29382. }
  29383. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  29384. func (m *UsageStatisticDayMutation) UpdatedAt() (r time.Time, exists bool) {
  29385. v := m.updated_at
  29386. if v == nil {
  29387. return
  29388. }
  29389. return *v, true
  29390. }
  29391. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticDay entity.
  29392. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  29393. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29394. func (m *UsageStatisticDayMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  29395. if !m.op.Is(OpUpdateOne) {
  29396. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  29397. }
  29398. if m.id == nil || m.oldValue == nil {
  29399. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  29400. }
  29401. oldValue, err := m.oldValue(ctx)
  29402. if err != nil {
  29403. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  29404. }
  29405. return oldValue.UpdatedAt, nil
  29406. }
  29407. // ResetUpdatedAt resets all changes to the "updated_at" field.
  29408. func (m *UsageStatisticDayMutation) ResetUpdatedAt() {
  29409. m.updated_at = nil
  29410. }
  29411. // SetStatus sets the "status" field.
  29412. func (m *UsageStatisticDayMutation) SetStatus(u uint8) {
  29413. m.status = &u
  29414. m.addstatus = nil
  29415. }
  29416. // Status returns the value of the "status" field in the mutation.
  29417. func (m *UsageStatisticDayMutation) Status() (r uint8, exists bool) {
  29418. v := m.status
  29419. if v == nil {
  29420. return
  29421. }
  29422. return *v, true
  29423. }
  29424. // OldStatus returns the old "status" field's value of the UsageStatisticDay entity.
  29425. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  29426. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29427. func (m *UsageStatisticDayMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  29428. if !m.op.Is(OpUpdateOne) {
  29429. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  29430. }
  29431. if m.id == nil || m.oldValue == nil {
  29432. return v, errors.New("OldStatus requires an ID field in the mutation")
  29433. }
  29434. oldValue, err := m.oldValue(ctx)
  29435. if err != nil {
  29436. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  29437. }
  29438. return oldValue.Status, nil
  29439. }
  29440. // AddStatus adds u to the "status" field.
  29441. func (m *UsageStatisticDayMutation) AddStatus(u int8) {
  29442. if m.addstatus != nil {
  29443. *m.addstatus += u
  29444. } else {
  29445. m.addstatus = &u
  29446. }
  29447. }
  29448. // AddedStatus returns the value that was added to the "status" field in this mutation.
  29449. func (m *UsageStatisticDayMutation) AddedStatus() (r int8, exists bool) {
  29450. v := m.addstatus
  29451. if v == nil {
  29452. return
  29453. }
  29454. return *v, true
  29455. }
  29456. // ClearStatus clears the value of the "status" field.
  29457. func (m *UsageStatisticDayMutation) ClearStatus() {
  29458. m.status = nil
  29459. m.addstatus = nil
  29460. m.clearedFields[usagestatisticday.FieldStatus] = struct{}{}
  29461. }
  29462. // StatusCleared returns if the "status" field was cleared in this mutation.
  29463. func (m *UsageStatisticDayMutation) StatusCleared() bool {
  29464. _, ok := m.clearedFields[usagestatisticday.FieldStatus]
  29465. return ok
  29466. }
  29467. // ResetStatus resets all changes to the "status" field.
  29468. func (m *UsageStatisticDayMutation) ResetStatus() {
  29469. m.status = nil
  29470. m.addstatus = nil
  29471. delete(m.clearedFields, usagestatisticday.FieldStatus)
  29472. }
  29473. // SetDeletedAt sets the "deleted_at" field.
  29474. func (m *UsageStatisticDayMutation) SetDeletedAt(t time.Time) {
  29475. m.deleted_at = &t
  29476. }
  29477. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  29478. func (m *UsageStatisticDayMutation) DeletedAt() (r time.Time, exists bool) {
  29479. v := m.deleted_at
  29480. if v == nil {
  29481. return
  29482. }
  29483. return *v, true
  29484. }
  29485. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticDay entity.
  29486. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  29487. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29488. func (m *UsageStatisticDayMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  29489. if !m.op.Is(OpUpdateOne) {
  29490. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  29491. }
  29492. if m.id == nil || m.oldValue == nil {
  29493. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  29494. }
  29495. oldValue, err := m.oldValue(ctx)
  29496. if err != nil {
  29497. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  29498. }
  29499. return oldValue.DeletedAt, nil
  29500. }
  29501. // ClearDeletedAt clears the value of the "deleted_at" field.
  29502. func (m *UsageStatisticDayMutation) ClearDeletedAt() {
  29503. m.deleted_at = nil
  29504. m.clearedFields[usagestatisticday.FieldDeletedAt] = struct{}{}
  29505. }
  29506. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  29507. func (m *UsageStatisticDayMutation) DeletedAtCleared() bool {
  29508. _, ok := m.clearedFields[usagestatisticday.FieldDeletedAt]
  29509. return ok
  29510. }
  29511. // ResetDeletedAt resets all changes to the "deleted_at" field.
  29512. func (m *UsageStatisticDayMutation) ResetDeletedAt() {
  29513. m.deleted_at = nil
  29514. delete(m.clearedFields, usagestatisticday.FieldDeletedAt)
  29515. }
  29516. // SetAddtime sets the "addtime" field.
  29517. func (m *UsageStatisticDayMutation) SetAddtime(u uint64) {
  29518. m.addtime = &u
  29519. m.addaddtime = nil
  29520. }
  29521. // Addtime returns the value of the "addtime" field in the mutation.
  29522. func (m *UsageStatisticDayMutation) Addtime() (r uint64, exists bool) {
  29523. v := m.addtime
  29524. if v == nil {
  29525. return
  29526. }
  29527. return *v, true
  29528. }
  29529. // OldAddtime returns the old "addtime" field's value of the UsageStatisticDay entity.
  29530. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  29531. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29532. func (m *UsageStatisticDayMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  29533. if !m.op.Is(OpUpdateOne) {
  29534. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  29535. }
  29536. if m.id == nil || m.oldValue == nil {
  29537. return v, errors.New("OldAddtime requires an ID field in the mutation")
  29538. }
  29539. oldValue, err := m.oldValue(ctx)
  29540. if err != nil {
  29541. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  29542. }
  29543. return oldValue.Addtime, nil
  29544. }
  29545. // AddAddtime adds u to the "addtime" field.
  29546. func (m *UsageStatisticDayMutation) AddAddtime(u int64) {
  29547. if m.addaddtime != nil {
  29548. *m.addaddtime += u
  29549. } else {
  29550. m.addaddtime = &u
  29551. }
  29552. }
  29553. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  29554. func (m *UsageStatisticDayMutation) AddedAddtime() (r int64, exists bool) {
  29555. v := m.addaddtime
  29556. if v == nil {
  29557. return
  29558. }
  29559. return *v, true
  29560. }
  29561. // ResetAddtime resets all changes to the "addtime" field.
  29562. func (m *UsageStatisticDayMutation) ResetAddtime() {
  29563. m.addtime = nil
  29564. m.addaddtime = nil
  29565. }
  29566. // SetType sets the "type" field.
  29567. func (m *UsageStatisticDayMutation) SetType(i int) {
  29568. m._type = &i
  29569. m.add_type = nil
  29570. }
  29571. // GetType returns the value of the "type" field in the mutation.
  29572. func (m *UsageStatisticDayMutation) GetType() (r int, exists bool) {
  29573. v := m._type
  29574. if v == nil {
  29575. return
  29576. }
  29577. return *v, true
  29578. }
  29579. // OldType returns the old "type" field's value of the UsageStatisticDay entity.
  29580. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  29581. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29582. func (m *UsageStatisticDayMutation) OldType(ctx context.Context) (v int, err error) {
  29583. if !m.op.Is(OpUpdateOne) {
  29584. return v, errors.New("OldType is only allowed on UpdateOne operations")
  29585. }
  29586. if m.id == nil || m.oldValue == nil {
  29587. return v, errors.New("OldType requires an ID field in the mutation")
  29588. }
  29589. oldValue, err := m.oldValue(ctx)
  29590. if err != nil {
  29591. return v, fmt.Errorf("querying old value for OldType: %w", err)
  29592. }
  29593. return oldValue.Type, nil
  29594. }
  29595. // AddType adds i to the "type" field.
  29596. func (m *UsageStatisticDayMutation) AddType(i int) {
  29597. if m.add_type != nil {
  29598. *m.add_type += i
  29599. } else {
  29600. m.add_type = &i
  29601. }
  29602. }
  29603. // AddedType returns the value that was added to the "type" field in this mutation.
  29604. func (m *UsageStatisticDayMutation) AddedType() (r int, exists bool) {
  29605. v := m.add_type
  29606. if v == nil {
  29607. return
  29608. }
  29609. return *v, true
  29610. }
  29611. // ResetType resets all changes to the "type" field.
  29612. func (m *UsageStatisticDayMutation) ResetType() {
  29613. m._type = nil
  29614. m.add_type = nil
  29615. }
  29616. // SetBotID sets the "bot_id" field.
  29617. func (m *UsageStatisticDayMutation) SetBotID(s string) {
  29618. m.bot_id = &s
  29619. }
  29620. // BotID returns the value of the "bot_id" field in the mutation.
  29621. func (m *UsageStatisticDayMutation) BotID() (r string, exists bool) {
  29622. v := m.bot_id
  29623. if v == nil {
  29624. return
  29625. }
  29626. return *v, true
  29627. }
  29628. // OldBotID returns the old "bot_id" field's value of the UsageStatisticDay entity.
  29629. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  29630. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29631. func (m *UsageStatisticDayMutation) OldBotID(ctx context.Context) (v string, err error) {
  29632. if !m.op.Is(OpUpdateOne) {
  29633. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  29634. }
  29635. if m.id == nil || m.oldValue == nil {
  29636. return v, errors.New("OldBotID requires an ID field in the mutation")
  29637. }
  29638. oldValue, err := m.oldValue(ctx)
  29639. if err != nil {
  29640. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  29641. }
  29642. return oldValue.BotID, nil
  29643. }
  29644. // ClearBotID clears the value of the "bot_id" field.
  29645. func (m *UsageStatisticDayMutation) ClearBotID() {
  29646. m.bot_id = nil
  29647. m.clearedFields[usagestatisticday.FieldBotID] = struct{}{}
  29648. }
  29649. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  29650. func (m *UsageStatisticDayMutation) BotIDCleared() bool {
  29651. _, ok := m.clearedFields[usagestatisticday.FieldBotID]
  29652. return ok
  29653. }
  29654. // ResetBotID resets all changes to the "bot_id" field.
  29655. func (m *UsageStatisticDayMutation) ResetBotID() {
  29656. m.bot_id = nil
  29657. delete(m.clearedFields, usagestatisticday.FieldBotID)
  29658. }
  29659. // SetOrganizationID sets the "organization_id" field.
  29660. func (m *UsageStatisticDayMutation) SetOrganizationID(u uint64) {
  29661. m.organization_id = &u
  29662. m.addorganization_id = nil
  29663. }
  29664. // OrganizationID returns the value of the "organization_id" field in the mutation.
  29665. func (m *UsageStatisticDayMutation) OrganizationID() (r uint64, exists bool) {
  29666. v := m.organization_id
  29667. if v == nil {
  29668. return
  29669. }
  29670. return *v, true
  29671. }
  29672. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticDay entity.
  29673. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  29674. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29675. func (m *UsageStatisticDayMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  29676. if !m.op.Is(OpUpdateOne) {
  29677. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  29678. }
  29679. if m.id == nil || m.oldValue == nil {
  29680. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  29681. }
  29682. oldValue, err := m.oldValue(ctx)
  29683. if err != nil {
  29684. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  29685. }
  29686. return oldValue.OrganizationID, nil
  29687. }
  29688. // AddOrganizationID adds u to the "organization_id" field.
  29689. func (m *UsageStatisticDayMutation) AddOrganizationID(u int64) {
  29690. if m.addorganization_id != nil {
  29691. *m.addorganization_id += u
  29692. } else {
  29693. m.addorganization_id = &u
  29694. }
  29695. }
  29696. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  29697. func (m *UsageStatisticDayMutation) AddedOrganizationID() (r int64, exists bool) {
  29698. v := m.addorganization_id
  29699. if v == nil {
  29700. return
  29701. }
  29702. return *v, true
  29703. }
  29704. // ClearOrganizationID clears the value of the "organization_id" field.
  29705. func (m *UsageStatisticDayMutation) ClearOrganizationID() {
  29706. m.organization_id = nil
  29707. m.addorganization_id = nil
  29708. m.clearedFields[usagestatisticday.FieldOrganizationID] = struct{}{}
  29709. }
  29710. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  29711. func (m *UsageStatisticDayMutation) OrganizationIDCleared() bool {
  29712. _, ok := m.clearedFields[usagestatisticday.FieldOrganizationID]
  29713. return ok
  29714. }
  29715. // ResetOrganizationID resets all changes to the "organization_id" field.
  29716. func (m *UsageStatisticDayMutation) ResetOrganizationID() {
  29717. m.organization_id = nil
  29718. m.addorganization_id = nil
  29719. delete(m.clearedFields, usagestatisticday.FieldOrganizationID)
  29720. }
  29721. // SetAiResponse sets the "ai_response" field.
  29722. func (m *UsageStatisticDayMutation) SetAiResponse(u uint64) {
  29723. m.ai_response = &u
  29724. m.addai_response = nil
  29725. }
  29726. // AiResponse returns the value of the "ai_response" field in the mutation.
  29727. func (m *UsageStatisticDayMutation) AiResponse() (r uint64, exists bool) {
  29728. v := m.ai_response
  29729. if v == nil {
  29730. return
  29731. }
  29732. return *v, true
  29733. }
  29734. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticDay entity.
  29735. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  29736. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29737. func (m *UsageStatisticDayMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  29738. if !m.op.Is(OpUpdateOne) {
  29739. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  29740. }
  29741. if m.id == nil || m.oldValue == nil {
  29742. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  29743. }
  29744. oldValue, err := m.oldValue(ctx)
  29745. if err != nil {
  29746. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  29747. }
  29748. return oldValue.AiResponse, nil
  29749. }
  29750. // AddAiResponse adds u to the "ai_response" field.
  29751. func (m *UsageStatisticDayMutation) AddAiResponse(u int64) {
  29752. if m.addai_response != nil {
  29753. *m.addai_response += u
  29754. } else {
  29755. m.addai_response = &u
  29756. }
  29757. }
  29758. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  29759. func (m *UsageStatisticDayMutation) AddedAiResponse() (r int64, exists bool) {
  29760. v := m.addai_response
  29761. if v == nil {
  29762. return
  29763. }
  29764. return *v, true
  29765. }
  29766. // ResetAiResponse resets all changes to the "ai_response" field.
  29767. func (m *UsageStatisticDayMutation) ResetAiResponse() {
  29768. m.ai_response = nil
  29769. m.addai_response = nil
  29770. }
  29771. // SetSopRun sets the "sop_run" field.
  29772. func (m *UsageStatisticDayMutation) SetSopRun(u uint64) {
  29773. m.sop_run = &u
  29774. m.addsop_run = nil
  29775. }
  29776. // SopRun returns the value of the "sop_run" field in the mutation.
  29777. func (m *UsageStatisticDayMutation) SopRun() (r uint64, exists bool) {
  29778. v := m.sop_run
  29779. if v == nil {
  29780. return
  29781. }
  29782. return *v, true
  29783. }
  29784. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticDay entity.
  29785. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  29786. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29787. func (m *UsageStatisticDayMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  29788. if !m.op.Is(OpUpdateOne) {
  29789. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  29790. }
  29791. if m.id == nil || m.oldValue == nil {
  29792. return v, errors.New("OldSopRun requires an ID field in the mutation")
  29793. }
  29794. oldValue, err := m.oldValue(ctx)
  29795. if err != nil {
  29796. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  29797. }
  29798. return oldValue.SopRun, nil
  29799. }
  29800. // AddSopRun adds u to the "sop_run" field.
  29801. func (m *UsageStatisticDayMutation) AddSopRun(u int64) {
  29802. if m.addsop_run != nil {
  29803. *m.addsop_run += u
  29804. } else {
  29805. m.addsop_run = &u
  29806. }
  29807. }
  29808. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  29809. func (m *UsageStatisticDayMutation) AddedSopRun() (r int64, exists bool) {
  29810. v := m.addsop_run
  29811. if v == nil {
  29812. return
  29813. }
  29814. return *v, true
  29815. }
  29816. // ResetSopRun resets all changes to the "sop_run" field.
  29817. func (m *UsageStatisticDayMutation) ResetSopRun() {
  29818. m.sop_run = nil
  29819. m.addsop_run = nil
  29820. }
  29821. // SetTotalFriend sets the "total_friend" field.
  29822. func (m *UsageStatisticDayMutation) SetTotalFriend(u uint64) {
  29823. m.total_friend = &u
  29824. m.addtotal_friend = nil
  29825. }
  29826. // TotalFriend returns the value of the "total_friend" field in the mutation.
  29827. func (m *UsageStatisticDayMutation) TotalFriend() (r uint64, exists bool) {
  29828. v := m.total_friend
  29829. if v == nil {
  29830. return
  29831. }
  29832. return *v, true
  29833. }
  29834. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticDay entity.
  29835. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  29836. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29837. func (m *UsageStatisticDayMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  29838. if !m.op.Is(OpUpdateOne) {
  29839. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  29840. }
  29841. if m.id == nil || m.oldValue == nil {
  29842. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  29843. }
  29844. oldValue, err := m.oldValue(ctx)
  29845. if err != nil {
  29846. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  29847. }
  29848. return oldValue.TotalFriend, nil
  29849. }
  29850. // AddTotalFriend adds u to the "total_friend" field.
  29851. func (m *UsageStatisticDayMutation) AddTotalFriend(u int64) {
  29852. if m.addtotal_friend != nil {
  29853. *m.addtotal_friend += u
  29854. } else {
  29855. m.addtotal_friend = &u
  29856. }
  29857. }
  29858. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  29859. func (m *UsageStatisticDayMutation) AddedTotalFriend() (r int64, exists bool) {
  29860. v := m.addtotal_friend
  29861. if v == nil {
  29862. return
  29863. }
  29864. return *v, true
  29865. }
  29866. // ResetTotalFriend resets all changes to the "total_friend" field.
  29867. func (m *UsageStatisticDayMutation) ResetTotalFriend() {
  29868. m.total_friend = nil
  29869. m.addtotal_friend = nil
  29870. }
  29871. // SetTotalGroup sets the "total_group" field.
  29872. func (m *UsageStatisticDayMutation) SetTotalGroup(u uint64) {
  29873. m.total_group = &u
  29874. m.addtotal_group = nil
  29875. }
  29876. // TotalGroup returns the value of the "total_group" field in the mutation.
  29877. func (m *UsageStatisticDayMutation) TotalGroup() (r uint64, exists bool) {
  29878. v := m.total_group
  29879. if v == nil {
  29880. return
  29881. }
  29882. return *v, true
  29883. }
  29884. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticDay entity.
  29885. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  29886. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29887. func (m *UsageStatisticDayMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  29888. if !m.op.Is(OpUpdateOne) {
  29889. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  29890. }
  29891. if m.id == nil || m.oldValue == nil {
  29892. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  29893. }
  29894. oldValue, err := m.oldValue(ctx)
  29895. if err != nil {
  29896. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  29897. }
  29898. return oldValue.TotalGroup, nil
  29899. }
  29900. // AddTotalGroup adds u to the "total_group" field.
  29901. func (m *UsageStatisticDayMutation) AddTotalGroup(u int64) {
  29902. if m.addtotal_group != nil {
  29903. *m.addtotal_group += u
  29904. } else {
  29905. m.addtotal_group = &u
  29906. }
  29907. }
  29908. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  29909. func (m *UsageStatisticDayMutation) AddedTotalGroup() (r int64, exists bool) {
  29910. v := m.addtotal_group
  29911. if v == nil {
  29912. return
  29913. }
  29914. return *v, true
  29915. }
  29916. // ResetTotalGroup resets all changes to the "total_group" field.
  29917. func (m *UsageStatisticDayMutation) ResetTotalGroup() {
  29918. m.total_group = nil
  29919. m.addtotal_group = nil
  29920. }
  29921. // SetAccountBalance sets the "account_balance" field.
  29922. func (m *UsageStatisticDayMutation) SetAccountBalance(u uint64) {
  29923. m.account_balance = &u
  29924. m.addaccount_balance = nil
  29925. }
  29926. // AccountBalance returns the value of the "account_balance" field in the mutation.
  29927. func (m *UsageStatisticDayMutation) AccountBalance() (r uint64, exists bool) {
  29928. v := m.account_balance
  29929. if v == nil {
  29930. return
  29931. }
  29932. return *v, true
  29933. }
  29934. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticDay entity.
  29935. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  29936. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29937. func (m *UsageStatisticDayMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  29938. if !m.op.Is(OpUpdateOne) {
  29939. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  29940. }
  29941. if m.id == nil || m.oldValue == nil {
  29942. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  29943. }
  29944. oldValue, err := m.oldValue(ctx)
  29945. if err != nil {
  29946. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  29947. }
  29948. return oldValue.AccountBalance, nil
  29949. }
  29950. // AddAccountBalance adds u to the "account_balance" field.
  29951. func (m *UsageStatisticDayMutation) AddAccountBalance(u int64) {
  29952. if m.addaccount_balance != nil {
  29953. *m.addaccount_balance += u
  29954. } else {
  29955. m.addaccount_balance = &u
  29956. }
  29957. }
  29958. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  29959. func (m *UsageStatisticDayMutation) AddedAccountBalance() (r int64, exists bool) {
  29960. v := m.addaccount_balance
  29961. if v == nil {
  29962. return
  29963. }
  29964. return *v, true
  29965. }
  29966. // ResetAccountBalance resets all changes to the "account_balance" field.
  29967. func (m *UsageStatisticDayMutation) ResetAccountBalance() {
  29968. m.account_balance = nil
  29969. m.addaccount_balance = nil
  29970. }
  29971. // SetConsumeToken sets the "consume_token" field.
  29972. func (m *UsageStatisticDayMutation) SetConsumeToken(u uint64) {
  29973. m.consume_token = &u
  29974. m.addconsume_token = nil
  29975. }
  29976. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  29977. func (m *UsageStatisticDayMutation) ConsumeToken() (r uint64, exists bool) {
  29978. v := m.consume_token
  29979. if v == nil {
  29980. return
  29981. }
  29982. return *v, true
  29983. }
  29984. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticDay entity.
  29985. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  29986. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29987. func (m *UsageStatisticDayMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  29988. if !m.op.Is(OpUpdateOne) {
  29989. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  29990. }
  29991. if m.id == nil || m.oldValue == nil {
  29992. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  29993. }
  29994. oldValue, err := m.oldValue(ctx)
  29995. if err != nil {
  29996. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  29997. }
  29998. return oldValue.ConsumeToken, nil
  29999. }
  30000. // AddConsumeToken adds u to the "consume_token" field.
  30001. func (m *UsageStatisticDayMutation) AddConsumeToken(u int64) {
  30002. if m.addconsume_token != nil {
  30003. *m.addconsume_token += u
  30004. } else {
  30005. m.addconsume_token = &u
  30006. }
  30007. }
  30008. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  30009. func (m *UsageStatisticDayMutation) AddedConsumeToken() (r int64, exists bool) {
  30010. v := m.addconsume_token
  30011. if v == nil {
  30012. return
  30013. }
  30014. return *v, true
  30015. }
  30016. // ResetConsumeToken resets all changes to the "consume_token" field.
  30017. func (m *UsageStatisticDayMutation) ResetConsumeToken() {
  30018. m.consume_token = nil
  30019. m.addconsume_token = nil
  30020. }
  30021. // SetActiveUser sets the "active_user" field.
  30022. func (m *UsageStatisticDayMutation) SetActiveUser(u uint64) {
  30023. m.active_user = &u
  30024. m.addactive_user = nil
  30025. }
  30026. // ActiveUser returns the value of the "active_user" field in the mutation.
  30027. func (m *UsageStatisticDayMutation) ActiveUser() (r uint64, exists bool) {
  30028. v := m.active_user
  30029. if v == nil {
  30030. return
  30031. }
  30032. return *v, true
  30033. }
  30034. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticDay entity.
  30035. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  30036. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30037. func (m *UsageStatisticDayMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  30038. if !m.op.Is(OpUpdateOne) {
  30039. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  30040. }
  30041. if m.id == nil || m.oldValue == nil {
  30042. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  30043. }
  30044. oldValue, err := m.oldValue(ctx)
  30045. if err != nil {
  30046. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  30047. }
  30048. return oldValue.ActiveUser, nil
  30049. }
  30050. // AddActiveUser adds u to the "active_user" field.
  30051. func (m *UsageStatisticDayMutation) AddActiveUser(u int64) {
  30052. if m.addactive_user != nil {
  30053. *m.addactive_user += u
  30054. } else {
  30055. m.addactive_user = &u
  30056. }
  30057. }
  30058. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  30059. func (m *UsageStatisticDayMutation) AddedActiveUser() (r int64, exists bool) {
  30060. v := m.addactive_user
  30061. if v == nil {
  30062. return
  30063. }
  30064. return *v, true
  30065. }
  30066. // ResetActiveUser resets all changes to the "active_user" field.
  30067. func (m *UsageStatisticDayMutation) ResetActiveUser() {
  30068. m.active_user = nil
  30069. m.addactive_user = nil
  30070. }
  30071. // SetNewUser sets the "new_user" field.
  30072. func (m *UsageStatisticDayMutation) SetNewUser(i int64) {
  30073. m.new_user = &i
  30074. m.addnew_user = nil
  30075. }
  30076. // NewUser returns the value of the "new_user" field in the mutation.
  30077. func (m *UsageStatisticDayMutation) NewUser() (r int64, exists bool) {
  30078. v := m.new_user
  30079. if v == nil {
  30080. return
  30081. }
  30082. return *v, true
  30083. }
  30084. // OldNewUser returns the old "new_user" field's value of the UsageStatisticDay entity.
  30085. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  30086. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30087. func (m *UsageStatisticDayMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  30088. if !m.op.Is(OpUpdateOne) {
  30089. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  30090. }
  30091. if m.id == nil || m.oldValue == nil {
  30092. return v, errors.New("OldNewUser requires an ID field in the mutation")
  30093. }
  30094. oldValue, err := m.oldValue(ctx)
  30095. if err != nil {
  30096. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  30097. }
  30098. return oldValue.NewUser, nil
  30099. }
  30100. // AddNewUser adds i to the "new_user" field.
  30101. func (m *UsageStatisticDayMutation) AddNewUser(i int64) {
  30102. if m.addnew_user != nil {
  30103. *m.addnew_user += i
  30104. } else {
  30105. m.addnew_user = &i
  30106. }
  30107. }
  30108. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  30109. func (m *UsageStatisticDayMutation) AddedNewUser() (r int64, exists bool) {
  30110. v := m.addnew_user
  30111. if v == nil {
  30112. return
  30113. }
  30114. return *v, true
  30115. }
  30116. // ResetNewUser resets all changes to the "new_user" field.
  30117. func (m *UsageStatisticDayMutation) ResetNewUser() {
  30118. m.new_user = nil
  30119. m.addnew_user = nil
  30120. }
  30121. // SetLabelDist sets the "label_dist" field.
  30122. func (m *UsageStatisticDayMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  30123. m.label_dist = &ctd
  30124. m.appendlabel_dist = nil
  30125. }
  30126. // LabelDist returns the value of the "label_dist" field in the mutation.
  30127. func (m *UsageStatisticDayMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  30128. v := m.label_dist
  30129. if v == nil {
  30130. return
  30131. }
  30132. return *v, true
  30133. }
  30134. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticDay entity.
  30135. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  30136. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30137. func (m *UsageStatisticDayMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  30138. if !m.op.Is(OpUpdateOne) {
  30139. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  30140. }
  30141. if m.id == nil || m.oldValue == nil {
  30142. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  30143. }
  30144. oldValue, err := m.oldValue(ctx)
  30145. if err != nil {
  30146. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  30147. }
  30148. return oldValue.LabelDist, nil
  30149. }
  30150. // AppendLabelDist adds ctd to the "label_dist" field.
  30151. func (m *UsageStatisticDayMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  30152. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  30153. }
  30154. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  30155. func (m *UsageStatisticDayMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  30156. if len(m.appendlabel_dist) == 0 {
  30157. return nil, false
  30158. }
  30159. return m.appendlabel_dist, true
  30160. }
  30161. // ResetLabelDist resets all changes to the "label_dist" field.
  30162. func (m *UsageStatisticDayMutation) ResetLabelDist() {
  30163. m.label_dist = nil
  30164. m.appendlabel_dist = nil
  30165. }
  30166. // Where appends a list predicates to the UsageStatisticDayMutation builder.
  30167. func (m *UsageStatisticDayMutation) Where(ps ...predicate.UsageStatisticDay) {
  30168. m.predicates = append(m.predicates, ps...)
  30169. }
  30170. // WhereP appends storage-level predicates to the UsageStatisticDayMutation builder. Using this method,
  30171. // users can use type-assertion to append predicates that do not depend on any generated package.
  30172. func (m *UsageStatisticDayMutation) WhereP(ps ...func(*sql.Selector)) {
  30173. p := make([]predicate.UsageStatisticDay, len(ps))
  30174. for i := range ps {
  30175. p[i] = ps[i]
  30176. }
  30177. m.Where(p...)
  30178. }
  30179. // Op returns the operation name.
  30180. func (m *UsageStatisticDayMutation) Op() Op {
  30181. return m.op
  30182. }
  30183. // SetOp allows setting the mutation operation.
  30184. func (m *UsageStatisticDayMutation) SetOp(op Op) {
  30185. m.op = op
  30186. }
  30187. // Type returns the node type of this mutation (UsageStatisticDay).
  30188. func (m *UsageStatisticDayMutation) Type() string {
  30189. return m.typ
  30190. }
  30191. // Fields returns all fields that were changed during this mutation. Note that in
  30192. // order to get all numeric fields that were incremented/decremented, call
  30193. // AddedFields().
  30194. func (m *UsageStatisticDayMutation) Fields() []string {
  30195. fields := make([]string, 0, 17)
  30196. if m.created_at != nil {
  30197. fields = append(fields, usagestatisticday.FieldCreatedAt)
  30198. }
  30199. if m.updated_at != nil {
  30200. fields = append(fields, usagestatisticday.FieldUpdatedAt)
  30201. }
  30202. if m.status != nil {
  30203. fields = append(fields, usagestatisticday.FieldStatus)
  30204. }
  30205. if m.deleted_at != nil {
  30206. fields = append(fields, usagestatisticday.FieldDeletedAt)
  30207. }
  30208. if m.addtime != nil {
  30209. fields = append(fields, usagestatisticday.FieldAddtime)
  30210. }
  30211. if m._type != nil {
  30212. fields = append(fields, usagestatisticday.FieldType)
  30213. }
  30214. if m.bot_id != nil {
  30215. fields = append(fields, usagestatisticday.FieldBotID)
  30216. }
  30217. if m.organization_id != nil {
  30218. fields = append(fields, usagestatisticday.FieldOrganizationID)
  30219. }
  30220. if m.ai_response != nil {
  30221. fields = append(fields, usagestatisticday.FieldAiResponse)
  30222. }
  30223. if m.sop_run != nil {
  30224. fields = append(fields, usagestatisticday.FieldSopRun)
  30225. }
  30226. if m.total_friend != nil {
  30227. fields = append(fields, usagestatisticday.FieldTotalFriend)
  30228. }
  30229. if m.total_group != nil {
  30230. fields = append(fields, usagestatisticday.FieldTotalGroup)
  30231. }
  30232. if m.account_balance != nil {
  30233. fields = append(fields, usagestatisticday.FieldAccountBalance)
  30234. }
  30235. if m.consume_token != nil {
  30236. fields = append(fields, usagestatisticday.FieldConsumeToken)
  30237. }
  30238. if m.active_user != nil {
  30239. fields = append(fields, usagestatisticday.FieldActiveUser)
  30240. }
  30241. if m.new_user != nil {
  30242. fields = append(fields, usagestatisticday.FieldNewUser)
  30243. }
  30244. if m.label_dist != nil {
  30245. fields = append(fields, usagestatisticday.FieldLabelDist)
  30246. }
  30247. return fields
  30248. }
  30249. // Field returns the value of a field with the given name. The second boolean
  30250. // return value indicates that this field was not set, or was not defined in the
  30251. // schema.
  30252. func (m *UsageStatisticDayMutation) Field(name string) (ent.Value, bool) {
  30253. switch name {
  30254. case usagestatisticday.FieldCreatedAt:
  30255. return m.CreatedAt()
  30256. case usagestatisticday.FieldUpdatedAt:
  30257. return m.UpdatedAt()
  30258. case usagestatisticday.FieldStatus:
  30259. return m.Status()
  30260. case usagestatisticday.FieldDeletedAt:
  30261. return m.DeletedAt()
  30262. case usagestatisticday.FieldAddtime:
  30263. return m.Addtime()
  30264. case usagestatisticday.FieldType:
  30265. return m.GetType()
  30266. case usagestatisticday.FieldBotID:
  30267. return m.BotID()
  30268. case usagestatisticday.FieldOrganizationID:
  30269. return m.OrganizationID()
  30270. case usagestatisticday.FieldAiResponse:
  30271. return m.AiResponse()
  30272. case usagestatisticday.FieldSopRun:
  30273. return m.SopRun()
  30274. case usagestatisticday.FieldTotalFriend:
  30275. return m.TotalFriend()
  30276. case usagestatisticday.FieldTotalGroup:
  30277. return m.TotalGroup()
  30278. case usagestatisticday.FieldAccountBalance:
  30279. return m.AccountBalance()
  30280. case usagestatisticday.FieldConsumeToken:
  30281. return m.ConsumeToken()
  30282. case usagestatisticday.FieldActiveUser:
  30283. return m.ActiveUser()
  30284. case usagestatisticday.FieldNewUser:
  30285. return m.NewUser()
  30286. case usagestatisticday.FieldLabelDist:
  30287. return m.LabelDist()
  30288. }
  30289. return nil, false
  30290. }
  30291. // OldField returns the old value of the field from the database. An error is
  30292. // returned if the mutation operation is not UpdateOne, or the query to the
  30293. // database failed.
  30294. func (m *UsageStatisticDayMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  30295. switch name {
  30296. case usagestatisticday.FieldCreatedAt:
  30297. return m.OldCreatedAt(ctx)
  30298. case usagestatisticday.FieldUpdatedAt:
  30299. return m.OldUpdatedAt(ctx)
  30300. case usagestatisticday.FieldStatus:
  30301. return m.OldStatus(ctx)
  30302. case usagestatisticday.FieldDeletedAt:
  30303. return m.OldDeletedAt(ctx)
  30304. case usagestatisticday.FieldAddtime:
  30305. return m.OldAddtime(ctx)
  30306. case usagestatisticday.FieldType:
  30307. return m.OldType(ctx)
  30308. case usagestatisticday.FieldBotID:
  30309. return m.OldBotID(ctx)
  30310. case usagestatisticday.FieldOrganizationID:
  30311. return m.OldOrganizationID(ctx)
  30312. case usagestatisticday.FieldAiResponse:
  30313. return m.OldAiResponse(ctx)
  30314. case usagestatisticday.FieldSopRun:
  30315. return m.OldSopRun(ctx)
  30316. case usagestatisticday.FieldTotalFriend:
  30317. return m.OldTotalFriend(ctx)
  30318. case usagestatisticday.FieldTotalGroup:
  30319. return m.OldTotalGroup(ctx)
  30320. case usagestatisticday.FieldAccountBalance:
  30321. return m.OldAccountBalance(ctx)
  30322. case usagestatisticday.FieldConsumeToken:
  30323. return m.OldConsumeToken(ctx)
  30324. case usagestatisticday.FieldActiveUser:
  30325. return m.OldActiveUser(ctx)
  30326. case usagestatisticday.FieldNewUser:
  30327. return m.OldNewUser(ctx)
  30328. case usagestatisticday.FieldLabelDist:
  30329. return m.OldLabelDist(ctx)
  30330. }
  30331. return nil, fmt.Errorf("unknown UsageStatisticDay field %s", name)
  30332. }
  30333. // SetField sets the value of a field with the given name. It returns an error if
  30334. // the field is not defined in the schema, or if the type mismatched the field
  30335. // type.
  30336. func (m *UsageStatisticDayMutation) SetField(name string, value ent.Value) error {
  30337. switch name {
  30338. case usagestatisticday.FieldCreatedAt:
  30339. v, ok := value.(time.Time)
  30340. if !ok {
  30341. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30342. }
  30343. m.SetCreatedAt(v)
  30344. return nil
  30345. case usagestatisticday.FieldUpdatedAt:
  30346. v, ok := value.(time.Time)
  30347. if !ok {
  30348. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30349. }
  30350. m.SetUpdatedAt(v)
  30351. return nil
  30352. case usagestatisticday.FieldStatus:
  30353. v, ok := value.(uint8)
  30354. if !ok {
  30355. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30356. }
  30357. m.SetStatus(v)
  30358. return nil
  30359. case usagestatisticday.FieldDeletedAt:
  30360. v, ok := value.(time.Time)
  30361. if !ok {
  30362. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30363. }
  30364. m.SetDeletedAt(v)
  30365. return nil
  30366. case usagestatisticday.FieldAddtime:
  30367. v, ok := value.(uint64)
  30368. if !ok {
  30369. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30370. }
  30371. m.SetAddtime(v)
  30372. return nil
  30373. case usagestatisticday.FieldType:
  30374. v, ok := value.(int)
  30375. if !ok {
  30376. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30377. }
  30378. m.SetType(v)
  30379. return nil
  30380. case usagestatisticday.FieldBotID:
  30381. v, ok := value.(string)
  30382. if !ok {
  30383. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30384. }
  30385. m.SetBotID(v)
  30386. return nil
  30387. case usagestatisticday.FieldOrganizationID:
  30388. v, ok := value.(uint64)
  30389. if !ok {
  30390. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30391. }
  30392. m.SetOrganizationID(v)
  30393. return nil
  30394. case usagestatisticday.FieldAiResponse:
  30395. v, ok := value.(uint64)
  30396. if !ok {
  30397. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30398. }
  30399. m.SetAiResponse(v)
  30400. return nil
  30401. case usagestatisticday.FieldSopRun:
  30402. v, ok := value.(uint64)
  30403. if !ok {
  30404. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30405. }
  30406. m.SetSopRun(v)
  30407. return nil
  30408. case usagestatisticday.FieldTotalFriend:
  30409. v, ok := value.(uint64)
  30410. if !ok {
  30411. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30412. }
  30413. m.SetTotalFriend(v)
  30414. return nil
  30415. case usagestatisticday.FieldTotalGroup:
  30416. v, ok := value.(uint64)
  30417. if !ok {
  30418. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30419. }
  30420. m.SetTotalGroup(v)
  30421. return nil
  30422. case usagestatisticday.FieldAccountBalance:
  30423. v, ok := value.(uint64)
  30424. if !ok {
  30425. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30426. }
  30427. m.SetAccountBalance(v)
  30428. return nil
  30429. case usagestatisticday.FieldConsumeToken:
  30430. v, ok := value.(uint64)
  30431. if !ok {
  30432. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30433. }
  30434. m.SetConsumeToken(v)
  30435. return nil
  30436. case usagestatisticday.FieldActiveUser:
  30437. v, ok := value.(uint64)
  30438. if !ok {
  30439. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30440. }
  30441. m.SetActiveUser(v)
  30442. return nil
  30443. case usagestatisticday.FieldNewUser:
  30444. v, ok := value.(int64)
  30445. if !ok {
  30446. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30447. }
  30448. m.SetNewUser(v)
  30449. return nil
  30450. case usagestatisticday.FieldLabelDist:
  30451. v, ok := value.([]custom_types.LabelDist)
  30452. if !ok {
  30453. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30454. }
  30455. m.SetLabelDist(v)
  30456. return nil
  30457. }
  30458. return fmt.Errorf("unknown UsageStatisticDay field %s", name)
  30459. }
  30460. // AddedFields returns all numeric fields that were incremented/decremented during
  30461. // this mutation.
  30462. func (m *UsageStatisticDayMutation) AddedFields() []string {
  30463. var fields []string
  30464. if m.addstatus != nil {
  30465. fields = append(fields, usagestatisticday.FieldStatus)
  30466. }
  30467. if m.addaddtime != nil {
  30468. fields = append(fields, usagestatisticday.FieldAddtime)
  30469. }
  30470. if m.add_type != nil {
  30471. fields = append(fields, usagestatisticday.FieldType)
  30472. }
  30473. if m.addorganization_id != nil {
  30474. fields = append(fields, usagestatisticday.FieldOrganizationID)
  30475. }
  30476. if m.addai_response != nil {
  30477. fields = append(fields, usagestatisticday.FieldAiResponse)
  30478. }
  30479. if m.addsop_run != nil {
  30480. fields = append(fields, usagestatisticday.FieldSopRun)
  30481. }
  30482. if m.addtotal_friend != nil {
  30483. fields = append(fields, usagestatisticday.FieldTotalFriend)
  30484. }
  30485. if m.addtotal_group != nil {
  30486. fields = append(fields, usagestatisticday.FieldTotalGroup)
  30487. }
  30488. if m.addaccount_balance != nil {
  30489. fields = append(fields, usagestatisticday.FieldAccountBalance)
  30490. }
  30491. if m.addconsume_token != nil {
  30492. fields = append(fields, usagestatisticday.FieldConsumeToken)
  30493. }
  30494. if m.addactive_user != nil {
  30495. fields = append(fields, usagestatisticday.FieldActiveUser)
  30496. }
  30497. if m.addnew_user != nil {
  30498. fields = append(fields, usagestatisticday.FieldNewUser)
  30499. }
  30500. return fields
  30501. }
  30502. // AddedField returns the numeric value that was incremented/decremented on a field
  30503. // with the given name. The second boolean return value indicates that this field
  30504. // was not set, or was not defined in the schema.
  30505. func (m *UsageStatisticDayMutation) AddedField(name string) (ent.Value, bool) {
  30506. switch name {
  30507. case usagestatisticday.FieldStatus:
  30508. return m.AddedStatus()
  30509. case usagestatisticday.FieldAddtime:
  30510. return m.AddedAddtime()
  30511. case usagestatisticday.FieldType:
  30512. return m.AddedType()
  30513. case usagestatisticday.FieldOrganizationID:
  30514. return m.AddedOrganizationID()
  30515. case usagestatisticday.FieldAiResponse:
  30516. return m.AddedAiResponse()
  30517. case usagestatisticday.FieldSopRun:
  30518. return m.AddedSopRun()
  30519. case usagestatisticday.FieldTotalFriend:
  30520. return m.AddedTotalFriend()
  30521. case usagestatisticday.FieldTotalGroup:
  30522. return m.AddedTotalGroup()
  30523. case usagestatisticday.FieldAccountBalance:
  30524. return m.AddedAccountBalance()
  30525. case usagestatisticday.FieldConsumeToken:
  30526. return m.AddedConsumeToken()
  30527. case usagestatisticday.FieldActiveUser:
  30528. return m.AddedActiveUser()
  30529. case usagestatisticday.FieldNewUser:
  30530. return m.AddedNewUser()
  30531. }
  30532. return nil, false
  30533. }
  30534. // AddField adds the value to the field with the given name. It returns an error if
  30535. // the field is not defined in the schema, or if the type mismatched the field
  30536. // type.
  30537. func (m *UsageStatisticDayMutation) AddField(name string, value ent.Value) error {
  30538. switch name {
  30539. case usagestatisticday.FieldStatus:
  30540. v, ok := value.(int8)
  30541. if !ok {
  30542. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30543. }
  30544. m.AddStatus(v)
  30545. return nil
  30546. case usagestatisticday.FieldAddtime:
  30547. v, ok := value.(int64)
  30548. if !ok {
  30549. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30550. }
  30551. m.AddAddtime(v)
  30552. return nil
  30553. case usagestatisticday.FieldType:
  30554. v, ok := value.(int)
  30555. if !ok {
  30556. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30557. }
  30558. m.AddType(v)
  30559. return nil
  30560. case usagestatisticday.FieldOrganizationID:
  30561. v, ok := value.(int64)
  30562. if !ok {
  30563. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30564. }
  30565. m.AddOrganizationID(v)
  30566. return nil
  30567. case usagestatisticday.FieldAiResponse:
  30568. v, ok := value.(int64)
  30569. if !ok {
  30570. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30571. }
  30572. m.AddAiResponse(v)
  30573. return nil
  30574. case usagestatisticday.FieldSopRun:
  30575. v, ok := value.(int64)
  30576. if !ok {
  30577. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30578. }
  30579. m.AddSopRun(v)
  30580. return nil
  30581. case usagestatisticday.FieldTotalFriend:
  30582. v, ok := value.(int64)
  30583. if !ok {
  30584. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30585. }
  30586. m.AddTotalFriend(v)
  30587. return nil
  30588. case usagestatisticday.FieldTotalGroup:
  30589. v, ok := value.(int64)
  30590. if !ok {
  30591. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30592. }
  30593. m.AddTotalGroup(v)
  30594. return nil
  30595. case usagestatisticday.FieldAccountBalance:
  30596. v, ok := value.(int64)
  30597. if !ok {
  30598. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30599. }
  30600. m.AddAccountBalance(v)
  30601. return nil
  30602. case usagestatisticday.FieldConsumeToken:
  30603. v, ok := value.(int64)
  30604. if !ok {
  30605. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30606. }
  30607. m.AddConsumeToken(v)
  30608. return nil
  30609. case usagestatisticday.FieldActiveUser:
  30610. v, ok := value.(int64)
  30611. if !ok {
  30612. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30613. }
  30614. m.AddActiveUser(v)
  30615. return nil
  30616. case usagestatisticday.FieldNewUser:
  30617. v, ok := value.(int64)
  30618. if !ok {
  30619. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30620. }
  30621. m.AddNewUser(v)
  30622. return nil
  30623. }
  30624. return fmt.Errorf("unknown UsageStatisticDay numeric field %s", name)
  30625. }
  30626. // ClearedFields returns all nullable fields that were cleared during this
  30627. // mutation.
  30628. func (m *UsageStatisticDayMutation) ClearedFields() []string {
  30629. var fields []string
  30630. if m.FieldCleared(usagestatisticday.FieldStatus) {
  30631. fields = append(fields, usagestatisticday.FieldStatus)
  30632. }
  30633. if m.FieldCleared(usagestatisticday.FieldDeletedAt) {
  30634. fields = append(fields, usagestatisticday.FieldDeletedAt)
  30635. }
  30636. if m.FieldCleared(usagestatisticday.FieldBotID) {
  30637. fields = append(fields, usagestatisticday.FieldBotID)
  30638. }
  30639. if m.FieldCleared(usagestatisticday.FieldOrganizationID) {
  30640. fields = append(fields, usagestatisticday.FieldOrganizationID)
  30641. }
  30642. return fields
  30643. }
  30644. // FieldCleared returns a boolean indicating if a field with the given name was
  30645. // cleared in this mutation.
  30646. func (m *UsageStatisticDayMutation) FieldCleared(name string) bool {
  30647. _, ok := m.clearedFields[name]
  30648. return ok
  30649. }
  30650. // ClearField clears the value of the field with the given name. It returns an
  30651. // error if the field is not defined in the schema.
  30652. func (m *UsageStatisticDayMutation) ClearField(name string) error {
  30653. switch name {
  30654. case usagestatisticday.FieldStatus:
  30655. m.ClearStatus()
  30656. return nil
  30657. case usagestatisticday.FieldDeletedAt:
  30658. m.ClearDeletedAt()
  30659. return nil
  30660. case usagestatisticday.FieldBotID:
  30661. m.ClearBotID()
  30662. return nil
  30663. case usagestatisticday.FieldOrganizationID:
  30664. m.ClearOrganizationID()
  30665. return nil
  30666. }
  30667. return fmt.Errorf("unknown UsageStatisticDay nullable field %s", name)
  30668. }
  30669. // ResetField resets all changes in the mutation for the field with the given name.
  30670. // It returns an error if the field is not defined in the schema.
  30671. func (m *UsageStatisticDayMutation) ResetField(name string) error {
  30672. switch name {
  30673. case usagestatisticday.FieldCreatedAt:
  30674. m.ResetCreatedAt()
  30675. return nil
  30676. case usagestatisticday.FieldUpdatedAt:
  30677. m.ResetUpdatedAt()
  30678. return nil
  30679. case usagestatisticday.FieldStatus:
  30680. m.ResetStatus()
  30681. return nil
  30682. case usagestatisticday.FieldDeletedAt:
  30683. m.ResetDeletedAt()
  30684. return nil
  30685. case usagestatisticday.FieldAddtime:
  30686. m.ResetAddtime()
  30687. return nil
  30688. case usagestatisticday.FieldType:
  30689. m.ResetType()
  30690. return nil
  30691. case usagestatisticday.FieldBotID:
  30692. m.ResetBotID()
  30693. return nil
  30694. case usagestatisticday.FieldOrganizationID:
  30695. m.ResetOrganizationID()
  30696. return nil
  30697. case usagestatisticday.FieldAiResponse:
  30698. m.ResetAiResponse()
  30699. return nil
  30700. case usagestatisticday.FieldSopRun:
  30701. m.ResetSopRun()
  30702. return nil
  30703. case usagestatisticday.FieldTotalFriend:
  30704. m.ResetTotalFriend()
  30705. return nil
  30706. case usagestatisticday.FieldTotalGroup:
  30707. m.ResetTotalGroup()
  30708. return nil
  30709. case usagestatisticday.FieldAccountBalance:
  30710. m.ResetAccountBalance()
  30711. return nil
  30712. case usagestatisticday.FieldConsumeToken:
  30713. m.ResetConsumeToken()
  30714. return nil
  30715. case usagestatisticday.FieldActiveUser:
  30716. m.ResetActiveUser()
  30717. return nil
  30718. case usagestatisticday.FieldNewUser:
  30719. m.ResetNewUser()
  30720. return nil
  30721. case usagestatisticday.FieldLabelDist:
  30722. m.ResetLabelDist()
  30723. return nil
  30724. }
  30725. return fmt.Errorf("unknown UsageStatisticDay field %s", name)
  30726. }
  30727. // AddedEdges returns all edge names that were set/added in this mutation.
  30728. func (m *UsageStatisticDayMutation) AddedEdges() []string {
  30729. edges := make([]string, 0, 0)
  30730. return edges
  30731. }
  30732. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  30733. // name in this mutation.
  30734. func (m *UsageStatisticDayMutation) AddedIDs(name string) []ent.Value {
  30735. return nil
  30736. }
  30737. // RemovedEdges returns all edge names that were removed in this mutation.
  30738. func (m *UsageStatisticDayMutation) RemovedEdges() []string {
  30739. edges := make([]string, 0, 0)
  30740. return edges
  30741. }
  30742. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  30743. // the given name in this mutation.
  30744. func (m *UsageStatisticDayMutation) RemovedIDs(name string) []ent.Value {
  30745. return nil
  30746. }
  30747. // ClearedEdges returns all edge names that were cleared in this mutation.
  30748. func (m *UsageStatisticDayMutation) ClearedEdges() []string {
  30749. edges := make([]string, 0, 0)
  30750. return edges
  30751. }
  30752. // EdgeCleared returns a boolean which indicates if the edge with the given name
  30753. // was cleared in this mutation.
  30754. func (m *UsageStatisticDayMutation) EdgeCleared(name string) bool {
  30755. return false
  30756. }
  30757. // ClearEdge clears the value of the edge with the given name. It returns an error
  30758. // if that edge is not defined in the schema.
  30759. func (m *UsageStatisticDayMutation) ClearEdge(name string) error {
  30760. return fmt.Errorf("unknown UsageStatisticDay unique edge %s", name)
  30761. }
  30762. // ResetEdge resets all changes to the edge with the given name in this mutation.
  30763. // It returns an error if the edge is not defined in the schema.
  30764. func (m *UsageStatisticDayMutation) ResetEdge(name string) error {
  30765. return fmt.Errorf("unknown UsageStatisticDay edge %s", name)
  30766. }
  30767. // UsageStatisticHourMutation represents an operation that mutates the UsageStatisticHour nodes in the graph.
  30768. type UsageStatisticHourMutation struct {
  30769. config
  30770. op Op
  30771. typ string
  30772. id *uint64
  30773. created_at *time.Time
  30774. updated_at *time.Time
  30775. status *uint8
  30776. addstatus *int8
  30777. deleted_at *time.Time
  30778. addtime *uint64
  30779. addaddtime *int64
  30780. _type *int
  30781. add_type *int
  30782. bot_id *string
  30783. organization_id *uint64
  30784. addorganization_id *int64
  30785. ai_response *uint64
  30786. addai_response *int64
  30787. sop_run *uint64
  30788. addsop_run *int64
  30789. total_friend *uint64
  30790. addtotal_friend *int64
  30791. total_group *uint64
  30792. addtotal_group *int64
  30793. account_balance *uint64
  30794. addaccount_balance *int64
  30795. consume_token *uint64
  30796. addconsume_token *int64
  30797. active_user *uint64
  30798. addactive_user *int64
  30799. new_user *int64
  30800. addnew_user *int64
  30801. label_dist *[]custom_types.LabelDist
  30802. appendlabel_dist []custom_types.LabelDist
  30803. clearedFields map[string]struct{}
  30804. done bool
  30805. oldValue func(context.Context) (*UsageStatisticHour, error)
  30806. predicates []predicate.UsageStatisticHour
  30807. }
  30808. var _ ent.Mutation = (*UsageStatisticHourMutation)(nil)
  30809. // usagestatistichourOption allows management of the mutation configuration using functional options.
  30810. type usagestatistichourOption func(*UsageStatisticHourMutation)
  30811. // newUsageStatisticHourMutation creates new mutation for the UsageStatisticHour entity.
  30812. func newUsageStatisticHourMutation(c config, op Op, opts ...usagestatistichourOption) *UsageStatisticHourMutation {
  30813. m := &UsageStatisticHourMutation{
  30814. config: c,
  30815. op: op,
  30816. typ: TypeUsageStatisticHour,
  30817. clearedFields: make(map[string]struct{}),
  30818. }
  30819. for _, opt := range opts {
  30820. opt(m)
  30821. }
  30822. return m
  30823. }
  30824. // withUsageStatisticHourID sets the ID field of the mutation.
  30825. func withUsageStatisticHourID(id uint64) usagestatistichourOption {
  30826. return func(m *UsageStatisticHourMutation) {
  30827. var (
  30828. err error
  30829. once sync.Once
  30830. value *UsageStatisticHour
  30831. )
  30832. m.oldValue = func(ctx context.Context) (*UsageStatisticHour, error) {
  30833. once.Do(func() {
  30834. if m.done {
  30835. err = errors.New("querying old values post mutation is not allowed")
  30836. } else {
  30837. value, err = m.Client().UsageStatisticHour.Get(ctx, id)
  30838. }
  30839. })
  30840. return value, err
  30841. }
  30842. m.id = &id
  30843. }
  30844. }
  30845. // withUsageStatisticHour sets the old UsageStatisticHour of the mutation.
  30846. func withUsageStatisticHour(node *UsageStatisticHour) usagestatistichourOption {
  30847. return func(m *UsageStatisticHourMutation) {
  30848. m.oldValue = func(context.Context) (*UsageStatisticHour, error) {
  30849. return node, nil
  30850. }
  30851. m.id = &node.ID
  30852. }
  30853. }
  30854. // Client returns a new `ent.Client` from the mutation. If the mutation was
  30855. // executed in a transaction (ent.Tx), a transactional client is returned.
  30856. func (m UsageStatisticHourMutation) Client() *Client {
  30857. client := &Client{config: m.config}
  30858. client.init()
  30859. return client
  30860. }
  30861. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  30862. // it returns an error otherwise.
  30863. func (m UsageStatisticHourMutation) Tx() (*Tx, error) {
  30864. if _, ok := m.driver.(*txDriver); !ok {
  30865. return nil, errors.New("ent: mutation is not running in a transaction")
  30866. }
  30867. tx := &Tx{config: m.config}
  30868. tx.init()
  30869. return tx, nil
  30870. }
  30871. // SetID sets the value of the id field. Note that this
  30872. // operation is only accepted on creation of UsageStatisticHour entities.
  30873. func (m *UsageStatisticHourMutation) SetID(id uint64) {
  30874. m.id = &id
  30875. }
  30876. // ID returns the ID value in the mutation. Note that the ID is only available
  30877. // if it was provided to the builder or after it was returned from the database.
  30878. func (m *UsageStatisticHourMutation) ID() (id uint64, exists bool) {
  30879. if m.id == nil {
  30880. return
  30881. }
  30882. return *m.id, true
  30883. }
  30884. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  30885. // That means, if the mutation is applied within a transaction with an isolation level such
  30886. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  30887. // or updated by the mutation.
  30888. func (m *UsageStatisticHourMutation) IDs(ctx context.Context) ([]uint64, error) {
  30889. switch {
  30890. case m.op.Is(OpUpdateOne | OpDeleteOne):
  30891. id, exists := m.ID()
  30892. if exists {
  30893. return []uint64{id}, nil
  30894. }
  30895. fallthrough
  30896. case m.op.Is(OpUpdate | OpDelete):
  30897. return m.Client().UsageStatisticHour.Query().Where(m.predicates...).IDs(ctx)
  30898. default:
  30899. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  30900. }
  30901. }
  30902. // SetCreatedAt sets the "created_at" field.
  30903. func (m *UsageStatisticHourMutation) SetCreatedAt(t time.Time) {
  30904. m.created_at = &t
  30905. }
  30906. // CreatedAt returns the value of the "created_at" field in the mutation.
  30907. func (m *UsageStatisticHourMutation) CreatedAt() (r time.Time, exists bool) {
  30908. v := m.created_at
  30909. if v == nil {
  30910. return
  30911. }
  30912. return *v, true
  30913. }
  30914. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticHour entity.
  30915. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30916. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30917. func (m *UsageStatisticHourMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  30918. if !m.op.Is(OpUpdateOne) {
  30919. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  30920. }
  30921. if m.id == nil || m.oldValue == nil {
  30922. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  30923. }
  30924. oldValue, err := m.oldValue(ctx)
  30925. if err != nil {
  30926. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  30927. }
  30928. return oldValue.CreatedAt, nil
  30929. }
  30930. // ResetCreatedAt resets all changes to the "created_at" field.
  30931. func (m *UsageStatisticHourMutation) ResetCreatedAt() {
  30932. m.created_at = nil
  30933. }
  30934. // SetUpdatedAt sets the "updated_at" field.
  30935. func (m *UsageStatisticHourMutation) SetUpdatedAt(t time.Time) {
  30936. m.updated_at = &t
  30937. }
  30938. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  30939. func (m *UsageStatisticHourMutation) UpdatedAt() (r time.Time, exists bool) {
  30940. v := m.updated_at
  30941. if v == nil {
  30942. return
  30943. }
  30944. return *v, true
  30945. }
  30946. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticHour entity.
  30947. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30948. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30949. func (m *UsageStatisticHourMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  30950. if !m.op.Is(OpUpdateOne) {
  30951. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  30952. }
  30953. if m.id == nil || m.oldValue == nil {
  30954. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  30955. }
  30956. oldValue, err := m.oldValue(ctx)
  30957. if err != nil {
  30958. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  30959. }
  30960. return oldValue.UpdatedAt, nil
  30961. }
  30962. // ResetUpdatedAt resets all changes to the "updated_at" field.
  30963. func (m *UsageStatisticHourMutation) ResetUpdatedAt() {
  30964. m.updated_at = nil
  30965. }
  30966. // SetStatus sets the "status" field.
  30967. func (m *UsageStatisticHourMutation) SetStatus(u uint8) {
  30968. m.status = &u
  30969. m.addstatus = nil
  30970. }
  30971. // Status returns the value of the "status" field in the mutation.
  30972. func (m *UsageStatisticHourMutation) Status() (r uint8, exists bool) {
  30973. v := m.status
  30974. if v == nil {
  30975. return
  30976. }
  30977. return *v, true
  30978. }
  30979. // OldStatus returns the old "status" field's value of the UsageStatisticHour entity.
  30980. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30981. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30982. func (m *UsageStatisticHourMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  30983. if !m.op.Is(OpUpdateOne) {
  30984. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  30985. }
  30986. if m.id == nil || m.oldValue == nil {
  30987. return v, errors.New("OldStatus requires an ID field in the mutation")
  30988. }
  30989. oldValue, err := m.oldValue(ctx)
  30990. if err != nil {
  30991. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  30992. }
  30993. return oldValue.Status, nil
  30994. }
  30995. // AddStatus adds u to the "status" field.
  30996. func (m *UsageStatisticHourMutation) AddStatus(u int8) {
  30997. if m.addstatus != nil {
  30998. *m.addstatus += u
  30999. } else {
  31000. m.addstatus = &u
  31001. }
  31002. }
  31003. // AddedStatus returns the value that was added to the "status" field in this mutation.
  31004. func (m *UsageStatisticHourMutation) AddedStatus() (r int8, exists bool) {
  31005. v := m.addstatus
  31006. if v == nil {
  31007. return
  31008. }
  31009. return *v, true
  31010. }
  31011. // ClearStatus clears the value of the "status" field.
  31012. func (m *UsageStatisticHourMutation) ClearStatus() {
  31013. m.status = nil
  31014. m.addstatus = nil
  31015. m.clearedFields[usagestatistichour.FieldStatus] = struct{}{}
  31016. }
  31017. // StatusCleared returns if the "status" field was cleared in this mutation.
  31018. func (m *UsageStatisticHourMutation) StatusCleared() bool {
  31019. _, ok := m.clearedFields[usagestatistichour.FieldStatus]
  31020. return ok
  31021. }
  31022. // ResetStatus resets all changes to the "status" field.
  31023. func (m *UsageStatisticHourMutation) ResetStatus() {
  31024. m.status = nil
  31025. m.addstatus = nil
  31026. delete(m.clearedFields, usagestatistichour.FieldStatus)
  31027. }
  31028. // SetDeletedAt sets the "deleted_at" field.
  31029. func (m *UsageStatisticHourMutation) SetDeletedAt(t time.Time) {
  31030. m.deleted_at = &t
  31031. }
  31032. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  31033. func (m *UsageStatisticHourMutation) DeletedAt() (r time.Time, exists bool) {
  31034. v := m.deleted_at
  31035. if v == nil {
  31036. return
  31037. }
  31038. return *v, true
  31039. }
  31040. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticHour entity.
  31041. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  31042. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31043. func (m *UsageStatisticHourMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  31044. if !m.op.Is(OpUpdateOne) {
  31045. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  31046. }
  31047. if m.id == nil || m.oldValue == nil {
  31048. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  31049. }
  31050. oldValue, err := m.oldValue(ctx)
  31051. if err != nil {
  31052. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  31053. }
  31054. return oldValue.DeletedAt, nil
  31055. }
  31056. // ClearDeletedAt clears the value of the "deleted_at" field.
  31057. func (m *UsageStatisticHourMutation) ClearDeletedAt() {
  31058. m.deleted_at = nil
  31059. m.clearedFields[usagestatistichour.FieldDeletedAt] = struct{}{}
  31060. }
  31061. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  31062. func (m *UsageStatisticHourMutation) DeletedAtCleared() bool {
  31063. _, ok := m.clearedFields[usagestatistichour.FieldDeletedAt]
  31064. return ok
  31065. }
  31066. // ResetDeletedAt resets all changes to the "deleted_at" field.
  31067. func (m *UsageStatisticHourMutation) ResetDeletedAt() {
  31068. m.deleted_at = nil
  31069. delete(m.clearedFields, usagestatistichour.FieldDeletedAt)
  31070. }
  31071. // SetAddtime sets the "addtime" field.
  31072. func (m *UsageStatisticHourMutation) SetAddtime(u uint64) {
  31073. m.addtime = &u
  31074. m.addaddtime = nil
  31075. }
  31076. // Addtime returns the value of the "addtime" field in the mutation.
  31077. func (m *UsageStatisticHourMutation) Addtime() (r uint64, exists bool) {
  31078. v := m.addtime
  31079. if v == nil {
  31080. return
  31081. }
  31082. return *v, true
  31083. }
  31084. // OldAddtime returns the old "addtime" field's value of the UsageStatisticHour entity.
  31085. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  31086. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31087. func (m *UsageStatisticHourMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  31088. if !m.op.Is(OpUpdateOne) {
  31089. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  31090. }
  31091. if m.id == nil || m.oldValue == nil {
  31092. return v, errors.New("OldAddtime requires an ID field in the mutation")
  31093. }
  31094. oldValue, err := m.oldValue(ctx)
  31095. if err != nil {
  31096. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  31097. }
  31098. return oldValue.Addtime, nil
  31099. }
  31100. // AddAddtime adds u to the "addtime" field.
  31101. func (m *UsageStatisticHourMutation) AddAddtime(u int64) {
  31102. if m.addaddtime != nil {
  31103. *m.addaddtime += u
  31104. } else {
  31105. m.addaddtime = &u
  31106. }
  31107. }
  31108. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  31109. func (m *UsageStatisticHourMutation) AddedAddtime() (r int64, exists bool) {
  31110. v := m.addaddtime
  31111. if v == nil {
  31112. return
  31113. }
  31114. return *v, true
  31115. }
  31116. // ResetAddtime resets all changes to the "addtime" field.
  31117. func (m *UsageStatisticHourMutation) ResetAddtime() {
  31118. m.addtime = nil
  31119. m.addaddtime = nil
  31120. }
  31121. // SetType sets the "type" field.
  31122. func (m *UsageStatisticHourMutation) SetType(i int) {
  31123. m._type = &i
  31124. m.add_type = nil
  31125. }
  31126. // GetType returns the value of the "type" field in the mutation.
  31127. func (m *UsageStatisticHourMutation) GetType() (r int, exists bool) {
  31128. v := m._type
  31129. if v == nil {
  31130. return
  31131. }
  31132. return *v, true
  31133. }
  31134. // OldType returns the old "type" field's value of the UsageStatisticHour entity.
  31135. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  31136. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31137. func (m *UsageStatisticHourMutation) OldType(ctx context.Context) (v int, err error) {
  31138. if !m.op.Is(OpUpdateOne) {
  31139. return v, errors.New("OldType is only allowed on UpdateOne operations")
  31140. }
  31141. if m.id == nil || m.oldValue == nil {
  31142. return v, errors.New("OldType requires an ID field in the mutation")
  31143. }
  31144. oldValue, err := m.oldValue(ctx)
  31145. if err != nil {
  31146. return v, fmt.Errorf("querying old value for OldType: %w", err)
  31147. }
  31148. return oldValue.Type, nil
  31149. }
  31150. // AddType adds i to the "type" field.
  31151. func (m *UsageStatisticHourMutation) AddType(i int) {
  31152. if m.add_type != nil {
  31153. *m.add_type += i
  31154. } else {
  31155. m.add_type = &i
  31156. }
  31157. }
  31158. // AddedType returns the value that was added to the "type" field in this mutation.
  31159. func (m *UsageStatisticHourMutation) AddedType() (r int, exists bool) {
  31160. v := m.add_type
  31161. if v == nil {
  31162. return
  31163. }
  31164. return *v, true
  31165. }
  31166. // ResetType resets all changes to the "type" field.
  31167. func (m *UsageStatisticHourMutation) ResetType() {
  31168. m._type = nil
  31169. m.add_type = nil
  31170. }
  31171. // SetBotID sets the "bot_id" field.
  31172. func (m *UsageStatisticHourMutation) SetBotID(s string) {
  31173. m.bot_id = &s
  31174. }
  31175. // BotID returns the value of the "bot_id" field in the mutation.
  31176. func (m *UsageStatisticHourMutation) BotID() (r string, exists bool) {
  31177. v := m.bot_id
  31178. if v == nil {
  31179. return
  31180. }
  31181. return *v, true
  31182. }
  31183. // OldBotID returns the old "bot_id" field's value of the UsageStatisticHour entity.
  31184. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  31185. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31186. func (m *UsageStatisticHourMutation) OldBotID(ctx context.Context) (v string, err error) {
  31187. if !m.op.Is(OpUpdateOne) {
  31188. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  31189. }
  31190. if m.id == nil || m.oldValue == nil {
  31191. return v, errors.New("OldBotID requires an ID field in the mutation")
  31192. }
  31193. oldValue, err := m.oldValue(ctx)
  31194. if err != nil {
  31195. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  31196. }
  31197. return oldValue.BotID, nil
  31198. }
  31199. // ClearBotID clears the value of the "bot_id" field.
  31200. func (m *UsageStatisticHourMutation) ClearBotID() {
  31201. m.bot_id = nil
  31202. m.clearedFields[usagestatistichour.FieldBotID] = struct{}{}
  31203. }
  31204. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  31205. func (m *UsageStatisticHourMutation) BotIDCleared() bool {
  31206. _, ok := m.clearedFields[usagestatistichour.FieldBotID]
  31207. return ok
  31208. }
  31209. // ResetBotID resets all changes to the "bot_id" field.
  31210. func (m *UsageStatisticHourMutation) ResetBotID() {
  31211. m.bot_id = nil
  31212. delete(m.clearedFields, usagestatistichour.FieldBotID)
  31213. }
  31214. // SetOrganizationID sets the "organization_id" field.
  31215. func (m *UsageStatisticHourMutation) SetOrganizationID(u uint64) {
  31216. m.organization_id = &u
  31217. m.addorganization_id = nil
  31218. }
  31219. // OrganizationID returns the value of the "organization_id" field in the mutation.
  31220. func (m *UsageStatisticHourMutation) OrganizationID() (r uint64, exists bool) {
  31221. v := m.organization_id
  31222. if v == nil {
  31223. return
  31224. }
  31225. return *v, true
  31226. }
  31227. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticHour entity.
  31228. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  31229. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31230. func (m *UsageStatisticHourMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  31231. if !m.op.Is(OpUpdateOne) {
  31232. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  31233. }
  31234. if m.id == nil || m.oldValue == nil {
  31235. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  31236. }
  31237. oldValue, err := m.oldValue(ctx)
  31238. if err != nil {
  31239. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  31240. }
  31241. return oldValue.OrganizationID, nil
  31242. }
  31243. // AddOrganizationID adds u to the "organization_id" field.
  31244. func (m *UsageStatisticHourMutation) AddOrganizationID(u int64) {
  31245. if m.addorganization_id != nil {
  31246. *m.addorganization_id += u
  31247. } else {
  31248. m.addorganization_id = &u
  31249. }
  31250. }
  31251. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  31252. func (m *UsageStatisticHourMutation) AddedOrganizationID() (r int64, exists bool) {
  31253. v := m.addorganization_id
  31254. if v == nil {
  31255. return
  31256. }
  31257. return *v, true
  31258. }
  31259. // ClearOrganizationID clears the value of the "organization_id" field.
  31260. func (m *UsageStatisticHourMutation) ClearOrganizationID() {
  31261. m.organization_id = nil
  31262. m.addorganization_id = nil
  31263. m.clearedFields[usagestatistichour.FieldOrganizationID] = struct{}{}
  31264. }
  31265. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  31266. func (m *UsageStatisticHourMutation) OrganizationIDCleared() bool {
  31267. _, ok := m.clearedFields[usagestatistichour.FieldOrganizationID]
  31268. return ok
  31269. }
  31270. // ResetOrganizationID resets all changes to the "organization_id" field.
  31271. func (m *UsageStatisticHourMutation) ResetOrganizationID() {
  31272. m.organization_id = nil
  31273. m.addorganization_id = nil
  31274. delete(m.clearedFields, usagestatistichour.FieldOrganizationID)
  31275. }
  31276. // SetAiResponse sets the "ai_response" field.
  31277. func (m *UsageStatisticHourMutation) SetAiResponse(u uint64) {
  31278. m.ai_response = &u
  31279. m.addai_response = nil
  31280. }
  31281. // AiResponse returns the value of the "ai_response" field in the mutation.
  31282. func (m *UsageStatisticHourMutation) AiResponse() (r uint64, exists bool) {
  31283. v := m.ai_response
  31284. if v == nil {
  31285. return
  31286. }
  31287. return *v, true
  31288. }
  31289. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticHour entity.
  31290. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  31291. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31292. func (m *UsageStatisticHourMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  31293. if !m.op.Is(OpUpdateOne) {
  31294. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  31295. }
  31296. if m.id == nil || m.oldValue == nil {
  31297. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  31298. }
  31299. oldValue, err := m.oldValue(ctx)
  31300. if err != nil {
  31301. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  31302. }
  31303. return oldValue.AiResponse, nil
  31304. }
  31305. // AddAiResponse adds u to the "ai_response" field.
  31306. func (m *UsageStatisticHourMutation) AddAiResponse(u int64) {
  31307. if m.addai_response != nil {
  31308. *m.addai_response += u
  31309. } else {
  31310. m.addai_response = &u
  31311. }
  31312. }
  31313. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  31314. func (m *UsageStatisticHourMutation) AddedAiResponse() (r int64, exists bool) {
  31315. v := m.addai_response
  31316. if v == nil {
  31317. return
  31318. }
  31319. return *v, true
  31320. }
  31321. // ResetAiResponse resets all changes to the "ai_response" field.
  31322. func (m *UsageStatisticHourMutation) ResetAiResponse() {
  31323. m.ai_response = nil
  31324. m.addai_response = nil
  31325. }
  31326. // SetSopRun sets the "sop_run" field.
  31327. func (m *UsageStatisticHourMutation) SetSopRun(u uint64) {
  31328. m.sop_run = &u
  31329. m.addsop_run = nil
  31330. }
  31331. // SopRun returns the value of the "sop_run" field in the mutation.
  31332. func (m *UsageStatisticHourMutation) SopRun() (r uint64, exists bool) {
  31333. v := m.sop_run
  31334. if v == nil {
  31335. return
  31336. }
  31337. return *v, true
  31338. }
  31339. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticHour entity.
  31340. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  31341. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31342. func (m *UsageStatisticHourMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  31343. if !m.op.Is(OpUpdateOne) {
  31344. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  31345. }
  31346. if m.id == nil || m.oldValue == nil {
  31347. return v, errors.New("OldSopRun requires an ID field in the mutation")
  31348. }
  31349. oldValue, err := m.oldValue(ctx)
  31350. if err != nil {
  31351. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  31352. }
  31353. return oldValue.SopRun, nil
  31354. }
  31355. // AddSopRun adds u to the "sop_run" field.
  31356. func (m *UsageStatisticHourMutation) AddSopRun(u int64) {
  31357. if m.addsop_run != nil {
  31358. *m.addsop_run += u
  31359. } else {
  31360. m.addsop_run = &u
  31361. }
  31362. }
  31363. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  31364. func (m *UsageStatisticHourMutation) AddedSopRun() (r int64, exists bool) {
  31365. v := m.addsop_run
  31366. if v == nil {
  31367. return
  31368. }
  31369. return *v, true
  31370. }
  31371. // ResetSopRun resets all changes to the "sop_run" field.
  31372. func (m *UsageStatisticHourMutation) ResetSopRun() {
  31373. m.sop_run = nil
  31374. m.addsop_run = nil
  31375. }
  31376. // SetTotalFriend sets the "total_friend" field.
  31377. func (m *UsageStatisticHourMutation) SetTotalFriend(u uint64) {
  31378. m.total_friend = &u
  31379. m.addtotal_friend = nil
  31380. }
  31381. // TotalFriend returns the value of the "total_friend" field in the mutation.
  31382. func (m *UsageStatisticHourMutation) TotalFriend() (r uint64, exists bool) {
  31383. v := m.total_friend
  31384. if v == nil {
  31385. return
  31386. }
  31387. return *v, true
  31388. }
  31389. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticHour entity.
  31390. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  31391. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31392. func (m *UsageStatisticHourMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  31393. if !m.op.Is(OpUpdateOne) {
  31394. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  31395. }
  31396. if m.id == nil || m.oldValue == nil {
  31397. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  31398. }
  31399. oldValue, err := m.oldValue(ctx)
  31400. if err != nil {
  31401. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  31402. }
  31403. return oldValue.TotalFriend, nil
  31404. }
  31405. // AddTotalFriend adds u to the "total_friend" field.
  31406. func (m *UsageStatisticHourMutation) AddTotalFriend(u int64) {
  31407. if m.addtotal_friend != nil {
  31408. *m.addtotal_friend += u
  31409. } else {
  31410. m.addtotal_friend = &u
  31411. }
  31412. }
  31413. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  31414. func (m *UsageStatisticHourMutation) AddedTotalFriend() (r int64, exists bool) {
  31415. v := m.addtotal_friend
  31416. if v == nil {
  31417. return
  31418. }
  31419. return *v, true
  31420. }
  31421. // ResetTotalFriend resets all changes to the "total_friend" field.
  31422. func (m *UsageStatisticHourMutation) ResetTotalFriend() {
  31423. m.total_friend = nil
  31424. m.addtotal_friend = nil
  31425. }
  31426. // SetTotalGroup sets the "total_group" field.
  31427. func (m *UsageStatisticHourMutation) SetTotalGroup(u uint64) {
  31428. m.total_group = &u
  31429. m.addtotal_group = nil
  31430. }
  31431. // TotalGroup returns the value of the "total_group" field in the mutation.
  31432. func (m *UsageStatisticHourMutation) TotalGroup() (r uint64, exists bool) {
  31433. v := m.total_group
  31434. if v == nil {
  31435. return
  31436. }
  31437. return *v, true
  31438. }
  31439. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticHour entity.
  31440. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  31441. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31442. func (m *UsageStatisticHourMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  31443. if !m.op.Is(OpUpdateOne) {
  31444. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  31445. }
  31446. if m.id == nil || m.oldValue == nil {
  31447. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  31448. }
  31449. oldValue, err := m.oldValue(ctx)
  31450. if err != nil {
  31451. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  31452. }
  31453. return oldValue.TotalGroup, nil
  31454. }
  31455. // AddTotalGroup adds u to the "total_group" field.
  31456. func (m *UsageStatisticHourMutation) AddTotalGroup(u int64) {
  31457. if m.addtotal_group != nil {
  31458. *m.addtotal_group += u
  31459. } else {
  31460. m.addtotal_group = &u
  31461. }
  31462. }
  31463. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  31464. func (m *UsageStatisticHourMutation) AddedTotalGroup() (r int64, exists bool) {
  31465. v := m.addtotal_group
  31466. if v == nil {
  31467. return
  31468. }
  31469. return *v, true
  31470. }
  31471. // ResetTotalGroup resets all changes to the "total_group" field.
  31472. func (m *UsageStatisticHourMutation) ResetTotalGroup() {
  31473. m.total_group = nil
  31474. m.addtotal_group = nil
  31475. }
  31476. // SetAccountBalance sets the "account_balance" field.
  31477. func (m *UsageStatisticHourMutation) SetAccountBalance(u uint64) {
  31478. m.account_balance = &u
  31479. m.addaccount_balance = nil
  31480. }
  31481. // AccountBalance returns the value of the "account_balance" field in the mutation.
  31482. func (m *UsageStatisticHourMutation) AccountBalance() (r uint64, exists bool) {
  31483. v := m.account_balance
  31484. if v == nil {
  31485. return
  31486. }
  31487. return *v, true
  31488. }
  31489. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticHour entity.
  31490. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  31491. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31492. func (m *UsageStatisticHourMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  31493. if !m.op.Is(OpUpdateOne) {
  31494. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  31495. }
  31496. if m.id == nil || m.oldValue == nil {
  31497. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  31498. }
  31499. oldValue, err := m.oldValue(ctx)
  31500. if err != nil {
  31501. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  31502. }
  31503. return oldValue.AccountBalance, nil
  31504. }
  31505. // AddAccountBalance adds u to the "account_balance" field.
  31506. func (m *UsageStatisticHourMutation) AddAccountBalance(u int64) {
  31507. if m.addaccount_balance != nil {
  31508. *m.addaccount_balance += u
  31509. } else {
  31510. m.addaccount_balance = &u
  31511. }
  31512. }
  31513. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  31514. func (m *UsageStatisticHourMutation) AddedAccountBalance() (r int64, exists bool) {
  31515. v := m.addaccount_balance
  31516. if v == nil {
  31517. return
  31518. }
  31519. return *v, true
  31520. }
  31521. // ResetAccountBalance resets all changes to the "account_balance" field.
  31522. func (m *UsageStatisticHourMutation) ResetAccountBalance() {
  31523. m.account_balance = nil
  31524. m.addaccount_balance = nil
  31525. }
  31526. // SetConsumeToken sets the "consume_token" field.
  31527. func (m *UsageStatisticHourMutation) SetConsumeToken(u uint64) {
  31528. m.consume_token = &u
  31529. m.addconsume_token = nil
  31530. }
  31531. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  31532. func (m *UsageStatisticHourMutation) ConsumeToken() (r uint64, exists bool) {
  31533. v := m.consume_token
  31534. if v == nil {
  31535. return
  31536. }
  31537. return *v, true
  31538. }
  31539. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticHour entity.
  31540. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  31541. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31542. func (m *UsageStatisticHourMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  31543. if !m.op.Is(OpUpdateOne) {
  31544. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  31545. }
  31546. if m.id == nil || m.oldValue == nil {
  31547. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  31548. }
  31549. oldValue, err := m.oldValue(ctx)
  31550. if err != nil {
  31551. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  31552. }
  31553. return oldValue.ConsumeToken, nil
  31554. }
  31555. // AddConsumeToken adds u to the "consume_token" field.
  31556. func (m *UsageStatisticHourMutation) AddConsumeToken(u int64) {
  31557. if m.addconsume_token != nil {
  31558. *m.addconsume_token += u
  31559. } else {
  31560. m.addconsume_token = &u
  31561. }
  31562. }
  31563. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  31564. func (m *UsageStatisticHourMutation) AddedConsumeToken() (r int64, exists bool) {
  31565. v := m.addconsume_token
  31566. if v == nil {
  31567. return
  31568. }
  31569. return *v, true
  31570. }
  31571. // ResetConsumeToken resets all changes to the "consume_token" field.
  31572. func (m *UsageStatisticHourMutation) ResetConsumeToken() {
  31573. m.consume_token = nil
  31574. m.addconsume_token = nil
  31575. }
  31576. // SetActiveUser sets the "active_user" field.
  31577. func (m *UsageStatisticHourMutation) SetActiveUser(u uint64) {
  31578. m.active_user = &u
  31579. m.addactive_user = nil
  31580. }
  31581. // ActiveUser returns the value of the "active_user" field in the mutation.
  31582. func (m *UsageStatisticHourMutation) ActiveUser() (r uint64, exists bool) {
  31583. v := m.active_user
  31584. if v == nil {
  31585. return
  31586. }
  31587. return *v, true
  31588. }
  31589. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticHour entity.
  31590. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  31591. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31592. func (m *UsageStatisticHourMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  31593. if !m.op.Is(OpUpdateOne) {
  31594. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  31595. }
  31596. if m.id == nil || m.oldValue == nil {
  31597. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  31598. }
  31599. oldValue, err := m.oldValue(ctx)
  31600. if err != nil {
  31601. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  31602. }
  31603. return oldValue.ActiveUser, nil
  31604. }
  31605. // AddActiveUser adds u to the "active_user" field.
  31606. func (m *UsageStatisticHourMutation) AddActiveUser(u int64) {
  31607. if m.addactive_user != nil {
  31608. *m.addactive_user += u
  31609. } else {
  31610. m.addactive_user = &u
  31611. }
  31612. }
  31613. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  31614. func (m *UsageStatisticHourMutation) AddedActiveUser() (r int64, exists bool) {
  31615. v := m.addactive_user
  31616. if v == nil {
  31617. return
  31618. }
  31619. return *v, true
  31620. }
  31621. // ResetActiveUser resets all changes to the "active_user" field.
  31622. func (m *UsageStatisticHourMutation) ResetActiveUser() {
  31623. m.active_user = nil
  31624. m.addactive_user = nil
  31625. }
  31626. // SetNewUser sets the "new_user" field.
  31627. func (m *UsageStatisticHourMutation) SetNewUser(i int64) {
  31628. m.new_user = &i
  31629. m.addnew_user = nil
  31630. }
  31631. // NewUser returns the value of the "new_user" field in the mutation.
  31632. func (m *UsageStatisticHourMutation) NewUser() (r int64, exists bool) {
  31633. v := m.new_user
  31634. if v == nil {
  31635. return
  31636. }
  31637. return *v, true
  31638. }
  31639. // OldNewUser returns the old "new_user" field's value of the UsageStatisticHour entity.
  31640. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  31641. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31642. func (m *UsageStatisticHourMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  31643. if !m.op.Is(OpUpdateOne) {
  31644. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  31645. }
  31646. if m.id == nil || m.oldValue == nil {
  31647. return v, errors.New("OldNewUser requires an ID field in the mutation")
  31648. }
  31649. oldValue, err := m.oldValue(ctx)
  31650. if err != nil {
  31651. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  31652. }
  31653. return oldValue.NewUser, nil
  31654. }
  31655. // AddNewUser adds i to the "new_user" field.
  31656. func (m *UsageStatisticHourMutation) AddNewUser(i int64) {
  31657. if m.addnew_user != nil {
  31658. *m.addnew_user += i
  31659. } else {
  31660. m.addnew_user = &i
  31661. }
  31662. }
  31663. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  31664. func (m *UsageStatisticHourMutation) AddedNewUser() (r int64, exists bool) {
  31665. v := m.addnew_user
  31666. if v == nil {
  31667. return
  31668. }
  31669. return *v, true
  31670. }
  31671. // ResetNewUser resets all changes to the "new_user" field.
  31672. func (m *UsageStatisticHourMutation) ResetNewUser() {
  31673. m.new_user = nil
  31674. m.addnew_user = nil
  31675. }
  31676. // SetLabelDist sets the "label_dist" field.
  31677. func (m *UsageStatisticHourMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  31678. m.label_dist = &ctd
  31679. m.appendlabel_dist = nil
  31680. }
  31681. // LabelDist returns the value of the "label_dist" field in the mutation.
  31682. func (m *UsageStatisticHourMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  31683. v := m.label_dist
  31684. if v == nil {
  31685. return
  31686. }
  31687. return *v, true
  31688. }
  31689. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticHour entity.
  31690. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  31691. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31692. func (m *UsageStatisticHourMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  31693. if !m.op.Is(OpUpdateOne) {
  31694. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  31695. }
  31696. if m.id == nil || m.oldValue == nil {
  31697. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  31698. }
  31699. oldValue, err := m.oldValue(ctx)
  31700. if err != nil {
  31701. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  31702. }
  31703. return oldValue.LabelDist, nil
  31704. }
  31705. // AppendLabelDist adds ctd to the "label_dist" field.
  31706. func (m *UsageStatisticHourMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  31707. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  31708. }
  31709. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  31710. func (m *UsageStatisticHourMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  31711. if len(m.appendlabel_dist) == 0 {
  31712. return nil, false
  31713. }
  31714. return m.appendlabel_dist, true
  31715. }
  31716. // ResetLabelDist resets all changes to the "label_dist" field.
  31717. func (m *UsageStatisticHourMutation) ResetLabelDist() {
  31718. m.label_dist = nil
  31719. m.appendlabel_dist = nil
  31720. }
  31721. // Where appends a list predicates to the UsageStatisticHourMutation builder.
  31722. func (m *UsageStatisticHourMutation) Where(ps ...predicate.UsageStatisticHour) {
  31723. m.predicates = append(m.predicates, ps...)
  31724. }
  31725. // WhereP appends storage-level predicates to the UsageStatisticHourMutation builder. Using this method,
  31726. // users can use type-assertion to append predicates that do not depend on any generated package.
  31727. func (m *UsageStatisticHourMutation) WhereP(ps ...func(*sql.Selector)) {
  31728. p := make([]predicate.UsageStatisticHour, len(ps))
  31729. for i := range ps {
  31730. p[i] = ps[i]
  31731. }
  31732. m.Where(p...)
  31733. }
  31734. // Op returns the operation name.
  31735. func (m *UsageStatisticHourMutation) Op() Op {
  31736. return m.op
  31737. }
  31738. // SetOp allows setting the mutation operation.
  31739. func (m *UsageStatisticHourMutation) SetOp(op Op) {
  31740. m.op = op
  31741. }
  31742. // Type returns the node type of this mutation (UsageStatisticHour).
  31743. func (m *UsageStatisticHourMutation) Type() string {
  31744. return m.typ
  31745. }
  31746. // Fields returns all fields that were changed during this mutation. Note that in
  31747. // order to get all numeric fields that were incremented/decremented, call
  31748. // AddedFields().
  31749. func (m *UsageStatisticHourMutation) Fields() []string {
  31750. fields := make([]string, 0, 17)
  31751. if m.created_at != nil {
  31752. fields = append(fields, usagestatistichour.FieldCreatedAt)
  31753. }
  31754. if m.updated_at != nil {
  31755. fields = append(fields, usagestatistichour.FieldUpdatedAt)
  31756. }
  31757. if m.status != nil {
  31758. fields = append(fields, usagestatistichour.FieldStatus)
  31759. }
  31760. if m.deleted_at != nil {
  31761. fields = append(fields, usagestatistichour.FieldDeletedAt)
  31762. }
  31763. if m.addtime != nil {
  31764. fields = append(fields, usagestatistichour.FieldAddtime)
  31765. }
  31766. if m._type != nil {
  31767. fields = append(fields, usagestatistichour.FieldType)
  31768. }
  31769. if m.bot_id != nil {
  31770. fields = append(fields, usagestatistichour.FieldBotID)
  31771. }
  31772. if m.organization_id != nil {
  31773. fields = append(fields, usagestatistichour.FieldOrganizationID)
  31774. }
  31775. if m.ai_response != nil {
  31776. fields = append(fields, usagestatistichour.FieldAiResponse)
  31777. }
  31778. if m.sop_run != nil {
  31779. fields = append(fields, usagestatistichour.FieldSopRun)
  31780. }
  31781. if m.total_friend != nil {
  31782. fields = append(fields, usagestatistichour.FieldTotalFriend)
  31783. }
  31784. if m.total_group != nil {
  31785. fields = append(fields, usagestatistichour.FieldTotalGroup)
  31786. }
  31787. if m.account_balance != nil {
  31788. fields = append(fields, usagestatistichour.FieldAccountBalance)
  31789. }
  31790. if m.consume_token != nil {
  31791. fields = append(fields, usagestatistichour.FieldConsumeToken)
  31792. }
  31793. if m.active_user != nil {
  31794. fields = append(fields, usagestatistichour.FieldActiveUser)
  31795. }
  31796. if m.new_user != nil {
  31797. fields = append(fields, usagestatistichour.FieldNewUser)
  31798. }
  31799. if m.label_dist != nil {
  31800. fields = append(fields, usagestatistichour.FieldLabelDist)
  31801. }
  31802. return fields
  31803. }
  31804. // Field returns the value of a field with the given name. The second boolean
  31805. // return value indicates that this field was not set, or was not defined in the
  31806. // schema.
  31807. func (m *UsageStatisticHourMutation) Field(name string) (ent.Value, bool) {
  31808. switch name {
  31809. case usagestatistichour.FieldCreatedAt:
  31810. return m.CreatedAt()
  31811. case usagestatistichour.FieldUpdatedAt:
  31812. return m.UpdatedAt()
  31813. case usagestatistichour.FieldStatus:
  31814. return m.Status()
  31815. case usagestatistichour.FieldDeletedAt:
  31816. return m.DeletedAt()
  31817. case usagestatistichour.FieldAddtime:
  31818. return m.Addtime()
  31819. case usagestatistichour.FieldType:
  31820. return m.GetType()
  31821. case usagestatistichour.FieldBotID:
  31822. return m.BotID()
  31823. case usagestatistichour.FieldOrganizationID:
  31824. return m.OrganizationID()
  31825. case usagestatistichour.FieldAiResponse:
  31826. return m.AiResponse()
  31827. case usagestatistichour.FieldSopRun:
  31828. return m.SopRun()
  31829. case usagestatistichour.FieldTotalFriend:
  31830. return m.TotalFriend()
  31831. case usagestatistichour.FieldTotalGroup:
  31832. return m.TotalGroup()
  31833. case usagestatistichour.FieldAccountBalance:
  31834. return m.AccountBalance()
  31835. case usagestatistichour.FieldConsumeToken:
  31836. return m.ConsumeToken()
  31837. case usagestatistichour.FieldActiveUser:
  31838. return m.ActiveUser()
  31839. case usagestatistichour.FieldNewUser:
  31840. return m.NewUser()
  31841. case usagestatistichour.FieldLabelDist:
  31842. return m.LabelDist()
  31843. }
  31844. return nil, false
  31845. }
  31846. // OldField returns the old value of the field from the database. An error is
  31847. // returned if the mutation operation is not UpdateOne, or the query to the
  31848. // database failed.
  31849. func (m *UsageStatisticHourMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  31850. switch name {
  31851. case usagestatistichour.FieldCreatedAt:
  31852. return m.OldCreatedAt(ctx)
  31853. case usagestatistichour.FieldUpdatedAt:
  31854. return m.OldUpdatedAt(ctx)
  31855. case usagestatistichour.FieldStatus:
  31856. return m.OldStatus(ctx)
  31857. case usagestatistichour.FieldDeletedAt:
  31858. return m.OldDeletedAt(ctx)
  31859. case usagestatistichour.FieldAddtime:
  31860. return m.OldAddtime(ctx)
  31861. case usagestatistichour.FieldType:
  31862. return m.OldType(ctx)
  31863. case usagestatistichour.FieldBotID:
  31864. return m.OldBotID(ctx)
  31865. case usagestatistichour.FieldOrganizationID:
  31866. return m.OldOrganizationID(ctx)
  31867. case usagestatistichour.FieldAiResponse:
  31868. return m.OldAiResponse(ctx)
  31869. case usagestatistichour.FieldSopRun:
  31870. return m.OldSopRun(ctx)
  31871. case usagestatistichour.FieldTotalFriend:
  31872. return m.OldTotalFriend(ctx)
  31873. case usagestatistichour.FieldTotalGroup:
  31874. return m.OldTotalGroup(ctx)
  31875. case usagestatistichour.FieldAccountBalance:
  31876. return m.OldAccountBalance(ctx)
  31877. case usagestatistichour.FieldConsumeToken:
  31878. return m.OldConsumeToken(ctx)
  31879. case usagestatistichour.FieldActiveUser:
  31880. return m.OldActiveUser(ctx)
  31881. case usagestatistichour.FieldNewUser:
  31882. return m.OldNewUser(ctx)
  31883. case usagestatistichour.FieldLabelDist:
  31884. return m.OldLabelDist(ctx)
  31885. }
  31886. return nil, fmt.Errorf("unknown UsageStatisticHour field %s", name)
  31887. }
  31888. // SetField sets the value of a field with the given name. It returns an error if
  31889. // the field is not defined in the schema, or if the type mismatched the field
  31890. // type.
  31891. func (m *UsageStatisticHourMutation) SetField(name string, value ent.Value) error {
  31892. switch name {
  31893. case usagestatistichour.FieldCreatedAt:
  31894. v, ok := value.(time.Time)
  31895. if !ok {
  31896. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31897. }
  31898. m.SetCreatedAt(v)
  31899. return nil
  31900. case usagestatistichour.FieldUpdatedAt:
  31901. v, ok := value.(time.Time)
  31902. if !ok {
  31903. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31904. }
  31905. m.SetUpdatedAt(v)
  31906. return nil
  31907. case usagestatistichour.FieldStatus:
  31908. v, ok := value.(uint8)
  31909. if !ok {
  31910. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31911. }
  31912. m.SetStatus(v)
  31913. return nil
  31914. case usagestatistichour.FieldDeletedAt:
  31915. v, ok := value.(time.Time)
  31916. if !ok {
  31917. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31918. }
  31919. m.SetDeletedAt(v)
  31920. return nil
  31921. case usagestatistichour.FieldAddtime:
  31922. v, ok := value.(uint64)
  31923. if !ok {
  31924. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31925. }
  31926. m.SetAddtime(v)
  31927. return nil
  31928. case usagestatistichour.FieldType:
  31929. v, ok := value.(int)
  31930. if !ok {
  31931. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31932. }
  31933. m.SetType(v)
  31934. return nil
  31935. case usagestatistichour.FieldBotID:
  31936. v, ok := value.(string)
  31937. if !ok {
  31938. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31939. }
  31940. m.SetBotID(v)
  31941. return nil
  31942. case usagestatistichour.FieldOrganizationID:
  31943. v, ok := value.(uint64)
  31944. if !ok {
  31945. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31946. }
  31947. m.SetOrganizationID(v)
  31948. return nil
  31949. case usagestatistichour.FieldAiResponse:
  31950. v, ok := value.(uint64)
  31951. if !ok {
  31952. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31953. }
  31954. m.SetAiResponse(v)
  31955. return nil
  31956. case usagestatistichour.FieldSopRun:
  31957. v, ok := value.(uint64)
  31958. if !ok {
  31959. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31960. }
  31961. m.SetSopRun(v)
  31962. return nil
  31963. case usagestatistichour.FieldTotalFriend:
  31964. v, ok := value.(uint64)
  31965. if !ok {
  31966. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31967. }
  31968. m.SetTotalFriend(v)
  31969. return nil
  31970. case usagestatistichour.FieldTotalGroup:
  31971. v, ok := value.(uint64)
  31972. if !ok {
  31973. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31974. }
  31975. m.SetTotalGroup(v)
  31976. return nil
  31977. case usagestatistichour.FieldAccountBalance:
  31978. v, ok := value.(uint64)
  31979. if !ok {
  31980. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31981. }
  31982. m.SetAccountBalance(v)
  31983. return nil
  31984. case usagestatistichour.FieldConsumeToken:
  31985. v, ok := value.(uint64)
  31986. if !ok {
  31987. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31988. }
  31989. m.SetConsumeToken(v)
  31990. return nil
  31991. case usagestatistichour.FieldActiveUser:
  31992. v, ok := value.(uint64)
  31993. if !ok {
  31994. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31995. }
  31996. m.SetActiveUser(v)
  31997. return nil
  31998. case usagestatistichour.FieldNewUser:
  31999. v, ok := value.(int64)
  32000. if !ok {
  32001. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32002. }
  32003. m.SetNewUser(v)
  32004. return nil
  32005. case usagestatistichour.FieldLabelDist:
  32006. v, ok := value.([]custom_types.LabelDist)
  32007. if !ok {
  32008. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32009. }
  32010. m.SetLabelDist(v)
  32011. return nil
  32012. }
  32013. return fmt.Errorf("unknown UsageStatisticHour field %s", name)
  32014. }
  32015. // AddedFields returns all numeric fields that were incremented/decremented during
  32016. // this mutation.
  32017. func (m *UsageStatisticHourMutation) AddedFields() []string {
  32018. var fields []string
  32019. if m.addstatus != nil {
  32020. fields = append(fields, usagestatistichour.FieldStatus)
  32021. }
  32022. if m.addaddtime != nil {
  32023. fields = append(fields, usagestatistichour.FieldAddtime)
  32024. }
  32025. if m.add_type != nil {
  32026. fields = append(fields, usagestatistichour.FieldType)
  32027. }
  32028. if m.addorganization_id != nil {
  32029. fields = append(fields, usagestatistichour.FieldOrganizationID)
  32030. }
  32031. if m.addai_response != nil {
  32032. fields = append(fields, usagestatistichour.FieldAiResponse)
  32033. }
  32034. if m.addsop_run != nil {
  32035. fields = append(fields, usagestatistichour.FieldSopRun)
  32036. }
  32037. if m.addtotal_friend != nil {
  32038. fields = append(fields, usagestatistichour.FieldTotalFriend)
  32039. }
  32040. if m.addtotal_group != nil {
  32041. fields = append(fields, usagestatistichour.FieldTotalGroup)
  32042. }
  32043. if m.addaccount_balance != nil {
  32044. fields = append(fields, usagestatistichour.FieldAccountBalance)
  32045. }
  32046. if m.addconsume_token != nil {
  32047. fields = append(fields, usagestatistichour.FieldConsumeToken)
  32048. }
  32049. if m.addactive_user != nil {
  32050. fields = append(fields, usagestatistichour.FieldActiveUser)
  32051. }
  32052. if m.addnew_user != nil {
  32053. fields = append(fields, usagestatistichour.FieldNewUser)
  32054. }
  32055. return fields
  32056. }
  32057. // AddedField returns the numeric value that was incremented/decremented on a field
  32058. // with the given name. The second boolean return value indicates that this field
  32059. // was not set, or was not defined in the schema.
  32060. func (m *UsageStatisticHourMutation) AddedField(name string) (ent.Value, bool) {
  32061. switch name {
  32062. case usagestatistichour.FieldStatus:
  32063. return m.AddedStatus()
  32064. case usagestatistichour.FieldAddtime:
  32065. return m.AddedAddtime()
  32066. case usagestatistichour.FieldType:
  32067. return m.AddedType()
  32068. case usagestatistichour.FieldOrganizationID:
  32069. return m.AddedOrganizationID()
  32070. case usagestatistichour.FieldAiResponse:
  32071. return m.AddedAiResponse()
  32072. case usagestatistichour.FieldSopRun:
  32073. return m.AddedSopRun()
  32074. case usagestatistichour.FieldTotalFriend:
  32075. return m.AddedTotalFriend()
  32076. case usagestatistichour.FieldTotalGroup:
  32077. return m.AddedTotalGroup()
  32078. case usagestatistichour.FieldAccountBalance:
  32079. return m.AddedAccountBalance()
  32080. case usagestatistichour.FieldConsumeToken:
  32081. return m.AddedConsumeToken()
  32082. case usagestatistichour.FieldActiveUser:
  32083. return m.AddedActiveUser()
  32084. case usagestatistichour.FieldNewUser:
  32085. return m.AddedNewUser()
  32086. }
  32087. return nil, false
  32088. }
  32089. // AddField adds the value to the field with the given name. It returns an error if
  32090. // the field is not defined in the schema, or if the type mismatched the field
  32091. // type.
  32092. func (m *UsageStatisticHourMutation) AddField(name string, value ent.Value) error {
  32093. switch name {
  32094. case usagestatistichour.FieldStatus:
  32095. v, ok := value.(int8)
  32096. if !ok {
  32097. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32098. }
  32099. m.AddStatus(v)
  32100. return nil
  32101. case usagestatistichour.FieldAddtime:
  32102. v, ok := value.(int64)
  32103. if !ok {
  32104. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32105. }
  32106. m.AddAddtime(v)
  32107. return nil
  32108. case usagestatistichour.FieldType:
  32109. v, ok := value.(int)
  32110. if !ok {
  32111. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32112. }
  32113. m.AddType(v)
  32114. return nil
  32115. case usagestatistichour.FieldOrganizationID:
  32116. v, ok := value.(int64)
  32117. if !ok {
  32118. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32119. }
  32120. m.AddOrganizationID(v)
  32121. return nil
  32122. case usagestatistichour.FieldAiResponse:
  32123. v, ok := value.(int64)
  32124. if !ok {
  32125. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32126. }
  32127. m.AddAiResponse(v)
  32128. return nil
  32129. case usagestatistichour.FieldSopRun:
  32130. v, ok := value.(int64)
  32131. if !ok {
  32132. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32133. }
  32134. m.AddSopRun(v)
  32135. return nil
  32136. case usagestatistichour.FieldTotalFriend:
  32137. v, ok := value.(int64)
  32138. if !ok {
  32139. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32140. }
  32141. m.AddTotalFriend(v)
  32142. return nil
  32143. case usagestatistichour.FieldTotalGroup:
  32144. v, ok := value.(int64)
  32145. if !ok {
  32146. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32147. }
  32148. m.AddTotalGroup(v)
  32149. return nil
  32150. case usagestatistichour.FieldAccountBalance:
  32151. v, ok := value.(int64)
  32152. if !ok {
  32153. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32154. }
  32155. m.AddAccountBalance(v)
  32156. return nil
  32157. case usagestatistichour.FieldConsumeToken:
  32158. v, ok := value.(int64)
  32159. if !ok {
  32160. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32161. }
  32162. m.AddConsumeToken(v)
  32163. return nil
  32164. case usagestatistichour.FieldActiveUser:
  32165. v, ok := value.(int64)
  32166. if !ok {
  32167. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32168. }
  32169. m.AddActiveUser(v)
  32170. return nil
  32171. case usagestatistichour.FieldNewUser:
  32172. v, ok := value.(int64)
  32173. if !ok {
  32174. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32175. }
  32176. m.AddNewUser(v)
  32177. return nil
  32178. }
  32179. return fmt.Errorf("unknown UsageStatisticHour numeric field %s", name)
  32180. }
  32181. // ClearedFields returns all nullable fields that were cleared during this
  32182. // mutation.
  32183. func (m *UsageStatisticHourMutation) ClearedFields() []string {
  32184. var fields []string
  32185. if m.FieldCleared(usagestatistichour.FieldStatus) {
  32186. fields = append(fields, usagestatistichour.FieldStatus)
  32187. }
  32188. if m.FieldCleared(usagestatistichour.FieldDeletedAt) {
  32189. fields = append(fields, usagestatistichour.FieldDeletedAt)
  32190. }
  32191. if m.FieldCleared(usagestatistichour.FieldBotID) {
  32192. fields = append(fields, usagestatistichour.FieldBotID)
  32193. }
  32194. if m.FieldCleared(usagestatistichour.FieldOrganizationID) {
  32195. fields = append(fields, usagestatistichour.FieldOrganizationID)
  32196. }
  32197. return fields
  32198. }
  32199. // FieldCleared returns a boolean indicating if a field with the given name was
  32200. // cleared in this mutation.
  32201. func (m *UsageStatisticHourMutation) FieldCleared(name string) bool {
  32202. _, ok := m.clearedFields[name]
  32203. return ok
  32204. }
  32205. // ClearField clears the value of the field with the given name. It returns an
  32206. // error if the field is not defined in the schema.
  32207. func (m *UsageStatisticHourMutation) ClearField(name string) error {
  32208. switch name {
  32209. case usagestatistichour.FieldStatus:
  32210. m.ClearStatus()
  32211. return nil
  32212. case usagestatistichour.FieldDeletedAt:
  32213. m.ClearDeletedAt()
  32214. return nil
  32215. case usagestatistichour.FieldBotID:
  32216. m.ClearBotID()
  32217. return nil
  32218. case usagestatistichour.FieldOrganizationID:
  32219. m.ClearOrganizationID()
  32220. return nil
  32221. }
  32222. return fmt.Errorf("unknown UsageStatisticHour nullable field %s", name)
  32223. }
  32224. // ResetField resets all changes in the mutation for the field with the given name.
  32225. // It returns an error if the field is not defined in the schema.
  32226. func (m *UsageStatisticHourMutation) ResetField(name string) error {
  32227. switch name {
  32228. case usagestatistichour.FieldCreatedAt:
  32229. m.ResetCreatedAt()
  32230. return nil
  32231. case usagestatistichour.FieldUpdatedAt:
  32232. m.ResetUpdatedAt()
  32233. return nil
  32234. case usagestatistichour.FieldStatus:
  32235. m.ResetStatus()
  32236. return nil
  32237. case usagestatistichour.FieldDeletedAt:
  32238. m.ResetDeletedAt()
  32239. return nil
  32240. case usagestatistichour.FieldAddtime:
  32241. m.ResetAddtime()
  32242. return nil
  32243. case usagestatistichour.FieldType:
  32244. m.ResetType()
  32245. return nil
  32246. case usagestatistichour.FieldBotID:
  32247. m.ResetBotID()
  32248. return nil
  32249. case usagestatistichour.FieldOrganizationID:
  32250. m.ResetOrganizationID()
  32251. return nil
  32252. case usagestatistichour.FieldAiResponse:
  32253. m.ResetAiResponse()
  32254. return nil
  32255. case usagestatistichour.FieldSopRun:
  32256. m.ResetSopRun()
  32257. return nil
  32258. case usagestatistichour.FieldTotalFriend:
  32259. m.ResetTotalFriend()
  32260. return nil
  32261. case usagestatistichour.FieldTotalGroup:
  32262. m.ResetTotalGroup()
  32263. return nil
  32264. case usagestatistichour.FieldAccountBalance:
  32265. m.ResetAccountBalance()
  32266. return nil
  32267. case usagestatistichour.FieldConsumeToken:
  32268. m.ResetConsumeToken()
  32269. return nil
  32270. case usagestatistichour.FieldActiveUser:
  32271. m.ResetActiveUser()
  32272. return nil
  32273. case usagestatistichour.FieldNewUser:
  32274. m.ResetNewUser()
  32275. return nil
  32276. case usagestatistichour.FieldLabelDist:
  32277. m.ResetLabelDist()
  32278. return nil
  32279. }
  32280. return fmt.Errorf("unknown UsageStatisticHour field %s", name)
  32281. }
  32282. // AddedEdges returns all edge names that were set/added in this mutation.
  32283. func (m *UsageStatisticHourMutation) AddedEdges() []string {
  32284. edges := make([]string, 0, 0)
  32285. return edges
  32286. }
  32287. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  32288. // name in this mutation.
  32289. func (m *UsageStatisticHourMutation) AddedIDs(name string) []ent.Value {
  32290. return nil
  32291. }
  32292. // RemovedEdges returns all edge names that were removed in this mutation.
  32293. func (m *UsageStatisticHourMutation) RemovedEdges() []string {
  32294. edges := make([]string, 0, 0)
  32295. return edges
  32296. }
  32297. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  32298. // the given name in this mutation.
  32299. func (m *UsageStatisticHourMutation) RemovedIDs(name string) []ent.Value {
  32300. return nil
  32301. }
  32302. // ClearedEdges returns all edge names that were cleared in this mutation.
  32303. func (m *UsageStatisticHourMutation) ClearedEdges() []string {
  32304. edges := make([]string, 0, 0)
  32305. return edges
  32306. }
  32307. // EdgeCleared returns a boolean which indicates if the edge with the given name
  32308. // was cleared in this mutation.
  32309. func (m *UsageStatisticHourMutation) EdgeCleared(name string) bool {
  32310. return false
  32311. }
  32312. // ClearEdge clears the value of the edge with the given name. It returns an error
  32313. // if that edge is not defined in the schema.
  32314. func (m *UsageStatisticHourMutation) ClearEdge(name string) error {
  32315. return fmt.Errorf("unknown UsageStatisticHour unique edge %s", name)
  32316. }
  32317. // ResetEdge resets all changes to the edge with the given name in this mutation.
  32318. // It returns an error if the edge is not defined in the schema.
  32319. func (m *UsageStatisticHourMutation) ResetEdge(name string) error {
  32320. return fmt.Errorf("unknown UsageStatisticHour edge %s", name)
  32321. }
  32322. // UsageStatisticMonthMutation represents an operation that mutates the UsageStatisticMonth nodes in the graph.
  32323. type UsageStatisticMonthMutation struct {
  32324. config
  32325. op Op
  32326. typ string
  32327. id *uint64
  32328. created_at *time.Time
  32329. updated_at *time.Time
  32330. status *uint8
  32331. addstatus *int8
  32332. deleted_at *time.Time
  32333. addtime *uint64
  32334. addaddtime *int64
  32335. _type *int
  32336. add_type *int
  32337. bot_id *string
  32338. organization_id *uint64
  32339. addorganization_id *int64
  32340. ai_response *uint64
  32341. addai_response *int64
  32342. sop_run *uint64
  32343. addsop_run *int64
  32344. total_friend *uint64
  32345. addtotal_friend *int64
  32346. total_group *uint64
  32347. addtotal_group *int64
  32348. account_balance *uint64
  32349. addaccount_balance *int64
  32350. consume_token *uint64
  32351. addconsume_token *int64
  32352. active_user *uint64
  32353. addactive_user *int64
  32354. new_user *int64
  32355. addnew_user *int64
  32356. label_dist *[]custom_types.LabelDist
  32357. appendlabel_dist []custom_types.LabelDist
  32358. clearedFields map[string]struct{}
  32359. done bool
  32360. oldValue func(context.Context) (*UsageStatisticMonth, error)
  32361. predicates []predicate.UsageStatisticMonth
  32362. }
  32363. var _ ent.Mutation = (*UsageStatisticMonthMutation)(nil)
  32364. // usagestatisticmonthOption allows management of the mutation configuration using functional options.
  32365. type usagestatisticmonthOption func(*UsageStatisticMonthMutation)
  32366. // newUsageStatisticMonthMutation creates new mutation for the UsageStatisticMonth entity.
  32367. func newUsageStatisticMonthMutation(c config, op Op, opts ...usagestatisticmonthOption) *UsageStatisticMonthMutation {
  32368. m := &UsageStatisticMonthMutation{
  32369. config: c,
  32370. op: op,
  32371. typ: TypeUsageStatisticMonth,
  32372. clearedFields: make(map[string]struct{}),
  32373. }
  32374. for _, opt := range opts {
  32375. opt(m)
  32376. }
  32377. return m
  32378. }
  32379. // withUsageStatisticMonthID sets the ID field of the mutation.
  32380. func withUsageStatisticMonthID(id uint64) usagestatisticmonthOption {
  32381. return func(m *UsageStatisticMonthMutation) {
  32382. var (
  32383. err error
  32384. once sync.Once
  32385. value *UsageStatisticMonth
  32386. )
  32387. m.oldValue = func(ctx context.Context) (*UsageStatisticMonth, error) {
  32388. once.Do(func() {
  32389. if m.done {
  32390. err = errors.New("querying old values post mutation is not allowed")
  32391. } else {
  32392. value, err = m.Client().UsageStatisticMonth.Get(ctx, id)
  32393. }
  32394. })
  32395. return value, err
  32396. }
  32397. m.id = &id
  32398. }
  32399. }
  32400. // withUsageStatisticMonth sets the old UsageStatisticMonth of the mutation.
  32401. func withUsageStatisticMonth(node *UsageStatisticMonth) usagestatisticmonthOption {
  32402. return func(m *UsageStatisticMonthMutation) {
  32403. m.oldValue = func(context.Context) (*UsageStatisticMonth, error) {
  32404. return node, nil
  32405. }
  32406. m.id = &node.ID
  32407. }
  32408. }
  32409. // Client returns a new `ent.Client` from the mutation. If the mutation was
  32410. // executed in a transaction (ent.Tx), a transactional client is returned.
  32411. func (m UsageStatisticMonthMutation) Client() *Client {
  32412. client := &Client{config: m.config}
  32413. client.init()
  32414. return client
  32415. }
  32416. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  32417. // it returns an error otherwise.
  32418. func (m UsageStatisticMonthMutation) Tx() (*Tx, error) {
  32419. if _, ok := m.driver.(*txDriver); !ok {
  32420. return nil, errors.New("ent: mutation is not running in a transaction")
  32421. }
  32422. tx := &Tx{config: m.config}
  32423. tx.init()
  32424. return tx, nil
  32425. }
  32426. // SetID sets the value of the id field. Note that this
  32427. // operation is only accepted on creation of UsageStatisticMonth entities.
  32428. func (m *UsageStatisticMonthMutation) SetID(id uint64) {
  32429. m.id = &id
  32430. }
  32431. // ID returns the ID value in the mutation. Note that the ID is only available
  32432. // if it was provided to the builder or after it was returned from the database.
  32433. func (m *UsageStatisticMonthMutation) ID() (id uint64, exists bool) {
  32434. if m.id == nil {
  32435. return
  32436. }
  32437. return *m.id, true
  32438. }
  32439. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  32440. // That means, if the mutation is applied within a transaction with an isolation level such
  32441. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  32442. // or updated by the mutation.
  32443. func (m *UsageStatisticMonthMutation) IDs(ctx context.Context) ([]uint64, error) {
  32444. switch {
  32445. case m.op.Is(OpUpdateOne | OpDeleteOne):
  32446. id, exists := m.ID()
  32447. if exists {
  32448. return []uint64{id}, nil
  32449. }
  32450. fallthrough
  32451. case m.op.Is(OpUpdate | OpDelete):
  32452. return m.Client().UsageStatisticMonth.Query().Where(m.predicates...).IDs(ctx)
  32453. default:
  32454. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  32455. }
  32456. }
  32457. // SetCreatedAt sets the "created_at" field.
  32458. func (m *UsageStatisticMonthMutation) SetCreatedAt(t time.Time) {
  32459. m.created_at = &t
  32460. }
  32461. // CreatedAt returns the value of the "created_at" field in the mutation.
  32462. func (m *UsageStatisticMonthMutation) CreatedAt() (r time.Time, exists bool) {
  32463. v := m.created_at
  32464. if v == nil {
  32465. return
  32466. }
  32467. return *v, true
  32468. }
  32469. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticMonth entity.
  32470. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  32471. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32472. func (m *UsageStatisticMonthMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  32473. if !m.op.Is(OpUpdateOne) {
  32474. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  32475. }
  32476. if m.id == nil || m.oldValue == nil {
  32477. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  32478. }
  32479. oldValue, err := m.oldValue(ctx)
  32480. if err != nil {
  32481. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  32482. }
  32483. return oldValue.CreatedAt, nil
  32484. }
  32485. // ResetCreatedAt resets all changes to the "created_at" field.
  32486. func (m *UsageStatisticMonthMutation) ResetCreatedAt() {
  32487. m.created_at = nil
  32488. }
  32489. // SetUpdatedAt sets the "updated_at" field.
  32490. func (m *UsageStatisticMonthMutation) SetUpdatedAt(t time.Time) {
  32491. m.updated_at = &t
  32492. }
  32493. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  32494. func (m *UsageStatisticMonthMutation) UpdatedAt() (r time.Time, exists bool) {
  32495. v := m.updated_at
  32496. if v == nil {
  32497. return
  32498. }
  32499. return *v, true
  32500. }
  32501. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticMonth entity.
  32502. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  32503. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32504. func (m *UsageStatisticMonthMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  32505. if !m.op.Is(OpUpdateOne) {
  32506. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  32507. }
  32508. if m.id == nil || m.oldValue == nil {
  32509. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  32510. }
  32511. oldValue, err := m.oldValue(ctx)
  32512. if err != nil {
  32513. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  32514. }
  32515. return oldValue.UpdatedAt, nil
  32516. }
  32517. // ResetUpdatedAt resets all changes to the "updated_at" field.
  32518. func (m *UsageStatisticMonthMutation) ResetUpdatedAt() {
  32519. m.updated_at = nil
  32520. }
  32521. // SetStatus sets the "status" field.
  32522. func (m *UsageStatisticMonthMutation) SetStatus(u uint8) {
  32523. m.status = &u
  32524. m.addstatus = nil
  32525. }
  32526. // Status returns the value of the "status" field in the mutation.
  32527. func (m *UsageStatisticMonthMutation) Status() (r uint8, exists bool) {
  32528. v := m.status
  32529. if v == nil {
  32530. return
  32531. }
  32532. return *v, true
  32533. }
  32534. // OldStatus returns the old "status" field's value of the UsageStatisticMonth entity.
  32535. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  32536. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32537. func (m *UsageStatisticMonthMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  32538. if !m.op.Is(OpUpdateOne) {
  32539. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  32540. }
  32541. if m.id == nil || m.oldValue == nil {
  32542. return v, errors.New("OldStatus requires an ID field in the mutation")
  32543. }
  32544. oldValue, err := m.oldValue(ctx)
  32545. if err != nil {
  32546. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  32547. }
  32548. return oldValue.Status, nil
  32549. }
  32550. // AddStatus adds u to the "status" field.
  32551. func (m *UsageStatisticMonthMutation) AddStatus(u int8) {
  32552. if m.addstatus != nil {
  32553. *m.addstatus += u
  32554. } else {
  32555. m.addstatus = &u
  32556. }
  32557. }
  32558. // AddedStatus returns the value that was added to the "status" field in this mutation.
  32559. func (m *UsageStatisticMonthMutation) AddedStatus() (r int8, exists bool) {
  32560. v := m.addstatus
  32561. if v == nil {
  32562. return
  32563. }
  32564. return *v, true
  32565. }
  32566. // ClearStatus clears the value of the "status" field.
  32567. func (m *UsageStatisticMonthMutation) ClearStatus() {
  32568. m.status = nil
  32569. m.addstatus = nil
  32570. m.clearedFields[usagestatisticmonth.FieldStatus] = struct{}{}
  32571. }
  32572. // StatusCleared returns if the "status" field was cleared in this mutation.
  32573. func (m *UsageStatisticMonthMutation) StatusCleared() bool {
  32574. _, ok := m.clearedFields[usagestatisticmonth.FieldStatus]
  32575. return ok
  32576. }
  32577. // ResetStatus resets all changes to the "status" field.
  32578. func (m *UsageStatisticMonthMutation) ResetStatus() {
  32579. m.status = nil
  32580. m.addstatus = nil
  32581. delete(m.clearedFields, usagestatisticmonth.FieldStatus)
  32582. }
  32583. // SetDeletedAt sets the "deleted_at" field.
  32584. func (m *UsageStatisticMonthMutation) SetDeletedAt(t time.Time) {
  32585. m.deleted_at = &t
  32586. }
  32587. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  32588. func (m *UsageStatisticMonthMutation) DeletedAt() (r time.Time, exists bool) {
  32589. v := m.deleted_at
  32590. if v == nil {
  32591. return
  32592. }
  32593. return *v, true
  32594. }
  32595. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticMonth entity.
  32596. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  32597. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32598. func (m *UsageStatisticMonthMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  32599. if !m.op.Is(OpUpdateOne) {
  32600. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  32601. }
  32602. if m.id == nil || m.oldValue == nil {
  32603. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  32604. }
  32605. oldValue, err := m.oldValue(ctx)
  32606. if err != nil {
  32607. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  32608. }
  32609. return oldValue.DeletedAt, nil
  32610. }
  32611. // ClearDeletedAt clears the value of the "deleted_at" field.
  32612. func (m *UsageStatisticMonthMutation) ClearDeletedAt() {
  32613. m.deleted_at = nil
  32614. m.clearedFields[usagestatisticmonth.FieldDeletedAt] = struct{}{}
  32615. }
  32616. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  32617. func (m *UsageStatisticMonthMutation) DeletedAtCleared() bool {
  32618. _, ok := m.clearedFields[usagestatisticmonth.FieldDeletedAt]
  32619. return ok
  32620. }
  32621. // ResetDeletedAt resets all changes to the "deleted_at" field.
  32622. func (m *UsageStatisticMonthMutation) ResetDeletedAt() {
  32623. m.deleted_at = nil
  32624. delete(m.clearedFields, usagestatisticmonth.FieldDeletedAt)
  32625. }
  32626. // SetAddtime sets the "addtime" field.
  32627. func (m *UsageStatisticMonthMutation) SetAddtime(u uint64) {
  32628. m.addtime = &u
  32629. m.addaddtime = nil
  32630. }
  32631. // Addtime returns the value of the "addtime" field in the mutation.
  32632. func (m *UsageStatisticMonthMutation) Addtime() (r uint64, exists bool) {
  32633. v := m.addtime
  32634. if v == nil {
  32635. return
  32636. }
  32637. return *v, true
  32638. }
  32639. // OldAddtime returns the old "addtime" field's value of the UsageStatisticMonth entity.
  32640. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  32641. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32642. func (m *UsageStatisticMonthMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  32643. if !m.op.Is(OpUpdateOne) {
  32644. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  32645. }
  32646. if m.id == nil || m.oldValue == nil {
  32647. return v, errors.New("OldAddtime requires an ID field in the mutation")
  32648. }
  32649. oldValue, err := m.oldValue(ctx)
  32650. if err != nil {
  32651. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  32652. }
  32653. return oldValue.Addtime, nil
  32654. }
  32655. // AddAddtime adds u to the "addtime" field.
  32656. func (m *UsageStatisticMonthMutation) AddAddtime(u int64) {
  32657. if m.addaddtime != nil {
  32658. *m.addaddtime += u
  32659. } else {
  32660. m.addaddtime = &u
  32661. }
  32662. }
  32663. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  32664. func (m *UsageStatisticMonthMutation) AddedAddtime() (r int64, exists bool) {
  32665. v := m.addaddtime
  32666. if v == nil {
  32667. return
  32668. }
  32669. return *v, true
  32670. }
  32671. // ResetAddtime resets all changes to the "addtime" field.
  32672. func (m *UsageStatisticMonthMutation) ResetAddtime() {
  32673. m.addtime = nil
  32674. m.addaddtime = nil
  32675. }
  32676. // SetType sets the "type" field.
  32677. func (m *UsageStatisticMonthMutation) SetType(i int) {
  32678. m._type = &i
  32679. m.add_type = nil
  32680. }
  32681. // GetType returns the value of the "type" field in the mutation.
  32682. func (m *UsageStatisticMonthMutation) GetType() (r int, exists bool) {
  32683. v := m._type
  32684. if v == nil {
  32685. return
  32686. }
  32687. return *v, true
  32688. }
  32689. // OldType returns the old "type" field's value of the UsageStatisticMonth entity.
  32690. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  32691. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32692. func (m *UsageStatisticMonthMutation) OldType(ctx context.Context) (v int, err error) {
  32693. if !m.op.Is(OpUpdateOne) {
  32694. return v, errors.New("OldType is only allowed on UpdateOne operations")
  32695. }
  32696. if m.id == nil || m.oldValue == nil {
  32697. return v, errors.New("OldType requires an ID field in the mutation")
  32698. }
  32699. oldValue, err := m.oldValue(ctx)
  32700. if err != nil {
  32701. return v, fmt.Errorf("querying old value for OldType: %w", err)
  32702. }
  32703. return oldValue.Type, nil
  32704. }
  32705. // AddType adds i to the "type" field.
  32706. func (m *UsageStatisticMonthMutation) AddType(i int) {
  32707. if m.add_type != nil {
  32708. *m.add_type += i
  32709. } else {
  32710. m.add_type = &i
  32711. }
  32712. }
  32713. // AddedType returns the value that was added to the "type" field in this mutation.
  32714. func (m *UsageStatisticMonthMutation) AddedType() (r int, exists bool) {
  32715. v := m.add_type
  32716. if v == nil {
  32717. return
  32718. }
  32719. return *v, true
  32720. }
  32721. // ResetType resets all changes to the "type" field.
  32722. func (m *UsageStatisticMonthMutation) ResetType() {
  32723. m._type = nil
  32724. m.add_type = nil
  32725. }
  32726. // SetBotID sets the "bot_id" field.
  32727. func (m *UsageStatisticMonthMutation) SetBotID(s string) {
  32728. m.bot_id = &s
  32729. }
  32730. // BotID returns the value of the "bot_id" field in the mutation.
  32731. func (m *UsageStatisticMonthMutation) BotID() (r string, exists bool) {
  32732. v := m.bot_id
  32733. if v == nil {
  32734. return
  32735. }
  32736. return *v, true
  32737. }
  32738. // OldBotID returns the old "bot_id" field's value of the UsageStatisticMonth entity.
  32739. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  32740. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32741. func (m *UsageStatisticMonthMutation) OldBotID(ctx context.Context) (v string, err error) {
  32742. if !m.op.Is(OpUpdateOne) {
  32743. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  32744. }
  32745. if m.id == nil || m.oldValue == nil {
  32746. return v, errors.New("OldBotID requires an ID field in the mutation")
  32747. }
  32748. oldValue, err := m.oldValue(ctx)
  32749. if err != nil {
  32750. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  32751. }
  32752. return oldValue.BotID, nil
  32753. }
  32754. // ClearBotID clears the value of the "bot_id" field.
  32755. func (m *UsageStatisticMonthMutation) ClearBotID() {
  32756. m.bot_id = nil
  32757. m.clearedFields[usagestatisticmonth.FieldBotID] = struct{}{}
  32758. }
  32759. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  32760. func (m *UsageStatisticMonthMutation) BotIDCleared() bool {
  32761. _, ok := m.clearedFields[usagestatisticmonth.FieldBotID]
  32762. return ok
  32763. }
  32764. // ResetBotID resets all changes to the "bot_id" field.
  32765. func (m *UsageStatisticMonthMutation) ResetBotID() {
  32766. m.bot_id = nil
  32767. delete(m.clearedFields, usagestatisticmonth.FieldBotID)
  32768. }
  32769. // SetOrganizationID sets the "organization_id" field.
  32770. func (m *UsageStatisticMonthMutation) SetOrganizationID(u uint64) {
  32771. m.organization_id = &u
  32772. m.addorganization_id = nil
  32773. }
  32774. // OrganizationID returns the value of the "organization_id" field in the mutation.
  32775. func (m *UsageStatisticMonthMutation) OrganizationID() (r uint64, exists bool) {
  32776. v := m.organization_id
  32777. if v == nil {
  32778. return
  32779. }
  32780. return *v, true
  32781. }
  32782. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticMonth entity.
  32783. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  32784. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32785. func (m *UsageStatisticMonthMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  32786. if !m.op.Is(OpUpdateOne) {
  32787. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  32788. }
  32789. if m.id == nil || m.oldValue == nil {
  32790. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  32791. }
  32792. oldValue, err := m.oldValue(ctx)
  32793. if err != nil {
  32794. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  32795. }
  32796. return oldValue.OrganizationID, nil
  32797. }
  32798. // AddOrganizationID adds u to the "organization_id" field.
  32799. func (m *UsageStatisticMonthMutation) AddOrganizationID(u int64) {
  32800. if m.addorganization_id != nil {
  32801. *m.addorganization_id += u
  32802. } else {
  32803. m.addorganization_id = &u
  32804. }
  32805. }
  32806. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  32807. func (m *UsageStatisticMonthMutation) AddedOrganizationID() (r int64, exists bool) {
  32808. v := m.addorganization_id
  32809. if v == nil {
  32810. return
  32811. }
  32812. return *v, true
  32813. }
  32814. // ClearOrganizationID clears the value of the "organization_id" field.
  32815. func (m *UsageStatisticMonthMutation) ClearOrganizationID() {
  32816. m.organization_id = nil
  32817. m.addorganization_id = nil
  32818. m.clearedFields[usagestatisticmonth.FieldOrganizationID] = struct{}{}
  32819. }
  32820. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  32821. func (m *UsageStatisticMonthMutation) OrganizationIDCleared() bool {
  32822. _, ok := m.clearedFields[usagestatisticmonth.FieldOrganizationID]
  32823. return ok
  32824. }
  32825. // ResetOrganizationID resets all changes to the "organization_id" field.
  32826. func (m *UsageStatisticMonthMutation) ResetOrganizationID() {
  32827. m.organization_id = nil
  32828. m.addorganization_id = nil
  32829. delete(m.clearedFields, usagestatisticmonth.FieldOrganizationID)
  32830. }
  32831. // SetAiResponse sets the "ai_response" field.
  32832. func (m *UsageStatisticMonthMutation) SetAiResponse(u uint64) {
  32833. m.ai_response = &u
  32834. m.addai_response = nil
  32835. }
  32836. // AiResponse returns the value of the "ai_response" field in the mutation.
  32837. func (m *UsageStatisticMonthMutation) AiResponse() (r uint64, exists bool) {
  32838. v := m.ai_response
  32839. if v == nil {
  32840. return
  32841. }
  32842. return *v, true
  32843. }
  32844. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticMonth entity.
  32845. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  32846. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32847. func (m *UsageStatisticMonthMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  32848. if !m.op.Is(OpUpdateOne) {
  32849. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  32850. }
  32851. if m.id == nil || m.oldValue == nil {
  32852. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  32853. }
  32854. oldValue, err := m.oldValue(ctx)
  32855. if err != nil {
  32856. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  32857. }
  32858. return oldValue.AiResponse, nil
  32859. }
  32860. // AddAiResponse adds u to the "ai_response" field.
  32861. func (m *UsageStatisticMonthMutation) AddAiResponse(u int64) {
  32862. if m.addai_response != nil {
  32863. *m.addai_response += u
  32864. } else {
  32865. m.addai_response = &u
  32866. }
  32867. }
  32868. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  32869. func (m *UsageStatisticMonthMutation) AddedAiResponse() (r int64, exists bool) {
  32870. v := m.addai_response
  32871. if v == nil {
  32872. return
  32873. }
  32874. return *v, true
  32875. }
  32876. // ResetAiResponse resets all changes to the "ai_response" field.
  32877. func (m *UsageStatisticMonthMutation) ResetAiResponse() {
  32878. m.ai_response = nil
  32879. m.addai_response = nil
  32880. }
  32881. // SetSopRun sets the "sop_run" field.
  32882. func (m *UsageStatisticMonthMutation) SetSopRun(u uint64) {
  32883. m.sop_run = &u
  32884. m.addsop_run = nil
  32885. }
  32886. // SopRun returns the value of the "sop_run" field in the mutation.
  32887. func (m *UsageStatisticMonthMutation) SopRun() (r uint64, exists bool) {
  32888. v := m.sop_run
  32889. if v == nil {
  32890. return
  32891. }
  32892. return *v, true
  32893. }
  32894. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticMonth entity.
  32895. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  32896. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32897. func (m *UsageStatisticMonthMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  32898. if !m.op.Is(OpUpdateOne) {
  32899. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  32900. }
  32901. if m.id == nil || m.oldValue == nil {
  32902. return v, errors.New("OldSopRun requires an ID field in the mutation")
  32903. }
  32904. oldValue, err := m.oldValue(ctx)
  32905. if err != nil {
  32906. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  32907. }
  32908. return oldValue.SopRun, nil
  32909. }
  32910. // AddSopRun adds u to the "sop_run" field.
  32911. func (m *UsageStatisticMonthMutation) AddSopRun(u int64) {
  32912. if m.addsop_run != nil {
  32913. *m.addsop_run += u
  32914. } else {
  32915. m.addsop_run = &u
  32916. }
  32917. }
  32918. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  32919. func (m *UsageStatisticMonthMutation) AddedSopRun() (r int64, exists bool) {
  32920. v := m.addsop_run
  32921. if v == nil {
  32922. return
  32923. }
  32924. return *v, true
  32925. }
  32926. // ResetSopRun resets all changes to the "sop_run" field.
  32927. func (m *UsageStatisticMonthMutation) ResetSopRun() {
  32928. m.sop_run = nil
  32929. m.addsop_run = nil
  32930. }
  32931. // SetTotalFriend sets the "total_friend" field.
  32932. func (m *UsageStatisticMonthMutation) SetTotalFriend(u uint64) {
  32933. m.total_friend = &u
  32934. m.addtotal_friend = nil
  32935. }
  32936. // TotalFriend returns the value of the "total_friend" field in the mutation.
  32937. func (m *UsageStatisticMonthMutation) TotalFriend() (r uint64, exists bool) {
  32938. v := m.total_friend
  32939. if v == nil {
  32940. return
  32941. }
  32942. return *v, true
  32943. }
  32944. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticMonth entity.
  32945. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  32946. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32947. func (m *UsageStatisticMonthMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  32948. if !m.op.Is(OpUpdateOne) {
  32949. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  32950. }
  32951. if m.id == nil || m.oldValue == nil {
  32952. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  32953. }
  32954. oldValue, err := m.oldValue(ctx)
  32955. if err != nil {
  32956. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  32957. }
  32958. return oldValue.TotalFriend, nil
  32959. }
  32960. // AddTotalFriend adds u to the "total_friend" field.
  32961. func (m *UsageStatisticMonthMutation) AddTotalFriend(u int64) {
  32962. if m.addtotal_friend != nil {
  32963. *m.addtotal_friend += u
  32964. } else {
  32965. m.addtotal_friend = &u
  32966. }
  32967. }
  32968. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  32969. func (m *UsageStatisticMonthMutation) AddedTotalFriend() (r int64, exists bool) {
  32970. v := m.addtotal_friend
  32971. if v == nil {
  32972. return
  32973. }
  32974. return *v, true
  32975. }
  32976. // ResetTotalFriend resets all changes to the "total_friend" field.
  32977. func (m *UsageStatisticMonthMutation) ResetTotalFriend() {
  32978. m.total_friend = nil
  32979. m.addtotal_friend = nil
  32980. }
  32981. // SetTotalGroup sets the "total_group" field.
  32982. func (m *UsageStatisticMonthMutation) SetTotalGroup(u uint64) {
  32983. m.total_group = &u
  32984. m.addtotal_group = nil
  32985. }
  32986. // TotalGroup returns the value of the "total_group" field in the mutation.
  32987. func (m *UsageStatisticMonthMutation) TotalGroup() (r uint64, exists bool) {
  32988. v := m.total_group
  32989. if v == nil {
  32990. return
  32991. }
  32992. return *v, true
  32993. }
  32994. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticMonth entity.
  32995. // If the UsageStatisticMonth 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 *UsageStatisticMonthMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  32998. if !m.op.Is(OpUpdateOne) {
  32999. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  33000. }
  33001. if m.id == nil || m.oldValue == nil {
  33002. return v, errors.New("OldTotalGroup 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 OldTotalGroup: %w", err)
  33007. }
  33008. return oldValue.TotalGroup, nil
  33009. }
  33010. // AddTotalGroup adds u to the "total_group" field.
  33011. func (m *UsageStatisticMonthMutation) AddTotalGroup(u int64) {
  33012. if m.addtotal_group != nil {
  33013. *m.addtotal_group += u
  33014. } else {
  33015. m.addtotal_group = &u
  33016. }
  33017. }
  33018. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  33019. func (m *UsageStatisticMonthMutation) AddedTotalGroup() (r int64, exists bool) {
  33020. v := m.addtotal_group
  33021. if v == nil {
  33022. return
  33023. }
  33024. return *v, true
  33025. }
  33026. // ResetTotalGroup resets all changes to the "total_group" field.
  33027. func (m *UsageStatisticMonthMutation) ResetTotalGroup() {
  33028. m.total_group = nil
  33029. m.addtotal_group = nil
  33030. }
  33031. // SetAccountBalance sets the "account_balance" field.
  33032. func (m *UsageStatisticMonthMutation) SetAccountBalance(u uint64) {
  33033. m.account_balance = &u
  33034. m.addaccount_balance = nil
  33035. }
  33036. // AccountBalance returns the value of the "account_balance" field in the mutation.
  33037. func (m *UsageStatisticMonthMutation) AccountBalance() (r uint64, exists bool) {
  33038. v := m.account_balance
  33039. if v == nil {
  33040. return
  33041. }
  33042. return *v, true
  33043. }
  33044. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticMonth entity.
  33045. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  33046. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33047. func (m *UsageStatisticMonthMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  33048. if !m.op.Is(OpUpdateOne) {
  33049. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  33050. }
  33051. if m.id == nil || m.oldValue == nil {
  33052. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  33053. }
  33054. oldValue, err := m.oldValue(ctx)
  33055. if err != nil {
  33056. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  33057. }
  33058. return oldValue.AccountBalance, nil
  33059. }
  33060. // AddAccountBalance adds u to the "account_balance" field.
  33061. func (m *UsageStatisticMonthMutation) AddAccountBalance(u int64) {
  33062. if m.addaccount_balance != nil {
  33063. *m.addaccount_balance += u
  33064. } else {
  33065. m.addaccount_balance = &u
  33066. }
  33067. }
  33068. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  33069. func (m *UsageStatisticMonthMutation) AddedAccountBalance() (r int64, exists bool) {
  33070. v := m.addaccount_balance
  33071. if v == nil {
  33072. return
  33073. }
  33074. return *v, true
  33075. }
  33076. // ResetAccountBalance resets all changes to the "account_balance" field.
  33077. func (m *UsageStatisticMonthMutation) ResetAccountBalance() {
  33078. m.account_balance = nil
  33079. m.addaccount_balance = nil
  33080. }
  33081. // SetConsumeToken sets the "consume_token" field.
  33082. func (m *UsageStatisticMonthMutation) SetConsumeToken(u uint64) {
  33083. m.consume_token = &u
  33084. m.addconsume_token = nil
  33085. }
  33086. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  33087. func (m *UsageStatisticMonthMutation) ConsumeToken() (r uint64, exists bool) {
  33088. v := m.consume_token
  33089. if v == nil {
  33090. return
  33091. }
  33092. return *v, true
  33093. }
  33094. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticMonth entity.
  33095. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  33096. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33097. func (m *UsageStatisticMonthMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  33098. if !m.op.Is(OpUpdateOne) {
  33099. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  33100. }
  33101. if m.id == nil || m.oldValue == nil {
  33102. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  33103. }
  33104. oldValue, err := m.oldValue(ctx)
  33105. if err != nil {
  33106. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  33107. }
  33108. return oldValue.ConsumeToken, nil
  33109. }
  33110. // AddConsumeToken adds u to the "consume_token" field.
  33111. func (m *UsageStatisticMonthMutation) AddConsumeToken(u int64) {
  33112. if m.addconsume_token != nil {
  33113. *m.addconsume_token += u
  33114. } else {
  33115. m.addconsume_token = &u
  33116. }
  33117. }
  33118. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  33119. func (m *UsageStatisticMonthMutation) AddedConsumeToken() (r int64, exists bool) {
  33120. v := m.addconsume_token
  33121. if v == nil {
  33122. return
  33123. }
  33124. return *v, true
  33125. }
  33126. // ResetConsumeToken resets all changes to the "consume_token" field.
  33127. func (m *UsageStatisticMonthMutation) ResetConsumeToken() {
  33128. m.consume_token = nil
  33129. m.addconsume_token = nil
  33130. }
  33131. // SetActiveUser sets the "active_user" field.
  33132. func (m *UsageStatisticMonthMutation) SetActiveUser(u uint64) {
  33133. m.active_user = &u
  33134. m.addactive_user = nil
  33135. }
  33136. // ActiveUser returns the value of the "active_user" field in the mutation.
  33137. func (m *UsageStatisticMonthMutation) ActiveUser() (r uint64, exists bool) {
  33138. v := m.active_user
  33139. if v == nil {
  33140. return
  33141. }
  33142. return *v, true
  33143. }
  33144. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticMonth entity.
  33145. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  33146. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33147. func (m *UsageStatisticMonthMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  33148. if !m.op.Is(OpUpdateOne) {
  33149. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  33150. }
  33151. if m.id == nil || m.oldValue == nil {
  33152. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  33153. }
  33154. oldValue, err := m.oldValue(ctx)
  33155. if err != nil {
  33156. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  33157. }
  33158. return oldValue.ActiveUser, nil
  33159. }
  33160. // AddActiveUser adds u to the "active_user" field.
  33161. func (m *UsageStatisticMonthMutation) AddActiveUser(u int64) {
  33162. if m.addactive_user != nil {
  33163. *m.addactive_user += u
  33164. } else {
  33165. m.addactive_user = &u
  33166. }
  33167. }
  33168. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  33169. func (m *UsageStatisticMonthMutation) AddedActiveUser() (r int64, exists bool) {
  33170. v := m.addactive_user
  33171. if v == nil {
  33172. return
  33173. }
  33174. return *v, true
  33175. }
  33176. // ResetActiveUser resets all changes to the "active_user" field.
  33177. func (m *UsageStatisticMonthMutation) ResetActiveUser() {
  33178. m.active_user = nil
  33179. m.addactive_user = nil
  33180. }
  33181. // SetNewUser sets the "new_user" field.
  33182. func (m *UsageStatisticMonthMutation) SetNewUser(i int64) {
  33183. m.new_user = &i
  33184. m.addnew_user = nil
  33185. }
  33186. // NewUser returns the value of the "new_user" field in the mutation.
  33187. func (m *UsageStatisticMonthMutation) NewUser() (r int64, exists bool) {
  33188. v := m.new_user
  33189. if v == nil {
  33190. return
  33191. }
  33192. return *v, true
  33193. }
  33194. // OldNewUser returns the old "new_user" field's value of the UsageStatisticMonth entity.
  33195. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  33196. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33197. func (m *UsageStatisticMonthMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  33198. if !m.op.Is(OpUpdateOne) {
  33199. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  33200. }
  33201. if m.id == nil || m.oldValue == nil {
  33202. return v, errors.New("OldNewUser requires an ID field in the mutation")
  33203. }
  33204. oldValue, err := m.oldValue(ctx)
  33205. if err != nil {
  33206. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  33207. }
  33208. return oldValue.NewUser, nil
  33209. }
  33210. // AddNewUser adds i to the "new_user" field.
  33211. func (m *UsageStatisticMonthMutation) AddNewUser(i int64) {
  33212. if m.addnew_user != nil {
  33213. *m.addnew_user += i
  33214. } else {
  33215. m.addnew_user = &i
  33216. }
  33217. }
  33218. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  33219. func (m *UsageStatisticMonthMutation) AddedNewUser() (r int64, exists bool) {
  33220. v := m.addnew_user
  33221. if v == nil {
  33222. return
  33223. }
  33224. return *v, true
  33225. }
  33226. // ResetNewUser resets all changes to the "new_user" field.
  33227. func (m *UsageStatisticMonthMutation) ResetNewUser() {
  33228. m.new_user = nil
  33229. m.addnew_user = nil
  33230. }
  33231. // SetLabelDist sets the "label_dist" field.
  33232. func (m *UsageStatisticMonthMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  33233. m.label_dist = &ctd
  33234. m.appendlabel_dist = nil
  33235. }
  33236. // LabelDist returns the value of the "label_dist" field in the mutation.
  33237. func (m *UsageStatisticMonthMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  33238. v := m.label_dist
  33239. if v == nil {
  33240. return
  33241. }
  33242. return *v, true
  33243. }
  33244. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticMonth entity.
  33245. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  33246. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33247. func (m *UsageStatisticMonthMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  33248. if !m.op.Is(OpUpdateOne) {
  33249. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  33250. }
  33251. if m.id == nil || m.oldValue == nil {
  33252. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  33253. }
  33254. oldValue, err := m.oldValue(ctx)
  33255. if err != nil {
  33256. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  33257. }
  33258. return oldValue.LabelDist, nil
  33259. }
  33260. // AppendLabelDist adds ctd to the "label_dist" field.
  33261. func (m *UsageStatisticMonthMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  33262. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  33263. }
  33264. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  33265. func (m *UsageStatisticMonthMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  33266. if len(m.appendlabel_dist) == 0 {
  33267. return nil, false
  33268. }
  33269. return m.appendlabel_dist, true
  33270. }
  33271. // ResetLabelDist resets all changes to the "label_dist" field.
  33272. func (m *UsageStatisticMonthMutation) ResetLabelDist() {
  33273. m.label_dist = nil
  33274. m.appendlabel_dist = nil
  33275. }
  33276. // Where appends a list predicates to the UsageStatisticMonthMutation builder.
  33277. func (m *UsageStatisticMonthMutation) Where(ps ...predicate.UsageStatisticMonth) {
  33278. m.predicates = append(m.predicates, ps...)
  33279. }
  33280. // WhereP appends storage-level predicates to the UsageStatisticMonthMutation builder. Using this method,
  33281. // users can use type-assertion to append predicates that do not depend on any generated package.
  33282. func (m *UsageStatisticMonthMutation) WhereP(ps ...func(*sql.Selector)) {
  33283. p := make([]predicate.UsageStatisticMonth, len(ps))
  33284. for i := range ps {
  33285. p[i] = ps[i]
  33286. }
  33287. m.Where(p...)
  33288. }
  33289. // Op returns the operation name.
  33290. func (m *UsageStatisticMonthMutation) Op() Op {
  33291. return m.op
  33292. }
  33293. // SetOp allows setting the mutation operation.
  33294. func (m *UsageStatisticMonthMutation) SetOp(op Op) {
  33295. m.op = op
  33296. }
  33297. // Type returns the node type of this mutation (UsageStatisticMonth).
  33298. func (m *UsageStatisticMonthMutation) Type() string {
  33299. return m.typ
  33300. }
  33301. // Fields returns all fields that were changed during this mutation. Note that in
  33302. // order to get all numeric fields that were incremented/decremented, call
  33303. // AddedFields().
  33304. func (m *UsageStatisticMonthMutation) Fields() []string {
  33305. fields := make([]string, 0, 17)
  33306. if m.created_at != nil {
  33307. fields = append(fields, usagestatisticmonth.FieldCreatedAt)
  33308. }
  33309. if m.updated_at != nil {
  33310. fields = append(fields, usagestatisticmonth.FieldUpdatedAt)
  33311. }
  33312. if m.status != nil {
  33313. fields = append(fields, usagestatisticmonth.FieldStatus)
  33314. }
  33315. if m.deleted_at != nil {
  33316. fields = append(fields, usagestatisticmonth.FieldDeletedAt)
  33317. }
  33318. if m.addtime != nil {
  33319. fields = append(fields, usagestatisticmonth.FieldAddtime)
  33320. }
  33321. if m._type != nil {
  33322. fields = append(fields, usagestatisticmonth.FieldType)
  33323. }
  33324. if m.bot_id != nil {
  33325. fields = append(fields, usagestatisticmonth.FieldBotID)
  33326. }
  33327. if m.organization_id != nil {
  33328. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  33329. }
  33330. if m.ai_response != nil {
  33331. fields = append(fields, usagestatisticmonth.FieldAiResponse)
  33332. }
  33333. if m.sop_run != nil {
  33334. fields = append(fields, usagestatisticmonth.FieldSopRun)
  33335. }
  33336. if m.total_friend != nil {
  33337. fields = append(fields, usagestatisticmonth.FieldTotalFriend)
  33338. }
  33339. if m.total_group != nil {
  33340. fields = append(fields, usagestatisticmonth.FieldTotalGroup)
  33341. }
  33342. if m.account_balance != nil {
  33343. fields = append(fields, usagestatisticmonth.FieldAccountBalance)
  33344. }
  33345. if m.consume_token != nil {
  33346. fields = append(fields, usagestatisticmonth.FieldConsumeToken)
  33347. }
  33348. if m.active_user != nil {
  33349. fields = append(fields, usagestatisticmonth.FieldActiveUser)
  33350. }
  33351. if m.new_user != nil {
  33352. fields = append(fields, usagestatisticmonth.FieldNewUser)
  33353. }
  33354. if m.label_dist != nil {
  33355. fields = append(fields, usagestatisticmonth.FieldLabelDist)
  33356. }
  33357. return fields
  33358. }
  33359. // Field returns the value of a field with the given name. The second boolean
  33360. // return value indicates that this field was not set, or was not defined in the
  33361. // schema.
  33362. func (m *UsageStatisticMonthMutation) Field(name string) (ent.Value, bool) {
  33363. switch name {
  33364. case usagestatisticmonth.FieldCreatedAt:
  33365. return m.CreatedAt()
  33366. case usagestatisticmonth.FieldUpdatedAt:
  33367. return m.UpdatedAt()
  33368. case usagestatisticmonth.FieldStatus:
  33369. return m.Status()
  33370. case usagestatisticmonth.FieldDeletedAt:
  33371. return m.DeletedAt()
  33372. case usagestatisticmonth.FieldAddtime:
  33373. return m.Addtime()
  33374. case usagestatisticmonth.FieldType:
  33375. return m.GetType()
  33376. case usagestatisticmonth.FieldBotID:
  33377. return m.BotID()
  33378. case usagestatisticmonth.FieldOrganizationID:
  33379. return m.OrganizationID()
  33380. case usagestatisticmonth.FieldAiResponse:
  33381. return m.AiResponse()
  33382. case usagestatisticmonth.FieldSopRun:
  33383. return m.SopRun()
  33384. case usagestatisticmonth.FieldTotalFriend:
  33385. return m.TotalFriend()
  33386. case usagestatisticmonth.FieldTotalGroup:
  33387. return m.TotalGroup()
  33388. case usagestatisticmonth.FieldAccountBalance:
  33389. return m.AccountBalance()
  33390. case usagestatisticmonth.FieldConsumeToken:
  33391. return m.ConsumeToken()
  33392. case usagestatisticmonth.FieldActiveUser:
  33393. return m.ActiveUser()
  33394. case usagestatisticmonth.FieldNewUser:
  33395. return m.NewUser()
  33396. case usagestatisticmonth.FieldLabelDist:
  33397. return m.LabelDist()
  33398. }
  33399. return nil, false
  33400. }
  33401. // OldField returns the old value of the field from the database. An error is
  33402. // returned if the mutation operation is not UpdateOne, or the query to the
  33403. // database failed.
  33404. func (m *UsageStatisticMonthMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  33405. switch name {
  33406. case usagestatisticmonth.FieldCreatedAt:
  33407. return m.OldCreatedAt(ctx)
  33408. case usagestatisticmonth.FieldUpdatedAt:
  33409. return m.OldUpdatedAt(ctx)
  33410. case usagestatisticmonth.FieldStatus:
  33411. return m.OldStatus(ctx)
  33412. case usagestatisticmonth.FieldDeletedAt:
  33413. return m.OldDeletedAt(ctx)
  33414. case usagestatisticmonth.FieldAddtime:
  33415. return m.OldAddtime(ctx)
  33416. case usagestatisticmonth.FieldType:
  33417. return m.OldType(ctx)
  33418. case usagestatisticmonth.FieldBotID:
  33419. return m.OldBotID(ctx)
  33420. case usagestatisticmonth.FieldOrganizationID:
  33421. return m.OldOrganizationID(ctx)
  33422. case usagestatisticmonth.FieldAiResponse:
  33423. return m.OldAiResponse(ctx)
  33424. case usagestatisticmonth.FieldSopRun:
  33425. return m.OldSopRun(ctx)
  33426. case usagestatisticmonth.FieldTotalFriend:
  33427. return m.OldTotalFriend(ctx)
  33428. case usagestatisticmonth.FieldTotalGroup:
  33429. return m.OldTotalGroup(ctx)
  33430. case usagestatisticmonth.FieldAccountBalance:
  33431. return m.OldAccountBalance(ctx)
  33432. case usagestatisticmonth.FieldConsumeToken:
  33433. return m.OldConsumeToken(ctx)
  33434. case usagestatisticmonth.FieldActiveUser:
  33435. return m.OldActiveUser(ctx)
  33436. case usagestatisticmonth.FieldNewUser:
  33437. return m.OldNewUser(ctx)
  33438. case usagestatisticmonth.FieldLabelDist:
  33439. return m.OldLabelDist(ctx)
  33440. }
  33441. return nil, fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  33442. }
  33443. // SetField sets the value of a field with the given name. It returns an error if
  33444. // the field is not defined in the schema, or if the type mismatched the field
  33445. // type.
  33446. func (m *UsageStatisticMonthMutation) SetField(name string, value ent.Value) error {
  33447. switch name {
  33448. case usagestatisticmonth.FieldCreatedAt:
  33449. v, ok := value.(time.Time)
  33450. if !ok {
  33451. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33452. }
  33453. m.SetCreatedAt(v)
  33454. return nil
  33455. case usagestatisticmonth.FieldUpdatedAt:
  33456. v, ok := value.(time.Time)
  33457. if !ok {
  33458. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33459. }
  33460. m.SetUpdatedAt(v)
  33461. return nil
  33462. case usagestatisticmonth.FieldStatus:
  33463. v, ok := value.(uint8)
  33464. if !ok {
  33465. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33466. }
  33467. m.SetStatus(v)
  33468. return nil
  33469. case usagestatisticmonth.FieldDeletedAt:
  33470. v, ok := value.(time.Time)
  33471. if !ok {
  33472. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33473. }
  33474. m.SetDeletedAt(v)
  33475. return nil
  33476. case usagestatisticmonth.FieldAddtime:
  33477. v, ok := value.(uint64)
  33478. if !ok {
  33479. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33480. }
  33481. m.SetAddtime(v)
  33482. return nil
  33483. case usagestatisticmonth.FieldType:
  33484. v, ok := value.(int)
  33485. if !ok {
  33486. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33487. }
  33488. m.SetType(v)
  33489. return nil
  33490. case usagestatisticmonth.FieldBotID:
  33491. v, ok := value.(string)
  33492. if !ok {
  33493. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33494. }
  33495. m.SetBotID(v)
  33496. return nil
  33497. case usagestatisticmonth.FieldOrganizationID:
  33498. v, ok := value.(uint64)
  33499. if !ok {
  33500. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33501. }
  33502. m.SetOrganizationID(v)
  33503. return nil
  33504. case usagestatisticmonth.FieldAiResponse:
  33505. v, ok := value.(uint64)
  33506. if !ok {
  33507. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33508. }
  33509. m.SetAiResponse(v)
  33510. return nil
  33511. case usagestatisticmonth.FieldSopRun:
  33512. v, ok := value.(uint64)
  33513. if !ok {
  33514. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33515. }
  33516. m.SetSopRun(v)
  33517. return nil
  33518. case usagestatisticmonth.FieldTotalFriend:
  33519. v, ok := value.(uint64)
  33520. if !ok {
  33521. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33522. }
  33523. m.SetTotalFriend(v)
  33524. return nil
  33525. case usagestatisticmonth.FieldTotalGroup:
  33526. v, ok := value.(uint64)
  33527. if !ok {
  33528. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33529. }
  33530. m.SetTotalGroup(v)
  33531. return nil
  33532. case usagestatisticmonth.FieldAccountBalance:
  33533. v, ok := value.(uint64)
  33534. if !ok {
  33535. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33536. }
  33537. m.SetAccountBalance(v)
  33538. return nil
  33539. case usagestatisticmonth.FieldConsumeToken:
  33540. v, ok := value.(uint64)
  33541. if !ok {
  33542. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33543. }
  33544. m.SetConsumeToken(v)
  33545. return nil
  33546. case usagestatisticmonth.FieldActiveUser:
  33547. v, ok := value.(uint64)
  33548. if !ok {
  33549. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33550. }
  33551. m.SetActiveUser(v)
  33552. return nil
  33553. case usagestatisticmonth.FieldNewUser:
  33554. v, ok := value.(int64)
  33555. if !ok {
  33556. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33557. }
  33558. m.SetNewUser(v)
  33559. return nil
  33560. case usagestatisticmonth.FieldLabelDist:
  33561. v, ok := value.([]custom_types.LabelDist)
  33562. if !ok {
  33563. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33564. }
  33565. m.SetLabelDist(v)
  33566. return nil
  33567. }
  33568. return fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  33569. }
  33570. // AddedFields returns all numeric fields that were incremented/decremented during
  33571. // this mutation.
  33572. func (m *UsageStatisticMonthMutation) AddedFields() []string {
  33573. var fields []string
  33574. if m.addstatus != nil {
  33575. fields = append(fields, usagestatisticmonth.FieldStatus)
  33576. }
  33577. if m.addaddtime != nil {
  33578. fields = append(fields, usagestatisticmonth.FieldAddtime)
  33579. }
  33580. if m.add_type != nil {
  33581. fields = append(fields, usagestatisticmonth.FieldType)
  33582. }
  33583. if m.addorganization_id != nil {
  33584. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  33585. }
  33586. if m.addai_response != nil {
  33587. fields = append(fields, usagestatisticmonth.FieldAiResponse)
  33588. }
  33589. if m.addsop_run != nil {
  33590. fields = append(fields, usagestatisticmonth.FieldSopRun)
  33591. }
  33592. if m.addtotal_friend != nil {
  33593. fields = append(fields, usagestatisticmonth.FieldTotalFriend)
  33594. }
  33595. if m.addtotal_group != nil {
  33596. fields = append(fields, usagestatisticmonth.FieldTotalGroup)
  33597. }
  33598. if m.addaccount_balance != nil {
  33599. fields = append(fields, usagestatisticmonth.FieldAccountBalance)
  33600. }
  33601. if m.addconsume_token != nil {
  33602. fields = append(fields, usagestatisticmonth.FieldConsumeToken)
  33603. }
  33604. if m.addactive_user != nil {
  33605. fields = append(fields, usagestatisticmonth.FieldActiveUser)
  33606. }
  33607. if m.addnew_user != nil {
  33608. fields = append(fields, usagestatisticmonth.FieldNewUser)
  33609. }
  33610. return fields
  33611. }
  33612. // AddedField returns the numeric value that was incremented/decremented on a field
  33613. // with the given name. The second boolean return value indicates that this field
  33614. // was not set, or was not defined in the schema.
  33615. func (m *UsageStatisticMonthMutation) AddedField(name string) (ent.Value, bool) {
  33616. switch name {
  33617. case usagestatisticmonth.FieldStatus:
  33618. return m.AddedStatus()
  33619. case usagestatisticmonth.FieldAddtime:
  33620. return m.AddedAddtime()
  33621. case usagestatisticmonth.FieldType:
  33622. return m.AddedType()
  33623. case usagestatisticmonth.FieldOrganizationID:
  33624. return m.AddedOrganizationID()
  33625. case usagestatisticmonth.FieldAiResponse:
  33626. return m.AddedAiResponse()
  33627. case usagestatisticmonth.FieldSopRun:
  33628. return m.AddedSopRun()
  33629. case usagestatisticmonth.FieldTotalFriend:
  33630. return m.AddedTotalFriend()
  33631. case usagestatisticmonth.FieldTotalGroup:
  33632. return m.AddedTotalGroup()
  33633. case usagestatisticmonth.FieldAccountBalance:
  33634. return m.AddedAccountBalance()
  33635. case usagestatisticmonth.FieldConsumeToken:
  33636. return m.AddedConsumeToken()
  33637. case usagestatisticmonth.FieldActiveUser:
  33638. return m.AddedActiveUser()
  33639. case usagestatisticmonth.FieldNewUser:
  33640. return m.AddedNewUser()
  33641. }
  33642. return nil, false
  33643. }
  33644. // AddField adds the value to the field with the given name. It returns an error if
  33645. // the field is not defined in the schema, or if the type mismatched the field
  33646. // type.
  33647. func (m *UsageStatisticMonthMutation) AddField(name string, value ent.Value) error {
  33648. switch name {
  33649. case usagestatisticmonth.FieldStatus:
  33650. v, ok := value.(int8)
  33651. if !ok {
  33652. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33653. }
  33654. m.AddStatus(v)
  33655. return nil
  33656. case usagestatisticmonth.FieldAddtime:
  33657. v, ok := value.(int64)
  33658. if !ok {
  33659. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33660. }
  33661. m.AddAddtime(v)
  33662. return nil
  33663. case usagestatisticmonth.FieldType:
  33664. v, ok := value.(int)
  33665. if !ok {
  33666. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33667. }
  33668. m.AddType(v)
  33669. return nil
  33670. case usagestatisticmonth.FieldOrganizationID:
  33671. v, ok := value.(int64)
  33672. if !ok {
  33673. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33674. }
  33675. m.AddOrganizationID(v)
  33676. return nil
  33677. case usagestatisticmonth.FieldAiResponse:
  33678. v, ok := value.(int64)
  33679. if !ok {
  33680. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33681. }
  33682. m.AddAiResponse(v)
  33683. return nil
  33684. case usagestatisticmonth.FieldSopRun:
  33685. v, ok := value.(int64)
  33686. if !ok {
  33687. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33688. }
  33689. m.AddSopRun(v)
  33690. return nil
  33691. case usagestatisticmonth.FieldTotalFriend:
  33692. v, ok := value.(int64)
  33693. if !ok {
  33694. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33695. }
  33696. m.AddTotalFriend(v)
  33697. return nil
  33698. case usagestatisticmonth.FieldTotalGroup:
  33699. v, ok := value.(int64)
  33700. if !ok {
  33701. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33702. }
  33703. m.AddTotalGroup(v)
  33704. return nil
  33705. case usagestatisticmonth.FieldAccountBalance:
  33706. v, ok := value.(int64)
  33707. if !ok {
  33708. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33709. }
  33710. m.AddAccountBalance(v)
  33711. return nil
  33712. case usagestatisticmonth.FieldConsumeToken:
  33713. v, ok := value.(int64)
  33714. if !ok {
  33715. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33716. }
  33717. m.AddConsumeToken(v)
  33718. return nil
  33719. case usagestatisticmonth.FieldActiveUser:
  33720. v, ok := value.(int64)
  33721. if !ok {
  33722. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33723. }
  33724. m.AddActiveUser(v)
  33725. return nil
  33726. case usagestatisticmonth.FieldNewUser:
  33727. v, ok := value.(int64)
  33728. if !ok {
  33729. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33730. }
  33731. m.AddNewUser(v)
  33732. return nil
  33733. }
  33734. return fmt.Errorf("unknown UsageStatisticMonth numeric field %s", name)
  33735. }
  33736. // ClearedFields returns all nullable fields that were cleared during this
  33737. // mutation.
  33738. func (m *UsageStatisticMonthMutation) ClearedFields() []string {
  33739. var fields []string
  33740. if m.FieldCleared(usagestatisticmonth.FieldStatus) {
  33741. fields = append(fields, usagestatisticmonth.FieldStatus)
  33742. }
  33743. if m.FieldCleared(usagestatisticmonth.FieldDeletedAt) {
  33744. fields = append(fields, usagestatisticmonth.FieldDeletedAt)
  33745. }
  33746. if m.FieldCleared(usagestatisticmonth.FieldBotID) {
  33747. fields = append(fields, usagestatisticmonth.FieldBotID)
  33748. }
  33749. if m.FieldCleared(usagestatisticmonth.FieldOrganizationID) {
  33750. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  33751. }
  33752. return fields
  33753. }
  33754. // FieldCleared returns a boolean indicating if a field with the given name was
  33755. // cleared in this mutation.
  33756. func (m *UsageStatisticMonthMutation) FieldCleared(name string) bool {
  33757. _, ok := m.clearedFields[name]
  33758. return ok
  33759. }
  33760. // ClearField clears the value of the field with the given name. It returns an
  33761. // error if the field is not defined in the schema.
  33762. func (m *UsageStatisticMonthMutation) ClearField(name string) error {
  33763. switch name {
  33764. case usagestatisticmonth.FieldStatus:
  33765. m.ClearStatus()
  33766. return nil
  33767. case usagestatisticmonth.FieldDeletedAt:
  33768. m.ClearDeletedAt()
  33769. return nil
  33770. case usagestatisticmonth.FieldBotID:
  33771. m.ClearBotID()
  33772. return nil
  33773. case usagestatisticmonth.FieldOrganizationID:
  33774. m.ClearOrganizationID()
  33775. return nil
  33776. }
  33777. return fmt.Errorf("unknown UsageStatisticMonth nullable field %s", name)
  33778. }
  33779. // ResetField resets all changes in the mutation for the field with the given name.
  33780. // It returns an error if the field is not defined in the schema.
  33781. func (m *UsageStatisticMonthMutation) ResetField(name string) error {
  33782. switch name {
  33783. case usagestatisticmonth.FieldCreatedAt:
  33784. m.ResetCreatedAt()
  33785. return nil
  33786. case usagestatisticmonth.FieldUpdatedAt:
  33787. m.ResetUpdatedAt()
  33788. return nil
  33789. case usagestatisticmonth.FieldStatus:
  33790. m.ResetStatus()
  33791. return nil
  33792. case usagestatisticmonth.FieldDeletedAt:
  33793. m.ResetDeletedAt()
  33794. return nil
  33795. case usagestatisticmonth.FieldAddtime:
  33796. m.ResetAddtime()
  33797. return nil
  33798. case usagestatisticmonth.FieldType:
  33799. m.ResetType()
  33800. return nil
  33801. case usagestatisticmonth.FieldBotID:
  33802. m.ResetBotID()
  33803. return nil
  33804. case usagestatisticmonth.FieldOrganizationID:
  33805. m.ResetOrganizationID()
  33806. return nil
  33807. case usagestatisticmonth.FieldAiResponse:
  33808. m.ResetAiResponse()
  33809. return nil
  33810. case usagestatisticmonth.FieldSopRun:
  33811. m.ResetSopRun()
  33812. return nil
  33813. case usagestatisticmonth.FieldTotalFriend:
  33814. m.ResetTotalFriend()
  33815. return nil
  33816. case usagestatisticmonth.FieldTotalGroup:
  33817. m.ResetTotalGroup()
  33818. return nil
  33819. case usagestatisticmonth.FieldAccountBalance:
  33820. m.ResetAccountBalance()
  33821. return nil
  33822. case usagestatisticmonth.FieldConsumeToken:
  33823. m.ResetConsumeToken()
  33824. return nil
  33825. case usagestatisticmonth.FieldActiveUser:
  33826. m.ResetActiveUser()
  33827. return nil
  33828. case usagestatisticmonth.FieldNewUser:
  33829. m.ResetNewUser()
  33830. return nil
  33831. case usagestatisticmonth.FieldLabelDist:
  33832. m.ResetLabelDist()
  33833. return nil
  33834. }
  33835. return fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  33836. }
  33837. // AddedEdges returns all edge names that were set/added in this mutation.
  33838. func (m *UsageStatisticMonthMutation) AddedEdges() []string {
  33839. edges := make([]string, 0, 0)
  33840. return edges
  33841. }
  33842. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  33843. // name in this mutation.
  33844. func (m *UsageStatisticMonthMutation) AddedIDs(name string) []ent.Value {
  33845. return nil
  33846. }
  33847. // RemovedEdges returns all edge names that were removed in this mutation.
  33848. func (m *UsageStatisticMonthMutation) RemovedEdges() []string {
  33849. edges := make([]string, 0, 0)
  33850. return edges
  33851. }
  33852. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  33853. // the given name in this mutation.
  33854. func (m *UsageStatisticMonthMutation) RemovedIDs(name string) []ent.Value {
  33855. return nil
  33856. }
  33857. // ClearedEdges returns all edge names that were cleared in this mutation.
  33858. func (m *UsageStatisticMonthMutation) ClearedEdges() []string {
  33859. edges := make([]string, 0, 0)
  33860. return edges
  33861. }
  33862. // EdgeCleared returns a boolean which indicates if the edge with the given name
  33863. // was cleared in this mutation.
  33864. func (m *UsageStatisticMonthMutation) EdgeCleared(name string) bool {
  33865. return false
  33866. }
  33867. // ClearEdge clears the value of the edge with the given name. It returns an error
  33868. // if that edge is not defined in the schema.
  33869. func (m *UsageStatisticMonthMutation) ClearEdge(name string) error {
  33870. return fmt.Errorf("unknown UsageStatisticMonth unique edge %s", name)
  33871. }
  33872. // ResetEdge resets all changes to the edge with the given name in this mutation.
  33873. // It returns an error if the edge is not defined in the schema.
  33874. func (m *UsageStatisticMonthMutation) ResetEdge(name string) error {
  33875. return fmt.Errorf("unknown UsageStatisticMonth edge %s", name)
  33876. }
  33877. // UsageTotalMutation represents an operation that mutates the UsageTotal nodes in the graph.
  33878. type UsageTotalMutation struct {
  33879. config
  33880. op Op
  33881. typ string
  33882. id *uint64
  33883. created_at *time.Time
  33884. updated_at *time.Time
  33885. status *uint8
  33886. addstatus *int8
  33887. _type *int
  33888. add_type *int
  33889. bot_id *string
  33890. total_tokens *uint64
  33891. addtotal_tokens *int64
  33892. start_index *uint64
  33893. addstart_index *int64
  33894. end_index *uint64
  33895. addend_index *int64
  33896. organization_id *uint64
  33897. addorganization_id *int64
  33898. clearedFields map[string]struct{}
  33899. done bool
  33900. oldValue func(context.Context) (*UsageTotal, error)
  33901. predicates []predicate.UsageTotal
  33902. }
  33903. var _ ent.Mutation = (*UsageTotalMutation)(nil)
  33904. // usagetotalOption allows management of the mutation configuration using functional options.
  33905. type usagetotalOption func(*UsageTotalMutation)
  33906. // newUsageTotalMutation creates new mutation for the UsageTotal entity.
  33907. func newUsageTotalMutation(c config, op Op, opts ...usagetotalOption) *UsageTotalMutation {
  33908. m := &UsageTotalMutation{
  33909. config: c,
  33910. op: op,
  33911. typ: TypeUsageTotal,
  33912. clearedFields: make(map[string]struct{}),
  33913. }
  33914. for _, opt := range opts {
  33915. opt(m)
  33916. }
  33917. return m
  33918. }
  33919. // withUsageTotalID sets the ID field of the mutation.
  33920. func withUsageTotalID(id uint64) usagetotalOption {
  33921. return func(m *UsageTotalMutation) {
  33922. var (
  33923. err error
  33924. once sync.Once
  33925. value *UsageTotal
  33926. )
  33927. m.oldValue = func(ctx context.Context) (*UsageTotal, error) {
  33928. once.Do(func() {
  33929. if m.done {
  33930. err = errors.New("querying old values post mutation is not allowed")
  33931. } else {
  33932. value, err = m.Client().UsageTotal.Get(ctx, id)
  33933. }
  33934. })
  33935. return value, err
  33936. }
  33937. m.id = &id
  33938. }
  33939. }
  33940. // withUsageTotal sets the old UsageTotal of the mutation.
  33941. func withUsageTotal(node *UsageTotal) usagetotalOption {
  33942. return func(m *UsageTotalMutation) {
  33943. m.oldValue = func(context.Context) (*UsageTotal, error) {
  33944. return node, nil
  33945. }
  33946. m.id = &node.ID
  33947. }
  33948. }
  33949. // Client returns a new `ent.Client` from the mutation. If the mutation was
  33950. // executed in a transaction (ent.Tx), a transactional client is returned.
  33951. func (m UsageTotalMutation) Client() *Client {
  33952. client := &Client{config: m.config}
  33953. client.init()
  33954. return client
  33955. }
  33956. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  33957. // it returns an error otherwise.
  33958. func (m UsageTotalMutation) Tx() (*Tx, error) {
  33959. if _, ok := m.driver.(*txDriver); !ok {
  33960. return nil, errors.New("ent: mutation is not running in a transaction")
  33961. }
  33962. tx := &Tx{config: m.config}
  33963. tx.init()
  33964. return tx, nil
  33965. }
  33966. // SetID sets the value of the id field. Note that this
  33967. // operation is only accepted on creation of UsageTotal entities.
  33968. func (m *UsageTotalMutation) SetID(id uint64) {
  33969. m.id = &id
  33970. }
  33971. // ID returns the ID value in the mutation. Note that the ID is only available
  33972. // if it was provided to the builder or after it was returned from the database.
  33973. func (m *UsageTotalMutation) ID() (id uint64, exists bool) {
  33974. if m.id == nil {
  33975. return
  33976. }
  33977. return *m.id, true
  33978. }
  33979. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  33980. // That means, if the mutation is applied within a transaction with an isolation level such
  33981. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  33982. // or updated by the mutation.
  33983. func (m *UsageTotalMutation) IDs(ctx context.Context) ([]uint64, error) {
  33984. switch {
  33985. case m.op.Is(OpUpdateOne | OpDeleteOne):
  33986. id, exists := m.ID()
  33987. if exists {
  33988. return []uint64{id}, nil
  33989. }
  33990. fallthrough
  33991. case m.op.Is(OpUpdate | OpDelete):
  33992. return m.Client().UsageTotal.Query().Where(m.predicates...).IDs(ctx)
  33993. default:
  33994. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  33995. }
  33996. }
  33997. // SetCreatedAt sets the "created_at" field.
  33998. func (m *UsageTotalMutation) SetCreatedAt(t time.Time) {
  33999. m.created_at = &t
  34000. }
  34001. // CreatedAt returns the value of the "created_at" field in the mutation.
  34002. func (m *UsageTotalMutation) CreatedAt() (r time.Time, exists bool) {
  34003. v := m.created_at
  34004. if v == nil {
  34005. return
  34006. }
  34007. return *v, true
  34008. }
  34009. // OldCreatedAt returns the old "created_at" field's value of the UsageTotal entity.
  34010. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  34011. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34012. func (m *UsageTotalMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  34013. if !m.op.Is(OpUpdateOne) {
  34014. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  34015. }
  34016. if m.id == nil || m.oldValue == nil {
  34017. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  34018. }
  34019. oldValue, err := m.oldValue(ctx)
  34020. if err != nil {
  34021. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  34022. }
  34023. return oldValue.CreatedAt, nil
  34024. }
  34025. // ResetCreatedAt resets all changes to the "created_at" field.
  34026. func (m *UsageTotalMutation) ResetCreatedAt() {
  34027. m.created_at = nil
  34028. }
  34029. // SetUpdatedAt sets the "updated_at" field.
  34030. func (m *UsageTotalMutation) SetUpdatedAt(t time.Time) {
  34031. m.updated_at = &t
  34032. }
  34033. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  34034. func (m *UsageTotalMutation) UpdatedAt() (r time.Time, exists bool) {
  34035. v := m.updated_at
  34036. if v == nil {
  34037. return
  34038. }
  34039. return *v, true
  34040. }
  34041. // OldUpdatedAt returns the old "updated_at" field's value of the UsageTotal entity.
  34042. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  34043. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34044. func (m *UsageTotalMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  34045. if !m.op.Is(OpUpdateOne) {
  34046. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  34047. }
  34048. if m.id == nil || m.oldValue == nil {
  34049. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  34050. }
  34051. oldValue, err := m.oldValue(ctx)
  34052. if err != nil {
  34053. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  34054. }
  34055. return oldValue.UpdatedAt, nil
  34056. }
  34057. // ResetUpdatedAt resets all changes to the "updated_at" field.
  34058. func (m *UsageTotalMutation) ResetUpdatedAt() {
  34059. m.updated_at = nil
  34060. }
  34061. // SetStatus sets the "status" field.
  34062. func (m *UsageTotalMutation) SetStatus(u uint8) {
  34063. m.status = &u
  34064. m.addstatus = nil
  34065. }
  34066. // Status returns the value of the "status" field in the mutation.
  34067. func (m *UsageTotalMutation) Status() (r uint8, exists bool) {
  34068. v := m.status
  34069. if v == nil {
  34070. return
  34071. }
  34072. return *v, true
  34073. }
  34074. // OldStatus returns the old "status" field's value of the UsageTotal entity.
  34075. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  34076. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34077. func (m *UsageTotalMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  34078. if !m.op.Is(OpUpdateOne) {
  34079. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  34080. }
  34081. if m.id == nil || m.oldValue == nil {
  34082. return v, errors.New("OldStatus requires an ID field in the mutation")
  34083. }
  34084. oldValue, err := m.oldValue(ctx)
  34085. if err != nil {
  34086. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  34087. }
  34088. return oldValue.Status, nil
  34089. }
  34090. // AddStatus adds u to the "status" field.
  34091. func (m *UsageTotalMutation) AddStatus(u int8) {
  34092. if m.addstatus != nil {
  34093. *m.addstatus += u
  34094. } else {
  34095. m.addstatus = &u
  34096. }
  34097. }
  34098. // AddedStatus returns the value that was added to the "status" field in this mutation.
  34099. func (m *UsageTotalMutation) AddedStatus() (r int8, exists bool) {
  34100. v := m.addstatus
  34101. if v == nil {
  34102. return
  34103. }
  34104. return *v, true
  34105. }
  34106. // ClearStatus clears the value of the "status" field.
  34107. func (m *UsageTotalMutation) ClearStatus() {
  34108. m.status = nil
  34109. m.addstatus = nil
  34110. m.clearedFields[usagetotal.FieldStatus] = struct{}{}
  34111. }
  34112. // StatusCleared returns if the "status" field was cleared in this mutation.
  34113. func (m *UsageTotalMutation) StatusCleared() bool {
  34114. _, ok := m.clearedFields[usagetotal.FieldStatus]
  34115. return ok
  34116. }
  34117. // ResetStatus resets all changes to the "status" field.
  34118. func (m *UsageTotalMutation) ResetStatus() {
  34119. m.status = nil
  34120. m.addstatus = nil
  34121. delete(m.clearedFields, usagetotal.FieldStatus)
  34122. }
  34123. // SetType sets the "type" field.
  34124. func (m *UsageTotalMutation) SetType(i int) {
  34125. m._type = &i
  34126. m.add_type = nil
  34127. }
  34128. // GetType returns the value of the "type" field in the mutation.
  34129. func (m *UsageTotalMutation) GetType() (r int, exists bool) {
  34130. v := m._type
  34131. if v == nil {
  34132. return
  34133. }
  34134. return *v, true
  34135. }
  34136. // OldType returns the old "type" field's value of the UsageTotal entity.
  34137. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  34138. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34139. func (m *UsageTotalMutation) OldType(ctx context.Context) (v int, err error) {
  34140. if !m.op.Is(OpUpdateOne) {
  34141. return v, errors.New("OldType is only allowed on UpdateOne operations")
  34142. }
  34143. if m.id == nil || m.oldValue == nil {
  34144. return v, errors.New("OldType requires an ID field in the mutation")
  34145. }
  34146. oldValue, err := m.oldValue(ctx)
  34147. if err != nil {
  34148. return v, fmt.Errorf("querying old value for OldType: %w", err)
  34149. }
  34150. return oldValue.Type, nil
  34151. }
  34152. // AddType adds i to the "type" field.
  34153. func (m *UsageTotalMutation) AddType(i int) {
  34154. if m.add_type != nil {
  34155. *m.add_type += i
  34156. } else {
  34157. m.add_type = &i
  34158. }
  34159. }
  34160. // AddedType returns the value that was added to the "type" field in this mutation.
  34161. func (m *UsageTotalMutation) AddedType() (r int, exists bool) {
  34162. v := m.add_type
  34163. if v == nil {
  34164. return
  34165. }
  34166. return *v, true
  34167. }
  34168. // ClearType clears the value of the "type" field.
  34169. func (m *UsageTotalMutation) ClearType() {
  34170. m._type = nil
  34171. m.add_type = nil
  34172. m.clearedFields[usagetotal.FieldType] = struct{}{}
  34173. }
  34174. // TypeCleared returns if the "type" field was cleared in this mutation.
  34175. func (m *UsageTotalMutation) TypeCleared() bool {
  34176. _, ok := m.clearedFields[usagetotal.FieldType]
  34177. return ok
  34178. }
  34179. // ResetType resets all changes to the "type" field.
  34180. func (m *UsageTotalMutation) ResetType() {
  34181. m._type = nil
  34182. m.add_type = nil
  34183. delete(m.clearedFields, usagetotal.FieldType)
  34184. }
  34185. // SetBotID sets the "bot_id" field.
  34186. func (m *UsageTotalMutation) SetBotID(s string) {
  34187. m.bot_id = &s
  34188. }
  34189. // BotID returns the value of the "bot_id" field in the mutation.
  34190. func (m *UsageTotalMutation) BotID() (r string, exists bool) {
  34191. v := m.bot_id
  34192. if v == nil {
  34193. return
  34194. }
  34195. return *v, true
  34196. }
  34197. // OldBotID returns the old "bot_id" field's value of the UsageTotal entity.
  34198. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  34199. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34200. func (m *UsageTotalMutation) OldBotID(ctx context.Context) (v string, err error) {
  34201. if !m.op.Is(OpUpdateOne) {
  34202. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  34203. }
  34204. if m.id == nil || m.oldValue == nil {
  34205. return v, errors.New("OldBotID requires an ID field in the mutation")
  34206. }
  34207. oldValue, err := m.oldValue(ctx)
  34208. if err != nil {
  34209. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  34210. }
  34211. return oldValue.BotID, nil
  34212. }
  34213. // ResetBotID resets all changes to the "bot_id" field.
  34214. func (m *UsageTotalMutation) ResetBotID() {
  34215. m.bot_id = nil
  34216. }
  34217. // SetTotalTokens sets the "total_tokens" field.
  34218. func (m *UsageTotalMutation) SetTotalTokens(u uint64) {
  34219. m.total_tokens = &u
  34220. m.addtotal_tokens = nil
  34221. }
  34222. // TotalTokens returns the value of the "total_tokens" field in the mutation.
  34223. func (m *UsageTotalMutation) TotalTokens() (r uint64, exists bool) {
  34224. v := m.total_tokens
  34225. if v == nil {
  34226. return
  34227. }
  34228. return *v, true
  34229. }
  34230. // OldTotalTokens returns the old "total_tokens" field's value of the UsageTotal entity.
  34231. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  34232. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34233. func (m *UsageTotalMutation) OldTotalTokens(ctx context.Context) (v uint64, err error) {
  34234. if !m.op.Is(OpUpdateOne) {
  34235. return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
  34236. }
  34237. if m.id == nil || m.oldValue == nil {
  34238. return v, errors.New("OldTotalTokens requires an ID field in the mutation")
  34239. }
  34240. oldValue, err := m.oldValue(ctx)
  34241. if err != nil {
  34242. return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
  34243. }
  34244. return oldValue.TotalTokens, nil
  34245. }
  34246. // AddTotalTokens adds u to the "total_tokens" field.
  34247. func (m *UsageTotalMutation) AddTotalTokens(u int64) {
  34248. if m.addtotal_tokens != nil {
  34249. *m.addtotal_tokens += u
  34250. } else {
  34251. m.addtotal_tokens = &u
  34252. }
  34253. }
  34254. // AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
  34255. func (m *UsageTotalMutation) AddedTotalTokens() (r int64, exists bool) {
  34256. v := m.addtotal_tokens
  34257. if v == nil {
  34258. return
  34259. }
  34260. return *v, true
  34261. }
  34262. // ClearTotalTokens clears the value of the "total_tokens" field.
  34263. func (m *UsageTotalMutation) ClearTotalTokens() {
  34264. m.total_tokens = nil
  34265. m.addtotal_tokens = nil
  34266. m.clearedFields[usagetotal.FieldTotalTokens] = struct{}{}
  34267. }
  34268. // TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
  34269. func (m *UsageTotalMutation) TotalTokensCleared() bool {
  34270. _, ok := m.clearedFields[usagetotal.FieldTotalTokens]
  34271. return ok
  34272. }
  34273. // ResetTotalTokens resets all changes to the "total_tokens" field.
  34274. func (m *UsageTotalMutation) ResetTotalTokens() {
  34275. m.total_tokens = nil
  34276. m.addtotal_tokens = nil
  34277. delete(m.clearedFields, usagetotal.FieldTotalTokens)
  34278. }
  34279. // SetStartIndex sets the "start_index" field.
  34280. func (m *UsageTotalMutation) SetStartIndex(u uint64) {
  34281. m.start_index = &u
  34282. m.addstart_index = nil
  34283. }
  34284. // StartIndex returns the value of the "start_index" field in the mutation.
  34285. func (m *UsageTotalMutation) StartIndex() (r uint64, exists bool) {
  34286. v := m.start_index
  34287. if v == nil {
  34288. return
  34289. }
  34290. return *v, true
  34291. }
  34292. // OldStartIndex returns the old "start_index" field's value of the UsageTotal entity.
  34293. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  34294. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34295. func (m *UsageTotalMutation) OldStartIndex(ctx context.Context) (v uint64, err error) {
  34296. if !m.op.Is(OpUpdateOne) {
  34297. return v, errors.New("OldStartIndex is only allowed on UpdateOne operations")
  34298. }
  34299. if m.id == nil || m.oldValue == nil {
  34300. return v, errors.New("OldStartIndex requires an ID field in the mutation")
  34301. }
  34302. oldValue, err := m.oldValue(ctx)
  34303. if err != nil {
  34304. return v, fmt.Errorf("querying old value for OldStartIndex: %w", err)
  34305. }
  34306. return oldValue.StartIndex, nil
  34307. }
  34308. // AddStartIndex adds u to the "start_index" field.
  34309. func (m *UsageTotalMutation) AddStartIndex(u int64) {
  34310. if m.addstart_index != nil {
  34311. *m.addstart_index += u
  34312. } else {
  34313. m.addstart_index = &u
  34314. }
  34315. }
  34316. // AddedStartIndex returns the value that was added to the "start_index" field in this mutation.
  34317. func (m *UsageTotalMutation) AddedStartIndex() (r int64, exists bool) {
  34318. v := m.addstart_index
  34319. if v == nil {
  34320. return
  34321. }
  34322. return *v, true
  34323. }
  34324. // ClearStartIndex clears the value of the "start_index" field.
  34325. func (m *UsageTotalMutation) ClearStartIndex() {
  34326. m.start_index = nil
  34327. m.addstart_index = nil
  34328. m.clearedFields[usagetotal.FieldStartIndex] = struct{}{}
  34329. }
  34330. // StartIndexCleared returns if the "start_index" field was cleared in this mutation.
  34331. func (m *UsageTotalMutation) StartIndexCleared() bool {
  34332. _, ok := m.clearedFields[usagetotal.FieldStartIndex]
  34333. return ok
  34334. }
  34335. // ResetStartIndex resets all changes to the "start_index" field.
  34336. func (m *UsageTotalMutation) ResetStartIndex() {
  34337. m.start_index = nil
  34338. m.addstart_index = nil
  34339. delete(m.clearedFields, usagetotal.FieldStartIndex)
  34340. }
  34341. // SetEndIndex sets the "end_index" field.
  34342. func (m *UsageTotalMutation) SetEndIndex(u uint64) {
  34343. m.end_index = &u
  34344. m.addend_index = nil
  34345. }
  34346. // EndIndex returns the value of the "end_index" field in the mutation.
  34347. func (m *UsageTotalMutation) EndIndex() (r uint64, exists bool) {
  34348. v := m.end_index
  34349. if v == nil {
  34350. return
  34351. }
  34352. return *v, true
  34353. }
  34354. // OldEndIndex returns the old "end_index" field's value of the UsageTotal entity.
  34355. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  34356. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34357. func (m *UsageTotalMutation) OldEndIndex(ctx context.Context) (v uint64, err error) {
  34358. if !m.op.Is(OpUpdateOne) {
  34359. return v, errors.New("OldEndIndex is only allowed on UpdateOne operations")
  34360. }
  34361. if m.id == nil || m.oldValue == nil {
  34362. return v, errors.New("OldEndIndex requires an ID field in the mutation")
  34363. }
  34364. oldValue, err := m.oldValue(ctx)
  34365. if err != nil {
  34366. return v, fmt.Errorf("querying old value for OldEndIndex: %w", err)
  34367. }
  34368. return oldValue.EndIndex, nil
  34369. }
  34370. // AddEndIndex adds u to the "end_index" field.
  34371. func (m *UsageTotalMutation) AddEndIndex(u int64) {
  34372. if m.addend_index != nil {
  34373. *m.addend_index += u
  34374. } else {
  34375. m.addend_index = &u
  34376. }
  34377. }
  34378. // AddedEndIndex returns the value that was added to the "end_index" field in this mutation.
  34379. func (m *UsageTotalMutation) AddedEndIndex() (r int64, exists bool) {
  34380. v := m.addend_index
  34381. if v == nil {
  34382. return
  34383. }
  34384. return *v, true
  34385. }
  34386. // ClearEndIndex clears the value of the "end_index" field.
  34387. func (m *UsageTotalMutation) ClearEndIndex() {
  34388. m.end_index = nil
  34389. m.addend_index = nil
  34390. m.clearedFields[usagetotal.FieldEndIndex] = struct{}{}
  34391. }
  34392. // EndIndexCleared returns if the "end_index" field was cleared in this mutation.
  34393. func (m *UsageTotalMutation) EndIndexCleared() bool {
  34394. _, ok := m.clearedFields[usagetotal.FieldEndIndex]
  34395. return ok
  34396. }
  34397. // ResetEndIndex resets all changes to the "end_index" field.
  34398. func (m *UsageTotalMutation) ResetEndIndex() {
  34399. m.end_index = nil
  34400. m.addend_index = nil
  34401. delete(m.clearedFields, usagetotal.FieldEndIndex)
  34402. }
  34403. // SetOrganizationID sets the "organization_id" field.
  34404. func (m *UsageTotalMutation) SetOrganizationID(u uint64) {
  34405. m.organization_id = &u
  34406. m.addorganization_id = nil
  34407. }
  34408. // OrganizationID returns the value of the "organization_id" field in the mutation.
  34409. func (m *UsageTotalMutation) OrganizationID() (r uint64, exists bool) {
  34410. v := m.organization_id
  34411. if v == nil {
  34412. return
  34413. }
  34414. return *v, true
  34415. }
  34416. // OldOrganizationID returns the old "organization_id" field's value of the UsageTotal entity.
  34417. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  34418. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34419. func (m *UsageTotalMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  34420. if !m.op.Is(OpUpdateOne) {
  34421. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  34422. }
  34423. if m.id == nil || m.oldValue == nil {
  34424. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  34425. }
  34426. oldValue, err := m.oldValue(ctx)
  34427. if err != nil {
  34428. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  34429. }
  34430. return oldValue.OrganizationID, nil
  34431. }
  34432. // AddOrganizationID adds u to the "organization_id" field.
  34433. func (m *UsageTotalMutation) AddOrganizationID(u int64) {
  34434. if m.addorganization_id != nil {
  34435. *m.addorganization_id += u
  34436. } else {
  34437. m.addorganization_id = &u
  34438. }
  34439. }
  34440. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  34441. func (m *UsageTotalMutation) AddedOrganizationID() (r int64, exists bool) {
  34442. v := m.addorganization_id
  34443. if v == nil {
  34444. return
  34445. }
  34446. return *v, true
  34447. }
  34448. // ClearOrganizationID clears the value of the "organization_id" field.
  34449. func (m *UsageTotalMutation) ClearOrganizationID() {
  34450. m.organization_id = nil
  34451. m.addorganization_id = nil
  34452. m.clearedFields[usagetotal.FieldOrganizationID] = struct{}{}
  34453. }
  34454. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  34455. func (m *UsageTotalMutation) OrganizationIDCleared() bool {
  34456. _, ok := m.clearedFields[usagetotal.FieldOrganizationID]
  34457. return ok
  34458. }
  34459. // ResetOrganizationID resets all changes to the "organization_id" field.
  34460. func (m *UsageTotalMutation) ResetOrganizationID() {
  34461. m.organization_id = nil
  34462. m.addorganization_id = nil
  34463. delete(m.clearedFields, usagetotal.FieldOrganizationID)
  34464. }
  34465. // Where appends a list predicates to the UsageTotalMutation builder.
  34466. func (m *UsageTotalMutation) Where(ps ...predicate.UsageTotal) {
  34467. m.predicates = append(m.predicates, ps...)
  34468. }
  34469. // WhereP appends storage-level predicates to the UsageTotalMutation builder. Using this method,
  34470. // users can use type-assertion to append predicates that do not depend on any generated package.
  34471. func (m *UsageTotalMutation) WhereP(ps ...func(*sql.Selector)) {
  34472. p := make([]predicate.UsageTotal, len(ps))
  34473. for i := range ps {
  34474. p[i] = ps[i]
  34475. }
  34476. m.Where(p...)
  34477. }
  34478. // Op returns the operation name.
  34479. func (m *UsageTotalMutation) Op() Op {
  34480. return m.op
  34481. }
  34482. // SetOp allows setting the mutation operation.
  34483. func (m *UsageTotalMutation) SetOp(op Op) {
  34484. m.op = op
  34485. }
  34486. // Type returns the node type of this mutation (UsageTotal).
  34487. func (m *UsageTotalMutation) Type() string {
  34488. return m.typ
  34489. }
  34490. // Fields returns all fields that were changed during this mutation. Note that in
  34491. // order to get all numeric fields that were incremented/decremented, call
  34492. // AddedFields().
  34493. func (m *UsageTotalMutation) Fields() []string {
  34494. fields := make([]string, 0, 9)
  34495. if m.created_at != nil {
  34496. fields = append(fields, usagetotal.FieldCreatedAt)
  34497. }
  34498. if m.updated_at != nil {
  34499. fields = append(fields, usagetotal.FieldUpdatedAt)
  34500. }
  34501. if m.status != nil {
  34502. fields = append(fields, usagetotal.FieldStatus)
  34503. }
  34504. if m._type != nil {
  34505. fields = append(fields, usagetotal.FieldType)
  34506. }
  34507. if m.bot_id != nil {
  34508. fields = append(fields, usagetotal.FieldBotID)
  34509. }
  34510. if m.total_tokens != nil {
  34511. fields = append(fields, usagetotal.FieldTotalTokens)
  34512. }
  34513. if m.start_index != nil {
  34514. fields = append(fields, usagetotal.FieldStartIndex)
  34515. }
  34516. if m.end_index != nil {
  34517. fields = append(fields, usagetotal.FieldEndIndex)
  34518. }
  34519. if m.organization_id != nil {
  34520. fields = append(fields, usagetotal.FieldOrganizationID)
  34521. }
  34522. return fields
  34523. }
  34524. // Field returns the value of a field with the given name. The second boolean
  34525. // return value indicates that this field was not set, or was not defined in the
  34526. // schema.
  34527. func (m *UsageTotalMutation) Field(name string) (ent.Value, bool) {
  34528. switch name {
  34529. case usagetotal.FieldCreatedAt:
  34530. return m.CreatedAt()
  34531. case usagetotal.FieldUpdatedAt:
  34532. return m.UpdatedAt()
  34533. case usagetotal.FieldStatus:
  34534. return m.Status()
  34535. case usagetotal.FieldType:
  34536. return m.GetType()
  34537. case usagetotal.FieldBotID:
  34538. return m.BotID()
  34539. case usagetotal.FieldTotalTokens:
  34540. return m.TotalTokens()
  34541. case usagetotal.FieldStartIndex:
  34542. return m.StartIndex()
  34543. case usagetotal.FieldEndIndex:
  34544. return m.EndIndex()
  34545. case usagetotal.FieldOrganizationID:
  34546. return m.OrganizationID()
  34547. }
  34548. return nil, false
  34549. }
  34550. // OldField returns the old value of the field from the database. An error is
  34551. // returned if the mutation operation is not UpdateOne, or the query to the
  34552. // database failed.
  34553. func (m *UsageTotalMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  34554. switch name {
  34555. case usagetotal.FieldCreatedAt:
  34556. return m.OldCreatedAt(ctx)
  34557. case usagetotal.FieldUpdatedAt:
  34558. return m.OldUpdatedAt(ctx)
  34559. case usagetotal.FieldStatus:
  34560. return m.OldStatus(ctx)
  34561. case usagetotal.FieldType:
  34562. return m.OldType(ctx)
  34563. case usagetotal.FieldBotID:
  34564. return m.OldBotID(ctx)
  34565. case usagetotal.FieldTotalTokens:
  34566. return m.OldTotalTokens(ctx)
  34567. case usagetotal.FieldStartIndex:
  34568. return m.OldStartIndex(ctx)
  34569. case usagetotal.FieldEndIndex:
  34570. return m.OldEndIndex(ctx)
  34571. case usagetotal.FieldOrganizationID:
  34572. return m.OldOrganizationID(ctx)
  34573. }
  34574. return nil, fmt.Errorf("unknown UsageTotal field %s", name)
  34575. }
  34576. // SetField sets the value of a field with the given name. It returns an error if
  34577. // the field is not defined in the schema, or if the type mismatched the field
  34578. // type.
  34579. func (m *UsageTotalMutation) SetField(name string, value ent.Value) error {
  34580. switch name {
  34581. case usagetotal.FieldCreatedAt:
  34582. v, ok := value.(time.Time)
  34583. if !ok {
  34584. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34585. }
  34586. m.SetCreatedAt(v)
  34587. return nil
  34588. case usagetotal.FieldUpdatedAt:
  34589. v, ok := value.(time.Time)
  34590. if !ok {
  34591. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34592. }
  34593. m.SetUpdatedAt(v)
  34594. return nil
  34595. case usagetotal.FieldStatus:
  34596. v, ok := value.(uint8)
  34597. if !ok {
  34598. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34599. }
  34600. m.SetStatus(v)
  34601. return nil
  34602. case usagetotal.FieldType:
  34603. v, ok := value.(int)
  34604. if !ok {
  34605. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34606. }
  34607. m.SetType(v)
  34608. return nil
  34609. case usagetotal.FieldBotID:
  34610. v, ok := value.(string)
  34611. if !ok {
  34612. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34613. }
  34614. m.SetBotID(v)
  34615. return nil
  34616. case usagetotal.FieldTotalTokens:
  34617. v, ok := value.(uint64)
  34618. if !ok {
  34619. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34620. }
  34621. m.SetTotalTokens(v)
  34622. return nil
  34623. case usagetotal.FieldStartIndex:
  34624. v, ok := value.(uint64)
  34625. if !ok {
  34626. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34627. }
  34628. m.SetStartIndex(v)
  34629. return nil
  34630. case usagetotal.FieldEndIndex:
  34631. v, ok := value.(uint64)
  34632. if !ok {
  34633. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34634. }
  34635. m.SetEndIndex(v)
  34636. return nil
  34637. case usagetotal.FieldOrganizationID:
  34638. v, ok := value.(uint64)
  34639. if !ok {
  34640. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34641. }
  34642. m.SetOrganizationID(v)
  34643. return nil
  34644. }
  34645. return fmt.Errorf("unknown UsageTotal field %s", name)
  34646. }
  34647. // AddedFields returns all numeric fields that were incremented/decremented during
  34648. // this mutation.
  34649. func (m *UsageTotalMutation) AddedFields() []string {
  34650. var fields []string
  34651. if m.addstatus != nil {
  34652. fields = append(fields, usagetotal.FieldStatus)
  34653. }
  34654. if m.add_type != nil {
  34655. fields = append(fields, usagetotal.FieldType)
  34656. }
  34657. if m.addtotal_tokens != nil {
  34658. fields = append(fields, usagetotal.FieldTotalTokens)
  34659. }
  34660. if m.addstart_index != nil {
  34661. fields = append(fields, usagetotal.FieldStartIndex)
  34662. }
  34663. if m.addend_index != nil {
  34664. fields = append(fields, usagetotal.FieldEndIndex)
  34665. }
  34666. if m.addorganization_id != nil {
  34667. fields = append(fields, usagetotal.FieldOrganizationID)
  34668. }
  34669. return fields
  34670. }
  34671. // AddedField returns the numeric value that was incremented/decremented on a field
  34672. // with the given name. The second boolean return value indicates that this field
  34673. // was not set, or was not defined in the schema.
  34674. func (m *UsageTotalMutation) AddedField(name string) (ent.Value, bool) {
  34675. switch name {
  34676. case usagetotal.FieldStatus:
  34677. return m.AddedStatus()
  34678. case usagetotal.FieldType:
  34679. return m.AddedType()
  34680. case usagetotal.FieldTotalTokens:
  34681. return m.AddedTotalTokens()
  34682. case usagetotal.FieldStartIndex:
  34683. return m.AddedStartIndex()
  34684. case usagetotal.FieldEndIndex:
  34685. return m.AddedEndIndex()
  34686. case usagetotal.FieldOrganizationID:
  34687. return m.AddedOrganizationID()
  34688. }
  34689. return nil, false
  34690. }
  34691. // AddField adds the value to the field with the given name. It returns an error if
  34692. // the field is not defined in the schema, or if the type mismatched the field
  34693. // type.
  34694. func (m *UsageTotalMutation) AddField(name string, value ent.Value) error {
  34695. switch name {
  34696. case usagetotal.FieldStatus:
  34697. v, ok := value.(int8)
  34698. if !ok {
  34699. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34700. }
  34701. m.AddStatus(v)
  34702. return nil
  34703. case usagetotal.FieldType:
  34704. v, ok := value.(int)
  34705. if !ok {
  34706. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34707. }
  34708. m.AddType(v)
  34709. return nil
  34710. case usagetotal.FieldTotalTokens:
  34711. v, ok := value.(int64)
  34712. if !ok {
  34713. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34714. }
  34715. m.AddTotalTokens(v)
  34716. return nil
  34717. case usagetotal.FieldStartIndex:
  34718. v, ok := value.(int64)
  34719. if !ok {
  34720. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34721. }
  34722. m.AddStartIndex(v)
  34723. return nil
  34724. case usagetotal.FieldEndIndex:
  34725. v, ok := value.(int64)
  34726. if !ok {
  34727. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34728. }
  34729. m.AddEndIndex(v)
  34730. return nil
  34731. case usagetotal.FieldOrganizationID:
  34732. v, ok := value.(int64)
  34733. if !ok {
  34734. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34735. }
  34736. m.AddOrganizationID(v)
  34737. return nil
  34738. }
  34739. return fmt.Errorf("unknown UsageTotal numeric field %s", name)
  34740. }
  34741. // ClearedFields returns all nullable fields that were cleared during this
  34742. // mutation.
  34743. func (m *UsageTotalMutation) ClearedFields() []string {
  34744. var fields []string
  34745. if m.FieldCleared(usagetotal.FieldStatus) {
  34746. fields = append(fields, usagetotal.FieldStatus)
  34747. }
  34748. if m.FieldCleared(usagetotal.FieldType) {
  34749. fields = append(fields, usagetotal.FieldType)
  34750. }
  34751. if m.FieldCleared(usagetotal.FieldTotalTokens) {
  34752. fields = append(fields, usagetotal.FieldTotalTokens)
  34753. }
  34754. if m.FieldCleared(usagetotal.FieldStartIndex) {
  34755. fields = append(fields, usagetotal.FieldStartIndex)
  34756. }
  34757. if m.FieldCleared(usagetotal.FieldEndIndex) {
  34758. fields = append(fields, usagetotal.FieldEndIndex)
  34759. }
  34760. if m.FieldCleared(usagetotal.FieldOrganizationID) {
  34761. fields = append(fields, usagetotal.FieldOrganizationID)
  34762. }
  34763. return fields
  34764. }
  34765. // FieldCleared returns a boolean indicating if a field with the given name was
  34766. // cleared in this mutation.
  34767. func (m *UsageTotalMutation) FieldCleared(name string) bool {
  34768. _, ok := m.clearedFields[name]
  34769. return ok
  34770. }
  34771. // ClearField clears the value of the field with the given name. It returns an
  34772. // error if the field is not defined in the schema.
  34773. func (m *UsageTotalMutation) ClearField(name string) error {
  34774. switch name {
  34775. case usagetotal.FieldStatus:
  34776. m.ClearStatus()
  34777. return nil
  34778. case usagetotal.FieldType:
  34779. m.ClearType()
  34780. return nil
  34781. case usagetotal.FieldTotalTokens:
  34782. m.ClearTotalTokens()
  34783. return nil
  34784. case usagetotal.FieldStartIndex:
  34785. m.ClearStartIndex()
  34786. return nil
  34787. case usagetotal.FieldEndIndex:
  34788. m.ClearEndIndex()
  34789. return nil
  34790. case usagetotal.FieldOrganizationID:
  34791. m.ClearOrganizationID()
  34792. return nil
  34793. }
  34794. return fmt.Errorf("unknown UsageTotal nullable field %s", name)
  34795. }
  34796. // ResetField resets all changes in the mutation for the field with the given name.
  34797. // It returns an error if the field is not defined in the schema.
  34798. func (m *UsageTotalMutation) ResetField(name string) error {
  34799. switch name {
  34800. case usagetotal.FieldCreatedAt:
  34801. m.ResetCreatedAt()
  34802. return nil
  34803. case usagetotal.FieldUpdatedAt:
  34804. m.ResetUpdatedAt()
  34805. return nil
  34806. case usagetotal.FieldStatus:
  34807. m.ResetStatus()
  34808. return nil
  34809. case usagetotal.FieldType:
  34810. m.ResetType()
  34811. return nil
  34812. case usagetotal.FieldBotID:
  34813. m.ResetBotID()
  34814. return nil
  34815. case usagetotal.FieldTotalTokens:
  34816. m.ResetTotalTokens()
  34817. return nil
  34818. case usagetotal.FieldStartIndex:
  34819. m.ResetStartIndex()
  34820. return nil
  34821. case usagetotal.FieldEndIndex:
  34822. m.ResetEndIndex()
  34823. return nil
  34824. case usagetotal.FieldOrganizationID:
  34825. m.ResetOrganizationID()
  34826. return nil
  34827. }
  34828. return fmt.Errorf("unknown UsageTotal field %s", name)
  34829. }
  34830. // AddedEdges returns all edge names that were set/added in this mutation.
  34831. func (m *UsageTotalMutation) AddedEdges() []string {
  34832. edges := make([]string, 0, 0)
  34833. return edges
  34834. }
  34835. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  34836. // name in this mutation.
  34837. func (m *UsageTotalMutation) AddedIDs(name string) []ent.Value {
  34838. return nil
  34839. }
  34840. // RemovedEdges returns all edge names that were removed in this mutation.
  34841. func (m *UsageTotalMutation) RemovedEdges() []string {
  34842. edges := make([]string, 0, 0)
  34843. return edges
  34844. }
  34845. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  34846. // the given name in this mutation.
  34847. func (m *UsageTotalMutation) RemovedIDs(name string) []ent.Value {
  34848. return nil
  34849. }
  34850. // ClearedEdges returns all edge names that were cleared in this mutation.
  34851. func (m *UsageTotalMutation) ClearedEdges() []string {
  34852. edges := make([]string, 0, 0)
  34853. return edges
  34854. }
  34855. // EdgeCleared returns a boolean which indicates if the edge with the given name
  34856. // was cleared in this mutation.
  34857. func (m *UsageTotalMutation) EdgeCleared(name string) bool {
  34858. return false
  34859. }
  34860. // ClearEdge clears the value of the edge with the given name. It returns an error
  34861. // if that edge is not defined in the schema.
  34862. func (m *UsageTotalMutation) ClearEdge(name string) error {
  34863. return fmt.Errorf("unknown UsageTotal unique edge %s", name)
  34864. }
  34865. // ResetEdge resets all changes to the edge with the given name in this mutation.
  34866. // It returns an error if the edge is not defined in the schema.
  34867. func (m *UsageTotalMutation) ResetEdge(name string) error {
  34868. return fmt.Errorf("unknown UsageTotal edge %s", name)
  34869. }
  34870. // WhatsappMutation represents an operation that mutates the Whatsapp nodes in the graph.
  34871. type WhatsappMutation struct {
  34872. config
  34873. op Op
  34874. typ string
  34875. id *uint64
  34876. created_at *time.Time
  34877. updated_at *time.Time
  34878. status *uint8
  34879. addstatus *int8
  34880. deleted_at *time.Time
  34881. wa_id *string
  34882. wa_name *string
  34883. callback *string
  34884. account *string
  34885. cc *string
  34886. phone *string
  34887. cc_phone *string
  34888. phone_name *string
  34889. phone_status *int8
  34890. addphone_status *int8
  34891. organization_id *uint64
  34892. addorganization_id *int64
  34893. api_base *string
  34894. api_key *string
  34895. allow_list *[]string
  34896. appendallow_list []string
  34897. group_allow_list *[]string
  34898. appendgroup_allow_list []string
  34899. block_list *[]string
  34900. appendblock_list []string
  34901. group_block_list *[]string
  34902. appendgroup_block_list []string
  34903. clearedFields map[string]struct{}
  34904. agent *uint64
  34905. clearedagent bool
  34906. done bool
  34907. oldValue func(context.Context) (*Whatsapp, error)
  34908. predicates []predicate.Whatsapp
  34909. }
  34910. var _ ent.Mutation = (*WhatsappMutation)(nil)
  34911. // whatsappOption allows management of the mutation configuration using functional options.
  34912. type whatsappOption func(*WhatsappMutation)
  34913. // newWhatsappMutation creates new mutation for the Whatsapp entity.
  34914. func newWhatsappMutation(c config, op Op, opts ...whatsappOption) *WhatsappMutation {
  34915. m := &WhatsappMutation{
  34916. config: c,
  34917. op: op,
  34918. typ: TypeWhatsapp,
  34919. clearedFields: make(map[string]struct{}),
  34920. }
  34921. for _, opt := range opts {
  34922. opt(m)
  34923. }
  34924. return m
  34925. }
  34926. // withWhatsappID sets the ID field of the mutation.
  34927. func withWhatsappID(id uint64) whatsappOption {
  34928. return func(m *WhatsappMutation) {
  34929. var (
  34930. err error
  34931. once sync.Once
  34932. value *Whatsapp
  34933. )
  34934. m.oldValue = func(ctx context.Context) (*Whatsapp, error) {
  34935. once.Do(func() {
  34936. if m.done {
  34937. err = errors.New("querying old values post mutation is not allowed")
  34938. } else {
  34939. value, err = m.Client().Whatsapp.Get(ctx, id)
  34940. }
  34941. })
  34942. return value, err
  34943. }
  34944. m.id = &id
  34945. }
  34946. }
  34947. // withWhatsapp sets the old Whatsapp of the mutation.
  34948. func withWhatsapp(node *Whatsapp) whatsappOption {
  34949. return func(m *WhatsappMutation) {
  34950. m.oldValue = func(context.Context) (*Whatsapp, error) {
  34951. return node, nil
  34952. }
  34953. m.id = &node.ID
  34954. }
  34955. }
  34956. // Client returns a new `ent.Client` from the mutation. If the mutation was
  34957. // executed in a transaction (ent.Tx), a transactional client is returned.
  34958. func (m WhatsappMutation) Client() *Client {
  34959. client := &Client{config: m.config}
  34960. client.init()
  34961. return client
  34962. }
  34963. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  34964. // it returns an error otherwise.
  34965. func (m WhatsappMutation) Tx() (*Tx, error) {
  34966. if _, ok := m.driver.(*txDriver); !ok {
  34967. return nil, errors.New("ent: mutation is not running in a transaction")
  34968. }
  34969. tx := &Tx{config: m.config}
  34970. tx.init()
  34971. return tx, nil
  34972. }
  34973. // SetID sets the value of the id field. Note that this
  34974. // operation is only accepted on creation of Whatsapp entities.
  34975. func (m *WhatsappMutation) SetID(id uint64) {
  34976. m.id = &id
  34977. }
  34978. // ID returns the ID value in the mutation. Note that the ID is only available
  34979. // if it was provided to the builder or after it was returned from the database.
  34980. func (m *WhatsappMutation) ID() (id uint64, exists bool) {
  34981. if m.id == nil {
  34982. return
  34983. }
  34984. return *m.id, true
  34985. }
  34986. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  34987. // That means, if the mutation is applied within a transaction with an isolation level such
  34988. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  34989. // or updated by the mutation.
  34990. func (m *WhatsappMutation) IDs(ctx context.Context) ([]uint64, error) {
  34991. switch {
  34992. case m.op.Is(OpUpdateOne | OpDeleteOne):
  34993. id, exists := m.ID()
  34994. if exists {
  34995. return []uint64{id}, nil
  34996. }
  34997. fallthrough
  34998. case m.op.Is(OpUpdate | OpDelete):
  34999. return m.Client().Whatsapp.Query().Where(m.predicates...).IDs(ctx)
  35000. default:
  35001. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  35002. }
  35003. }
  35004. // SetCreatedAt sets the "created_at" field.
  35005. func (m *WhatsappMutation) SetCreatedAt(t time.Time) {
  35006. m.created_at = &t
  35007. }
  35008. // CreatedAt returns the value of the "created_at" field in the mutation.
  35009. func (m *WhatsappMutation) CreatedAt() (r time.Time, exists bool) {
  35010. v := m.created_at
  35011. if v == nil {
  35012. return
  35013. }
  35014. return *v, true
  35015. }
  35016. // OldCreatedAt returns the old "created_at" field's value of the Whatsapp entity.
  35017. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35018. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35019. func (m *WhatsappMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  35020. if !m.op.Is(OpUpdateOne) {
  35021. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  35022. }
  35023. if m.id == nil || m.oldValue == nil {
  35024. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  35025. }
  35026. oldValue, err := m.oldValue(ctx)
  35027. if err != nil {
  35028. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  35029. }
  35030. return oldValue.CreatedAt, nil
  35031. }
  35032. // ResetCreatedAt resets all changes to the "created_at" field.
  35033. func (m *WhatsappMutation) ResetCreatedAt() {
  35034. m.created_at = nil
  35035. }
  35036. // SetUpdatedAt sets the "updated_at" field.
  35037. func (m *WhatsappMutation) SetUpdatedAt(t time.Time) {
  35038. m.updated_at = &t
  35039. }
  35040. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  35041. func (m *WhatsappMutation) UpdatedAt() (r time.Time, exists bool) {
  35042. v := m.updated_at
  35043. if v == nil {
  35044. return
  35045. }
  35046. return *v, true
  35047. }
  35048. // OldUpdatedAt returns the old "updated_at" field's value of the Whatsapp entity.
  35049. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35050. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35051. func (m *WhatsappMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  35052. if !m.op.Is(OpUpdateOne) {
  35053. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  35054. }
  35055. if m.id == nil || m.oldValue == nil {
  35056. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  35057. }
  35058. oldValue, err := m.oldValue(ctx)
  35059. if err != nil {
  35060. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  35061. }
  35062. return oldValue.UpdatedAt, nil
  35063. }
  35064. // ResetUpdatedAt resets all changes to the "updated_at" field.
  35065. func (m *WhatsappMutation) ResetUpdatedAt() {
  35066. m.updated_at = nil
  35067. }
  35068. // SetStatus sets the "status" field.
  35069. func (m *WhatsappMutation) SetStatus(u uint8) {
  35070. m.status = &u
  35071. m.addstatus = nil
  35072. }
  35073. // Status returns the value of the "status" field in the mutation.
  35074. func (m *WhatsappMutation) Status() (r uint8, exists bool) {
  35075. v := m.status
  35076. if v == nil {
  35077. return
  35078. }
  35079. return *v, true
  35080. }
  35081. // OldStatus returns the old "status" field's value of the Whatsapp entity.
  35082. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35083. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35084. func (m *WhatsappMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  35085. if !m.op.Is(OpUpdateOne) {
  35086. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  35087. }
  35088. if m.id == nil || m.oldValue == nil {
  35089. return v, errors.New("OldStatus requires an ID field in the mutation")
  35090. }
  35091. oldValue, err := m.oldValue(ctx)
  35092. if err != nil {
  35093. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  35094. }
  35095. return oldValue.Status, nil
  35096. }
  35097. // AddStatus adds u to the "status" field.
  35098. func (m *WhatsappMutation) AddStatus(u int8) {
  35099. if m.addstatus != nil {
  35100. *m.addstatus += u
  35101. } else {
  35102. m.addstatus = &u
  35103. }
  35104. }
  35105. // AddedStatus returns the value that was added to the "status" field in this mutation.
  35106. func (m *WhatsappMutation) AddedStatus() (r int8, exists bool) {
  35107. v := m.addstatus
  35108. if v == nil {
  35109. return
  35110. }
  35111. return *v, true
  35112. }
  35113. // ClearStatus clears the value of the "status" field.
  35114. func (m *WhatsappMutation) ClearStatus() {
  35115. m.status = nil
  35116. m.addstatus = nil
  35117. m.clearedFields[whatsapp.FieldStatus] = struct{}{}
  35118. }
  35119. // StatusCleared returns if the "status" field was cleared in this mutation.
  35120. func (m *WhatsappMutation) StatusCleared() bool {
  35121. _, ok := m.clearedFields[whatsapp.FieldStatus]
  35122. return ok
  35123. }
  35124. // ResetStatus resets all changes to the "status" field.
  35125. func (m *WhatsappMutation) ResetStatus() {
  35126. m.status = nil
  35127. m.addstatus = nil
  35128. delete(m.clearedFields, whatsapp.FieldStatus)
  35129. }
  35130. // SetDeletedAt sets the "deleted_at" field.
  35131. func (m *WhatsappMutation) SetDeletedAt(t time.Time) {
  35132. m.deleted_at = &t
  35133. }
  35134. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  35135. func (m *WhatsappMutation) DeletedAt() (r time.Time, exists bool) {
  35136. v := m.deleted_at
  35137. if v == nil {
  35138. return
  35139. }
  35140. return *v, true
  35141. }
  35142. // OldDeletedAt returns the old "deleted_at" field's value of the Whatsapp entity.
  35143. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35144. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35145. func (m *WhatsappMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  35146. if !m.op.Is(OpUpdateOne) {
  35147. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  35148. }
  35149. if m.id == nil || m.oldValue == nil {
  35150. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  35151. }
  35152. oldValue, err := m.oldValue(ctx)
  35153. if err != nil {
  35154. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  35155. }
  35156. return oldValue.DeletedAt, nil
  35157. }
  35158. // ClearDeletedAt clears the value of the "deleted_at" field.
  35159. func (m *WhatsappMutation) ClearDeletedAt() {
  35160. m.deleted_at = nil
  35161. m.clearedFields[whatsapp.FieldDeletedAt] = struct{}{}
  35162. }
  35163. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  35164. func (m *WhatsappMutation) DeletedAtCleared() bool {
  35165. _, ok := m.clearedFields[whatsapp.FieldDeletedAt]
  35166. return ok
  35167. }
  35168. // ResetDeletedAt resets all changes to the "deleted_at" field.
  35169. func (m *WhatsappMutation) ResetDeletedAt() {
  35170. m.deleted_at = nil
  35171. delete(m.clearedFields, whatsapp.FieldDeletedAt)
  35172. }
  35173. // SetWaID sets the "wa_id" field.
  35174. func (m *WhatsappMutation) SetWaID(s string) {
  35175. m.wa_id = &s
  35176. }
  35177. // WaID returns the value of the "wa_id" field in the mutation.
  35178. func (m *WhatsappMutation) WaID() (r string, exists bool) {
  35179. v := m.wa_id
  35180. if v == nil {
  35181. return
  35182. }
  35183. return *v, true
  35184. }
  35185. // OldWaID returns the old "wa_id" field's value of the Whatsapp entity.
  35186. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35187. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35188. func (m *WhatsappMutation) OldWaID(ctx context.Context) (v string, err error) {
  35189. if !m.op.Is(OpUpdateOne) {
  35190. return v, errors.New("OldWaID is only allowed on UpdateOne operations")
  35191. }
  35192. if m.id == nil || m.oldValue == nil {
  35193. return v, errors.New("OldWaID requires an ID field in the mutation")
  35194. }
  35195. oldValue, err := m.oldValue(ctx)
  35196. if err != nil {
  35197. return v, fmt.Errorf("querying old value for OldWaID: %w", err)
  35198. }
  35199. return oldValue.WaID, nil
  35200. }
  35201. // ClearWaID clears the value of the "wa_id" field.
  35202. func (m *WhatsappMutation) ClearWaID() {
  35203. m.wa_id = nil
  35204. m.clearedFields[whatsapp.FieldWaID] = struct{}{}
  35205. }
  35206. // WaIDCleared returns if the "wa_id" field was cleared in this mutation.
  35207. func (m *WhatsappMutation) WaIDCleared() bool {
  35208. _, ok := m.clearedFields[whatsapp.FieldWaID]
  35209. return ok
  35210. }
  35211. // ResetWaID resets all changes to the "wa_id" field.
  35212. func (m *WhatsappMutation) ResetWaID() {
  35213. m.wa_id = nil
  35214. delete(m.clearedFields, whatsapp.FieldWaID)
  35215. }
  35216. // SetWaName sets the "wa_name" field.
  35217. func (m *WhatsappMutation) SetWaName(s string) {
  35218. m.wa_name = &s
  35219. }
  35220. // WaName returns the value of the "wa_name" field in the mutation.
  35221. func (m *WhatsappMutation) WaName() (r string, exists bool) {
  35222. v := m.wa_name
  35223. if v == nil {
  35224. return
  35225. }
  35226. return *v, true
  35227. }
  35228. // OldWaName returns the old "wa_name" field's value of the Whatsapp entity.
  35229. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35230. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35231. func (m *WhatsappMutation) OldWaName(ctx context.Context) (v string, err error) {
  35232. if !m.op.Is(OpUpdateOne) {
  35233. return v, errors.New("OldWaName is only allowed on UpdateOne operations")
  35234. }
  35235. if m.id == nil || m.oldValue == nil {
  35236. return v, errors.New("OldWaName requires an ID field in the mutation")
  35237. }
  35238. oldValue, err := m.oldValue(ctx)
  35239. if err != nil {
  35240. return v, fmt.Errorf("querying old value for OldWaName: %w", err)
  35241. }
  35242. return oldValue.WaName, nil
  35243. }
  35244. // ClearWaName clears the value of the "wa_name" field.
  35245. func (m *WhatsappMutation) ClearWaName() {
  35246. m.wa_name = nil
  35247. m.clearedFields[whatsapp.FieldWaName] = struct{}{}
  35248. }
  35249. // WaNameCleared returns if the "wa_name" field was cleared in this mutation.
  35250. func (m *WhatsappMutation) WaNameCleared() bool {
  35251. _, ok := m.clearedFields[whatsapp.FieldWaName]
  35252. return ok
  35253. }
  35254. // ResetWaName resets all changes to the "wa_name" field.
  35255. func (m *WhatsappMutation) ResetWaName() {
  35256. m.wa_name = nil
  35257. delete(m.clearedFields, whatsapp.FieldWaName)
  35258. }
  35259. // SetCallback sets the "callback" field.
  35260. func (m *WhatsappMutation) SetCallback(s string) {
  35261. m.callback = &s
  35262. }
  35263. // Callback returns the value of the "callback" field in the mutation.
  35264. func (m *WhatsappMutation) Callback() (r string, exists bool) {
  35265. v := m.callback
  35266. if v == nil {
  35267. return
  35268. }
  35269. return *v, true
  35270. }
  35271. // OldCallback returns the old "callback" field's value of the Whatsapp entity.
  35272. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35273. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35274. func (m *WhatsappMutation) OldCallback(ctx context.Context) (v string, err error) {
  35275. if !m.op.Is(OpUpdateOne) {
  35276. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  35277. }
  35278. if m.id == nil || m.oldValue == nil {
  35279. return v, errors.New("OldCallback requires an ID field in the mutation")
  35280. }
  35281. oldValue, err := m.oldValue(ctx)
  35282. if err != nil {
  35283. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  35284. }
  35285. return oldValue.Callback, nil
  35286. }
  35287. // ClearCallback clears the value of the "callback" field.
  35288. func (m *WhatsappMutation) ClearCallback() {
  35289. m.callback = nil
  35290. m.clearedFields[whatsapp.FieldCallback] = struct{}{}
  35291. }
  35292. // CallbackCleared returns if the "callback" field was cleared in this mutation.
  35293. func (m *WhatsappMutation) CallbackCleared() bool {
  35294. _, ok := m.clearedFields[whatsapp.FieldCallback]
  35295. return ok
  35296. }
  35297. // ResetCallback resets all changes to the "callback" field.
  35298. func (m *WhatsappMutation) ResetCallback() {
  35299. m.callback = nil
  35300. delete(m.clearedFields, whatsapp.FieldCallback)
  35301. }
  35302. // SetAgentID sets the "agent_id" field.
  35303. func (m *WhatsappMutation) SetAgentID(u uint64) {
  35304. m.agent = &u
  35305. }
  35306. // AgentID returns the value of the "agent_id" field in the mutation.
  35307. func (m *WhatsappMutation) AgentID() (r uint64, exists bool) {
  35308. v := m.agent
  35309. if v == nil {
  35310. return
  35311. }
  35312. return *v, true
  35313. }
  35314. // OldAgentID returns the old "agent_id" field's value of the Whatsapp entity.
  35315. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35316. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35317. func (m *WhatsappMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  35318. if !m.op.Is(OpUpdateOne) {
  35319. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  35320. }
  35321. if m.id == nil || m.oldValue == nil {
  35322. return v, errors.New("OldAgentID requires an ID field in the mutation")
  35323. }
  35324. oldValue, err := m.oldValue(ctx)
  35325. if err != nil {
  35326. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  35327. }
  35328. return oldValue.AgentID, nil
  35329. }
  35330. // ResetAgentID resets all changes to the "agent_id" field.
  35331. func (m *WhatsappMutation) ResetAgentID() {
  35332. m.agent = nil
  35333. }
  35334. // SetAccount sets the "account" field.
  35335. func (m *WhatsappMutation) SetAccount(s string) {
  35336. m.account = &s
  35337. }
  35338. // Account returns the value of the "account" field in the mutation.
  35339. func (m *WhatsappMutation) Account() (r string, exists bool) {
  35340. v := m.account
  35341. if v == nil {
  35342. return
  35343. }
  35344. return *v, true
  35345. }
  35346. // OldAccount returns the old "account" field's value of the Whatsapp entity.
  35347. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35348. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35349. func (m *WhatsappMutation) OldAccount(ctx context.Context) (v string, err error) {
  35350. if !m.op.Is(OpUpdateOne) {
  35351. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  35352. }
  35353. if m.id == nil || m.oldValue == nil {
  35354. return v, errors.New("OldAccount requires an ID field in the mutation")
  35355. }
  35356. oldValue, err := m.oldValue(ctx)
  35357. if err != nil {
  35358. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  35359. }
  35360. return oldValue.Account, nil
  35361. }
  35362. // ClearAccount clears the value of the "account" field.
  35363. func (m *WhatsappMutation) ClearAccount() {
  35364. m.account = nil
  35365. m.clearedFields[whatsapp.FieldAccount] = struct{}{}
  35366. }
  35367. // AccountCleared returns if the "account" field was cleared in this mutation.
  35368. func (m *WhatsappMutation) AccountCleared() bool {
  35369. _, ok := m.clearedFields[whatsapp.FieldAccount]
  35370. return ok
  35371. }
  35372. // ResetAccount resets all changes to the "account" field.
  35373. func (m *WhatsappMutation) ResetAccount() {
  35374. m.account = nil
  35375. delete(m.clearedFields, whatsapp.FieldAccount)
  35376. }
  35377. // SetCc sets the "cc" field.
  35378. func (m *WhatsappMutation) SetCc(s string) {
  35379. m.cc = &s
  35380. }
  35381. // Cc returns the value of the "cc" field in the mutation.
  35382. func (m *WhatsappMutation) Cc() (r string, exists bool) {
  35383. v := m.cc
  35384. if v == nil {
  35385. return
  35386. }
  35387. return *v, true
  35388. }
  35389. // OldCc returns the old "cc" field's value of the Whatsapp entity.
  35390. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35391. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35392. func (m *WhatsappMutation) OldCc(ctx context.Context) (v string, err error) {
  35393. if !m.op.Is(OpUpdateOne) {
  35394. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  35395. }
  35396. if m.id == nil || m.oldValue == nil {
  35397. return v, errors.New("OldCc requires an ID field in the mutation")
  35398. }
  35399. oldValue, err := m.oldValue(ctx)
  35400. if err != nil {
  35401. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  35402. }
  35403. return oldValue.Cc, nil
  35404. }
  35405. // ResetCc resets all changes to the "cc" field.
  35406. func (m *WhatsappMutation) ResetCc() {
  35407. m.cc = nil
  35408. }
  35409. // SetPhone sets the "phone" field.
  35410. func (m *WhatsappMutation) SetPhone(s string) {
  35411. m.phone = &s
  35412. }
  35413. // Phone returns the value of the "phone" field in the mutation.
  35414. func (m *WhatsappMutation) Phone() (r string, exists bool) {
  35415. v := m.phone
  35416. if v == nil {
  35417. return
  35418. }
  35419. return *v, true
  35420. }
  35421. // OldPhone returns the old "phone" field's value of the Whatsapp entity.
  35422. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35423. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35424. func (m *WhatsappMutation) OldPhone(ctx context.Context) (v string, err error) {
  35425. if !m.op.Is(OpUpdateOne) {
  35426. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  35427. }
  35428. if m.id == nil || m.oldValue == nil {
  35429. return v, errors.New("OldPhone requires an ID field in the mutation")
  35430. }
  35431. oldValue, err := m.oldValue(ctx)
  35432. if err != nil {
  35433. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  35434. }
  35435. return oldValue.Phone, nil
  35436. }
  35437. // ResetPhone resets all changes to the "phone" field.
  35438. func (m *WhatsappMutation) ResetPhone() {
  35439. m.phone = nil
  35440. }
  35441. // SetCcPhone sets the "cc_phone" field.
  35442. func (m *WhatsappMutation) SetCcPhone(s string) {
  35443. m.cc_phone = &s
  35444. }
  35445. // CcPhone returns the value of the "cc_phone" field in the mutation.
  35446. func (m *WhatsappMutation) CcPhone() (r string, exists bool) {
  35447. v := m.cc_phone
  35448. if v == nil {
  35449. return
  35450. }
  35451. return *v, true
  35452. }
  35453. // OldCcPhone returns the old "cc_phone" field's value of the Whatsapp entity.
  35454. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35455. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35456. func (m *WhatsappMutation) OldCcPhone(ctx context.Context) (v string, err error) {
  35457. if !m.op.Is(OpUpdateOne) {
  35458. return v, errors.New("OldCcPhone is only allowed on UpdateOne operations")
  35459. }
  35460. if m.id == nil || m.oldValue == nil {
  35461. return v, errors.New("OldCcPhone requires an ID field in the mutation")
  35462. }
  35463. oldValue, err := m.oldValue(ctx)
  35464. if err != nil {
  35465. return v, fmt.Errorf("querying old value for OldCcPhone: %w", err)
  35466. }
  35467. return oldValue.CcPhone, nil
  35468. }
  35469. // ResetCcPhone resets all changes to the "cc_phone" field.
  35470. func (m *WhatsappMutation) ResetCcPhone() {
  35471. m.cc_phone = nil
  35472. }
  35473. // SetPhoneName sets the "phone_name" field.
  35474. func (m *WhatsappMutation) SetPhoneName(s string) {
  35475. m.phone_name = &s
  35476. }
  35477. // PhoneName returns the value of the "phone_name" field in the mutation.
  35478. func (m *WhatsappMutation) PhoneName() (r string, exists bool) {
  35479. v := m.phone_name
  35480. if v == nil {
  35481. return
  35482. }
  35483. return *v, true
  35484. }
  35485. // OldPhoneName returns the old "phone_name" field's value of the Whatsapp entity.
  35486. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35487. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35488. func (m *WhatsappMutation) OldPhoneName(ctx context.Context) (v string, err error) {
  35489. if !m.op.Is(OpUpdateOne) {
  35490. return v, errors.New("OldPhoneName is only allowed on UpdateOne operations")
  35491. }
  35492. if m.id == nil || m.oldValue == nil {
  35493. return v, errors.New("OldPhoneName requires an ID field in the mutation")
  35494. }
  35495. oldValue, err := m.oldValue(ctx)
  35496. if err != nil {
  35497. return v, fmt.Errorf("querying old value for OldPhoneName: %w", err)
  35498. }
  35499. return oldValue.PhoneName, nil
  35500. }
  35501. // ResetPhoneName resets all changes to the "phone_name" field.
  35502. func (m *WhatsappMutation) ResetPhoneName() {
  35503. m.phone_name = nil
  35504. }
  35505. // SetPhoneStatus sets the "phone_status" field.
  35506. func (m *WhatsappMutation) SetPhoneStatus(i int8) {
  35507. m.phone_status = &i
  35508. m.addphone_status = nil
  35509. }
  35510. // PhoneStatus returns the value of the "phone_status" field in the mutation.
  35511. func (m *WhatsappMutation) PhoneStatus() (r int8, exists bool) {
  35512. v := m.phone_status
  35513. if v == nil {
  35514. return
  35515. }
  35516. return *v, true
  35517. }
  35518. // OldPhoneStatus returns the old "phone_status" field's value of the Whatsapp entity.
  35519. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35520. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35521. func (m *WhatsappMutation) OldPhoneStatus(ctx context.Context) (v int8, err error) {
  35522. if !m.op.Is(OpUpdateOne) {
  35523. return v, errors.New("OldPhoneStatus is only allowed on UpdateOne operations")
  35524. }
  35525. if m.id == nil || m.oldValue == nil {
  35526. return v, errors.New("OldPhoneStatus requires an ID field in the mutation")
  35527. }
  35528. oldValue, err := m.oldValue(ctx)
  35529. if err != nil {
  35530. return v, fmt.Errorf("querying old value for OldPhoneStatus: %w", err)
  35531. }
  35532. return oldValue.PhoneStatus, nil
  35533. }
  35534. // AddPhoneStatus adds i to the "phone_status" field.
  35535. func (m *WhatsappMutation) AddPhoneStatus(i int8) {
  35536. if m.addphone_status != nil {
  35537. *m.addphone_status += i
  35538. } else {
  35539. m.addphone_status = &i
  35540. }
  35541. }
  35542. // AddedPhoneStatus returns the value that was added to the "phone_status" field in this mutation.
  35543. func (m *WhatsappMutation) AddedPhoneStatus() (r int8, exists bool) {
  35544. v := m.addphone_status
  35545. if v == nil {
  35546. return
  35547. }
  35548. return *v, true
  35549. }
  35550. // ResetPhoneStatus resets all changes to the "phone_status" field.
  35551. func (m *WhatsappMutation) ResetPhoneStatus() {
  35552. m.phone_status = nil
  35553. m.addphone_status = nil
  35554. }
  35555. // SetOrganizationID sets the "organization_id" field.
  35556. func (m *WhatsappMutation) SetOrganizationID(u uint64) {
  35557. m.organization_id = &u
  35558. m.addorganization_id = nil
  35559. }
  35560. // OrganizationID returns the value of the "organization_id" field in the mutation.
  35561. func (m *WhatsappMutation) OrganizationID() (r uint64, exists bool) {
  35562. v := m.organization_id
  35563. if v == nil {
  35564. return
  35565. }
  35566. return *v, true
  35567. }
  35568. // OldOrganizationID returns the old "organization_id" field's value of the Whatsapp entity.
  35569. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35570. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35571. func (m *WhatsappMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  35572. if !m.op.Is(OpUpdateOne) {
  35573. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  35574. }
  35575. if m.id == nil || m.oldValue == nil {
  35576. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  35577. }
  35578. oldValue, err := m.oldValue(ctx)
  35579. if err != nil {
  35580. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  35581. }
  35582. return oldValue.OrganizationID, nil
  35583. }
  35584. // AddOrganizationID adds u to the "organization_id" field.
  35585. func (m *WhatsappMutation) AddOrganizationID(u int64) {
  35586. if m.addorganization_id != nil {
  35587. *m.addorganization_id += u
  35588. } else {
  35589. m.addorganization_id = &u
  35590. }
  35591. }
  35592. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  35593. func (m *WhatsappMutation) AddedOrganizationID() (r int64, exists bool) {
  35594. v := m.addorganization_id
  35595. if v == nil {
  35596. return
  35597. }
  35598. return *v, true
  35599. }
  35600. // ClearOrganizationID clears the value of the "organization_id" field.
  35601. func (m *WhatsappMutation) ClearOrganizationID() {
  35602. m.organization_id = nil
  35603. m.addorganization_id = nil
  35604. m.clearedFields[whatsapp.FieldOrganizationID] = struct{}{}
  35605. }
  35606. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  35607. func (m *WhatsappMutation) OrganizationIDCleared() bool {
  35608. _, ok := m.clearedFields[whatsapp.FieldOrganizationID]
  35609. return ok
  35610. }
  35611. // ResetOrganizationID resets all changes to the "organization_id" field.
  35612. func (m *WhatsappMutation) ResetOrganizationID() {
  35613. m.organization_id = nil
  35614. m.addorganization_id = nil
  35615. delete(m.clearedFields, whatsapp.FieldOrganizationID)
  35616. }
  35617. // SetAPIBase sets the "api_base" field.
  35618. func (m *WhatsappMutation) SetAPIBase(s string) {
  35619. m.api_base = &s
  35620. }
  35621. // APIBase returns the value of the "api_base" field in the mutation.
  35622. func (m *WhatsappMutation) APIBase() (r string, exists bool) {
  35623. v := m.api_base
  35624. if v == nil {
  35625. return
  35626. }
  35627. return *v, true
  35628. }
  35629. // OldAPIBase returns the old "api_base" field's value of the Whatsapp entity.
  35630. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35631. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35632. func (m *WhatsappMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  35633. if !m.op.Is(OpUpdateOne) {
  35634. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  35635. }
  35636. if m.id == nil || m.oldValue == nil {
  35637. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  35638. }
  35639. oldValue, err := m.oldValue(ctx)
  35640. if err != nil {
  35641. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  35642. }
  35643. return oldValue.APIBase, nil
  35644. }
  35645. // ClearAPIBase clears the value of the "api_base" field.
  35646. func (m *WhatsappMutation) ClearAPIBase() {
  35647. m.api_base = nil
  35648. m.clearedFields[whatsapp.FieldAPIBase] = struct{}{}
  35649. }
  35650. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  35651. func (m *WhatsappMutation) APIBaseCleared() bool {
  35652. _, ok := m.clearedFields[whatsapp.FieldAPIBase]
  35653. return ok
  35654. }
  35655. // ResetAPIBase resets all changes to the "api_base" field.
  35656. func (m *WhatsappMutation) ResetAPIBase() {
  35657. m.api_base = nil
  35658. delete(m.clearedFields, whatsapp.FieldAPIBase)
  35659. }
  35660. // SetAPIKey sets the "api_key" field.
  35661. func (m *WhatsappMutation) SetAPIKey(s string) {
  35662. m.api_key = &s
  35663. }
  35664. // APIKey returns the value of the "api_key" field in the mutation.
  35665. func (m *WhatsappMutation) APIKey() (r string, exists bool) {
  35666. v := m.api_key
  35667. if v == nil {
  35668. return
  35669. }
  35670. return *v, true
  35671. }
  35672. // OldAPIKey returns the old "api_key" field's value of the Whatsapp entity.
  35673. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35674. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35675. func (m *WhatsappMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  35676. if !m.op.Is(OpUpdateOne) {
  35677. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  35678. }
  35679. if m.id == nil || m.oldValue == nil {
  35680. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  35681. }
  35682. oldValue, err := m.oldValue(ctx)
  35683. if err != nil {
  35684. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  35685. }
  35686. return oldValue.APIKey, nil
  35687. }
  35688. // ClearAPIKey clears the value of the "api_key" field.
  35689. func (m *WhatsappMutation) ClearAPIKey() {
  35690. m.api_key = nil
  35691. m.clearedFields[whatsapp.FieldAPIKey] = struct{}{}
  35692. }
  35693. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  35694. func (m *WhatsappMutation) APIKeyCleared() bool {
  35695. _, ok := m.clearedFields[whatsapp.FieldAPIKey]
  35696. return ok
  35697. }
  35698. // ResetAPIKey resets all changes to the "api_key" field.
  35699. func (m *WhatsappMutation) ResetAPIKey() {
  35700. m.api_key = nil
  35701. delete(m.clearedFields, whatsapp.FieldAPIKey)
  35702. }
  35703. // SetAllowList sets the "allow_list" field.
  35704. func (m *WhatsappMutation) SetAllowList(s []string) {
  35705. m.allow_list = &s
  35706. m.appendallow_list = nil
  35707. }
  35708. // AllowList returns the value of the "allow_list" field in the mutation.
  35709. func (m *WhatsappMutation) AllowList() (r []string, exists bool) {
  35710. v := m.allow_list
  35711. if v == nil {
  35712. return
  35713. }
  35714. return *v, true
  35715. }
  35716. // OldAllowList returns the old "allow_list" field's value of the Whatsapp entity.
  35717. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35718. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35719. func (m *WhatsappMutation) OldAllowList(ctx context.Context) (v []string, err error) {
  35720. if !m.op.Is(OpUpdateOne) {
  35721. return v, errors.New("OldAllowList is only allowed on UpdateOne operations")
  35722. }
  35723. if m.id == nil || m.oldValue == nil {
  35724. return v, errors.New("OldAllowList requires an ID field in the mutation")
  35725. }
  35726. oldValue, err := m.oldValue(ctx)
  35727. if err != nil {
  35728. return v, fmt.Errorf("querying old value for OldAllowList: %w", err)
  35729. }
  35730. return oldValue.AllowList, nil
  35731. }
  35732. // AppendAllowList adds s to the "allow_list" field.
  35733. func (m *WhatsappMutation) AppendAllowList(s []string) {
  35734. m.appendallow_list = append(m.appendallow_list, s...)
  35735. }
  35736. // AppendedAllowList returns the list of values that were appended to the "allow_list" field in this mutation.
  35737. func (m *WhatsappMutation) AppendedAllowList() ([]string, bool) {
  35738. if len(m.appendallow_list) == 0 {
  35739. return nil, false
  35740. }
  35741. return m.appendallow_list, true
  35742. }
  35743. // ClearAllowList clears the value of the "allow_list" field.
  35744. func (m *WhatsappMutation) ClearAllowList() {
  35745. m.allow_list = nil
  35746. m.appendallow_list = nil
  35747. m.clearedFields[whatsapp.FieldAllowList] = struct{}{}
  35748. }
  35749. // AllowListCleared returns if the "allow_list" field was cleared in this mutation.
  35750. func (m *WhatsappMutation) AllowListCleared() bool {
  35751. _, ok := m.clearedFields[whatsapp.FieldAllowList]
  35752. return ok
  35753. }
  35754. // ResetAllowList resets all changes to the "allow_list" field.
  35755. func (m *WhatsappMutation) ResetAllowList() {
  35756. m.allow_list = nil
  35757. m.appendallow_list = nil
  35758. delete(m.clearedFields, whatsapp.FieldAllowList)
  35759. }
  35760. // SetGroupAllowList sets the "group_allow_list" field.
  35761. func (m *WhatsappMutation) SetGroupAllowList(s []string) {
  35762. m.group_allow_list = &s
  35763. m.appendgroup_allow_list = nil
  35764. }
  35765. // GroupAllowList returns the value of the "group_allow_list" field in the mutation.
  35766. func (m *WhatsappMutation) GroupAllowList() (r []string, exists bool) {
  35767. v := m.group_allow_list
  35768. if v == nil {
  35769. return
  35770. }
  35771. return *v, true
  35772. }
  35773. // OldGroupAllowList returns the old "group_allow_list" field's value of the Whatsapp entity.
  35774. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35775. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35776. func (m *WhatsappMutation) OldGroupAllowList(ctx context.Context) (v []string, err error) {
  35777. if !m.op.Is(OpUpdateOne) {
  35778. return v, errors.New("OldGroupAllowList is only allowed on UpdateOne operations")
  35779. }
  35780. if m.id == nil || m.oldValue == nil {
  35781. return v, errors.New("OldGroupAllowList requires an ID field in the mutation")
  35782. }
  35783. oldValue, err := m.oldValue(ctx)
  35784. if err != nil {
  35785. return v, fmt.Errorf("querying old value for OldGroupAllowList: %w", err)
  35786. }
  35787. return oldValue.GroupAllowList, nil
  35788. }
  35789. // AppendGroupAllowList adds s to the "group_allow_list" field.
  35790. func (m *WhatsappMutation) AppendGroupAllowList(s []string) {
  35791. m.appendgroup_allow_list = append(m.appendgroup_allow_list, s...)
  35792. }
  35793. // AppendedGroupAllowList returns the list of values that were appended to the "group_allow_list" field in this mutation.
  35794. func (m *WhatsappMutation) AppendedGroupAllowList() ([]string, bool) {
  35795. if len(m.appendgroup_allow_list) == 0 {
  35796. return nil, false
  35797. }
  35798. return m.appendgroup_allow_list, true
  35799. }
  35800. // ClearGroupAllowList clears the value of the "group_allow_list" field.
  35801. func (m *WhatsappMutation) ClearGroupAllowList() {
  35802. m.group_allow_list = nil
  35803. m.appendgroup_allow_list = nil
  35804. m.clearedFields[whatsapp.FieldGroupAllowList] = struct{}{}
  35805. }
  35806. // GroupAllowListCleared returns if the "group_allow_list" field was cleared in this mutation.
  35807. func (m *WhatsappMutation) GroupAllowListCleared() bool {
  35808. _, ok := m.clearedFields[whatsapp.FieldGroupAllowList]
  35809. return ok
  35810. }
  35811. // ResetGroupAllowList resets all changes to the "group_allow_list" field.
  35812. func (m *WhatsappMutation) ResetGroupAllowList() {
  35813. m.group_allow_list = nil
  35814. m.appendgroup_allow_list = nil
  35815. delete(m.clearedFields, whatsapp.FieldGroupAllowList)
  35816. }
  35817. // SetBlockList sets the "block_list" field.
  35818. func (m *WhatsappMutation) SetBlockList(s []string) {
  35819. m.block_list = &s
  35820. m.appendblock_list = nil
  35821. }
  35822. // BlockList returns the value of the "block_list" field in the mutation.
  35823. func (m *WhatsappMutation) BlockList() (r []string, exists bool) {
  35824. v := m.block_list
  35825. if v == nil {
  35826. return
  35827. }
  35828. return *v, true
  35829. }
  35830. // OldBlockList returns the old "block_list" field's value of the Whatsapp entity.
  35831. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35832. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35833. func (m *WhatsappMutation) OldBlockList(ctx context.Context) (v []string, err error) {
  35834. if !m.op.Is(OpUpdateOne) {
  35835. return v, errors.New("OldBlockList is only allowed on UpdateOne operations")
  35836. }
  35837. if m.id == nil || m.oldValue == nil {
  35838. return v, errors.New("OldBlockList requires an ID field in the mutation")
  35839. }
  35840. oldValue, err := m.oldValue(ctx)
  35841. if err != nil {
  35842. return v, fmt.Errorf("querying old value for OldBlockList: %w", err)
  35843. }
  35844. return oldValue.BlockList, nil
  35845. }
  35846. // AppendBlockList adds s to the "block_list" field.
  35847. func (m *WhatsappMutation) AppendBlockList(s []string) {
  35848. m.appendblock_list = append(m.appendblock_list, s...)
  35849. }
  35850. // AppendedBlockList returns the list of values that were appended to the "block_list" field in this mutation.
  35851. func (m *WhatsappMutation) AppendedBlockList() ([]string, bool) {
  35852. if len(m.appendblock_list) == 0 {
  35853. return nil, false
  35854. }
  35855. return m.appendblock_list, true
  35856. }
  35857. // ClearBlockList clears the value of the "block_list" field.
  35858. func (m *WhatsappMutation) ClearBlockList() {
  35859. m.block_list = nil
  35860. m.appendblock_list = nil
  35861. m.clearedFields[whatsapp.FieldBlockList] = struct{}{}
  35862. }
  35863. // BlockListCleared returns if the "block_list" field was cleared in this mutation.
  35864. func (m *WhatsappMutation) BlockListCleared() bool {
  35865. _, ok := m.clearedFields[whatsapp.FieldBlockList]
  35866. return ok
  35867. }
  35868. // ResetBlockList resets all changes to the "block_list" field.
  35869. func (m *WhatsappMutation) ResetBlockList() {
  35870. m.block_list = nil
  35871. m.appendblock_list = nil
  35872. delete(m.clearedFields, whatsapp.FieldBlockList)
  35873. }
  35874. // SetGroupBlockList sets the "group_block_list" field.
  35875. func (m *WhatsappMutation) SetGroupBlockList(s []string) {
  35876. m.group_block_list = &s
  35877. m.appendgroup_block_list = nil
  35878. }
  35879. // GroupBlockList returns the value of the "group_block_list" field in the mutation.
  35880. func (m *WhatsappMutation) GroupBlockList() (r []string, exists bool) {
  35881. v := m.group_block_list
  35882. if v == nil {
  35883. return
  35884. }
  35885. return *v, true
  35886. }
  35887. // OldGroupBlockList returns the old "group_block_list" field's value of the Whatsapp entity.
  35888. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35889. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35890. func (m *WhatsappMutation) OldGroupBlockList(ctx context.Context) (v []string, err error) {
  35891. if !m.op.Is(OpUpdateOne) {
  35892. return v, errors.New("OldGroupBlockList is only allowed on UpdateOne operations")
  35893. }
  35894. if m.id == nil || m.oldValue == nil {
  35895. return v, errors.New("OldGroupBlockList requires an ID field in the mutation")
  35896. }
  35897. oldValue, err := m.oldValue(ctx)
  35898. if err != nil {
  35899. return v, fmt.Errorf("querying old value for OldGroupBlockList: %w", err)
  35900. }
  35901. return oldValue.GroupBlockList, nil
  35902. }
  35903. // AppendGroupBlockList adds s to the "group_block_list" field.
  35904. func (m *WhatsappMutation) AppendGroupBlockList(s []string) {
  35905. m.appendgroup_block_list = append(m.appendgroup_block_list, s...)
  35906. }
  35907. // AppendedGroupBlockList returns the list of values that were appended to the "group_block_list" field in this mutation.
  35908. func (m *WhatsappMutation) AppendedGroupBlockList() ([]string, bool) {
  35909. if len(m.appendgroup_block_list) == 0 {
  35910. return nil, false
  35911. }
  35912. return m.appendgroup_block_list, true
  35913. }
  35914. // ClearGroupBlockList clears the value of the "group_block_list" field.
  35915. func (m *WhatsappMutation) ClearGroupBlockList() {
  35916. m.group_block_list = nil
  35917. m.appendgroup_block_list = nil
  35918. m.clearedFields[whatsapp.FieldGroupBlockList] = struct{}{}
  35919. }
  35920. // GroupBlockListCleared returns if the "group_block_list" field was cleared in this mutation.
  35921. func (m *WhatsappMutation) GroupBlockListCleared() bool {
  35922. _, ok := m.clearedFields[whatsapp.FieldGroupBlockList]
  35923. return ok
  35924. }
  35925. // ResetGroupBlockList resets all changes to the "group_block_list" field.
  35926. func (m *WhatsappMutation) ResetGroupBlockList() {
  35927. m.group_block_list = nil
  35928. m.appendgroup_block_list = nil
  35929. delete(m.clearedFields, whatsapp.FieldGroupBlockList)
  35930. }
  35931. // ClearAgent clears the "agent" edge to the Agent entity.
  35932. func (m *WhatsappMutation) ClearAgent() {
  35933. m.clearedagent = true
  35934. m.clearedFields[whatsapp.FieldAgentID] = struct{}{}
  35935. }
  35936. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  35937. func (m *WhatsappMutation) AgentCleared() bool {
  35938. return m.clearedagent
  35939. }
  35940. // AgentIDs returns the "agent" edge IDs in the mutation.
  35941. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  35942. // AgentID instead. It exists only for internal usage by the builders.
  35943. func (m *WhatsappMutation) AgentIDs() (ids []uint64) {
  35944. if id := m.agent; id != nil {
  35945. ids = append(ids, *id)
  35946. }
  35947. return
  35948. }
  35949. // ResetAgent resets all changes to the "agent" edge.
  35950. func (m *WhatsappMutation) ResetAgent() {
  35951. m.agent = nil
  35952. m.clearedagent = false
  35953. }
  35954. // Where appends a list predicates to the WhatsappMutation builder.
  35955. func (m *WhatsappMutation) Where(ps ...predicate.Whatsapp) {
  35956. m.predicates = append(m.predicates, ps...)
  35957. }
  35958. // WhereP appends storage-level predicates to the WhatsappMutation builder. Using this method,
  35959. // users can use type-assertion to append predicates that do not depend on any generated package.
  35960. func (m *WhatsappMutation) WhereP(ps ...func(*sql.Selector)) {
  35961. p := make([]predicate.Whatsapp, len(ps))
  35962. for i := range ps {
  35963. p[i] = ps[i]
  35964. }
  35965. m.Where(p...)
  35966. }
  35967. // Op returns the operation name.
  35968. func (m *WhatsappMutation) Op() Op {
  35969. return m.op
  35970. }
  35971. // SetOp allows setting the mutation operation.
  35972. func (m *WhatsappMutation) SetOp(op Op) {
  35973. m.op = op
  35974. }
  35975. // Type returns the node type of this mutation (Whatsapp).
  35976. func (m *WhatsappMutation) Type() string {
  35977. return m.typ
  35978. }
  35979. // Fields returns all fields that were changed during this mutation. Note that in
  35980. // order to get all numeric fields that were incremented/decremented, call
  35981. // AddedFields().
  35982. func (m *WhatsappMutation) Fields() []string {
  35983. fields := make([]string, 0, 21)
  35984. if m.created_at != nil {
  35985. fields = append(fields, whatsapp.FieldCreatedAt)
  35986. }
  35987. if m.updated_at != nil {
  35988. fields = append(fields, whatsapp.FieldUpdatedAt)
  35989. }
  35990. if m.status != nil {
  35991. fields = append(fields, whatsapp.FieldStatus)
  35992. }
  35993. if m.deleted_at != nil {
  35994. fields = append(fields, whatsapp.FieldDeletedAt)
  35995. }
  35996. if m.wa_id != nil {
  35997. fields = append(fields, whatsapp.FieldWaID)
  35998. }
  35999. if m.wa_name != nil {
  36000. fields = append(fields, whatsapp.FieldWaName)
  36001. }
  36002. if m.callback != nil {
  36003. fields = append(fields, whatsapp.FieldCallback)
  36004. }
  36005. if m.agent != nil {
  36006. fields = append(fields, whatsapp.FieldAgentID)
  36007. }
  36008. if m.account != nil {
  36009. fields = append(fields, whatsapp.FieldAccount)
  36010. }
  36011. if m.cc != nil {
  36012. fields = append(fields, whatsapp.FieldCc)
  36013. }
  36014. if m.phone != nil {
  36015. fields = append(fields, whatsapp.FieldPhone)
  36016. }
  36017. if m.cc_phone != nil {
  36018. fields = append(fields, whatsapp.FieldCcPhone)
  36019. }
  36020. if m.phone_name != nil {
  36021. fields = append(fields, whatsapp.FieldPhoneName)
  36022. }
  36023. if m.phone_status != nil {
  36024. fields = append(fields, whatsapp.FieldPhoneStatus)
  36025. }
  36026. if m.organization_id != nil {
  36027. fields = append(fields, whatsapp.FieldOrganizationID)
  36028. }
  36029. if m.api_base != nil {
  36030. fields = append(fields, whatsapp.FieldAPIBase)
  36031. }
  36032. if m.api_key != nil {
  36033. fields = append(fields, whatsapp.FieldAPIKey)
  36034. }
  36035. if m.allow_list != nil {
  36036. fields = append(fields, whatsapp.FieldAllowList)
  36037. }
  36038. if m.group_allow_list != nil {
  36039. fields = append(fields, whatsapp.FieldGroupAllowList)
  36040. }
  36041. if m.block_list != nil {
  36042. fields = append(fields, whatsapp.FieldBlockList)
  36043. }
  36044. if m.group_block_list != nil {
  36045. fields = append(fields, whatsapp.FieldGroupBlockList)
  36046. }
  36047. return fields
  36048. }
  36049. // Field returns the value of a field with the given name. The second boolean
  36050. // return value indicates that this field was not set, or was not defined in the
  36051. // schema.
  36052. func (m *WhatsappMutation) Field(name string) (ent.Value, bool) {
  36053. switch name {
  36054. case whatsapp.FieldCreatedAt:
  36055. return m.CreatedAt()
  36056. case whatsapp.FieldUpdatedAt:
  36057. return m.UpdatedAt()
  36058. case whatsapp.FieldStatus:
  36059. return m.Status()
  36060. case whatsapp.FieldDeletedAt:
  36061. return m.DeletedAt()
  36062. case whatsapp.FieldWaID:
  36063. return m.WaID()
  36064. case whatsapp.FieldWaName:
  36065. return m.WaName()
  36066. case whatsapp.FieldCallback:
  36067. return m.Callback()
  36068. case whatsapp.FieldAgentID:
  36069. return m.AgentID()
  36070. case whatsapp.FieldAccount:
  36071. return m.Account()
  36072. case whatsapp.FieldCc:
  36073. return m.Cc()
  36074. case whatsapp.FieldPhone:
  36075. return m.Phone()
  36076. case whatsapp.FieldCcPhone:
  36077. return m.CcPhone()
  36078. case whatsapp.FieldPhoneName:
  36079. return m.PhoneName()
  36080. case whatsapp.FieldPhoneStatus:
  36081. return m.PhoneStatus()
  36082. case whatsapp.FieldOrganizationID:
  36083. return m.OrganizationID()
  36084. case whatsapp.FieldAPIBase:
  36085. return m.APIBase()
  36086. case whatsapp.FieldAPIKey:
  36087. return m.APIKey()
  36088. case whatsapp.FieldAllowList:
  36089. return m.AllowList()
  36090. case whatsapp.FieldGroupAllowList:
  36091. return m.GroupAllowList()
  36092. case whatsapp.FieldBlockList:
  36093. return m.BlockList()
  36094. case whatsapp.FieldGroupBlockList:
  36095. return m.GroupBlockList()
  36096. }
  36097. return nil, false
  36098. }
  36099. // OldField returns the old value of the field from the database. An error is
  36100. // returned if the mutation operation is not UpdateOne, or the query to the
  36101. // database failed.
  36102. func (m *WhatsappMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  36103. switch name {
  36104. case whatsapp.FieldCreatedAt:
  36105. return m.OldCreatedAt(ctx)
  36106. case whatsapp.FieldUpdatedAt:
  36107. return m.OldUpdatedAt(ctx)
  36108. case whatsapp.FieldStatus:
  36109. return m.OldStatus(ctx)
  36110. case whatsapp.FieldDeletedAt:
  36111. return m.OldDeletedAt(ctx)
  36112. case whatsapp.FieldWaID:
  36113. return m.OldWaID(ctx)
  36114. case whatsapp.FieldWaName:
  36115. return m.OldWaName(ctx)
  36116. case whatsapp.FieldCallback:
  36117. return m.OldCallback(ctx)
  36118. case whatsapp.FieldAgentID:
  36119. return m.OldAgentID(ctx)
  36120. case whatsapp.FieldAccount:
  36121. return m.OldAccount(ctx)
  36122. case whatsapp.FieldCc:
  36123. return m.OldCc(ctx)
  36124. case whatsapp.FieldPhone:
  36125. return m.OldPhone(ctx)
  36126. case whatsapp.FieldCcPhone:
  36127. return m.OldCcPhone(ctx)
  36128. case whatsapp.FieldPhoneName:
  36129. return m.OldPhoneName(ctx)
  36130. case whatsapp.FieldPhoneStatus:
  36131. return m.OldPhoneStatus(ctx)
  36132. case whatsapp.FieldOrganizationID:
  36133. return m.OldOrganizationID(ctx)
  36134. case whatsapp.FieldAPIBase:
  36135. return m.OldAPIBase(ctx)
  36136. case whatsapp.FieldAPIKey:
  36137. return m.OldAPIKey(ctx)
  36138. case whatsapp.FieldAllowList:
  36139. return m.OldAllowList(ctx)
  36140. case whatsapp.FieldGroupAllowList:
  36141. return m.OldGroupAllowList(ctx)
  36142. case whatsapp.FieldBlockList:
  36143. return m.OldBlockList(ctx)
  36144. case whatsapp.FieldGroupBlockList:
  36145. return m.OldGroupBlockList(ctx)
  36146. }
  36147. return nil, fmt.Errorf("unknown Whatsapp field %s", name)
  36148. }
  36149. // SetField sets the value of a field with the given name. It returns an error if
  36150. // the field is not defined in the schema, or if the type mismatched the field
  36151. // type.
  36152. func (m *WhatsappMutation) SetField(name string, value ent.Value) error {
  36153. switch name {
  36154. case whatsapp.FieldCreatedAt:
  36155. v, ok := value.(time.Time)
  36156. if !ok {
  36157. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36158. }
  36159. m.SetCreatedAt(v)
  36160. return nil
  36161. case whatsapp.FieldUpdatedAt:
  36162. v, ok := value.(time.Time)
  36163. if !ok {
  36164. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36165. }
  36166. m.SetUpdatedAt(v)
  36167. return nil
  36168. case whatsapp.FieldStatus:
  36169. v, ok := value.(uint8)
  36170. if !ok {
  36171. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36172. }
  36173. m.SetStatus(v)
  36174. return nil
  36175. case whatsapp.FieldDeletedAt:
  36176. v, ok := value.(time.Time)
  36177. if !ok {
  36178. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36179. }
  36180. m.SetDeletedAt(v)
  36181. return nil
  36182. case whatsapp.FieldWaID:
  36183. v, ok := value.(string)
  36184. if !ok {
  36185. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36186. }
  36187. m.SetWaID(v)
  36188. return nil
  36189. case whatsapp.FieldWaName:
  36190. v, ok := value.(string)
  36191. if !ok {
  36192. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36193. }
  36194. m.SetWaName(v)
  36195. return nil
  36196. case whatsapp.FieldCallback:
  36197. v, ok := value.(string)
  36198. if !ok {
  36199. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36200. }
  36201. m.SetCallback(v)
  36202. return nil
  36203. case whatsapp.FieldAgentID:
  36204. v, ok := value.(uint64)
  36205. if !ok {
  36206. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36207. }
  36208. m.SetAgentID(v)
  36209. return nil
  36210. case whatsapp.FieldAccount:
  36211. v, ok := value.(string)
  36212. if !ok {
  36213. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36214. }
  36215. m.SetAccount(v)
  36216. return nil
  36217. case whatsapp.FieldCc:
  36218. v, ok := value.(string)
  36219. if !ok {
  36220. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36221. }
  36222. m.SetCc(v)
  36223. return nil
  36224. case whatsapp.FieldPhone:
  36225. v, ok := value.(string)
  36226. if !ok {
  36227. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36228. }
  36229. m.SetPhone(v)
  36230. return nil
  36231. case whatsapp.FieldCcPhone:
  36232. v, ok := value.(string)
  36233. if !ok {
  36234. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36235. }
  36236. m.SetCcPhone(v)
  36237. return nil
  36238. case whatsapp.FieldPhoneName:
  36239. v, ok := value.(string)
  36240. if !ok {
  36241. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36242. }
  36243. m.SetPhoneName(v)
  36244. return nil
  36245. case whatsapp.FieldPhoneStatus:
  36246. v, ok := value.(int8)
  36247. if !ok {
  36248. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36249. }
  36250. m.SetPhoneStatus(v)
  36251. return nil
  36252. case whatsapp.FieldOrganizationID:
  36253. v, ok := value.(uint64)
  36254. if !ok {
  36255. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36256. }
  36257. m.SetOrganizationID(v)
  36258. return nil
  36259. case whatsapp.FieldAPIBase:
  36260. v, ok := value.(string)
  36261. if !ok {
  36262. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36263. }
  36264. m.SetAPIBase(v)
  36265. return nil
  36266. case whatsapp.FieldAPIKey:
  36267. v, ok := value.(string)
  36268. if !ok {
  36269. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36270. }
  36271. m.SetAPIKey(v)
  36272. return nil
  36273. case whatsapp.FieldAllowList:
  36274. v, ok := value.([]string)
  36275. if !ok {
  36276. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36277. }
  36278. m.SetAllowList(v)
  36279. return nil
  36280. case whatsapp.FieldGroupAllowList:
  36281. v, ok := value.([]string)
  36282. if !ok {
  36283. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36284. }
  36285. m.SetGroupAllowList(v)
  36286. return nil
  36287. case whatsapp.FieldBlockList:
  36288. v, ok := value.([]string)
  36289. if !ok {
  36290. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36291. }
  36292. m.SetBlockList(v)
  36293. return nil
  36294. case whatsapp.FieldGroupBlockList:
  36295. v, ok := value.([]string)
  36296. if !ok {
  36297. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36298. }
  36299. m.SetGroupBlockList(v)
  36300. return nil
  36301. }
  36302. return fmt.Errorf("unknown Whatsapp field %s", name)
  36303. }
  36304. // AddedFields returns all numeric fields that were incremented/decremented during
  36305. // this mutation.
  36306. func (m *WhatsappMutation) AddedFields() []string {
  36307. var fields []string
  36308. if m.addstatus != nil {
  36309. fields = append(fields, whatsapp.FieldStatus)
  36310. }
  36311. if m.addphone_status != nil {
  36312. fields = append(fields, whatsapp.FieldPhoneStatus)
  36313. }
  36314. if m.addorganization_id != nil {
  36315. fields = append(fields, whatsapp.FieldOrganizationID)
  36316. }
  36317. return fields
  36318. }
  36319. // AddedField returns the numeric value that was incremented/decremented on a field
  36320. // with the given name. The second boolean return value indicates that this field
  36321. // was not set, or was not defined in the schema.
  36322. func (m *WhatsappMutation) AddedField(name string) (ent.Value, bool) {
  36323. switch name {
  36324. case whatsapp.FieldStatus:
  36325. return m.AddedStatus()
  36326. case whatsapp.FieldPhoneStatus:
  36327. return m.AddedPhoneStatus()
  36328. case whatsapp.FieldOrganizationID:
  36329. return m.AddedOrganizationID()
  36330. }
  36331. return nil, false
  36332. }
  36333. // AddField adds the value to the field with the given name. It returns an error if
  36334. // the field is not defined in the schema, or if the type mismatched the field
  36335. // type.
  36336. func (m *WhatsappMutation) AddField(name string, value ent.Value) error {
  36337. switch name {
  36338. case whatsapp.FieldStatus:
  36339. v, ok := value.(int8)
  36340. if !ok {
  36341. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36342. }
  36343. m.AddStatus(v)
  36344. return nil
  36345. case whatsapp.FieldPhoneStatus:
  36346. v, ok := value.(int8)
  36347. if !ok {
  36348. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36349. }
  36350. m.AddPhoneStatus(v)
  36351. return nil
  36352. case whatsapp.FieldOrganizationID:
  36353. v, ok := value.(int64)
  36354. if !ok {
  36355. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36356. }
  36357. m.AddOrganizationID(v)
  36358. return nil
  36359. }
  36360. return fmt.Errorf("unknown Whatsapp numeric field %s", name)
  36361. }
  36362. // ClearedFields returns all nullable fields that were cleared during this
  36363. // mutation.
  36364. func (m *WhatsappMutation) ClearedFields() []string {
  36365. var fields []string
  36366. if m.FieldCleared(whatsapp.FieldStatus) {
  36367. fields = append(fields, whatsapp.FieldStatus)
  36368. }
  36369. if m.FieldCleared(whatsapp.FieldDeletedAt) {
  36370. fields = append(fields, whatsapp.FieldDeletedAt)
  36371. }
  36372. if m.FieldCleared(whatsapp.FieldWaID) {
  36373. fields = append(fields, whatsapp.FieldWaID)
  36374. }
  36375. if m.FieldCleared(whatsapp.FieldWaName) {
  36376. fields = append(fields, whatsapp.FieldWaName)
  36377. }
  36378. if m.FieldCleared(whatsapp.FieldCallback) {
  36379. fields = append(fields, whatsapp.FieldCallback)
  36380. }
  36381. if m.FieldCleared(whatsapp.FieldAccount) {
  36382. fields = append(fields, whatsapp.FieldAccount)
  36383. }
  36384. if m.FieldCleared(whatsapp.FieldOrganizationID) {
  36385. fields = append(fields, whatsapp.FieldOrganizationID)
  36386. }
  36387. if m.FieldCleared(whatsapp.FieldAPIBase) {
  36388. fields = append(fields, whatsapp.FieldAPIBase)
  36389. }
  36390. if m.FieldCleared(whatsapp.FieldAPIKey) {
  36391. fields = append(fields, whatsapp.FieldAPIKey)
  36392. }
  36393. if m.FieldCleared(whatsapp.FieldAllowList) {
  36394. fields = append(fields, whatsapp.FieldAllowList)
  36395. }
  36396. if m.FieldCleared(whatsapp.FieldGroupAllowList) {
  36397. fields = append(fields, whatsapp.FieldGroupAllowList)
  36398. }
  36399. if m.FieldCleared(whatsapp.FieldBlockList) {
  36400. fields = append(fields, whatsapp.FieldBlockList)
  36401. }
  36402. if m.FieldCleared(whatsapp.FieldGroupBlockList) {
  36403. fields = append(fields, whatsapp.FieldGroupBlockList)
  36404. }
  36405. return fields
  36406. }
  36407. // FieldCleared returns a boolean indicating if a field with the given name was
  36408. // cleared in this mutation.
  36409. func (m *WhatsappMutation) FieldCleared(name string) bool {
  36410. _, ok := m.clearedFields[name]
  36411. return ok
  36412. }
  36413. // ClearField clears the value of the field with the given name. It returns an
  36414. // error if the field is not defined in the schema.
  36415. func (m *WhatsappMutation) ClearField(name string) error {
  36416. switch name {
  36417. case whatsapp.FieldStatus:
  36418. m.ClearStatus()
  36419. return nil
  36420. case whatsapp.FieldDeletedAt:
  36421. m.ClearDeletedAt()
  36422. return nil
  36423. case whatsapp.FieldWaID:
  36424. m.ClearWaID()
  36425. return nil
  36426. case whatsapp.FieldWaName:
  36427. m.ClearWaName()
  36428. return nil
  36429. case whatsapp.FieldCallback:
  36430. m.ClearCallback()
  36431. return nil
  36432. case whatsapp.FieldAccount:
  36433. m.ClearAccount()
  36434. return nil
  36435. case whatsapp.FieldOrganizationID:
  36436. m.ClearOrganizationID()
  36437. return nil
  36438. case whatsapp.FieldAPIBase:
  36439. m.ClearAPIBase()
  36440. return nil
  36441. case whatsapp.FieldAPIKey:
  36442. m.ClearAPIKey()
  36443. return nil
  36444. case whatsapp.FieldAllowList:
  36445. m.ClearAllowList()
  36446. return nil
  36447. case whatsapp.FieldGroupAllowList:
  36448. m.ClearGroupAllowList()
  36449. return nil
  36450. case whatsapp.FieldBlockList:
  36451. m.ClearBlockList()
  36452. return nil
  36453. case whatsapp.FieldGroupBlockList:
  36454. m.ClearGroupBlockList()
  36455. return nil
  36456. }
  36457. return fmt.Errorf("unknown Whatsapp nullable field %s", name)
  36458. }
  36459. // ResetField resets all changes in the mutation for the field with the given name.
  36460. // It returns an error if the field is not defined in the schema.
  36461. func (m *WhatsappMutation) ResetField(name string) error {
  36462. switch name {
  36463. case whatsapp.FieldCreatedAt:
  36464. m.ResetCreatedAt()
  36465. return nil
  36466. case whatsapp.FieldUpdatedAt:
  36467. m.ResetUpdatedAt()
  36468. return nil
  36469. case whatsapp.FieldStatus:
  36470. m.ResetStatus()
  36471. return nil
  36472. case whatsapp.FieldDeletedAt:
  36473. m.ResetDeletedAt()
  36474. return nil
  36475. case whatsapp.FieldWaID:
  36476. m.ResetWaID()
  36477. return nil
  36478. case whatsapp.FieldWaName:
  36479. m.ResetWaName()
  36480. return nil
  36481. case whatsapp.FieldCallback:
  36482. m.ResetCallback()
  36483. return nil
  36484. case whatsapp.FieldAgentID:
  36485. m.ResetAgentID()
  36486. return nil
  36487. case whatsapp.FieldAccount:
  36488. m.ResetAccount()
  36489. return nil
  36490. case whatsapp.FieldCc:
  36491. m.ResetCc()
  36492. return nil
  36493. case whatsapp.FieldPhone:
  36494. m.ResetPhone()
  36495. return nil
  36496. case whatsapp.FieldCcPhone:
  36497. m.ResetCcPhone()
  36498. return nil
  36499. case whatsapp.FieldPhoneName:
  36500. m.ResetPhoneName()
  36501. return nil
  36502. case whatsapp.FieldPhoneStatus:
  36503. m.ResetPhoneStatus()
  36504. return nil
  36505. case whatsapp.FieldOrganizationID:
  36506. m.ResetOrganizationID()
  36507. return nil
  36508. case whatsapp.FieldAPIBase:
  36509. m.ResetAPIBase()
  36510. return nil
  36511. case whatsapp.FieldAPIKey:
  36512. m.ResetAPIKey()
  36513. return nil
  36514. case whatsapp.FieldAllowList:
  36515. m.ResetAllowList()
  36516. return nil
  36517. case whatsapp.FieldGroupAllowList:
  36518. m.ResetGroupAllowList()
  36519. return nil
  36520. case whatsapp.FieldBlockList:
  36521. m.ResetBlockList()
  36522. return nil
  36523. case whatsapp.FieldGroupBlockList:
  36524. m.ResetGroupBlockList()
  36525. return nil
  36526. }
  36527. return fmt.Errorf("unknown Whatsapp field %s", name)
  36528. }
  36529. // AddedEdges returns all edge names that were set/added in this mutation.
  36530. func (m *WhatsappMutation) AddedEdges() []string {
  36531. edges := make([]string, 0, 1)
  36532. if m.agent != nil {
  36533. edges = append(edges, whatsapp.EdgeAgent)
  36534. }
  36535. return edges
  36536. }
  36537. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  36538. // name in this mutation.
  36539. func (m *WhatsappMutation) AddedIDs(name string) []ent.Value {
  36540. switch name {
  36541. case whatsapp.EdgeAgent:
  36542. if id := m.agent; id != nil {
  36543. return []ent.Value{*id}
  36544. }
  36545. }
  36546. return nil
  36547. }
  36548. // RemovedEdges returns all edge names that were removed in this mutation.
  36549. func (m *WhatsappMutation) RemovedEdges() []string {
  36550. edges := make([]string, 0, 1)
  36551. return edges
  36552. }
  36553. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  36554. // the given name in this mutation.
  36555. func (m *WhatsappMutation) RemovedIDs(name string) []ent.Value {
  36556. return nil
  36557. }
  36558. // ClearedEdges returns all edge names that were cleared in this mutation.
  36559. func (m *WhatsappMutation) ClearedEdges() []string {
  36560. edges := make([]string, 0, 1)
  36561. if m.clearedagent {
  36562. edges = append(edges, whatsapp.EdgeAgent)
  36563. }
  36564. return edges
  36565. }
  36566. // EdgeCleared returns a boolean which indicates if the edge with the given name
  36567. // was cleared in this mutation.
  36568. func (m *WhatsappMutation) EdgeCleared(name string) bool {
  36569. switch name {
  36570. case whatsapp.EdgeAgent:
  36571. return m.clearedagent
  36572. }
  36573. return false
  36574. }
  36575. // ClearEdge clears the value of the edge with the given name. It returns an error
  36576. // if that edge is not defined in the schema.
  36577. func (m *WhatsappMutation) ClearEdge(name string) error {
  36578. switch name {
  36579. case whatsapp.EdgeAgent:
  36580. m.ClearAgent()
  36581. return nil
  36582. }
  36583. return fmt.Errorf("unknown Whatsapp unique edge %s", name)
  36584. }
  36585. // ResetEdge resets all changes to the edge with the given name in this mutation.
  36586. // It returns an error if the edge is not defined in the schema.
  36587. func (m *WhatsappMutation) ResetEdge(name string) error {
  36588. switch name {
  36589. case whatsapp.EdgeAgent:
  36590. m.ResetAgent()
  36591. return nil
  36592. }
  36593. return fmt.Errorf("unknown Whatsapp edge %s", name)
  36594. }
  36595. // WhatsappChannelMutation represents an operation that mutates the WhatsappChannel nodes in the graph.
  36596. type WhatsappChannelMutation struct {
  36597. config
  36598. op Op
  36599. typ string
  36600. id *uint64
  36601. created_at *time.Time
  36602. updated_at *time.Time
  36603. status *uint8
  36604. addstatus *int8
  36605. deleted_at *time.Time
  36606. ak *string
  36607. sk *string
  36608. wa_id *string
  36609. wa_name *string
  36610. waba_id *uint64
  36611. addwaba_id *int64
  36612. business_id *uint64
  36613. addbusiness_id *int64
  36614. organization_id *uint64
  36615. addorganization_id *int64
  36616. verify_account *string
  36617. clearedFields map[string]struct{}
  36618. done bool
  36619. oldValue func(context.Context) (*WhatsappChannel, error)
  36620. predicates []predicate.WhatsappChannel
  36621. }
  36622. var _ ent.Mutation = (*WhatsappChannelMutation)(nil)
  36623. // whatsappchannelOption allows management of the mutation configuration using functional options.
  36624. type whatsappchannelOption func(*WhatsappChannelMutation)
  36625. // newWhatsappChannelMutation creates new mutation for the WhatsappChannel entity.
  36626. func newWhatsappChannelMutation(c config, op Op, opts ...whatsappchannelOption) *WhatsappChannelMutation {
  36627. m := &WhatsappChannelMutation{
  36628. config: c,
  36629. op: op,
  36630. typ: TypeWhatsappChannel,
  36631. clearedFields: make(map[string]struct{}),
  36632. }
  36633. for _, opt := range opts {
  36634. opt(m)
  36635. }
  36636. return m
  36637. }
  36638. // withWhatsappChannelID sets the ID field of the mutation.
  36639. func withWhatsappChannelID(id uint64) whatsappchannelOption {
  36640. return func(m *WhatsappChannelMutation) {
  36641. var (
  36642. err error
  36643. once sync.Once
  36644. value *WhatsappChannel
  36645. )
  36646. m.oldValue = func(ctx context.Context) (*WhatsappChannel, error) {
  36647. once.Do(func() {
  36648. if m.done {
  36649. err = errors.New("querying old values post mutation is not allowed")
  36650. } else {
  36651. value, err = m.Client().WhatsappChannel.Get(ctx, id)
  36652. }
  36653. })
  36654. return value, err
  36655. }
  36656. m.id = &id
  36657. }
  36658. }
  36659. // withWhatsappChannel sets the old WhatsappChannel of the mutation.
  36660. func withWhatsappChannel(node *WhatsappChannel) whatsappchannelOption {
  36661. return func(m *WhatsappChannelMutation) {
  36662. m.oldValue = func(context.Context) (*WhatsappChannel, error) {
  36663. return node, nil
  36664. }
  36665. m.id = &node.ID
  36666. }
  36667. }
  36668. // Client returns a new `ent.Client` from the mutation. If the mutation was
  36669. // executed in a transaction (ent.Tx), a transactional client is returned.
  36670. func (m WhatsappChannelMutation) Client() *Client {
  36671. client := &Client{config: m.config}
  36672. client.init()
  36673. return client
  36674. }
  36675. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  36676. // it returns an error otherwise.
  36677. func (m WhatsappChannelMutation) Tx() (*Tx, error) {
  36678. if _, ok := m.driver.(*txDriver); !ok {
  36679. return nil, errors.New("ent: mutation is not running in a transaction")
  36680. }
  36681. tx := &Tx{config: m.config}
  36682. tx.init()
  36683. return tx, nil
  36684. }
  36685. // SetID sets the value of the id field. Note that this
  36686. // operation is only accepted on creation of WhatsappChannel entities.
  36687. func (m *WhatsappChannelMutation) SetID(id uint64) {
  36688. m.id = &id
  36689. }
  36690. // ID returns the ID value in the mutation. Note that the ID is only available
  36691. // if it was provided to the builder or after it was returned from the database.
  36692. func (m *WhatsappChannelMutation) ID() (id uint64, exists bool) {
  36693. if m.id == nil {
  36694. return
  36695. }
  36696. return *m.id, true
  36697. }
  36698. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  36699. // That means, if the mutation is applied within a transaction with an isolation level such
  36700. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  36701. // or updated by the mutation.
  36702. func (m *WhatsappChannelMutation) IDs(ctx context.Context) ([]uint64, error) {
  36703. switch {
  36704. case m.op.Is(OpUpdateOne | OpDeleteOne):
  36705. id, exists := m.ID()
  36706. if exists {
  36707. return []uint64{id}, nil
  36708. }
  36709. fallthrough
  36710. case m.op.Is(OpUpdate | OpDelete):
  36711. return m.Client().WhatsappChannel.Query().Where(m.predicates...).IDs(ctx)
  36712. default:
  36713. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  36714. }
  36715. }
  36716. // SetCreatedAt sets the "created_at" field.
  36717. func (m *WhatsappChannelMutation) SetCreatedAt(t time.Time) {
  36718. m.created_at = &t
  36719. }
  36720. // CreatedAt returns the value of the "created_at" field in the mutation.
  36721. func (m *WhatsappChannelMutation) CreatedAt() (r time.Time, exists bool) {
  36722. v := m.created_at
  36723. if v == nil {
  36724. return
  36725. }
  36726. return *v, true
  36727. }
  36728. // OldCreatedAt returns the old "created_at" field's value of the WhatsappChannel entity.
  36729. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  36730. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36731. func (m *WhatsappChannelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  36732. if !m.op.Is(OpUpdateOne) {
  36733. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  36734. }
  36735. if m.id == nil || m.oldValue == nil {
  36736. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  36737. }
  36738. oldValue, err := m.oldValue(ctx)
  36739. if err != nil {
  36740. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  36741. }
  36742. return oldValue.CreatedAt, nil
  36743. }
  36744. // ResetCreatedAt resets all changes to the "created_at" field.
  36745. func (m *WhatsappChannelMutation) ResetCreatedAt() {
  36746. m.created_at = nil
  36747. }
  36748. // SetUpdatedAt sets the "updated_at" field.
  36749. func (m *WhatsappChannelMutation) SetUpdatedAt(t time.Time) {
  36750. m.updated_at = &t
  36751. }
  36752. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  36753. func (m *WhatsappChannelMutation) UpdatedAt() (r time.Time, exists bool) {
  36754. v := m.updated_at
  36755. if v == nil {
  36756. return
  36757. }
  36758. return *v, true
  36759. }
  36760. // OldUpdatedAt returns the old "updated_at" field's value of the WhatsappChannel entity.
  36761. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  36762. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36763. func (m *WhatsappChannelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  36764. if !m.op.Is(OpUpdateOne) {
  36765. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  36766. }
  36767. if m.id == nil || m.oldValue == nil {
  36768. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  36769. }
  36770. oldValue, err := m.oldValue(ctx)
  36771. if err != nil {
  36772. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  36773. }
  36774. return oldValue.UpdatedAt, nil
  36775. }
  36776. // ResetUpdatedAt resets all changes to the "updated_at" field.
  36777. func (m *WhatsappChannelMutation) ResetUpdatedAt() {
  36778. m.updated_at = nil
  36779. }
  36780. // SetStatus sets the "status" field.
  36781. func (m *WhatsappChannelMutation) SetStatus(u uint8) {
  36782. m.status = &u
  36783. m.addstatus = nil
  36784. }
  36785. // Status returns the value of the "status" field in the mutation.
  36786. func (m *WhatsappChannelMutation) Status() (r uint8, exists bool) {
  36787. v := m.status
  36788. if v == nil {
  36789. return
  36790. }
  36791. return *v, true
  36792. }
  36793. // OldStatus returns the old "status" field's value of the WhatsappChannel entity.
  36794. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  36795. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36796. func (m *WhatsappChannelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  36797. if !m.op.Is(OpUpdateOne) {
  36798. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  36799. }
  36800. if m.id == nil || m.oldValue == nil {
  36801. return v, errors.New("OldStatus requires an ID field in the mutation")
  36802. }
  36803. oldValue, err := m.oldValue(ctx)
  36804. if err != nil {
  36805. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  36806. }
  36807. return oldValue.Status, nil
  36808. }
  36809. // AddStatus adds u to the "status" field.
  36810. func (m *WhatsappChannelMutation) AddStatus(u int8) {
  36811. if m.addstatus != nil {
  36812. *m.addstatus += u
  36813. } else {
  36814. m.addstatus = &u
  36815. }
  36816. }
  36817. // AddedStatus returns the value that was added to the "status" field in this mutation.
  36818. func (m *WhatsappChannelMutation) AddedStatus() (r int8, exists bool) {
  36819. v := m.addstatus
  36820. if v == nil {
  36821. return
  36822. }
  36823. return *v, true
  36824. }
  36825. // ClearStatus clears the value of the "status" field.
  36826. func (m *WhatsappChannelMutation) ClearStatus() {
  36827. m.status = nil
  36828. m.addstatus = nil
  36829. m.clearedFields[whatsappchannel.FieldStatus] = struct{}{}
  36830. }
  36831. // StatusCleared returns if the "status" field was cleared in this mutation.
  36832. func (m *WhatsappChannelMutation) StatusCleared() bool {
  36833. _, ok := m.clearedFields[whatsappchannel.FieldStatus]
  36834. return ok
  36835. }
  36836. // ResetStatus resets all changes to the "status" field.
  36837. func (m *WhatsappChannelMutation) ResetStatus() {
  36838. m.status = nil
  36839. m.addstatus = nil
  36840. delete(m.clearedFields, whatsappchannel.FieldStatus)
  36841. }
  36842. // SetDeletedAt sets the "deleted_at" field.
  36843. func (m *WhatsappChannelMutation) SetDeletedAt(t time.Time) {
  36844. m.deleted_at = &t
  36845. }
  36846. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  36847. func (m *WhatsappChannelMutation) DeletedAt() (r time.Time, exists bool) {
  36848. v := m.deleted_at
  36849. if v == nil {
  36850. return
  36851. }
  36852. return *v, true
  36853. }
  36854. // OldDeletedAt returns the old "deleted_at" field's value of the WhatsappChannel entity.
  36855. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  36856. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36857. func (m *WhatsappChannelMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  36858. if !m.op.Is(OpUpdateOne) {
  36859. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  36860. }
  36861. if m.id == nil || m.oldValue == nil {
  36862. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  36863. }
  36864. oldValue, err := m.oldValue(ctx)
  36865. if err != nil {
  36866. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  36867. }
  36868. return oldValue.DeletedAt, nil
  36869. }
  36870. // ClearDeletedAt clears the value of the "deleted_at" field.
  36871. func (m *WhatsappChannelMutation) ClearDeletedAt() {
  36872. m.deleted_at = nil
  36873. m.clearedFields[whatsappchannel.FieldDeletedAt] = struct{}{}
  36874. }
  36875. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  36876. func (m *WhatsappChannelMutation) DeletedAtCleared() bool {
  36877. _, ok := m.clearedFields[whatsappchannel.FieldDeletedAt]
  36878. return ok
  36879. }
  36880. // ResetDeletedAt resets all changes to the "deleted_at" field.
  36881. func (m *WhatsappChannelMutation) ResetDeletedAt() {
  36882. m.deleted_at = nil
  36883. delete(m.clearedFields, whatsappchannel.FieldDeletedAt)
  36884. }
  36885. // SetAk sets the "ak" field.
  36886. func (m *WhatsappChannelMutation) SetAk(s string) {
  36887. m.ak = &s
  36888. }
  36889. // Ak returns the value of the "ak" field in the mutation.
  36890. func (m *WhatsappChannelMutation) Ak() (r string, exists bool) {
  36891. v := m.ak
  36892. if v == nil {
  36893. return
  36894. }
  36895. return *v, true
  36896. }
  36897. // OldAk returns the old "ak" field's value of the WhatsappChannel entity.
  36898. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  36899. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36900. func (m *WhatsappChannelMutation) OldAk(ctx context.Context) (v string, err error) {
  36901. if !m.op.Is(OpUpdateOne) {
  36902. return v, errors.New("OldAk is only allowed on UpdateOne operations")
  36903. }
  36904. if m.id == nil || m.oldValue == nil {
  36905. return v, errors.New("OldAk requires an ID field in the mutation")
  36906. }
  36907. oldValue, err := m.oldValue(ctx)
  36908. if err != nil {
  36909. return v, fmt.Errorf("querying old value for OldAk: %w", err)
  36910. }
  36911. return oldValue.Ak, nil
  36912. }
  36913. // ClearAk clears the value of the "ak" field.
  36914. func (m *WhatsappChannelMutation) ClearAk() {
  36915. m.ak = nil
  36916. m.clearedFields[whatsappchannel.FieldAk] = struct{}{}
  36917. }
  36918. // AkCleared returns if the "ak" field was cleared in this mutation.
  36919. func (m *WhatsappChannelMutation) AkCleared() bool {
  36920. _, ok := m.clearedFields[whatsappchannel.FieldAk]
  36921. return ok
  36922. }
  36923. // ResetAk resets all changes to the "ak" field.
  36924. func (m *WhatsappChannelMutation) ResetAk() {
  36925. m.ak = nil
  36926. delete(m.clearedFields, whatsappchannel.FieldAk)
  36927. }
  36928. // SetSk sets the "sk" field.
  36929. func (m *WhatsappChannelMutation) SetSk(s string) {
  36930. m.sk = &s
  36931. }
  36932. // Sk returns the value of the "sk" field in the mutation.
  36933. func (m *WhatsappChannelMutation) Sk() (r string, exists bool) {
  36934. v := m.sk
  36935. if v == nil {
  36936. return
  36937. }
  36938. return *v, true
  36939. }
  36940. // OldSk returns the old "sk" field's value of the WhatsappChannel entity.
  36941. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  36942. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36943. func (m *WhatsappChannelMutation) OldSk(ctx context.Context) (v string, err error) {
  36944. if !m.op.Is(OpUpdateOne) {
  36945. return v, errors.New("OldSk is only allowed on UpdateOne operations")
  36946. }
  36947. if m.id == nil || m.oldValue == nil {
  36948. return v, errors.New("OldSk requires an ID field in the mutation")
  36949. }
  36950. oldValue, err := m.oldValue(ctx)
  36951. if err != nil {
  36952. return v, fmt.Errorf("querying old value for OldSk: %w", err)
  36953. }
  36954. return oldValue.Sk, nil
  36955. }
  36956. // ResetSk resets all changes to the "sk" field.
  36957. func (m *WhatsappChannelMutation) ResetSk() {
  36958. m.sk = nil
  36959. }
  36960. // SetWaID sets the "wa_id" field.
  36961. func (m *WhatsappChannelMutation) SetWaID(s string) {
  36962. m.wa_id = &s
  36963. }
  36964. // WaID returns the value of the "wa_id" field in the mutation.
  36965. func (m *WhatsappChannelMutation) WaID() (r string, exists bool) {
  36966. v := m.wa_id
  36967. if v == nil {
  36968. return
  36969. }
  36970. return *v, true
  36971. }
  36972. // OldWaID returns the old "wa_id" field's value of the WhatsappChannel entity.
  36973. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  36974. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36975. func (m *WhatsappChannelMutation) OldWaID(ctx context.Context) (v string, err error) {
  36976. if !m.op.Is(OpUpdateOne) {
  36977. return v, errors.New("OldWaID is only allowed on UpdateOne operations")
  36978. }
  36979. if m.id == nil || m.oldValue == nil {
  36980. return v, errors.New("OldWaID requires an ID field in the mutation")
  36981. }
  36982. oldValue, err := m.oldValue(ctx)
  36983. if err != nil {
  36984. return v, fmt.Errorf("querying old value for OldWaID: %w", err)
  36985. }
  36986. return oldValue.WaID, nil
  36987. }
  36988. // ClearWaID clears the value of the "wa_id" field.
  36989. func (m *WhatsappChannelMutation) ClearWaID() {
  36990. m.wa_id = nil
  36991. m.clearedFields[whatsappchannel.FieldWaID] = struct{}{}
  36992. }
  36993. // WaIDCleared returns if the "wa_id" field was cleared in this mutation.
  36994. func (m *WhatsappChannelMutation) WaIDCleared() bool {
  36995. _, ok := m.clearedFields[whatsappchannel.FieldWaID]
  36996. return ok
  36997. }
  36998. // ResetWaID resets all changes to the "wa_id" field.
  36999. func (m *WhatsappChannelMutation) ResetWaID() {
  37000. m.wa_id = nil
  37001. delete(m.clearedFields, whatsappchannel.FieldWaID)
  37002. }
  37003. // SetWaName sets the "wa_name" field.
  37004. func (m *WhatsappChannelMutation) SetWaName(s string) {
  37005. m.wa_name = &s
  37006. }
  37007. // WaName returns the value of the "wa_name" field in the mutation.
  37008. func (m *WhatsappChannelMutation) WaName() (r string, exists bool) {
  37009. v := m.wa_name
  37010. if v == nil {
  37011. return
  37012. }
  37013. return *v, true
  37014. }
  37015. // OldWaName returns the old "wa_name" field's value of the WhatsappChannel entity.
  37016. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  37017. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37018. func (m *WhatsappChannelMutation) OldWaName(ctx context.Context) (v string, err error) {
  37019. if !m.op.Is(OpUpdateOne) {
  37020. return v, errors.New("OldWaName is only allowed on UpdateOne operations")
  37021. }
  37022. if m.id == nil || m.oldValue == nil {
  37023. return v, errors.New("OldWaName requires an ID field in the mutation")
  37024. }
  37025. oldValue, err := m.oldValue(ctx)
  37026. if err != nil {
  37027. return v, fmt.Errorf("querying old value for OldWaName: %w", err)
  37028. }
  37029. return oldValue.WaName, nil
  37030. }
  37031. // ClearWaName clears the value of the "wa_name" field.
  37032. func (m *WhatsappChannelMutation) ClearWaName() {
  37033. m.wa_name = nil
  37034. m.clearedFields[whatsappchannel.FieldWaName] = struct{}{}
  37035. }
  37036. // WaNameCleared returns if the "wa_name" field was cleared in this mutation.
  37037. func (m *WhatsappChannelMutation) WaNameCleared() bool {
  37038. _, ok := m.clearedFields[whatsappchannel.FieldWaName]
  37039. return ok
  37040. }
  37041. // ResetWaName resets all changes to the "wa_name" field.
  37042. func (m *WhatsappChannelMutation) ResetWaName() {
  37043. m.wa_name = nil
  37044. delete(m.clearedFields, whatsappchannel.FieldWaName)
  37045. }
  37046. // SetWabaID sets the "waba_id" field.
  37047. func (m *WhatsappChannelMutation) SetWabaID(u uint64) {
  37048. m.waba_id = &u
  37049. m.addwaba_id = nil
  37050. }
  37051. // WabaID returns the value of the "waba_id" field in the mutation.
  37052. func (m *WhatsappChannelMutation) WabaID() (r uint64, exists bool) {
  37053. v := m.waba_id
  37054. if v == nil {
  37055. return
  37056. }
  37057. return *v, true
  37058. }
  37059. // OldWabaID returns the old "waba_id" field's value of the WhatsappChannel entity.
  37060. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  37061. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37062. func (m *WhatsappChannelMutation) OldWabaID(ctx context.Context) (v uint64, err error) {
  37063. if !m.op.Is(OpUpdateOne) {
  37064. return v, errors.New("OldWabaID is only allowed on UpdateOne operations")
  37065. }
  37066. if m.id == nil || m.oldValue == nil {
  37067. return v, errors.New("OldWabaID requires an ID field in the mutation")
  37068. }
  37069. oldValue, err := m.oldValue(ctx)
  37070. if err != nil {
  37071. return v, fmt.Errorf("querying old value for OldWabaID: %w", err)
  37072. }
  37073. return oldValue.WabaID, nil
  37074. }
  37075. // AddWabaID adds u to the "waba_id" field.
  37076. func (m *WhatsappChannelMutation) AddWabaID(u int64) {
  37077. if m.addwaba_id != nil {
  37078. *m.addwaba_id += u
  37079. } else {
  37080. m.addwaba_id = &u
  37081. }
  37082. }
  37083. // AddedWabaID returns the value that was added to the "waba_id" field in this mutation.
  37084. func (m *WhatsappChannelMutation) AddedWabaID() (r int64, exists bool) {
  37085. v := m.addwaba_id
  37086. if v == nil {
  37087. return
  37088. }
  37089. return *v, true
  37090. }
  37091. // ResetWabaID resets all changes to the "waba_id" field.
  37092. func (m *WhatsappChannelMutation) ResetWabaID() {
  37093. m.waba_id = nil
  37094. m.addwaba_id = nil
  37095. }
  37096. // SetBusinessID sets the "business_id" field.
  37097. func (m *WhatsappChannelMutation) SetBusinessID(u uint64) {
  37098. m.business_id = &u
  37099. m.addbusiness_id = nil
  37100. }
  37101. // BusinessID returns the value of the "business_id" field in the mutation.
  37102. func (m *WhatsappChannelMutation) BusinessID() (r uint64, exists bool) {
  37103. v := m.business_id
  37104. if v == nil {
  37105. return
  37106. }
  37107. return *v, true
  37108. }
  37109. // OldBusinessID returns the old "business_id" field's value of the WhatsappChannel entity.
  37110. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  37111. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37112. func (m *WhatsappChannelMutation) OldBusinessID(ctx context.Context) (v uint64, err error) {
  37113. if !m.op.Is(OpUpdateOne) {
  37114. return v, errors.New("OldBusinessID is only allowed on UpdateOne operations")
  37115. }
  37116. if m.id == nil || m.oldValue == nil {
  37117. return v, errors.New("OldBusinessID requires an ID field in the mutation")
  37118. }
  37119. oldValue, err := m.oldValue(ctx)
  37120. if err != nil {
  37121. return v, fmt.Errorf("querying old value for OldBusinessID: %w", err)
  37122. }
  37123. return oldValue.BusinessID, nil
  37124. }
  37125. // AddBusinessID adds u to the "business_id" field.
  37126. func (m *WhatsappChannelMutation) AddBusinessID(u int64) {
  37127. if m.addbusiness_id != nil {
  37128. *m.addbusiness_id += u
  37129. } else {
  37130. m.addbusiness_id = &u
  37131. }
  37132. }
  37133. // AddedBusinessID returns the value that was added to the "business_id" field in this mutation.
  37134. func (m *WhatsappChannelMutation) AddedBusinessID() (r int64, exists bool) {
  37135. v := m.addbusiness_id
  37136. if v == nil {
  37137. return
  37138. }
  37139. return *v, true
  37140. }
  37141. // ResetBusinessID resets all changes to the "business_id" field.
  37142. func (m *WhatsappChannelMutation) ResetBusinessID() {
  37143. m.business_id = nil
  37144. m.addbusiness_id = nil
  37145. }
  37146. // SetOrganizationID sets the "organization_id" field.
  37147. func (m *WhatsappChannelMutation) SetOrganizationID(u uint64) {
  37148. m.organization_id = &u
  37149. m.addorganization_id = nil
  37150. }
  37151. // OrganizationID returns the value of the "organization_id" field in the mutation.
  37152. func (m *WhatsappChannelMutation) OrganizationID() (r uint64, exists bool) {
  37153. v := m.organization_id
  37154. if v == nil {
  37155. return
  37156. }
  37157. return *v, true
  37158. }
  37159. // OldOrganizationID returns the old "organization_id" field's value of the WhatsappChannel entity.
  37160. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  37161. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37162. func (m *WhatsappChannelMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  37163. if !m.op.Is(OpUpdateOne) {
  37164. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  37165. }
  37166. if m.id == nil || m.oldValue == nil {
  37167. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  37168. }
  37169. oldValue, err := m.oldValue(ctx)
  37170. if err != nil {
  37171. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  37172. }
  37173. return oldValue.OrganizationID, nil
  37174. }
  37175. // AddOrganizationID adds u to the "organization_id" field.
  37176. func (m *WhatsappChannelMutation) AddOrganizationID(u int64) {
  37177. if m.addorganization_id != nil {
  37178. *m.addorganization_id += u
  37179. } else {
  37180. m.addorganization_id = &u
  37181. }
  37182. }
  37183. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  37184. func (m *WhatsappChannelMutation) AddedOrganizationID() (r int64, exists bool) {
  37185. v := m.addorganization_id
  37186. if v == nil {
  37187. return
  37188. }
  37189. return *v, true
  37190. }
  37191. // ClearOrganizationID clears the value of the "organization_id" field.
  37192. func (m *WhatsappChannelMutation) ClearOrganizationID() {
  37193. m.organization_id = nil
  37194. m.addorganization_id = nil
  37195. m.clearedFields[whatsappchannel.FieldOrganizationID] = struct{}{}
  37196. }
  37197. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  37198. func (m *WhatsappChannelMutation) OrganizationIDCleared() bool {
  37199. _, ok := m.clearedFields[whatsappchannel.FieldOrganizationID]
  37200. return ok
  37201. }
  37202. // ResetOrganizationID resets all changes to the "organization_id" field.
  37203. func (m *WhatsappChannelMutation) ResetOrganizationID() {
  37204. m.organization_id = nil
  37205. m.addorganization_id = nil
  37206. delete(m.clearedFields, whatsappchannel.FieldOrganizationID)
  37207. }
  37208. // SetVerifyAccount sets the "verify_account" field.
  37209. func (m *WhatsappChannelMutation) SetVerifyAccount(s string) {
  37210. m.verify_account = &s
  37211. }
  37212. // VerifyAccount returns the value of the "verify_account" field in the mutation.
  37213. func (m *WhatsappChannelMutation) VerifyAccount() (r string, exists bool) {
  37214. v := m.verify_account
  37215. if v == nil {
  37216. return
  37217. }
  37218. return *v, true
  37219. }
  37220. // OldVerifyAccount returns the old "verify_account" field's value of the WhatsappChannel entity.
  37221. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  37222. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37223. func (m *WhatsappChannelMutation) OldVerifyAccount(ctx context.Context) (v string, err error) {
  37224. if !m.op.Is(OpUpdateOne) {
  37225. return v, errors.New("OldVerifyAccount is only allowed on UpdateOne operations")
  37226. }
  37227. if m.id == nil || m.oldValue == nil {
  37228. return v, errors.New("OldVerifyAccount requires an ID field in the mutation")
  37229. }
  37230. oldValue, err := m.oldValue(ctx)
  37231. if err != nil {
  37232. return v, fmt.Errorf("querying old value for OldVerifyAccount: %w", err)
  37233. }
  37234. return oldValue.VerifyAccount, nil
  37235. }
  37236. // ResetVerifyAccount resets all changes to the "verify_account" field.
  37237. func (m *WhatsappChannelMutation) ResetVerifyAccount() {
  37238. m.verify_account = nil
  37239. }
  37240. // Where appends a list predicates to the WhatsappChannelMutation builder.
  37241. func (m *WhatsappChannelMutation) Where(ps ...predicate.WhatsappChannel) {
  37242. m.predicates = append(m.predicates, ps...)
  37243. }
  37244. // WhereP appends storage-level predicates to the WhatsappChannelMutation builder. Using this method,
  37245. // users can use type-assertion to append predicates that do not depend on any generated package.
  37246. func (m *WhatsappChannelMutation) WhereP(ps ...func(*sql.Selector)) {
  37247. p := make([]predicate.WhatsappChannel, len(ps))
  37248. for i := range ps {
  37249. p[i] = ps[i]
  37250. }
  37251. m.Where(p...)
  37252. }
  37253. // Op returns the operation name.
  37254. func (m *WhatsappChannelMutation) Op() Op {
  37255. return m.op
  37256. }
  37257. // SetOp allows setting the mutation operation.
  37258. func (m *WhatsappChannelMutation) SetOp(op Op) {
  37259. m.op = op
  37260. }
  37261. // Type returns the node type of this mutation (WhatsappChannel).
  37262. func (m *WhatsappChannelMutation) Type() string {
  37263. return m.typ
  37264. }
  37265. // Fields returns all fields that were changed during this mutation. Note that in
  37266. // order to get all numeric fields that were incremented/decremented, call
  37267. // AddedFields().
  37268. func (m *WhatsappChannelMutation) Fields() []string {
  37269. fields := make([]string, 0, 12)
  37270. if m.created_at != nil {
  37271. fields = append(fields, whatsappchannel.FieldCreatedAt)
  37272. }
  37273. if m.updated_at != nil {
  37274. fields = append(fields, whatsappchannel.FieldUpdatedAt)
  37275. }
  37276. if m.status != nil {
  37277. fields = append(fields, whatsappchannel.FieldStatus)
  37278. }
  37279. if m.deleted_at != nil {
  37280. fields = append(fields, whatsappchannel.FieldDeletedAt)
  37281. }
  37282. if m.ak != nil {
  37283. fields = append(fields, whatsappchannel.FieldAk)
  37284. }
  37285. if m.sk != nil {
  37286. fields = append(fields, whatsappchannel.FieldSk)
  37287. }
  37288. if m.wa_id != nil {
  37289. fields = append(fields, whatsappchannel.FieldWaID)
  37290. }
  37291. if m.wa_name != nil {
  37292. fields = append(fields, whatsappchannel.FieldWaName)
  37293. }
  37294. if m.waba_id != nil {
  37295. fields = append(fields, whatsappchannel.FieldWabaID)
  37296. }
  37297. if m.business_id != nil {
  37298. fields = append(fields, whatsappchannel.FieldBusinessID)
  37299. }
  37300. if m.organization_id != nil {
  37301. fields = append(fields, whatsappchannel.FieldOrganizationID)
  37302. }
  37303. if m.verify_account != nil {
  37304. fields = append(fields, whatsappchannel.FieldVerifyAccount)
  37305. }
  37306. return fields
  37307. }
  37308. // Field returns the value of a field with the given name. The second boolean
  37309. // return value indicates that this field was not set, or was not defined in the
  37310. // schema.
  37311. func (m *WhatsappChannelMutation) Field(name string) (ent.Value, bool) {
  37312. switch name {
  37313. case whatsappchannel.FieldCreatedAt:
  37314. return m.CreatedAt()
  37315. case whatsappchannel.FieldUpdatedAt:
  37316. return m.UpdatedAt()
  37317. case whatsappchannel.FieldStatus:
  37318. return m.Status()
  37319. case whatsappchannel.FieldDeletedAt:
  37320. return m.DeletedAt()
  37321. case whatsappchannel.FieldAk:
  37322. return m.Ak()
  37323. case whatsappchannel.FieldSk:
  37324. return m.Sk()
  37325. case whatsappchannel.FieldWaID:
  37326. return m.WaID()
  37327. case whatsappchannel.FieldWaName:
  37328. return m.WaName()
  37329. case whatsappchannel.FieldWabaID:
  37330. return m.WabaID()
  37331. case whatsappchannel.FieldBusinessID:
  37332. return m.BusinessID()
  37333. case whatsappchannel.FieldOrganizationID:
  37334. return m.OrganizationID()
  37335. case whatsappchannel.FieldVerifyAccount:
  37336. return m.VerifyAccount()
  37337. }
  37338. return nil, false
  37339. }
  37340. // OldField returns the old value of the field from the database. An error is
  37341. // returned if the mutation operation is not UpdateOne, or the query to the
  37342. // database failed.
  37343. func (m *WhatsappChannelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  37344. switch name {
  37345. case whatsappchannel.FieldCreatedAt:
  37346. return m.OldCreatedAt(ctx)
  37347. case whatsappchannel.FieldUpdatedAt:
  37348. return m.OldUpdatedAt(ctx)
  37349. case whatsappchannel.FieldStatus:
  37350. return m.OldStatus(ctx)
  37351. case whatsappchannel.FieldDeletedAt:
  37352. return m.OldDeletedAt(ctx)
  37353. case whatsappchannel.FieldAk:
  37354. return m.OldAk(ctx)
  37355. case whatsappchannel.FieldSk:
  37356. return m.OldSk(ctx)
  37357. case whatsappchannel.FieldWaID:
  37358. return m.OldWaID(ctx)
  37359. case whatsappchannel.FieldWaName:
  37360. return m.OldWaName(ctx)
  37361. case whatsappchannel.FieldWabaID:
  37362. return m.OldWabaID(ctx)
  37363. case whatsappchannel.FieldBusinessID:
  37364. return m.OldBusinessID(ctx)
  37365. case whatsappchannel.FieldOrganizationID:
  37366. return m.OldOrganizationID(ctx)
  37367. case whatsappchannel.FieldVerifyAccount:
  37368. return m.OldVerifyAccount(ctx)
  37369. }
  37370. return nil, fmt.Errorf("unknown WhatsappChannel field %s", name)
  37371. }
  37372. // SetField sets the value of a field with the given name. It returns an error if
  37373. // the field is not defined in the schema, or if the type mismatched the field
  37374. // type.
  37375. func (m *WhatsappChannelMutation) SetField(name string, value ent.Value) error {
  37376. switch name {
  37377. case whatsappchannel.FieldCreatedAt:
  37378. v, ok := value.(time.Time)
  37379. if !ok {
  37380. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37381. }
  37382. m.SetCreatedAt(v)
  37383. return nil
  37384. case whatsappchannel.FieldUpdatedAt:
  37385. v, ok := value.(time.Time)
  37386. if !ok {
  37387. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37388. }
  37389. m.SetUpdatedAt(v)
  37390. return nil
  37391. case whatsappchannel.FieldStatus:
  37392. v, ok := value.(uint8)
  37393. if !ok {
  37394. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37395. }
  37396. m.SetStatus(v)
  37397. return nil
  37398. case whatsappchannel.FieldDeletedAt:
  37399. v, ok := value.(time.Time)
  37400. if !ok {
  37401. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37402. }
  37403. m.SetDeletedAt(v)
  37404. return nil
  37405. case whatsappchannel.FieldAk:
  37406. v, ok := value.(string)
  37407. if !ok {
  37408. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37409. }
  37410. m.SetAk(v)
  37411. return nil
  37412. case whatsappchannel.FieldSk:
  37413. v, ok := value.(string)
  37414. if !ok {
  37415. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37416. }
  37417. m.SetSk(v)
  37418. return nil
  37419. case whatsappchannel.FieldWaID:
  37420. v, ok := value.(string)
  37421. if !ok {
  37422. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37423. }
  37424. m.SetWaID(v)
  37425. return nil
  37426. case whatsappchannel.FieldWaName:
  37427. v, ok := value.(string)
  37428. if !ok {
  37429. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37430. }
  37431. m.SetWaName(v)
  37432. return nil
  37433. case whatsappchannel.FieldWabaID:
  37434. v, ok := value.(uint64)
  37435. if !ok {
  37436. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37437. }
  37438. m.SetWabaID(v)
  37439. return nil
  37440. case whatsappchannel.FieldBusinessID:
  37441. v, ok := value.(uint64)
  37442. if !ok {
  37443. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37444. }
  37445. m.SetBusinessID(v)
  37446. return nil
  37447. case whatsappchannel.FieldOrganizationID:
  37448. v, ok := value.(uint64)
  37449. if !ok {
  37450. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37451. }
  37452. m.SetOrganizationID(v)
  37453. return nil
  37454. case whatsappchannel.FieldVerifyAccount:
  37455. v, ok := value.(string)
  37456. if !ok {
  37457. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37458. }
  37459. m.SetVerifyAccount(v)
  37460. return nil
  37461. }
  37462. return fmt.Errorf("unknown WhatsappChannel field %s", name)
  37463. }
  37464. // AddedFields returns all numeric fields that were incremented/decremented during
  37465. // this mutation.
  37466. func (m *WhatsappChannelMutation) AddedFields() []string {
  37467. var fields []string
  37468. if m.addstatus != nil {
  37469. fields = append(fields, whatsappchannel.FieldStatus)
  37470. }
  37471. if m.addwaba_id != nil {
  37472. fields = append(fields, whatsappchannel.FieldWabaID)
  37473. }
  37474. if m.addbusiness_id != nil {
  37475. fields = append(fields, whatsappchannel.FieldBusinessID)
  37476. }
  37477. if m.addorganization_id != nil {
  37478. fields = append(fields, whatsappchannel.FieldOrganizationID)
  37479. }
  37480. return fields
  37481. }
  37482. // AddedField returns the numeric value that was incremented/decremented on a field
  37483. // with the given name. The second boolean return value indicates that this field
  37484. // was not set, or was not defined in the schema.
  37485. func (m *WhatsappChannelMutation) AddedField(name string) (ent.Value, bool) {
  37486. switch name {
  37487. case whatsappchannel.FieldStatus:
  37488. return m.AddedStatus()
  37489. case whatsappchannel.FieldWabaID:
  37490. return m.AddedWabaID()
  37491. case whatsappchannel.FieldBusinessID:
  37492. return m.AddedBusinessID()
  37493. case whatsappchannel.FieldOrganizationID:
  37494. return m.AddedOrganizationID()
  37495. }
  37496. return nil, false
  37497. }
  37498. // AddField adds the value to the field with the given name. It returns an error if
  37499. // the field is not defined in the schema, or if the type mismatched the field
  37500. // type.
  37501. func (m *WhatsappChannelMutation) AddField(name string, value ent.Value) error {
  37502. switch name {
  37503. case whatsappchannel.FieldStatus:
  37504. v, ok := value.(int8)
  37505. if !ok {
  37506. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37507. }
  37508. m.AddStatus(v)
  37509. return nil
  37510. case whatsappchannel.FieldWabaID:
  37511. v, ok := value.(int64)
  37512. if !ok {
  37513. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37514. }
  37515. m.AddWabaID(v)
  37516. return nil
  37517. case whatsappchannel.FieldBusinessID:
  37518. v, ok := value.(int64)
  37519. if !ok {
  37520. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37521. }
  37522. m.AddBusinessID(v)
  37523. return nil
  37524. case whatsappchannel.FieldOrganizationID:
  37525. v, ok := value.(int64)
  37526. if !ok {
  37527. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37528. }
  37529. m.AddOrganizationID(v)
  37530. return nil
  37531. }
  37532. return fmt.Errorf("unknown WhatsappChannel numeric field %s", name)
  37533. }
  37534. // ClearedFields returns all nullable fields that were cleared during this
  37535. // mutation.
  37536. func (m *WhatsappChannelMutation) ClearedFields() []string {
  37537. var fields []string
  37538. if m.FieldCleared(whatsappchannel.FieldStatus) {
  37539. fields = append(fields, whatsappchannel.FieldStatus)
  37540. }
  37541. if m.FieldCleared(whatsappchannel.FieldDeletedAt) {
  37542. fields = append(fields, whatsappchannel.FieldDeletedAt)
  37543. }
  37544. if m.FieldCleared(whatsappchannel.FieldAk) {
  37545. fields = append(fields, whatsappchannel.FieldAk)
  37546. }
  37547. if m.FieldCleared(whatsappchannel.FieldWaID) {
  37548. fields = append(fields, whatsappchannel.FieldWaID)
  37549. }
  37550. if m.FieldCleared(whatsappchannel.FieldWaName) {
  37551. fields = append(fields, whatsappchannel.FieldWaName)
  37552. }
  37553. if m.FieldCleared(whatsappchannel.FieldOrganizationID) {
  37554. fields = append(fields, whatsappchannel.FieldOrganizationID)
  37555. }
  37556. return fields
  37557. }
  37558. // FieldCleared returns a boolean indicating if a field with the given name was
  37559. // cleared in this mutation.
  37560. func (m *WhatsappChannelMutation) FieldCleared(name string) bool {
  37561. _, ok := m.clearedFields[name]
  37562. return ok
  37563. }
  37564. // ClearField clears the value of the field with the given name. It returns an
  37565. // error if the field is not defined in the schema.
  37566. func (m *WhatsappChannelMutation) ClearField(name string) error {
  37567. switch name {
  37568. case whatsappchannel.FieldStatus:
  37569. m.ClearStatus()
  37570. return nil
  37571. case whatsappchannel.FieldDeletedAt:
  37572. m.ClearDeletedAt()
  37573. return nil
  37574. case whatsappchannel.FieldAk:
  37575. m.ClearAk()
  37576. return nil
  37577. case whatsappchannel.FieldWaID:
  37578. m.ClearWaID()
  37579. return nil
  37580. case whatsappchannel.FieldWaName:
  37581. m.ClearWaName()
  37582. return nil
  37583. case whatsappchannel.FieldOrganizationID:
  37584. m.ClearOrganizationID()
  37585. return nil
  37586. }
  37587. return fmt.Errorf("unknown WhatsappChannel nullable field %s", name)
  37588. }
  37589. // ResetField resets all changes in the mutation for the field with the given name.
  37590. // It returns an error if the field is not defined in the schema.
  37591. func (m *WhatsappChannelMutation) ResetField(name string) error {
  37592. switch name {
  37593. case whatsappchannel.FieldCreatedAt:
  37594. m.ResetCreatedAt()
  37595. return nil
  37596. case whatsappchannel.FieldUpdatedAt:
  37597. m.ResetUpdatedAt()
  37598. return nil
  37599. case whatsappchannel.FieldStatus:
  37600. m.ResetStatus()
  37601. return nil
  37602. case whatsappchannel.FieldDeletedAt:
  37603. m.ResetDeletedAt()
  37604. return nil
  37605. case whatsappchannel.FieldAk:
  37606. m.ResetAk()
  37607. return nil
  37608. case whatsappchannel.FieldSk:
  37609. m.ResetSk()
  37610. return nil
  37611. case whatsappchannel.FieldWaID:
  37612. m.ResetWaID()
  37613. return nil
  37614. case whatsappchannel.FieldWaName:
  37615. m.ResetWaName()
  37616. return nil
  37617. case whatsappchannel.FieldWabaID:
  37618. m.ResetWabaID()
  37619. return nil
  37620. case whatsappchannel.FieldBusinessID:
  37621. m.ResetBusinessID()
  37622. return nil
  37623. case whatsappchannel.FieldOrganizationID:
  37624. m.ResetOrganizationID()
  37625. return nil
  37626. case whatsappchannel.FieldVerifyAccount:
  37627. m.ResetVerifyAccount()
  37628. return nil
  37629. }
  37630. return fmt.Errorf("unknown WhatsappChannel field %s", name)
  37631. }
  37632. // AddedEdges returns all edge names that were set/added in this mutation.
  37633. func (m *WhatsappChannelMutation) AddedEdges() []string {
  37634. edges := make([]string, 0, 0)
  37635. return edges
  37636. }
  37637. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  37638. // name in this mutation.
  37639. func (m *WhatsappChannelMutation) AddedIDs(name string) []ent.Value {
  37640. return nil
  37641. }
  37642. // RemovedEdges returns all edge names that were removed in this mutation.
  37643. func (m *WhatsappChannelMutation) RemovedEdges() []string {
  37644. edges := make([]string, 0, 0)
  37645. return edges
  37646. }
  37647. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  37648. // the given name in this mutation.
  37649. func (m *WhatsappChannelMutation) RemovedIDs(name string) []ent.Value {
  37650. return nil
  37651. }
  37652. // ClearedEdges returns all edge names that were cleared in this mutation.
  37653. func (m *WhatsappChannelMutation) ClearedEdges() []string {
  37654. edges := make([]string, 0, 0)
  37655. return edges
  37656. }
  37657. // EdgeCleared returns a boolean which indicates if the edge with the given name
  37658. // was cleared in this mutation.
  37659. func (m *WhatsappChannelMutation) EdgeCleared(name string) bool {
  37660. return false
  37661. }
  37662. // ClearEdge clears the value of the edge with the given name. It returns an error
  37663. // if that edge is not defined in the schema.
  37664. func (m *WhatsappChannelMutation) ClearEdge(name string) error {
  37665. return fmt.Errorf("unknown WhatsappChannel unique edge %s", name)
  37666. }
  37667. // ResetEdge resets all changes to the edge with the given name in this mutation.
  37668. // It returns an error if the edge is not defined in the schema.
  37669. func (m *WhatsappChannelMutation) ResetEdge(name string) error {
  37670. return fmt.Errorf("unknown WhatsappChannel edge %s", name)
  37671. }
  37672. // WorkExperienceMutation represents an operation that mutates the WorkExperience nodes in the graph.
  37673. type WorkExperienceMutation struct {
  37674. config
  37675. op Op
  37676. typ string
  37677. id *uint64
  37678. created_at *time.Time
  37679. updated_at *time.Time
  37680. deleted_at *time.Time
  37681. start_date *time.Time
  37682. end_date *time.Time
  37683. company *string
  37684. experience *string
  37685. organization_id *uint64
  37686. addorganization_id *int64
  37687. clearedFields map[string]struct{}
  37688. employee *uint64
  37689. clearedemployee bool
  37690. done bool
  37691. oldValue func(context.Context) (*WorkExperience, error)
  37692. predicates []predicate.WorkExperience
  37693. }
  37694. var _ ent.Mutation = (*WorkExperienceMutation)(nil)
  37695. // workexperienceOption allows management of the mutation configuration using functional options.
  37696. type workexperienceOption func(*WorkExperienceMutation)
  37697. // newWorkExperienceMutation creates new mutation for the WorkExperience entity.
  37698. func newWorkExperienceMutation(c config, op Op, opts ...workexperienceOption) *WorkExperienceMutation {
  37699. m := &WorkExperienceMutation{
  37700. config: c,
  37701. op: op,
  37702. typ: TypeWorkExperience,
  37703. clearedFields: make(map[string]struct{}),
  37704. }
  37705. for _, opt := range opts {
  37706. opt(m)
  37707. }
  37708. return m
  37709. }
  37710. // withWorkExperienceID sets the ID field of the mutation.
  37711. func withWorkExperienceID(id uint64) workexperienceOption {
  37712. return func(m *WorkExperienceMutation) {
  37713. var (
  37714. err error
  37715. once sync.Once
  37716. value *WorkExperience
  37717. )
  37718. m.oldValue = func(ctx context.Context) (*WorkExperience, error) {
  37719. once.Do(func() {
  37720. if m.done {
  37721. err = errors.New("querying old values post mutation is not allowed")
  37722. } else {
  37723. value, err = m.Client().WorkExperience.Get(ctx, id)
  37724. }
  37725. })
  37726. return value, err
  37727. }
  37728. m.id = &id
  37729. }
  37730. }
  37731. // withWorkExperience sets the old WorkExperience of the mutation.
  37732. func withWorkExperience(node *WorkExperience) workexperienceOption {
  37733. return func(m *WorkExperienceMutation) {
  37734. m.oldValue = func(context.Context) (*WorkExperience, error) {
  37735. return node, nil
  37736. }
  37737. m.id = &node.ID
  37738. }
  37739. }
  37740. // Client returns a new `ent.Client` from the mutation. If the mutation was
  37741. // executed in a transaction (ent.Tx), a transactional client is returned.
  37742. func (m WorkExperienceMutation) Client() *Client {
  37743. client := &Client{config: m.config}
  37744. client.init()
  37745. return client
  37746. }
  37747. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  37748. // it returns an error otherwise.
  37749. func (m WorkExperienceMutation) Tx() (*Tx, error) {
  37750. if _, ok := m.driver.(*txDriver); !ok {
  37751. return nil, errors.New("ent: mutation is not running in a transaction")
  37752. }
  37753. tx := &Tx{config: m.config}
  37754. tx.init()
  37755. return tx, nil
  37756. }
  37757. // SetID sets the value of the id field. Note that this
  37758. // operation is only accepted on creation of WorkExperience entities.
  37759. func (m *WorkExperienceMutation) SetID(id uint64) {
  37760. m.id = &id
  37761. }
  37762. // ID returns the ID value in the mutation. Note that the ID is only available
  37763. // if it was provided to the builder or after it was returned from the database.
  37764. func (m *WorkExperienceMutation) ID() (id uint64, exists bool) {
  37765. if m.id == nil {
  37766. return
  37767. }
  37768. return *m.id, true
  37769. }
  37770. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  37771. // That means, if the mutation is applied within a transaction with an isolation level such
  37772. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  37773. // or updated by the mutation.
  37774. func (m *WorkExperienceMutation) IDs(ctx context.Context) ([]uint64, error) {
  37775. switch {
  37776. case m.op.Is(OpUpdateOne | OpDeleteOne):
  37777. id, exists := m.ID()
  37778. if exists {
  37779. return []uint64{id}, nil
  37780. }
  37781. fallthrough
  37782. case m.op.Is(OpUpdate | OpDelete):
  37783. return m.Client().WorkExperience.Query().Where(m.predicates...).IDs(ctx)
  37784. default:
  37785. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  37786. }
  37787. }
  37788. // SetCreatedAt sets the "created_at" field.
  37789. func (m *WorkExperienceMutation) SetCreatedAt(t time.Time) {
  37790. m.created_at = &t
  37791. }
  37792. // CreatedAt returns the value of the "created_at" field in the mutation.
  37793. func (m *WorkExperienceMutation) CreatedAt() (r time.Time, exists bool) {
  37794. v := m.created_at
  37795. if v == nil {
  37796. return
  37797. }
  37798. return *v, true
  37799. }
  37800. // OldCreatedAt returns the old "created_at" field's value of the WorkExperience entity.
  37801. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  37802. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37803. func (m *WorkExperienceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  37804. if !m.op.Is(OpUpdateOne) {
  37805. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  37806. }
  37807. if m.id == nil || m.oldValue == nil {
  37808. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  37809. }
  37810. oldValue, err := m.oldValue(ctx)
  37811. if err != nil {
  37812. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  37813. }
  37814. return oldValue.CreatedAt, nil
  37815. }
  37816. // ResetCreatedAt resets all changes to the "created_at" field.
  37817. func (m *WorkExperienceMutation) ResetCreatedAt() {
  37818. m.created_at = nil
  37819. }
  37820. // SetUpdatedAt sets the "updated_at" field.
  37821. func (m *WorkExperienceMutation) SetUpdatedAt(t time.Time) {
  37822. m.updated_at = &t
  37823. }
  37824. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  37825. func (m *WorkExperienceMutation) UpdatedAt() (r time.Time, exists bool) {
  37826. v := m.updated_at
  37827. if v == nil {
  37828. return
  37829. }
  37830. return *v, true
  37831. }
  37832. // OldUpdatedAt returns the old "updated_at" field's value of the WorkExperience entity.
  37833. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  37834. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37835. func (m *WorkExperienceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  37836. if !m.op.Is(OpUpdateOne) {
  37837. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  37838. }
  37839. if m.id == nil || m.oldValue == nil {
  37840. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  37841. }
  37842. oldValue, err := m.oldValue(ctx)
  37843. if err != nil {
  37844. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  37845. }
  37846. return oldValue.UpdatedAt, nil
  37847. }
  37848. // ResetUpdatedAt resets all changes to the "updated_at" field.
  37849. func (m *WorkExperienceMutation) ResetUpdatedAt() {
  37850. m.updated_at = nil
  37851. }
  37852. // SetDeletedAt sets the "deleted_at" field.
  37853. func (m *WorkExperienceMutation) SetDeletedAt(t time.Time) {
  37854. m.deleted_at = &t
  37855. }
  37856. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  37857. func (m *WorkExperienceMutation) DeletedAt() (r time.Time, exists bool) {
  37858. v := m.deleted_at
  37859. if v == nil {
  37860. return
  37861. }
  37862. return *v, true
  37863. }
  37864. // OldDeletedAt returns the old "deleted_at" field's value of the WorkExperience entity.
  37865. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  37866. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37867. func (m *WorkExperienceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  37868. if !m.op.Is(OpUpdateOne) {
  37869. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  37870. }
  37871. if m.id == nil || m.oldValue == nil {
  37872. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  37873. }
  37874. oldValue, err := m.oldValue(ctx)
  37875. if err != nil {
  37876. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  37877. }
  37878. return oldValue.DeletedAt, nil
  37879. }
  37880. // ClearDeletedAt clears the value of the "deleted_at" field.
  37881. func (m *WorkExperienceMutation) ClearDeletedAt() {
  37882. m.deleted_at = nil
  37883. m.clearedFields[workexperience.FieldDeletedAt] = struct{}{}
  37884. }
  37885. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  37886. func (m *WorkExperienceMutation) DeletedAtCleared() bool {
  37887. _, ok := m.clearedFields[workexperience.FieldDeletedAt]
  37888. return ok
  37889. }
  37890. // ResetDeletedAt resets all changes to the "deleted_at" field.
  37891. func (m *WorkExperienceMutation) ResetDeletedAt() {
  37892. m.deleted_at = nil
  37893. delete(m.clearedFields, workexperience.FieldDeletedAt)
  37894. }
  37895. // SetEmployeeID sets the "employee_id" field.
  37896. func (m *WorkExperienceMutation) SetEmployeeID(u uint64) {
  37897. m.employee = &u
  37898. }
  37899. // EmployeeID returns the value of the "employee_id" field in the mutation.
  37900. func (m *WorkExperienceMutation) EmployeeID() (r uint64, exists bool) {
  37901. v := m.employee
  37902. if v == nil {
  37903. return
  37904. }
  37905. return *v, true
  37906. }
  37907. // OldEmployeeID returns the old "employee_id" field's value of the WorkExperience entity.
  37908. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  37909. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37910. func (m *WorkExperienceMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  37911. if !m.op.Is(OpUpdateOne) {
  37912. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  37913. }
  37914. if m.id == nil || m.oldValue == nil {
  37915. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  37916. }
  37917. oldValue, err := m.oldValue(ctx)
  37918. if err != nil {
  37919. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  37920. }
  37921. return oldValue.EmployeeID, nil
  37922. }
  37923. // ResetEmployeeID resets all changes to the "employee_id" field.
  37924. func (m *WorkExperienceMutation) ResetEmployeeID() {
  37925. m.employee = nil
  37926. }
  37927. // SetStartDate sets the "start_date" field.
  37928. func (m *WorkExperienceMutation) SetStartDate(t time.Time) {
  37929. m.start_date = &t
  37930. }
  37931. // StartDate returns the value of the "start_date" field in the mutation.
  37932. func (m *WorkExperienceMutation) StartDate() (r time.Time, exists bool) {
  37933. v := m.start_date
  37934. if v == nil {
  37935. return
  37936. }
  37937. return *v, true
  37938. }
  37939. // OldStartDate returns the old "start_date" field's value of the WorkExperience entity.
  37940. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  37941. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37942. func (m *WorkExperienceMutation) OldStartDate(ctx context.Context) (v time.Time, err error) {
  37943. if !m.op.Is(OpUpdateOne) {
  37944. return v, errors.New("OldStartDate is only allowed on UpdateOne operations")
  37945. }
  37946. if m.id == nil || m.oldValue == nil {
  37947. return v, errors.New("OldStartDate requires an ID field in the mutation")
  37948. }
  37949. oldValue, err := m.oldValue(ctx)
  37950. if err != nil {
  37951. return v, fmt.Errorf("querying old value for OldStartDate: %w", err)
  37952. }
  37953. return oldValue.StartDate, nil
  37954. }
  37955. // ResetStartDate resets all changes to the "start_date" field.
  37956. func (m *WorkExperienceMutation) ResetStartDate() {
  37957. m.start_date = nil
  37958. }
  37959. // SetEndDate sets the "end_date" field.
  37960. func (m *WorkExperienceMutation) SetEndDate(t time.Time) {
  37961. m.end_date = &t
  37962. }
  37963. // EndDate returns the value of the "end_date" field in the mutation.
  37964. func (m *WorkExperienceMutation) EndDate() (r time.Time, exists bool) {
  37965. v := m.end_date
  37966. if v == nil {
  37967. return
  37968. }
  37969. return *v, true
  37970. }
  37971. // OldEndDate returns the old "end_date" field's value of the WorkExperience entity.
  37972. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  37973. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37974. func (m *WorkExperienceMutation) OldEndDate(ctx context.Context) (v time.Time, err error) {
  37975. if !m.op.Is(OpUpdateOne) {
  37976. return v, errors.New("OldEndDate is only allowed on UpdateOne operations")
  37977. }
  37978. if m.id == nil || m.oldValue == nil {
  37979. return v, errors.New("OldEndDate requires an ID field in the mutation")
  37980. }
  37981. oldValue, err := m.oldValue(ctx)
  37982. if err != nil {
  37983. return v, fmt.Errorf("querying old value for OldEndDate: %w", err)
  37984. }
  37985. return oldValue.EndDate, nil
  37986. }
  37987. // ResetEndDate resets all changes to the "end_date" field.
  37988. func (m *WorkExperienceMutation) ResetEndDate() {
  37989. m.end_date = nil
  37990. }
  37991. // SetCompany sets the "company" field.
  37992. func (m *WorkExperienceMutation) SetCompany(s string) {
  37993. m.company = &s
  37994. }
  37995. // Company returns the value of the "company" field in the mutation.
  37996. func (m *WorkExperienceMutation) Company() (r string, exists bool) {
  37997. v := m.company
  37998. if v == nil {
  37999. return
  38000. }
  38001. return *v, true
  38002. }
  38003. // OldCompany returns the old "company" field's value of the WorkExperience entity.
  38004. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  38005. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38006. func (m *WorkExperienceMutation) OldCompany(ctx context.Context) (v string, err error) {
  38007. if !m.op.Is(OpUpdateOne) {
  38008. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  38009. }
  38010. if m.id == nil || m.oldValue == nil {
  38011. return v, errors.New("OldCompany requires an ID field in the mutation")
  38012. }
  38013. oldValue, err := m.oldValue(ctx)
  38014. if err != nil {
  38015. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  38016. }
  38017. return oldValue.Company, nil
  38018. }
  38019. // ResetCompany resets all changes to the "company" field.
  38020. func (m *WorkExperienceMutation) ResetCompany() {
  38021. m.company = nil
  38022. }
  38023. // SetExperience sets the "experience" field.
  38024. func (m *WorkExperienceMutation) SetExperience(s string) {
  38025. m.experience = &s
  38026. }
  38027. // Experience returns the value of the "experience" field in the mutation.
  38028. func (m *WorkExperienceMutation) Experience() (r string, exists bool) {
  38029. v := m.experience
  38030. if v == nil {
  38031. return
  38032. }
  38033. return *v, true
  38034. }
  38035. // OldExperience returns the old "experience" field's value of the WorkExperience entity.
  38036. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  38037. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38038. func (m *WorkExperienceMutation) OldExperience(ctx context.Context) (v string, err error) {
  38039. if !m.op.Is(OpUpdateOne) {
  38040. return v, errors.New("OldExperience is only allowed on UpdateOne operations")
  38041. }
  38042. if m.id == nil || m.oldValue == nil {
  38043. return v, errors.New("OldExperience requires an ID field in the mutation")
  38044. }
  38045. oldValue, err := m.oldValue(ctx)
  38046. if err != nil {
  38047. return v, fmt.Errorf("querying old value for OldExperience: %w", err)
  38048. }
  38049. return oldValue.Experience, nil
  38050. }
  38051. // ResetExperience resets all changes to the "experience" field.
  38052. func (m *WorkExperienceMutation) ResetExperience() {
  38053. m.experience = nil
  38054. }
  38055. // SetOrganizationID sets the "organization_id" field.
  38056. func (m *WorkExperienceMutation) SetOrganizationID(u uint64) {
  38057. m.organization_id = &u
  38058. m.addorganization_id = nil
  38059. }
  38060. // OrganizationID returns the value of the "organization_id" field in the mutation.
  38061. func (m *WorkExperienceMutation) OrganizationID() (r uint64, exists bool) {
  38062. v := m.organization_id
  38063. if v == nil {
  38064. return
  38065. }
  38066. return *v, true
  38067. }
  38068. // OldOrganizationID returns the old "organization_id" field's value of the WorkExperience entity.
  38069. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  38070. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38071. func (m *WorkExperienceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  38072. if !m.op.Is(OpUpdateOne) {
  38073. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  38074. }
  38075. if m.id == nil || m.oldValue == nil {
  38076. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  38077. }
  38078. oldValue, err := m.oldValue(ctx)
  38079. if err != nil {
  38080. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  38081. }
  38082. return oldValue.OrganizationID, nil
  38083. }
  38084. // AddOrganizationID adds u to the "organization_id" field.
  38085. func (m *WorkExperienceMutation) AddOrganizationID(u int64) {
  38086. if m.addorganization_id != nil {
  38087. *m.addorganization_id += u
  38088. } else {
  38089. m.addorganization_id = &u
  38090. }
  38091. }
  38092. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  38093. func (m *WorkExperienceMutation) AddedOrganizationID() (r int64, exists bool) {
  38094. v := m.addorganization_id
  38095. if v == nil {
  38096. return
  38097. }
  38098. return *v, true
  38099. }
  38100. // ResetOrganizationID resets all changes to the "organization_id" field.
  38101. func (m *WorkExperienceMutation) ResetOrganizationID() {
  38102. m.organization_id = nil
  38103. m.addorganization_id = nil
  38104. }
  38105. // ClearEmployee clears the "employee" edge to the Employee entity.
  38106. func (m *WorkExperienceMutation) ClearEmployee() {
  38107. m.clearedemployee = true
  38108. m.clearedFields[workexperience.FieldEmployeeID] = struct{}{}
  38109. }
  38110. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  38111. func (m *WorkExperienceMutation) EmployeeCleared() bool {
  38112. return m.clearedemployee
  38113. }
  38114. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  38115. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  38116. // EmployeeID instead. It exists only for internal usage by the builders.
  38117. func (m *WorkExperienceMutation) EmployeeIDs() (ids []uint64) {
  38118. if id := m.employee; id != nil {
  38119. ids = append(ids, *id)
  38120. }
  38121. return
  38122. }
  38123. // ResetEmployee resets all changes to the "employee" edge.
  38124. func (m *WorkExperienceMutation) ResetEmployee() {
  38125. m.employee = nil
  38126. m.clearedemployee = false
  38127. }
  38128. // Where appends a list predicates to the WorkExperienceMutation builder.
  38129. func (m *WorkExperienceMutation) Where(ps ...predicate.WorkExperience) {
  38130. m.predicates = append(m.predicates, ps...)
  38131. }
  38132. // WhereP appends storage-level predicates to the WorkExperienceMutation builder. Using this method,
  38133. // users can use type-assertion to append predicates that do not depend on any generated package.
  38134. func (m *WorkExperienceMutation) WhereP(ps ...func(*sql.Selector)) {
  38135. p := make([]predicate.WorkExperience, len(ps))
  38136. for i := range ps {
  38137. p[i] = ps[i]
  38138. }
  38139. m.Where(p...)
  38140. }
  38141. // Op returns the operation name.
  38142. func (m *WorkExperienceMutation) Op() Op {
  38143. return m.op
  38144. }
  38145. // SetOp allows setting the mutation operation.
  38146. func (m *WorkExperienceMutation) SetOp(op Op) {
  38147. m.op = op
  38148. }
  38149. // Type returns the node type of this mutation (WorkExperience).
  38150. func (m *WorkExperienceMutation) Type() string {
  38151. return m.typ
  38152. }
  38153. // Fields returns all fields that were changed during this mutation. Note that in
  38154. // order to get all numeric fields that were incremented/decremented, call
  38155. // AddedFields().
  38156. func (m *WorkExperienceMutation) Fields() []string {
  38157. fields := make([]string, 0, 9)
  38158. if m.created_at != nil {
  38159. fields = append(fields, workexperience.FieldCreatedAt)
  38160. }
  38161. if m.updated_at != nil {
  38162. fields = append(fields, workexperience.FieldUpdatedAt)
  38163. }
  38164. if m.deleted_at != nil {
  38165. fields = append(fields, workexperience.FieldDeletedAt)
  38166. }
  38167. if m.employee != nil {
  38168. fields = append(fields, workexperience.FieldEmployeeID)
  38169. }
  38170. if m.start_date != nil {
  38171. fields = append(fields, workexperience.FieldStartDate)
  38172. }
  38173. if m.end_date != nil {
  38174. fields = append(fields, workexperience.FieldEndDate)
  38175. }
  38176. if m.company != nil {
  38177. fields = append(fields, workexperience.FieldCompany)
  38178. }
  38179. if m.experience != nil {
  38180. fields = append(fields, workexperience.FieldExperience)
  38181. }
  38182. if m.organization_id != nil {
  38183. fields = append(fields, workexperience.FieldOrganizationID)
  38184. }
  38185. return fields
  38186. }
  38187. // Field returns the value of a field with the given name. The second boolean
  38188. // return value indicates that this field was not set, or was not defined in the
  38189. // schema.
  38190. func (m *WorkExperienceMutation) Field(name string) (ent.Value, bool) {
  38191. switch name {
  38192. case workexperience.FieldCreatedAt:
  38193. return m.CreatedAt()
  38194. case workexperience.FieldUpdatedAt:
  38195. return m.UpdatedAt()
  38196. case workexperience.FieldDeletedAt:
  38197. return m.DeletedAt()
  38198. case workexperience.FieldEmployeeID:
  38199. return m.EmployeeID()
  38200. case workexperience.FieldStartDate:
  38201. return m.StartDate()
  38202. case workexperience.FieldEndDate:
  38203. return m.EndDate()
  38204. case workexperience.FieldCompany:
  38205. return m.Company()
  38206. case workexperience.FieldExperience:
  38207. return m.Experience()
  38208. case workexperience.FieldOrganizationID:
  38209. return m.OrganizationID()
  38210. }
  38211. return nil, false
  38212. }
  38213. // OldField returns the old value of the field from the database. An error is
  38214. // returned if the mutation operation is not UpdateOne, or the query to the
  38215. // database failed.
  38216. func (m *WorkExperienceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  38217. switch name {
  38218. case workexperience.FieldCreatedAt:
  38219. return m.OldCreatedAt(ctx)
  38220. case workexperience.FieldUpdatedAt:
  38221. return m.OldUpdatedAt(ctx)
  38222. case workexperience.FieldDeletedAt:
  38223. return m.OldDeletedAt(ctx)
  38224. case workexperience.FieldEmployeeID:
  38225. return m.OldEmployeeID(ctx)
  38226. case workexperience.FieldStartDate:
  38227. return m.OldStartDate(ctx)
  38228. case workexperience.FieldEndDate:
  38229. return m.OldEndDate(ctx)
  38230. case workexperience.FieldCompany:
  38231. return m.OldCompany(ctx)
  38232. case workexperience.FieldExperience:
  38233. return m.OldExperience(ctx)
  38234. case workexperience.FieldOrganizationID:
  38235. return m.OldOrganizationID(ctx)
  38236. }
  38237. return nil, fmt.Errorf("unknown WorkExperience field %s", name)
  38238. }
  38239. // SetField sets the value of a field with the given name. It returns an error if
  38240. // the field is not defined in the schema, or if the type mismatched the field
  38241. // type.
  38242. func (m *WorkExperienceMutation) SetField(name string, value ent.Value) error {
  38243. switch name {
  38244. case workexperience.FieldCreatedAt:
  38245. v, ok := value.(time.Time)
  38246. if !ok {
  38247. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38248. }
  38249. m.SetCreatedAt(v)
  38250. return nil
  38251. case workexperience.FieldUpdatedAt:
  38252. v, ok := value.(time.Time)
  38253. if !ok {
  38254. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38255. }
  38256. m.SetUpdatedAt(v)
  38257. return nil
  38258. case workexperience.FieldDeletedAt:
  38259. v, ok := value.(time.Time)
  38260. if !ok {
  38261. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38262. }
  38263. m.SetDeletedAt(v)
  38264. return nil
  38265. case workexperience.FieldEmployeeID:
  38266. v, ok := value.(uint64)
  38267. if !ok {
  38268. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38269. }
  38270. m.SetEmployeeID(v)
  38271. return nil
  38272. case workexperience.FieldStartDate:
  38273. v, ok := value.(time.Time)
  38274. if !ok {
  38275. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38276. }
  38277. m.SetStartDate(v)
  38278. return nil
  38279. case workexperience.FieldEndDate:
  38280. v, ok := value.(time.Time)
  38281. if !ok {
  38282. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38283. }
  38284. m.SetEndDate(v)
  38285. return nil
  38286. case workexperience.FieldCompany:
  38287. v, ok := value.(string)
  38288. if !ok {
  38289. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38290. }
  38291. m.SetCompany(v)
  38292. return nil
  38293. case workexperience.FieldExperience:
  38294. v, ok := value.(string)
  38295. if !ok {
  38296. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38297. }
  38298. m.SetExperience(v)
  38299. return nil
  38300. case workexperience.FieldOrganizationID:
  38301. v, ok := value.(uint64)
  38302. if !ok {
  38303. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38304. }
  38305. m.SetOrganizationID(v)
  38306. return nil
  38307. }
  38308. return fmt.Errorf("unknown WorkExperience field %s", name)
  38309. }
  38310. // AddedFields returns all numeric fields that were incremented/decremented during
  38311. // this mutation.
  38312. func (m *WorkExperienceMutation) AddedFields() []string {
  38313. var fields []string
  38314. if m.addorganization_id != nil {
  38315. fields = append(fields, workexperience.FieldOrganizationID)
  38316. }
  38317. return fields
  38318. }
  38319. // AddedField returns the numeric value that was incremented/decremented on a field
  38320. // with the given name. The second boolean return value indicates that this field
  38321. // was not set, or was not defined in the schema.
  38322. func (m *WorkExperienceMutation) AddedField(name string) (ent.Value, bool) {
  38323. switch name {
  38324. case workexperience.FieldOrganizationID:
  38325. return m.AddedOrganizationID()
  38326. }
  38327. return nil, false
  38328. }
  38329. // AddField adds the value to the field with the given name. It returns an error if
  38330. // the field is not defined in the schema, or if the type mismatched the field
  38331. // type.
  38332. func (m *WorkExperienceMutation) AddField(name string, value ent.Value) error {
  38333. switch name {
  38334. case workexperience.FieldOrganizationID:
  38335. v, ok := value.(int64)
  38336. if !ok {
  38337. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38338. }
  38339. m.AddOrganizationID(v)
  38340. return nil
  38341. }
  38342. return fmt.Errorf("unknown WorkExperience numeric field %s", name)
  38343. }
  38344. // ClearedFields returns all nullable fields that were cleared during this
  38345. // mutation.
  38346. func (m *WorkExperienceMutation) ClearedFields() []string {
  38347. var fields []string
  38348. if m.FieldCleared(workexperience.FieldDeletedAt) {
  38349. fields = append(fields, workexperience.FieldDeletedAt)
  38350. }
  38351. return fields
  38352. }
  38353. // FieldCleared returns a boolean indicating if a field with the given name was
  38354. // cleared in this mutation.
  38355. func (m *WorkExperienceMutation) FieldCleared(name string) bool {
  38356. _, ok := m.clearedFields[name]
  38357. return ok
  38358. }
  38359. // ClearField clears the value of the field with the given name. It returns an
  38360. // error if the field is not defined in the schema.
  38361. func (m *WorkExperienceMutation) ClearField(name string) error {
  38362. switch name {
  38363. case workexperience.FieldDeletedAt:
  38364. m.ClearDeletedAt()
  38365. return nil
  38366. }
  38367. return fmt.Errorf("unknown WorkExperience nullable field %s", name)
  38368. }
  38369. // ResetField resets all changes in the mutation for the field with the given name.
  38370. // It returns an error if the field is not defined in the schema.
  38371. func (m *WorkExperienceMutation) ResetField(name string) error {
  38372. switch name {
  38373. case workexperience.FieldCreatedAt:
  38374. m.ResetCreatedAt()
  38375. return nil
  38376. case workexperience.FieldUpdatedAt:
  38377. m.ResetUpdatedAt()
  38378. return nil
  38379. case workexperience.FieldDeletedAt:
  38380. m.ResetDeletedAt()
  38381. return nil
  38382. case workexperience.FieldEmployeeID:
  38383. m.ResetEmployeeID()
  38384. return nil
  38385. case workexperience.FieldStartDate:
  38386. m.ResetStartDate()
  38387. return nil
  38388. case workexperience.FieldEndDate:
  38389. m.ResetEndDate()
  38390. return nil
  38391. case workexperience.FieldCompany:
  38392. m.ResetCompany()
  38393. return nil
  38394. case workexperience.FieldExperience:
  38395. m.ResetExperience()
  38396. return nil
  38397. case workexperience.FieldOrganizationID:
  38398. m.ResetOrganizationID()
  38399. return nil
  38400. }
  38401. return fmt.Errorf("unknown WorkExperience field %s", name)
  38402. }
  38403. // AddedEdges returns all edge names that were set/added in this mutation.
  38404. func (m *WorkExperienceMutation) AddedEdges() []string {
  38405. edges := make([]string, 0, 1)
  38406. if m.employee != nil {
  38407. edges = append(edges, workexperience.EdgeEmployee)
  38408. }
  38409. return edges
  38410. }
  38411. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  38412. // name in this mutation.
  38413. func (m *WorkExperienceMutation) AddedIDs(name string) []ent.Value {
  38414. switch name {
  38415. case workexperience.EdgeEmployee:
  38416. if id := m.employee; id != nil {
  38417. return []ent.Value{*id}
  38418. }
  38419. }
  38420. return nil
  38421. }
  38422. // RemovedEdges returns all edge names that were removed in this mutation.
  38423. func (m *WorkExperienceMutation) RemovedEdges() []string {
  38424. edges := make([]string, 0, 1)
  38425. return edges
  38426. }
  38427. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  38428. // the given name in this mutation.
  38429. func (m *WorkExperienceMutation) RemovedIDs(name string) []ent.Value {
  38430. return nil
  38431. }
  38432. // ClearedEdges returns all edge names that were cleared in this mutation.
  38433. func (m *WorkExperienceMutation) ClearedEdges() []string {
  38434. edges := make([]string, 0, 1)
  38435. if m.clearedemployee {
  38436. edges = append(edges, workexperience.EdgeEmployee)
  38437. }
  38438. return edges
  38439. }
  38440. // EdgeCleared returns a boolean which indicates if the edge with the given name
  38441. // was cleared in this mutation.
  38442. func (m *WorkExperienceMutation) EdgeCleared(name string) bool {
  38443. switch name {
  38444. case workexperience.EdgeEmployee:
  38445. return m.clearedemployee
  38446. }
  38447. return false
  38448. }
  38449. // ClearEdge clears the value of the edge with the given name. It returns an error
  38450. // if that edge is not defined in the schema.
  38451. func (m *WorkExperienceMutation) ClearEdge(name string) error {
  38452. switch name {
  38453. case workexperience.EdgeEmployee:
  38454. m.ClearEmployee()
  38455. return nil
  38456. }
  38457. return fmt.Errorf("unknown WorkExperience unique edge %s", name)
  38458. }
  38459. // ResetEdge resets all changes to the edge with the given name in this mutation.
  38460. // It returns an error if the edge is not defined in the schema.
  38461. func (m *WorkExperienceMutation) ResetEdge(name string) error {
  38462. switch name {
  38463. case workexperience.EdgeEmployee:
  38464. m.ResetEmployee()
  38465. return nil
  38466. }
  38467. return fmt.Errorf("unknown WorkExperience edge %s", name)
  38468. }
  38469. // WpChatroomMutation represents an operation that mutates the WpChatroom nodes in the graph.
  38470. type WpChatroomMutation struct {
  38471. config
  38472. op Op
  38473. typ string
  38474. id *uint64
  38475. created_at *time.Time
  38476. updated_at *time.Time
  38477. status *uint8
  38478. addstatus *int8
  38479. wx_wxid *string
  38480. chatroom_id *string
  38481. nickname *string
  38482. owner *string
  38483. avatar *string
  38484. member_list *[]string
  38485. appendmember_list []string
  38486. clearedFields map[string]struct{}
  38487. done bool
  38488. oldValue func(context.Context) (*WpChatroom, error)
  38489. predicates []predicate.WpChatroom
  38490. }
  38491. var _ ent.Mutation = (*WpChatroomMutation)(nil)
  38492. // wpchatroomOption allows management of the mutation configuration using functional options.
  38493. type wpchatroomOption func(*WpChatroomMutation)
  38494. // newWpChatroomMutation creates new mutation for the WpChatroom entity.
  38495. func newWpChatroomMutation(c config, op Op, opts ...wpchatroomOption) *WpChatroomMutation {
  38496. m := &WpChatroomMutation{
  38497. config: c,
  38498. op: op,
  38499. typ: TypeWpChatroom,
  38500. clearedFields: make(map[string]struct{}),
  38501. }
  38502. for _, opt := range opts {
  38503. opt(m)
  38504. }
  38505. return m
  38506. }
  38507. // withWpChatroomID sets the ID field of the mutation.
  38508. func withWpChatroomID(id uint64) wpchatroomOption {
  38509. return func(m *WpChatroomMutation) {
  38510. var (
  38511. err error
  38512. once sync.Once
  38513. value *WpChatroom
  38514. )
  38515. m.oldValue = func(ctx context.Context) (*WpChatroom, error) {
  38516. once.Do(func() {
  38517. if m.done {
  38518. err = errors.New("querying old values post mutation is not allowed")
  38519. } else {
  38520. value, err = m.Client().WpChatroom.Get(ctx, id)
  38521. }
  38522. })
  38523. return value, err
  38524. }
  38525. m.id = &id
  38526. }
  38527. }
  38528. // withWpChatroom sets the old WpChatroom of the mutation.
  38529. func withWpChatroom(node *WpChatroom) wpchatroomOption {
  38530. return func(m *WpChatroomMutation) {
  38531. m.oldValue = func(context.Context) (*WpChatroom, error) {
  38532. return node, nil
  38533. }
  38534. m.id = &node.ID
  38535. }
  38536. }
  38537. // Client returns a new `ent.Client` from the mutation. If the mutation was
  38538. // executed in a transaction (ent.Tx), a transactional client is returned.
  38539. func (m WpChatroomMutation) Client() *Client {
  38540. client := &Client{config: m.config}
  38541. client.init()
  38542. return client
  38543. }
  38544. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  38545. // it returns an error otherwise.
  38546. func (m WpChatroomMutation) Tx() (*Tx, error) {
  38547. if _, ok := m.driver.(*txDriver); !ok {
  38548. return nil, errors.New("ent: mutation is not running in a transaction")
  38549. }
  38550. tx := &Tx{config: m.config}
  38551. tx.init()
  38552. return tx, nil
  38553. }
  38554. // SetID sets the value of the id field. Note that this
  38555. // operation is only accepted on creation of WpChatroom entities.
  38556. func (m *WpChatroomMutation) SetID(id uint64) {
  38557. m.id = &id
  38558. }
  38559. // ID returns the ID value in the mutation. Note that the ID is only available
  38560. // if it was provided to the builder or after it was returned from the database.
  38561. func (m *WpChatroomMutation) ID() (id uint64, exists bool) {
  38562. if m.id == nil {
  38563. return
  38564. }
  38565. return *m.id, true
  38566. }
  38567. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  38568. // That means, if the mutation is applied within a transaction with an isolation level such
  38569. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  38570. // or updated by the mutation.
  38571. func (m *WpChatroomMutation) IDs(ctx context.Context) ([]uint64, error) {
  38572. switch {
  38573. case m.op.Is(OpUpdateOne | OpDeleteOne):
  38574. id, exists := m.ID()
  38575. if exists {
  38576. return []uint64{id}, nil
  38577. }
  38578. fallthrough
  38579. case m.op.Is(OpUpdate | OpDelete):
  38580. return m.Client().WpChatroom.Query().Where(m.predicates...).IDs(ctx)
  38581. default:
  38582. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  38583. }
  38584. }
  38585. // SetCreatedAt sets the "created_at" field.
  38586. func (m *WpChatroomMutation) SetCreatedAt(t time.Time) {
  38587. m.created_at = &t
  38588. }
  38589. // CreatedAt returns the value of the "created_at" field in the mutation.
  38590. func (m *WpChatroomMutation) CreatedAt() (r time.Time, exists bool) {
  38591. v := m.created_at
  38592. if v == nil {
  38593. return
  38594. }
  38595. return *v, true
  38596. }
  38597. // OldCreatedAt returns the old "created_at" field's value of the WpChatroom entity.
  38598. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  38599. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38600. func (m *WpChatroomMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  38601. if !m.op.Is(OpUpdateOne) {
  38602. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  38603. }
  38604. if m.id == nil || m.oldValue == nil {
  38605. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  38606. }
  38607. oldValue, err := m.oldValue(ctx)
  38608. if err != nil {
  38609. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  38610. }
  38611. return oldValue.CreatedAt, nil
  38612. }
  38613. // ResetCreatedAt resets all changes to the "created_at" field.
  38614. func (m *WpChatroomMutation) ResetCreatedAt() {
  38615. m.created_at = nil
  38616. }
  38617. // SetUpdatedAt sets the "updated_at" field.
  38618. func (m *WpChatroomMutation) SetUpdatedAt(t time.Time) {
  38619. m.updated_at = &t
  38620. }
  38621. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  38622. func (m *WpChatroomMutation) UpdatedAt() (r time.Time, exists bool) {
  38623. v := m.updated_at
  38624. if v == nil {
  38625. return
  38626. }
  38627. return *v, true
  38628. }
  38629. // OldUpdatedAt returns the old "updated_at" field's value of the WpChatroom entity.
  38630. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  38631. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38632. func (m *WpChatroomMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  38633. if !m.op.Is(OpUpdateOne) {
  38634. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  38635. }
  38636. if m.id == nil || m.oldValue == nil {
  38637. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  38638. }
  38639. oldValue, err := m.oldValue(ctx)
  38640. if err != nil {
  38641. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  38642. }
  38643. return oldValue.UpdatedAt, nil
  38644. }
  38645. // ResetUpdatedAt resets all changes to the "updated_at" field.
  38646. func (m *WpChatroomMutation) ResetUpdatedAt() {
  38647. m.updated_at = nil
  38648. }
  38649. // SetStatus sets the "status" field.
  38650. func (m *WpChatroomMutation) SetStatus(u uint8) {
  38651. m.status = &u
  38652. m.addstatus = nil
  38653. }
  38654. // Status returns the value of the "status" field in the mutation.
  38655. func (m *WpChatroomMutation) Status() (r uint8, exists bool) {
  38656. v := m.status
  38657. if v == nil {
  38658. return
  38659. }
  38660. return *v, true
  38661. }
  38662. // OldStatus returns the old "status" field's value of the WpChatroom entity.
  38663. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  38664. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38665. func (m *WpChatroomMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  38666. if !m.op.Is(OpUpdateOne) {
  38667. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  38668. }
  38669. if m.id == nil || m.oldValue == nil {
  38670. return v, errors.New("OldStatus requires an ID field in the mutation")
  38671. }
  38672. oldValue, err := m.oldValue(ctx)
  38673. if err != nil {
  38674. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  38675. }
  38676. return oldValue.Status, nil
  38677. }
  38678. // AddStatus adds u to the "status" field.
  38679. func (m *WpChatroomMutation) AddStatus(u int8) {
  38680. if m.addstatus != nil {
  38681. *m.addstatus += u
  38682. } else {
  38683. m.addstatus = &u
  38684. }
  38685. }
  38686. // AddedStatus returns the value that was added to the "status" field in this mutation.
  38687. func (m *WpChatroomMutation) AddedStatus() (r int8, exists bool) {
  38688. v := m.addstatus
  38689. if v == nil {
  38690. return
  38691. }
  38692. return *v, true
  38693. }
  38694. // ClearStatus clears the value of the "status" field.
  38695. func (m *WpChatroomMutation) ClearStatus() {
  38696. m.status = nil
  38697. m.addstatus = nil
  38698. m.clearedFields[wpchatroom.FieldStatus] = struct{}{}
  38699. }
  38700. // StatusCleared returns if the "status" field was cleared in this mutation.
  38701. func (m *WpChatroomMutation) StatusCleared() bool {
  38702. _, ok := m.clearedFields[wpchatroom.FieldStatus]
  38703. return ok
  38704. }
  38705. // ResetStatus resets all changes to the "status" field.
  38706. func (m *WpChatroomMutation) ResetStatus() {
  38707. m.status = nil
  38708. m.addstatus = nil
  38709. delete(m.clearedFields, wpchatroom.FieldStatus)
  38710. }
  38711. // SetWxWxid sets the "wx_wxid" field.
  38712. func (m *WpChatroomMutation) SetWxWxid(s string) {
  38713. m.wx_wxid = &s
  38714. }
  38715. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  38716. func (m *WpChatroomMutation) WxWxid() (r string, exists bool) {
  38717. v := m.wx_wxid
  38718. if v == nil {
  38719. return
  38720. }
  38721. return *v, true
  38722. }
  38723. // OldWxWxid returns the old "wx_wxid" field's value of the WpChatroom entity.
  38724. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  38725. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38726. func (m *WpChatroomMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  38727. if !m.op.Is(OpUpdateOne) {
  38728. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  38729. }
  38730. if m.id == nil || m.oldValue == nil {
  38731. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  38732. }
  38733. oldValue, err := m.oldValue(ctx)
  38734. if err != nil {
  38735. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  38736. }
  38737. return oldValue.WxWxid, nil
  38738. }
  38739. // ResetWxWxid resets all changes to the "wx_wxid" field.
  38740. func (m *WpChatroomMutation) ResetWxWxid() {
  38741. m.wx_wxid = nil
  38742. }
  38743. // SetChatroomID sets the "chatroom_id" field.
  38744. func (m *WpChatroomMutation) SetChatroomID(s string) {
  38745. m.chatroom_id = &s
  38746. }
  38747. // ChatroomID returns the value of the "chatroom_id" field in the mutation.
  38748. func (m *WpChatroomMutation) ChatroomID() (r string, exists bool) {
  38749. v := m.chatroom_id
  38750. if v == nil {
  38751. return
  38752. }
  38753. return *v, true
  38754. }
  38755. // OldChatroomID returns the old "chatroom_id" field's value of the WpChatroom entity.
  38756. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  38757. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38758. func (m *WpChatroomMutation) OldChatroomID(ctx context.Context) (v string, err error) {
  38759. if !m.op.Is(OpUpdateOne) {
  38760. return v, errors.New("OldChatroomID is only allowed on UpdateOne operations")
  38761. }
  38762. if m.id == nil || m.oldValue == nil {
  38763. return v, errors.New("OldChatroomID requires an ID field in the mutation")
  38764. }
  38765. oldValue, err := m.oldValue(ctx)
  38766. if err != nil {
  38767. return v, fmt.Errorf("querying old value for OldChatroomID: %w", err)
  38768. }
  38769. return oldValue.ChatroomID, nil
  38770. }
  38771. // ResetChatroomID resets all changes to the "chatroom_id" field.
  38772. func (m *WpChatroomMutation) ResetChatroomID() {
  38773. m.chatroom_id = nil
  38774. }
  38775. // SetNickname sets the "nickname" field.
  38776. func (m *WpChatroomMutation) SetNickname(s string) {
  38777. m.nickname = &s
  38778. }
  38779. // Nickname returns the value of the "nickname" field in the mutation.
  38780. func (m *WpChatroomMutation) Nickname() (r string, exists bool) {
  38781. v := m.nickname
  38782. if v == nil {
  38783. return
  38784. }
  38785. return *v, true
  38786. }
  38787. // OldNickname returns the old "nickname" field's value of the WpChatroom entity.
  38788. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  38789. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38790. func (m *WpChatroomMutation) OldNickname(ctx context.Context) (v string, err error) {
  38791. if !m.op.Is(OpUpdateOne) {
  38792. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  38793. }
  38794. if m.id == nil || m.oldValue == nil {
  38795. return v, errors.New("OldNickname requires an ID field in the mutation")
  38796. }
  38797. oldValue, err := m.oldValue(ctx)
  38798. if err != nil {
  38799. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  38800. }
  38801. return oldValue.Nickname, nil
  38802. }
  38803. // ResetNickname resets all changes to the "nickname" field.
  38804. func (m *WpChatroomMutation) ResetNickname() {
  38805. m.nickname = nil
  38806. }
  38807. // SetOwner sets the "owner" field.
  38808. func (m *WpChatroomMutation) SetOwner(s string) {
  38809. m.owner = &s
  38810. }
  38811. // Owner returns the value of the "owner" field in the mutation.
  38812. func (m *WpChatroomMutation) Owner() (r string, exists bool) {
  38813. v := m.owner
  38814. if v == nil {
  38815. return
  38816. }
  38817. return *v, true
  38818. }
  38819. // OldOwner returns the old "owner" field's value of the WpChatroom entity.
  38820. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  38821. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38822. func (m *WpChatroomMutation) OldOwner(ctx context.Context) (v string, err error) {
  38823. if !m.op.Is(OpUpdateOne) {
  38824. return v, errors.New("OldOwner is only allowed on UpdateOne operations")
  38825. }
  38826. if m.id == nil || m.oldValue == nil {
  38827. return v, errors.New("OldOwner requires an ID field in the mutation")
  38828. }
  38829. oldValue, err := m.oldValue(ctx)
  38830. if err != nil {
  38831. return v, fmt.Errorf("querying old value for OldOwner: %w", err)
  38832. }
  38833. return oldValue.Owner, nil
  38834. }
  38835. // ResetOwner resets all changes to the "owner" field.
  38836. func (m *WpChatroomMutation) ResetOwner() {
  38837. m.owner = nil
  38838. }
  38839. // SetAvatar sets the "avatar" field.
  38840. func (m *WpChatroomMutation) SetAvatar(s string) {
  38841. m.avatar = &s
  38842. }
  38843. // Avatar returns the value of the "avatar" field in the mutation.
  38844. func (m *WpChatroomMutation) Avatar() (r string, exists bool) {
  38845. v := m.avatar
  38846. if v == nil {
  38847. return
  38848. }
  38849. return *v, true
  38850. }
  38851. // OldAvatar returns the old "avatar" field's value of the WpChatroom entity.
  38852. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  38853. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38854. func (m *WpChatroomMutation) OldAvatar(ctx context.Context) (v string, err error) {
  38855. if !m.op.Is(OpUpdateOne) {
  38856. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  38857. }
  38858. if m.id == nil || m.oldValue == nil {
  38859. return v, errors.New("OldAvatar requires an ID field in the mutation")
  38860. }
  38861. oldValue, err := m.oldValue(ctx)
  38862. if err != nil {
  38863. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  38864. }
  38865. return oldValue.Avatar, nil
  38866. }
  38867. // ResetAvatar resets all changes to the "avatar" field.
  38868. func (m *WpChatroomMutation) ResetAvatar() {
  38869. m.avatar = nil
  38870. }
  38871. // SetMemberList sets the "member_list" field.
  38872. func (m *WpChatroomMutation) SetMemberList(s []string) {
  38873. m.member_list = &s
  38874. m.appendmember_list = nil
  38875. }
  38876. // MemberList returns the value of the "member_list" field in the mutation.
  38877. func (m *WpChatroomMutation) MemberList() (r []string, exists bool) {
  38878. v := m.member_list
  38879. if v == nil {
  38880. return
  38881. }
  38882. return *v, true
  38883. }
  38884. // OldMemberList returns the old "member_list" field's value of the WpChatroom entity.
  38885. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  38886. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38887. func (m *WpChatroomMutation) OldMemberList(ctx context.Context) (v []string, err error) {
  38888. if !m.op.Is(OpUpdateOne) {
  38889. return v, errors.New("OldMemberList is only allowed on UpdateOne operations")
  38890. }
  38891. if m.id == nil || m.oldValue == nil {
  38892. return v, errors.New("OldMemberList requires an ID field in the mutation")
  38893. }
  38894. oldValue, err := m.oldValue(ctx)
  38895. if err != nil {
  38896. return v, fmt.Errorf("querying old value for OldMemberList: %w", err)
  38897. }
  38898. return oldValue.MemberList, nil
  38899. }
  38900. // AppendMemberList adds s to the "member_list" field.
  38901. func (m *WpChatroomMutation) AppendMemberList(s []string) {
  38902. m.appendmember_list = append(m.appendmember_list, s...)
  38903. }
  38904. // AppendedMemberList returns the list of values that were appended to the "member_list" field in this mutation.
  38905. func (m *WpChatroomMutation) AppendedMemberList() ([]string, bool) {
  38906. if len(m.appendmember_list) == 0 {
  38907. return nil, false
  38908. }
  38909. return m.appendmember_list, true
  38910. }
  38911. // ResetMemberList resets all changes to the "member_list" field.
  38912. func (m *WpChatroomMutation) ResetMemberList() {
  38913. m.member_list = nil
  38914. m.appendmember_list = nil
  38915. }
  38916. // Where appends a list predicates to the WpChatroomMutation builder.
  38917. func (m *WpChatroomMutation) Where(ps ...predicate.WpChatroom) {
  38918. m.predicates = append(m.predicates, ps...)
  38919. }
  38920. // WhereP appends storage-level predicates to the WpChatroomMutation builder. Using this method,
  38921. // users can use type-assertion to append predicates that do not depend on any generated package.
  38922. func (m *WpChatroomMutation) WhereP(ps ...func(*sql.Selector)) {
  38923. p := make([]predicate.WpChatroom, len(ps))
  38924. for i := range ps {
  38925. p[i] = ps[i]
  38926. }
  38927. m.Where(p...)
  38928. }
  38929. // Op returns the operation name.
  38930. func (m *WpChatroomMutation) Op() Op {
  38931. return m.op
  38932. }
  38933. // SetOp allows setting the mutation operation.
  38934. func (m *WpChatroomMutation) SetOp(op Op) {
  38935. m.op = op
  38936. }
  38937. // Type returns the node type of this mutation (WpChatroom).
  38938. func (m *WpChatroomMutation) Type() string {
  38939. return m.typ
  38940. }
  38941. // Fields returns all fields that were changed during this mutation. Note that in
  38942. // order to get all numeric fields that were incremented/decremented, call
  38943. // AddedFields().
  38944. func (m *WpChatroomMutation) Fields() []string {
  38945. fields := make([]string, 0, 9)
  38946. if m.created_at != nil {
  38947. fields = append(fields, wpchatroom.FieldCreatedAt)
  38948. }
  38949. if m.updated_at != nil {
  38950. fields = append(fields, wpchatroom.FieldUpdatedAt)
  38951. }
  38952. if m.status != nil {
  38953. fields = append(fields, wpchatroom.FieldStatus)
  38954. }
  38955. if m.wx_wxid != nil {
  38956. fields = append(fields, wpchatroom.FieldWxWxid)
  38957. }
  38958. if m.chatroom_id != nil {
  38959. fields = append(fields, wpchatroom.FieldChatroomID)
  38960. }
  38961. if m.nickname != nil {
  38962. fields = append(fields, wpchatroom.FieldNickname)
  38963. }
  38964. if m.owner != nil {
  38965. fields = append(fields, wpchatroom.FieldOwner)
  38966. }
  38967. if m.avatar != nil {
  38968. fields = append(fields, wpchatroom.FieldAvatar)
  38969. }
  38970. if m.member_list != nil {
  38971. fields = append(fields, wpchatroom.FieldMemberList)
  38972. }
  38973. return fields
  38974. }
  38975. // Field returns the value of a field with the given name. The second boolean
  38976. // return value indicates that this field was not set, or was not defined in the
  38977. // schema.
  38978. func (m *WpChatroomMutation) Field(name string) (ent.Value, bool) {
  38979. switch name {
  38980. case wpchatroom.FieldCreatedAt:
  38981. return m.CreatedAt()
  38982. case wpchatroom.FieldUpdatedAt:
  38983. return m.UpdatedAt()
  38984. case wpchatroom.FieldStatus:
  38985. return m.Status()
  38986. case wpchatroom.FieldWxWxid:
  38987. return m.WxWxid()
  38988. case wpchatroom.FieldChatroomID:
  38989. return m.ChatroomID()
  38990. case wpchatroom.FieldNickname:
  38991. return m.Nickname()
  38992. case wpchatroom.FieldOwner:
  38993. return m.Owner()
  38994. case wpchatroom.FieldAvatar:
  38995. return m.Avatar()
  38996. case wpchatroom.FieldMemberList:
  38997. return m.MemberList()
  38998. }
  38999. return nil, false
  39000. }
  39001. // OldField returns the old value of the field from the database. An error is
  39002. // returned if the mutation operation is not UpdateOne, or the query to the
  39003. // database failed.
  39004. func (m *WpChatroomMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  39005. switch name {
  39006. case wpchatroom.FieldCreatedAt:
  39007. return m.OldCreatedAt(ctx)
  39008. case wpchatroom.FieldUpdatedAt:
  39009. return m.OldUpdatedAt(ctx)
  39010. case wpchatroom.FieldStatus:
  39011. return m.OldStatus(ctx)
  39012. case wpchatroom.FieldWxWxid:
  39013. return m.OldWxWxid(ctx)
  39014. case wpchatroom.FieldChatroomID:
  39015. return m.OldChatroomID(ctx)
  39016. case wpchatroom.FieldNickname:
  39017. return m.OldNickname(ctx)
  39018. case wpchatroom.FieldOwner:
  39019. return m.OldOwner(ctx)
  39020. case wpchatroom.FieldAvatar:
  39021. return m.OldAvatar(ctx)
  39022. case wpchatroom.FieldMemberList:
  39023. return m.OldMemberList(ctx)
  39024. }
  39025. return nil, fmt.Errorf("unknown WpChatroom field %s", name)
  39026. }
  39027. // SetField sets the value of a field with the given name. It returns an error if
  39028. // the field is not defined in the schema, or if the type mismatched the field
  39029. // type.
  39030. func (m *WpChatroomMutation) SetField(name string, value ent.Value) error {
  39031. switch name {
  39032. case wpchatroom.FieldCreatedAt:
  39033. v, ok := value.(time.Time)
  39034. if !ok {
  39035. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39036. }
  39037. m.SetCreatedAt(v)
  39038. return nil
  39039. case wpchatroom.FieldUpdatedAt:
  39040. v, ok := value.(time.Time)
  39041. if !ok {
  39042. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39043. }
  39044. m.SetUpdatedAt(v)
  39045. return nil
  39046. case wpchatroom.FieldStatus:
  39047. v, ok := value.(uint8)
  39048. if !ok {
  39049. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39050. }
  39051. m.SetStatus(v)
  39052. return nil
  39053. case wpchatroom.FieldWxWxid:
  39054. v, ok := value.(string)
  39055. if !ok {
  39056. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39057. }
  39058. m.SetWxWxid(v)
  39059. return nil
  39060. case wpchatroom.FieldChatroomID:
  39061. v, ok := value.(string)
  39062. if !ok {
  39063. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39064. }
  39065. m.SetChatroomID(v)
  39066. return nil
  39067. case wpchatroom.FieldNickname:
  39068. v, ok := value.(string)
  39069. if !ok {
  39070. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39071. }
  39072. m.SetNickname(v)
  39073. return nil
  39074. case wpchatroom.FieldOwner:
  39075. v, ok := value.(string)
  39076. if !ok {
  39077. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39078. }
  39079. m.SetOwner(v)
  39080. return nil
  39081. case wpchatroom.FieldAvatar:
  39082. v, ok := value.(string)
  39083. if !ok {
  39084. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39085. }
  39086. m.SetAvatar(v)
  39087. return nil
  39088. case wpchatroom.FieldMemberList:
  39089. v, ok := value.([]string)
  39090. if !ok {
  39091. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39092. }
  39093. m.SetMemberList(v)
  39094. return nil
  39095. }
  39096. return fmt.Errorf("unknown WpChatroom field %s", name)
  39097. }
  39098. // AddedFields returns all numeric fields that were incremented/decremented during
  39099. // this mutation.
  39100. func (m *WpChatroomMutation) AddedFields() []string {
  39101. var fields []string
  39102. if m.addstatus != nil {
  39103. fields = append(fields, wpchatroom.FieldStatus)
  39104. }
  39105. return fields
  39106. }
  39107. // AddedField returns the numeric value that was incremented/decremented on a field
  39108. // with the given name. The second boolean return value indicates that this field
  39109. // was not set, or was not defined in the schema.
  39110. func (m *WpChatroomMutation) AddedField(name string) (ent.Value, bool) {
  39111. switch name {
  39112. case wpchatroom.FieldStatus:
  39113. return m.AddedStatus()
  39114. }
  39115. return nil, false
  39116. }
  39117. // AddField adds the value to the field with the given name. It returns an error if
  39118. // the field is not defined in the schema, or if the type mismatched the field
  39119. // type.
  39120. func (m *WpChatroomMutation) AddField(name string, value ent.Value) error {
  39121. switch name {
  39122. case wpchatroom.FieldStatus:
  39123. v, ok := value.(int8)
  39124. if !ok {
  39125. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39126. }
  39127. m.AddStatus(v)
  39128. return nil
  39129. }
  39130. return fmt.Errorf("unknown WpChatroom numeric field %s", name)
  39131. }
  39132. // ClearedFields returns all nullable fields that were cleared during this
  39133. // mutation.
  39134. func (m *WpChatroomMutation) ClearedFields() []string {
  39135. var fields []string
  39136. if m.FieldCleared(wpchatroom.FieldStatus) {
  39137. fields = append(fields, wpchatroom.FieldStatus)
  39138. }
  39139. return fields
  39140. }
  39141. // FieldCleared returns a boolean indicating if a field with the given name was
  39142. // cleared in this mutation.
  39143. func (m *WpChatroomMutation) FieldCleared(name string) bool {
  39144. _, ok := m.clearedFields[name]
  39145. return ok
  39146. }
  39147. // ClearField clears the value of the field with the given name. It returns an
  39148. // error if the field is not defined in the schema.
  39149. func (m *WpChatroomMutation) ClearField(name string) error {
  39150. switch name {
  39151. case wpchatroom.FieldStatus:
  39152. m.ClearStatus()
  39153. return nil
  39154. }
  39155. return fmt.Errorf("unknown WpChatroom nullable field %s", name)
  39156. }
  39157. // ResetField resets all changes in the mutation for the field with the given name.
  39158. // It returns an error if the field is not defined in the schema.
  39159. func (m *WpChatroomMutation) ResetField(name string) error {
  39160. switch name {
  39161. case wpchatroom.FieldCreatedAt:
  39162. m.ResetCreatedAt()
  39163. return nil
  39164. case wpchatroom.FieldUpdatedAt:
  39165. m.ResetUpdatedAt()
  39166. return nil
  39167. case wpchatroom.FieldStatus:
  39168. m.ResetStatus()
  39169. return nil
  39170. case wpchatroom.FieldWxWxid:
  39171. m.ResetWxWxid()
  39172. return nil
  39173. case wpchatroom.FieldChatroomID:
  39174. m.ResetChatroomID()
  39175. return nil
  39176. case wpchatroom.FieldNickname:
  39177. m.ResetNickname()
  39178. return nil
  39179. case wpchatroom.FieldOwner:
  39180. m.ResetOwner()
  39181. return nil
  39182. case wpchatroom.FieldAvatar:
  39183. m.ResetAvatar()
  39184. return nil
  39185. case wpchatroom.FieldMemberList:
  39186. m.ResetMemberList()
  39187. return nil
  39188. }
  39189. return fmt.Errorf("unknown WpChatroom field %s", name)
  39190. }
  39191. // AddedEdges returns all edge names that were set/added in this mutation.
  39192. func (m *WpChatroomMutation) AddedEdges() []string {
  39193. edges := make([]string, 0, 0)
  39194. return edges
  39195. }
  39196. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  39197. // name in this mutation.
  39198. func (m *WpChatroomMutation) AddedIDs(name string) []ent.Value {
  39199. return nil
  39200. }
  39201. // RemovedEdges returns all edge names that were removed in this mutation.
  39202. func (m *WpChatroomMutation) RemovedEdges() []string {
  39203. edges := make([]string, 0, 0)
  39204. return edges
  39205. }
  39206. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  39207. // the given name in this mutation.
  39208. func (m *WpChatroomMutation) RemovedIDs(name string) []ent.Value {
  39209. return nil
  39210. }
  39211. // ClearedEdges returns all edge names that were cleared in this mutation.
  39212. func (m *WpChatroomMutation) ClearedEdges() []string {
  39213. edges := make([]string, 0, 0)
  39214. return edges
  39215. }
  39216. // EdgeCleared returns a boolean which indicates if the edge with the given name
  39217. // was cleared in this mutation.
  39218. func (m *WpChatroomMutation) EdgeCleared(name string) bool {
  39219. return false
  39220. }
  39221. // ClearEdge clears the value of the edge with the given name. It returns an error
  39222. // if that edge is not defined in the schema.
  39223. func (m *WpChatroomMutation) ClearEdge(name string) error {
  39224. return fmt.Errorf("unknown WpChatroom unique edge %s", name)
  39225. }
  39226. // ResetEdge resets all changes to the edge with the given name in this mutation.
  39227. // It returns an error if the edge is not defined in the schema.
  39228. func (m *WpChatroomMutation) ResetEdge(name string) error {
  39229. return fmt.Errorf("unknown WpChatroom edge %s", name)
  39230. }
  39231. // WpChatroomMemberMutation represents an operation that mutates the WpChatroomMember nodes in the graph.
  39232. type WpChatroomMemberMutation struct {
  39233. config
  39234. op Op
  39235. typ string
  39236. id *uint64
  39237. created_at *time.Time
  39238. updated_at *time.Time
  39239. status *uint8
  39240. addstatus *int8
  39241. wx_wxid *string
  39242. wxid *string
  39243. nickname *string
  39244. avatar *string
  39245. clearedFields map[string]struct{}
  39246. done bool
  39247. oldValue func(context.Context) (*WpChatroomMember, error)
  39248. predicates []predicate.WpChatroomMember
  39249. }
  39250. var _ ent.Mutation = (*WpChatroomMemberMutation)(nil)
  39251. // wpchatroommemberOption allows management of the mutation configuration using functional options.
  39252. type wpchatroommemberOption func(*WpChatroomMemberMutation)
  39253. // newWpChatroomMemberMutation creates new mutation for the WpChatroomMember entity.
  39254. func newWpChatroomMemberMutation(c config, op Op, opts ...wpchatroommemberOption) *WpChatroomMemberMutation {
  39255. m := &WpChatroomMemberMutation{
  39256. config: c,
  39257. op: op,
  39258. typ: TypeWpChatroomMember,
  39259. clearedFields: make(map[string]struct{}),
  39260. }
  39261. for _, opt := range opts {
  39262. opt(m)
  39263. }
  39264. return m
  39265. }
  39266. // withWpChatroomMemberID sets the ID field of the mutation.
  39267. func withWpChatroomMemberID(id uint64) wpchatroommemberOption {
  39268. return func(m *WpChatroomMemberMutation) {
  39269. var (
  39270. err error
  39271. once sync.Once
  39272. value *WpChatroomMember
  39273. )
  39274. m.oldValue = func(ctx context.Context) (*WpChatroomMember, error) {
  39275. once.Do(func() {
  39276. if m.done {
  39277. err = errors.New("querying old values post mutation is not allowed")
  39278. } else {
  39279. value, err = m.Client().WpChatroomMember.Get(ctx, id)
  39280. }
  39281. })
  39282. return value, err
  39283. }
  39284. m.id = &id
  39285. }
  39286. }
  39287. // withWpChatroomMember sets the old WpChatroomMember of the mutation.
  39288. func withWpChatroomMember(node *WpChatroomMember) wpchatroommemberOption {
  39289. return func(m *WpChatroomMemberMutation) {
  39290. m.oldValue = func(context.Context) (*WpChatroomMember, error) {
  39291. return node, nil
  39292. }
  39293. m.id = &node.ID
  39294. }
  39295. }
  39296. // Client returns a new `ent.Client` from the mutation. If the mutation was
  39297. // executed in a transaction (ent.Tx), a transactional client is returned.
  39298. func (m WpChatroomMemberMutation) Client() *Client {
  39299. client := &Client{config: m.config}
  39300. client.init()
  39301. return client
  39302. }
  39303. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  39304. // it returns an error otherwise.
  39305. func (m WpChatroomMemberMutation) Tx() (*Tx, error) {
  39306. if _, ok := m.driver.(*txDriver); !ok {
  39307. return nil, errors.New("ent: mutation is not running in a transaction")
  39308. }
  39309. tx := &Tx{config: m.config}
  39310. tx.init()
  39311. return tx, nil
  39312. }
  39313. // SetID sets the value of the id field. Note that this
  39314. // operation is only accepted on creation of WpChatroomMember entities.
  39315. func (m *WpChatroomMemberMutation) SetID(id uint64) {
  39316. m.id = &id
  39317. }
  39318. // ID returns the ID value in the mutation. Note that the ID is only available
  39319. // if it was provided to the builder or after it was returned from the database.
  39320. func (m *WpChatroomMemberMutation) ID() (id uint64, exists bool) {
  39321. if m.id == nil {
  39322. return
  39323. }
  39324. return *m.id, true
  39325. }
  39326. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  39327. // That means, if the mutation is applied within a transaction with an isolation level such
  39328. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  39329. // or updated by the mutation.
  39330. func (m *WpChatroomMemberMutation) IDs(ctx context.Context) ([]uint64, error) {
  39331. switch {
  39332. case m.op.Is(OpUpdateOne | OpDeleteOne):
  39333. id, exists := m.ID()
  39334. if exists {
  39335. return []uint64{id}, nil
  39336. }
  39337. fallthrough
  39338. case m.op.Is(OpUpdate | OpDelete):
  39339. return m.Client().WpChatroomMember.Query().Where(m.predicates...).IDs(ctx)
  39340. default:
  39341. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  39342. }
  39343. }
  39344. // SetCreatedAt sets the "created_at" field.
  39345. func (m *WpChatroomMemberMutation) SetCreatedAt(t time.Time) {
  39346. m.created_at = &t
  39347. }
  39348. // CreatedAt returns the value of the "created_at" field in the mutation.
  39349. func (m *WpChatroomMemberMutation) CreatedAt() (r time.Time, exists bool) {
  39350. v := m.created_at
  39351. if v == nil {
  39352. return
  39353. }
  39354. return *v, true
  39355. }
  39356. // OldCreatedAt returns the old "created_at" field's value of the WpChatroomMember entity.
  39357. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  39358. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39359. func (m *WpChatroomMemberMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  39360. if !m.op.Is(OpUpdateOne) {
  39361. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  39362. }
  39363. if m.id == nil || m.oldValue == nil {
  39364. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  39365. }
  39366. oldValue, err := m.oldValue(ctx)
  39367. if err != nil {
  39368. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  39369. }
  39370. return oldValue.CreatedAt, nil
  39371. }
  39372. // ResetCreatedAt resets all changes to the "created_at" field.
  39373. func (m *WpChatroomMemberMutation) ResetCreatedAt() {
  39374. m.created_at = nil
  39375. }
  39376. // SetUpdatedAt sets the "updated_at" field.
  39377. func (m *WpChatroomMemberMutation) SetUpdatedAt(t time.Time) {
  39378. m.updated_at = &t
  39379. }
  39380. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  39381. func (m *WpChatroomMemberMutation) UpdatedAt() (r time.Time, exists bool) {
  39382. v := m.updated_at
  39383. if v == nil {
  39384. return
  39385. }
  39386. return *v, true
  39387. }
  39388. // OldUpdatedAt returns the old "updated_at" field's value of the WpChatroomMember entity.
  39389. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  39390. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39391. func (m *WpChatroomMemberMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  39392. if !m.op.Is(OpUpdateOne) {
  39393. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  39394. }
  39395. if m.id == nil || m.oldValue == nil {
  39396. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  39397. }
  39398. oldValue, err := m.oldValue(ctx)
  39399. if err != nil {
  39400. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  39401. }
  39402. return oldValue.UpdatedAt, nil
  39403. }
  39404. // ResetUpdatedAt resets all changes to the "updated_at" field.
  39405. func (m *WpChatroomMemberMutation) ResetUpdatedAt() {
  39406. m.updated_at = nil
  39407. }
  39408. // SetStatus sets the "status" field.
  39409. func (m *WpChatroomMemberMutation) SetStatus(u uint8) {
  39410. m.status = &u
  39411. m.addstatus = nil
  39412. }
  39413. // Status returns the value of the "status" field in the mutation.
  39414. func (m *WpChatroomMemberMutation) Status() (r uint8, exists bool) {
  39415. v := m.status
  39416. if v == nil {
  39417. return
  39418. }
  39419. return *v, true
  39420. }
  39421. // OldStatus returns the old "status" field's value of the WpChatroomMember entity.
  39422. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  39423. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39424. func (m *WpChatroomMemberMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  39425. if !m.op.Is(OpUpdateOne) {
  39426. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  39427. }
  39428. if m.id == nil || m.oldValue == nil {
  39429. return v, errors.New("OldStatus requires an ID field in the mutation")
  39430. }
  39431. oldValue, err := m.oldValue(ctx)
  39432. if err != nil {
  39433. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  39434. }
  39435. return oldValue.Status, nil
  39436. }
  39437. // AddStatus adds u to the "status" field.
  39438. func (m *WpChatroomMemberMutation) AddStatus(u int8) {
  39439. if m.addstatus != nil {
  39440. *m.addstatus += u
  39441. } else {
  39442. m.addstatus = &u
  39443. }
  39444. }
  39445. // AddedStatus returns the value that was added to the "status" field in this mutation.
  39446. func (m *WpChatroomMemberMutation) AddedStatus() (r int8, exists bool) {
  39447. v := m.addstatus
  39448. if v == nil {
  39449. return
  39450. }
  39451. return *v, true
  39452. }
  39453. // ClearStatus clears the value of the "status" field.
  39454. func (m *WpChatroomMemberMutation) ClearStatus() {
  39455. m.status = nil
  39456. m.addstatus = nil
  39457. m.clearedFields[wpchatroommember.FieldStatus] = struct{}{}
  39458. }
  39459. // StatusCleared returns if the "status" field was cleared in this mutation.
  39460. func (m *WpChatroomMemberMutation) StatusCleared() bool {
  39461. _, ok := m.clearedFields[wpchatroommember.FieldStatus]
  39462. return ok
  39463. }
  39464. // ResetStatus resets all changes to the "status" field.
  39465. func (m *WpChatroomMemberMutation) ResetStatus() {
  39466. m.status = nil
  39467. m.addstatus = nil
  39468. delete(m.clearedFields, wpchatroommember.FieldStatus)
  39469. }
  39470. // SetWxWxid sets the "wx_wxid" field.
  39471. func (m *WpChatroomMemberMutation) SetWxWxid(s string) {
  39472. m.wx_wxid = &s
  39473. }
  39474. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  39475. func (m *WpChatroomMemberMutation) WxWxid() (r string, exists bool) {
  39476. v := m.wx_wxid
  39477. if v == nil {
  39478. return
  39479. }
  39480. return *v, true
  39481. }
  39482. // OldWxWxid returns the old "wx_wxid" field's value of the WpChatroomMember entity.
  39483. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  39484. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39485. func (m *WpChatroomMemberMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  39486. if !m.op.Is(OpUpdateOne) {
  39487. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  39488. }
  39489. if m.id == nil || m.oldValue == nil {
  39490. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  39491. }
  39492. oldValue, err := m.oldValue(ctx)
  39493. if err != nil {
  39494. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  39495. }
  39496. return oldValue.WxWxid, nil
  39497. }
  39498. // ResetWxWxid resets all changes to the "wx_wxid" field.
  39499. func (m *WpChatroomMemberMutation) ResetWxWxid() {
  39500. m.wx_wxid = nil
  39501. }
  39502. // SetWxid sets the "wxid" field.
  39503. func (m *WpChatroomMemberMutation) SetWxid(s string) {
  39504. m.wxid = &s
  39505. }
  39506. // Wxid returns the value of the "wxid" field in the mutation.
  39507. func (m *WpChatroomMemberMutation) Wxid() (r string, exists bool) {
  39508. v := m.wxid
  39509. if v == nil {
  39510. return
  39511. }
  39512. return *v, true
  39513. }
  39514. // OldWxid returns the old "wxid" field's value of the WpChatroomMember entity.
  39515. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  39516. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39517. func (m *WpChatroomMemberMutation) OldWxid(ctx context.Context) (v string, err error) {
  39518. if !m.op.Is(OpUpdateOne) {
  39519. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  39520. }
  39521. if m.id == nil || m.oldValue == nil {
  39522. return v, errors.New("OldWxid requires an ID field in the mutation")
  39523. }
  39524. oldValue, err := m.oldValue(ctx)
  39525. if err != nil {
  39526. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  39527. }
  39528. return oldValue.Wxid, nil
  39529. }
  39530. // ResetWxid resets all changes to the "wxid" field.
  39531. func (m *WpChatroomMemberMutation) ResetWxid() {
  39532. m.wxid = nil
  39533. }
  39534. // SetNickname sets the "nickname" field.
  39535. func (m *WpChatroomMemberMutation) SetNickname(s string) {
  39536. m.nickname = &s
  39537. }
  39538. // Nickname returns the value of the "nickname" field in the mutation.
  39539. func (m *WpChatroomMemberMutation) Nickname() (r string, exists bool) {
  39540. v := m.nickname
  39541. if v == nil {
  39542. return
  39543. }
  39544. return *v, true
  39545. }
  39546. // OldNickname returns the old "nickname" field's value of the WpChatroomMember entity.
  39547. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  39548. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39549. func (m *WpChatroomMemberMutation) OldNickname(ctx context.Context) (v string, err error) {
  39550. if !m.op.Is(OpUpdateOne) {
  39551. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  39552. }
  39553. if m.id == nil || m.oldValue == nil {
  39554. return v, errors.New("OldNickname requires an ID field in the mutation")
  39555. }
  39556. oldValue, err := m.oldValue(ctx)
  39557. if err != nil {
  39558. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  39559. }
  39560. return oldValue.Nickname, nil
  39561. }
  39562. // ResetNickname resets all changes to the "nickname" field.
  39563. func (m *WpChatroomMemberMutation) ResetNickname() {
  39564. m.nickname = nil
  39565. }
  39566. // SetAvatar sets the "avatar" field.
  39567. func (m *WpChatroomMemberMutation) SetAvatar(s string) {
  39568. m.avatar = &s
  39569. }
  39570. // Avatar returns the value of the "avatar" field in the mutation.
  39571. func (m *WpChatroomMemberMutation) Avatar() (r string, exists bool) {
  39572. v := m.avatar
  39573. if v == nil {
  39574. return
  39575. }
  39576. return *v, true
  39577. }
  39578. // OldAvatar returns the old "avatar" field's value of the WpChatroomMember entity.
  39579. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  39580. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39581. func (m *WpChatroomMemberMutation) OldAvatar(ctx context.Context) (v string, err error) {
  39582. if !m.op.Is(OpUpdateOne) {
  39583. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  39584. }
  39585. if m.id == nil || m.oldValue == nil {
  39586. return v, errors.New("OldAvatar requires an ID field in the mutation")
  39587. }
  39588. oldValue, err := m.oldValue(ctx)
  39589. if err != nil {
  39590. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  39591. }
  39592. return oldValue.Avatar, nil
  39593. }
  39594. // ResetAvatar resets all changes to the "avatar" field.
  39595. func (m *WpChatroomMemberMutation) ResetAvatar() {
  39596. m.avatar = nil
  39597. }
  39598. // Where appends a list predicates to the WpChatroomMemberMutation builder.
  39599. func (m *WpChatroomMemberMutation) Where(ps ...predicate.WpChatroomMember) {
  39600. m.predicates = append(m.predicates, ps...)
  39601. }
  39602. // WhereP appends storage-level predicates to the WpChatroomMemberMutation builder. Using this method,
  39603. // users can use type-assertion to append predicates that do not depend on any generated package.
  39604. func (m *WpChatroomMemberMutation) WhereP(ps ...func(*sql.Selector)) {
  39605. p := make([]predicate.WpChatroomMember, len(ps))
  39606. for i := range ps {
  39607. p[i] = ps[i]
  39608. }
  39609. m.Where(p...)
  39610. }
  39611. // Op returns the operation name.
  39612. func (m *WpChatroomMemberMutation) Op() Op {
  39613. return m.op
  39614. }
  39615. // SetOp allows setting the mutation operation.
  39616. func (m *WpChatroomMemberMutation) SetOp(op Op) {
  39617. m.op = op
  39618. }
  39619. // Type returns the node type of this mutation (WpChatroomMember).
  39620. func (m *WpChatroomMemberMutation) Type() string {
  39621. return m.typ
  39622. }
  39623. // Fields returns all fields that were changed during this mutation. Note that in
  39624. // order to get all numeric fields that were incremented/decremented, call
  39625. // AddedFields().
  39626. func (m *WpChatroomMemberMutation) Fields() []string {
  39627. fields := make([]string, 0, 7)
  39628. if m.created_at != nil {
  39629. fields = append(fields, wpchatroommember.FieldCreatedAt)
  39630. }
  39631. if m.updated_at != nil {
  39632. fields = append(fields, wpchatroommember.FieldUpdatedAt)
  39633. }
  39634. if m.status != nil {
  39635. fields = append(fields, wpchatroommember.FieldStatus)
  39636. }
  39637. if m.wx_wxid != nil {
  39638. fields = append(fields, wpchatroommember.FieldWxWxid)
  39639. }
  39640. if m.wxid != nil {
  39641. fields = append(fields, wpchatroommember.FieldWxid)
  39642. }
  39643. if m.nickname != nil {
  39644. fields = append(fields, wpchatroommember.FieldNickname)
  39645. }
  39646. if m.avatar != nil {
  39647. fields = append(fields, wpchatroommember.FieldAvatar)
  39648. }
  39649. return fields
  39650. }
  39651. // Field returns the value of a field with the given name. The second boolean
  39652. // return value indicates that this field was not set, or was not defined in the
  39653. // schema.
  39654. func (m *WpChatroomMemberMutation) Field(name string) (ent.Value, bool) {
  39655. switch name {
  39656. case wpchatroommember.FieldCreatedAt:
  39657. return m.CreatedAt()
  39658. case wpchatroommember.FieldUpdatedAt:
  39659. return m.UpdatedAt()
  39660. case wpchatroommember.FieldStatus:
  39661. return m.Status()
  39662. case wpchatroommember.FieldWxWxid:
  39663. return m.WxWxid()
  39664. case wpchatroommember.FieldWxid:
  39665. return m.Wxid()
  39666. case wpchatroommember.FieldNickname:
  39667. return m.Nickname()
  39668. case wpchatroommember.FieldAvatar:
  39669. return m.Avatar()
  39670. }
  39671. return nil, false
  39672. }
  39673. // OldField returns the old value of the field from the database. An error is
  39674. // returned if the mutation operation is not UpdateOne, or the query to the
  39675. // database failed.
  39676. func (m *WpChatroomMemberMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  39677. switch name {
  39678. case wpchatroommember.FieldCreatedAt:
  39679. return m.OldCreatedAt(ctx)
  39680. case wpchatroommember.FieldUpdatedAt:
  39681. return m.OldUpdatedAt(ctx)
  39682. case wpchatroommember.FieldStatus:
  39683. return m.OldStatus(ctx)
  39684. case wpchatroommember.FieldWxWxid:
  39685. return m.OldWxWxid(ctx)
  39686. case wpchatroommember.FieldWxid:
  39687. return m.OldWxid(ctx)
  39688. case wpchatroommember.FieldNickname:
  39689. return m.OldNickname(ctx)
  39690. case wpchatroommember.FieldAvatar:
  39691. return m.OldAvatar(ctx)
  39692. }
  39693. return nil, fmt.Errorf("unknown WpChatroomMember field %s", name)
  39694. }
  39695. // SetField sets the value of a field with the given name. It returns an error if
  39696. // the field is not defined in the schema, or if the type mismatched the field
  39697. // type.
  39698. func (m *WpChatroomMemberMutation) SetField(name string, value ent.Value) error {
  39699. switch name {
  39700. case wpchatroommember.FieldCreatedAt:
  39701. v, ok := value.(time.Time)
  39702. if !ok {
  39703. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39704. }
  39705. m.SetCreatedAt(v)
  39706. return nil
  39707. case wpchatroommember.FieldUpdatedAt:
  39708. v, ok := value.(time.Time)
  39709. if !ok {
  39710. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39711. }
  39712. m.SetUpdatedAt(v)
  39713. return nil
  39714. case wpchatroommember.FieldStatus:
  39715. v, ok := value.(uint8)
  39716. if !ok {
  39717. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39718. }
  39719. m.SetStatus(v)
  39720. return nil
  39721. case wpchatroommember.FieldWxWxid:
  39722. v, ok := value.(string)
  39723. if !ok {
  39724. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39725. }
  39726. m.SetWxWxid(v)
  39727. return nil
  39728. case wpchatroommember.FieldWxid:
  39729. v, ok := value.(string)
  39730. if !ok {
  39731. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39732. }
  39733. m.SetWxid(v)
  39734. return nil
  39735. case wpchatroommember.FieldNickname:
  39736. v, ok := value.(string)
  39737. if !ok {
  39738. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39739. }
  39740. m.SetNickname(v)
  39741. return nil
  39742. case wpchatroommember.FieldAvatar:
  39743. v, ok := value.(string)
  39744. if !ok {
  39745. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39746. }
  39747. m.SetAvatar(v)
  39748. return nil
  39749. }
  39750. return fmt.Errorf("unknown WpChatroomMember field %s", name)
  39751. }
  39752. // AddedFields returns all numeric fields that were incremented/decremented during
  39753. // this mutation.
  39754. func (m *WpChatroomMemberMutation) AddedFields() []string {
  39755. var fields []string
  39756. if m.addstatus != nil {
  39757. fields = append(fields, wpchatroommember.FieldStatus)
  39758. }
  39759. return fields
  39760. }
  39761. // AddedField returns the numeric value that was incremented/decremented on a field
  39762. // with the given name. The second boolean return value indicates that this field
  39763. // was not set, or was not defined in the schema.
  39764. func (m *WpChatroomMemberMutation) AddedField(name string) (ent.Value, bool) {
  39765. switch name {
  39766. case wpchatroommember.FieldStatus:
  39767. return m.AddedStatus()
  39768. }
  39769. return nil, false
  39770. }
  39771. // AddField adds the value to the field with the given name. It returns an error if
  39772. // the field is not defined in the schema, or if the type mismatched the field
  39773. // type.
  39774. func (m *WpChatroomMemberMutation) AddField(name string, value ent.Value) error {
  39775. switch name {
  39776. case wpchatroommember.FieldStatus:
  39777. v, ok := value.(int8)
  39778. if !ok {
  39779. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39780. }
  39781. m.AddStatus(v)
  39782. return nil
  39783. }
  39784. return fmt.Errorf("unknown WpChatroomMember numeric field %s", name)
  39785. }
  39786. // ClearedFields returns all nullable fields that were cleared during this
  39787. // mutation.
  39788. func (m *WpChatroomMemberMutation) ClearedFields() []string {
  39789. var fields []string
  39790. if m.FieldCleared(wpchatroommember.FieldStatus) {
  39791. fields = append(fields, wpchatroommember.FieldStatus)
  39792. }
  39793. return fields
  39794. }
  39795. // FieldCleared returns a boolean indicating if a field with the given name was
  39796. // cleared in this mutation.
  39797. func (m *WpChatroomMemberMutation) FieldCleared(name string) bool {
  39798. _, ok := m.clearedFields[name]
  39799. return ok
  39800. }
  39801. // ClearField clears the value of the field with the given name. It returns an
  39802. // error if the field is not defined in the schema.
  39803. func (m *WpChatroomMemberMutation) ClearField(name string) error {
  39804. switch name {
  39805. case wpchatroommember.FieldStatus:
  39806. m.ClearStatus()
  39807. return nil
  39808. }
  39809. return fmt.Errorf("unknown WpChatroomMember nullable field %s", name)
  39810. }
  39811. // ResetField resets all changes in the mutation for the field with the given name.
  39812. // It returns an error if the field is not defined in the schema.
  39813. func (m *WpChatroomMemberMutation) ResetField(name string) error {
  39814. switch name {
  39815. case wpchatroommember.FieldCreatedAt:
  39816. m.ResetCreatedAt()
  39817. return nil
  39818. case wpchatroommember.FieldUpdatedAt:
  39819. m.ResetUpdatedAt()
  39820. return nil
  39821. case wpchatroommember.FieldStatus:
  39822. m.ResetStatus()
  39823. return nil
  39824. case wpchatroommember.FieldWxWxid:
  39825. m.ResetWxWxid()
  39826. return nil
  39827. case wpchatroommember.FieldWxid:
  39828. m.ResetWxid()
  39829. return nil
  39830. case wpchatroommember.FieldNickname:
  39831. m.ResetNickname()
  39832. return nil
  39833. case wpchatroommember.FieldAvatar:
  39834. m.ResetAvatar()
  39835. return nil
  39836. }
  39837. return fmt.Errorf("unknown WpChatroomMember field %s", name)
  39838. }
  39839. // AddedEdges returns all edge names that were set/added in this mutation.
  39840. func (m *WpChatroomMemberMutation) AddedEdges() []string {
  39841. edges := make([]string, 0, 0)
  39842. return edges
  39843. }
  39844. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  39845. // name in this mutation.
  39846. func (m *WpChatroomMemberMutation) AddedIDs(name string) []ent.Value {
  39847. return nil
  39848. }
  39849. // RemovedEdges returns all edge names that were removed in this mutation.
  39850. func (m *WpChatroomMemberMutation) RemovedEdges() []string {
  39851. edges := make([]string, 0, 0)
  39852. return edges
  39853. }
  39854. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  39855. // the given name in this mutation.
  39856. func (m *WpChatroomMemberMutation) RemovedIDs(name string) []ent.Value {
  39857. return nil
  39858. }
  39859. // ClearedEdges returns all edge names that were cleared in this mutation.
  39860. func (m *WpChatroomMemberMutation) ClearedEdges() []string {
  39861. edges := make([]string, 0, 0)
  39862. return edges
  39863. }
  39864. // EdgeCleared returns a boolean which indicates if the edge with the given name
  39865. // was cleared in this mutation.
  39866. func (m *WpChatroomMemberMutation) EdgeCleared(name string) bool {
  39867. return false
  39868. }
  39869. // ClearEdge clears the value of the edge with the given name. It returns an error
  39870. // if that edge is not defined in the schema.
  39871. func (m *WpChatroomMemberMutation) ClearEdge(name string) error {
  39872. return fmt.Errorf("unknown WpChatroomMember unique edge %s", name)
  39873. }
  39874. // ResetEdge resets all changes to the edge with the given name in this mutation.
  39875. // It returns an error if the edge is not defined in the schema.
  39876. func (m *WpChatroomMemberMutation) ResetEdge(name string) error {
  39877. return fmt.Errorf("unknown WpChatroomMember edge %s", name)
  39878. }
  39879. // WxMutation represents an operation that mutates the Wx nodes in the graph.
  39880. type WxMutation struct {
  39881. config
  39882. op Op
  39883. typ string
  39884. id *uint64
  39885. created_at *time.Time
  39886. updated_at *time.Time
  39887. status *uint8
  39888. addstatus *int8
  39889. deleted_at *time.Time
  39890. port *string
  39891. process_id *string
  39892. callback *string
  39893. wxid *string
  39894. account *string
  39895. nickname *string
  39896. tel *string
  39897. head_big *string
  39898. organization_id *uint64
  39899. addorganization_id *int64
  39900. api_base *string
  39901. api_key *string
  39902. allow_list *[]string
  39903. appendallow_list []string
  39904. group_allow_list *[]string
  39905. appendgroup_allow_list []string
  39906. block_list *[]string
  39907. appendblock_list []string
  39908. group_block_list *[]string
  39909. appendgroup_block_list []string
  39910. clearedFields map[string]struct{}
  39911. server *uint64
  39912. clearedserver bool
  39913. agent *uint64
  39914. clearedagent bool
  39915. done bool
  39916. oldValue func(context.Context) (*Wx, error)
  39917. predicates []predicate.Wx
  39918. }
  39919. var _ ent.Mutation = (*WxMutation)(nil)
  39920. // wxOption allows management of the mutation configuration using functional options.
  39921. type wxOption func(*WxMutation)
  39922. // newWxMutation creates new mutation for the Wx entity.
  39923. func newWxMutation(c config, op Op, opts ...wxOption) *WxMutation {
  39924. m := &WxMutation{
  39925. config: c,
  39926. op: op,
  39927. typ: TypeWx,
  39928. clearedFields: make(map[string]struct{}),
  39929. }
  39930. for _, opt := range opts {
  39931. opt(m)
  39932. }
  39933. return m
  39934. }
  39935. // withWxID sets the ID field of the mutation.
  39936. func withWxID(id uint64) wxOption {
  39937. return func(m *WxMutation) {
  39938. var (
  39939. err error
  39940. once sync.Once
  39941. value *Wx
  39942. )
  39943. m.oldValue = func(ctx context.Context) (*Wx, error) {
  39944. once.Do(func() {
  39945. if m.done {
  39946. err = errors.New("querying old values post mutation is not allowed")
  39947. } else {
  39948. value, err = m.Client().Wx.Get(ctx, id)
  39949. }
  39950. })
  39951. return value, err
  39952. }
  39953. m.id = &id
  39954. }
  39955. }
  39956. // withWx sets the old Wx of the mutation.
  39957. func withWx(node *Wx) wxOption {
  39958. return func(m *WxMutation) {
  39959. m.oldValue = func(context.Context) (*Wx, error) {
  39960. return node, nil
  39961. }
  39962. m.id = &node.ID
  39963. }
  39964. }
  39965. // Client returns a new `ent.Client` from the mutation. If the mutation was
  39966. // executed in a transaction (ent.Tx), a transactional client is returned.
  39967. func (m WxMutation) Client() *Client {
  39968. client := &Client{config: m.config}
  39969. client.init()
  39970. return client
  39971. }
  39972. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  39973. // it returns an error otherwise.
  39974. func (m WxMutation) Tx() (*Tx, error) {
  39975. if _, ok := m.driver.(*txDriver); !ok {
  39976. return nil, errors.New("ent: mutation is not running in a transaction")
  39977. }
  39978. tx := &Tx{config: m.config}
  39979. tx.init()
  39980. return tx, nil
  39981. }
  39982. // SetID sets the value of the id field. Note that this
  39983. // operation is only accepted on creation of Wx entities.
  39984. func (m *WxMutation) SetID(id uint64) {
  39985. m.id = &id
  39986. }
  39987. // ID returns the ID value in the mutation. Note that the ID is only available
  39988. // if it was provided to the builder or after it was returned from the database.
  39989. func (m *WxMutation) ID() (id uint64, exists bool) {
  39990. if m.id == nil {
  39991. return
  39992. }
  39993. return *m.id, true
  39994. }
  39995. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  39996. // That means, if the mutation is applied within a transaction with an isolation level such
  39997. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  39998. // or updated by the mutation.
  39999. func (m *WxMutation) IDs(ctx context.Context) ([]uint64, error) {
  40000. switch {
  40001. case m.op.Is(OpUpdateOne | OpDeleteOne):
  40002. id, exists := m.ID()
  40003. if exists {
  40004. return []uint64{id}, nil
  40005. }
  40006. fallthrough
  40007. case m.op.Is(OpUpdate | OpDelete):
  40008. return m.Client().Wx.Query().Where(m.predicates...).IDs(ctx)
  40009. default:
  40010. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  40011. }
  40012. }
  40013. // SetCreatedAt sets the "created_at" field.
  40014. func (m *WxMutation) SetCreatedAt(t time.Time) {
  40015. m.created_at = &t
  40016. }
  40017. // CreatedAt returns the value of the "created_at" field in the mutation.
  40018. func (m *WxMutation) CreatedAt() (r time.Time, exists bool) {
  40019. v := m.created_at
  40020. if v == nil {
  40021. return
  40022. }
  40023. return *v, true
  40024. }
  40025. // OldCreatedAt returns the old "created_at" field's value of the Wx entity.
  40026. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40027. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40028. func (m *WxMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  40029. if !m.op.Is(OpUpdateOne) {
  40030. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  40031. }
  40032. if m.id == nil || m.oldValue == nil {
  40033. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  40034. }
  40035. oldValue, err := m.oldValue(ctx)
  40036. if err != nil {
  40037. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  40038. }
  40039. return oldValue.CreatedAt, nil
  40040. }
  40041. // ResetCreatedAt resets all changes to the "created_at" field.
  40042. func (m *WxMutation) ResetCreatedAt() {
  40043. m.created_at = nil
  40044. }
  40045. // SetUpdatedAt sets the "updated_at" field.
  40046. func (m *WxMutation) SetUpdatedAt(t time.Time) {
  40047. m.updated_at = &t
  40048. }
  40049. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  40050. func (m *WxMutation) UpdatedAt() (r time.Time, exists bool) {
  40051. v := m.updated_at
  40052. if v == nil {
  40053. return
  40054. }
  40055. return *v, true
  40056. }
  40057. // OldUpdatedAt returns the old "updated_at" field's value of the Wx entity.
  40058. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40059. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40060. func (m *WxMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  40061. if !m.op.Is(OpUpdateOne) {
  40062. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  40063. }
  40064. if m.id == nil || m.oldValue == nil {
  40065. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  40066. }
  40067. oldValue, err := m.oldValue(ctx)
  40068. if err != nil {
  40069. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  40070. }
  40071. return oldValue.UpdatedAt, nil
  40072. }
  40073. // ResetUpdatedAt resets all changes to the "updated_at" field.
  40074. func (m *WxMutation) ResetUpdatedAt() {
  40075. m.updated_at = nil
  40076. }
  40077. // SetStatus sets the "status" field.
  40078. func (m *WxMutation) SetStatus(u uint8) {
  40079. m.status = &u
  40080. m.addstatus = nil
  40081. }
  40082. // Status returns the value of the "status" field in the mutation.
  40083. func (m *WxMutation) Status() (r uint8, exists bool) {
  40084. v := m.status
  40085. if v == nil {
  40086. return
  40087. }
  40088. return *v, true
  40089. }
  40090. // OldStatus returns the old "status" field's value of the Wx entity.
  40091. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40092. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40093. func (m *WxMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  40094. if !m.op.Is(OpUpdateOne) {
  40095. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  40096. }
  40097. if m.id == nil || m.oldValue == nil {
  40098. return v, errors.New("OldStatus requires an ID field in the mutation")
  40099. }
  40100. oldValue, err := m.oldValue(ctx)
  40101. if err != nil {
  40102. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  40103. }
  40104. return oldValue.Status, nil
  40105. }
  40106. // AddStatus adds u to the "status" field.
  40107. func (m *WxMutation) AddStatus(u int8) {
  40108. if m.addstatus != nil {
  40109. *m.addstatus += u
  40110. } else {
  40111. m.addstatus = &u
  40112. }
  40113. }
  40114. // AddedStatus returns the value that was added to the "status" field in this mutation.
  40115. func (m *WxMutation) AddedStatus() (r int8, exists bool) {
  40116. v := m.addstatus
  40117. if v == nil {
  40118. return
  40119. }
  40120. return *v, true
  40121. }
  40122. // ClearStatus clears the value of the "status" field.
  40123. func (m *WxMutation) ClearStatus() {
  40124. m.status = nil
  40125. m.addstatus = nil
  40126. m.clearedFields[wx.FieldStatus] = struct{}{}
  40127. }
  40128. // StatusCleared returns if the "status" field was cleared in this mutation.
  40129. func (m *WxMutation) StatusCleared() bool {
  40130. _, ok := m.clearedFields[wx.FieldStatus]
  40131. return ok
  40132. }
  40133. // ResetStatus resets all changes to the "status" field.
  40134. func (m *WxMutation) ResetStatus() {
  40135. m.status = nil
  40136. m.addstatus = nil
  40137. delete(m.clearedFields, wx.FieldStatus)
  40138. }
  40139. // SetDeletedAt sets the "deleted_at" field.
  40140. func (m *WxMutation) SetDeletedAt(t time.Time) {
  40141. m.deleted_at = &t
  40142. }
  40143. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  40144. func (m *WxMutation) DeletedAt() (r time.Time, exists bool) {
  40145. v := m.deleted_at
  40146. if v == nil {
  40147. return
  40148. }
  40149. return *v, true
  40150. }
  40151. // OldDeletedAt returns the old "deleted_at" field's value of the Wx entity.
  40152. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40153. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40154. func (m *WxMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  40155. if !m.op.Is(OpUpdateOne) {
  40156. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  40157. }
  40158. if m.id == nil || m.oldValue == nil {
  40159. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  40160. }
  40161. oldValue, err := m.oldValue(ctx)
  40162. if err != nil {
  40163. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  40164. }
  40165. return oldValue.DeletedAt, nil
  40166. }
  40167. // ClearDeletedAt clears the value of the "deleted_at" field.
  40168. func (m *WxMutation) ClearDeletedAt() {
  40169. m.deleted_at = nil
  40170. m.clearedFields[wx.FieldDeletedAt] = struct{}{}
  40171. }
  40172. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  40173. func (m *WxMutation) DeletedAtCleared() bool {
  40174. _, ok := m.clearedFields[wx.FieldDeletedAt]
  40175. return ok
  40176. }
  40177. // ResetDeletedAt resets all changes to the "deleted_at" field.
  40178. func (m *WxMutation) ResetDeletedAt() {
  40179. m.deleted_at = nil
  40180. delete(m.clearedFields, wx.FieldDeletedAt)
  40181. }
  40182. // SetServerID sets the "server_id" field.
  40183. func (m *WxMutation) SetServerID(u uint64) {
  40184. m.server = &u
  40185. }
  40186. // ServerID returns the value of the "server_id" field in the mutation.
  40187. func (m *WxMutation) ServerID() (r uint64, exists bool) {
  40188. v := m.server
  40189. if v == nil {
  40190. return
  40191. }
  40192. return *v, true
  40193. }
  40194. // OldServerID returns the old "server_id" field's value of the Wx entity.
  40195. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40196. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40197. func (m *WxMutation) OldServerID(ctx context.Context) (v uint64, err error) {
  40198. if !m.op.Is(OpUpdateOne) {
  40199. return v, errors.New("OldServerID is only allowed on UpdateOne operations")
  40200. }
  40201. if m.id == nil || m.oldValue == nil {
  40202. return v, errors.New("OldServerID requires an ID field in the mutation")
  40203. }
  40204. oldValue, err := m.oldValue(ctx)
  40205. if err != nil {
  40206. return v, fmt.Errorf("querying old value for OldServerID: %w", err)
  40207. }
  40208. return oldValue.ServerID, nil
  40209. }
  40210. // ClearServerID clears the value of the "server_id" field.
  40211. func (m *WxMutation) ClearServerID() {
  40212. m.server = nil
  40213. m.clearedFields[wx.FieldServerID] = struct{}{}
  40214. }
  40215. // ServerIDCleared returns if the "server_id" field was cleared in this mutation.
  40216. func (m *WxMutation) ServerIDCleared() bool {
  40217. _, ok := m.clearedFields[wx.FieldServerID]
  40218. return ok
  40219. }
  40220. // ResetServerID resets all changes to the "server_id" field.
  40221. func (m *WxMutation) ResetServerID() {
  40222. m.server = nil
  40223. delete(m.clearedFields, wx.FieldServerID)
  40224. }
  40225. // SetPort sets the "port" field.
  40226. func (m *WxMutation) SetPort(s string) {
  40227. m.port = &s
  40228. }
  40229. // Port returns the value of the "port" field in the mutation.
  40230. func (m *WxMutation) Port() (r string, exists bool) {
  40231. v := m.port
  40232. if v == nil {
  40233. return
  40234. }
  40235. return *v, true
  40236. }
  40237. // OldPort returns the old "port" field's value of the Wx entity.
  40238. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40239. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40240. func (m *WxMutation) OldPort(ctx context.Context) (v string, err error) {
  40241. if !m.op.Is(OpUpdateOne) {
  40242. return v, errors.New("OldPort is only allowed on UpdateOne operations")
  40243. }
  40244. if m.id == nil || m.oldValue == nil {
  40245. return v, errors.New("OldPort requires an ID field in the mutation")
  40246. }
  40247. oldValue, err := m.oldValue(ctx)
  40248. if err != nil {
  40249. return v, fmt.Errorf("querying old value for OldPort: %w", err)
  40250. }
  40251. return oldValue.Port, nil
  40252. }
  40253. // ResetPort resets all changes to the "port" field.
  40254. func (m *WxMutation) ResetPort() {
  40255. m.port = nil
  40256. }
  40257. // SetProcessID sets the "process_id" field.
  40258. func (m *WxMutation) SetProcessID(s string) {
  40259. m.process_id = &s
  40260. }
  40261. // ProcessID returns the value of the "process_id" field in the mutation.
  40262. func (m *WxMutation) ProcessID() (r string, exists bool) {
  40263. v := m.process_id
  40264. if v == nil {
  40265. return
  40266. }
  40267. return *v, true
  40268. }
  40269. // OldProcessID returns the old "process_id" field's value of the Wx entity.
  40270. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40271. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40272. func (m *WxMutation) OldProcessID(ctx context.Context) (v string, err error) {
  40273. if !m.op.Is(OpUpdateOne) {
  40274. return v, errors.New("OldProcessID is only allowed on UpdateOne operations")
  40275. }
  40276. if m.id == nil || m.oldValue == nil {
  40277. return v, errors.New("OldProcessID requires an ID field in the mutation")
  40278. }
  40279. oldValue, err := m.oldValue(ctx)
  40280. if err != nil {
  40281. return v, fmt.Errorf("querying old value for OldProcessID: %w", err)
  40282. }
  40283. return oldValue.ProcessID, nil
  40284. }
  40285. // ResetProcessID resets all changes to the "process_id" field.
  40286. func (m *WxMutation) ResetProcessID() {
  40287. m.process_id = nil
  40288. }
  40289. // SetCallback sets the "callback" field.
  40290. func (m *WxMutation) SetCallback(s string) {
  40291. m.callback = &s
  40292. }
  40293. // Callback returns the value of the "callback" field in the mutation.
  40294. func (m *WxMutation) Callback() (r string, exists bool) {
  40295. v := m.callback
  40296. if v == nil {
  40297. return
  40298. }
  40299. return *v, true
  40300. }
  40301. // OldCallback returns the old "callback" field's value of the Wx entity.
  40302. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40303. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40304. func (m *WxMutation) OldCallback(ctx context.Context) (v string, err error) {
  40305. if !m.op.Is(OpUpdateOne) {
  40306. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  40307. }
  40308. if m.id == nil || m.oldValue == nil {
  40309. return v, errors.New("OldCallback requires an ID field in the mutation")
  40310. }
  40311. oldValue, err := m.oldValue(ctx)
  40312. if err != nil {
  40313. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  40314. }
  40315. return oldValue.Callback, nil
  40316. }
  40317. // ResetCallback resets all changes to the "callback" field.
  40318. func (m *WxMutation) ResetCallback() {
  40319. m.callback = nil
  40320. }
  40321. // SetWxid sets the "wxid" field.
  40322. func (m *WxMutation) SetWxid(s string) {
  40323. m.wxid = &s
  40324. }
  40325. // Wxid returns the value of the "wxid" field in the mutation.
  40326. func (m *WxMutation) Wxid() (r string, exists bool) {
  40327. v := m.wxid
  40328. if v == nil {
  40329. return
  40330. }
  40331. return *v, true
  40332. }
  40333. // OldWxid returns the old "wxid" field's value of the Wx entity.
  40334. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40335. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40336. func (m *WxMutation) OldWxid(ctx context.Context) (v string, err error) {
  40337. if !m.op.Is(OpUpdateOne) {
  40338. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  40339. }
  40340. if m.id == nil || m.oldValue == nil {
  40341. return v, errors.New("OldWxid requires an ID field in the mutation")
  40342. }
  40343. oldValue, err := m.oldValue(ctx)
  40344. if err != nil {
  40345. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  40346. }
  40347. return oldValue.Wxid, nil
  40348. }
  40349. // ResetWxid resets all changes to the "wxid" field.
  40350. func (m *WxMutation) ResetWxid() {
  40351. m.wxid = nil
  40352. }
  40353. // SetAccount sets the "account" field.
  40354. func (m *WxMutation) SetAccount(s string) {
  40355. m.account = &s
  40356. }
  40357. // Account returns the value of the "account" field in the mutation.
  40358. func (m *WxMutation) Account() (r string, exists bool) {
  40359. v := m.account
  40360. if v == nil {
  40361. return
  40362. }
  40363. return *v, true
  40364. }
  40365. // OldAccount returns the old "account" field's value of the Wx entity.
  40366. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40367. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40368. func (m *WxMutation) OldAccount(ctx context.Context) (v string, err error) {
  40369. if !m.op.Is(OpUpdateOne) {
  40370. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  40371. }
  40372. if m.id == nil || m.oldValue == nil {
  40373. return v, errors.New("OldAccount requires an ID field in the mutation")
  40374. }
  40375. oldValue, err := m.oldValue(ctx)
  40376. if err != nil {
  40377. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  40378. }
  40379. return oldValue.Account, nil
  40380. }
  40381. // ResetAccount resets all changes to the "account" field.
  40382. func (m *WxMutation) ResetAccount() {
  40383. m.account = nil
  40384. }
  40385. // SetNickname sets the "nickname" field.
  40386. func (m *WxMutation) SetNickname(s string) {
  40387. m.nickname = &s
  40388. }
  40389. // Nickname returns the value of the "nickname" field in the mutation.
  40390. func (m *WxMutation) Nickname() (r string, exists bool) {
  40391. v := m.nickname
  40392. if v == nil {
  40393. return
  40394. }
  40395. return *v, true
  40396. }
  40397. // OldNickname returns the old "nickname" field's value of the Wx entity.
  40398. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40399. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40400. func (m *WxMutation) OldNickname(ctx context.Context) (v string, err error) {
  40401. if !m.op.Is(OpUpdateOne) {
  40402. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  40403. }
  40404. if m.id == nil || m.oldValue == nil {
  40405. return v, errors.New("OldNickname requires an ID field in the mutation")
  40406. }
  40407. oldValue, err := m.oldValue(ctx)
  40408. if err != nil {
  40409. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  40410. }
  40411. return oldValue.Nickname, nil
  40412. }
  40413. // ResetNickname resets all changes to the "nickname" field.
  40414. func (m *WxMutation) ResetNickname() {
  40415. m.nickname = nil
  40416. }
  40417. // SetTel sets the "tel" field.
  40418. func (m *WxMutation) SetTel(s string) {
  40419. m.tel = &s
  40420. }
  40421. // Tel returns the value of the "tel" field in the mutation.
  40422. func (m *WxMutation) Tel() (r string, exists bool) {
  40423. v := m.tel
  40424. if v == nil {
  40425. return
  40426. }
  40427. return *v, true
  40428. }
  40429. // OldTel returns the old "tel" field's value of the Wx entity.
  40430. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40431. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40432. func (m *WxMutation) OldTel(ctx context.Context) (v string, err error) {
  40433. if !m.op.Is(OpUpdateOne) {
  40434. return v, errors.New("OldTel is only allowed on UpdateOne operations")
  40435. }
  40436. if m.id == nil || m.oldValue == nil {
  40437. return v, errors.New("OldTel requires an ID field in the mutation")
  40438. }
  40439. oldValue, err := m.oldValue(ctx)
  40440. if err != nil {
  40441. return v, fmt.Errorf("querying old value for OldTel: %w", err)
  40442. }
  40443. return oldValue.Tel, nil
  40444. }
  40445. // ResetTel resets all changes to the "tel" field.
  40446. func (m *WxMutation) ResetTel() {
  40447. m.tel = nil
  40448. }
  40449. // SetHeadBig sets the "head_big" field.
  40450. func (m *WxMutation) SetHeadBig(s string) {
  40451. m.head_big = &s
  40452. }
  40453. // HeadBig returns the value of the "head_big" field in the mutation.
  40454. func (m *WxMutation) HeadBig() (r string, exists bool) {
  40455. v := m.head_big
  40456. if v == nil {
  40457. return
  40458. }
  40459. return *v, true
  40460. }
  40461. // OldHeadBig returns the old "head_big" field's value of the Wx entity.
  40462. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40463. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40464. func (m *WxMutation) OldHeadBig(ctx context.Context) (v string, err error) {
  40465. if !m.op.Is(OpUpdateOne) {
  40466. return v, errors.New("OldHeadBig is only allowed on UpdateOne operations")
  40467. }
  40468. if m.id == nil || m.oldValue == nil {
  40469. return v, errors.New("OldHeadBig requires an ID field in the mutation")
  40470. }
  40471. oldValue, err := m.oldValue(ctx)
  40472. if err != nil {
  40473. return v, fmt.Errorf("querying old value for OldHeadBig: %w", err)
  40474. }
  40475. return oldValue.HeadBig, nil
  40476. }
  40477. // ResetHeadBig resets all changes to the "head_big" field.
  40478. func (m *WxMutation) ResetHeadBig() {
  40479. m.head_big = nil
  40480. }
  40481. // SetOrganizationID sets the "organization_id" field.
  40482. func (m *WxMutation) SetOrganizationID(u uint64) {
  40483. m.organization_id = &u
  40484. m.addorganization_id = nil
  40485. }
  40486. // OrganizationID returns the value of the "organization_id" field in the mutation.
  40487. func (m *WxMutation) OrganizationID() (r uint64, exists bool) {
  40488. v := m.organization_id
  40489. if v == nil {
  40490. return
  40491. }
  40492. return *v, true
  40493. }
  40494. // OldOrganizationID returns the old "organization_id" field's value of the Wx entity.
  40495. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40496. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40497. func (m *WxMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  40498. if !m.op.Is(OpUpdateOne) {
  40499. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  40500. }
  40501. if m.id == nil || m.oldValue == nil {
  40502. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  40503. }
  40504. oldValue, err := m.oldValue(ctx)
  40505. if err != nil {
  40506. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  40507. }
  40508. return oldValue.OrganizationID, nil
  40509. }
  40510. // AddOrganizationID adds u to the "organization_id" field.
  40511. func (m *WxMutation) AddOrganizationID(u int64) {
  40512. if m.addorganization_id != nil {
  40513. *m.addorganization_id += u
  40514. } else {
  40515. m.addorganization_id = &u
  40516. }
  40517. }
  40518. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  40519. func (m *WxMutation) AddedOrganizationID() (r int64, exists bool) {
  40520. v := m.addorganization_id
  40521. if v == nil {
  40522. return
  40523. }
  40524. return *v, true
  40525. }
  40526. // ClearOrganizationID clears the value of the "organization_id" field.
  40527. func (m *WxMutation) ClearOrganizationID() {
  40528. m.organization_id = nil
  40529. m.addorganization_id = nil
  40530. m.clearedFields[wx.FieldOrganizationID] = struct{}{}
  40531. }
  40532. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  40533. func (m *WxMutation) OrganizationIDCleared() bool {
  40534. _, ok := m.clearedFields[wx.FieldOrganizationID]
  40535. return ok
  40536. }
  40537. // ResetOrganizationID resets all changes to the "organization_id" field.
  40538. func (m *WxMutation) ResetOrganizationID() {
  40539. m.organization_id = nil
  40540. m.addorganization_id = nil
  40541. delete(m.clearedFields, wx.FieldOrganizationID)
  40542. }
  40543. // SetAgentID sets the "agent_id" field.
  40544. func (m *WxMutation) SetAgentID(u uint64) {
  40545. m.agent = &u
  40546. }
  40547. // AgentID returns the value of the "agent_id" field in the mutation.
  40548. func (m *WxMutation) AgentID() (r uint64, exists bool) {
  40549. v := m.agent
  40550. if v == nil {
  40551. return
  40552. }
  40553. return *v, true
  40554. }
  40555. // OldAgentID returns the old "agent_id" field's value of the Wx entity.
  40556. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40557. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40558. func (m *WxMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  40559. if !m.op.Is(OpUpdateOne) {
  40560. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  40561. }
  40562. if m.id == nil || m.oldValue == nil {
  40563. return v, errors.New("OldAgentID requires an ID field in the mutation")
  40564. }
  40565. oldValue, err := m.oldValue(ctx)
  40566. if err != nil {
  40567. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  40568. }
  40569. return oldValue.AgentID, nil
  40570. }
  40571. // ResetAgentID resets all changes to the "agent_id" field.
  40572. func (m *WxMutation) ResetAgentID() {
  40573. m.agent = nil
  40574. }
  40575. // SetAPIBase sets the "api_base" field.
  40576. func (m *WxMutation) SetAPIBase(s string) {
  40577. m.api_base = &s
  40578. }
  40579. // APIBase returns the value of the "api_base" field in the mutation.
  40580. func (m *WxMutation) APIBase() (r string, exists bool) {
  40581. v := m.api_base
  40582. if v == nil {
  40583. return
  40584. }
  40585. return *v, true
  40586. }
  40587. // OldAPIBase returns the old "api_base" field's value of the Wx entity.
  40588. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40589. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40590. func (m *WxMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  40591. if !m.op.Is(OpUpdateOne) {
  40592. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  40593. }
  40594. if m.id == nil || m.oldValue == nil {
  40595. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  40596. }
  40597. oldValue, err := m.oldValue(ctx)
  40598. if err != nil {
  40599. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  40600. }
  40601. return oldValue.APIBase, nil
  40602. }
  40603. // ClearAPIBase clears the value of the "api_base" field.
  40604. func (m *WxMutation) ClearAPIBase() {
  40605. m.api_base = nil
  40606. m.clearedFields[wx.FieldAPIBase] = struct{}{}
  40607. }
  40608. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  40609. func (m *WxMutation) APIBaseCleared() bool {
  40610. _, ok := m.clearedFields[wx.FieldAPIBase]
  40611. return ok
  40612. }
  40613. // ResetAPIBase resets all changes to the "api_base" field.
  40614. func (m *WxMutation) ResetAPIBase() {
  40615. m.api_base = nil
  40616. delete(m.clearedFields, wx.FieldAPIBase)
  40617. }
  40618. // SetAPIKey sets the "api_key" field.
  40619. func (m *WxMutation) SetAPIKey(s string) {
  40620. m.api_key = &s
  40621. }
  40622. // APIKey returns the value of the "api_key" field in the mutation.
  40623. func (m *WxMutation) APIKey() (r string, exists bool) {
  40624. v := m.api_key
  40625. if v == nil {
  40626. return
  40627. }
  40628. return *v, true
  40629. }
  40630. // OldAPIKey returns the old "api_key" field's value of the Wx entity.
  40631. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40632. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40633. func (m *WxMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  40634. if !m.op.Is(OpUpdateOne) {
  40635. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  40636. }
  40637. if m.id == nil || m.oldValue == nil {
  40638. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  40639. }
  40640. oldValue, err := m.oldValue(ctx)
  40641. if err != nil {
  40642. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  40643. }
  40644. return oldValue.APIKey, nil
  40645. }
  40646. // ClearAPIKey clears the value of the "api_key" field.
  40647. func (m *WxMutation) ClearAPIKey() {
  40648. m.api_key = nil
  40649. m.clearedFields[wx.FieldAPIKey] = struct{}{}
  40650. }
  40651. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  40652. func (m *WxMutation) APIKeyCleared() bool {
  40653. _, ok := m.clearedFields[wx.FieldAPIKey]
  40654. return ok
  40655. }
  40656. // ResetAPIKey resets all changes to the "api_key" field.
  40657. func (m *WxMutation) ResetAPIKey() {
  40658. m.api_key = nil
  40659. delete(m.clearedFields, wx.FieldAPIKey)
  40660. }
  40661. // SetAllowList sets the "allow_list" field.
  40662. func (m *WxMutation) SetAllowList(s []string) {
  40663. m.allow_list = &s
  40664. m.appendallow_list = nil
  40665. }
  40666. // AllowList returns the value of the "allow_list" field in the mutation.
  40667. func (m *WxMutation) AllowList() (r []string, exists bool) {
  40668. v := m.allow_list
  40669. if v == nil {
  40670. return
  40671. }
  40672. return *v, true
  40673. }
  40674. // OldAllowList returns the old "allow_list" field's value of the Wx entity.
  40675. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40676. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40677. func (m *WxMutation) OldAllowList(ctx context.Context) (v []string, err error) {
  40678. if !m.op.Is(OpUpdateOne) {
  40679. return v, errors.New("OldAllowList is only allowed on UpdateOne operations")
  40680. }
  40681. if m.id == nil || m.oldValue == nil {
  40682. return v, errors.New("OldAllowList requires an ID field in the mutation")
  40683. }
  40684. oldValue, err := m.oldValue(ctx)
  40685. if err != nil {
  40686. return v, fmt.Errorf("querying old value for OldAllowList: %w", err)
  40687. }
  40688. return oldValue.AllowList, nil
  40689. }
  40690. // AppendAllowList adds s to the "allow_list" field.
  40691. func (m *WxMutation) AppendAllowList(s []string) {
  40692. m.appendallow_list = append(m.appendallow_list, s...)
  40693. }
  40694. // AppendedAllowList returns the list of values that were appended to the "allow_list" field in this mutation.
  40695. func (m *WxMutation) AppendedAllowList() ([]string, bool) {
  40696. if len(m.appendallow_list) == 0 {
  40697. return nil, false
  40698. }
  40699. return m.appendallow_list, true
  40700. }
  40701. // ResetAllowList resets all changes to the "allow_list" field.
  40702. func (m *WxMutation) ResetAllowList() {
  40703. m.allow_list = nil
  40704. m.appendallow_list = nil
  40705. }
  40706. // SetGroupAllowList sets the "group_allow_list" field.
  40707. func (m *WxMutation) SetGroupAllowList(s []string) {
  40708. m.group_allow_list = &s
  40709. m.appendgroup_allow_list = nil
  40710. }
  40711. // GroupAllowList returns the value of the "group_allow_list" field in the mutation.
  40712. func (m *WxMutation) GroupAllowList() (r []string, exists bool) {
  40713. v := m.group_allow_list
  40714. if v == nil {
  40715. return
  40716. }
  40717. return *v, true
  40718. }
  40719. // OldGroupAllowList returns the old "group_allow_list" field's value of the Wx entity.
  40720. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40721. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40722. func (m *WxMutation) OldGroupAllowList(ctx context.Context) (v []string, err error) {
  40723. if !m.op.Is(OpUpdateOne) {
  40724. return v, errors.New("OldGroupAllowList is only allowed on UpdateOne operations")
  40725. }
  40726. if m.id == nil || m.oldValue == nil {
  40727. return v, errors.New("OldGroupAllowList requires an ID field in the mutation")
  40728. }
  40729. oldValue, err := m.oldValue(ctx)
  40730. if err != nil {
  40731. return v, fmt.Errorf("querying old value for OldGroupAllowList: %w", err)
  40732. }
  40733. return oldValue.GroupAllowList, nil
  40734. }
  40735. // AppendGroupAllowList adds s to the "group_allow_list" field.
  40736. func (m *WxMutation) AppendGroupAllowList(s []string) {
  40737. m.appendgroup_allow_list = append(m.appendgroup_allow_list, s...)
  40738. }
  40739. // AppendedGroupAllowList returns the list of values that were appended to the "group_allow_list" field in this mutation.
  40740. func (m *WxMutation) AppendedGroupAllowList() ([]string, bool) {
  40741. if len(m.appendgroup_allow_list) == 0 {
  40742. return nil, false
  40743. }
  40744. return m.appendgroup_allow_list, true
  40745. }
  40746. // ResetGroupAllowList resets all changes to the "group_allow_list" field.
  40747. func (m *WxMutation) ResetGroupAllowList() {
  40748. m.group_allow_list = nil
  40749. m.appendgroup_allow_list = nil
  40750. }
  40751. // SetBlockList sets the "block_list" field.
  40752. func (m *WxMutation) SetBlockList(s []string) {
  40753. m.block_list = &s
  40754. m.appendblock_list = nil
  40755. }
  40756. // BlockList returns the value of the "block_list" field in the mutation.
  40757. func (m *WxMutation) BlockList() (r []string, exists bool) {
  40758. v := m.block_list
  40759. if v == nil {
  40760. return
  40761. }
  40762. return *v, true
  40763. }
  40764. // OldBlockList returns the old "block_list" field's value of the Wx entity.
  40765. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40766. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40767. func (m *WxMutation) OldBlockList(ctx context.Context) (v []string, err error) {
  40768. if !m.op.Is(OpUpdateOne) {
  40769. return v, errors.New("OldBlockList is only allowed on UpdateOne operations")
  40770. }
  40771. if m.id == nil || m.oldValue == nil {
  40772. return v, errors.New("OldBlockList requires an ID field in the mutation")
  40773. }
  40774. oldValue, err := m.oldValue(ctx)
  40775. if err != nil {
  40776. return v, fmt.Errorf("querying old value for OldBlockList: %w", err)
  40777. }
  40778. return oldValue.BlockList, nil
  40779. }
  40780. // AppendBlockList adds s to the "block_list" field.
  40781. func (m *WxMutation) AppendBlockList(s []string) {
  40782. m.appendblock_list = append(m.appendblock_list, s...)
  40783. }
  40784. // AppendedBlockList returns the list of values that were appended to the "block_list" field in this mutation.
  40785. func (m *WxMutation) AppendedBlockList() ([]string, bool) {
  40786. if len(m.appendblock_list) == 0 {
  40787. return nil, false
  40788. }
  40789. return m.appendblock_list, true
  40790. }
  40791. // ResetBlockList resets all changes to the "block_list" field.
  40792. func (m *WxMutation) ResetBlockList() {
  40793. m.block_list = nil
  40794. m.appendblock_list = nil
  40795. }
  40796. // SetGroupBlockList sets the "group_block_list" field.
  40797. func (m *WxMutation) SetGroupBlockList(s []string) {
  40798. m.group_block_list = &s
  40799. m.appendgroup_block_list = nil
  40800. }
  40801. // GroupBlockList returns the value of the "group_block_list" field in the mutation.
  40802. func (m *WxMutation) GroupBlockList() (r []string, exists bool) {
  40803. v := m.group_block_list
  40804. if v == nil {
  40805. return
  40806. }
  40807. return *v, true
  40808. }
  40809. // OldGroupBlockList returns the old "group_block_list" field's value of the Wx entity.
  40810. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40811. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40812. func (m *WxMutation) OldGroupBlockList(ctx context.Context) (v []string, err error) {
  40813. if !m.op.Is(OpUpdateOne) {
  40814. return v, errors.New("OldGroupBlockList is only allowed on UpdateOne operations")
  40815. }
  40816. if m.id == nil || m.oldValue == nil {
  40817. return v, errors.New("OldGroupBlockList requires an ID field in the mutation")
  40818. }
  40819. oldValue, err := m.oldValue(ctx)
  40820. if err != nil {
  40821. return v, fmt.Errorf("querying old value for OldGroupBlockList: %w", err)
  40822. }
  40823. return oldValue.GroupBlockList, nil
  40824. }
  40825. // AppendGroupBlockList adds s to the "group_block_list" field.
  40826. func (m *WxMutation) AppendGroupBlockList(s []string) {
  40827. m.appendgroup_block_list = append(m.appendgroup_block_list, s...)
  40828. }
  40829. // AppendedGroupBlockList returns the list of values that were appended to the "group_block_list" field in this mutation.
  40830. func (m *WxMutation) AppendedGroupBlockList() ([]string, bool) {
  40831. if len(m.appendgroup_block_list) == 0 {
  40832. return nil, false
  40833. }
  40834. return m.appendgroup_block_list, true
  40835. }
  40836. // ResetGroupBlockList resets all changes to the "group_block_list" field.
  40837. func (m *WxMutation) ResetGroupBlockList() {
  40838. m.group_block_list = nil
  40839. m.appendgroup_block_list = nil
  40840. }
  40841. // ClearServer clears the "server" edge to the Server entity.
  40842. func (m *WxMutation) ClearServer() {
  40843. m.clearedserver = true
  40844. m.clearedFields[wx.FieldServerID] = struct{}{}
  40845. }
  40846. // ServerCleared reports if the "server" edge to the Server entity was cleared.
  40847. func (m *WxMutation) ServerCleared() bool {
  40848. return m.ServerIDCleared() || m.clearedserver
  40849. }
  40850. // ServerIDs returns the "server" edge IDs in the mutation.
  40851. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  40852. // ServerID instead. It exists only for internal usage by the builders.
  40853. func (m *WxMutation) ServerIDs() (ids []uint64) {
  40854. if id := m.server; id != nil {
  40855. ids = append(ids, *id)
  40856. }
  40857. return
  40858. }
  40859. // ResetServer resets all changes to the "server" edge.
  40860. func (m *WxMutation) ResetServer() {
  40861. m.server = nil
  40862. m.clearedserver = false
  40863. }
  40864. // ClearAgent clears the "agent" edge to the Agent entity.
  40865. func (m *WxMutation) ClearAgent() {
  40866. m.clearedagent = true
  40867. m.clearedFields[wx.FieldAgentID] = struct{}{}
  40868. }
  40869. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  40870. func (m *WxMutation) AgentCleared() bool {
  40871. return m.clearedagent
  40872. }
  40873. // AgentIDs returns the "agent" edge IDs in the mutation.
  40874. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  40875. // AgentID instead. It exists only for internal usage by the builders.
  40876. func (m *WxMutation) AgentIDs() (ids []uint64) {
  40877. if id := m.agent; id != nil {
  40878. ids = append(ids, *id)
  40879. }
  40880. return
  40881. }
  40882. // ResetAgent resets all changes to the "agent" edge.
  40883. func (m *WxMutation) ResetAgent() {
  40884. m.agent = nil
  40885. m.clearedagent = false
  40886. }
  40887. // Where appends a list predicates to the WxMutation builder.
  40888. func (m *WxMutation) Where(ps ...predicate.Wx) {
  40889. m.predicates = append(m.predicates, ps...)
  40890. }
  40891. // WhereP appends storage-level predicates to the WxMutation builder. Using this method,
  40892. // users can use type-assertion to append predicates that do not depend on any generated package.
  40893. func (m *WxMutation) WhereP(ps ...func(*sql.Selector)) {
  40894. p := make([]predicate.Wx, len(ps))
  40895. for i := range ps {
  40896. p[i] = ps[i]
  40897. }
  40898. m.Where(p...)
  40899. }
  40900. // Op returns the operation name.
  40901. func (m *WxMutation) Op() Op {
  40902. return m.op
  40903. }
  40904. // SetOp allows setting the mutation operation.
  40905. func (m *WxMutation) SetOp(op Op) {
  40906. m.op = op
  40907. }
  40908. // Type returns the node type of this mutation (Wx).
  40909. func (m *WxMutation) Type() string {
  40910. return m.typ
  40911. }
  40912. // Fields returns all fields that were changed during this mutation. Note that in
  40913. // order to get all numeric fields that were incremented/decremented, call
  40914. // AddedFields().
  40915. func (m *WxMutation) Fields() []string {
  40916. fields := make([]string, 0, 21)
  40917. if m.created_at != nil {
  40918. fields = append(fields, wx.FieldCreatedAt)
  40919. }
  40920. if m.updated_at != nil {
  40921. fields = append(fields, wx.FieldUpdatedAt)
  40922. }
  40923. if m.status != nil {
  40924. fields = append(fields, wx.FieldStatus)
  40925. }
  40926. if m.deleted_at != nil {
  40927. fields = append(fields, wx.FieldDeletedAt)
  40928. }
  40929. if m.server != nil {
  40930. fields = append(fields, wx.FieldServerID)
  40931. }
  40932. if m.port != nil {
  40933. fields = append(fields, wx.FieldPort)
  40934. }
  40935. if m.process_id != nil {
  40936. fields = append(fields, wx.FieldProcessID)
  40937. }
  40938. if m.callback != nil {
  40939. fields = append(fields, wx.FieldCallback)
  40940. }
  40941. if m.wxid != nil {
  40942. fields = append(fields, wx.FieldWxid)
  40943. }
  40944. if m.account != nil {
  40945. fields = append(fields, wx.FieldAccount)
  40946. }
  40947. if m.nickname != nil {
  40948. fields = append(fields, wx.FieldNickname)
  40949. }
  40950. if m.tel != nil {
  40951. fields = append(fields, wx.FieldTel)
  40952. }
  40953. if m.head_big != nil {
  40954. fields = append(fields, wx.FieldHeadBig)
  40955. }
  40956. if m.organization_id != nil {
  40957. fields = append(fields, wx.FieldOrganizationID)
  40958. }
  40959. if m.agent != nil {
  40960. fields = append(fields, wx.FieldAgentID)
  40961. }
  40962. if m.api_base != nil {
  40963. fields = append(fields, wx.FieldAPIBase)
  40964. }
  40965. if m.api_key != nil {
  40966. fields = append(fields, wx.FieldAPIKey)
  40967. }
  40968. if m.allow_list != nil {
  40969. fields = append(fields, wx.FieldAllowList)
  40970. }
  40971. if m.group_allow_list != nil {
  40972. fields = append(fields, wx.FieldGroupAllowList)
  40973. }
  40974. if m.block_list != nil {
  40975. fields = append(fields, wx.FieldBlockList)
  40976. }
  40977. if m.group_block_list != nil {
  40978. fields = append(fields, wx.FieldGroupBlockList)
  40979. }
  40980. return fields
  40981. }
  40982. // Field returns the value of a field with the given name. The second boolean
  40983. // return value indicates that this field was not set, or was not defined in the
  40984. // schema.
  40985. func (m *WxMutation) Field(name string) (ent.Value, bool) {
  40986. switch name {
  40987. case wx.FieldCreatedAt:
  40988. return m.CreatedAt()
  40989. case wx.FieldUpdatedAt:
  40990. return m.UpdatedAt()
  40991. case wx.FieldStatus:
  40992. return m.Status()
  40993. case wx.FieldDeletedAt:
  40994. return m.DeletedAt()
  40995. case wx.FieldServerID:
  40996. return m.ServerID()
  40997. case wx.FieldPort:
  40998. return m.Port()
  40999. case wx.FieldProcessID:
  41000. return m.ProcessID()
  41001. case wx.FieldCallback:
  41002. return m.Callback()
  41003. case wx.FieldWxid:
  41004. return m.Wxid()
  41005. case wx.FieldAccount:
  41006. return m.Account()
  41007. case wx.FieldNickname:
  41008. return m.Nickname()
  41009. case wx.FieldTel:
  41010. return m.Tel()
  41011. case wx.FieldHeadBig:
  41012. return m.HeadBig()
  41013. case wx.FieldOrganizationID:
  41014. return m.OrganizationID()
  41015. case wx.FieldAgentID:
  41016. return m.AgentID()
  41017. case wx.FieldAPIBase:
  41018. return m.APIBase()
  41019. case wx.FieldAPIKey:
  41020. return m.APIKey()
  41021. case wx.FieldAllowList:
  41022. return m.AllowList()
  41023. case wx.FieldGroupAllowList:
  41024. return m.GroupAllowList()
  41025. case wx.FieldBlockList:
  41026. return m.BlockList()
  41027. case wx.FieldGroupBlockList:
  41028. return m.GroupBlockList()
  41029. }
  41030. return nil, false
  41031. }
  41032. // OldField returns the old value of the field from the database. An error is
  41033. // returned if the mutation operation is not UpdateOne, or the query to the
  41034. // database failed.
  41035. func (m *WxMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  41036. switch name {
  41037. case wx.FieldCreatedAt:
  41038. return m.OldCreatedAt(ctx)
  41039. case wx.FieldUpdatedAt:
  41040. return m.OldUpdatedAt(ctx)
  41041. case wx.FieldStatus:
  41042. return m.OldStatus(ctx)
  41043. case wx.FieldDeletedAt:
  41044. return m.OldDeletedAt(ctx)
  41045. case wx.FieldServerID:
  41046. return m.OldServerID(ctx)
  41047. case wx.FieldPort:
  41048. return m.OldPort(ctx)
  41049. case wx.FieldProcessID:
  41050. return m.OldProcessID(ctx)
  41051. case wx.FieldCallback:
  41052. return m.OldCallback(ctx)
  41053. case wx.FieldWxid:
  41054. return m.OldWxid(ctx)
  41055. case wx.FieldAccount:
  41056. return m.OldAccount(ctx)
  41057. case wx.FieldNickname:
  41058. return m.OldNickname(ctx)
  41059. case wx.FieldTel:
  41060. return m.OldTel(ctx)
  41061. case wx.FieldHeadBig:
  41062. return m.OldHeadBig(ctx)
  41063. case wx.FieldOrganizationID:
  41064. return m.OldOrganizationID(ctx)
  41065. case wx.FieldAgentID:
  41066. return m.OldAgentID(ctx)
  41067. case wx.FieldAPIBase:
  41068. return m.OldAPIBase(ctx)
  41069. case wx.FieldAPIKey:
  41070. return m.OldAPIKey(ctx)
  41071. case wx.FieldAllowList:
  41072. return m.OldAllowList(ctx)
  41073. case wx.FieldGroupAllowList:
  41074. return m.OldGroupAllowList(ctx)
  41075. case wx.FieldBlockList:
  41076. return m.OldBlockList(ctx)
  41077. case wx.FieldGroupBlockList:
  41078. return m.OldGroupBlockList(ctx)
  41079. }
  41080. return nil, fmt.Errorf("unknown Wx field %s", name)
  41081. }
  41082. // SetField sets the value of a field with the given name. It returns an error if
  41083. // the field is not defined in the schema, or if the type mismatched the field
  41084. // type.
  41085. func (m *WxMutation) SetField(name string, value ent.Value) error {
  41086. switch name {
  41087. case wx.FieldCreatedAt:
  41088. v, ok := value.(time.Time)
  41089. if !ok {
  41090. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41091. }
  41092. m.SetCreatedAt(v)
  41093. return nil
  41094. case wx.FieldUpdatedAt:
  41095. v, ok := value.(time.Time)
  41096. if !ok {
  41097. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41098. }
  41099. m.SetUpdatedAt(v)
  41100. return nil
  41101. case wx.FieldStatus:
  41102. v, ok := value.(uint8)
  41103. if !ok {
  41104. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41105. }
  41106. m.SetStatus(v)
  41107. return nil
  41108. case wx.FieldDeletedAt:
  41109. v, ok := value.(time.Time)
  41110. if !ok {
  41111. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41112. }
  41113. m.SetDeletedAt(v)
  41114. return nil
  41115. case wx.FieldServerID:
  41116. v, ok := value.(uint64)
  41117. if !ok {
  41118. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41119. }
  41120. m.SetServerID(v)
  41121. return nil
  41122. case wx.FieldPort:
  41123. v, ok := value.(string)
  41124. if !ok {
  41125. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41126. }
  41127. m.SetPort(v)
  41128. return nil
  41129. case wx.FieldProcessID:
  41130. v, ok := value.(string)
  41131. if !ok {
  41132. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41133. }
  41134. m.SetProcessID(v)
  41135. return nil
  41136. case wx.FieldCallback:
  41137. v, ok := value.(string)
  41138. if !ok {
  41139. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41140. }
  41141. m.SetCallback(v)
  41142. return nil
  41143. case wx.FieldWxid:
  41144. v, ok := value.(string)
  41145. if !ok {
  41146. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41147. }
  41148. m.SetWxid(v)
  41149. return nil
  41150. case wx.FieldAccount:
  41151. v, ok := value.(string)
  41152. if !ok {
  41153. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41154. }
  41155. m.SetAccount(v)
  41156. return nil
  41157. case wx.FieldNickname:
  41158. v, ok := value.(string)
  41159. if !ok {
  41160. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41161. }
  41162. m.SetNickname(v)
  41163. return nil
  41164. case wx.FieldTel:
  41165. v, ok := value.(string)
  41166. if !ok {
  41167. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41168. }
  41169. m.SetTel(v)
  41170. return nil
  41171. case wx.FieldHeadBig:
  41172. v, ok := value.(string)
  41173. if !ok {
  41174. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41175. }
  41176. m.SetHeadBig(v)
  41177. return nil
  41178. case wx.FieldOrganizationID:
  41179. v, ok := value.(uint64)
  41180. if !ok {
  41181. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41182. }
  41183. m.SetOrganizationID(v)
  41184. return nil
  41185. case wx.FieldAgentID:
  41186. v, ok := value.(uint64)
  41187. if !ok {
  41188. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41189. }
  41190. m.SetAgentID(v)
  41191. return nil
  41192. case wx.FieldAPIBase:
  41193. v, ok := value.(string)
  41194. if !ok {
  41195. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41196. }
  41197. m.SetAPIBase(v)
  41198. return nil
  41199. case wx.FieldAPIKey:
  41200. v, ok := value.(string)
  41201. if !ok {
  41202. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41203. }
  41204. m.SetAPIKey(v)
  41205. return nil
  41206. case wx.FieldAllowList:
  41207. v, ok := value.([]string)
  41208. if !ok {
  41209. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41210. }
  41211. m.SetAllowList(v)
  41212. return nil
  41213. case wx.FieldGroupAllowList:
  41214. v, ok := value.([]string)
  41215. if !ok {
  41216. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41217. }
  41218. m.SetGroupAllowList(v)
  41219. return nil
  41220. case wx.FieldBlockList:
  41221. v, ok := value.([]string)
  41222. if !ok {
  41223. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41224. }
  41225. m.SetBlockList(v)
  41226. return nil
  41227. case wx.FieldGroupBlockList:
  41228. v, ok := value.([]string)
  41229. if !ok {
  41230. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41231. }
  41232. m.SetGroupBlockList(v)
  41233. return nil
  41234. }
  41235. return fmt.Errorf("unknown Wx field %s", name)
  41236. }
  41237. // AddedFields returns all numeric fields that were incremented/decremented during
  41238. // this mutation.
  41239. func (m *WxMutation) AddedFields() []string {
  41240. var fields []string
  41241. if m.addstatus != nil {
  41242. fields = append(fields, wx.FieldStatus)
  41243. }
  41244. if m.addorganization_id != nil {
  41245. fields = append(fields, wx.FieldOrganizationID)
  41246. }
  41247. return fields
  41248. }
  41249. // AddedField returns the numeric value that was incremented/decremented on a field
  41250. // with the given name. The second boolean return value indicates that this field
  41251. // was not set, or was not defined in the schema.
  41252. func (m *WxMutation) AddedField(name string) (ent.Value, bool) {
  41253. switch name {
  41254. case wx.FieldStatus:
  41255. return m.AddedStatus()
  41256. case wx.FieldOrganizationID:
  41257. return m.AddedOrganizationID()
  41258. }
  41259. return nil, false
  41260. }
  41261. // AddField adds the value to the field with the given name. It returns an error if
  41262. // the field is not defined in the schema, or if the type mismatched the field
  41263. // type.
  41264. func (m *WxMutation) AddField(name string, value ent.Value) error {
  41265. switch name {
  41266. case wx.FieldStatus:
  41267. v, ok := value.(int8)
  41268. if !ok {
  41269. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41270. }
  41271. m.AddStatus(v)
  41272. return nil
  41273. case wx.FieldOrganizationID:
  41274. v, ok := value.(int64)
  41275. if !ok {
  41276. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41277. }
  41278. m.AddOrganizationID(v)
  41279. return nil
  41280. }
  41281. return fmt.Errorf("unknown Wx numeric field %s", name)
  41282. }
  41283. // ClearedFields returns all nullable fields that were cleared during this
  41284. // mutation.
  41285. func (m *WxMutation) ClearedFields() []string {
  41286. var fields []string
  41287. if m.FieldCleared(wx.FieldStatus) {
  41288. fields = append(fields, wx.FieldStatus)
  41289. }
  41290. if m.FieldCleared(wx.FieldDeletedAt) {
  41291. fields = append(fields, wx.FieldDeletedAt)
  41292. }
  41293. if m.FieldCleared(wx.FieldServerID) {
  41294. fields = append(fields, wx.FieldServerID)
  41295. }
  41296. if m.FieldCleared(wx.FieldOrganizationID) {
  41297. fields = append(fields, wx.FieldOrganizationID)
  41298. }
  41299. if m.FieldCleared(wx.FieldAPIBase) {
  41300. fields = append(fields, wx.FieldAPIBase)
  41301. }
  41302. if m.FieldCleared(wx.FieldAPIKey) {
  41303. fields = append(fields, wx.FieldAPIKey)
  41304. }
  41305. return fields
  41306. }
  41307. // FieldCleared returns a boolean indicating if a field with the given name was
  41308. // cleared in this mutation.
  41309. func (m *WxMutation) FieldCleared(name string) bool {
  41310. _, ok := m.clearedFields[name]
  41311. return ok
  41312. }
  41313. // ClearField clears the value of the field with the given name. It returns an
  41314. // error if the field is not defined in the schema.
  41315. func (m *WxMutation) ClearField(name string) error {
  41316. switch name {
  41317. case wx.FieldStatus:
  41318. m.ClearStatus()
  41319. return nil
  41320. case wx.FieldDeletedAt:
  41321. m.ClearDeletedAt()
  41322. return nil
  41323. case wx.FieldServerID:
  41324. m.ClearServerID()
  41325. return nil
  41326. case wx.FieldOrganizationID:
  41327. m.ClearOrganizationID()
  41328. return nil
  41329. case wx.FieldAPIBase:
  41330. m.ClearAPIBase()
  41331. return nil
  41332. case wx.FieldAPIKey:
  41333. m.ClearAPIKey()
  41334. return nil
  41335. }
  41336. return fmt.Errorf("unknown Wx nullable field %s", name)
  41337. }
  41338. // ResetField resets all changes in the mutation for the field with the given name.
  41339. // It returns an error if the field is not defined in the schema.
  41340. func (m *WxMutation) ResetField(name string) error {
  41341. switch name {
  41342. case wx.FieldCreatedAt:
  41343. m.ResetCreatedAt()
  41344. return nil
  41345. case wx.FieldUpdatedAt:
  41346. m.ResetUpdatedAt()
  41347. return nil
  41348. case wx.FieldStatus:
  41349. m.ResetStatus()
  41350. return nil
  41351. case wx.FieldDeletedAt:
  41352. m.ResetDeletedAt()
  41353. return nil
  41354. case wx.FieldServerID:
  41355. m.ResetServerID()
  41356. return nil
  41357. case wx.FieldPort:
  41358. m.ResetPort()
  41359. return nil
  41360. case wx.FieldProcessID:
  41361. m.ResetProcessID()
  41362. return nil
  41363. case wx.FieldCallback:
  41364. m.ResetCallback()
  41365. return nil
  41366. case wx.FieldWxid:
  41367. m.ResetWxid()
  41368. return nil
  41369. case wx.FieldAccount:
  41370. m.ResetAccount()
  41371. return nil
  41372. case wx.FieldNickname:
  41373. m.ResetNickname()
  41374. return nil
  41375. case wx.FieldTel:
  41376. m.ResetTel()
  41377. return nil
  41378. case wx.FieldHeadBig:
  41379. m.ResetHeadBig()
  41380. return nil
  41381. case wx.FieldOrganizationID:
  41382. m.ResetOrganizationID()
  41383. return nil
  41384. case wx.FieldAgentID:
  41385. m.ResetAgentID()
  41386. return nil
  41387. case wx.FieldAPIBase:
  41388. m.ResetAPIBase()
  41389. return nil
  41390. case wx.FieldAPIKey:
  41391. m.ResetAPIKey()
  41392. return nil
  41393. case wx.FieldAllowList:
  41394. m.ResetAllowList()
  41395. return nil
  41396. case wx.FieldGroupAllowList:
  41397. m.ResetGroupAllowList()
  41398. return nil
  41399. case wx.FieldBlockList:
  41400. m.ResetBlockList()
  41401. return nil
  41402. case wx.FieldGroupBlockList:
  41403. m.ResetGroupBlockList()
  41404. return nil
  41405. }
  41406. return fmt.Errorf("unknown Wx field %s", name)
  41407. }
  41408. // AddedEdges returns all edge names that were set/added in this mutation.
  41409. func (m *WxMutation) AddedEdges() []string {
  41410. edges := make([]string, 0, 2)
  41411. if m.server != nil {
  41412. edges = append(edges, wx.EdgeServer)
  41413. }
  41414. if m.agent != nil {
  41415. edges = append(edges, wx.EdgeAgent)
  41416. }
  41417. return edges
  41418. }
  41419. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  41420. // name in this mutation.
  41421. func (m *WxMutation) AddedIDs(name string) []ent.Value {
  41422. switch name {
  41423. case wx.EdgeServer:
  41424. if id := m.server; id != nil {
  41425. return []ent.Value{*id}
  41426. }
  41427. case wx.EdgeAgent:
  41428. if id := m.agent; id != nil {
  41429. return []ent.Value{*id}
  41430. }
  41431. }
  41432. return nil
  41433. }
  41434. // RemovedEdges returns all edge names that were removed in this mutation.
  41435. func (m *WxMutation) RemovedEdges() []string {
  41436. edges := make([]string, 0, 2)
  41437. return edges
  41438. }
  41439. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  41440. // the given name in this mutation.
  41441. func (m *WxMutation) RemovedIDs(name string) []ent.Value {
  41442. return nil
  41443. }
  41444. // ClearedEdges returns all edge names that were cleared in this mutation.
  41445. func (m *WxMutation) ClearedEdges() []string {
  41446. edges := make([]string, 0, 2)
  41447. if m.clearedserver {
  41448. edges = append(edges, wx.EdgeServer)
  41449. }
  41450. if m.clearedagent {
  41451. edges = append(edges, wx.EdgeAgent)
  41452. }
  41453. return edges
  41454. }
  41455. // EdgeCleared returns a boolean which indicates if the edge with the given name
  41456. // was cleared in this mutation.
  41457. func (m *WxMutation) EdgeCleared(name string) bool {
  41458. switch name {
  41459. case wx.EdgeServer:
  41460. return m.clearedserver
  41461. case wx.EdgeAgent:
  41462. return m.clearedagent
  41463. }
  41464. return false
  41465. }
  41466. // ClearEdge clears the value of the edge with the given name. It returns an error
  41467. // if that edge is not defined in the schema.
  41468. func (m *WxMutation) ClearEdge(name string) error {
  41469. switch name {
  41470. case wx.EdgeServer:
  41471. m.ClearServer()
  41472. return nil
  41473. case wx.EdgeAgent:
  41474. m.ClearAgent()
  41475. return nil
  41476. }
  41477. return fmt.Errorf("unknown Wx unique edge %s", name)
  41478. }
  41479. // ResetEdge resets all changes to the edge with the given name in this mutation.
  41480. // It returns an error if the edge is not defined in the schema.
  41481. func (m *WxMutation) ResetEdge(name string) error {
  41482. switch name {
  41483. case wx.EdgeServer:
  41484. m.ResetServer()
  41485. return nil
  41486. case wx.EdgeAgent:
  41487. m.ResetAgent()
  41488. return nil
  41489. }
  41490. return fmt.Errorf("unknown Wx edge %s", name)
  41491. }
  41492. // WxCardMutation represents an operation that mutates the WxCard nodes in the graph.
  41493. type WxCardMutation struct {
  41494. config
  41495. op Op
  41496. typ string
  41497. id *uint64
  41498. created_at *time.Time
  41499. updated_at *time.Time
  41500. deleted_at *time.Time
  41501. user_id *uint64
  41502. adduser_id *int64
  41503. wx_user_id *uint64
  41504. addwx_user_id *int64
  41505. avatar *string
  41506. logo *string
  41507. name *string
  41508. company *string
  41509. address *string
  41510. phone *string
  41511. official_account *string
  41512. wechat_account *string
  41513. email *string
  41514. api_base *string
  41515. api_key *string
  41516. ai_info *string
  41517. intro *string
  41518. clearedFields map[string]struct{}
  41519. done bool
  41520. oldValue func(context.Context) (*WxCard, error)
  41521. predicates []predicate.WxCard
  41522. }
  41523. var _ ent.Mutation = (*WxCardMutation)(nil)
  41524. // wxcardOption allows management of the mutation configuration using functional options.
  41525. type wxcardOption func(*WxCardMutation)
  41526. // newWxCardMutation creates new mutation for the WxCard entity.
  41527. func newWxCardMutation(c config, op Op, opts ...wxcardOption) *WxCardMutation {
  41528. m := &WxCardMutation{
  41529. config: c,
  41530. op: op,
  41531. typ: TypeWxCard,
  41532. clearedFields: make(map[string]struct{}),
  41533. }
  41534. for _, opt := range opts {
  41535. opt(m)
  41536. }
  41537. return m
  41538. }
  41539. // withWxCardID sets the ID field of the mutation.
  41540. func withWxCardID(id uint64) wxcardOption {
  41541. return func(m *WxCardMutation) {
  41542. var (
  41543. err error
  41544. once sync.Once
  41545. value *WxCard
  41546. )
  41547. m.oldValue = func(ctx context.Context) (*WxCard, error) {
  41548. once.Do(func() {
  41549. if m.done {
  41550. err = errors.New("querying old values post mutation is not allowed")
  41551. } else {
  41552. value, err = m.Client().WxCard.Get(ctx, id)
  41553. }
  41554. })
  41555. return value, err
  41556. }
  41557. m.id = &id
  41558. }
  41559. }
  41560. // withWxCard sets the old WxCard of the mutation.
  41561. func withWxCard(node *WxCard) wxcardOption {
  41562. return func(m *WxCardMutation) {
  41563. m.oldValue = func(context.Context) (*WxCard, error) {
  41564. return node, nil
  41565. }
  41566. m.id = &node.ID
  41567. }
  41568. }
  41569. // Client returns a new `ent.Client` from the mutation. If the mutation was
  41570. // executed in a transaction (ent.Tx), a transactional client is returned.
  41571. func (m WxCardMutation) Client() *Client {
  41572. client := &Client{config: m.config}
  41573. client.init()
  41574. return client
  41575. }
  41576. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  41577. // it returns an error otherwise.
  41578. func (m WxCardMutation) Tx() (*Tx, error) {
  41579. if _, ok := m.driver.(*txDriver); !ok {
  41580. return nil, errors.New("ent: mutation is not running in a transaction")
  41581. }
  41582. tx := &Tx{config: m.config}
  41583. tx.init()
  41584. return tx, nil
  41585. }
  41586. // SetID sets the value of the id field. Note that this
  41587. // operation is only accepted on creation of WxCard entities.
  41588. func (m *WxCardMutation) SetID(id uint64) {
  41589. m.id = &id
  41590. }
  41591. // ID returns the ID value in the mutation. Note that the ID is only available
  41592. // if it was provided to the builder or after it was returned from the database.
  41593. func (m *WxCardMutation) ID() (id uint64, exists bool) {
  41594. if m.id == nil {
  41595. return
  41596. }
  41597. return *m.id, true
  41598. }
  41599. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  41600. // That means, if the mutation is applied within a transaction with an isolation level such
  41601. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  41602. // or updated by the mutation.
  41603. func (m *WxCardMutation) IDs(ctx context.Context) ([]uint64, error) {
  41604. switch {
  41605. case m.op.Is(OpUpdateOne | OpDeleteOne):
  41606. id, exists := m.ID()
  41607. if exists {
  41608. return []uint64{id}, nil
  41609. }
  41610. fallthrough
  41611. case m.op.Is(OpUpdate | OpDelete):
  41612. return m.Client().WxCard.Query().Where(m.predicates...).IDs(ctx)
  41613. default:
  41614. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  41615. }
  41616. }
  41617. // SetCreatedAt sets the "created_at" field.
  41618. func (m *WxCardMutation) SetCreatedAt(t time.Time) {
  41619. m.created_at = &t
  41620. }
  41621. // CreatedAt returns the value of the "created_at" field in the mutation.
  41622. func (m *WxCardMutation) CreatedAt() (r time.Time, exists bool) {
  41623. v := m.created_at
  41624. if v == nil {
  41625. return
  41626. }
  41627. return *v, true
  41628. }
  41629. // OldCreatedAt returns the old "created_at" field's value of the WxCard entity.
  41630. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  41631. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41632. func (m *WxCardMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  41633. if !m.op.Is(OpUpdateOne) {
  41634. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  41635. }
  41636. if m.id == nil || m.oldValue == nil {
  41637. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  41638. }
  41639. oldValue, err := m.oldValue(ctx)
  41640. if err != nil {
  41641. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  41642. }
  41643. return oldValue.CreatedAt, nil
  41644. }
  41645. // ResetCreatedAt resets all changes to the "created_at" field.
  41646. func (m *WxCardMutation) ResetCreatedAt() {
  41647. m.created_at = nil
  41648. }
  41649. // SetUpdatedAt sets the "updated_at" field.
  41650. func (m *WxCardMutation) SetUpdatedAt(t time.Time) {
  41651. m.updated_at = &t
  41652. }
  41653. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  41654. func (m *WxCardMutation) UpdatedAt() (r time.Time, exists bool) {
  41655. v := m.updated_at
  41656. if v == nil {
  41657. return
  41658. }
  41659. return *v, true
  41660. }
  41661. // OldUpdatedAt returns the old "updated_at" field's value of the WxCard entity.
  41662. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  41663. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41664. func (m *WxCardMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  41665. if !m.op.Is(OpUpdateOne) {
  41666. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  41667. }
  41668. if m.id == nil || m.oldValue == nil {
  41669. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  41670. }
  41671. oldValue, err := m.oldValue(ctx)
  41672. if err != nil {
  41673. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  41674. }
  41675. return oldValue.UpdatedAt, nil
  41676. }
  41677. // ResetUpdatedAt resets all changes to the "updated_at" field.
  41678. func (m *WxCardMutation) ResetUpdatedAt() {
  41679. m.updated_at = nil
  41680. }
  41681. // SetDeletedAt sets the "deleted_at" field.
  41682. func (m *WxCardMutation) SetDeletedAt(t time.Time) {
  41683. m.deleted_at = &t
  41684. }
  41685. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  41686. func (m *WxCardMutation) DeletedAt() (r time.Time, exists bool) {
  41687. v := m.deleted_at
  41688. if v == nil {
  41689. return
  41690. }
  41691. return *v, true
  41692. }
  41693. // OldDeletedAt returns the old "deleted_at" field's value of the WxCard entity.
  41694. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  41695. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41696. func (m *WxCardMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  41697. if !m.op.Is(OpUpdateOne) {
  41698. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  41699. }
  41700. if m.id == nil || m.oldValue == nil {
  41701. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  41702. }
  41703. oldValue, err := m.oldValue(ctx)
  41704. if err != nil {
  41705. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  41706. }
  41707. return oldValue.DeletedAt, nil
  41708. }
  41709. // ClearDeletedAt clears the value of the "deleted_at" field.
  41710. func (m *WxCardMutation) ClearDeletedAt() {
  41711. m.deleted_at = nil
  41712. m.clearedFields[wxcard.FieldDeletedAt] = struct{}{}
  41713. }
  41714. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  41715. func (m *WxCardMutation) DeletedAtCleared() bool {
  41716. _, ok := m.clearedFields[wxcard.FieldDeletedAt]
  41717. return ok
  41718. }
  41719. // ResetDeletedAt resets all changes to the "deleted_at" field.
  41720. func (m *WxCardMutation) ResetDeletedAt() {
  41721. m.deleted_at = nil
  41722. delete(m.clearedFields, wxcard.FieldDeletedAt)
  41723. }
  41724. // SetUserID sets the "user_id" field.
  41725. func (m *WxCardMutation) SetUserID(u uint64) {
  41726. m.user_id = &u
  41727. m.adduser_id = nil
  41728. }
  41729. // UserID returns the value of the "user_id" field in the mutation.
  41730. func (m *WxCardMutation) UserID() (r uint64, exists bool) {
  41731. v := m.user_id
  41732. if v == nil {
  41733. return
  41734. }
  41735. return *v, true
  41736. }
  41737. // OldUserID returns the old "user_id" field's value of the WxCard entity.
  41738. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  41739. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41740. func (m *WxCardMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  41741. if !m.op.Is(OpUpdateOne) {
  41742. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  41743. }
  41744. if m.id == nil || m.oldValue == nil {
  41745. return v, errors.New("OldUserID requires an ID field in the mutation")
  41746. }
  41747. oldValue, err := m.oldValue(ctx)
  41748. if err != nil {
  41749. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  41750. }
  41751. return oldValue.UserID, nil
  41752. }
  41753. // AddUserID adds u to the "user_id" field.
  41754. func (m *WxCardMutation) AddUserID(u int64) {
  41755. if m.adduser_id != nil {
  41756. *m.adduser_id += u
  41757. } else {
  41758. m.adduser_id = &u
  41759. }
  41760. }
  41761. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  41762. func (m *WxCardMutation) AddedUserID() (r int64, exists bool) {
  41763. v := m.adduser_id
  41764. if v == nil {
  41765. return
  41766. }
  41767. return *v, true
  41768. }
  41769. // ClearUserID clears the value of the "user_id" field.
  41770. func (m *WxCardMutation) ClearUserID() {
  41771. m.user_id = nil
  41772. m.adduser_id = nil
  41773. m.clearedFields[wxcard.FieldUserID] = struct{}{}
  41774. }
  41775. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  41776. func (m *WxCardMutation) UserIDCleared() bool {
  41777. _, ok := m.clearedFields[wxcard.FieldUserID]
  41778. return ok
  41779. }
  41780. // ResetUserID resets all changes to the "user_id" field.
  41781. func (m *WxCardMutation) ResetUserID() {
  41782. m.user_id = nil
  41783. m.adduser_id = nil
  41784. delete(m.clearedFields, wxcard.FieldUserID)
  41785. }
  41786. // SetWxUserID sets the "wx_user_id" field.
  41787. func (m *WxCardMutation) SetWxUserID(u uint64) {
  41788. m.wx_user_id = &u
  41789. m.addwx_user_id = nil
  41790. }
  41791. // WxUserID returns the value of the "wx_user_id" field in the mutation.
  41792. func (m *WxCardMutation) WxUserID() (r uint64, exists bool) {
  41793. v := m.wx_user_id
  41794. if v == nil {
  41795. return
  41796. }
  41797. return *v, true
  41798. }
  41799. // OldWxUserID returns the old "wx_user_id" field's value of the WxCard entity.
  41800. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  41801. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41802. func (m *WxCardMutation) OldWxUserID(ctx context.Context) (v uint64, err error) {
  41803. if !m.op.Is(OpUpdateOne) {
  41804. return v, errors.New("OldWxUserID is only allowed on UpdateOne operations")
  41805. }
  41806. if m.id == nil || m.oldValue == nil {
  41807. return v, errors.New("OldWxUserID requires an ID field in the mutation")
  41808. }
  41809. oldValue, err := m.oldValue(ctx)
  41810. if err != nil {
  41811. return v, fmt.Errorf("querying old value for OldWxUserID: %w", err)
  41812. }
  41813. return oldValue.WxUserID, nil
  41814. }
  41815. // AddWxUserID adds u to the "wx_user_id" field.
  41816. func (m *WxCardMutation) AddWxUserID(u int64) {
  41817. if m.addwx_user_id != nil {
  41818. *m.addwx_user_id += u
  41819. } else {
  41820. m.addwx_user_id = &u
  41821. }
  41822. }
  41823. // AddedWxUserID returns the value that was added to the "wx_user_id" field in this mutation.
  41824. func (m *WxCardMutation) AddedWxUserID() (r int64, exists bool) {
  41825. v := m.addwx_user_id
  41826. if v == nil {
  41827. return
  41828. }
  41829. return *v, true
  41830. }
  41831. // ClearWxUserID clears the value of the "wx_user_id" field.
  41832. func (m *WxCardMutation) ClearWxUserID() {
  41833. m.wx_user_id = nil
  41834. m.addwx_user_id = nil
  41835. m.clearedFields[wxcard.FieldWxUserID] = struct{}{}
  41836. }
  41837. // WxUserIDCleared returns if the "wx_user_id" field was cleared in this mutation.
  41838. func (m *WxCardMutation) WxUserIDCleared() bool {
  41839. _, ok := m.clearedFields[wxcard.FieldWxUserID]
  41840. return ok
  41841. }
  41842. // ResetWxUserID resets all changes to the "wx_user_id" field.
  41843. func (m *WxCardMutation) ResetWxUserID() {
  41844. m.wx_user_id = nil
  41845. m.addwx_user_id = nil
  41846. delete(m.clearedFields, wxcard.FieldWxUserID)
  41847. }
  41848. // SetAvatar sets the "avatar" field.
  41849. func (m *WxCardMutation) SetAvatar(s string) {
  41850. m.avatar = &s
  41851. }
  41852. // Avatar returns the value of the "avatar" field in the mutation.
  41853. func (m *WxCardMutation) Avatar() (r string, exists bool) {
  41854. v := m.avatar
  41855. if v == nil {
  41856. return
  41857. }
  41858. return *v, true
  41859. }
  41860. // OldAvatar returns the old "avatar" field's value of the WxCard entity.
  41861. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  41862. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41863. func (m *WxCardMutation) OldAvatar(ctx context.Context) (v string, err error) {
  41864. if !m.op.Is(OpUpdateOne) {
  41865. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  41866. }
  41867. if m.id == nil || m.oldValue == nil {
  41868. return v, errors.New("OldAvatar requires an ID field in the mutation")
  41869. }
  41870. oldValue, err := m.oldValue(ctx)
  41871. if err != nil {
  41872. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  41873. }
  41874. return oldValue.Avatar, nil
  41875. }
  41876. // ResetAvatar resets all changes to the "avatar" field.
  41877. func (m *WxCardMutation) ResetAvatar() {
  41878. m.avatar = nil
  41879. }
  41880. // SetLogo sets the "logo" field.
  41881. func (m *WxCardMutation) SetLogo(s string) {
  41882. m.logo = &s
  41883. }
  41884. // Logo returns the value of the "logo" field in the mutation.
  41885. func (m *WxCardMutation) Logo() (r string, exists bool) {
  41886. v := m.logo
  41887. if v == nil {
  41888. return
  41889. }
  41890. return *v, true
  41891. }
  41892. // OldLogo returns the old "logo" field's value of the WxCard entity.
  41893. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  41894. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41895. func (m *WxCardMutation) OldLogo(ctx context.Context) (v string, err error) {
  41896. if !m.op.Is(OpUpdateOne) {
  41897. return v, errors.New("OldLogo is only allowed on UpdateOne operations")
  41898. }
  41899. if m.id == nil || m.oldValue == nil {
  41900. return v, errors.New("OldLogo requires an ID field in the mutation")
  41901. }
  41902. oldValue, err := m.oldValue(ctx)
  41903. if err != nil {
  41904. return v, fmt.Errorf("querying old value for OldLogo: %w", err)
  41905. }
  41906. return oldValue.Logo, nil
  41907. }
  41908. // ResetLogo resets all changes to the "logo" field.
  41909. func (m *WxCardMutation) ResetLogo() {
  41910. m.logo = nil
  41911. }
  41912. // SetName sets the "name" field.
  41913. func (m *WxCardMutation) SetName(s string) {
  41914. m.name = &s
  41915. }
  41916. // Name returns the value of the "name" field in the mutation.
  41917. func (m *WxCardMutation) Name() (r string, exists bool) {
  41918. v := m.name
  41919. if v == nil {
  41920. return
  41921. }
  41922. return *v, true
  41923. }
  41924. // OldName returns the old "name" field's value of the WxCard entity.
  41925. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  41926. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41927. func (m *WxCardMutation) OldName(ctx context.Context) (v string, err error) {
  41928. if !m.op.Is(OpUpdateOne) {
  41929. return v, errors.New("OldName is only allowed on UpdateOne operations")
  41930. }
  41931. if m.id == nil || m.oldValue == nil {
  41932. return v, errors.New("OldName requires an ID field in the mutation")
  41933. }
  41934. oldValue, err := m.oldValue(ctx)
  41935. if err != nil {
  41936. return v, fmt.Errorf("querying old value for OldName: %w", err)
  41937. }
  41938. return oldValue.Name, nil
  41939. }
  41940. // ResetName resets all changes to the "name" field.
  41941. func (m *WxCardMutation) ResetName() {
  41942. m.name = nil
  41943. }
  41944. // SetCompany sets the "company" field.
  41945. func (m *WxCardMutation) SetCompany(s string) {
  41946. m.company = &s
  41947. }
  41948. // Company returns the value of the "company" field in the mutation.
  41949. func (m *WxCardMutation) Company() (r string, exists bool) {
  41950. v := m.company
  41951. if v == nil {
  41952. return
  41953. }
  41954. return *v, true
  41955. }
  41956. // OldCompany returns the old "company" field's value of the WxCard entity.
  41957. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  41958. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41959. func (m *WxCardMutation) OldCompany(ctx context.Context) (v string, err error) {
  41960. if !m.op.Is(OpUpdateOne) {
  41961. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  41962. }
  41963. if m.id == nil || m.oldValue == nil {
  41964. return v, errors.New("OldCompany requires an ID field in the mutation")
  41965. }
  41966. oldValue, err := m.oldValue(ctx)
  41967. if err != nil {
  41968. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  41969. }
  41970. return oldValue.Company, nil
  41971. }
  41972. // ResetCompany resets all changes to the "company" field.
  41973. func (m *WxCardMutation) ResetCompany() {
  41974. m.company = nil
  41975. }
  41976. // SetAddress sets the "address" field.
  41977. func (m *WxCardMutation) SetAddress(s string) {
  41978. m.address = &s
  41979. }
  41980. // Address returns the value of the "address" field in the mutation.
  41981. func (m *WxCardMutation) Address() (r string, exists bool) {
  41982. v := m.address
  41983. if v == nil {
  41984. return
  41985. }
  41986. return *v, true
  41987. }
  41988. // OldAddress returns the old "address" field's value of the WxCard entity.
  41989. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  41990. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41991. func (m *WxCardMutation) OldAddress(ctx context.Context) (v string, err error) {
  41992. if !m.op.Is(OpUpdateOne) {
  41993. return v, errors.New("OldAddress is only allowed on UpdateOne operations")
  41994. }
  41995. if m.id == nil || m.oldValue == nil {
  41996. return v, errors.New("OldAddress requires an ID field in the mutation")
  41997. }
  41998. oldValue, err := m.oldValue(ctx)
  41999. if err != nil {
  42000. return v, fmt.Errorf("querying old value for OldAddress: %w", err)
  42001. }
  42002. return oldValue.Address, nil
  42003. }
  42004. // ResetAddress resets all changes to the "address" field.
  42005. func (m *WxCardMutation) ResetAddress() {
  42006. m.address = nil
  42007. }
  42008. // SetPhone sets the "phone" field.
  42009. func (m *WxCardMutation) SetPhone(s string) {
  42010. m.phone = &s
  42011. }
  42012. // Phone returns the value of the "phone" field in the mutation.
  42013. func (m *WxCardMutation) Phone() (r string, exists bool) {
  42014. v := m.phone
  42015. if v == nil {
  42016. return
  42017. }
  42018. return *v, true
  42019. }
  42020. // OldPhone returns the old "phone" field's value of the WxCard entity.
  42021. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  42022. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42023. func (m *WxCardMutation) OldPhone(ctx context.Context) (v string, err error) {
  42024. if !m.op.Is(OpUpdateOne) {
  42025. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  42026. }
  42027. if m.id == nil || m.oldValue == nil {
  42028. return v, errors.New("OldPhone requires an ID field in the mutation")
  42029. }
  42030. oldValue, err := m.oldValue(ctx)
  42031. if err != nil {
  42032. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  42033. }
  42034. return oldValue.Phone, nil
  42035. }
  42036. // ResetPhone resets all changes to the "phone" field.
  42037. func (m *WxCardMutation) ResetPhone() {
  42038. m.phone = nil
  42039. }
  42040. // SetOfficialAccount sets the "official_account" field.
  42041. func (m *WxCardMutation) SetOfficialAccount(s string) {
  42042. m.official_account = &s
  42043. }
  42044. // OfficialAccount returns the value of the "official_account" field in the mutation.
  42045. func (m *WxCardMutation) OfficialAccount() (r string, exists bool) {
  42046. v := m.official_account
  42047. if v == nil {
  42048. return
  42049. }
  42050. return *v, true
  42051. }
  42052. // OldOfficialAccount returns the old "official_account" field's value of the WxCard entity.
  42053. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  42054. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42055. func (m *WxCardMutation) OldOfficialAccount(ctx context.Context) (v string, err error) {
  42056. if !m.op.Is(OpUpdateOne) {
  42057. return v, errors.New("OldOfficialAccount is only allowed on UpdateOne operations")
  42058. }
  42059. if m.id == nil || m.oldValue == nil {
  42060. return v, errors.New("OldOfficialAccount requires an ID field in the mutation")
  42061. }
  42062. oldValue, err := m.oldValue(ctx)
  42063. if err != nil {
  42064. return v, fmt.Errorf("querying old value for OldOfficialAccount: %w", err)
  42065. }
  42066. return oldValue.OfficialAccount, nil
  42067. }
  42068. // ResetOfficialAccount resets all changes to the "official_account" field.
  42069. func (m *WxCardMutation) ResetOfficialAccount() {
  42070. m.official_account = nil
  42071. }
  42072. // SetWechatAccount sets the "wechat_account" field.
  42073. func (m *WxCardMutation) SetWechatAccount(s string) {
  42074. m.wechat_account = &s
  42075. }
  42076. // WechatAccount returns the value of the "wechat_account" field in the mutation.
  42077. func (m *WxCardMutation) WechatAccount() (r string, exists bool) {
  42078. v := m.wechat_account
  42079. if v == nil {
  42080. return
  42081. }
  42082. return *v, true
  42083. }
  42084. // OldWechatAccount returns the old "wechat_account" field's value of the WxCard entity.
  42085. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  42086. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42087. func (m *WxCardMutation) OldWechatAccount(ctx context.Context) (v string, err error) {
  42088. if !m.op.Is(OpUpdateOne) {
  42089. return v, errors.New("OldWechatAccount is only allowed on UpdateOne operations")
  42090. }
  42091. if m.id == nil || m.oldValue == nil {
  42092. return v, errors.New("OldWechatAccount requires an ID field in the mutation")
  42093. }
  42094. oldValue, err := m.oldValue(ctx)
  42095. if err != nil {
  42096. return v, fmt.Errorf("querying old value for OldWechatAccount: %w", err)
  42097. }
  42098. return oldValue.WechatAccount, nil
  42099. }
  42100. // ResetWechatAccount resets all changes to the "wechat_account" field.
  42101. func (m *WxCardMutation) ResetWechatAccount() {
  42102. m.wechat_account = nil
  42103. }
  42104. // SetEmail sets the "email" field.
  42105. func (m *WxCardMutation) SetEmail(s string) {
  42106. m.email = &s
  42107. }
  42108. // Email returns the value of the "email" field in the mutation.
  42109. func (m *WxCardMutation) Email() (r string, exists bool) {
  42110. v := m.email
  42111. if v == nil {
  42112. return
  42113. }
  42114. return *v, true
  42115. }
  42116. // OldEmail returns the old "email" field's value of the WxCard entity.
  42117. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  42118. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42119. func (m *WxCardMutation) OldEmail(ctx context.Context) (v string, err error) {
  42120. if !m.op.Is(OpUpdateOne) {
  42121. return v, errors.New("OldEmail is only allowed on UpdateOne operations")
  42122. }
  42123. if m.id == nil || m.oldValue == nil {
  42124. return v, errors.New("OldEmail requires an ID field in the mutation")
  42125. }
  42126. oldValue, err := m.oldValue(ctx)
  42127. if err != nil {
  42128. return v, fmt.Errorf("querying old value for OldEmail: %w", err)
  42129. }
  42130. return oldValue.Email, nil
  42131. }
  42132. // ClearEmail clears the value of the "email" field.
  42133. func (m *WxCardMutation) ClearEmail() {
  42134. m.email = nil
  42135. m.clearedFields[wxcard.FieldEmail] = struct{}{}
  42136. }
  42137. // EmailCleared returns if the "email" field was cleared in this mutation.
  42138. func (m *WxCardMutation) EmailCleared() bool {
  42139. _, ok := m.clearedFields[wxcard.FieldEmail]
  42140. return ok
  42141. }
  42142. // ResetEmail resets all changes to the "email" field.
  42143. func (m *WxCardMutation) ResetEmail() {
  42144. m.email = nil
  42145. delete(m.clearedFields, wxcard.FieldEmail)
  42146. }
  42147. // SetAPIBase sets the "api_base" field.
  42148. func (m *WxCardMutation) SetAPIBase(s string) {
  42149. m.api_base = &s
  42150. }
  42151. // APIBase returns the value of the "api_base" field in the mutation.
  42152. func (m *WxCardMutation) APIBase() (r string, exists bool) {
  42153. v := m.api_base
  42154. if v == nil {
  42155. return
  42156. }
  42157. return *v, true
  42158. }
  42159. // OldAPIBase returns the old "api_base" field's value of the WxCard entity.
  42160. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  42161. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42162. func (m *WxCardMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  42163. if !m.op.Is(OpUpdateOne) {
  42164. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  42165. }
  42166. if m.id == nil || m.oldValue == nil {
  42167. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  42168. }
  42169. oldValue, err := m.oldValue(ctx)
  42170. if err != nil {
  42171. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  42172. }
  42173. return oldValue.APIBase, nil
  42174. }
  42175. // ClearAPIBase clears the value of the "api_base" field.
  42176. func (m *WxCardMutation) ClearAPIBase() {
  42177. m.api_base = nil
  42178. m.clearedFields[wxcard.FieldAPIBase] = struct{}{}
  42179. }
  42180. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  42181. func (m *WxCardMutation) APIBaseCleared() bool {
  42182. _, ok := m.clearedFields[wxcard.FieldAPIBase]
  42183. return ok
  42184. }
  42185. // ResetAPIBase resets all changes to the "api_base" field.
  42186. func (m *WxCardMutation) ResetAPIBase() {
  42187. m.api_base = nil
  42188. delete(m.clearedFields, wxcard.FieldAPIBase)
  42189. }
  42190. // SetAPIKey sets the "api_key" field.
  42191. func (m *WxCardMutation) SetAPIKey(s string) {
  42192. m.api_key = &s
  42193. }
  42194. // APIKey returns the value of the "api_key" field in the mutation.
  42195. func (m *WxCardMutation) APIKey() (r string, exists bool) {
  42196. v := m.api_key
  42197. if v == nil {
  42198. return
  42199. }
  42200. return *v, true
  42201. }
  42202. // OldAPIKey returns the old "api_key" field's value of the WxCard entity.
  42203. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  42204. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42205. func (m *WxCardMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  42206. if !m.op.Is(OpUpdateOne) {
  42207. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  42208. }
  42209. if m.id == nil || m.oldValue == nil {
  42210. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  42211. }
  42212. oldValue, err := m.oldValue(ctx)
  42213. if err != nil {
  42214. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  42215. }
  42216. return oldValue.APIKey, nil
  42217. }
  42218. // ClearAPIKey clears the value of the "api_key" field.
  42219. func (m *WxCardMutation) ClearAPIKey() {
  42220. m.api_key = nil
  42221. m.clearedFields[wxcard.FieldAPIKey] = struct{}{}
  42222. }
  42223. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  42224. func (m *WxCardMutation) APIKeyCleared() bool {
  42225. _, ok := m.clearedFields[wxcard.FieldAPIKey]
  42226. return ok
  42227. }
  42228. // ResetAPIKey resets all changes to the "api_key" field.
  42229. func (m *WxCardMutation) ResetAPIKey() {
  42230. m.api_key = nil
  42231. delete(m.clearedFields, wxcard.FieldAPIKey)
  42232. }
  42233. // SetAiInfo sets the "ai_info" field.
  42234. func (m *WxCardMutation) SetAiInfo(s string) {
  42235. m.ai_info = &s
  42236. }
  42237. // AiInfo returns the value of the "ai_info" field in the mutation.
  42238. func (m *WxCardMutation) AiInfo() (r string, exists bool) {
  42239. v := m.ai_info
  42240. if v == nil {
  42241. return
  42242. }
  42243. return *v, true
  42244. }
  42245. // OldAiInfo returns the old "ai_info" field's value of the WxCard entity.
  42246. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  42247. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42248. func (m *WxCardMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  42249. if !m.op.Is(OpUpdateOne) {
  42250. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  42251. }
  42252. if m.id == nil || m.oldValue == nil {
  42253. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  42254. }
  42255. oldValue, err := m.oldValue(ctx)
  42256. if err != nil {
  42257. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  42258. }
  42259. return oldValue.AiInfo, nil
  42260. }
  42261. // ClearAiInfo clears the value of the "ai_info" field.
  42262. func (m *WxCardMutation) ClearAiInfo() {
  42263. m.ai_info = nil
  42264. m.clearedFields[wxcard.FieldAiInfo] = struct{}{}
  42265. }
  42266. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  42267. func (m *WxCardMutation) AiInfoCleared() bool {
  42268. _, ok := m.clearedFields[wxcard.FieldAiInfo]
  42269. return ok
  42270. }
  42271. // ResetAiInfo resets all changes to the "ai_info" field.
  42272. func (m *WxCardMutation) ResetAiInfo() {
  42273. m.ai_info = nil
  42274. delete(m.clearedFields, wxcard.FieldAiInfo)
  42275. }
  42276. // SetIntro sets the "intro" field.
  42277. func (m *WxCardMutation) SetIntro(s string) {
  42278. m.intro = &s
  42279. }
  42280. // Intro returns the value of the "intro" field in the mutation.
  42281. func (m *WxCardMutation) Intro() (r string, exists bool) {
  42282. v := m.intro
  42283. if v == nil {
  42284. return
  42285. }
  42286. return *v, true
  42287. }
  42288. // OldIntro returns the old "intro" field's value of the WxCard entity.
  42289. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  42290. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42291. func (m *WxCardMutation) OldIntro(ctx context.Context) (v string, err error) {
  42292. if !m.op.Is(OpUpdateOne) {
  42293. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  42294. }
  42295. if m.id == nil || m.oldValue == nil {
  42296. return v, errors.New("OldIntro requires an ID field in the mutation")
  42297. }
  42298. oldValue, err := m.oldValue(ctx)
  42299. if err != nil {
  42300. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  42301. }
  42302. return oldValue.Intro, nil
  42303. }
  42304. // ClearIntro clears the value of the "intro" field.
  42305. func (m *WxCardMutation) ClearIntro() {
  42306. m.intro = nil
  42307. m.clearedFields[wxcard.FieldIntro] = struct{}{}
  42308. }
  42309. // IntroCleared returns if the "intro" field was cleared in this mutation.
  42310. func (m *WxCardMutation) IntroCleared() bool {
  42311. _, ok := m.clearedFields[wxcard.FieldIntro]
  42312. return ok
  42313. }
  42314. // ResetIntro resets all changes to the "intro" field.
  42315. func (m *WxCardMutation) ResetIntro() {
  42316. m.intro = nil
  42317. delete(m.clearedFields, wxcard.FieldIntro)
  42318. }
  42319. // Where appends a list predicates to the WxCardMutation builder.
  42320. func (m *WxCardMutation) Where(ps ...predicate.WxCard) {
  42321. m.predicates = append(m.predicates, ps...)
  42322. }
  42323. // WhereP appends storage-level predicates to the WxCardMutation builder. Using this method,
  42324. // users can use type-assertion to append predicates that do not depend on any generated package.
  42325. func (m *WxCardMutation) WhereP(ps ...func(*sql.Selector)) {
  42326. p := make([]predicate.WxCard, len(ps))
  42327. for i := range ps {
  42328. p[i] = ps[i]
  42329. }
  42330. m.Where(p...)
  42331. }
  42332. // Op returns the operation name.
  42333. func (m *WxCardMutation) Op() Op {
  42334. return m.op
  42335. }
  42336. // SetOp allows setting the mutation operation.
  42337. func (m *WxCardMutation) SetOp(op Op) {
  42338. m.op = op
  42339. }
  42340. // Type returns the node type of this mutation (WxCard).
  42341. func (m *WxCardMutation) Type() string {
  42342. return m.typ
  42343. }
  42344. // Fields returns all fields that were changed during this mutation. Note that in
  42345. // order to get all numeric fields that were incremented/decremented, call
  42346. // AddedFields().
  42347. func (m *WxCardMutation) Fields() []string {
  42348. fields := make([]string, 0, 18)
  42349. if m.created_at != nil {
  42350. fields = append(fields, wxcard.FieldCreatedAt)
  42351. }
  42352. if m.updated_at != nil {
  42353. fields = append(fields, wxcard.FieldUpdatedAt)
  42354. }
  42355. if m.deleted_at != nil {
  42356. fields = append(fields, wxcard.FieldDeletedAt)
  42357. }
  42358. if m.user_id != nil {
  42359. fields = append(fields, wxcard.FieldUserID)
  42360. }
  42361. if m.wx_user_id != nil {
  42362. fields = append(fields, wxcard.FieldWxUserID)
  42363. }
  42364. if m.avatar != nil {
  42365. fields = append(fields, wxcard.FieldAvatar)
  42366. }
  42367. if m.logo != nil {
  42368. fields = append(fields, wxcard.FieldLogo)
  42369. }
  42370. if m.name != nil {
  42371. fields = append(fields, wxcard.FieldName)
  42372. }
  42373. if m.company != nil {
  42374. fields = append(fields, wxcard.FieldCompany)
  42375. }
  42376. if m.address != nil {
  42377. fields = append(fields, wxcard.FieldAddress)
  42378. }
  42379. if m.phone != nil {
  42380. fields = append(fields, wxcard.FieldPhone)
  42381. }
  42382. if m.official_account != nil {
  42383. fields = append(fields, wxcard.FieldOfficialAccount)
  42384. }
  42385. if m.wechat_account != nil {
  42386. fields = append(fields, wxcard.FieldWechatAccount)
  42387. }
  42388. if m.email != nil {
  42389. fields = append(fields, wxcard.FieldEmail)
  42390. }
  42391. if m.api_base != nil {
  42392. fields = append(fields, wxcard.FieldAPIBase)
  42393. }
  42394. if m.api_key != nil {
  42395. fields = append(fields, wxcard.FieldAPIKey)
  42396. }
  42397. if m.ai_info != nil {
  42398. fields = append(fields, wxcard.FieldAiInfo)
  42399. }
  42400. if m.intro != nil {
  42401. fields = append(fields, wxcard.FieldIntro)
  42402. }
  42403. return fields
  42404. }
  42405. // Field returns the value of a field with the given name. The second boolean
  42406. // return value indicates that this field was not set, or was not defined in the
  42407. // schema.
  42408. func (m *WxCardMutation) Field(name string) (ent.Value, bool) {
  42409. switch name {
  42410. case wxcard.FieldCreatedAt:
  42411. return m.CreatedAt()
  42412. case wxcard.FieldUpdatedAt:
  42413. return m.UpdatedAt()
  42414. case wxcard.FieldDeletedAt:
  42415. return m.DeletedAt()
  42416. case wxcard.FieldUserID:
  42417. return m.UserID()
  42418. case wxcard.FieldWxUserID:
  42419. return m.WxUserID()
  42420. case wxcard.FieldAvatar:
  42421. return m.Avatar()
  42422. case wxcard.FieldLogo:
  42423. return m.Logo()
  42424. case wxcard.FieldName:
  42425. return m.Name()
  42426. case wxcard.FieldCompany:
  42427. return m.Company()
  42428. case wxcard.FieldAddress:
  42429. return m.Address()
  42430. case wxcard.FieldPhone:
  42431. return m.Phone()
  42432. case wxcard.FieldOfficialAccount:
  42433. return m.OfficialAccount()
  42434. case wxcard.FieldWechatAccount:
  42435. return m.WechatAccount()
  42436. case wxcard.FieldEmail:
  42437. return m.Email()
  42438. case wxcard.FieldAPIBase:
  42439. return m.APIBase()
  42440. case wxcard.FieldAPIKey:
  42441. return m.APIKey()
  42442. case wxcard.FieldAiInfo:
  42443. return m.AiInfo()
  42444. case wxcard.FieldIntro:
  42445. return m.Intro()
  42446. }
  42447. return nil, false
  42448. }
  42449. // OldField returns the old value of the field from the database. An error is
  42450. // returned if the mutation operation is not UpdateOne, or the query to the
  42451. // database failed.
  42452. func (m *WxCardMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  42453. switch name {
  42454. case wxcard.FieldCreatedAt:
  42455. return m.OldCreatedAt(ctx)
  42456. case wxcard.FieldUpdatedAt:
  42457. return m.OldUpdatedAt(ctx)
  42458. case wxcard.FieldDeletedAt:
  42459. return m.OldDeletedAt(ctx)
  42460. case wxcard.FieldUserID:
  42461. return m.OldUserID(ctx)
  42462. case wxcard.FieldWxUserID:
  42463. return m.OldWxUserID(ctx)
  42464. case wxcard.FieldAvatar:
  42465. return m.OldAvatar(ctx)
  42466. case wxcard.FieldLogo:
  42467. return m.OldLogo(ctx)
  42468. case wxcard.FieldName:
  42469. return m.OldName(ctx)
  42470. case wxcard.FieldCompany:
  42471. return m.OldCompany(ctx)
  42472. case wxcard.FieldAddress:
  42473. return m.OldAddress(ctx)
  42474. case wxcard.FieldPhone:
  42475. return m.OldPhone(ctx)
  42476. case wxcard.FieldOfficialAccount:
  42477. return m.OldOfficialAccount(ctx)
  42478. case wxcard.FieldWechatAccount:
  42479. return m.OldWechatAccount(ctx)
  42480. case wxcard.FieldEmail:
  42481. return m.OldEmail(ctx)
  42482. case wxcard.FieldAPIBase:
  42483. return m.OldAPIBase(ctx)
  42484. case wxcard.FieldAPIKey:
  42485. return m.OldAPIKey(ctx)
  42486. case wxcard.FieldAiInfo:
  42487. return m.OldAiInfo(ctx)
  42488. case wxcard.FieldIntro:
  42489. return m.OldIntro(ctx)
  42490. }
  42491. return nil, fmt.Errorf("unknown WxCard field %s", name)
  42492. }
  42493. // SetField sets the value of a field with the given name. It returns an error if
  42494. // the field is not defined in the schema, or if the type mismatched the field
  42495. // type.
  42496. func (m *WxCardMutation) SetField(name string, value ent.Value) error {
  42497. switch name {
  42498. case wxcard.FieldCreatedAt:
  42499. v, ok := value.(time.Time)
  42500. if !ok {
  42501. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42502. }
  42503. m.SetCreatedAt(v)
  42504. return nil
  42505. case wxcard.FieldUpdatedAt:
  42506. v, ok := value.(time.Time)
  42507. if !ok {
  42508. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42509. }
  42510. m.SetUpdatedAt(v)
  42511. return nil
  42512. case wxcard.FieldDeletedAt:
  42513. v, ok := value.(time.Time)
  42514. if !ok {
  42515. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42516. }
  42517. m.SetDeletedAt(v)
  42518. return nil
  42519. case wxcard.FieldUserID:
  42520. v, ok := value.(uint64)
  42521. if !ok {
  42522. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42523. }
  42524. m.SetUserID(v)
  42525. return nil
  42526. case wxcard.FieldWxUserID:
  42527. v, ok := value.(uint64)
  42528. if !ok {
  42529. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42530. }
  42531. m.SetWxUserID(v)
  42532. return nil
  42533. case wxcard.FieldAvatar:
  42534. v, ok := value.(string)
  42535. if !ok {
  42536. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42537. }
  42538. m.SetAvatar(v)
  42539. return nil
  42540. case wxcard.FieldLogo:
  42541. v, ok := value.(string)
  42542. if !ok {
  42543. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42544. }
  42545. m.SetLogo(v)
  42546. return nil
  42547. case wxcard.FieldName:
  42548. v, ok := value.(string)
  42549. if !ok {
  42550. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42551. }
  42552. m.SetName(v)
  42553. return nil
  42554. case wxcard.FieldCompany:
  42555. v, ok := value.(string)
  42556. if !ok {
  42557. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42558. }
  42559. m.SetCompany(v)
  42560. return nil
  42561. case wxcard.FieldAddress:
  42562. v, ok := value.(string)
  42563. if !ok {
  42564. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42565. }
  42566. m.SetAddress(v)
  42567. return nil
  42568. case wxcard.FieldPhone:
  42569. v, ok := value.(string)
  42570. if !ok {
  42571. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42572. }
  42573. m.SetPhone(v)
  42574. return nil
  42575. case wxcard.FieldOfficialAccount:
  42576. v, ok := value.(string)
  42577. if !ok {
  42578. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42579. }
  42580. m.SetOfficialAccount(v)
  42581. return nil
  42582. case wxcard.FieldWechatAccount:
  42583. v, ok := value.(string)
  42584. if !ok {
  42585. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42586. }
  42587. m.SetWechatAccount(v)
  42588. return nil
  42589. case wxcard.FieldEmail:
  42590. v, ok := value.(string)
  42591. if !ok {
  42592. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42593. }
  42594. m.SetEmail(v)
  42595. return nil
  42596. case wxcard.FieldAPIBase:
  42597. v, ok := value.(string)
  42598. if !ok {
  42599. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42600. }
  42601. m.SetAPIBase(v)
  42602. return nil
  42603. case wxcard.FieldAPIKey:
  42604. v, ok := value.(string)
  42605. if !ok {
  42606. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42607. }
  42608. m.SetAPIKey(v)
  42609. return nil
  42610. case wxcard.FieldAiInfo:
  42611. v, ok := value.(string)
  42612. if !ok {
  42613. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42614. }
  42615. m.SetAiInfo(v)
  42616. return nil
  42617. case wxcard.FieldIntro:
  42618. v, ok := value.(string)
  42619. if !ok {
  42620. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42621. }
  42622. m.SetIntro(v)
  42623. return nil
  42624. }
  42625. return fmt.Errorf("unknown WxCard field %s", name)
  42626. }
  42627. // AddedFields returns all numeric fields that were incremented/decremented during
  42628. // this mutation.
  42629. func (m *WxCardMutation) AddedFields() []string {
  42630. var fields []string
  42631. if m.adduser_id != nil {
  42632. fields = append(fields, wxcard.FieldUserID)
  42633. }
  42634. if m.addwx_user_id != nil {
  42635. fields = append(fields, wxcard.FieldWxUserID)
  42636. }
  42637. return fields
  42638. }
  42639. // AddedField returns the numeric value that was incremented/decremented on a field
  42640. // with the given name. The second boolean return value indicates that this field
  42641. // was not set, or was not defined in the schema.
  42642. func (m *WxCardMutation) AddedField(name string) (ent.Value, bool) {
  42643. switch name {
  42644. case wxcard.FieldUserID:
  42645. return m.AddedUserID()
  42646. case wxcard.FieldWxUserID:
  42647. return m.AddedWxUserID()
  42648. }
  42649. return nil, false
  42650. }
  42651. // AddField adds the value to the field with the given name. It returns an error if
  42652. // the field is not defined in the schema, or if the type mismatched the field
  42653. // type.
  42654. func (m *WxCardMutation) AddField(name string, value ent.Value) error {
  42655. switch name {
  42656. case wxcard.FieldUserID:
  42657. v, ok := value.(int64)
  42658. if !ok {
  42659. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42660. }
  42661. m.AddUserID(v)
  42662. return nil
  42663. case wxcard.FieldWxUserID:
  42664. v, ok := value.(int64)
  42665. if !ok {
  42666. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42667. }
  42668. m.AddWxUserID(v)
  42669. return nil
  42670. }
  42671. return fmt.Errorf("unknown WxCard numeric field %s", name)
  42672. }
  42673. // ClearedFields returns all nullable fields that were cleared during this
  42674. // mutation.
  42675. func (m *WxCardMutation) ClearedFields() []string {
  42676. var fields []string
  42677. if m.FieldCleared(wxcard.FieldDeletedAt) {
  42678. fields = append(fields, wxcard.FieldDeletedAt)
  42679. }
  42680. if m.FieldCleared(wxcard.FieldUserID) {
  42681. fields = append(fields, wxcard.FieldUserID)
  42682. }
  42683. if m.FieldCleared(wxcard.FieldWxUserID) {
  42684. fields = append(fields, wxcard.FieldWxUserID)
  42685. }
  42686. if m.FieldCleared(wxcard.FieldEmail) {
  42687. fields = append(fields, wxcard.FieldEmail)
  42688. }
  42689. if m.FieldCleared(wxcard.FieldAPIBase) {
  42690. fields = append(fields, wxcard.FieldAPIBase)
  42691. }
  42692. if m.FieldCleared(wxcard.FieldAPIKey) {
  42693. fields = append(fields, wxcard.FieldAPIKey)
  42694. }
  42695. if m.FieldCleared(wxcard.FieldAiInfo) {
  42696. fields = append(fields, wxcard.FieldAiInfo)
  42697. }
  42698. if m.FieldCleared(wxcard.FieldIntro) {
  42699. fields = append(fields, wxcard.FieldIntro)
  42700. }
  42701. return fields
  42702. }
  42703. // FieldCleared returns a boolean indicating if a field with the given name was
  42704. // cleared in this mutation.
  42705. func (m *WxCardMutation) FieldCleared(name string) bool {
  42706. _, ok := m.clearedFields[name]
  42707. return ok
  42708. }
  42709. // ClearField clears the value of the field with the given name. It returns an
  42710. // error if the field is not defined in the schema.
  42711. func (m *WxCardMutation) ClearField(name string) error {
  42712. switch name {
  42713. case wxcard.FieldDeletedAt:
  42714. m.ClearDeletedAt()
  42715. return nil
  42716. case wxcard.FieldUserID:
  42717. m.ClearUserID()
  42718. return nil
  42719. case wxcard.FieldWxUserID:
  42720. m.ClearWxUserID()
  42721. return nil
  42722. case wxcard.FieldEmail:
  42723. m.ClearEmail()
  42724. return nil
  42725. case wxcard.FieldAPIBase:
  42726. m.ClearAPIBase()
  42727. return nil
  42728. case wxcard.FieldAPIKey:
  42729. m.ClearAPIKey()
  42730. return nil
  42731. case wxcard.FieldAiInfo:
  42732. m.ClearAiInfo()
  42733. return nil
  42734. case wxcard.FieldIntro:
  42735. m.ClearIntro()
  42736. return nil
  42737. }
  42738. return fmt.Errorf("unknown WxCard nullable field %s", name)
  42739. }
  42740. // ResetField resets all changes in the mutation for the field with the given name.
  42741. // It returns an error if the field is not defined in the schema.
  42742. func (m *WxCardMutation) ResetField(name string) error {
  42743. switch name {
  42744. case wxcard.FieldCreatedAt:
  42745. m.ResetCreatedAt()
  42746. return nil
  42747. case wxcard.FieldUpdatedAt:
  42748. m.ResetUpdatedAt()
  42749. return nil
  42750. case wxcard.FieldDeletedAt:
  42751. m.ResetDeletedAt()
  42752. return nil
  42753. case wxcard.FieldUserID:
  42754. m.ResetUserID()
  42755. return nil
  42756. case wxcard.FieldWxUserID:
  42757. m.ResetWxUserID()
  42758. return nil
  42759. case wxcard.FieldAvatar:
  42760. m.ResetAvatar()
  42761. return nil
  42762. case wxcard.FieldLogo:
  42763. m.ResetLogo()
  42764. return nil
  42765. case wxcard.FieldName:
  42766. m.ResetName()
  42767. return nil
  42768. case wxcard.FieldCompany:
  42769. m.ResetCompany()
  42770. return nil
  42771. case wxcard.FieldAddress:
  42772. m.ResetAddress()
  42773. return nil
  42774. case wxcard.FieldPhone:
  42775. m.ResetPhone()
  42776. return nil
  42777. case wxcard.FieldOfficialAccount:
  42778. m.ResetOfficialAccount()
  42779. return nil
  42780. case wxcard.FieldWechatAccount:
  42781. m.ResetWechatAccount()
  42782. return nil
  42783. case wxcard.FieldEmail:
  42784. m.ResetEmail()
  42785. return nil
  42786. case wxcard.FieldAPIBase:
  42787. m.ResetAPIBase()
  42788. return nil
  42789. case wxcard.FieldAPIKey:
  42790. m.ResetAPIKey()
  42791. return nil
  42792. case wxcard.FieldAiInfo:
  42793. m.ResetAiInfo()
  42794. return nil
  42795. case wxcard.FieldIntro:
  42796. m.ResetIntro()
  42797. return nil
  42798. }
  42799. return fmt.Errorf("unknown WxCard field %s", name)
  42800. }
  42801. // AddedEdges returns all edge names that were set/added in this mutation.
  42802. func (m *WxCardMutation) AddedEdges() []string {
  42803. edges := make([]string, 0, 0)
  42804. return edges
  42805. }
  42806. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  42807. // name in this mutation.
  42808. func (m *WxCardMutation) AddedIDs(name string) []ent.Value {
  42809. return nil
  42810. }
  42811. // RemovedEdges returns all edge names that were removed in this mutation.
  42812. func (m *WxCardMutation) RemovedEdges() []string {
  42813. edges := make([]string, 0, 0)
  42814. return edges
  42815. }
  42816. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  42817. // the given name in this mutation.
  42818. func (m *WxCardMutation) RemovedIDs(name string) []ent.Value {
  42819. return nil
  42820. }
  42821. // ClearedEdges returns all edge names that were cleared in this mutation.
  42822. func (m *WxCardMutation) ClearedEdges() []string {
  42823. edges := make([]string, 0, 0)
  42824. return edges
  42825. }
  42826. // EdgeCleared returns a boolean which indicates if the edge with the given name
  42827. // was cleared in this mutation.
  42828. func (m *WxCardMutation) EdgeCleared(name string) bool {
  42829. return false
  42830. }
  42831. // ClearEdge clears the value of the edge with the given name. It returns an error
  42832. // if that edge is not defined in the schema.
  42833. func (m *WxCardMutation) ClearEdge(name string) error {
  42834. return fmt.Errorf("unknown WxCard unique edge %s", name)
  42835. }
  42836. // ResetEdge resets all changes to the edge with the given name in this mutation.
  42837. // It returns an error if the edge is not defined in the schema.
  42838. func (m *WxCardMutation) ResetEdge(name string) error {
  42839. return fmt.Errorf("unknown WxCard edge %s", name)
  42840. }
  42841. // WxCardUserMutation represents an operation that mutates the WxCardUser nodes in the graph.
  42842. type WxCardUserMutation struct {
  42843. config
  42844. op Op
  42845. typ string
  42846. id *uint64
  42847. created_at *time.Time
  42848. updated_at *time.Time
  42849. deleted_at *time.Time
  42850. wxid *string
  42851. account *string
  42852. avatar *string
  42853. nickname *string
  42854. remark *string
  42855. phone *string
  42856. open_id *string
  42857. union_id *string
  42858. session_key *string
  42859. is_vip *int
  42860. addis_vip *int
  42861. clearedFields map[string]struct{}
  42862. done bool
  42863. oldValue func(context.Context) (*WxCardUser, error)
  42864. predicates []predicate.WxCardUser
  42865. }
  42866. var _ ent.Mutation = (*WxCardUserMutation)(nil)
  42867. // wxcarduserOption allows management of the mutation configuration using functional options.
  42868. type wxcarduserOption func(*WxCardUserMutation)
  42869. // newWxCardUserMutation creates new mutation for the WxCardUser entity.
  42870. func newWxCardUserMutation(c config, op Op, opts ...wxcarduserOption) *WxCardUserMutation {
  42871. m := &WxCardUserMutation{
  42872. config: c,
  42873. op: op,
  42874. typ: TypeWxCardUser,
  42875. clearedFields: make(map[string]struct{}),
  42876. }
  42877. for _, opt := range opts {
  42878. opt(m)
  42879. }
  42880. return m
  42881. }
  42882. // withWxCardUserID sets the ID field of the mutation.
  42883. func withWxCardUserID(id uint64) wxcarduserOption {
  42884. return func(m *WxCardUserMutation) {
  42885. var (
  42886. err error
  42887. once sync.Once
  42888. value *WxCardUser
  42889. )
  42890. m.oldValue = func(ctx context.Context) (*WxCardUser, error) {
  42891. once.Do(func() {
  42892. if m.done {
  42893. err = errors.New("querying old values post mutation is not allowed")
  42894. } else {
  42895. value, err = m.Client().WxCardUser.Get(ctx, id)
  42896. }
  42897. })
  42898. return value, err
  42899. }
  42900. m.id = &id
  42901. }
  42902. }
  42903. // withWxCardUser sets the old WxCardUser of the mutation.
  42904. func withWxCardUser(node *WxCardUser) wxcarduserOption {
  42905. return func(m *WxCardUserMutation) {
  42906. m.oldValue = func(context.Context) (*WxCardUser, error) {
  42907. return node, nil
  42908. }
  42909. m.id = &node.ID
  42910. }
  42911. }
  42912. // Client returns a new `ent.Client` from the mutation. If the mutation was
  42913. // executed in a transaction (ent.Tx), a transactional client is returned.
  42914. func (m WxCardUserMutation) Client() *Client {
  42915. client := &Client{config: m.config}
  42916. client.init()
  42917. return client
  42918. }
  42919. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  42920. // it returns an error otherwise.
  42921. func (m WxCardUserMutation) Tx() (*Tx, error) {
  42922. if _, ok := m.driver.(*txDriver); !ok {
  42923. return nil, errors.New("ent: mutation is not running in a transaction")
  42924. }
  42925. tx := &Tx{config: m.config}
  42926. tx.init()
  42927. return tx, nil
  42928. }
  42929. // SetID sets the value of the id field. Note that this
  42930. // operation is only accepted on creation of WxCardUser entities.
  42931. func (m *WxCardUserMutation) SetID(id uint64) {
  42932. m.id = &id
  42933. }
  42934. // ID returns the ID value in the mutation. Note that the ID is only available
  42935. // if it was provided to the builder or after it was returned from the database.
  42936. func (m *WxCardUserMutation) ID() (id uint64, exists bool) {
  42937. if m.id == nil {
  42938. return
  42939. }
  42940. return *m.id, true
  42941. }
  42942. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  42943. // That means, if the mutation is applied within a transaction with an isolation level such
  42944. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  42945. // or updated by the mutation.
  42946. func (m *WxCardUserMutation) IDs(ctx context.Context) ([]uint64, error) {
  42947. switch {
  42948. case m.op.Is(OpUpdateOne | OpDeleteOne):
  42949. id, exists := m.ID()
  42950. if exists {
  42951. return []uint64{id}, nil
  42952. }
  42953. fallthrough
  42954. case m.op.Is(OpUpdate | OpDelete):
  42955. return m.Client().WxCardUser.Query().Where(m.predicates...).IDs(ctx)
  42956. default:
  42957. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  42958. }
  42959. }
  42960. // SetCreatedAt sets the "created_at" field.
  42961. func (m *WxCardUserMutation) SetCreatedAt(t time.Time) {
  42962. m.created_at = &t
  42963. }
  42964. // CreatedAt returns the value of the "created_at" field in the mutation.
  42965. func (m *WxCardUserMutation) CreatedAt() (r time.Time, exists bool) {
  42966. v := m.created_at
  42967. if v == nil {
  42968. return
  42969. }
  42970. return *v, true
  42971. }
  42972. // OldCreatedAt returns the old "created_at" field's value of the WxCardUser entity.
  42973. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  42974. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42975. func (m *WxCardUserMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  42976. if !m.op.Is(OpUpdateOne) {
  42977. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  42978. }
  42979. if m.id == nil || m.oldValue == nil {
  42980. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  42981. }
  42982. oldValue, err := m.oldValue(ctx)
  42983. if err != nil {
  42984. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  42985. }
  42986. return oldValue.CreatedAt, nil
  42987. }
  42988. // ResetCreatedAt resets all changes to the "created_at" field.
  42989. func (m *WxCardUserMutation) ResetCreatedAt() {
  42990. m.created_at = nil
  42991. }
  42992. // SetUpdatedAt sets the "updated_at" field.
  42993. func (m *WxCardUserMutation) SetUpdatedAt(t time.Time) {
  42994. m.updated_at = &t
  42995. }
  42996. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  42997. func (m *WxCardUserMutation) UpdatedAt() (r time.Time, exists bool) {
  42998. v := m.updated_at
  42999. if v == nil {
  43000. return
  43001. }
  43002. return *v, true
  43003. }
  43004. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardUser entity.
  43005. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  43006. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43007. func (m *WxCardUserMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  43008. if !m.op.Is(OpUpdateOne) {
  43009. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  43010. }
  43011. if m.id == nil || m.oldValue == nil {
  43012. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  43013. }
  43014. oldValue, err := m.oldValue(ctx)
  43015. if err != nil {
  43016. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  43017. }
  43018. return oldValue.UpdatedAt, nil
  43019. }
  43020. // ResetUpdatedAt resets all changes to the "updated_at" field.
  43021. func (m *WxCardUserMutation) ResetUpdatedAt() {
  43022. m.updated_at = nil
  43023. }
  43024. // SetDeletedAt sets the "deleted_at" field.
  43025. func (m *WxCardUserMutation) SetDeletedAt(t time.Time) {
  43026. m.deleted_at = &t
  43027. }
  43028. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  43029. func (m *WxCardUserMutation) DeletedAt() (r time.Time, exists bool) {
  43030. v := m.deleted_at
  43031. if v == nil {
  43032. return
  43033. }
  43034. return *v, true
  43035. }
  43036. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardUser entity.
  43037. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  43038. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43039. func (m *WxCardUserMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  43040. if !m.op.Is(OpUpdateOne) {
  43041. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  43042. }
  43043. if m.id == nil || m.oldValue == nil {
  43044. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  43045. }
  43046. oldValue, err := m.oldValue(ctx)
  43047. if err != nil {
  43048. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  43049. }
  43050. return oldValue.DeletedAt, nil
  43051. }
  43052. // ClearDeletedAt clears the value of the "deleted_at" field.
  43053. func (m *WxCardUserMutation) ClearDeletedAt() {
  43054. m.deleted_at = nil
  43055. m.clearedFields[wxcarduser.FieldDeletedAt] = struct{}{}
  43056. }
  43057. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  43058. func (m *WxCardUserMutation) DeletedAtCleared() bool {
  43059. _, ok := m.clearedFields[wxcarduser.FieldDeletedAt]
  43060. return ok
  43061. }
  43062. // ResetDeletedAt resets all changes to the "deleted_at" field.
  43063. func (m *WxCardUserMutation) ResetDeletedAt() {
  43064. m.deleted_at = nil
  43065. delete(m.clearedFields, wxcarduser.FieldDeletedAt)
  43066. }
  43067. // SetWxid sets the "wxid" field.
  43068. func (m *WxCardUserMutation) SetWxid(s string) {
  43069. m.wxid = &s
  43070. }
  43071. // Wxid returns the value of the "wxid" field in the mutation.
  43072. func (m *WxCardUserMutation) Wxid() (r string, exists bool) {
  43073. v := m.wxid
  43074. if v == nil {
  43075. return
  43076. }
  43077. return *v, true
  43078. }
  43079. // OldWxid returns the old "wxid" field's value of the WxCardUser entity.
  43080. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  43081. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43082. func (m *WxCardUserMutation) OldWxid(ctx context.Context) (v string, err error) {
  43083. if !m.op.Is(OpUpdateOne) {
  43084. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  43085. }
  43086. if m.id == nil || m.oldValue == nil {
  43087. return v, errors.New("OldWxid requires an ID field in the mutation")
  43088. }
  43089. oldValue, err := m.oldValue(ctx)
  43090. if err != nil {
  43091. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  43092. }
  43093. return oldValue.Wxid, nil
  43094. }
  43095. // ResetWxid resets all changes to the "wxid" field.
  43096. func (m *WxCardUserMutation) ResetWxid() {
  43097. m.wxid = nil
  43098. }
  43099. // SetAccount sets the "account" field.
  43100. func (m *WxCardUserMutation) SetAccount(s string) {
  43101. m.account = &s
  43102. }
  43103. // Account returns the value of the "account" field in the mutation.
  43104. func (m *WxCardUserMutation) Account() (r string, exists bool) {
  43105. v := m.account
  43106. if v == nil {
  43107. return
  43108. }
  43109. return *v, true
  43110. }
  43111. // OldAccount returns the old "account" field's value of the WxCardUser entity.
  43112. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  43113. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43114. func (m *WxCardUserMutation) OldAccount(ctx context.Context) (v string, err error) {
  43115. if !m.op.Is(OpUpdateOne) {
  43116. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  43117. }
  43118. if m.id == nil || m.oldValue == nil {
  43119. return v, errors.New("OldAccount requires an ID field in the mutation")
  43120. }
  43121. oldValue, err := m.oldValue(ctx)
  43122. if err != nil {
  43123. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  43124. }
  43125. return oldValue.Account, nil
  43126. }
  43127. // ResetAccount resets all changes to the "account" field.
  43128. func (m *WxCardUserMutation) ResetAccount() {
  43129. m.account = nil
  43130. }
  43131. // SetAvatar sets the "avatar" field.
  43132. func (m *WxCardUserMutation) SetAvatar(s string) {
  43133. m.avatar = &s
  43134. }
  43135. // Avatar returns the value of the "avatar" field in the mutation.
  43136. func (m *WxCardUserMutation) Avatar() (r string, exists bool) {
  43137. v := m.avatar
  43138. if v == nil {
  43139. return
  43140. }
  43141. return *v, true
  43142. }
  43143. // OldAvatar returns the old "avatar" field's value of the WxCardUser entity.
  43144. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  43145. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43146. func (m *WxCardUserMutation) OldAvatar(ctx context.Context) (v string, err error) {
  43147. if !m.op.Is(OpUpdateOne) {
  43148. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  43149. }
  43150. if m.id == nil || m.oldValue == nil {
  43151. return v, errors.New("OldAvatar requires an ID field in the mutation")
  43152. }
  43153. oldValue, err := m.oldValue(ctx)
  43154. if err != nil {
  43155. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  43156. }
  43157. return oldValue.Avatar, nil
  43158. }
  43159. // ResetAvatar resets all changes to the "avatar" field.
  43160. func (m *WxCardUserMutation) ResetAvatar() {
  43161. m.avatar = nil
  43162. }
  43163. // SetNickname sets the "nickname" field.
  43164. func (m *WxCardUserMutation) SetNickname(s string) {
  43165. m.nickname = &s
  43166. }
  43167. // Nickname returns the value of the "nickname" field in the mutation.
  43168. func (m *WxCardUserMutation) Nickname() (r string, exists bool) {
  43169. v := m.nickname
  43170. if v == nil {
  43171. return
  43172. }
  43173. return *v, true
  43174. }
  43175. // OldNickname returns the old "nickname" field's value of the WxCardUser entity.
  43176. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  43177. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43178. func (m *WxCardUserMutation) OldNickname(ctx context.Context) (v string, err error) {
  43179. if !m.op.Is(OpUpdateOne) {
  43180. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  43181. }
  43182. if m.id == nil || m.oldValue == nil {
  43183. return v, errors.New("OldNickname requires an ID field in the mutation")
  43184. }
  43185. oldValue, err := m.oldValue(ctx)
  43186. if err != nil {
  43187. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  43188. }
  43189. return oldValue.Nickname, nil
  43190. }
  43191. // ResetNickname resets all changes to the "nickname" field.
  43192. func (m *WxCardUserMutation) ResetNickname() {
  43193. m.nickname = nil
  43194. }
  43195. // SetRemark sets the "remark" field.
  43196. func (m *WxCardUserMutation) SetRemark(s string) {
  43197. m.remark = &s
  43198. }
  43199. // Remark returns the value of the "remark" field in the mutation.
  43200. func (m *WxCardUserMutation) Remark() (r string, exists bool) {
  43201. v := m.remark
  43202. if v == nil {
  43203. return
  43204. }
  43205. return *v, true
  43206. }
  43207. // OldRemark returns the old "remark" field's value of the WxCardUser entity.
  43208. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  43209. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43210. func (m *WxCardUserMutation) OldRemark(ctx context.Context) (v string, err error) {
  43211. if !m.op.Is(OpUpdateOne) {
  43212. return v, errors.New("OldRemark is only allowed on UpdateOne operations")
  43213. }
  43214. if m.id == nil || m.oldValue == nil {
  43215. return v, errors.New("OldRemark requires an ID field in the mutation")
  43216. }
  43217. oldValue, err := m.oldValue(ctx)
  43218. if err != nil {
  43219. return v, fmt.Errorf("querying old value for OldRemark: %w", err)
  43220. }
  43221. return oldValue.Remark, nil
  43222. }
  43223. // ResetRemark resets all changes to the "remark" field.
  43224. func (m *WxCardUserMutation) ResetRemark() {
  43225. m.remark = nil
  43226. }
  43227. // SetPhone sets the "phone" field.
  43228. func (m *WxCardUserMutation) SetPhone(s string) {
  43229. m.phone = &s
  43230. }
  43231. // Phone returns the value of the "phone" field in the mutation.
  43232. func (m *WxCardUserMutation) Phone() (r string, exists bool) {
  43233. v := m.phone
  43234. if v == nil {
  43235. return
  43236. }
  43237. return *v, true
  43238. }
  43239. // OldPhone returns the old "phone" field's value of the WxCardUser entity.
  43240. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  43241. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43242. func (m *WxCardUserMutation) OldPhone(ctx context.Context) (v string, err error) {
  43243. if !m.op.Is(OpUpdateOne) {
  43244. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  43245. }
  43246. if m.id == nil || m.oldValue == nil {
  43247. return v, errors.New("OldPhone requires an ID field in the mutation")
  43248. }
  43249. oldValue, err := m.oldValue(ctx)
  43250. if err != nil {
  43251. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  43252. }
  43253. return oldValue.Phone, nil
  43254. }
  43255. // ResetPhone resets all changes to the "phone" field.
  43256. func (m *WxCardUserMutation) ResetPhone() {
  43257. m.phone = nil
  43258. }
  43259. // SetOpenID sets the "open_id" field.
  43260. func (m *WxCardUserMutation) SetOpenID(s string) {
  43261. m.open_id = &s
  43262. }
  43263. // OpenID returns the value of the "open_id" field in the mutation.
  43264. func (m *WxCardUserMutation) OpenID() (r string, exists bool) {
  43265. v := m.open_id
  43266. if v == nil {
  43267. return
  43268. }
  43269. return *v, true
  43270. }
  43271. // OldOpenID returns the old "open_id" field's value of the WxCardUser entity.
  43272. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  43273. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43274. func (m *WxCardUserMutation) OldOpenID(ctx context.Context) (v string, err error) {
  43275. if !m.op.Is(OpUpdateOne) {
  43276. return v, errors.New("OldOpenID is only allowed on UpdateOne operations")
  43277. }
  43278. if m.id == nil || m.oldValue == nil {
  43279. return v, errors.New("OldOpenID requires an ID field in the mutation")
  43280. }
  43281. oldValue, err := m.oldValue(ctx)
  43282. if err != nil {
  43283. return v, fmt.Errorf("querying old value for OldOpenID: %w", err)
  43284. }
  43285. return oldValue.OpenID, nil
  43286. }
  43287. // ResetOpenID resets all changes to the "open_id" field.
  43288. func (m *WxCardUserMutation) ResetOpenID() {
  43289. m.open_id = nil
  43290. }
  43291. // SetUnionID sets the "union_id" field.
  43292. func (m *WxCardUserMutation) SetUnionID(s string) {
  43293. m.union_id = &s
  43294. }
  43295. // UnionID returns the value of the "union_id" field in the mutation.
  43296. func (m *WxCardUserMutation) UnionID() (r string, exists bool) {
  43297. v := m.union_id
  43298. if v == nil {
  43299. return
  43300. }
  43301. return *v, true
  43302. }
  43303. // OldUnionID returns the old "union_id" field's value of the WxCardUser entity.
  43304. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  43305. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43306. func (m *WxCardUserMutation) OldUnionID(ctx context.Context) (v string, err error) {
  43307. if !m.op.Is(OpUpdateOne) {
  43308. return v, errors.New("OldUnionID is only allowed on UpdateOne operations")
  43309. }
  43310. if m.id == nil || m.oldValue == nil {
  43311. return v, errors.New("OldUnionID requires an ID field in the mutation")
  43312. }
  43313. oldValue, err := m.oldValue(ctx)
  43314. if err != nil {
  43315. return v, fmt.Errorf("querying old value for OldUnionID: %w", err)
  43316. }
  43317. return oldValue.UnionID, nil
  43318. }
  43319. // ResetUnionID resets all changes to the "union_id" field.
  43320. func (m *WxCardUserMutation) ResetUnionID() {
  43321. m.union_id = nil
  43322. }
  43323. // SetSessionKey sets the "session_key" field.
  43324. func (m *WxCardUserMutation) SetSessionKey(s string) {
  43325. m.session_key = &s
  43326. }
  43327. // SessionKey returns the value of the "session_key" field in the mutation.
  43328. func (m *WxCardUserMutation) SessionKey() (r string, exists bool) {
  43329. v := m.session_key
  43330. if v == nil {
  43331. return
  43332. }
  43333. return *v, true
  43334. }
  43335. // OldSessionKey returns the old "session_key" field's value of the WxCardUser entity.
  43336. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  43337. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43338. func (m *WxCardUserMutation) OldSessionKey(ctx context.Context) (v string, err error) {
  43339. if !m.op.Is(OpUpdateOne) {
  43340. return v, errors.New("OldSessionKey is only allowed on UpdateOne operations")
  43341. }
  43342. if m.id == nil || m.oldValue == nil {
  43343. return v, errors.New("OldSessionKey requires an ID field in the mutation")
  43344. }
  43345. oldValue, err := m.oldValue(ctx)
  43346. if err != nil {
  43347. return v, fmt.Errorf("querying old value for OldSessionKey: %w", err)
  43348. }
  43349. return oldValue.SessionKey, nil
  43350. }
  43351. // ResetSessionKey resets all changes to the "session_key" field.
  43352. func (m *WxCardUserMutation) ResetSessionKey() {
  43353. m.session_key = nil
  43354. }
  43355. // SetIsVip sets the "is_vip" field.
  43356. func (m *WxCardUserMutation) SetIsVip(i int) {
  43357. m.is_vip = &i
  43358. m.addis_vip = nil
  43359. }
  43360. // IsVip returns the value of the "is_vip" field in the mutation.
  43361. func (m *WxCardUserMutation) IsVip() (r int, exists bool) {
  43362. v := m.is_vip
  43363. if v == nil {
  43364. return
  43365. }
  43366. return *v, true
  43367. }
  43368. // OldIsVip returns the old "is_vip" field's value of the WxCardUser entity.
  43369. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  43370. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43371. func (m *WxCardUserMutation) OldIsVip(ctx context.Context) (v int, err error) {
  43372. if !m.op.Is(OpUpdateOne) {
  43373. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  43374. }
  43375. if m.id == nil || m.oldValue == nil {
  43376. return v, errors.New("OldIsVip requires an ID field in the mutation")
  43377. }
  43378. oldValue, err := m.oldValue(ctx)
  43379. if err != nil {
  43380. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  43381. }
  43382. return oldValue.IsVip, nil
  43383. }
  43384. // AddIsVip adds i to the "is_vip" field.
  43385. func (m *WxCardUserMutation) AddIsVip(i int) {
  43386. if m.addis_vip != nil {
  43387. *m.addis_vip += i
  43388. } else {
  43389. m.addis_vip = &i
  43390. }
  43391. }
  43392. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  43393. func (m *WxCardUserMutation) AddedIsVip() (r int, exists bool) {
  43394. v := m.addis_vip
  43395. if v == nil {
  43396. return
  43397. }
  43398. return *v, true
  43399. }
  43400. // ResetIsVip resets all changes to the "is_vip" field.
  43401. func (m *WxCardUserMutation) ResetIsVip() {
  43402. m.is_vip = nil
  43403. m.addis_vip = nil
  43404. }
  43405. // Where appends a list predicates to the WxCardUserMutation builder.
  43406. func (m *WxCardUserMutation) Where(ps ...predicate.WxCardUser) {
  43407. m.predicates = append(m.predicates, ps...)
  43408. }
  43409. // WhereP appends storage-level predicates to the WxCardUserMutation builder. Using this method,
  43410. // users can use type-assertion to append predicates that do not depend on any generated package.
  43411. func (m *WxCardUserMutation) WhereP(ps ...func(*sql.Selector)) {
  43412. p := make([]predicate.WxCardUser, len(ps))
  43413. for i := range ps {
  43414. p[i] = ps[i]
  43415. }
  43416. m.Where(p...)
  43417. }
  43418. // Op returns the operation name.
  43419. func (m *WxCardUserMutation) Op() Op {
  43420. return m.op
  43421. }
  43422. // SetOp allows setting the mutation operation.
  43423. func (m *WxCardUserMutation) SetOp(op Op) {
  43424. m.op = op
  43425. }
  43426. // Type returns the node type of this mutation (WxCardUser).
  43427. func (m *WxCardUserMutation) Type() string {
  43428. return m.typ
  43429. }
  43430. // Fields returns all fields that were changed during this mutation. Note that in
  43431. // order to get all numeric fields that were incremented/decremented, call
  43432. // AddedFields().
  43433. func (m *WxCardUserMutation) Fields() []string {
  43434. fields := make([]string, 0, 13)
  43435. if m.created_at != nil {
  43436. fields = append(fields, wxcarduser.FieldCreatedAt)
  43437. }
  43438. if m.updated_at != nil {
  43439. fields = append(fields, wxcarduser.FieldUpdatedAt)
  43440. }
  43441. if m.deleted_at != nil {
  43442. fields = append(fields, wxcarduser.FieldDeletedAt)
  43443. }
  43444. if m.wxid != nil {
  43445. fields = append(fields, wxcarduser.FieldWxid)
  43446. }
  43447. if m.account != nil {
  43448. fields = append(fields, wxcarduser.FieldAccount)
  43449. }
  43450. if m.avatar != nil {
  43451. fields = append(fields, wxcarduser.FieldAvatar)
  43452. }
  43453. if m.nickname != nil {
  43454. fields = append(fields, wxcarduser.FieldNickname)
  43455. }
  43456. if m.remark != nil {
  43457. fields = append(fields, wxcarduser.FieldRemark)
  43458. }
  43459. if m.phone != nil {
  43460. fields = append(fields, wxcarduser.FieldPhone)
  43461. }
  43462. if m.open_id != nil {
  43463. fields = append(fields, wxcarduser.FieldOpenID)
  43464. }
  43465. if m.union_id != nil {
  43466. fields = append(fields, wxcarduser.FieldUnionID)
  43467. }
  43468. if m.session_key != nil {
  43469. fields = append(fields, wxcarduser.FieldSessionKey)
  43470. }
  43471. if m.is_vip != nil {
  43472. fields = append(fields, wxcarduser.FieldIsVip)
  43473. }
  43474. return fields
  43475. }
  43476. // Field returns the value of a field with the given name. The second boolean
  43477. // return value indicates that this field was not set, or was not defined in the
  43478. // schema.
  43479. func (m *WxCardUserMutation) Field(name string) (ent.Value, bool) {
  43480. switch name {
  43481. case wxcarduser.FieldCreatedAt:
  43482. return m.CreatedAt()
  43483. case wxcarduser.FieldUpdatedAt:
  43484. return m.UpdatedAt()
  43485. case wxcarduser.FieldDeletedAt:
  43486. return m.DeletedAt()
  43487. case wxcarduser.FieldWxid:
  43488. return m.Wxid()
  43489. case wxcarduser.FieldAccount:
  43490. return m.Account()
  43491. case wxcarduser.FieldAvatar:
  43492. return m.Avatar()
  43493. case wxcarduser.FieldNickname:
  43494. return m.Nickname()
  43495. case wxcarduser.FieldRemark:
  43496. return m.Remark()
  43497. case wxcarduser.FieldPhone:
  43498. return m.Phone()
  43499. case wxcarduser.FieldOpenID:
  43500. return m.OpenID()
  43501. case wxcarduser.FieldUnionID:
  43502. return m.UnionID()
  43503. case wxcarduser.FieldSessionKey:
  43504. return m.SessionKey()
  43505. case wxcarduser.FieldIsVip:
  43506. return m.IsVip()
  43507. }
  43508. return nil, false
  43509. }
  43510. // OldField returns the old value of the field from the database. An error is
  43511. // returned if the mutation operation is not UpdateOne, or the query to the
  43512. // database failed.
  43513. func (m *WxCardUserMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  43514. switch name {
  43515. case wxcarduser.FieldCreatedAt:
  43516. return m.OldCreatedAt(ctx)
  43517. case wxcarduser.FieldUpdatedAt:
  43518. return m.OldUpdatedAt(ctx)
  43519. case wxcarduser.FieldDeletedAt:
  43520. return m.OldDeletedAt(ctx)
  43521. case wxcarduser.FieldWxid:
  43522. return m.OldWxid(ctx)
  43523. case wxcarduser.FieldAccount:
  43524. return m.OldAccount(ctx)
  43525. case wxcarduser.FieldAvatar:
  43526. return m.OldAvatar(ctx)
  43527. case wxcarduser.FieldNickname:
  43528. return m.OldNickname(ctx)
  43529. case wxcarduser.FieldRemark:
  43530. return m.OldRemark(ctx)
  43531. case wxcarduser.FieldPhone:
  43532. return m.OldPhone(ctx)
  43533. case wxcarduser.FieldOpenID:
  43534. return m.OldOpenID(ctx)
  43535. case wxcarduser.FieldUnionID:
  43536. return m.OldUnionID(ctx)
  43537. case wxcarduser.FieldSessionKey:
  43538. return m.OldSessionKey(ctx)
  43539. case wxcarduser.FieldIsVip:
  43540. return m.OldIsVip(ctx)
  43541. }
  43542. return nil, fmt.Errorf("unknown WxCardUser field %s", name)
  43543. }
  43544. // SetField sets the value of a field with the given name. It returns an error if
  43545. // the field is not defined in the schema, or if the type mismatched the field
  43546. // type.
  43547. func (m *WxCardUserMutation) SetField(name string, value ent.Value) error {
  43548. switch name {
  43549. case wxcarduser.FieldCreatedAt:
  43550. v, ok := value.(time.Time)
  43551. if !ok {
  43552. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43553. }
  43554. m.SetCreatedAt(v)
  43555. return nil
  43556. case wxcarduser.FieldUpdatedAt:
  43557. v, ok := value.(time.Time)
  43558. if !ok {
  43559. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43560. }
  43561. m.SetUpdatedAt(v)
  43562. return nil
  43563. case wxcarduser.FieldDeletedAt:
  43564. v, ok := value.(time.Time)
  43565. if !ok {
  43566. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43567. }
  43568. m.SetDeletedAt(v)
  43569. return nil
  43570. case wxcarduser.FieldWxid:
  43571. v, ok := value.(string)
  43572. if !ok {
  43573. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43574. }
  43575. m.SetWxid(v)
  43576. return nil
  43577. case wxcarduser.FieldAccount:
  43578. v, ok := value.(string)
  43579. if !ok {
  43580. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43581. }
  43582. m.SetAccount(v)
  43583. return nil
  43584. case wxcarduser.FieldAvatar:
  43585. v, ok := value.(string)
  43586. if !ok {
  43587. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43588. }
  43589. m.SetAvatar(v)
  43590. return nil
  43591. case wxcarduser.FieldNickname:
  43592. v, ok := value.(string)
  43593. if !ok {
  43594. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43595. }
  43596. m.SetNickname(v)
  43597. return nil
  43598. case wxcarduser.FieldRemark:
  43599. v, ok := value.(string)
  43600. if !ok {
  43601. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43602. }
  43603. m.SetRemark(v)
  43604. return nil
  43605. case wxcarduser.FieldPhone:
  43606. v, ok := value.(string)
  43607. if !ok {
  43608. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43609. }
  43610. m.SetPhone(v)
  43611. return nil
  43612. case wxcarduser.FieldOpenID:
  43613. v, ok := value.(string)
  43614. if !ok {
  43615. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43616. }
  43617. m.SetOpenID(v)
  43618. return nil
  43619. case wxcarduser.FieldUnionID:
  43620. v, ok := value.(string)
  43621. if !ok {
  43622. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43623. }
  43624. m.SetUnionID(v)
  43625. return nil
  43626. case wxcarduser.FieldSessionKey:
  43627. v, ok := value.(string)
  43628. if !ok {
  43629. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43630. }
  43631. m.SetSessionKey(v)
  43632. return nil
  43633. case wxcarduser.FieldIsVip:
  43634. v, ok := value.(int)
  43635. if !ok {
  43636. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43637. }
  43638. m.SetIsVip(v)
  43639. return nil
  43640. }
  43641. return fmt.Errorf("unknown WxCardUser field %s", name)
  43642. }
  43643. // AddedFields returns all numeric fields that were incremented/decremented during
  43644. // this mutation.
  43645. func (m *WxCardUserMutation) AddedFields() []string {
  43646. var fields []string
  43647. if m.addis_vip != nil {
  43648. fields = append(fields, wxcarduser.FieldIsVip)
  43649. }
  43650. return fields
  43651. }
  43652. // AddedField returns the numeric value that was incremented/decremented on a field
  43653. // with the given name. The second boolean return value indicates that this field
  43654. // was not set, or was not defined in the schema.
  43655. func (m *WxCardUserMutation) AddedField(name string) (ent.Value, bool) {
  43656. switch name {
  43657. case wxcarduser.FieldIsVip:
  43658. return m.AddedIsVip()
  43659. }
  43660. return nil, false
  43661. }
  43662. // AddField adds the value to the field with the given name. It returns an error if
  43663. // the field is not defined in the schema, or if the type mismatched the field
  43664. // type.
  43665. func (m *WxCardUserMutation) AddField(name string, value ent.Value) error {
  43666. switch name {
  43667. case wxcarduser.FieldIsVip:
  43668. v, ok := value.(int)
  43669. if !ok {
  43670. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43671. }
  43672. m.AddIsVip(v)
  43673. return nil
  43674. }
  43675. return fmt.Errorf("unknown WxCardUser numeric field %s", name)
  43676. }
  43677. // ClearedFields returns all nullable fields that were cleared during this
  43678. // mutation.
  43679. func (m *WxCardUserMutation) ClearedFields() []string {
  43680. var fields []string
  43681. if m.FieldCleared(wxcarduser.FieldDeletedAt) {
  43682. fields = append(fields, wxcarduser.FieldDeletedAt)
  43683. }
  43684. return fields
  43685. }
  43686. // FieldCleared returns a boolean indicating if a field with the given name was
  43687. // cleared in this mutation.
  43688. func (m *WxCardUserMutation) FieldCleared(name string) bool {
  43689. _, ok := m.clearedFields[name]
  43690. return ok
  43691. }
  43692. // ClearField clears the value of the field with the given name. It returns an
  43693. // error if the field is not defined in the schema.
  43694. func (m *WxCardUserMutation) ClearField(name string) error {
  43695. switch name {
  43696. case wxcarduser.FieldDeletedAt:
  43697. m.ClearDeletedAt()
  43698. return nil
  43699. }
  43700. return fmt.Errorf("unknown WxCardUser nullable field %s", name)
  43701. }
  43702. // ResetField resets all changes in the mutation for the field with the given name.
  43703. // It returns an error if the field is not defined in the schema.
  43704. func (m *WxCardUserMutation) ResetField(name string) error {
  43705. switch name {
  43706. case wxcarduser.FieldCreatedAt:
  43707. m.ResetCreatedAt()
  43708. return nil
  43709. case wxcarduser.FieldUpdatedAt:
  43710. m.ResetUpdatedAt()
  43711. return nil
  43712. case wxcarduser.FieldDeletedAt:
  43713. m.ResetDeletedAt()
  43714. return nil
  43715. case wxcarduser.FieldWxid:
  43716. m.ResetWxid()
  43717. return nil
  43718. case wxcarduser.FieldAccount:
  43719. m.ResetAccount()
  43720. return nil
  43721. case wxcarduser.FieldAvatar:
  43722. m.ResetAvatar()
  43723. return nil
  43724. case wxcarduser.FieldNickname:
  43725. m.ResetNickname()
  43726. return nil
  43727. case wxcarduser.FieldRemark:
  43728. m.ResetRemark()
  43729. return nil
  43730. case wxcarduser.FieldPhone:
  43731. m.ResetPhone()
  43732. return nil
  43733. case wxcarduser.FieldOpenID:
  43734. m.ResetOpenID()
  43735. return nil
  43736. case wxcarduser.FieldUnionID:
  43737. m.ResetUnionID()
  43738. return nil
  43739. case wxcarduser.FieldSessionKey:
  43740. m.ResetSessionKey()
  43741. return nil
  43742. case wxcarduser.FieldIsVip:
  43743. m.ResetIsVip()
  43744. return nil
  43745. }
  43746. return fmt.Errorf("unknown WxCardUser field %s", name)
  43747. }
  43748. // AddedEdges returns all edge names that were set/added in this mutation.
  43749. func (m *WxCardUserMutation) AddedEdges() []string {
  43750. edges := make([]string, 0, 0)
  43751. return edges
  43752. }
  43753. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  43754. // name in this mutation.
  43755. func (m *WxCardUserMutation) AddedIDs(name string) []ent.Value {
  43756. return nil
  43757. }
  43758. // RemovedEdges returns all edge names that were removed in this mutation.
  43759. func (m *WxCardUserMutation) RemovedEdges() []string {
  43760. edges := make([]string, 0, 0)
  43761. return edges
  43762. }
  43763. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  43764. // the given name in this mutation.
  43765. func (m *WxCardUserMutation) RemovedIDs(name string) []ent.Value {
  43766. return nil
  43767. }
  43768. // ClearedEdges returns all edge names that were cleared in this mutation.
  43769. func (m *WxCardUserMutation) ClearedEdges() []string {
  43770. edges := make([]string, 0, 0)
  43771. return edges
  43772. }
  43773. // EdgeCleared returns a boolean which indicates if the edge with the given name
  43774. // was cleared in this mutation.
  43775. func (m *WxCardUserMutation) EdgeCleared(name string) bool {
  43776. return false
  43777. }
  43778. // ClearEdge clears the value of the edge with the given name. It returns an error
  43779. // if that edge is not defined in the schema.
  43780. func (m *WxCardUserMutation) ClearEdge(name string) error {
  43781. return fmt.Errorf("unknown WxCardUser unique edge %s", name)
  43782. }
  43783. // ResetEdge resets all changes to the edge with the given name in this mutation.
  43784. // It returns an error if the edge is not defined in the schema.
  43785. func (m *WxCardUserMutation) ResetEdge(name string) error {
  43786. return fmt.Errorf("unknown WxCardUser edge %s", name)
  43787. }
  43788. // WxCardVisitMutation represents an operation that mutates the WxCardVisit nodes in the graph.
  43789. type WxCardVisitMutation struct {
  43790. config
  43791. op Op
  43792. typ string
  43793. id *uint64
  43794. created_at *time.Time
  43795. updated_at *time.Time
  43796. deleted_at *time.Time
  43797. user_id *uint64
  43798. adduser_id *int64
  43799. bot_id *uint64
  43800. addbot_id *int64
  43801. bot_type *uint8
  43802. addbot_type *int8
  43803. clearedFields map[string]struct{}
  43804. done bool
  43805. oldValue func(context.Context) (*WxCardVisit, error)
  43806. predicates []predicate.WxCardVisit
  43807. }
  43808. var _ ent.Mutation = (*WxCardVisitMutation)(nil)
  43809. // wxcardvisitOption allows management of the mutation configuration using functional options.
  43810. type wxcardvisitOption func(*WxCardVisitMutation)
  43811. // newWxCardVisitMutation creates new mutation for the WxCardVisit entity.
  43812. func newWxCardVisitMutation(c config, op Op, opts ...wxcardvisitOption) *WxCardVisitMutation {
  43813. m := &WxCardVisitMutation{
  43814. config: c,
  43815. op: op,
  43816. typ: TypeWxCardVisit,
  43817. clearedFields: make(map[string]struct{}),
  43818. }
  43819. for _, opt := range opts {
  43820. opt(m)
  43821. }
  43822. return m
  43823. }
  43824. // withWxCardVisitID sets the ID field of the mutation.
  43825. func withWxCardVisitID(id uint64) wxcardvisitOption {
  43826. return func(m *WxCardVisitMutation) {
  43827. var (
  43828. err error
  43829. once sync.Once
  43830. value *WxCardVisit
  43831. )
  43832. m.oldValue = func(ctx context.Context) (*WxCardVisit, error) {
  43833. once.Do(func() {
  43834. if m.done {
  43835. err = errors.New("querying old values post mutation is not allowed")
  43836. } else {
  43837. value, err = m.Client().WxCardVisit.Get(ctx, id)
  43838. }
  43839. })
  43840. return value, err
  43841. }
  43842. m.id = &id
  43843. }
  43844. }
  43845. // withWxCardVisit sets the old WxCardVisit of the mutation.
  43846. func withWxCardVisit(node *WxCardVisit) wxcardvisitOption {
  43847. return func(m *WxCardVisitMutation) {
  43848. m.oldValue = func(context.Context) (*WxCardVisit, error) {
  43849. return node, nil
  43850. }
  43851. m.id = &node.ID
  43852. }
  43853. }
  43854. // Client returns a new `ent.Client` from the mutation. If the mutation was
  43855. // executed in a transaction (ent.Tx), a transactional client is returned.
  43856. func (m WxCardVisitMutation) Client() *Client {
  43857. client := &Client{config: m.config}
  43858. client.init()
  43859. return client
  43860. }
  43861. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  43862. // it returns an error otherwise.
  43863. func (m WxCardVisitMutation) Tx() (*Tx, error) {
  43864. if _, ok := m.driver.(*txDriver); !ok {
  43865. return nil, errors.New("ent: mutation is not running in a transaction")
  43866. }
  43867. tx := &Tx{config: m.config}
  43868. tx.init()
  43869. return tx, nil
  43870. }
  43871. // SetID sets the value of the id field. Note that this
  43872. // operation is only accepted on creation of WxCardVisit entities.
  43873. func (m *WxCardVisitMutation) SetID(id uint64) {
  43874. m.id = &id
  43875. }
  43876. // ID returns the ID value in the mutation. Note that the ID is only available
  43877. // if it was provided to the builder or after it was returned from the database.
  43878. func (m *WxCardVisitMutation) ID() (id uint64, exists bool) {
  43879. if m.id == nil {
  43880. return
  43881. }
  43882. return *m.id, true
  43883. }
  43884. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  43885. // That means, if the mutation is applied within a transaction with an isolation level such
  43886. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  43887. // or updated by the mutation.
  43888. func (m *WxCardVisitMutation) IDs(ctx context.Context) ([]uint64, error) {
  43889. switch {
  43890. case m.op.Is(OpUpdateOne | OpDeleteOne):
  43891. id, exists := m.ID()
  43892. if exists {
  43893. return []uint64{id}, nil
  43894. }
  43895. fallthrough
  43896. case m.op.Is(OpUpdate | OpDelete):
  43897. return m.Client().WxCardVisit.Query().Where(m.predicates...).IDs(ctx)
  43898. default:
  43899. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  43900. }
  43901. }
  43902. // SetCreatedAt sets the "created_at" field.
  43903. func (m *WxCardVisitMutation) SetCreatedAt(t time.Time) {
  43904. m.created_at = &t
  43905. }
  43906. // CreatedAt returns the value of the "created_at" field in the mutation.
  43907. func (m *WxCardVisitMutation) CreatedAt() (r time.Time, exists bool) {
  43908. v := m.created_at
  43909. if v == nil {
  43910. return
  43911. }
  43912. return *v, true
  43913. }
  43914. // OldCreatedAt returns the old "created_at" field's value of the WxCardVisit entity.
  43915. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  43916. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43917. func (m *WxCardVisitMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  43918. if !m.op.Is(OpUpdateOne) {
  43919. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  43920. }
  43921. if m.id == nil || m.oldValue == nil {
  43922. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  43923. }
  43924. oldValue, err := m.oldValue(ctx)
  43925. if err != nil {
  43926. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  43927. }
  43928. return oldValue.CreatedAt, nil
  43929. }
  43930. // ResetCreatedAt resets all changes to the "created_at" field.
  43931. func (m *WxCardVisitMutation) ResetCreatedAt() {
  43932. m.created_at = nil
  43933. }
  43934. // SetUpdatedAt sets the "updated_at" field.
  43935. func (m *WxCardVisitMutation) SetUpdatedAt(t time.Time) {
  43936. m.updated_at = &t
  43937. }
  43938. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  43939. func (m *WxCardVisitMutation) UpdatedAt() (r time.Time, exists bool) {
  43940. v := m.updated_at
  43941. if v == nil {
  43942. return
  43943. }
  43944. return *v, true
  43945. }
  43946. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardVisit entity.
  43947. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  43948. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43949. func (m *WxCardVisitMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  43950. if !m.op.Is(OpUpdateOne) {
  43951. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  43952. }
  43953. if m.id == nil || m.oldValue == nil {
  43954. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  43955. }
  43956. oldValue, err := m.oldValue(ctx)
  43957. if err != nil {
  43958. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  43959. }
  43960. return oldValue.UpdatedAt, nil
  43961. }
  43962. // ResetUpdatedAt resets all changes to the "updated_at" field.
  43963. func (m *WxCardVisitMutation) ResetUpdatedAt() {
  43964. m.updated_at = nil
  43965. }
  43966. // SetDeletedAt sets the "deleted_at" field.
  43967. func (m *WxCardVisitMutation) SetDeletedAt(t time.Time) {
  43968. m.deleted_at = &t
  43969. }
  43970. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  43971. func (m *WxCardVisitMutation) DeletedAt() (r time.Time, exists bool) {
  43972. v := m.deleted_at
  43973. if v == nil {
  43974. return
  43975. }
  43976. return *v, true
  43977. }
  43978. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardVisit entity.
  43979. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  43980. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43981. func (m *WxCardVisitMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  43982. if !m.op.Is(OpUpdateOne) {
  43983. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  43984. }
  43985. if m.id == nil || m.oldValue == nil {
  43986. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  43987. }
  43988. oldValue, err := m.oldValue(ctx)
  43989. if err != nil {
  43990. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  43991. }
  43992. return oldValue.DeletedAt, nil
  43993. }
  43994. // ClearDeletedAt clears the value of the "deleted_at" field.
  43995. func (m *WxCardVisitMutation) ClearDeletedAt() {
  43996. m.deleted_at = nil
  43997. m.clearedFields[wxcardvisit.FieldDeletedAt] = struct{}{}
  43998. }
  43999. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  44000. func (m *WxCardVisitMutation) DeletedAtCleared() bool {
  44001. _, ok := m.clearedFields[wxcardvisit.FieldDeletedAt]
  44002. return ok
  44003. }
  44004. // ResetDeletedAt resets all changes to the "deleted_at" field.
  44005. func (m *WxCardVisitMutation) ResetDeletedAt() {
  44006. m.deleted_at = nil
  44007. delete(m.clearedFields, wxcardvisit.FieldDeletedAt)
  44008. }
  44009. // SetUserID sets the "user_id" field.
  44010. func (m *WxCardVisitMutation) SetUserID(u uint64) {
  44011. m.user_id = &u
  44012. m.adduser_id = nil
  44013. }
  44014. // UserID returns the value of the "user_id" field in the mutation.
  44015. func (m *WxCardVisitMutation) UserID() (r uint64, exists bool) {
  44016. v := m.user_id
  44017. if v == nil {
  44018. return
  44019. }
  44020. return *v, true
  44021. }
  44022. // OldUserID returns the old "user_id" field's value of the WxCardVisit entity.
  44023. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  44024. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44025. func (m *WxCardVisitMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  44026. if !m.op.Is(OpUpdateOne) {
  44027. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  44028. }
  44029. if m.id == nil || m.oldValue == nil {
  44030. return v, errors.New("OldUserID requires an ID field in the mutation")
  44031. }
  44032. oldValue, err := m.oldValue(ctx)
  44033. if err != nil {
  44034. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  44035. }
  44036. return oldValue.UserID, nil
  44037. }
  44038. // AddUserID adds u to the "user_id" field.
  44039. func (m *WxCardVisitMutation) AddUserID(u int64) {
  44040. if m.adduser_id != nil {
  44041. *m.adduser_id += u
  44042. } else {
  44043. m.adduser_id = &u
  44044. }
  44045. }
  44046. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  44047. func (m *WxCardVisitMutation) AddedUserID() (r int64, exists bool) {
  44048. v := m.adduser_id
  44049. if v == nil {
  44050. return
  44051. }
  44052. return *v, true
  44053. }
  44054. // ClearUserID clears the value of the "user_id" field.
  44055. func (m *WxCardVisitMutation) ClearUserID() {
  44056. m.user_id = nil
  44057. m.adduser_id = nil
  44058. m.clearedFields[wxcardvisit.FieldUserID] = struct{}{}
  44059. }
  44060. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  44061. func (m *WxCardVisitMutation) UserIDCleared() bool {
  44062. _, ok := m.clearedFields[wxcardvisit.FieldUserID]
  44063. return ok
  44064. }
  44065. // ResetUserID resets all changes to the "user_id" field.
  44066. func (m *WxCardVisitMutation) ResetUserID() {
  44067. m.user_id = nil
  44068. m.adduser_id = nil
  44069. delete(m.clearedFields, wxcardvisit.FieldUserID)
  44070. }
  44071. // SetBotID sets the "bot_id" field.
  44072. func (m *WxCardVisitMutation) SetBotID(u uint64) {
  44073. m.bot_id = &u
  44074. m.addbot_id = nil
  44075. }
  44076. // BotID returns the value of the "bot_id" field in the mutation.
  44077. func (m *WxCardVisitMutation) BotID() (r uint64, exists bool) {
  44078. v := m.bot_id
  44079. if v == nil {
  44080. return
  44081. }
  44082. return *v, true
  44083. }
  44084. // OldBotID returns the old "bot_id" field's value of the WxCardVisit entity.
  44085. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  44086. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44087. func (m *WxCardVisitMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  44088. if !m.op.Is(OpUpdateOne) {
  44089. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  44090. }
  44091. if m.id == nil || m.oldValue == nil {
  44092. return v, errors.New("OldBotID requires an ID field in the mutation")
  44093. }
  44094. oldValue, err := m.oldValue(ctx)
  44095. if err != nil {
  44096. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  44097. }
  44098. return oldValue.BotID, nil
  44099. }
  44100. // AddBotID adds u to the "bot_id" field.
  44101. func (m *WxCardVisitMutation) AddBotID(u int64) {
  44102. if m.addbot_id != nil {
  44103. *m.addbot_id += u
  44104. } else {
  44105. m.addbot_id = &u
  44106. }
  44107. }
  44108. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  44109. func (m *WxCardVisitMutation) AddedBotID() (r int64, exists bool) {
  44110. v := m.addbot_id
  44111. if v == nil {
  44112. return
  44113. }
  44114. return *v, true
  44115. }
  44116. // ResetBotID resets all changes to the "bot_id" field.
  44117. func (m *WxCardVisitMutation) ResetBotID() {
  44118. m.bot_id = nil
  44119. m.addbot_id = nil
  44120. }
  44121. // SetBotType sets the "bot_type" field.
  44122. func (m *WxCardVisitMutation) SetBotType(u uint8) {
  44123. m.bot_type = &u
  44124. m.addbot_type = nil
  44125. }
  44126. // BotType returns the value of the "bot_type" field in the mutation.
  44127. func (m *WxCardVisitMutation) BotType() (r uint8, exists bool) {
  44128. v := m.bot_type
  44129. if v == nil {
  44130. return
  44131. }
  44132. return *v, true
  44133. }
  44134. // OldBotType returns the old "bot_type" field's value of the WxCardVisit entity.
  44135. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  44136. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44137. func (m *WxCardVisitMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  44138. if !m.op.Is(OpUpdateOne) {
  44139. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  44140. }
  44141. if m.id == nil || m.oldValue == nil {
  44142. return v, errors.New("OldBotType requires an ID field in the mutation")
  44143. }
  44144. oldValue, err := m.oldValue(ctx)
  44145. if err != nil {
  44146. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  44147. }
  44148. return oldValue.BotType, nil
  44149. }
  44150. // AddBotType adds u to the "bot_type" field.
  44151. func (m *WxCardVisitMutation) AddBotType(u int8) {
  44152. if m.addbot_type != nil {
  44153. *m.addbot_type += u
  44154. } else {
  44155. m.addbot_type = &u
  44156. }
  44157. }
  44158. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  44159. func (m *WxCardVisitMutation) AddedBotType() (r int8, exists bool) {
  44160. v := m.addbot_type
  44161. if v == nil {
  44162. return
  44163. }
  44164. return *v, true
  44165. }
  44166. // ResetBotType resets all changes to the "bot_type" field.
  44167. func (m *WxCardVisitMutation) ResetBotType() {
  44168. m.bot_type = nil
  44169. m.addbot_type = nil
  44170. }
  44171. // Where appends a list predicates to the WxCardVisitMutation builder.
  44172. func (m *WxCardVisitMutation) Where(ps ...predicate.WxCardVisit) {
  44173. m.predicates = append(m.predicates, ps...)
  44174. }
  44175. // WhereP appends storage-level predicates to the WxCardVisitMutation builder. Using this method,
  44176. // users can use type-assertion to append predicates that do not depend on any generated package.
  44177. func (m *WxCardVisitMutation) WhereP(ps ...func(*sql.Selector)) {
  44178. p := make([]predicate.WxCardVisit, len(ps))
  44179. for i := range ps {
  44180. p[i] = ps[i]
  44181. }
  44182. m.Where(p...)
  44183. }
  44184. // Op returns the operation name.
  44185. func (m *WxCardVisitMutation) Op() Op {
  44186. return m.op
  44187. }
  44188. // SetOp allows setting the mutation operation.
  44189. func (m *WxCardVisitMutation) SetOp(op Op) {
  44190. m.op = op
  44191. }
  44192. // Type returns the node type of this mutation (WxCardVisit).
  44193. func (m *WxCardVisitMutation) Type() string {
  44194. return m.typ
  44195. }
  44196. // Fields returns all fields that were changed during this mutation. Note that in
  44197. // order to get all numeric fields that were incremented/decremented, call
  44198. // AddedFields().
  44199. func (m *WxCardVisitMutation) Fields() []string {
  44200. fields := make([]string, 0, 6)
  44201. if m.created_at != nil {
  44202. fields = append(fields, wxcardvisit.FieldCreatedAt)
  44203. }
  44204. if m.updated_at != nil {
  44205. fields = append(fields, wxcardvisit.FieldUpdatedAt)
  44206. }
  44207. if m.deleted_at != nil {
  44208. fields = append(fields, wxcardvisit.FieldDeletedAt)
  44209. }
  44210. if m.user_id != nil {
  44211. fields = append(fields, wxcardvisit.FieldUserID)
  44212. }
  44213. if m.bot_id != nil {
  44214. fields = append(fields, wxcardvisit.FieldBotID)
  44215. }
  44216. if m.bot_type != nil {
  44217. fields = append(fields, wxcardvisit.FieldBotType)
  44218. }
  44219. return fields
  44220. }
  44221. // Field returns the value of a field with the given name. The second boolean
  44222. // return value indicates that this field was not set, or was not defined in the
  44223. // schema.
  44224. func (m *WxCardVisitMutation) Field(name string) (ent.Value, bool) {
  44225. switch name {
  44226. case wxcardvisit.FieldCreatedAt:
  44227. return m.CreatedAt()
  44228. case wxcardvisit.FieldUpdatedAt:
  44229. return m.UpdatedAt()
  44230. case wxcardvisit.FieldDeletedAt:
  44231. return m.DeletedAt()
  44232. case wxcardvisit.FieldUserID:
  44233. return m.UserID()
  44234. case wxcardvisit.FieldBotID:
  44235. return m.BotID()
  44236. case wxcardvisit.FieldBotType:
  44237. return m.BotType()
  44238. }
  44239. return nil, false
  44240. }
  44241. // OldField returns the old value of the field from the database. An error is
  44242. // returned if the mutation operation is not UpdateOne, or the query to the
  44243. // database failed.
  44244. func (m *WxCardVisitMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  44245. switch name {
  44246. case wxcardvisit.FieldCreatedAt:
  44247. return m.OldCreatedAt(ctx)
  44248. case wxcardvisit.FieldUpdatedAt:
  44249. return m.OldUpdatedAt(ctx)
  44250. case wxcardvisit.FieldDeletedAt:
  44251. return m.OldDeletedAt(ctx)
  44252. case wxcardvisit.FieldUserID:
  44253. return m.OldUserID(ctx)
  44254. case wxcardvisit.FieldBotID:
  44255. return m.OldBotID(ctx)
  44256. case wxcardvisit.FieldBotType:
  44257. return m.OldBotType(ctx)
  44258. }
  44259. return nil, fmt.Errorf("unknown WxCardVisit field %s", name)
  44260. }
  44261. // SetField sets the value of a field with the given name. It returns an error if
  44262. // the field is not defined in the schema, or if the type mismatched the field
  44263. // type.
  44264. func (m *WxCardVisitMutation) SetField(name string, value ent.Value) error {
  44265. switch name {
  44266. case wxcardvisit.FieldCreatedAt:
  44267. v, ok := value.(time.Time)
  44268. if !ok {
  44269. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44270. }
  44271. m.SetCreatedAt(v)
  44272. return nil
  44273. case wxcardvisit.FieldUpdatedAt:
  44274. v, ok := value.(time.Time)
  44275. if !ok {
  44276. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44277. }
  44278. m.SetUpdatedAt(v)
  44279. return nil
  44280. case wxcardvisit.FieldDeletedAt:
  44281. v, ok := value.(time.Time)
  44282. if !ok {
  44283. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44284. }
  44285. m.SetDeletedAt(v)
  44286. return nil
  44287. case wxcardvisit.FieldUserID:
  44288. v, ok := value.(uint64)
  44289. if !ok {
  44290. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44291. }
  44292. m.SetUserID(v)
  44293. return nil
  44294. case wxcardvisit.FieldBotID:
  44295. v, ok := value.(uint64)
  44296. if !ok {
  44297. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44298. }
  44299. m.SetBotID(v)
  44300. return nil
  44301. case wxcardvisit.FieldBotType:
  44302. v, ok := value.(uint8)
  44303. if !ok {
  44304. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44305. }
  44306. m.SetBotType(v)
  44307. return nil
  44308. }
  44309. return fmt.Errorf("unknown WxCardVisit field %s", name)
  44310. }
  44311. // AddedFields returns all numeric fields that were incremented/decremented during
  44312. // this mutation.
  44313. func (m *WxCardVisitMutation) AddedFields() []string {
  44314. var fields []string
  44315. if m.adduser_id != nil {
  44316. fields = append(fields, wxcardvisit.FieldUserID)
  44317. }
  44318. if m.addbot_id != nil {
  44319. fields = append(fields, wxcardvisit.FieldBotID)
  44320. }
  44321. if m.addbot_type != nil {
  44322. fields = append(fields, wxcardvisit.FieldBotType)
  44323. }
  44324. return fields
  44325. }
  44326. // AddedField returns the numeric value that was incremented/decremented on a field
  44327. // with the given name. The second boolean return value indicates that this field
  44328. // was not set, or was not defined in the schema.
  44329. func (m *WxCardVisitMutation) AddedField(name string) (ent.Value, bool) {
  44330. switch name {
  44331. case wxcardvisit.FieldUserID:
  44332. return m.AddedUserID()
  44333. case wxcardvisit.FieldBotID:
  44334. return m.AddedBotID()
  44335. case wxcardvisit.FieldBotType:
  44336. return m.AddedBotType()
  44337. }
  44338. return nil, false
  44339. }
  44340. // AddField adds the value to the field with the given name. It returns an error if
  44341. // the field is not defined in the schema, or if the type mismatched the field
  44342. // type.
  44343. func (m *WxCardVisitMutation) AddField(name string, value ent.Value) error {
  44344. switch name {
  44345. case wxcardvisit.FieldUserID:
  44346. v, ok := value.(int64)
  44347. if !ok {
  44348. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44349. }
  44350. m.AddUserID(v)
  44351. return nil
  44352. case wxcardvisit.FieldBotID:
  44353. v, ok := value.(int64)
  44354. if !ok {
  44355. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44356. }
  44357. m.AddBotID(v)
  44358. return nil
  44359. case wxcardvisit.FieldBotType:
  44360. v, ok := value.(int8)
  44361. if !ok {
  44362. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44363. }
  44364. m.AddBotType(v)
  44365. return nil
  44366. }
  44367. return fmt.Errorf("unknown WxCardVisit numeric field %s", name)
  44368. }
  44369. // ClearedFields returns all nullable fields that were cleared during this
  44370. // mutation.
  44371. func (m *WxCardVisitMutation) ClearedFields() []string {
  44372. var fields []string
  44373. if m.FieldCleared(wxcardvisit.FieldDeletedAt) {
  44374. fields = append(fields, wxcardvisit.FieldDeletedAt)
  44375. }
  44376. if m.FieldCleared(wxcardvisit.FieldUserID) {
  44377. fields = append(fields, wxcardvisit.FieldUserID)
  44378. }
  44379. return fields
  44380. }
  44381. // FieldCleared returns a boolean indicating if a field with the given name was
  44382. // cleared in this mutation.
  44383. func (m *WxCardVisitMutation) FieldCleared(name string) bool {
  44384. _, ok := m.clearedFields[name]
  44385. return ok
  44386. }
  44387. // ClearField clears the value of the field with the given name. It returns an
  44388. // error if the field is not defined in the schema.
  44389. func (m *WxCardVisitMutation) ClearField(name string) error {
  44390. switch name {
  44391. case wxcardvisit.FieldDeletedAt:
  44392. m.ClearDeletedAt()
  44393. return nil
  44394. case wxcardvisit.FieldUserID:
  44395. m.ClearUserID()
  44396. return nil
  44397. }
  44398. return fmt.Errorf("unknown WxCardVisit nullable field %s", name)
  44399. }
  44400. // ResetField resets all changes in the mutation for the field with the given name.
  44401. // It returns an error if the field is not defined in the schema.
  44402. func (m *WxCardVisitMutation) ResetField(name string) error {
  44403. switch name {
  44404. case wxcardvisit.FieldCreatedAt:
  44405. m.ResetCreatedAt()
  44406. return nil
  44407. case wxcardvisit.FieldUpdatedAt:
  44408. m.ResetUpdatedAt()
  44409. return nil
  44410. case wxcardvisit.FieldDeletedAt:
  44411. m.ResetDeletedAt()
  44412. return nil
  44413. case wxcardvisit.FieldUserID:
  44414. m.ResetUserID()
  44415. return nil
  44416. case wxcardvisit.FieldBotID:
  44417. m.ResetBotID()
  44418. return nil
  44419. case wxcardvisit.FieldBotType:
  44420. m.ResetBotType()
  44421. return nil
  44422. }
  44423. return fmt.Errorf("unknown WxCardVisit field %s", name)
  44424. }
  44425. // AddedEdges returns all edge names that were set/added in this mutation.
  44426. func (m *WxCardVisitMutation) AddedEdges() []string {
  44427. edges := make([]string, 0, 0)
  44428. return edges
  44429. }
  44430. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  44431. // name in this mutation.
  44432. func (m *WxCardVisitMutation) AddedIDs(name string) []ent.Value {
  44433. return nil
  44434. }
  44435. // RemovedEdges returns all edge names that were removed in this mutation.
  44436. func (m *WxCardVisitMutation) RemovedEdges() []string {
  44437. edges := make([]string, 0, 0)
  44438. return edges
  44439. }
  44440. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  44441. // the given name in this mutation.
  44442. func (m *WxCardVisitMutation) RemovedIDs(name string) []ent.Value {
  44443. return nil
  44444. }
  44445. // ClearedEdges returns all edge names that were cleared in this mutation.
  44446. func (m *WxCardVisitMutation) ClearedEdges() []string {
  44447. edges := make([]string, 0, 0)
  44448. return edges
  44449. }
  44450. // EdgeCleared returns a boolean which indicates if the edge with the given name
  44451. // was cleared in this mutation.
  44452. func (m *WxCardVisitMutation) EdgeCleared(name string) bool {
  44453. return false
  44454. }
  44455. // ClearEdge clears the value of the edge with the given name. It returns an error
  44456. // if that edge is not defined in the schema.
  44457. func (m *WxCardVisitMutation) ClearEdge(name string) error {
  44458. return fmt.Errorf("unknown WxCardVisit unique edge %s", name)
  44459. }
  44460. // ResetEdge resets all changes to the edge with the given name in this mutation.
  44461. // It returns an error if the edge is not defined in the schema.
  44462. func (m *WxCardVisitMutation) ResetEdge(name string) error {
  44463. return fmt.Errorf("unknown WxCardVisit edge %s", name)
  44464. }