mutation.go 1.4 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437
  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. clearedFields map[string]struct{}
  14428. label_relationships map[uint64]struct{}
  14429. removedlabel_relationships map[uint64]struct{}
  14430. clearedlabel_relationships bool
  14431. done bool
  14432. oldValue func(context.Context) (*Label, error)
  14433. predicates []predicate.Label
  14434. }
  14435. var _ ent.Mutation = (*LabelMutation)(nil)
  14436. // labelOption allows management of the mutation configuration using functional options.
  14437. type labelOption func(*LabelMutation)
  14438. // newLabelMutation creates new mutation for the Label entity.
  14439. func newLabelMutation(c config, op Op, opts ...labelOption) *LabelMutation {
  14440. m := &LabelMutation{
  14441. config: c,
  14442. op: op,
  14443. typ: TypeLabel,
  14444. clearedFields: make(map[string]struct{}),
  14445. }
  14446. for _, opt := range opts {
  14447. opt(m)
  14448. }
  14449. return m
  14450. }
  14451. // withLabelID sets the ID field of the mutation.
  14452. func withLabelID(id uint64) labelOption {
  14453. return func(m *LabelMutation) {
  14454. var (
  14455. err error
  14456. once sync.Once
  14457. value *Label
  14458. )
  14459. m.oldValue = func(ctx context.Context) (*Label, error) {
  14460. once.Do(func() {
  14461. if m.done {
  14462. err = errors.New("querying old values post mutation is not allowed")
  14463. } else {
  14464. value, err = m.Client().Label.Get(ctx, id)
  14465. }
  14466. })
  14467. return value, err
  14468. }
  14469. m.id = &id
  14470. }
  14471. }
  14472. // withLabel sets the old Label of the mutation.
  14473. func withLabel(node *Label) labelOption {
  14474. return func(m *LabelMutation) {
  14475. m.oldValue = func(context.Context) (*Label, error) {
  14476. return node, nil
  14477. }
  14478. m.id = &node.ID
  14479. }
  14480. }
  14481. // Client returns a new `ent.Client` from the mutation. If the mutation was
  14482. // executed in a transaction (ent.Tx), a transactional client is returned.
  14483. func (m LabelMutation) Client() *Client {
  14484. client := &Client{config: m.config}
  14485. client.init()
  14486. return client
  14487. }
  14488. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  14489. // it returns an error otherwise.
  14490. func (m LabelMutation) Tx() (*Tx, error) {
  14491. if _, ok := m.driver.(*txDriver); !ok {
  14492. return nil, errors.New("ent: mutation is not running in a transaction")
  14493. }
  14494. tx := &Tx{config: m.config}
  14495. tx.init()
  14496. return tx, nil
  14497. }
  14498. // SetID sets the value of the id field. Note that this
  14499. // operation is only accepted on creation of Label entities.
  14500. func (m *LabelMutation) SetID(id uint64) {
  14501. m.id = &id
  14502. }
  14503. // ID returns the ID value in the mutation. Note that the ID is only available
  14504. // if it was provided to the builder or after it was returned from the database.
  14505. func (m *LabelMutation) ID() (id uint64, exists bool) {
  14506. if m.id == nil {
  14507. return
  14508. }
  14509. return *m.id, true
  14510. }
  14511. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  14512. // That means, if the mutation is applied within a transaction with an isolation level such
  14513. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  14514. // or updated by the mutation.
  14515. func (m *LabelMutation) IDs(ctx context.Context) ([]uint64, error) {
  14516. switch {
  14517. case m.op.Is(OpUpdateOne | OpDeleteOne):
  14518. id, exists := m.ID()
  14519. if exists {
  14520. return []uint64{id}, nil
  14521. }
  14522. fallthrough
  14523. case m.op.Is(OpUpdate | OpDelete):
  14524. return m.Client().Label.Query().Where(m.predicates...).IDs(ctx)
  14525. default:
  14526. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  14527. }
  14528. }
  14529. // SetCreatedAt sets the "created_at" field.
  14530. func (m *LabelMutation) SetCreatedAt(t time.Time) {
  14531. m.created_at = &t
  14532. }
  14533. // CreatedAt returns the value of the "created_at" field in the mutation.
  14534. func (m *LabelMutation) CreatedAt() (r time.Time, exists bool) {
  14535. v := m.created_at
  14536. if v == nil {
  14537. return
  14538. }
  14539. return *v, true
  14540. }
  14541. // OldCreatedAt returns the old "created_at" field's value of the Label entity.
  14542. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  14543. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14544. func (m *LabelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  14545. if !m.op.Is(OpUpdateOne) {
  14546. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  14547. }
  14548. if m.id == nil || m.oldValue == nil {
  14549. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  14550. }
  14551. oldValue, err := m.oldValue(ctx)
  14552. if err != nil {
  14553. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  14554. }
  14555. return oldValue.CreatedAt, nil
  14556. }
  14557. // ResetCreatedAt resets all changes to the "created_at" field.
  14558. func (m *LabelMutation) ResetCreatedAt() {
  14559. m.created_at = nil
  14560. }
  14561. // SetUpdatedAt sets the "updated_at" field.
  14562. func (m *LabelMutation) SetUpdatedAt(t time.Time) {
  14563. m.updated_at = &t
  14564. }
  14565. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  14566. func (m *LabelMutation) UpdatedAt() (r time.Time, exists bool) {
  14567. v := m.updated_at
  14568. if v == nil {
  14569. return
  14570. }
  14571. return *v, true
  14572. }
  14573. // OldUpdatedAt returns the old "updated_at" field's value of the Label entity.
  14574. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  14575. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14576. func (m *LabelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  14577. if !m.op.Is(OpUpdateOne) {
  14578. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  14579. }
  14580. if m.id == nil || m.oldValue == nil {
  14581. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  14582. }
  14583. oldValue, err := m.oldValue(ctx)
  14584. if err != nil {
  14585. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  14586. }
  14587. return oldValue.UpdatedAt, nil
  14588. }
  14589. // ResetUpdatedAt resets all changes to the "updated_at" field.
  14590. func (m *LabelMutation) ResetUpdatedAt() {
  14591. m.updated_at = nil
  14592. }
  14593. // SetStatus sets the "status" field.
  14594. func (m *LabelMutation) SetStatus(u uint8) {
  14595. m.status = &u
  14596. m.addstatus = nil
  14597. }
  14598. // Status returns the value of the "status" field in the mutation.
  14599. func (m *LabelMutation) Status() (r uint8, exists bool) {
  14600. v := m.status
  14601. if v == nil {
  14602. return
  14603. }
  14604. return *v, true
  14605. }
  14606. // OldStatus returns the old "status" field's value of the Label entity.
  14607. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  14608. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14609. func (m *LabelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  14610. if !m.op.Is(OpUpdateOne) {
  14611. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  14612. }
  14613. if m.id == nil || m.oldValue == nil {
  14614. return v, errors.New("OldStatus requires an ID field in the mutation")
  14615. }
  14616. oldValue, err := m.oldValue(ctx)
  14617. if err != nil {
  14618. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  14619. }
  14620. return oldValue.Status, nil
  14621. }
  14622. // AddStatus adds u to the "status" field.
  14623. func (m *LabelMutation) AddStatus(u int8) {
  14624. if m.addstatus != nil {
  14625. *m.addstatus += u
  14626. } else {
  14627. m.addstatus = &u
  14628. }
  14629. }
  14630. // AddedStatus returns the value that was added to the "status" field in this mutation.
  14631. func (m *LabelMutation) AddedStatus() (r int8, exists bool) {
  14632. v := m.addstatus
  14633. if v == nil {
  14634. return
  14635. }
  14636. return *v, true
  14637. }
  14638. // ClearStatus clears the value of the "status" field.
  14639. func (m *LabelMutation) ClearStatus() {
  14640. m.status = nil
  14641. m.addstatus = nil
  14642. m.clearedFields[label.FieldStatus] = struct{}{}
  14643. }
  14644. // StatusCleared returns if the "status" field was cleared in this mutation.
  14645. func (m *LabelMutation) StatusCleared() bool {
  14646. _, ok := m.clearedFields[label.FieldStatus]
  14647. return ok
  14648. }
  14649. // ResetStatus resets all changes to the "status" field.
  14650. func (m *LabelMutation) ResetStatus() {
  14651. m.status = nil
  14652. m.addstatus = nil
  14653. delete(m.clearedFields, label.FieldStatus)
  14654. }
  14655. // SetType sets the "type" field.
  14656. func (m *LabelMutation) SetType(i int) {
  14657. m._type = &i
  14658. m.add_type = nil
  14659. }
  14660. // GetType returns the value of the "type" field in the mutation.
  14661. func (m *LabelMutation) GetType() (r int, exists bool) {
  14662. v := m._type
  14663. if v == nil {
  14664. return
  14665. }
  14666. return *v, true
  14667. }
  14668. // OldType returns the old "type" field's value of the Label entity.
  14669. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  14670. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14671. func (m *LabelMutation) OldType(ctx context.Context) (v int, err error) {
  14672. if !m.op.Is(OpUpdateOne) {
  14673. return v, errors.New("OldType is only allowed on UpdateOne operations")
  14674. }
  14675. if m.id == nil || m.oldValue == nil {
  14676. return v, errors.New("OldType requires an ID field in the mutation")
  14677. }
  14678. oldValue, err := m.oldValue(ctx)
  14679. if err != nil {
  14680. return v, fmt.Errorf("querying old value for OldType: %w", err)
  14681. }
  14682. return oldValue.Type, nil
  14683. }
  14684. // AddType adds i to the "type" field.
  14685. func (m *LabelMutation) AddType(i int) {
  14686. if m.add_type != nil {
  14687. *m.add_type += i
  14688. } else {
  14689. m.add_type = &i
  14690. }
  14691. }
  14692. // AddedType returns the value that was added to the "type" field in this mutation.
  14693. func (m *LabelMutation) AddedType() (r int, exists bool) {
  14694. v := m.add_type
  14695. if v == nil {
  14696. return
  14697. }
  14698. return *v, true
  14699. }
  14700. // ResetType resets all changes to the "type" field.
  14701. func (m *LabelMutation) ResetType() {
  14702. m._type = nil
  14703. m.add_type = nil
  14704. }
  14705. // SetName sets the "name" field.
  14706. func (m *LabelMutation) SetName(s string) {
  14707. m.name = &s
  14708. }
  14709. // Name returns the value of the "name" field in the mutation.
  14710. func (m *LabelMutation) Name() (r string, exists bool) {
  14711. v := m.name
  14712. if v == nil {
  14713. return
  14714. }
  14715. return *v, true
  14716. }
  14717. // OldName returns the old "name" field's value of the Label entity.
  14718. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  14719. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14720. func (m *LabelMutation) OldName(ctx context.Context) (v string, err error) {
  14721. if !m.op.Is(OpUpdateOne) {
  14722. return v, errors.New("OldName is only allowed on UpdateOne operations")
  14723. }
  14724. if m.id == nil || m.oldValue == nil {
  14725. return v, errors.New("OldName requires an ID field in the mutation")
  14726. }
  14727. oldValue, err := m.oldValue(ctx)
  14728. if err != nil {
  14729. return v, fmt.Errorf("querying old value for OldName: %w", err)
  14730. }
  14731. return oldValue.Name, nil
  14732. }
  14733. // ResetName resets all changes to the "name" field.
  14734. func (m *LabelMutation) ResetName() {
  14735. m.name = nil
  14736. }
  14737. // SetFrom sets the "from" field.
  14738. func (m *LabelMutation) SetFrom(i int) {
  14739. m.from = &i
  14740. m.addfrom = nil
  14741. }
  14742. // From returns the value of the "from" field in the mutation.
  14743. func (m *LabelMutation) From() (r int, exists bool) {
  14744. v := m.from
  14745. if v == nil {
  14746. return
  14747. }
  14748. return *v, true
  14749. }
  14750. // OldFrom returns the old "from" field's value of the Label entity.
  14751. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  14752. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14753. func (m *LabelMutation) OldFrom(ctx context.Context) (v int, err error) {
  14754. if !m.op.Is(OpUpdateOne) {
  14755. return v, errors.New("OldFrom is only allowed on UpdateOne operations")
  14756. }
  14757. if m.id == nil || m.oldValue == nil {
  14758. return v, errors.New("OldFrom requires an ID field in the mutation")
  14759. }
  14760. oldValue, err := m.oldValue(ctx)
  14761. if err != nil {
  14762. return v, fmt.Errorf("querying old value for OldFrom: %w", err)
  14763. }
  14764. return oldValue.From, nil
  14765. }
  14766. // AddFrom adds i to the "from" field.
  14767. func (m *LabelMutation) AddFrom(i int) {
  14768. if m.addfrom != nil {
  14769. *m.addfrom += i
  14770. } else {
  14771. m.addfrom = &i
  14772. }
  14773. }
  14774. // AddedFrom returns the value that was added to the "from" field in this mutation.
  14775. func (m *LabelMutation) AddedFrom() (r int, exists bool) {
  14776. v := m.addfrom
  14777. if v == nil {
  14778. return
  14779. }
  14780. return *v, true
  14781. }
  14782. // ResetFrom resets all changes to the "from" field.
  14783. func (m *LabelMutation) ResetFrom() {
  14784. m.from = nil
  14785. m.addfrom = nil
  14786. }
  14787. // SetMode sets the "mode" field.
  14788. func (m *LabelMutation) SetMode(i int) {
  14789. m.mode = &i
  14790. m.addmode = nil
  14791. }
  14792. // Mode returns the value of the "mode" field in the mutation.
  14793. func (m *LabelMutation) Mode() (r int, exists bool) {
  14794. v := m.mode
  14795. if v == nil {
  14796. return
  14797. }
  14798. return *v, true
  14799. }
  14800. // OldMode returns the old "mode" field's value of the Label entity.
  14801. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  14802. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14803. func (m *LabelMutation) OldMode(ctx context.Context) (v int, err error) {
  14804. if !m.op.Is(OpUpdateOne) {
  14805. return v, errors.New("OldMode is only allowed on UpdateOne operations")
  14806. }
  14807. if m.id == nil || m.oldValue == nil {
  14808. return v, errors.New("OldMode requires an ID field in the mutation")
  14809. }
  14810. oldValue, err := m.oldValue(ctx)
  14811. if err != nil {
  14812. return v, fmt.Errorf("querying old value for OldMode: %w", err)
  14813. }
  14814. return oldValue.Mode, nil
  14815. }
  14816. // AddMode adds i to the "mode" field.
  14817. func (m *LabelMutation) AddMode(i int) {
  14818. if m.addmode != nil {
  14819. *m.addmode += i
  14820. } else {
  14821. m.addmode = &i
  14822. }
  14823. }
  14824. // AddedMode returns the value that was added to the "mode" field in this mutation.
  14825. func (m *LabelMutation) AddedMode() (r int, exists bool) {
  14826. v := m.addmode
  14827. if v == nil {
  14828. return
  14829. }
  14830. return *v, true
  14831. }
  14832. // ResetMode resets all changes to the "mode" field.
  14833. func (m *LabelMutation) ResetMode() {
  14834. m.mode = nil
  14835. m.addmode = nil
  14836. }
  14837. // SetConditions sets the "conditions" field.
  14838. func (m *LabelMutation) SetConditions(s string) {
  14839. m.conditions = &s
  14840. }
  14841. // Conditions returns the value of the "conditions" field in the mutation.
  14842. func (m *LabelMutation) Conditions() (r string, exists bool) {
  14843. v := m.conditions
  14844. if v == nil {
  14845. return
  14846. }
  14847. return *v, true
  14848. }
  14849. // OldConditions returns the old "conditions" field's value of the Label entity.
  14850. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  14851. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14852. func (m *LabelMutation) OldConditions(ctx context.Context) (v string, err error) {
  14853. if !m.op.Is(OpUpdateOne) {
  14854. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  14855. }
  14856. if m.id == nil || m.oldValue == nil {
  14857. return v, errors.New("OldConditions requires an ID field in the mutation")
  14858. }
  14859. oldValue, err := m.oldValue(ctx)
  14860. if err != nil {
  14861. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  14862. }
  14863. return oldValue.Conditions, nil
  14864. }
  14865. // ClearConditions clears the value of the "conditions" field.
  14866. func (m *LabelMutation) ClearConditions() {
  14867. m.conditions = nil
  14868. m.clearedFields[label.FieldConditions] = struct{}{}
  14869. }
  14870. // ConditionsCleared returns if the "conditions" field was cleared in this mutation.
  14871. func (m *LabelMutation) ConditionsCleared() bool {
  14872. _, ok := m.clearedFields[label.FieldConditions]
  14873. return ok
  14874. }
  14875. // ResetConditions resets all changes to the "conditions" field.
  14876. func (m *LabelMutation) ResetConditions() {
  14877. m.conditions = nil
  14878. delete(m.clearedFields, label.FieldConditions)
  14879. }
  14880. // SetOrganizationID sets the "organization_id" field.
  14881. func (m *LabelMutation) SetOrganizationID(u uint64) {
  14882. m.organization_id = &u
  14883. m.addorganization_id = nil
  14884. }
  14885. // OrganizationID returns the value of the "organization_id" field in the mutation.
  14886. func (m *LabelMutation) OrganizationID() (r uint64, exists bool) {
  14887. v := m.organization_id
  14888. if v == nil {
  14889. return
  14890. }
  14891. return *v, true
  14892. }
  14893. // OldOrganizationID returns the old "organization_id" field's value of the Label entity.
  14894. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  14895. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14896. func (m *LabelMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  14897. if !m.op.Is(OpUpdateOne) {
  14898. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  14899. }
  14900. if m.id == nil || m.oldValue == nil {
  14901. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  14902. }
  14903. oldValue, err := m.oldValue(ctx)
  14904. if err != nil {
  14905. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  14906. }
  14907. return oldValue.OrganizationID, nil
  14908. }
  14909. // AddOrganizationID adds u to the "organization_id" field.
  14910. func (m *LabelMutation) AddOrganizationID(u int64) {
  14911. if m.addorganization_id != nil {
  14912. *m.addorganization_id += u
  14913. } else {
  14914. m.addorganization_id = &u
  14915. }
  14916. }
  14917. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  14918. func (m *LabelMutation) AddedOrganizationID() (r int64, exists bool) {
  14919. v := m.addorganization_id
  14920. if v == nil {
  14921. return
  14922. }
  14923. return *v, true
  14924. }
  14925. // ClearOrganizationID clears the value of the "organization_id" field.
  14926. func (m *LabelMutation) ClearOrganizationID() {
  14927. m.organization_id = nil
  14928. m.addorganization_id = nil
  14929. m.clearedFields[label.FieldOrganizationID] = struct{}{}
  14930. }
  14931. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  14932. func (m *LabelMutation) OrganizationIDCleared() bool {
  14933. _, ok := m.clearedFields[label.FieldOrganizationID]
  14934. return ok
  14935. }
  14936. // ResetOrganizationID resets all changes to the "organization_id" field.
  14937. func (m *LabelMutation) ResetOrganizationID() {
  14938. m.organization_id = nil
  14939. m.addorganization_id = nil
  14940. delete(m.clearedFields, label.FieldOrganizationID)
  14941. }
  14942. // AddLabelRelationshipIDs adds the "label_relationships" edge to the LabelRelationship entity by ids.
  14943. func (m *LabelMutation) AddLabelRelationshipIDs(ids ...uint64) {
  14944. if m.label_relationships == nil {
  14945. m.label_relationships = make(map[uint64]struct{})
  14946. }
  14947. for i := range ids {
  14948. m.label_relationships[ids[i]] = struct{}{}
  14949. }
  14950. }
  14951. // ClearLabelRelationships clears the "label_relationships" edge to the LabelRelationship entity.
  14952. func (m *LabelMutation) ClearLabelRelationships() {
  14953. m.clearedlabel_relationships = true
  14954. }
  14955. // LabelRelationshipsCleared reports if the "label_relationships" edge to the LabelRelationship entity was cleared.
  14956. func (m *LabelMutation) LabelRelationshipsCleared() bool {
  14957. return m.clearedlabel_relationships
  14958. }
  14959. // RemoveLabelRelationshipIDs removes the "label_relationships" edge to the LabelRelationship entity by IDs.
  14960. func (m *LabelMutation) RemoveLabelRelationshipIDs(ids ...uint64) {
  14961. if m.removedlabel_relationships == nil {
  14962. m.removedlabel_relationships = make(map[uint64]struct{})
  14963. }
  14964. for i := range ids {
  14965. delete(m.label_relationships, ids[i])
  14966. m.removedlabel_relationships[ids[i]] = struct{}{}
  14967. }
  14968. }
  14969. // RemovedLabelRelationships returns the removed IDs of the "label_relationships" edge to the LabelRelationship entity.
  14970. func (m *LabelMutation) RemovedLabelRelationshipsIDs() (ids []uint64) {
  14971. for id := range m.removedlabel_relationships {
  14972. ids = append(ids, id)
  14973. }
  14974. return
  14975. }
  14976. // LabelRelationshipsIDs returns the "label_relationships" edge IDs in the mutation.
  14977. func (m *LabelMutation) LabelRelationshipsIDs() (ids []uint64) {
  14978. for id := range m.label_relationships {
  14979. ids = append(ids, id)
  14980. }
  14981. return
  14982. }
  14983. // ResetLabelRelationships resets all changes to the "label_relationships" edge.
  14984. func (m *LabelMutation) ResetLabelRelationships() {
  14985. m.label_relationships = nil
  14986. m.clearedlabel_relationships = false
  14987. m.removedlabel_relationships = nil
  14988. }
  14989. // Where appends a list predicates to the LabelMutation builder.
  14990. func (m *LabelMutation) Where(ps ...predicate.Label) {
  14991. m.predicates = append(m.predicates, ps...)
  14992. }
  14993. // WhereP appends storage-level predicates to the LabelMutation builder. Using this method,
  14994. // users can use type-assertion to append predicates that do not depend on any generated package.
  14995. func (m *LabelMutation) WhereP(ps ...func(*sql.Selector)) {
  14996. p := make([]predicate.Label, len(ps))
  14997. for i := range ps {
  14998. p[i] = ps[i]
  14999. }
  15000. m.Where(p...)
  15001. }
  15002. // Op returns the operation name.
  15003. func (m *LabelMutation) Op() Op {
  15004. return m.op
  15005. }
  15006. // SetOp allows setting the mutation operation.
  15007. func (m *LabelMutation) SetOp(op Op) {
  15008. m.op = op
  15009. }
  15010. // Type returns the node type of this mutation (Label).
  15011. func (m *LabelMutation) Type() string {
  15012. return m.typ
  15013. }
  15014. // Fields returns all fields that were changed during this mutation. Note that in
  15015. // order to get all numeric fields that were incremented/decremented, call
  15016. // AddedFields().
  15017. func (m *LabelMutation) Fields() []string {
  15018. fields := make([]string, 0, 9)
  15019. if m.created_at != nil {
  15020. fields = append(fields, label.FieldCreatedAt)
  15021. }
  15022. if m.updated_at != nil {
  15023. fields = append(fields, label.FieldUpdatedAt)
  15024. }
  15025. if m.status != nil {
  15026. fields = append(fields, label.FieldStatus)
  15027. }
  15028. if m._type != nil {
  15029. fields = append(fields, label.FieldType)
  15030. }
  15031. if m.name != nil {
  15032. fields = append(fields, label.FieldName)
  15033. }
  15034. if m.from != nil {
  15035. fields = append(fields, label.FieldFrom)
  15036. }
  15037. if m.mode != nil {
  15038. fields = append(fields, label.FieldMode)
  15039. }
  15040. if m.conditions != nil {
  15041. fields = append(fields, label.FieldConditions)
  15042. }
  15043. if m.organization_id != nil {
  15044. fields = append(fields, label.FieldOrganizationID)
  15045. }
  15046. return fields
  15047. }
  15048. // Field returns the value of a field with the given name. The second boolean
  15049. // return value indicates that this field was not set, or was not defined in the
  15050. // schema.
  15051. func (m *LabelMutation) Field(name string) (ent.Value, bool) {
  15052. switch name {
  15053. case label.FieldCreatedAt:
  15054. return m.CreatedAt()
  15055. case label.FieldUpdatedAt:
  15056. return m.UpdatedAt()
  15057. case label.FieldStatus:
  15058. return m.Status()
  15059. case label.FieldType:
  15060. return m.GetType()
  15061. case label.FieldName:
  15062. return m.Name()
  15063. case label.FieldFrom:
  15064. return m.From()
  15065. case label.FieldMode:
  15066. return m.Mode()
  15067. case label.FieldConditions:
  15068. return m.Conditions()
  15069. case label.FieldOrganizationID:
  15070. return m.OrganizationID()
  15071. }
  15072. return nil, false
  15073. }
  15074. // OldField returns the old value of the field from the database. An error is
  15075. // returned if the mutation operation is not UpdateOne, or the query to the
  15076. // database failed.
  15077. func (m *LabelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  15078. switch name {
  15079. case label.FieldCreatedAt:
  15080. return m.OldCreatedAt(ctx)
  15081. case label.FieldUpdatedAt:
  15082. return m.OldUpdatedAt(ctx)
  15083. case label.FieldStatus:
  15084. return m.OldStatus(ctx)
  15085. case label.FieldType:
  15086. return m.OldType(ctx)
  15087. case label.FieldName:
  15088. return m.OldName(ctx)
  15089. case label.FieldFrom:
  15090. return m.OldFrom(ctx)
  15091. case label.FieldMode:
  15092. return m.OldMode(ctx)
  15093. case label.FieldConditions:
  15094. return m.OldConditions(ctx)
  15095. case label.FieldOrganizationID:
  15096. return m.OldOrganizationID(ctx)
  15097. }
  15098. return nil, fmt.Errorf("unknown Label field %s", name)
  15099. }
  15100. // SetField sets the value of a field with the given name. It returns an error if
  15101. // the field is not defined in the schema, or if the type mismatched the field
  15102. // type.
  15103. func (m *LabelMutation) SetField(name string, value ent.Value) error {
  15104. switch name {
  15105. case label.FieldCreatedAt:
  15106. v, ok := value.(time.Time)
  15107. if !ok {
  15108. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15109. }
  15110. m.SetCreatedAt(v)
  15111. return nil
  15112. case label.FieldUpdatedAt:
  15113. v, ok := value.(time.Time)
  15114. if !ok {
  15115. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15116. }
  15117. m.SetUpdatedAt(v)
  15118. return nil
  15119. case label.FieldStatus:
  15120. v, ok := value.(uint8)
  15121. if !ok {
  15122. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15123. }
  15124. m.SetStatus(v)
  15125. return nil
  15126. case label.FieldType:
  15127. v, ok := value.(int)
  15128. if !ok {
  15129. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15130. }
  15131. m.SetType(v)
  15132. return nil
  15133. case label.FieldName:
  15134. v, ok := value.(string)
  15135. if !ok {
  15136. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15137. }
  15138. m.SetName(v)
  15139. return nil
  15140. case label.FieldFrom:
  15141. v, ok := value.(int)
  15142. if !ok {
  15143. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15144. }
  15145. m.SetFrom(v)
  15146. return nil
  15147. case label.FieldMode:
  15148. v, ok := value.(int)
  15149. if !ok {
  15150. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15151. }
  15152. m.SetMode(v)
  15153. return nil
  15154. case label.FieldConditions:
  15155. v, ok := value.(string)
  15156. if !ok {
  15157. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15158. }
  15159. m.SetConditions(v)
  15160. return nil
  15161. case label.FieldOrganizationID:
  15162. v, ok := value.(uint64)
  15163. if !ok {
  15164. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15165. }
  15166. m.SetOrganizationID(v)
  15167. return nil
  15168. }
  15169. return fmt.Errorf("unknown Label field %s", name)
  15170. }
  15171. // AddedFields returns all numeric fields that were incremented/decremented during
  15172. // this mutation.
  15173. func (m *LabelMutation) AddedFields() []string {
  15174. var fields []string
  15175. if m.addstatus != nil {
  15176. fields = append(fields, label.FieldStatus)
  15177. }
  15178. if m.add_type != nil {
  15179. fields = append(fields, label.FieldType)
  15180. }
  15181. if m.addfrom != nil {
  15182. fields = append(fields, label.FieldFrom)
  15183. }
  15184. if m.addmode != nil {
  15185. fields = append(fields, label.FieldMode)
  15186. }
  15187. if m.addorganization_id != nil {
  15188. fields = append(fields, label.FieldOrganizationID)
  15189. }
  15190. return fields
  15191. }
  15192. // AddedField returns the numeric value that was incremented/decremented on a field
  15193. // with the given name. The second boolean return value indicates that this field
  15194. // was not set, or was not defined in the schema.
  15195. func (m *LabelMutation) AddedField(name string) (ent.Value, bool) {
  15196. switch name {
  15197. case label.FieldStatus:
  15198. return m.AddedStatus()
  15199. case label.FieldType:
  15200. return m.AddedType()
  15201. case label.FieldFrom:
  15202. return m.AddedFrom()
  15203. case label.FieldMode:
  15204. return m.AddedMode()
  15205. case label.FieldOrganizationID:
  15206. return m.AddedOrganizationID()
  15207. }
  15208. return nil, false
  15209. }
  15210. // AddField adds the value to the field with the given name. It returns an error if
  15211. // the field is not defined in the schema, or if the type mismatched the field
  15212. // type.
  15213. func (m *LabelMutation) AddField(name string, value ent.Value) error {
  15214. switch name {
  15215. case label.FieldStatus:
  15216. v, ok := value.(int8)
  15217. if !ok {
  15218. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15219. }
  15220. m.AddStatus(v)
  15221. return nil
  15222. case label.FieldType:
  15223. v, ok := value.(int)
  15224. if !ok {
  15225. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15226. }
  15227. m.AddType(v)
  15228. return nil
  15229. case label.FieldFrom:
  15230. v, ok := value.(int)
  15231. if !ok {
  15232. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15233. }
  15234. m.AddFrom(v)
  15235. return nil
  15236. case label.FieldMode:
  15237. v, ok := value.(int)
  15238. if !ok {
  15239. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15240. }
  15241. m.AddMode(v)
  15242. return nil
  15243. case label.FieldOrganizationID:
  15244. v, ok := value.(int64)
  15245. if !ok {
  15246. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15247. }
  15248. m.AddOrganizationID(v)
  15249. return nil
  15250. }
  15251. return fmt.Errorf("unknown Label numeric field %s", name)
  15252. }
  15253. // ClearedFields returns all nullable fields that were cleared during this
  15254. // mutation.
  15255. func (m *LabelMutation) ClearedFields() []string {
  15256. var fields []string
  15257. if m.FieldCleared(label.FieldStatus) {
  15258. fields = append(fields, label.FieldStatus)
  15259. }
  15260. if m.FieldCleared(label.FieldConditions) {
  15261. fields = append(fields, label.FieldConditions)
  15262. }
  15263. if m.FieldCleared(label.FieldOrganizationID) {
  15264. fields = append(fields, label.FieldOrganizationID)
  15265. }
  15266. return fields
  15267. }
  15268. // FieldCleared returns a boolean indicating if a field with the given name was
  15269. // cleared in this mutation.
  15270. func (m *LabelMutation) FieldCleared(name string) bool {
  15271. _, ok := m.clearedFields[name]
  15272. return ok
  15273. }
  15274. // ClearField clears the value of the field with the given name. It returns an
  15275. // error if the field is not defined in the schema.
  15276. func (m *LabelMutation) ClearField(name string) error {
  15277. switch name {
  15278. case label.FieldStatus:
  15279. m.ClearStatus()
  15280. return nil
  15281. case label.FieldConditions:
  15282. m.ClearConditions()
  15283. return nil
  15284. case label.FieldOrganizationID:
  15285. m.ClearOrganizationID()
  15286. return nil
  15287. }
  15288. return fmt.Errorf("unknown Label nullable field %s", name)
  15289. }
  15290. // ResetField resets all changes in the mutation for the field with the given name.
  15291. // It returns an error if the field is not defined in the schema.
  15292. func (m *LabelMutation) ResetField(name string) error {
  15293. switch name {
  15294. case label.FieldCreatedAt:
  15295. m.ResetCreatedAt()
  15296. return nil
  15297. case label.FieldUpdatedAt:
  15298. m.ResetUpdatedAt()
  15299. return nil
  15300. case label.FieldStatus:
  15301. m.ResetStatus()
  15302. return nil
  15303. case label.FieldType:
  15304. m.ResetType()
  15305. return nil
  15306. case label.FieldName:
  15307. m.ResetName()
  15308. return nil
  15309. case label.FieldFrom:
  15310. m.ResetFrom()
  15311. return nil
  15312. case label.FieldMode:
  15313. m.ResetMode()
  15314. return nil
  15315. case label.FieldConditions:
  15316. m.ResetConditions()
  15317. return nil
  15318. case label.FieldOrganizationID:
  15319. m.ResetOrganizationID()
  15320. return nil
  15321. }
  15322. return fmt.Errorf("unknown Label field %s", name)
  15323. }
  15324. // AddedEdges returns all edge names that were set/added in this mutation.
  15325. func (m *LabelMutation) AddedEdges() []string {
  15326. edges := make([]string, 0, 1)
  15327. if m.label_relationships != nil {
  15328. edges = append(edges, label.EdgeLabelRelationships)
  15329. }
  15330. return edges
  15331. }
  15332. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  15333. // name in this mutation.
  15334. func (m *LabelMutation) AddedIDs(name string) []ent.Value {
  15335. switch name {
  15336. case label.EdgeLabelRelationships:
  15337. ids := make([]ent.Value, 0, len(m.label_relationships))
  15338. for id := range m.label_relationships {
  15339. ids = append(ids, id)
  15340. }
  15341. return ids
  15342. }
  15343. return nil
  15344. }
  15345. // RemovedEdges returns all edge names that were removed in this mutation.
  15346. func (m *LabelMutation) RemovedEdges() []string {
  15347. edges := make([]string, 0, 1)
  15348. if m.removedlabel_relationships != nil {
  15349. edges = append(edges, label.EdgeLabelRelationships)
  15350. }
  15351. return edges
  15352. }
  15353. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  15354. // the given name in this mutation.
  15355. func (m *LabelMutation) RemovedIDs(name string) []ent.Value {
  15356. switch name {
  15357. case label.EdgeLabelRelationships:
  15358. ids := make([]ent.Value, 0, len(m.removedlabel_relationships))
  15359. for id := range m.removedlabel_relationships {
  15360. ids = append(ids, id)
  15361. }
  15362. return ids
  15363. }
  15364. return nil
  15365. }
  15366. // ClearedEdges returns all edge names that were cleared in this mutation.
  15367. func (m *LabelMutation) ClearedEdges() []string {
  15368. edges := make([]string, 0, 1)
  15369. if m.clearedlabel_relationships {
  15370. edges = append(edges, label.EdgeLabelRelationships)
  15371. }
  15372. return edges
  15373. }
  15374. // EdgeCleared returns a boolean which indicates if the edge with the given name
  15375. // was cleared in this mutation.
  15376. func (m *LabelMutation) EdgeCleared(name string) bool {
  15377. switch name {
  15378. case label.EdgeLabelRelationships:
  15379. return m.clearedlabel_relationships
  15380. }
  15381. return false
  15382. }
  15383. // ClearEdge clears the value of the edge with the given name. It returns an error
  15384. // if that edge is not defined in the schema.
  15385. func (m *LabelMutation) ClearEdge(name string) error {
  15386. switch name {
  15387. }
  15388. return fmt.Errorf("unknown Label unique edge %s", name)
  15389. }
  15390. // ResetEdge resets all changes to the edge with the given name in this mutation.
  15391. // It returns an error if the edge is not defined in the schema.
  15392. func (m *LabelMutation) ResetEdge(name string) error {
  15393. switch name {
  15394. case label.EdgeLabelRelationships:
  15395. m.ResetLabelRelationships()
  15396. return nil
  15397. }
  15398. return fmt.Errorf("unknown Label edge %s", name)
  15399. }
  15400. // LabelRelationshipMutation represents an operation that mutates the LabelRelationship nodes in the graph.
  15401. type LabelRelationshipMutation struct {
  15402. config
  15403. op Op
  15404. typ string
  15405. id *uint64
  15406. created_at *time.Time
  15407. updated_at *time.Time
  15408. status *uint8
  15409. addstatus *int8
  15410. organization_id *uint64
  15411. addorganization_id *int64
  15412. clearedFields map[string]struct{}
  15413. contacts *uint64
  15414. clearedcontacts bool
  15415. labels *uint64
  15416. clearedlabels bool
  15417. done bool
  15418. oldValue func(context.Context) (*LabelRelationship, error)
  15419. predicates []predicate.LabelRelationship
  15420. }
  15421. var _ ent.Mutation = (*LabelRelationshipMutation)(nil)
  15422. // labelrelationshipOption allows management of the mutation configuration using functional options.
  15423. type labelrelationshipOption func(*LabelRelationshipMutation)
  15424. // newLabelRelationshipMutation creates new mutation for the LabelRelationship entity.
  15425. func newLabelRelationshipMutation(c config, op Op, opts ...labelrelationshipOption) *LabelRelationshipMutation {
  15426. m := &LabelRelationshipMutation{
  15427. config: c,
  15428. op: op,
  15429. typ: TypeLabelRelationship,
  15430. clearedFields: make(map[string]struct{}),
  15431. }
  15432. for _, opt := range opts {
  15433. opt(m)
  15434. }
  15435. return m
  15436. }
  15437. // withLabelRelationshipID sets the ID field of the mutation.
  15438. func withLabelRelationshipID(id uint64) labelrelationshipOption {
  15439. return func(m *LabelRelationshipMutation) {
  15440. var (
  15441. err error
  15442. once sync.Once
  15443. value *LabelRelationship
  15444. )
  15445. m.oldValue = func(ctx context.Context) (*LabelRelationship, error) {
  15446. once.Do(func() {
  15447. if m.done {
  15448. err = errors.New("querying old values post mutation is not allowed")
  15449. } else {
  15450. value, err = m.Client().LabelRelationship.Get(ctx, id)
  15451. }
  15452. })
  15453. return value, err
  15454. }
  15455. m.id = &id
  15456. }
  15457. }
  15458. // withLabelRelationship sets the old LabelRelationship of the mutation.
  15459. func withLabelRelationship(node *LabelRelationship) labelrelationshipOption {
  15460. return func(m *LabelRelationshipMutation) {
  15461. m.oldValue = func(context.Context) (*LabelRelationship, error) {
  15462. return node, nil
  15463. }
  15464. m.id = &node.ID
  15465. }
  15466. }
  15467. // Client returns a new `ent.Client` from the mutation. If the mutation was
  15468. // executed in a transaction (ent.Tx), a transactional client is returned.
  15469. func (m LabelRelationshipMutation) Client() *Client {
  15470. client := &Client{config: m.config}
  15471. client.init()
  15472. return client
  15473. }
  15474. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  15475. // it returns an error otherwise.
  15476. func (m LabelRelationshipMutation) Tx() (*Tx, error) {
  15477. if _, ok := m.driver.(*txDriver); !ok {
  15478. return nil, errors.New("ent: mutation is not running in a transaction")
  15479. }
  15480. tx := &Tx{config: m.config}
  15481. tx.init()
  15482. return tx, nil
  15483. }
  15484. // SetID sets the value of the id field. Note that this
  15485. // operation is only accepted on creation of LabelRelationship entities.
  15486. func (m *LabelRelationshipMutation) SetID(id uint64) {
  15487. m.id = &id
  15488. }
  15489. // ID returns the ID value in the mutation. Note that the ID is only available
  15490. // if it was provided to the builder or after it was returned from the database.
  15491. func (m *LabelRelationshipMutation) ID() (id uint64, exists bool) {
  15492. if m.id == nil {
  15493. return
  15494. }
  15495. return *m.id, true
  15496. }
  15497. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  15498. // That means, if the mutation is applied within a transaction with an isolation level such
  15499. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  15500. // or updated by the mutation.
  15501. func (m *LabelRelationshipMutation) IDs(ctx context.Context) ([]uint64, error) {
  15502. switch {
  15503. case m.op.Is(OpUpdateOne | OpDeleteOne):
  15504. id, exists := m.ID()
  15505. if exists {
  15506. return []uint64{id}, nil
  15507. }
  15508. fallthrough
  15509. case m.op.Is(OpUpdate | OpDelete):
  15510. return m.Client().LabelRelationship.Query().Where(m.predicates...).IDs(ctx)
  15511. default:
  15512. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  15513. }
  15514. }
  15515. // SetCreatedAt sets the "created_at" field.
  15516. func (m *LabelRelationshipMutation) SetCreatedAt(t time.Time) {
  15517. m.created_at = &t
  15518. }
  15519. // CreatedAt returns the value of the "created_at" field in the mutation.
  15520. func (m *LabelRelationshipMutation) CreatedAt() (r time.Time, exists bool) {
  15521. v := m.created_at
  15522. if v == nil {
  15523. return
  15524. }
  15525. return *v, true
  15526. }
  15527. // OldCreatedAt returns the old "created_at" field's value of the LabelRelationship entity.
  15528. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  15529. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15530. func (m *LabelRelationshipMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  15531. if !m.op.Is(OpUpdateOne) {
  15532. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  15533. }
  15534. if m.id == nil || m.oldValue == nil {
  15535. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  15536. }
  15537. oldValue, err := m.oldValue(ctx)
  15538. if err != nil {
  15539. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  15540. }
  15541. return oldValue.CreatedAt, nil
  15542. }
  15543. // ResetCreatedAt resets all changes to the "created_at" field.
  15544. func (m *LabelRelationshipMutation) ResetCreatedAt() {
  15545. m.created_at = nil
  15546. }
  15547. // SetUpdatedAt sets the "updated_at" field.
  15548. func (m *LabelRelationshipMutation) SetUpdatedAt(t time.Time) {
  15549. m.updated_at = &t
  15550. }
  15551. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  15552. func (m *LabelRelationshipMutation) UpdatedAt() (r time.Time, exists bool) {
  15553. v := m.updated_at
  15554. if v == nil {
  15555. return
  15556. }
  15557. return *v, true
  15558. }
  15559. // OldUpdatedAt returns the old "updated_at" field's value of the LabelRelationship entity.
  15560. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  15561. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15562. func (m *LabelRelationshipMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  15563. if !m.op.Is(OpUpdateOne) {
  15564. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  15565. }
  15566. if m.id == nil || m.oldValue == nil {
  15567. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  15568. }
  15569. oldValue, err := m.oldValue(ctx)
  15570. if err != nil {
  15571. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  15572. }
  15573. return oldValue.UpdatedAt, nil
  15574. }
  15575. // ResetUpdatedAt resets all changes to the "updated_at" field.
  15576. func (m *LabelRelationshipMutation) ResetUpdatedAt() {
  15577. m.updated_at = nil
  15578. }
  15579. // SetStatus sets the "status" field.
  15580. func (m *LabelRelationshipMutation) SetStatus(u uint8) {
  15581. m.status = &u
  15582. m.addstatus = nil
  15583. }
  15584. // Status returns the value of the "status" field in the mutation.
  15585. func (m *LabelRelationshipMutation) Status() (r uint8, exists bool) {
  15586. v := m.status
  15587. if v == nil {
  15588. return
  15589. }
  15590. return *v, true
  15591. }
  15592. // OldStatus returns the old "status" field's value of the LabelRelationship entity.
  15593. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  15594. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15595. func (m *LabelRelationshipMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  15596. if !m.op.Is(OpUpdateOne) {
  15597. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  15598. }
  15599. if m.id == nil || m.oldValue == nil {
  15600. return v, errors.New("OldStatus requires an ID field in the mutation")
  15601. }
  15602. oldValue, err := m.oldValue(ctx)
  15603. if err != nil {
  15604. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  15605. }
  15606. return oldValue.Status, nil
  15607. }
  15608. // AddStatus adds u to the "status" field.
  15609. func (m *LabelRelationshipMutation) AddStatus(u int8) {
  15610. if m.addstatus != nil {
  15611. *m.addstatus += u
  15612. } else {
  15613. m.addstatus = &u
  15614. }
  15615. }
  15616. // AddedStatus returns the value that was added to the "status" field in this mutation.
  15617. func (m *LabelRelationshipMutation) AddedStatus() (r int8, exists bool) {
  15618. v := m.addstatus
  15619. if v == nil {
  15620. return
  15621. }
  15622. return *v, true
  15623. }
  15624. // ClearStatus clears the value of the "status" field.
  15625. func (m *LabelRelationshipMutation) ClearStatus() {
  15626. m.status = nil
  15627. m.addstatus = nil
  15628. m.clearedFields[labelrelationship.FieldStatus] = struct{}{}
  15629. }
  15630. // StatusCleared returns if the "status" field was cleared in this mutation.
  15631. func (m *LabelRelationshipMutation) StatusCleared() bool {
  15632. _, ok := m.clearedFields[labelrelationship.FieldStatus]
  15633. return ok
  15634. }
  15635. // ResetStatus resets all changes to the "status" field.
  15636. func (m *LabelRelationshipMutation) ResetStatus() {
  15637. m.status = nil
  15638. m.addstatus = nil
  15639. delete(m.clearedFields, labelrelationship.FieldStatus)
  15640. }
  15641. // SetLabelID sets the "label_id" field.
  15642. func (m *LabelRelationshipMutation) SetLabelID(u uint64) {
  15643. m.labels = &u
  15644. }
  15645. // LabelID returns the value of the "label_id" field in the mutation.
  15646. func (m *LabelRelationshipMutation) LabelID() (r uint64, exists bool) {
  15647. v := m.labels
  15648. if v == nil {
  15649. return
  15650. }
  15651. return *v, true
  15652. }
  15653. // OldLabelID returns the old "label_id" field's value of the LabelRelationship entity.
  15654. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  15655. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15656. func (m *LabelRelationshipMutation) OldLabelID(ctx context.Context) (v uint64, err error) {
  15657. if !m.op.Is(OpUpdateOne) {
  15658. return v, errors.New("OldLabelID is only allowed on UpdateOne operations")
  15659. }
  15660. if m.id == nil || m.oldValue == nil {
  15661. return v, errors.New("OldLabelID requires an ID field in the mutation")
  15662. }
  15663. oldValue, err := m.oldValue(ctx)
  15664. if err != nil {
  15665. return v, fmt.Errorf("querying old value for OldLabelID: %w", err)
  15666. }
  15667. return oldValue.LabelID, nil
  15668. }
  15669. // ResetLabelID resets all changes to the "label_id" field.
  15670. func (m *LabelRelationshipMutation) ResetLabelID() {
  15671. m.labels = nil
  15672. }
  15673. // SetContactID sets the "contact_id" field.
  15674. func (m *LabelRelationshipMutation) SetContactID(u uint64) {
  15675. m.contacts = &u
  15676. }
  15677. // ContactID returns the value of the "contact_id" field in the mutation.
  15678. func (m *LabelRelationshipMutation) ContactID() (r uint64, exists bool) {
  15679. v := m.contacts
  15680. if v == nil {
  15681. return
  15682. }
  15683. return *v, true
  15684. }
  15685. // OldContactID returns the old "contact_id" field's value of the LabelRelationship entity.
  15686. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  15687. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15688. func (m *LabelRelationshipMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  15689. if !m.op.Is(OpUpdateOne) {
  15690. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  15691. }
  15692. if m.id == nil || m.oldValue == nil {
  15693. return v, errors.New("OldContactID requires an ID field in the mutation")
  15694. }
  15695. oldValue, err := m.oldValue(ctx)
  15696. if err != nil {
  15697. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  15698. }
  15699. return oldValue.ContactID, nil
  15700. }
  15701. // ResetContactID resets all changes to the "contact_id" field.
  15702. func (m *LabelRelationshipMutation) ResetContactID() {
  15703. m.contacts = nil
  15704. }
  15705. // SetOrganizationID sets the "organization_id" field.
  15706. func (m *LabelRelationshipMutation) SetOrganizationID(u uint64) {
  15707. m.organization_id = &u
  15708. m.addorganization_id = nil
  15709. }
  15710. // OrganizationID returns the value of the "organization_id" field in the mutation.
  15711. func (m *LabelRelationshipMutation) OrganizationID() (r uint64, exists bool) {
  15712. v := m.organization_id
  15713. if v == nil {
  15714. return
  15715. }
  15716. return *v, true
  15717. }
  15718. // OldOrganizationID returns the old "organization_id" field's value of the LabelRelationship entity.
  15719. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  15720. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15721. func (m *LabelRelationshipMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  15722. if !m.op.Is(OpUpdateOne) {
  15723. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  15724. }
  15725. if m.id == nil || m.oldValue == nil {
  15726. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  15727. }
  15728. oldValue, err := m.oldValue(ctx)
  15729. if err != nil {
  15730. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  15731. }
  15732. return oldValue.OrganizationID, nil
  15733. }
  15734. // AddOrganizationID adds u to the "organization_id" field.
  15735. func (m *LabelRelationshipMutation) AddOrganizationID(u int64) {
  15736. if m.addorganization_id != nil {
  15737. *m.addorganization_id += u
  15738. } else {
  15739. m.addorganization_id = &u
  15740. }
  15741. }
  15742. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  15743. func (m *LabelRelationshipMutation) AddedOrganizationID() (r int64, exists bool) {
  15744. v := m.addorganization_id
  15745. if v == nil {
  15746. return
  15747. }
  15748. return *v, true
  15749. }
  15750. // ClearOrganizationID clears the value of the "organization_id" field.
  15751. func (m *LabelRelationshipMutation) ClearOrganizationID() {
  15752. m.organization_id = nil
  15753. m.addorganization_id = nil
  15754. m.clearedFields[labelrelationship.FieldOrganizationID] = struct{}{}
  15755. }
  15756. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  15757. func (m *LabelRelationshipMutation) OrganizationIDCleared() bool {
  15758. _, ok := m.clearedFields[labelrelationship.FieldOrganizationID]
  15759. return ok
  15760. }
  15761. // ResetOrganizationID resets all changes to the "organization_id" field.
  15762. func (m *LabelRelationshipMutation) ResetOrganizationID() {
  15763. m.organization_id = nil
  15764. m.addorganization_id = nil
  15765. delete(m.clearedFields, labelrelationship.FieldOrganizationID)
  15766. }
  15767. // SetContactsID sets the "contacts" edge to the Contact entity by id.
  15768. func (m *LabelRelationshipMutation) SetContactsID(id uint64) {
  15769. m.contacts = &id
  15770. }
  15771. // ClearContacts clears the "contacts" edge to the Contact entity.
  15772. func (m *LabelRelationshipMutation) ClearContacts() {
  15773. m.clearedcontacts = true
  15774. m.clearedFields[labelrelationship.FieldContactID] = struct{}{}
  15775. }
  15776. // ContactsCleared reports if the "contacts" edge to the Contact entity was cleared.
  15777. func (m *LabelRelationshipMutation) ContactsCleared() bool {
  15778. return m.clearedcontacts
  15779. }
  15780. // ContactsID returns the "contacts" edge ID in the mutation.
  15781. func (m *LabelRelationshipMutation) ContactsID() (id uint64, exists bool) {
  15782. if m.contacts != nil {
  15783. return *m.contacts, true
  15784. }
  15785. return
  15786. }
  15787. // ContactsIDs returns the "contacts" edge IDs in the mutation.
  15788. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  15789. // ContactsID instead. It exists only for internal usage by the builders.
  15790. func (m *LabelRelationshipMutation) ContactsIDs() (ids []uint64) {
  15791. if id := m.contacts; id != nil {
  15792. ids = append(ids, *id)
  15793. }
  15794. return
  15795. }
  15796. // ResetContacts resets all changes to the "contacts" edge.
  15797. func (m *LabelRelationshipMutation) ResetContacts() {
  15798. m.contacts = nil
  15799. m.clearedcontacts = false
  15800. }
  15801. // SetLabelsID sets the "labels" edge to the Label entity by id.
  15802. func (m *LabelRelationshipMutation) SetLabelsID(id uint64) {
  15803. m.labels = &id
  15804. }
  15805. // ClearLabels clears the "labels" edge to the Label entity.
  15806. func (m *LabelRelationshipMutation) ClearLabels() {
  15807. m.clearedlabels = true
  15808. m.clearedFields[labelrelationship.FieldLabelID] = struct{}{}
  15809. }
  15810. // LabelsCleared reports if the "labels" edge to the Label entity was cleared.
  15811. func (m *LabelRelationshipMutation) LabelsCleared() bool {
  15812. return m.clearedlabels
  15813. }
  15814. // LabelsID returns the "labels" edge ID in the mutation.
  15815. func (m *LabelRelationshipMutation) LabelsID() (id uint64, exists bool) {
  15816. if m.labels != nil {
  15817. return *m.labels, true
  15818. }
  15819. return
  15820. }
  15821. // LabelsIDs returns the "labels" edge IDs in the mutation.
  15822. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  15823. // LabelsID instead. It exists only for internal usage by the builders.
  15824. func (m *LabelRelationshipMutation) LabelsIDs() (ids []uint64) {
  15825. if id := m.labels; id != nil {
  15826. ids = append(ids, *id)
  15827. }
  15828. return
  15829. }
  15830. // ResetLabels resets all changes to the "labels" edge.
  15831. func (m *LabelRelationshipMutation) ResetLabels() {
  15832. m.labels = nil
  15833. m.clearedlabels = false
  15834. }
  15835. // Where appends a list predicates to the LabelRelationshipMutation builder.
  15836. func (m *LabelRelationshipMutation) Where(ps ...predicate.LabelRelationship) {
  15837. m.predicates = append(m.predicates, ps...)
  15838. }
  15839. // WhereP appends storage-level predicates to the LabelRelationshipMutation builder. Using this method,
  15840. // users can use type-assertion to append predicates that do not depend on any generated package.
  15841. func (m *LabelRelationshipMutation) WhereP(ps ...func(*sql.Selector)) {
  15842. p := make([]predicate.LabelRelationship, len(ps))
  15843. for i := range ps {
  15844. p[i] = ps[i]
  15845. }
  15846. m.Where(p...)
  15847. }
  15848. // Op returns the operation name.
  15849. func (m *LabelRelationshipMutation) Op() Op {
  15850. return m.op
  15851. }
  15852. // SetOp allows setting the mutation operation.
  15853. func (m *LabelRelationshipMutation) SetOp(op Op) {
  15854. m.op = op
  15855. }
  15856. // Type returns the node type of this mutation (LabelRelationship).
  15857. func (m *LabelRelationshipMutation) Type() string {
  15858. return m.typ
  15859. }
  15860. // Fields returns all fields that were changed during this mutation. Note that in
  15861. // order to get all numeric fields that were incremented/decremented, call
  15862. // AddedFields().
  15863. func (m *LabelRelationshipMutation) Fields() []string {
  15864. fields := make([]string, 0, 6)
  15865. if m.created_at != nil {
  15866. fields = append(fields, labelrelationship.FieldCreatedAt)
  15867. }
  15868. if m.updated_at != nil {
  15869. fields = append(fields, labelrelationship.FieldUpdatedAt)
  15870. }
  15871. if m.status != nil {
  15872. fields = append(fields, labelrelationship.FieldStatus)
  15873. }
  15874. if m.labels != nil {
  15875. fields = append(fields, labelrelationship.FieldLabelID)
  15876. }
  15877. if m.contacts != nil {
  15878. fields = append(fields, labelrelationship.FieldContactID)
  15879. }
  15880. if m.organization_id != nil {
  15881. fields = append(fields, labelrelationship.FieldOrganizationID)
  15882. }
  15883. return fields
  15884. }
  15885. // Field returns the value of a field with the given name. The second boolean
  15886. // return value indicates that this field was not set, or was not defined in the
  15887. // schema.
  15888. func (m *LabelRelationshipMutation) Field(name string) (ent.Value, bool) {
  15889. switch name {
  15890. case labelrelationship.FieldCreatedAt:
  15891. return m.CreatedAt()
  15892. case labelrelationship.FieldUpdatedAt:
  15893. return m.UpdatedAt()
  15894. case labelrelationship.FieldStatus:
  15895. return m.Status()
  15896. case labelrelationship.FieldLabelID:
  15897. return m.LabelID()
  15898. case labelrelationship.FieldContactID:
  15899. return m.ContactID()
  15900. case labelrelationship.FieldOrganizationID:
  15901. return m.OrganizationID()
  15902. }
  15903. return nil, false
  15904. }
  15905. // OldField returns the old value of the field from the database. An error is
  15906. // returned if the mutation operation is not UpdateOne, or the query to the
  15907. // database failed.
  15908. func (m *LabelRelationshipMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  15909. switch name {
  15910. case labelrelationship.FieldCreatedAt:
  15911. return m.OldCreatedAt(ctx)
  15912. case labelrelationship.FieldUpdatedAt:
  15913. return m.OldUpdatedAt(ctx)
  15914. case labelrelationship.FieldStatus:
  15915. return m.OldStatus(ctx)
  15916. case labelrelationship.FieldLabelID:
  15917. return m.OldLabelID(ctx)
  15918. case labelrelationship.FieldContactID:
  15919. return m.OldContactID(ctx)
  15920. case labelrelationship.FieldOrganizationID:
  15921. return m.OldOrganizationID(ctx)
  15922. }
  15923. return nil, fmt.Errorf("unknown LabelRelationship field %s", name)
  15924. }
  15925. // SetField sets the value of a field with the given name. It returns an error if
  15926. // the field is not defined in the schema, or if the type mismatched the field
  15927. // type.
  15928. func (m *LabelRelationshipMutation) SetField(name string, value ent.Value) error {
  15929. switch name {
  15930. case labelrelationship.FieldCreatedAt:
  15931. v, ok := value.(time.Time)
  15932. if !ok {
  15933. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15934. }
  15935. m.SetCreatedAt(v)
  15936. return nil
  15937. case labelrelationship.FieldUpdatedAt:
  15938. v, ok := value.(time.Time)
  15939. if !ok {
  15940. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15941. }
  15942. m.SetUpdatedAt(v)
  15943. return nil
  15944. case labelrelationship.FieldStatus:
  15945. v, ok := value.(uint8)
  15946. if !ok {
  15947. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15948. }
  15949. m.SetStatus(v)
  15950. return nil
  15951. case labelrelationship.FieldLabelID:
  15952. v, ok := value.(uint64)
  15953. if !ok {
  15954. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15955. }
  15956. m.SetLabelID(v)
  15957. return nil
  15958. case labelrelationship.FieldContactID:
  15959. v, ok := value.(uint64)
  15960. if !ok {
  15961. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15962. }
  15963. m.SetContactID(v)
  15964. return nil
  15965. case labelrelationship.FieldOrganizationID:
  15966. v, ok := value.(uint64)
  15967. if !ok {
  15968. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15969. }
  15970. m.SetOrganizationID(v)
  15971. return nil
  15972. }
  15973. return fmt.Errorf("unknown LabelRelationship field %s", name)
  15974. }
  15975. // AddedFields returns all numeric fields that were incremented/decremented during
  15976. // this mutation.
  15977. func (m *LabelRelationshipMutation) AddedFields() []string {
  15978. var fields []string
  15979. if m.addstatus != nil {
  15980. fields = append(fields, labelrelationship.FieldStatus)
  15981. }
  15982. if m.addorganization_id != nil {
  15983. fields = append(fields, labelrelationship.FieldOrganizationID)
  15984. }
  15985. return fields
  15986. }
  15987. // AddedField returns the numeric value that was incremented/decremented on a field
  15988. // with the given name. The second boolean return value indicates that this field
  15989. // was not set, or was not defined in the schema.
  15990. func (m *LabelRelationshipMutation) AddedField(name string) (ent.Value, bool) {
  15991. switch name {
  15992. case labelrelationship.FieldStatus:
  15993. return m.AddedStatus()
  15994. case labelrelationship.FieldOrganizationID:
  15995. return m.AddedOrganizationID()
  15996. }
  15997. return nil, false
  15998. }
  15999. // AddField adds the value to the field with the given name. It returns an error if
  16000. // the field is not defined in the schema, or if the type mismatched the field
  16001. // type.
  16002. func (m *LabelRelationshipMutation) AddField(name string, value ent.Value) error {
  16003. switch name {
  16004. case labelrelationship.FieldStatus:
  16005. v, ok := value.(int8)
  16006. if !ok {
  16007. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16008. }
  16009. m.AddStatus(v)
  16010. return nil
  16011. case labelrelationship.FieldOrganizationID:
  16012. v, ok := value.(int64)
  16013. if !ok {
  16014. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16015. }
  16016. m.AddOrganizationID(v)
  16017. return nil
  16018. }
  16019. return fmt.Errorf("unknown LabelRelationship numeric field %s", name)
  16020. }
  16021. // ClearedFields returns all nullable fields that were cleared during this
  16022. // mutation.
  16023. func (m *LabelRelationshipMutation) ClearedFields() []string {
  16024. var fields []string
  16025. if m.FieldCleared(labelrelationship.FieldStatus) {
  16026. fields = append(fields, labelrelationship.FieldStatus)
  16027. }
  16028. if m.FieldCleared(labelrelationship.FieldOrganizationID) {
  16029. fields = append(fields, labelrelationship.FieldOrganizationID)
  16030. }
  16031. return fields
  16032. }
  16033. // FieldCleared returns a boolean indicating if a field with the given name was
  16034. // cleared in this mutation.
  16035. func (m *LabelRelationshipMutation) FieldCleared(name string) bool {
  16036. _, ok := m.clearedFields[name]
  16037. return ok
  16038. }
  16039. // ClearField clears the value of the field with the given name. It returns an
  16040. // error if the field is not defined in the schema.
  16041. func (m *LabelRelationshipMutation) ClearField(name string) error {
  16042. switch name {
  16043. case labelrelationship.FieldStatus:
  16044. m.ClearStatus()
  16045. return nil
  16046. case labelrelationship.FieldOrganizationID:
  16047. m.ClearOrganizationID()
  16048. return nil
  16049. }
  16050. return fmt.Errorf("unknown LabelRelationship nullable field %s", name)
  16051. }
  16052. // ResetField resets all changes in the mutation for the field with the given name.
  16053. // It returns an error if the field is not defined in the schema.
  16054. func (m *LabelRelationshipMutation) ResetField(name string) error {
  16055. switch name {
  16056. case labelrelationship.FieldCreatedAt:
  16057. m.ResetCreatedAt()
  16058. return nil
  16059. case labelrelationship.FieldUpdatedAt:
  16060. m.ResetUpdatedAt()
  16061. return nil
  16062. case labelrelationship.FieldStatus:
  16063. m.ResetStatus()
  16064. return nil
  16065. case labelrelationship.FieldLabelID:
  16066. m.ResetLabelID()
  16067. return nil
  16068. case labelrelationship.FieldContactID:
  16069. m.ResetContactID()
  16070. return nil
  16071. case labelrelationship.FieldOrganizationID:
  16072. m.ResetOrganizationID()
  16073. return nil
  16074. }
  16075. return fmt.Errorf("unknown LabelRelationship field %s", name)
  16076. }
  16077. // AddedEdges returns all edge names that were set/added in this mutation.
  16078. func (m *LabelRelationshipMutation) AddedEdges() []string {
  16079. edges := make([]string, 0, 2)
  16080. if m.contacts != nil {
  16081. edges = append(edges, labelrelationship.EdgeContacts)
  16082. }
  16083. if m.labels != nil {
  16084. edges = append(edges, labelrelationship.EdgeLabels)
  16085. }
  16086. return edges
  16087. }
  16088. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  16089. // name in this mutation.
  16090. func (m *LabelRelationshipMutation) AddedIDs(name string) []ent.Value {
  16091. switch name {
  16092. case labelrelationship.EdgeContacts:
  16093. if id := m.contacts; id != nil {
  16094. return []ent.Value{*id}
  16095. }
  16096. case labelrelationship.EdgeLabels:
  16097. if id := m.labels; id != nil {
  16098. return []ent.Value{*id}
  16099. }
  16100. }
  16101. return nil
  16102. }
  16103. // RemovedEdges returns all edge names that were removed in this mutation.
  16104. func (m *LabelRelationshipMutation) RemovedEdges() []string {
  16105. edges := make([]string, 0, 2)
  16106. return edges
  16107. }
  16108. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  16109. // the given name in this mutation.
  16110. func (m *LabelRelationshipMutation) RemovedIDs(name string) []ent.Value {
  16111. return nil
  16112. }
  16113. // ClearedEdges returns all edge names that were cleared in this mutation.
  16114. func (m *LabelRelationshipMutation) ClearedEdges() []string {
  16115. edges := make([]string, 0, 2)
  16116. if m.clearedcontacts {
  16117. edges = append(edges, labelrelationship.EdgeContacts)
  16118. }
  16119. if m.clearedlabels {
  16120. edges = append(edges, labelrelationship.EdgeLabels)
  16121. }
  16122. return edges
  16123. }
  16124. // EdgeCleared returns a boolean which indicates if the edge with the given name
  16125. // was cleared in this mutation.
  16126. func (m *LabelRelationshipMutation) EdgeCleared(name string) bool {
  16127. switch name {
  16128. case labelrelationship.EdgeContacts:
  16129. return m.clearedcontacts
  16130. case labelrelationship.EdgeLabels:
  16131. return m.clearedlabels
  16132. }
  16133. return false
  16134. }
  16135. // ClearEdge clears the value of the edge with the given name. It returns an error
  16136. // if that edge is not defined in the schema.
  16137. func (m *LabelRelationshipMutation) ClearEdge(name string) error {
  16138. switch name {
  16139. case labelrelationship.EdgeContacts:
  16140. m.ClearContacts()
  16141. return nil
  16142. case labelrelationship.EdgeLabels:
  16143. m.ClearLabels()
  16144. return nil
  16145. }
  16146. return fmt.Errorf("unknown LabelRelationship unique edge %s", name)
  16147. }
  16148. // ResetEdge resets all changes to the edge with the given name in this mutation.
  16149. // It returns an error if the edge is not defined in the schema.
  16150. func (m *LabelRelationshipMutation) ResetEdge(name string) error {
  16151. switch name {
  16152. case labelrelationship.EdgeContacts:
  16153. m.ResetContacts()
  16154. return nil
  16155. case labelrelationship.EdgeLabels:
  16156. m.ResetLabels()
  16157. return nil
  16158. }
  16159. return fmt.Errorf("unknown LabelRelationship edge %s", name)
  16160. }
  16161. // LabelTaggingMutation represents an operation that mutates the LabelTagging nodes in the graph.
  16162. type LabelTaggingMutation struct {
  16163. config
  16164. op Op
  16165. typ string
  16166. id *uint64
  16167. created_at *time.Time
  16168. updated_at *time.Time
  16169. status *uint8
  16170. addstatus *int8
  16171. deleted_at *time.Time
  16172. organization_id *uint64
  16173. addorganization_id *int64
  16174. _type *int
  16175. add_type *int
  16176. conditions *string
  16177. action_label_add *[]uint64
  16178. appendaction_label_add []uint64
  16179. action_label_del *[]uint64
  16180. appendaction_label_del []uint64
  16181. clearedFields map[string]struct{}
  16182. done bool
  16183. oldValue func(context.Context) (*LabelTagging, error)
  16184. predicates []predicate.LabelTagging
  16185. }
  16186. var _ ent.Mutation = (*LabelTaggingMutation)(nil)
  16187. // labeltaggingOption allows management of the mutation configuration using functional options.
  16188. type labeltaggingOption func(*LabelTaggingMutation)
  16189. // newLabelTaggingMutation creates new mutation for the LabelTagging entity.
  16190. func newLabelTaggingMutation(c config, op Op, opts ...labeltaggingOption) *LabelTaggingMutation {
  16191. m := &LabelTaggingMutation{
  16192. config: c,
  16193. op: op,
  16194. typ: TypeLabelTagging,
  16195. clearedFields: make(map[string]struct{}),
  16196. }
  16197. for _, opt := range opts {
  16198. opt(m)
  16199. }
  16200. return m
  16201. }
  16202. // withLabelTaggingID sets the ID field of the mutation.
  16203. func withLabelTaggingID(id uint64) labeltaggingOption {
  16204. return func(m *LabelTaggingMutation) {
  16205. var (
  16206. err error
  16207. once sync.Once
  16208. value *LabelTagging
  16209. )
  16210. m.oldValue = func(ctx context.Context) (*LabelTagging, error) {
  16211. once.Do(func() {
  16212. if m.done {
  16213. err = errors.New("querying old values post mutation is not allowed")
  16214. } else {
  16215. value, err = m.Client().LabelTagging.Get(ctx, id)
  16216. }
  16217. })
  16218. return value, err
  16219. }
  16220. m.id = &id
  16221. }
  16222. }
  16223. // withLabelTagging sets the old LabelTagging of the mutation.
  16224. func withLabelTagging(node *LabelTagging) labeltaggingOption {
  16225. return func(m *LabelTaggingMutation) {
  16226. m.oldValue = func(context.Context) (*LabelTagging, error) {
  16227. return node, nil
  16228. }
  16229. m.id = &node.ID
  16230. }
  16231. }
  16232. // Client returns a new `ent.Client` from the mutation. If the mutation was
  16233. // executed in a transaction (ent.Tx), a transactional client is returned.
  16234. func (m LabelTaggingMutation) Client() *Client {
  16235. client := &Client{config: m.config}
  16236. client.init()
  16237. return client
  16238. }
  16239. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  16240. // it returns an error otherwise.
  16241. func (m LabelTaggingMutation) Tx() (*Tx, error) {
  16242. if _, ok := m.driver.(*txDriver); !ok {
  16243. return nil, errors.New("ent: mutation is not running in a transaction")
  16244. }
  16245. tx := &Tx{config: m.config}
  16246. tx.init()
  16247. return tx, nil
  16248. }
  16249. // SetID sets the value of the id field. Note that this
  16250. // operation is only accepted on creation of LabelTagging entities.
  16251. func (m *LabelTaggingMutation) SetID(id uint64) {
  16252. m.id = &id
  16253. }
  16254. // ID returns the ID value in the mutation. Note that the ID is only available
  16255. // if it was provided to the builder or after it was returned from the database.
  16256. func (m *LabelTaggingMutation) ID() (id uint64, exists bool) {
  16257. if m.id == nil {
  16258. return
  16259. }
  16260. return *m.id, true
  16261. }
  16262. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  16263. // That means, if the mutation is applied within a transaction with an isolation level such
  16264. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  16265. // or updated by the mutation.
  16266. func (m *LabelTaggingMutation) IDs(ctx context.Context) ([]uint64, error) {
  16267. switch {
  16268. case m.op.Is(OpUpdateOne | OpDeleteOne):
  16269. id, exists := m.ID()
  16270. if exists {
  16271. return []uint64{id}, nil
  16272. }
  16273. fallthrough
  16274. case m.op.Is(OpUpdate | OpDelete):
  16275. return m.Client().LabelTagging.Query().Where(m.predicates...).IDs(ctx)
  16276. default:
  16277. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  16278. }
  16279. }
  16280. // SetCreatedAt sets the "created_at" field.
  16281. func (m *LabelTaggingMutation) SetCreatedAt(t time.Time) {
  16282. m.created_at = &t
  16283. }
  16284. // CreatedAt returns the value of the "created_at" field in the mutation.
  16285. func (m *LabelTaggingMutation) CreatedAt() (r time.Time, exists bool) {
  16286. v := m.created_at
  16287. if v == nil {
  16288. return
  16289. }
  16290. return *v, true
  16291. }
  16292. // OldCreatedAt returns the old "created_at" field's value of the LabelTagging entity.
  16293. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  16294. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16295. func (m *LabelTaggingMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  16296. if !m.op.Is(OpUpdateOne) {
  16297. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  16298. }
  16299. if m.id == nil || m.oldValue == nil {
  16300. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  16301. }
  16302. oldValue, err := m.oldValue(ctx)
  16303. if err != nil {
  16304. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  16305. }
  16306. return oldValue.CreatedAt, nil
  16307. }
  16308. // ResetCreatedAt resets all changes to the "created_at" field.
  16309. func (m *LabelTaggingMutation) ResetCreatedAt() {
  16310. m.created_at = nil
  16311. }
  16312. // SetUpdatedAt sets the "updated_at" field.
  16313. func (m *LabelTaggingMutation) SetUpdatedAt(t time.Time) {
  16314. m.updated_at = &t
  16315. }
  16316. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  16317. func (m *LabelTaggingMutation) UpdatedAt() (r time.Time, exists bool) {
  16318. v := m.updated_at
  16319. if v == nil {
  16320. return
  16321. }
  16322. return *v, true
  16323. }
  16324. // OldUpdatedAt returns the old "updated_at" field's value of the LabelTagging entity.
  16325. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  16326. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16327. func (m *LabelTaggingMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  16328. if !m.op.Is(OpUpdateOne) {
  16329. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  16330. }
  16331. if m.id == nil || m.oldValue == nil {
  16332. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  16333. }
  16334. oldValue, err := m.oldValue(ctx)
  16335. if err != nil {
  16336. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  16337. }
  16338. return oldValue.UpdatedAt, nil
  16339. }
  16340. // ResetUpdatedAt resets all changes to the "updated_at" field.
  16341. func (m *LabelTaggingMutation) ResetUpdatedAt() {
  16342. m.updated_at = nil
  16343. }
  16344. // SetStatus sets the "status" field.
  16345. func (m *LabelTaggingMutation) SetStatus(u uint8) {
  16346. m.status = &u
  16347. m.addstatus = nil
  16348. }
  16349. // Status returns the value of the "status" field in the mutation.
  16350. func (m *LabelTaggingMutation) Status() (r uint8, exists bool) {
  16351. v := m.status
  16352. if v == nil {
  16353. return
  16354. }
  16355. return *v, true
  16356. }
  16357. // OldStatus returns the old "status" field's value of the LabelTagging entity.
  16358. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  16359. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16360. func (m *LabelTaggingMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  16361. if !m.op.Is(OpUpdateOne) {
  16362. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  16363. }
  16364. if m.id == nil || m.oldValue == nil {
  16365. return v, errors.New("OldStatus requires an ID field in the mutation")
  16366. }
  16367. oldValue, err := m.oldValue(ctx)
  16368. if err != nil {
  16369. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  16370. }
  16371. return oldValue.Status, nil
  16372. }
  16373. // AddStatus adds u to the "status" field.
  16374. func (m *LabelTaggingMutation) AddStatus(u int8) {
  16375. if m.addstatus != nil {
  16376. *m.addstatus += u
  16377. } else {
  16378. m.addstatus = &u
  16379. }
  16380. }
  16381. // AddedStatus returns the value that was added to the "status" field in this mutation.
  16382. func (m *LabelTaggingMutation) AddedStatus() (r int8, exists bool) {
  16383. v := m.addstatus
  16384. if v == nil {
  16385. return
  16386. }
  16387. return *v, true
  16388. }
  16389. // ClearStatus clears the value of the "status" field.
  16390. func (m *LabelTaggingMutation) ClearStatus() {
  16391. m.status = nil
  16392. m.addstatus = nil
  16393. m.clearedFields[labeltagging.FieldStatus] = struct{}{}
  16394. }
  16395. // StatusCleared returns if the "status" field was cleared in this mutation.
  16396. func (m *LabelTaggingMutation) StatusCleared() bool {
  16397. _, ok := m.clearedFields[labeltagging.FieldStatus]
  16398. return ok
  16399. }
  16400. // ResetStatus resets all changes to the "status" field.
  16401. func (m *LabelTaggingMutation) ResetStatus() {
  16402. m.status = nil
  16403. m.addstatus = nil
  16404. delete(m.clearedFields, labeltagging.FieldStatus)
  16405. }
  16406. // SetDeletedAt sets the "deleted_at" field.
  16407. func (m *LabelTaggingMutation) SetDeletedAt(t time.Time) {
  16408. m.deleted_at = &t
  16409. }
  16410. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  16411. func (m *LabelTaggingMutation) DeletedAt() (r time.Time, exists bool) {
  16412. v := m.deleted_at
  16413. if v == nil {
  16414. return
  16415. }
  16416. return *v, true
  16417. }
  16418. // OldDeletedAt returns the old "deleted_at" field's value of the LabelTagging entity.
  16419. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  16420. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16421. func (m *LabelTaggingMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  16422. if !m.op.Is(OpUpdateOne) {
  16423. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  16424. }
  16425. if m.id == nil || m.oldValue == nil {
  16426. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  16427. }
  16428. oldValue, err := m.oldValue(ctx)
  16429. if err != nil {
  16430. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  16431. }
  16432. return oldValue.DeletedAt, nil
  16433. }
  16434. // ClearDeletedAt clears the value of the "deleted_at" field.
  16435. func (m *LabelTaggingMutation) ClearDeletedAt() {
  16436. m.deleted_at = nil
  16437. m.clearedFields[labeltagging.FieldDeletedAt] = struct{}{}
  16438. }
  16439. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  16440. func (m *LabelTaggingMutation) DeletedAtCleared() bool {
  16441. _, ok := m.clearedFields[labeltagging.FieldDeletedAt]
  16442. return ok
  16443. }
  16444. // ResetDeletedAt resets all changes to the "deleted_at" field.
  16445. func (m *LabelTaggingMutation) ResetDeletedAt() {
  16446. m.deleted_at = nil
  16447. delete(m.clearedFields, labeltagging.FieldDeletedAt)
  16448. }
  16449. // SetOrganizationID sets the "organization_id" field.
  16450. func (m *LabelTaggingMutation) SetOrganizationID(u uint64) {
  16451. m.organization_id = &u
  16452. m.addorganization_id = nil
  16453. }
  16454. // OrganizationID returns the value of the "organization_id" field in the mutation.
  16455. func (m *LabelTaggingMutation) OrganizationID() (r uint64, exists bool) {
  16456. v := m.organization_id
  16457. if v == nil {
  16458. return
  16459. }
  16460. return *v, true
  16461. }
  16462. // OldOrganizationID returns the old "organization_id" field's value of the LabelTagging entity.
  16463. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  16464. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16465. func (m *LabelTaggingMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  16466. if !m.op.Is(OpUpdateOne) {
  16467. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  16468. }
  16469. if m.id == nil || m.oldValue == nil {
  16470. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  16471. }
  16472. oldValue, err := m.oldValue(ctx)
  16473. if err != nil {
  16474. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  16475. }
  16476. return oldValue.OrganizationID, nil
  16477. }
  16478. // AddOrganizationID adds u to the "organization_id" field.
  16479. func (m *LabelTaggingMutation) AddOrganizationID(u int64) {
  16480. if m.addorganization_id != nil {
  16481. *m.addorganization_id += u
  16482. } else {
  16483. m.addorganization_id = &u
  16484. }
  16485. }
  16486. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  16487. func (m *LabelTaggingMutation) AddedOrganizationID() (r int64, exists bool) {
  16488. v := m.addorganization_id
  16489. if v == nil {
  16490. return
  16491. }
  16492. return *v, true
  16493. }
  16494. // ResetOrganizationID resets all changes to the "organization_id" field.
  16495. func (m *LabelTaggingMutation) ResetOrganizationID() {
  16496. m.organization_id = nil
  16497. m.addorganization_id = nil
  16498. }
  16499. // SetType sets the "type" field.
  16500. func (m *LabelTaggingMutation) SetType(i int) {
  16501. m._type = &i
  16502. m.add_type = nil
  16503. }
  16504. // GetType returns the value of the "type" field in the mutation.
  16505. func (m *LabelTaggingMutation) GetType() (r int, exists bool) {
  16506. v := m._type
  16507. if v == nil {
  16508. return
  16509. }
  16510. return *v, true
  16511. }
  16512. // OldType returns the old "type" field's value of the LabelTagging entity.
  16513. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  16514. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16515. func (m *LabelTaggingMutation) OldType(ctx context.Context) (v int, err error) {
  16516. if !m.op.Is(OpUpdateOne) {
  16517. return v, errors.New("OldType is only allowed on UpdateOne operations")
  16518. }
  16519. if m.id == nil || m.oldValue == nil {
  16520. return v, errors.New("OldType requires an ID field in the mutation")
  16521. }
  16522. oldValue, err := m.oldValue(ctx)
  16523. if err != nil {
  16524. return v, fmt.Errorf("querying old value for OldType: %w", err)
  16525. }
  16526. return oldValue.Type, nil
  16527. }
  16528. // AddType adds i to the "type" field.
  16529. func (m *LabelTaggingMutation) AddType(i int) {
  16530. if m.add_type != nil {
  16531. *m.add_type += i
  16532. } else {
  16533. m.add_type = &i
  16534. }
  16535. }
  16536. // AddedType returns the value that was added to the "type" field in this mutation.
  16537. func (m *LabelTaggingMutation) AddedType() (r int, exists bool) {
  16538. v := m.add_type
  16539. if v == nil {
  16540. return
  16541. }
  16542. return *v, true
  16543. }
  16544. // ResetType resets all changes to the "type" field.
  16545. func (m *LabelTaggingMutation) ResetType() {
  16546. m._type = nil
  16547. m.add_type = nil
  16548. }
  16549. // SetConditions sets the "conditions" field.
  16550. func (m *LabelTaggingMutation) SetConditions(s string) {
  16551. m.conditions = &s
  16552. }
  16553. // Conditions returns the value of the "conditions" field in the mutation.
  16554. func (m *LabelTaggingMutation) Conditions() (r string, exists bool) {
  16555. v := m.conditions
  16556. if v == nil {
  16557. return
  16558. }
  16559. return *v, true
  16560. }
  16561. // OldConditions returns the old "conditions" field's value of the LabelTagging entity.
  16562. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  16563. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16564. func (m *LabelTaggingMutation) OldConditions(ctx context.Context) (v string, err error) {
  16565. if !m.op.Is(OpUpdateOne) {
  16566. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  16567. }
  16568. if m.id == nil || m.oldValue == nil {
  16569. return v, errors.New("OldConditions requires an ID field in the mutation")
  16570. }
  16571. oldValue, err := m.oldValue(ctx)
  16572. if err != nil {
  16573. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  16574. }
  16575. return oldValue.Conditions, nil
  16576. }
  16577. // ResetConditions resets all changes to the "conditions" field.
  16578. func (m *LabelTaggingMutation) ResetConditions() {
  16579. m.conditions = nil
  16580. }
  16581. // SetActionLabelAdd sets the "action_label_add" field.
  16582. func (m *LabelTaggingMutation) SetActionLabelAdd(u []uint64) {
  16583. m.action_label_add = &u
  16584. m.appendaction_label_add = nil
  16585. }
  16586. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  16587. func (m *LabelTaggingMutation) ActionLabelAdd() (r []uint64, exists bool) {
  16588. v := m.action_label_add
  16589. if v == nil {
  16590. return
  16591. }
  16592. return *v, true
  16593. }
  16594. // OldActionLabelAdd returns the old "action_label_add" field's value of the LabelTagging entity.
  16595. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  16596. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16597. func (m *LabelTaggingMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  16598. if !m.op.Is(OpUpdateOne) {
  16599. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  16600. }
  16601. if m.id == nil || m.oldValue == nil {
  16602. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  16603. }
  16604. oldValue, err := m.oldValue(ctx)
  16605. if err != nil {
  16606. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  16607. }
  16608. return oldValue.ActionLabelAdd, nil
  16609. }
  16610. // AppendActionLabelAdd adds u to the "action_label_add" field.
  16611. func (m *LabelTaggingMutation) AppendActionLabelAdd(u []uint64) {
  16612. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  16613. }
  16614. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  16615. func (m *LabelTaggingMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  16616. if len(m.appendaction_label_add) == 0 {
  16617. return nil, false
  16618. }
  16619. return m.appendaction_label_add, true
  16620. }
  16621. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  16622. func (m *LabelTaggingMutation) ClearActionLabelAdd() {
  16623. m.action_label_add = nil
  16624. m.appendaction_label_add = nil
  16625. m.clearedFields[labeltagging.FieldActionLabelAdd] = struct{}{}
  16626. }
  16627. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  16628. func (m *LabelTaggingMutation) ActionLabelAddCleared() bool {
  16629. _, ok := m.clearedFields[labeltagging.FieldActionLabelAdd]
  16630. return ok
  16631. }
  16632. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  16633. func (m *LabelTaggingMutation) ResetActionLabelAdd() {
  16634. m.action_label_add = nil
  16635. m.appendaction_label_add = nil
  16636. delete(m.clearedFields, labeltagging.FieldActionLabelAdd)
  16637. }
  16638. // SetActionLabelDel sets the "action_label_del" field.
  16639. func (m *LabelTaggingMutation) SetActionLabelDel(u []uint64) {
  16640. m.action_label_del = &u
  16641. m.appendaction_label_del = nil
  16642. }
  16643. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  16644. func (m *LabelTaggingMutation) ActionLabelDel() (r []uint64, exists bool) {
  16645. v := m.action_label_del
  16646. if v == nil {
  16647. return
  16648. }
  16649. return *v, true
  16650. }
  16651. // OldActionLabelDel returns the old "action_label_del" field's value of the LabelTagging entity.
  16652. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  16653. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16654. func (m *LabelTaggingMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  16655. if !m.op.Is(OpUpdateOne) {
  16656. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  16657. }
  16658. if m.id == nil || m.oldValue == nil {
  16659. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  16660. }
  16661. oldValue, err := m.oldValue(ctx)
  16662. if err != nil {
  16663. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  16664. }
  16665. return oldValue.ActionLabelDel, nil
  16666. }
  16667. // AppendActionLabelDel adds u to the "action_label_del" field.
  16668. func (m *LabelTaggingMutation) AppendActionLabelDel(u []uint64) {
  16669. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  16670. }
  16671. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  16672. func (m *LabelTaggingMutation) AppendedActionLabelDel() ([]uint64, bool) {
  16673. if len(m.appendaction_label_del) == 0 {
  16674. return nil, false
  16675. }
  16676. return m.appendaction_label_del, true
  16677. }
  16678. // ClearActionLabelDel clears the value of the "action_label_del" field.
  16679. func (m *LabelTaggingMutation) ClearActionLabelDel() {
  16680. m.action_label_del = nil
  16681. m.appendaction_label_del = nil
  16682. m.clearedFields[labeltagging.FieldActionLabelDel] = struct{}{}
  16683. }
  16684. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  16685. func (m *LabelTaggingMutation) ActionLabelDelCleared() bool {
  16686. _, ok := m.clearedFields[labeltagging.FieldActionLabelDel]
  16687. return ok
  16688. }
  16689. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  16690. func (m *LabelTaggingMutation) ResetActionLabelDel() {
  16691. m.action_label_del = nil
  16692. m.appendaction_label_del = nil
  16693. delete(m.clearedFields, labeltagging.FieldActionLabelDel)
  16694. }
  16695. // Where appends a list predicates to the LabelTaggingMutation builder.
  16696. func (m *LabelTaggingMutation) Where(ps ...predicate.LabelTagging) {
  16697. m.predicates = append(m.predicates, ps...)
  16698. }
  16699. // WhereP appends storage-level predicates to the LabelTaggingMutation builder. Using this method,
  16700. // users can use type-assertion to append predicates that do not depend on any generated package.
  16701. func (m *LabelTaggingMutation) WhereP(ps ...func(*sql.Selector)) {
  16702. p := make([]predicate.LabelTagging, len(ps))
  16703. for i := range ps {
  16704. p[i] = ps[i]
  16705. }
  16706. m.Where(p...)
  16707. }
  16708. // Op returns the operation name.
  16709. func (m *LabelTaggingMutation) Op() Op {
  16710. return m.op
  16711. }
  16712. // SetOp allows setting the mutation operation.
  16713. func (m *LabelTaggingMutation) SetOp(op Op) {
  16714. m.op = op
  16715. }
  16716. // Type returns the node type of this mutation (LabelTagging).
  16717. func (m *LabelTaggingMutation) Type() string {
  16718. return m.typ
  16719. }
  16720. // Fields returns all fields that were changed during this mutation. Note that in
  16721. // order to get all numeric fields that were incremented/decremented, call
  16722. // AddedFields().
  16723. func (m *LabelTaggingMutation) Fields() []string {
  16724. fields := make([]string, 0, 9)
  16725. if m.created_at != nil {
  16726. fields = append(fields, labeltagging.FieldCreatedAt)
  16727. }
  16728. if m.updated_at != nil {
  16729. fields = append(fields, labeltagging.FieldUpdatedAt)
  16730. }
  16731. if m.status != nil {
  16732. fields = append(fields, labeltagging.FieldStatus)
  16733. }
  16734. if m.deleted_at != nil {
  16735. fields = append(fields, labeltagging.FieldDeletedAt)
  16736. }
  16737. if m.organization_id != nil {
  16738. fields = append(fields, labeltagging.FieldOrganizationID)
  16739. }
  16740. if m._type != nil {
  16741. fields = append(fields, labeltagging.FieldType)
  16742. }
  16743. if m.conditions != nil {
  16744. fields = append(fields, labeltagging.FieldConditions)
  16745. }
  16746. if m.action_label_add != nil {
  16747. fields = append(fields, labeltagging.FieldActionLabelAdd)
  16748. }
  16749. if m.action_label_del != nil {
  16750. fields = append(fields, labeltagging.FieldActionLabelDel)
  16751. }
  16752. return fields
  16753. }
  16754. // Field returns the value of a field with the given name. The second boolean
  16755. // return value indicates that this field was not set, or was not defined in the
  16756. // schema.
  16757. func (m *LabelTaggingMutation) Field(name string) (ent.Value, bool) {
  16758. switch name {
  16759. case labeltagging.FieldCreatedAt:
  16760. return m.CreatedAt()
  16761. case labeltagging.FieldUpdatedAt:
  16762. return m.UpdatedAt()
  16763. case labeltagging.FieldStatus:
  16764. return m.Status()
  16765. case labeltagging.FieldDeletedAt:
  16766. return m.DeletedAt()
  16767. case labeltagging.FieldOrganizationID:
  16768. return m.OrganizationID()
  16769. case labeltagging.FieldType:
  16770. return m.GetType()
  16771. case labeltagging.FieldConditions:
  16772. return m.Conditions()
  16773. case labeltagging.FieldActionLabelAdd:
  16774. return m.ActionLabelAdd()
  16775. case labeltagging.FieldActionLabelDel:
  16776. return m.ActionLabelDel()
  16777. }
  16778. return nil, false
  16779. }
  16780. // OldField returns the old value of the field from the database. An error is
  16781. // returned if the mutation operation is not UpdateOne, or the query to the
  16782. // database failed.
  16783. func (m *LabelTaggingMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  16784. switch name {
  16785. case labeltagging.FieldCreatedAt:
  16786. return m.OldCreatedAt(ctx)
  16787. case labeltagging.FieldUpdatedAt:
  16788. return m.OldUpdatedAt(ctx)
  16789. case labeltagging.FieldStatus:
  16790. return m.OldStatus(ctx)
  16791. case labeltagging.FieldDeletedAt:
  16792. return m.OldDeletedAt(ctx)
  16793. case labeltagging.FieldOrganizationID:
  16794. return m.OldOrganizationID(ctx)
  16795. case labeltagging.FieldType:
  16796. return m.OldType(ctx)
  16797. case labeltagging.FieldConditions:
  16798. return m.OldConditions(ctx)
  16799. case labeltagging.FieldActionLabelAdd:
  16800. return m.OldActionLabelAdd(ctx)
  16801. case labeltagging.FieldActionLabelDel:
  16802. return m.OldActionLabelDel(ctx)
  16803. }
  16804. return nil, fmt.Errorf("unknown LabelTagging field %s", name)
  16805. }
  16806. // SetField sets the value of a field with the given name. It returns an error if
  16807. // the field is not defined in the schema, or if the type mismatched the field
  16808. // type.
  16809. func (m *LabelTaggingMutation) SetField(name string, value ent.Value) error {
  16810. switch name {
  16811. case labeltagging.FieldCreatedAt:
  16812. v, ok := value.(time.Time)
  16813. if !ok {
  16814. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16815. }
  16816. m.SetCreatedAt(v)
  16817. return nil
  16818. case labeltagging.FieldUpdatedAt:
  16819. v, ok := value.(time.Time)
  16820. if !ok {
  16821. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16822. }
  16823. m.SetUpdatedAt(v)
  16824. return nil
  16825. case labeltagging.FieldStatus:
  16826. v, ok := value.(uint8)
  16827. if !ok {
  16828. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16829. }
  16830. m.SetStatus(v)
  16831. return nil
  16832. case labeltagging.FieldDeletedAt:
  16833. v, ok := value.(time.Time)
  16834. if !ok {
  16835. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16836. }
  16837. m.SetDeletedAt(v)
  16838. return nil
  16839. case labeltagging.FieldOrganizationID:
  16840. v, ok := value.(uint64)
  16841. if !ok {
  16842. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16843. }
  16844. m.SetOrganizationID(v)
  16845. return nil
  16846. case labeltagging.FieldType:
  16847. v, ok := value.(int)
  16848. if !ok {
  16849. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16850. }
  16851. m.SetType(v)
  16852. return nil
  16853. case labeltagging.FieldConditions:
  16854. v, ok := value.(string)
  16855. if !ok {
  16856. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16857. }
  16858. m.SetConditions(v)
  16859. return nil
  16860. case labeltagging.FieldActionLabelAdd:
  16861. v, ok := value.([]uint64)
  16862. if !ok {
  16863. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16864. }
  16865. m.SetActionLabelAdd(v)
  16866. return nil
  16867. case labeltagging.FieldActionLabelDel:
  16868. v, ok := value.([]uint64)
  16869. if !ok {
  16870. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16871. }
  16872. m.SetActionLabelDel(v)
  16873. return nil
  16874. }
  16875. return fmt.Errorf("unknown LabelTagging field %s", name)
  16876. }
  16877. // AddedFields returns all numeric fields that were incremented/decremented during
  16878. // this mutation.
  16879. func (m *LabelTaggingMutation) AddedFields() []string {
  16880. var fields []string
  16881. if m.addstatus != nil {
  16882. fields = append(fields, labeltagging.FieldStatus)
  16883. }
  16884. if m.addorganization_id != nil {
  16885. fields = append(fields, labeltagging.FieldOrganizationID)
  16886. }
  16887. if m.add_type != nil {
  16888. fields = append(fields, labeltagging.FieldType)
  16889. }
  16890. return fields
  16891. }
  16892. // AddedField returns the numeric value that was incremented/decremented on a field
  16893. // with the given name. The second boolean return value indicates that this field
  16894. // was not set, or was not defined in the schema.
  16895. func (m *LabelTaggingMutation) AddedField(name string) (ent.Value, bool) {
  16896. switch name {
  16897. case labeltagging.FieldStatus:
  16898. return m.AddedStatus()
  16899. case labeltagging.FieldOrganizationID:
  16900. return m.AddedOrganizationID()
  16901. case labeltagging.FieldType:
  16902. return m.AddedType()
  16903. }
  16904. return nil, false
  16905. }
  16906. // AddField adds the value to the field with the given name. It returns an error if
  16907. // the field is not defined in the schema, or if the type mismatched the field
  16908. // type.
  16909. func (m *LabelTaggingMutation) AddField(name string, value ent.Value) error {
  16910. switch name {
  16911. case labeltagging.FieldStatus:
  16912. v, ok := value.(int8)
  16913. if !ok {
  16914. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16915. }
  16916. m.AddStatus(v)
  16917. return nil
  16918. case labeltagging.FieldOrganizationID:
  16919. v, ok := value.(int64)
  16920. if !ok {
  16921. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16922. }
  16923. m.AddOrganizationID(v)
  16924. return nil
  16925. case labeltagging.FieldType:
  16926. v, ok := value.(int)
  16927. if !ok {
  16928. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16929. }
  16930. m.AddType(v)
  16931. return nil
  16932. }
  16933. return fmt.Errorf("unknown LabelTagging numeric field %s", name)
  16934. }
  16935. // ClearedFields returns all nullable fields that were cleared during this
  16936. // mutation.
  16937. func (m *LabelTaggingMutation) ClearedFields() []string {
  16938. var fields []string
  16939. if m.FieldCleared(labeltagging.FieldStatus) {
  16940. fields = append(fields, labeltagging.FieldStatus)
  16941. }
  16942. if m.FieldCleared(labeltagging.FieldDeletedAt) {
  16943. fields = append(fields, labeltagging.FieldDeletedAt)
  16944. }
  16945. if m.FieldCleared(labeltagging.FieldActionLabelAdd) {
  16946. fields = append(fields, labeltagging.FieldActionLabelAdd)
  16947. }
  16948. if m.FieldCleared(labeltagging.FieldActionLabelDel) {
  16949. fields = append(fields, labeltagging.FieldActionLabelDel)
  16950. }
  16951. return fields
  16952. }
  16953. // FieldCleared returns a boolean indicating if a field with the given name was
  16954. // cleared in this mutation.
  16955. func (m *LabelTaggingMutation) FieldCleared(name string) bool {
  16956. _, ok := m.clearedFields[name]
  16957. return ok
  16958. }
  16959. // ClearField clears the value of the field with the given name. It returns an
  16960. // error if the field is not defined in the schema.
  16961. func (m *LabelTaggingMutation) ClearField(name string) error {
  16962. switch name {
  16963. case labeltagging.FieldStatus:
  16964. m.ClearStatus()
  16965. return nil
  16966. case labeltagging.FieldDeletedAt:
  16967. m.ClearDeletedAt()
  16968. return nil
  16969. case labeltagging.FieldActionLabelAdd:
  16970. m.ClearActionLabelAdd()
  16971. return nil
  16972. case labeltagging.FieldActionLabelDel:
  16973. m.ClearActionLabelDel()
  16974. return nil
  16975. }
  16976. return fmt.Errorf("unknown LabelTagging nullable field %s", name)
  16977. }
  16978. // ResetField resets all changes in the mutation for the field with the given name.
  16979. // It returns an error if the field is not defined in the schema.
  16980. func (m *LabelTaggingMutation) ResetField(name string) error {
  16981. switch name {
  16982. case labeltagging.FieldCreatedAt:
  16983. m.ResetCreatedAt()
  16984. return nil
  16985. case labeltagging.FieldUpdatedAt:
  16986. m.ResetUpdatedAt()
  16987. return nil
  16988. case labeltagging.FieldStatus:
  16989. m.ResetStatus()
  16990. return nil
  16991. case labeltagging.FieldDeletedAt:
  16992. m.ResetDeletedAt()
  16993. return nil
  16994. case labeltagging.FieldOrganizationID:
  16995. m.ResetOrganizationID()
  16996. return nil
  16997. case labeltagging.FieldType:
  16998. m.ResetType()
  16999. return nil
  17000. case labeltagging.FieldConditions:
  17001. m.ResetConditions()
  17002. return nil
  17003. case labeltagging.FieldActionLabelAdd:
  17004. m.ResetActionLabelAdd()
  17005. return nil
  17006. case labeltagging.FieldActionLabelDel:
  17007. m.ResetActionLabelDel()
  17008. return nil
  17009. }
  17010. return fmt.Errorf("unknown LabelTagging field %s", name)
  17011. }
  17012. // AddedEdges returns all edge names that were set/added in this mutation.
  17013. func (m *LabelTaggingMutation) AddedEdges() []string {
  17014. edges := make([]string, 0, 0)
  17015. return edges
  17016. }
  17017. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  17018. // name in this mutation.
  17019. func (m *LabelTaggingMutation) AddedIDs(name string) []ent.Value {
  17020. return nil
  17021. }
  17022. // RemovedEdges returns all edge names that were removed in this mutation.
  17023. func (m *LabelTaggingMutation) RemovedEdges() []string {
  17024. edges := make([]string, 0, 0)
  17025. return edges
  17026. }
  17027. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  17028. // the given name in this mutation.
  17029. func (m *LabelTaggingMutation) RemovedIDs(name string) []ent.Value {
  17030. return nil
  17031. }
  17032. // ClearedEdges returns all edge names that were cleared in this mutation.
  17033. func (m *LabelTaggingMutation) ClearedEdges() []string {
  17034. edges := make([]string, 0, 0)
  17035. return edges
  17036. }
  17037. // EdgeCleared returns a boolean which indicates if the edge with the given name
  17038. // was cleared in this mutation.
  17039. func (m *LabelTaggingMutation) EdgeCleared(name string) bool {
  17040. return false
  17041. }
  17042. // ClearEdge clears the value of the edge with the given name. It returns an error
  17043. // if that edge is not defined in the schema.
  17044. func (m *LabelTaggingMutation) ClearEdge(name string) error {
  17045. return fmt.Errorf("unknown LabelTagging unique edge %s", name)
  17046. }
  17047. // ResetEdge resets all changes to the edge with the given name in this mutation.
  17048. // It returns an error if the edge is not defined in the schema.
  17049. func (m *LabelTaggingMutation) ResetEdge(name string) error {
  17050. return fmt.Errorf("unknown LabelTagging edge %s", name)
  17051. }
  17052. // MessageMutation represents an operation that mutates the Message nodes in the graph.
  17053. type MessageMutation struct {
  17054. config
  17055. op Op
  17056. typ string
  17057. id *int
  17058. wx_wxid *string
  17059. wxid *string
  17060. content *string
  17061. clearedFields map[string]struct{}
  17062. done bool
  17063. oldValue func(context.Context) (*Message, error)
  17064. predicates []predicate.Message
  17065. }
  17066. var _ ent.Mutation = (*MessageMutation)(nil)
  17067. // messageOption allows management of the mutation configuration using functional options.
  17068. type messageOption func(*MessageMutation)
  17069. // newMessageMutation creates new mutation for the Message entity.
  17070. func newMessageMutation(c config, op Op, opts ...messageOption) *MessageMutation {
  17071. m := &MessageMutation{
  17072. config: c,
  17073. op: op,
  17074. typ: TypeMessage,
  17075. clearedFields: make(map[string]struct{}),
  17076. }
  17077. for _, opt := range opts {
  17078. opt(m)
  17079. }
  17080. return m
  17081. }
  17082. // withMessageID sets the ID field of the mutation.
  17083. func withMessageID(id int) messageOption {
  17084. return func(m *MessageMutation) {
  17085. var (
  17086. err error
  17087. once sync.Once
  17088. value *Message
  17089. )
  17090. m.oldValue = func(ctx context.Context) (*Message, error) {
  17091. once.Do(func() {
  17092. if m.done {
  17093. err = errors.New("querying old values post mutation is not allowed")
  17094. } else {
  17095. value, err = m.Client().Message.Get(ctx, id)
  17096. }
  17097. })
  17098. return value, err
  17099. }
  17100. m.id = &id
  17101. }
  17102. }
  17103. // withMessage sets the old Message of the mutation.
  17104. func withMessage(node *Message) messageOption {
  17105. return func(m *MessageMutation) {
  17106. m.oldValue = func(context.Context) (*Message, error) {
  17107. return node, nil
  17108. }
  17109. m.id = &node.ID
  17110. }
  17111. }
  17112. // Client returns a new `ent.Client` from the mutation. If the mutation was
  17113. // executed in a transaction (ent.Tx), a transactional client is returned.
  17114. func (m MessageMutation) Client() *Client {
  17115. client := &Client{config: m.config}
  17116. client.init()
  17117. return client
  17118. }
  17119. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  17120. // it returns an error otherwise.
  17121. func (m MessageMutation) Tx() (*Tx, error) {
  17122. if _, ok := m.driver.(*txDriver); !ok {
  17123. return nil, errors.New("ent: mutation is not running in a transaction")
  17124. }
  17125. tx := &Tx{config: m.config}
  17126. tx.init()
  17127. return tx, nil
  17128. }
  17129. // ID returns the ID value in the mutation. Note that the ID is only available
  17130. // if it was provided to the builder or after it was returned from the database.
  17131. func (m *MessageMutation) ID() (id int, exists bool) {
  17132. if m.id == nil {
  17133. return
  17134. }
  17135. return *m.id, true
  17136. }
  17137. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  17138. // That means, if the mutation is applied within a transaction with an isolation level such
  17139. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  17140. // or updated by the mutation.
  17141. func (m *MessageMutation) IDs(ctx context.Context) ([]int, error) {
  17142. switch {
  17143. case m.op.Is(OpUpdateOne | OpDeleteOne):
  17144. id, exists := m.ID()
  17145. if exists {
  17146. return []int{id}, nil
  17147. }
  17148. fallthrough
  17149. case m.op.Is(OpUpdate | OpDelete):
  17150. return m.Client().Message.Query().Where(m.predicates...).IDs(ctx)
  17151. default:
  17152. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  17153. }
  17154. }
  17155. // SetWxWxid sets the "wx_wxid" field.
  17156. func (m *MessageMutation) SetWxWxid(s string) {
  17157. m.wx_wxid = &s
  17158. }
  17159. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  17160. func (m *MessageMutation) WxWxid() (r string, exists bool) {
  17161. v := m.wx_wxid
  17162. if v == nil {
  17163. return
  17164. }
  17165. return *v, true
  17166. }
  17167. // OldWxWxid returns the old "wx_wxid" field's value of the Message entity.
  17168. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  17169. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17170. func (m *MessageMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  17171. if !m.op.Is(OpUpdateOne) {
  17172. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  17173. }
  17174. if m.id == nil || m.oldValue == nil {
  17175. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  17176. }
  17177. oldValue, err := m.oldValue(ctx)
  17178. if err != nil {
  17179. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  17180. }
  17181. return oldValue.WxWxid, nil
  17182. }
  17183. // ClearWxWxid clears the value of the "wx_wxid" field.
  17184. func (m *MessageMutation) ClearWxWxid() {
  17185. m.wx_wxid = nil
  17186. m.clearedFields[message.FieldWxWxid] = struct{}{}
  17187. }
  17188. // WxWxidCleared returns if the "wx_wxid" field was cleared in this mutation.
  17189. func (m *MessageMutation) WxWxidCleared() bool {
  17190. _, ok := m.clearedFields[message.FieldWxWxid]
  17191. return ok
  17192. }
  17193. // ResetWxWxid resets all changes to the "wx_wxid" field.
  17194. func (m *MessageMutation) ResetWxWxid() {
  17195. m.wx_wxid = nil
  17196. delete(m.clearedFields, message.FieldWxWxid)
  17197. }
  17198. // SetWxid sets the "wxid" field.
  17199. func (m *MessageMutation) SetWxid(s string) {
  17200. m.wxid = &s
  17201. }
  17202. // Wxid returns the value of the "wxid" field in the mutation.
  17203. func (m *MessageMutation) Wxid() (r string, exists bool) {
  17204. v := m.wxid
  17205. if v == nil {
  17206. return
  17207. }
  17208. return *v, true
  17209. }
  17210. // OldWxid returns the old "wxid" field's value of the Message entity.
  17211. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  17212. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17213. func (m *MessageMutation) OldWxid(ctx context.Context) (v string, err error) {
  17214. if !m.op.Is(OpUpdateOne) {
  17215. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  17216. }
  17217. if m.id == nil || m.oldValue == nil {
  17218. return v, errors.New("OldWxid requires an ID field in the mutation")
  17219. }
  17220. oldValue, err := m.oldValue(ctx)
  17221. if err != nil {
  17222. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  17223. }
  17224. return oldValue.Wxid, nil
  17225. }
  17226. // ResetWxid resets all changes to the "wxid" field.
  17227. func (m *MessageMutation) ResetWxid() {
  17228. m.wxid = nil
  17229. }
  17230. // SetContent sets the "content" field.
  17231. func (m *MessageMutation) SetContent(s string) {
  17232. m.content = &s
  17233. }
  17234. // Content returns the value of the "content" field in the mutation.
  17235. func (m *MessageMutation) Content() (r string, exists bool) {
  17236. v := m.content
  17237. if v == nil {
  17238. return
  17239. }
  17240. return *v, true
  17241. }
  17242. // OldContent returns the old "content" field's value of the Message entity.
  17243. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  17244. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17245. func (m *MessageMutation) OldContent(ctx context.Context) (v string, err error) {
  17246. if !m.op.Is(OpUpdateOne) {
  17247. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  17248. }
  17249. if m.id == nil || m.oldValue == nil {
  17250. return v, errors.New("OldContent requires an ID field in the mutation")
  17251. }
  17252. oldValue, err := m.oldValue(ctx)
  17253. if err != nil {
  17254. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  17255. }
  17256. return oldValue.Content, nil
  17257. }
  17258. // ResetContent resets all changes to the "content" field.
  17259. func (m *MessageMutation) ResetContent() {
  17260. m.content = nil
  17261. }
  17262. // Where appends a list predicates to the MessageMutation builder.
  17263. func (m *MessageMutation) Where(ps ...predicate.Message) {
  17264. m.predicates = append(m.predicates, ps...)
  17265. }
  17266. // WhereP appends storage-level predicates to the MessageMutation builder. Using this method,
  17267. // users can use type-assertion to append predicates that do not depend on any generated package.
  17268. func (m *MessageMutation) WhereP(ps ...func(*sql.Selector)) {
  17269. p := make([]predicate.Message, len(ps))
  17270. for i := range ps {
  17271. p[i] = ps[i]
  17272. }
  17273. m.Where(p...)
  17274. }
  17275. // Op returns the operation name.
  17276. func (m *MessageMutation) Op() Op {
  17277. return m.op
  17278. }
  17279. // SetOp allows setting the mutation operation.
  17280. func (m *MessageMutation) SetOp(op Op) {
  17281. m.op = op
  17282. }
  17283. // Type returns the node type of this mutation (Message).
  17284. func (m *MessageMutation) Type() string {
  17285. return m.typ
  17286. }
  17287. // Fields returns all fields that were changed during this mutation. Note that in
  17288. // order to get all numeric fields that were incremented/decremented, call
  17289. // AddedFields().
  17290. func (m *MessageMutation) Fields() []string {
  17291. fields := make([]string, 0, 3)
  17292. if m.wx_wxid != nil {
  17293. fields = append(fields, message.FieldWxWxid)
  17294. }
  17295. if m.wxid != nil {
  17296. fields = append(fields, message.FieldWxid)
  17297. }
  17298. if m.content != nil {
  17299. fields = append(fields, message.FieldContent)
  17300. }
  17301. return fields
  17302. }
  17303. // Field returns the value of a field with the given name. The second boolean
  17304. // return value indicates that this field was not set, or was not defined in the
  17305. // schema.
  17306. func (m *MessageMutation) Field(name string) (ent.Value, bool) {
  17307. switch name {
  17308. case message.FieldWxWxid:
  17309. return m.WxWxid()
  17310. case message.FieldWxid:
  17311. return m.Wxid()
  17312. case message.FieldContent:
  17313. return m.Content()
  17314. }
  17315. return nil, false
  17316. }
  17317. // OldField returns the old value of the field from the database. An error is
  17318. // returned if the mutation operation is not UpdateOne, or the query to the
  17319. // database failed.
  17320. func (m *MessageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  17321. switch name {
  17322. case message.FieldWxWxid:
  17323. return m.OldWxWxid(ctx)
  17324. case message.FieldWxid:
  17325. return m.OldWxid(ctx)
  17326. case message.FieldContent:
  17327. return m.OldContent(ctx)
  17328. }
  17329. return nil, fmt.Errorf("unknown Message field %s", name)
  17330. }
  17331. // SetField sets the value of a field with the given name. It returns an error if
  17332. // the field is not defined in the schema, or if the type mismatched the field
  17333. // type.
  17334. func (m *MessageMutation) SetField(name string, value ent.Value) error {
  17335. switch name {
  17336. case message.FieldWxWxid:
  17337. v, ok := value.(string)
  17338. if !ok {
  17339. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17340. }
  17341. m.SetWxWxid(v)
  17342. return nil
  17343. case message.FieldWxid:
  17344. v, ok := value.(string)
  17345. if !ok {
  17346. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17347. }
  17348. m.SetWxid(v)
  17349. return nil
  17350. case message.FieldContent:
  17351. v, ok := value.(string)
  17352. if !ok {
  17353. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17354. }
  17355. m.SetContent(v)
  17356. return nil
  17357. }
  17358. return fmt.Errorf("unknown Message field %s", name)
  17359. }
  17360. // AddedFields returns all numeric fields that were incremented/decremented during
  17361. // this mutation.
  17362. func (m *MessageMutation) AddedFields() []string {
  17363. return nil
  17364. }
  17365. // AddedField returns the numeric value that was incremented/decremented on a field
  17366. // with the given name. The second boolean return value indicates that this field
  17367. // was not set, or was not defined in the schema.
  17368. func (m *MessageMutation) AddedField(name string) (ent.Value, bool) {
  17369. return nil, false
  17370. }
  17371. // AddField adds the value to the field with the given name. It returns an error if
  17372. // the field is not defined in the schema, or if the type mismatched the field
  17373. // type.
  17374. func (m *MessageMutation) AddField(name string, value ent.Value) error {
  17375. switch name {
  17376. }
  17377. return fmt.Errorf("unknown Message numeric field %s", name)
  17378. }
  17379. // ClearedFields returns all nullable fields that were cleared during this
  17380. // mutation.
  17381. func (m *MessageMutation) ClearedFields() []string {
  17382. var fields []string
  17383. if m.FieldCleared(message.FieldWxWxid) {
  17384. fields = append(fields, message.FieldWxWxid)
  17385. }
  17386. return fields
  17387. }
  17388. // FieldCleared returns a boolean indicating if a field with the given name was
  17389. // cleared in this mutation.
  17390. func (m *MessageMutation) FieldCleared(name string) bool {
  17391. _, ok := m.clearedFields[name]
  17392. return ok
  17393. }
  17394. // ClearField clears the value of the field with the given name. It returns an
  17395. // error if the field is not defined in the schema.
  17396. func (m *MessageMutation) ClearField(name string) error {
  17397. switch name {
  17398. case message.FieldWxWxid:
  17399. m.ClearWxWxid()
  17400. return nil
  17401. }
  17402. return fmt.Errorf("unknown Message nullable field %s", name)
  17403. }
  17404. // ResetField resets all changes in the mutation for the field with the given name.
  17405. // It returns an error if the field is not defined in the schema.
  17406. func (m *MessageMutation) ResetField(name string) error {
  17407. switch name {
  17408. case message.FieldWxWxid:
  17409. m.ResetWxWxid()
  17410. return nil
  17411. case message.FieldWxid:
  17412. m.ResetWxid()
  17413. return nil
  17414. case message.FieldContent:
  17415. m.ResetContent()
  17416. return nil
  17417. }
  17418. return fmt.Errorf("unknown Message field %s", name)
  17419. }
  17420. // AddedEdges returns all edge names that were set/added in this mutation.
  17421. func (m *MessageMutation) AddedEdges() []string {
  17422. edges := make([]string, 0, 0)
  17423. return edges
  17424. }
  17425. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  17426. // name in this mutation.
  17427. func (m *MessageMutation) AddedIDs(name string) []ent.Value {
  17428. return nil
  17429. }
  17430. // RemovedEdges returns all edge names that were removed in this mutation.
  17431. func (m *MessageMutation) RemovedEdges() []string {
  17432. edges := make([]string, 0, 0)
  17433. return edges
  17434. }
  17435. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  17436. // the given name in this mutation.
  17437. func (m *MessageMutation) RemovedIDs(name string) []ent.Value {
  17438. return nil
  17439. }
  17440. // ClearedEdges returns all edge names that were cleared in this mutation.
  17441. func (m *MessageMutation) ClearedEdges() []string {
  17442. edges := make([]string, 0, 0)
  17443. return edges
  17444. }
  17445. // EdgeCleared returns a boolean which indicates if the edge with the given name
  17446. // was cleared in this mutation.
  17447. func (m *MessageMutation) EdgeCleared(name string) bool {
  17448. return false
  17449. }
  17450. // ClearEdge clears the value of the edge with the given name. It returns an error
  17451. // if that edge is not defined in the schema.
  17452. func (m *MessageMutation) ClearEdge(name string) error {
  17453. return fmt.Errorf("unknown Message unique edge %s", name)
  17454. }
  17455. // ResetEdge resets all changes to the edge with the given name in this mutation.
  17456. // It returns an error if the edge is not defined in the schema.
  17457. func (m *MessageMutation) ResetEdge(name string) error {
  17458. return fmt.Errorf("unknown Message edge %s", name)
  17459. }
  17460. // MessageRecordsMutation represents an operation that mutates the MessageRecords nodes in the graph.
  17461. type MessageRecordsMutation struct {
  17462. config
  17463. op Op
  17464. typ string
  17465. id *uint64
  17466. created_at *time.Time
  17467. updated_at *time.Time
  17468. status *uint8
  17469. addstatus *int8
  17470. bot_wxid *string
  17471. contact_type *int
  17472. addcontact_type *int
  17473. contact_wxid *string
  17474. content_type *int
  17475. addcontent_type *int
  17476. content *string
  17477. meta *custom_types.Meta
  17478. error_detail *string
  17479. send_time *time.Time
  17480. source_type *int
  17481. addsource_type *int
  17482. organization_id *uint64
  17483. addorganization_id *int64
  17484. clearedFields map[string]struct{}
  17485. sop_stage *uint64
  17486. clearedsop_stage bool
  17487. sop_node *uint64
  17488. clearedsop_node bool
  17489. message_contact *uint64
  17490. clearedmessage_contact bool
  17491. done bool
  17492. oldValue func(context.Context) (*MessageRecords, error)
  17493. predicates []predicate.MessageRecords
  17494. }
  17495. var _ ent.Mutation = (*MessageRecordsMutation)(nil)
  17496. // messagerecordsOption allows management of the mutation configuration using functional options.
  17497. type messagerecordsOption func(*MessageRecordsMutation)
  17498. // newMessageRecordsMutation creates new mutation for the MessageRecords entity.
  17499. func newMessageRecordsMutation(c config, op Op, opts ...messagerecordsOption) *MessageRecordsMutation {
  17500. m := &MessageRecordsMutation{
  17501. config: c,
  17502. op: op,
  17503. typ: TypeMessageRecords,
  17504. clearedFields: make(map[string]struct{}),
  17505. }
  17506. for _, opt := range opts {
  17507. opt(m)
  17508. }
  17509. return m
  17510. }
  17511. // withMessageRecordsID sets the ID field of the mutation.
  17512. func withMessageRecordsID(id uint64) messagerecordsOption {
  17513. return func(m *MessageRecordsMutation) {
  17514. var (
  17515. err error
  17516. once sync.Once
  17517. value *MessageRecords
  17518. )
  17519. m.oldValue = func(ctx context.Context) (*MessageRecords, error) {
  17520. once.Do(func() {
  17521. if m.done {
  17522. err = errors.New("querying old values post mutation is not allowed")
  17523. } else {
  17524. value, err = m.Client().MessageRecords.Get(ctx, id)
  17525. }
  17526. })
  17527. return value, err
  17528. }
  17529. m.id = &id
  17530. }
  17531. }
  17532. // withMessageRecords sets the old MessageRecords of the mutation.
  17533. func withMessageRecords(node *MessageRecords) messagerecordsOption {
  17534. return func(m *MessageRecordsMutation) {
  17535. m.oldValue = func(context.Context) (*MessageRecords, error) {
  17536. return node, nil
  17537. }
  17538. m.id = &node.ID
  17539. }
  17540. }
  17541. // Client returns a new `ent.Client` from the mutation. If the mutation was
  17542. // executed in a transaction (ent.Tx), a transactional client is returned.
  17543. func (m MessageRecordsMutation) Client() *Client {
  17544. client := &Client{config: m.config}
  17545. client.init()
  17546. return client
  17547. }
  17548. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  17549. // it returns an error otherwise.
  17550. func (m MessageRecordsMutation) Tx() (*Tx, error) {
  17551. if _, ok := m.driver.(*txDriver); !ok {
  17552. return nil, errors.New("ent: mutation is not running in a transaction")
  17553. }
  17554. tx := &Tx{config: m.config}
  17555. tx.init()
  17556. return tx, nil
  17557. }
  17558. // SetID sets the value of the id field. Note that this
  17559. // operation is only accepted on creation of MessageRecords entities.
  17560. func (m *MessageRecordsMutation) SetID(id uint64) {
  17561. m.id = &id
  17562. }
  17563. // ID returns the ID value in the mutation. Note that the ID is only available
  17564. // if it was provided to the builder or after it was returned from the database.
  17565. func (m *MessageRecordsMutation) ID() (id uint64, exists bool) {
  17566. if m.id == nil {
  17567. return
  17568. }
  17569. return *m.id, true
  17570. }
  17571. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  17572. // That means, if the mutation is applied within a transaction with an isolation level such
  17573. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  17574. // or updated by the mutation.
  17575. func (m *MessageRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  17576. switch {
  17577. case m.op.Is(OpUpdateOne | OpDeleteOne):
  17578. id, exists := m.ID()
  17579. if exists {
  17580. return []uint64{id}, nil
  17581. }
  17582. fallthrough
  17583. case m.op.Is(OpUpdate | OpDelete):
  17584. return m.Client().MessageRecords.Query().Where(m.predicates...).IDs(ctx)
  17585. default:
  17586. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  17587. }
  17588. }
  17589. // SetCreatedAt sets the "created_at" field.
  17590. func (m *MessageRecordsMutation) SetCreatedAt(t time.Time) {
  17591. m.created_at = &t
  17592. }
  17593. // CreatedAt returns the value of the "created_at" field in the mutation.
  17594. func (m *MessageRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  17595. v := m.created_at
  17596. if v == nil {
  17597. return
  17598. }
  17599. return *v, true
  17600. }
  17601. // OldCreatedAt returns the old "created_at" field's value of the MessageRecords entity.
  17602. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17603. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17604. func (m *MessageRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  17605. if !m.op.Is(OpUpdateOne) {
  17606. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  17607. }
  17608. if m.id == nil || m.oldValue == nil {
  17609. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  17610. }
  17611. oldValue, err := m.oldValue(ctx)
  17612. if err != nil {
  17613. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  17614. }
  17615. return oldValue.CreatedAt, nil
  17616. }
  17617. // ResetCreatedAt resets all changes to the "created_at" field.
  17618. func (m *MessageRecordsMutation) ResetCreatedAt() {
  17619. m.created_at = nil
  17620. }
  17621. // SetUpdatedAt sets the "updated_at" field.
  17622. func (m *MessageRecordsMutation) SetUpdatedAt(t time.Time) {
  17623. m.updated_at = &t
  17624. }
  17625. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  17626. func (m *MessageRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  17627. v := m.updated_at
  17628. if v == nil {
  17629. return
  17630. }
  17631. return *v, true
  17632. }
  17633. // OldUpdatedAt returns the old "updated_at" field's value of the MessageRecords entity.
  17634. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17635. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17636. func (m *MessageRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  17637. if !m.op.Is(OpUpdateOne) {
  17638. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  17639. }
  17640. if m.id == nil || m.oldValue == nil {
  17641. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  17642. }
  17643. oldValue, err := m.oldValue(ctx)
  17644. if err != nil {
  17645. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  17646. }
  17647. return oldValue.UpdatedAt, nil
  17648. }
  17649. // ResetUpdatedAt resets all changes to the "updated_at" field.
  17650. func (m *MessageRecordsMutation) ResetUpdatedAt() {
  17651. m.updated_at = nil
  17652. }
  17653. // SetStatus sets the "status" field.
  17654. func (m *MessageRecordsMutation) SetStatus(u uint8) {
  17655. m.status = &u
  17656. m.addstatus = nil
  17657. }
  17658. // Status returns the value of the "status" field in the mutation.
  17659. func (m *MessageRecordsMutation) Status() (r uint8, exists bool) {
  17660. v := m.status
  17661. if v == nil {
  17662. return
  17663. }
  17664. return *v, true
  17665. }
  17666. // OldStatus returns the old "status" field's value of the MessageRecords entity.
  17667. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17668. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17669. func (m *MessageRecordsMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  17670. if !m.op.Is(OpUpdateOne) {
  17671. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  17672. }
  17673. if m.id == nil || m.oldValue == nil {
  17674. return v, errors.New("OldStatus requires an ID field in the mutation")
  17675. }
  17676. oldValue, err := m.oldValue(ctx)
  17677. if err != nil {
  17678. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  17679. }
  17680. return oldValue.Status, nil
  17681. }
  17682. // AddStatus adds u to the "status" field.
  17683. func (m *MessageRecordsMutation) AddStatus(u int8) {
  17684. if m.addstatus != nil {
  17685. *m.addstatus += u
  17686. } else {
  17687. m.addstatus = &u
  17688. }
  17689. }
  17690. // AddedStatus returns the value that was added to the "status" field in this mutation.
  17691. func (m *MessageRecordsMutation) AddedStatus() (r int8, exists bool) {
  17692. v := m.addstatus
  17693. if v == nil {
  17694. return
  17695. }
  17696. return *v, true
  17697. }
  17698. // ClearStatus clears the value of the "status" field.
  17699. func (m *MessageRecordsMutation) ClearStatus() {
  17700. m.status = nil
  17701. m.addstatus = nil
  17702. m.clearedFields[messagerecords.FieldStatus] = struct{}{}
  17703. }
  17704. // StatusCleared returns if the "status" field was cleared in this mutation.
  17705. func (m *MessageRecordsMutation) StatusCleared() bool {
  17706. _, ok := m.clearedFields[messagerecords.FieldStatus]
  17707. return ok
  17708. }
  17709. // ResetStatus resets all changes to the "status" field.
  17710. func (m *MessageRecordsMutation) ResetStatus() {
  17711. m.status = nil
  17712. m.addstatus = nil
  17713. delete(m.clearedFields, messagerecords.FieldStatus)
  17714. }
  17715. // SetBotWxid sets the "bot_wxid" field.
  17716. func (m *MessageRecordsMutation) SetBotWxid(s string) {
  17717. m.bot_wxid = &s
  17718. }
  17719. // BotWxid returns the value of the "bot_wxid" field in the mutation.
  17720. func (m *MessageRecordsMutation) BotWxid() (r string, exists bool) {
  17721. v := m.bot_wxid
  17722. if v == nil {
  17723. return
  17724. }
  17725. return *v, true
  17726. }
  17727. // OldBotWxid returns the old "bot_wxid" field's value of the MessageRecords entity.
  17728. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17729. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17730. func (m *MessageRecordsMutation) OldBotWxid(ctx context.Context) (v string, err error) {
  17731. if !m.op.Is(OpUpdateOne) {
  17732. return v, errors.New("OldBotWxid is only allowed on UpdateOne operations")
  17733. }
  17734. if m.id == nil || m.oldValue == nil {
  17735. return v, errors.New("OldBotWxid requires an ID field in the mutation")
  17736. }
  17737. oldValue, err := m.oldValue(ctx)
  17738. if err != nil {
  17739. return v, fmt.Errorf("querying old value for OldBotWxid: %w", err)
  17740. }
  17741. return oldValue.BotWxid, nil
  17742. }
  17743. // ResetBotWxid resets all changes to the "bot_wxid" field.
  17744. func (m *MessageRecordsMutation) ResetBotWxid() {
  17745. m.bot_wxid = nil
  17746. }
  17747. // SetContactID sets the "contact_id" field.
  17748. func (m *MessageRecordsMutation) SetContactID(u uint64) {
  17749. m.message_contact = &u
  17750. }
  17751. // ContactID returns the value of the "contact_id" field in the mutation.
  17752. func (m *MessageRecordsMutation) ContactID() (r uint64, exists bool) {
  17753. v := m.message_contact
  17754. if v == nil {
  17755. return
  17756. }
  17757. return *v, true
  17758. }
  17759. // OldContactID returns the old "contact_id" field's value of the MessageRecords entity.
  17760. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17761. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17762. func (m *MessageRecordsMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  17763. if !m.op.Is(OpUpdateOne) {
  17764. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  17765. }
  17766. if m.id == nil || m.oldValue == nil {
  17767. return v, errors.New("OldContactID requires an ID field in the mutation")
  17768. }
  17769. oldValue, err := m.oldValue(ctx)
  17770. if err != nil {
  17771. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  17772. }
  17773. return oldValue.ContactID, nil
  17774. }
  17775. // ClearContactID clears the value of the "contact_id" field.
  17776. func (m *MessageRecordsMutation) ClearContactID() {
  17777. m.message_contact = nil
  17778. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  17779. }
  17780. // ContactIDCleared returns if the "contact_id" field was cleared in this mutation.
  17781. func (m *MessageRecordsMutation) ContactIDCleared() bool {
  17782. _, ok := m.clearedFields[messagerecords.FieldContactID]
  17783. return ok
  17784. }
  17785. // ResetContactID resets all changes to the "contact_id" field.
  17786. func (m *MessageRecordsMutation) ResetContactID() {
  17787. m.message_contact = nil
  17788. delete(m.clearedFields, messagerecords.FieldContactID)
  17789. }
  17790. // SetContactType sets the "contact_type" field.
  17791. func (m *MessageRecordsMutation) SetContactType(i int) {
  17792. m.contact_type = &i
  17793. m.addcontact_type = nil
  17794. }
  17795. // ContactType returns the value of the "contact_type" field in the mutation.
  17796. func (m *MessageRecordsMutation) ContactType() (r int, exists bool) {
  17797. v := m.contact_type
  17798. if v == nil {
  17799. return
  17800. }
  17801. return *v, true
  17802. }
  17803. // OldContactType returns the old "contact_type" field's value of the MessageRecords entity.
  17804. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17805. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17806. func (m *MessageRecordsMutation) OldContactType(ctx context.Context) (v int, err error) {
  17807. if !m.op.Is(OpUpdateOne) {
  17808. return v, errors.New("OldContactType is only allowed on UpdateOne operations")
  17809. }
  17810. if m.id == nil || m.oldValue == nil {
  17811. return v, errors.New("OldContactType requires an ID field in the mutation")
  17812. }
  17813. oldValue, err := m.oldValue(ctx)
  17814. if err != nil {
  17815. return v, fmt.Errorf("querying old value for OldContactType: %w", err)
  17816. }
  17817. return oldValue.ContactType, nil
  17818. }
  17819. // AddContactType adds i to the "contact_type" field.
  17820. func (m *MessageRecordsMutation) AddContactType(i int) {
  17821. if m.addcontact_type != nil {
  17822. *m.addcontact_type += i
  17823. } else {
  17824. m.addcontact_type = &i
  17825. }
  17826. }
  17827. // AddedContactType returns the value that was added to the "contact_type" field in this mutation.
  17828. func (m *MessageRecordsMutation) AddedContactType() (r int, exists bool) {
  17829. v := m.addcontact_type
  17830. if v == nil {
  17831. return
  17832. }
  17833. return *v, true
  17834. }
  17835. // ResetContactType resets all changes to the "contact_type" field.
  17836. func (m *MessageRecordsMutation) ResetContactType() {
  17837. m.contact_type = nil
  17838. m.addcontact_type = nil
  17839. }
  17840. // SetContactWxid sets the "contact_wxid" field.
  17841. func (m *MessageRecordsMutation) SetContactWxid(s string) {
  17842. m.contact_wxid = &s
  17843. }
  17844. // ContactWxid returns the value of the "contact_wxid" field in the mutation.
  17845. func (m *MessageRecordsMutation) ContactWxid() (r string, exists bool) {
  17846. v := m.contact_wxid
  17847. if v == nil {
  17848. return
  17849. }
  17850. return *v, true
  17851. }
  17852. // OldContactWxid returns the old "contact_wxid" field's value of the MessageRecords entity.
  17853. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17854. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17855. func (m *MessageRecordsMutation) OldContactWxid(ctx context.Context) (v string, err error) {
  17856. if !m.op.Is(OpUpdateOne) {
  17857. return v, errors.New("OldContactWxid is only allowed on UpdateOne operations")
  17858. }
  17859. if m.id == nil || m.oldValue == nil {
  17860. return v, errors.New("OldContactWxid requires an ID field in the mutation")
  17861. }
  17862. oldValue, err := m.oldValue(ctx)
  17863. if err != nil {
  17864. return v, fmt.Errorf("querying old value for OldContactWxid: %w", err)
  17865. }
  17866. return oldValue.ContactWxid, nil
  17867. }
  17868. // ResetContactWxid resets all changes to the "contact_wxid" field.
  17869. func (m *MessageRecordsMutation) ResetContactWxid() {
  17870. m.contact_wxid = nil
  17871. }
  17872. // SetContentType sets the "content_type" field.
  17873. func (m *MessageRecordsMutation) SetContentType(i int) {
  17874. m.content_type = &i
  17875. m.addcontent_type = nil
  17876. }
  17877. // ContentType returns the value of the "content_type" field in the mutation.
  17878. func (m *MessageRecordsMutation) ContentType() (r int, exists bool) {
  17879. v := m.content_type
  17880. if v == nil {
  17881. return
  17882. }
  17883. return *v, true
  17884. }
  17885. // OldContentType returns the old "content_type" field's value of the MessageRecords entity.
  17886. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17887. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17888. func (m *MessageRecordsMutation) OldContentType(ctx context.Context) (v int, err error) {
  17889. if !m.op.Is(OpUpdateOne) {
  17890. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  17891. }
  17892. if m.id == nil || m.oldValue == nil {
  17893. return v, errors.New("OldContentType requires an ID field in the mutation")
  17894. }
  17895. oldValue, err := m.oldValue(ctx)
  17896. if err != nil {
  17897. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  17898. }
  17899. return oldValue.ContentType, nil
  17900. }
  17901. // AddContentType adds i to the "content_type" field.
  17902. func (m *MessageRecordsMutation) AddContentType(i int) {
  17903. if m.addcontent_type != nil {
  17904. *m.addcontent_type += i
  17905. } else {
  17906. m.addcontent_type = &i
  17907. }
  17908. }
  17909. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  17910. func (m *MessageRecordsMutation) AddedContentType() (r int, exists bool) {
  17911. v := m.addcontent_type
  17912. if v == nil {
  17913. return
  17914. }
  17915. return *v, true
  17916. }
  17917. // ResetContentType resets all changes to the "content_type" field.
  17918. func (m *MessageRecordsMutation) ResetContentType() {
  17919. m.content_type = nil
  17920. m.addcontent_type = nil
  17921. }
  17922. // SetContent sets the "content" field.
  17923. func (m *MessageRecordsMutation) SetContent(s string) {
  17924. m.content = &s
  17925. }
  17926. // Content returns the value of the "content" field in the mutation.
  17927. func (m *MessageRecordsMutation) Content() (r string, exists bool) {
  17928. v := m.content
  17929. if v == nil {
  17930. return
  17931. }
  17932. return *v, true
  17933. }
  17934. // OldContent returns the old "content" field's value of the MessageRecords entity.
  17935. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17936. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17937. func (m *MessageRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  17938. if !m.op.Is(OpUpdateOne) {
  17939. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  17940. }
  17941. if m.id == nil || m.oldValue == nil {
  17942. return v, errors.New("OldContent requires an ID field in the mutation")
  17943. }
  17944. oldValue, err := m.oldValue(ctx)
  17945. if err != nil {
  17946. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  17947. }
  17948. return oldValue.Content, nil
  17949. }
  17950. // ResetContent resets all changes to the "content" field.
  17951. func (m *MessageRecordsMutation) ResetContent() {
  17952. m.content = nil
  17953. }
  17954. // SetMeta sets the "meta" field.
  17955. func (m *MessageRecordsMutation) SetMeta(ct custom_types.Meta) {
  17956. m.meta = &ct
  17957. }
  17958. // Meta returns the value of the "meta" field in the mutation.
  17959. func (m *MessageRecordsMutation) Meta() (r custom_types.Meta, exists bool) {
  17960. v := m.meta
  17961. if v == nil {
  17962. return
  17963. }
  17964. return *v, true
  17965. }
  17966. // OldMeta returns the old "meta" field's value of the MessageRecords entity.
  17967. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17968. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17969. func (m *MessageRecordsMutation) OldMeta(ctx context.Context) (v custom_types.Meta, err error) {
  17970. if !m.op.Is(OpUpdateOne) {
  17971. return v, errors.New("OldMeta is only allowed on UpdateOne operations")
  17972. }
  17973. if m.id == nil || m.oldValue == nil {
  17974. return v, errors.New("OldMeta requires an ID field in the mutation")
  17975. }
  17976. oldValue, err := m.oldValue(ctx)
  17977. if err != nil {
  17978. return v, fmt.Errorf("querying old value for OldMeta: %w", err)
  17979. }
  17980. return oldValue.Meta, nil
  17981. }
  17982. // ClearMeta clears the value of the "meta" field.
  17983. func (m *MessageRecordsMutation) ClearMeta() {
  17984. m.meta = nil
  17985. m.clearedFields[messagerecords.FieldMeta] = struct{}{}
  17986. }
  17987. // MetaCleared returns if the "meta" field was cleared in this mutation.
  17988. func (m *MessageRecordsMutation) MetaCleared() bool {
  17989. _, ok := m.clearedFields[messagerecords.FieldMeta]
  17990. return ok
  17991. }
  17992. // ResetMeta resets all changes to the "meta" field.
  17993. func (m *MessageRecordsMutation) ResetMeta() {
  17994. m.meta = nil
  17995. delete(m.clearedFields, messagerecords.FieldMeta)
  17996. }
  17997. // SetErrorDetail sets the "error_detail" field.
  17998. func (m *MessageRecordsMutation) SetErrorDetail(s string) {
  17999. m.error_detail = &s
  18000. }
  18001. // ErrorDetail returns the value of the "error_detail" field in the mutation.
  18002. func (m *MessageRecordsMutation) ErrorDetail() (r string, exists bool) {
  18003. v := m.error_detail
  18004. if v == nil {
  18005. return
  18006. }
  18007. return *v, true
  18008. }
  18009. // OldErrorDetail returns the old "error_detail" field's value of the MessageRecords entity.
  18010. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  18011. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18012. func (m *MessageRecordsMutation) OldErrorDetail(ctx context.Context) (v string, err error) {
  18013. if !m.op.Is(OpUpdateOne) {
  18014. return v, errors.New("OldErrorDetail is only allowed on UpdateOne operations")
  18015. }
  18016. if m.id == nil || m.oldValue == nil {
  18017. return v, errors.New("OldErrorDetail requires an ID field in the mutation")
  18018. }
  18019. oldValue, err := m.oldValue(ctx)
  18020. if err != nil {
  18021. return v, fmt.Errorf("querying old value for OldErrorDetail: %w", err)
  18022. }
  18023. return oldValue.ErrorDetail, nil
  18024. }
  18025. // ResetErrorDetail resets all changes to the "error_detail" field.
  18026. func (m *MessageRecordsMutation) ResetErrorDetail() {
  18027. m.error_detail = nil
  18028. }
  18029. // SetSendTime sets the "send_time" field.
  18030. func (m *MessageRecordsMutation) SetSendTime(t time.Time) {
  18031. m.send_time = &t
  18032. }
  18033. // SendTime returns the value of the "send_time" field in the mutation.
  18034. func (m *MessageRecordsMutation) SendTime() (r time.Time, exists bool) {
  18035. v := m.send_time
  18036. if v == nil {
  18037. return
  18038. }
  18039. return *v, true
  18040. }
  18041. // OldSendTime returns the old "send_time" field's value of the MessageRecords entity.
  18042. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  18043. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18044. func (m *MessageRecordsMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  18045. if !m.op.Is(OpUpdateOne) {
  18046. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  18047. }
  18048. if m.id == nil || m.oldValue == nil {
  18049. return v, errors.New("OldSendTime requires an ID field in the mutation")
  18050. }
  18051. oldValue, err := m.oldValue(ctx)
  18052. if err != nil {
  18053. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  18054. }
  18055. return oldValue.SendTime, nil
  18056. }
  18057. // ClearSendTime clears the value of the "send_time" field.
  18058. func (m *MessageRecordsMutation) ClearSendTime() {
  18059. m.send_time = nil
  18060. m.clearedFields[messagerecords.FieldSendTime] = struct{}{}
  18061. }
  18062. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  18063. func (m *MessageRecordsMutation) SendTimeCleared() bool {
  18064. _, ok := m.clearedFields[messagerecords.FieldSendTime]
  18065. return ok
  18066. }
  18067. // ResetSendTime resets all changes to the "send_time" field.
  18068. func (m *MessageRecordsMutation) ResetSendTime() {
  18069. m.send_time = nil
  18070. delete(m.clearedFields, messagerecords.FieldSendTime)
  18071. }
  18072. // SetSourceType sets the "source_type" field.
  18073. func (m *MessageRecordsMutation) SetSourceType(i int) {
  18074. m.source_type = &i
  18075. m.addsource_type = nil
  18076. }
  18077. // SourceType returns the value of the "source_type" field in the mutation.
  18078. func (m *MessageRecordsMutation) SourceType() (r int, exists bool) {
  18079. v := m.source_type
  18080. if v == nil {
  18081. return
  18082. }
  18083. return *v, true
  18084. }
  18085. // OldSourceType returns the old "source_type" field's value of the MessageRecords entity.
  18086. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  18087. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18088. func (m *MessageRecordsMutation) OldSourceType(ctx context.Context) (v int, err error) {
  18089. if !m.op.Is(OpUpdateOne) {
  18090. return v, errors.New("OldSourceType is only allowed on UpdateOne operations")
  18091. }
  18092. if m.id == nil || m.oldValue == nil {
  18093. return v, errors.New("OldSourceType requires an ID field in the mutation")
  18094. }
  18095. oldValue, err := m.oldValue(ctx)
  18096. if err != nil {
  18097. return v, fmt.Errorf("querying old value for OldSourceType: %w", err)
  18098. }
  18099. return oldValue.SourceType, nil
  18100. }
  18101. // AddSourceType adds i to the "source_type" field.
  18102. func (m *MessageRecordsMutation) AddSourceType(i int) {
  18103. if m.addsource_type != nil {
  18104. *m.addsource_type += i
  18105. } else {
  18106. m.addsource_type = &i
  18107. }
  18108. }
  18109. // AddedSourceType returns the value that was added to the "source_type" field in this mutation.
  18110. func (m *MessageRecordsMutation) AddedSourceType() (r int, exists bool) {
  18111. v := m.addsource_type
  18112. if v == nil {
  18113. return
  18114. }
  18115. return *v, true
  18116. }
  18117. // ResetSourceType resets all changes to the "source_type" field.
  18118. func (m *MessageRecordsMutation) ResetSourceType() {
  18119. m.source_type = nil
  18120. m.addsource_type = nil
  18121. }
  18122. // SetSourceID sets the "source_id" field.
  18123. func (m *MessageRecordsMutation) SetSourceID(u uint64) {
  18124. m.sop_stage = &u
  18125. }
  18126. // SourceID returns the value of the "source_id" field in the mutation.
  18127. func (m *MessageRecordsMutation) SourceID() (r uint64, exists bool) {
  18128. v := m.sop_stage
  18129. if v == nil {
  18130. return
  18131. }
  18132. return *v, true
  18133. }
  18134. // OldSourceID returns the old "source_id" field's value of the MessageRecords entity.
  18135. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  18136. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18137. func (m *MessageRecordsMutation) OldSourceID(ctx context.Context) (v uint64, err error) {
  18138. if !m.op.Is(OpUpdateOne) {
  18139. return v, errors.New("OldSourceID is only allowed on UpdateOne operations")
  18140. }
  18141. if m.id == nil || m.oldValue == nil {
  18142. return v, errors.New("OldSourceID requires an ID field in the mutation")
  18143. }
  18144. oldValue, err := m.oldValue(ctx)
  18145. if err != nil {
  18146. return v, fmt.Errorf("querying old value for OldSourceID: %w", err)
  18147. }
  18148. return oldValue.SourceID, nil
  18149. }
  18150. // ClearSourceID clears the value of the "source_id" field.
  18151. func (m *MessageRecordsMutation) ClearSourceID() {
  18152. m.sop_stage = nil
  18153. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  18154. }
  18155. // SourceIDCleared returns if the "source_id" field was cleared in this mutation.
  18156. func (m *MessageRecordsMutation) SourceIDCleared() bool {
  18157. _, ok := m.clearedFields[messagerecords.FieldSourceID]
  18158. return ok
  18159. }
  18160. // ResetSourceID resets all changes to the "source_id" field.
  18161. func (m *MessageRecordsMutation) ResetSourceID() {
  18162. m.sop_stage = nil
  18163. delete(m.clearedFields, messagerecords.FieldSourceID)
  18164. }
  18165. // SetSubSourceID sets the "sub_source_id" field.
  18166. func (m *MessageRecordsMutation) SetSubSourceID(u uint64) {
  18167. m.sop_node = &u
  18168. }
  18169. // SubSourceID returns the value of the "sub_source_id" field in the mutation.
  18170. func (m *MessageRecordsMutation) SubSourceID() (r uint64, exists bool) {
  18171. v := m.sop_node
  18172. if v == nil {
  18173. return
  18174. }
  18175. return *v, true
  18176. }
  18177. // OldSubSourceID returns the old "sub_source_id" field's value of the MessageRecords entity.
  18178. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  18179. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18180. func (m *MessageRecordsMutation) OldSubSourceID(ctx context.Context) (v uint64, err error) {
  18181. if !m.op.Is(OpUpdateOne) {
  18182. return v, errors.New("OldSubSourceID is only allowed on UpdateOne operations")
  18183. }
  18184. if m.id == nil || m.oldValue == nil {
  18185. return v, errors.New("OldSubSourceID requires an ID field in the mutation")
  18186. }
  18187. oldValue, err := m.oldValue(ctx)
  18188. if err != nil {
  18189. return v, fmt.Errorf("querying old value for OldSubSourceID: %w", err)
  18190. }
  18191. return oldValue.SubSourceID, nil
  18192. }
  18193. // ClearSubSourceID clears the value of the "sub_source_id" field.
  18194. func (m *MessageRecordsMutation) ClearSubSourceID() {
  18195. m.sop_node = nil
  18196. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  18197. }
  18198. // SubSourceIDCleared returns if the "sub_source_id" field was cleared in this mutation.
  18199. func (m *MessageRecordsMutation) SubSourceIDCleared() bool {
  18200. _, ok := m.clearedFields[messagerecords.FieldSubSourceID]
  18201. return ok
  18202. }
  18203. // ResetSubSourceID resets all changes to the "sub_source_id" field.
  18204. func (m *MessageRecordsMutation) ResetSubSourceID() {
  18205. m.sop_node = nil
  18206. delete(m.clearedFields, messagerecords.FieldSubSourceID)
  18207. }
  18208. // SetOrganizationID sets the "organization_id" field.
  18209. func (m *MessageRecordsMutation) SetOrganizationID(u uint64) {
  18210. m.organization_id = &u
  18211. m.addorganization_id = nil
  18212. }
  18213. // OrganizationID returns the value of the "organization_id" field in the mutation.
  18214. func (m *MessageRecordsMutation) OrganizationID() (r uint64, exists bool) {
  18215. v := m.organization_id
  18216. if v == nil {
  18217. return
  18218. }
  18219. return *v, true
  18220. }
  18221. // OldOrganizationID returns the old "organization_id" field's value of the MessageRecords entity.
  18222. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  18223. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18224. func (m *MessageRecordsMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  18225. if !m.op.Is(OpUpdateOne) {
  18226. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  18227. }
  18228. if m.id == nil || m.oldValue == nil {
  18229. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  18230. }
  18231. oldValue, err := m.oldValue(ctx)
  18232. if err != nil {
  18233. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  18234. }
  18235. return oldValue.OrganizationID, nil
  18236. }
  18237. // AddOrganizationID adds u to the "organization_id" field.
  18238. func (m *MessageRecordsMutation) AddOrganizationID(u int64) {
  18239. if m.addorganization_id != nil {
  18240. *m.addorganization_id += u
  18241. } else {
  18242. m.addorganization_id = &u
  18243. }
  18244. }
  18245. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  18246. func (m *MessageRecordsMutation) AddedOrganizationID() (r int64, exists bool) {
  18247. v := m.addorganization_id
  18248. if v == nil {
  18249. return
  18250. }
  18251. return *v, true
  18252. }
  18253. // ClearOrganizationID clears the value of the "organization_id" field.
  18254. func (m *MessageRecordsMutation) ClearOrganizationID() {
  18255. m.organization_id = nil
  18256. m.addorganization_id = nil
  18257. m.clearedFields[messagerecords.FieldOrganizationID] = struct{}{}
  18258. }
  18259. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  18260. func (m *MessageRecordsMutation) OrganizationIDCleared() bool {
  18261. _, ok := m.clearedFields[messagerecords.FieldOrganizationID]
  18262. return ok
  18263. }
  18264. // ResetOrganizationID resets all changes to the "organization_id" field.
  18265. func (m *MessageRecordsMutation) ResetOrganizationID() {
  18266. m.organization_id = nil
  18267. m.addorganization_id = nil
  18268. delete(m.clearedFields, messagerecords.FieldOrganizationID)
  18269. }
  18270. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  18271. func (m *MessageRecordsMutation) SetSopStageID(id uint64) {
  18272. m.sop_stage = &id
  18273. }
  18274. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  18275. func (m *MessageRecordsMutation) ClearSopStage() {
  18276. m.clearedsop_stage = true
  18277. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  18278. }
  18279. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  18280. func (m *MessageRecordsMutation) SopStageCleared() bool {
  18281. return m.SourceIDCleared() || m.clearedsop_stage
  18282. }
  18283. // SopStageID returns the "sop_stage" edge ID in the mutation.
  18284. func (m *MessageRecordsMutation) SopStageID() (id uint64, exists bool) {
  18285. if m.sop_stage != nil {
  18286. return *m.sop_stage, true
  18287. }
  18288. return
  18289. }
  18290. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  18291. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  18292. // SopStageID instead. It exists only for internal usage by the builders.
  18293. func (m *MessageRecordsMutation) SopStageIDs() (ids []uint64) {
  18294. if id := m.sop_stage; id != nil {
  18295. ids = append(ids, *id)
  18296. }
  18297. return
  18298. }
  18299. // ResetSopStage resets all changes to the "sop_stage" edge.
  18300. func (m *MessageRecordsMutation) ResetSopStage() {
  18301. m.sop_stage = nil
  18302. m.clearedsop_stage = false
  18303. }
  18304. // SetSopNodeID sets the "sop_node" edge to the SopNode entity by id.
  18305. func (m *MessageRecordsMutation) SetSopNodeID(id uint64) {
  18306. m.sop_node = &id
  18307. }
  18308. // ClearSopNode clears the "sop_node" edge to the SopNode entity.
  18309. func (m *MessageRecordsMutation) ClearSopNode() {
  18310. m.clearedsop_node = true
  18311. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  18312. }
  18313. // SopNodeCleared reports if the "sop_node" edge to the SopNode entity was cleared.
  18314. func (m *MessageRecordsMutation) SopNodeCleared() bool {
  18315. return m.SubSourceIDCleared() || m.clearedsop_node
  18316. }
  18317. // SopNodeID returns the "sop_node" edge ID in the mutation.
  18318. func (m *MessageRecordsMutation) SopNodeID() (id uint64, exists bool) {
  18319. if m.sop_node != nil {
  18320. return *m.sop_node, true
  18321. }
  18322. return
  18323. }
  18324. // SopNodeIDs returns the "sop_node" edge IDs in the mutation.
  18325. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  18326. // SopNodeID instead. It exists only for internal usage by the builders.
  18327. func (m *MessageRecordsMutation) SopNodeIDs() (ids []uint64) {
  18328. if id := m.sop_node; id != nil {
  18329. ids = append(ids, *id)
  18330. }
  18331. return
  18332. }
  18333. // ResetSopNode resets all changes to the "sop_node" edge.
  18334. func (m *MessageRecordsMutation) ResetSopNode() {
  18335. m.sop_node = nil
  18336. m.clearedsop_node = false
  18337. }
  18338. // SetMessageContactID sets the "message_contact" edge to the Contact entity by id.
  18339. func (m *MessageRecordsMutation) SetMessageContactID(id uint64) {
  18340. m.message_contact = &id
  18341. }
  18342. // ClearMessageContact clears the "message_contact" edge to the Contact entity.
  18343. func (m *MessageRecordsMutation) ClearMessageContact() {
  18344. m.clearedmessage_contact = true
  18345. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  18346. }
  18347. // MessageContactCleared reports if the "message_contact" edge to the Contact entity was cleared.
  18348. func (m *MessageRecordsMutation) MessageContactCleared() bool {
  18349. return m.ContactIDCleared() || m.clearedmessage_contact
  18350. }
  18351. // MessageContactID returns the "message_contact" edge ID in the mutation.
  18352. func (m *MessageRecordsMutation) MessageContactID() (id uint64, exists bool) {
  18353. if m.message_contact != nil {
  18354. return *m.message_contact, true
  18355. }
  18356. return
  18357. }
  18358. // MessageContactIDs returns the "message_contact" edge IDs in the mutation.
  18359. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  18360. // MessageContactID instead. It exists only for internal usage by the builders.
  18361. func (m *MessageRecordsMutation) MessageContactIDs() (ids []uint64) {
  18362. if id := m.message_contact; id != nil {
  18363. ids = append(ids, *id)
  18364. }
  18365. return
  18366. }
  18367. // ResetMessageContact resets all changes to the "message_contact" edge.
  18368. func (m *MessageRecordsMutation) ResetMessageContact() {
  18369. m.message_contact = nil
  18370. m.clearedmessage_contact = false
  18371. }
  18372. // Where appends a list predicates to the MessageRecordsMutation builder.
  18373. func (m *MessageRecordsMutation) Where(ps ...predicate.MessageRecords) {
  18374. m.predicates = append(m.predicates, ps...)
  18375. }
  18376. // WhereP appends storage-level predicates to the MessageRecordsMutation builder. Using this method,
  18377. // users can use type-assertion to append predicates that do not depend on any generated package.
  18378. func (m *MessageRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  18379. p := make([]predicate.MessageRecords, len(ps))
  18380. for i := range ps {
  18381. p[i] = ps[i]
  18382. }
  18383. m.Where(p...)
  18384. }
  18385. // Op returns the operation name.
  18386. func (m *MessageRecordsMutation) Op() Op {
  18387. return m.op
  18388. }
  18389. // SetOp allows setting the mutation operation.
  18390. func (m *MessageRecordsMutation) SetOp(op Op) {
  18391. m.op = op
  18392. }
  18393. // Type returns the node type of this mutation (MessageRecords).
  18394. func (m *MessageRecordsMutation) Type() string {
  18395. return m.typ
  18396. }
  18397. // Fields returns all fields that were changed during this mutation. Note that in
  18398. // order to get all numeric fields that were incremented/decremented, call
  18399. // AddedFields().
  18400. func (m *MessageRecordsMutation) Fields() []string {
  18401. fields := make([]string, 0, 16)
  18402. if m.created_at != nil {
  18403. fields = append(fields, messagerecords.FieldCreatedAt)
  18404. }
  18405. if m.updated_at != nil {
  18406. fields = append(fields, messagerecords.FieldUpdatedAt)
  18407. }
  18408. if m.status != nil {
  18409. fields = append(fields, messagerecords.FieldStatus)
  18410. }
  18411. if m.bot_wxid != nil {
  18412. fields = append(fields, messagerecords.FieldBotWxid)
  18413. }
  18414. if m.message_contact != nil {
  18415. fields = append(fields, messagerecords.FieldContactID)
  18416. }
  18417. if m.contact_type != nil {
  18418. fields = append(fields, messagerecords.FieldContactType)
  18419. }
  18420. if m.contact_wxid != nil {
  18421. fields = append(fields, messagerecords.FieldContactWxid)
  18422. }
  18423. if m.content_type != nil {
  18424. fields = append(fields, messagerecords.FieldContentType)
  18425. }
  18426. if m.content != nil {
  18427. fields = append(fields, messagerecords.FieldContent)
  18428. }
  18429. if m.meta != nil {
  18430. fields = append(fields, messagerecords.FieldMeta)
  18431. }
  18432. if m.error_detail != nil {
  18433. fields = append(fields, messagerecords.FieldErrorDetail)
  18434. }
  18435. if m.send_time != nil {
  18436. fields = append(fields, messagerecords.FieldSendTime)
  18437. }
  18438. if m.source_type != nil {
  18439. fields = append(fields, messagerecords.FieldSourceType)
  18440. }
  18441. if m.sop_stage != nil {
  18442. fields = append(fields, messagerecords.FieldSourceID)
  18443. }
  18444. if m.sop_node != nil {
  18445. fields = append(fields, messagerecords.FieldSubSourceID)
  18446. }
  18447. if m.organization_id != nil {
  18448. fields = append(fields, messagerecords.FieldOrganizationID)
  18449. }
  18450. return fields
  18451. }
  18452. // Field returns the value of a field with the given name. The second boolean
  18453. // return value indicates that this field was not set, or was not defined in the
  18454. // schema.
  18455. func (m *MessageRecordsMutation) Field(name string) (ent.Value, bool) {
  18456. switch name {
  18457. case messagerecords.FieldCreatedAt:
  18458. return m.CreatedAt()
  18459. case messagerecords.FieldUpdatedAt:
  18460. return m.UpdatedAt()
  18461. case messagerecords.FieldStatus:
  18462. return m.Status()
  18463. case messagerecords.FieldBotWxid:
  18464. return m.BotWxid()
  18465. case messagerecords.FieldContactID:
  18466. return m.ContactID()
  18467. case messagerecords.FieldContactType:
  18468. return m.ContactType()
  18469. case messagerecords.FieldContactWxid:
  18470. return m.ContactWxid()
  18471. case messagerecords.FieldContentType:
  18472. return m.ContentType()
  18473. case messagerecords.FieldContent:
  18474. return m.Content()
  18475. case messagerecords.FieldMeta:
  18476. return m.Meta()
  18477. case messagerecords.FieldErrorDetail:
  18478. return m.ErrorDetail()
  18479. case messagerecords.FieldSendTime:
  18480. return m.SendTime()
  18481. case messagerecords.FieldSourceType:
  18482. return m.SourceType()
  18483. case messagerecords.FieldSourceID:
  18484. return m.SourceID()
  18485. case messagerecords.FieldSubSourceID:
  18486. return m.SubSourceID()
  18487. case messagerecords.FieldOrganizationID:
  18488. return m.OrganizationID()
  18489. }
  18490. return nil, false
  18491. }
  18492. // OldField returns the old value of the field from the database. An error is
  18493. // returned if the mutation operation is not UpdateOne, or the query to the
  18494. // database failed.
  18495. func (m *MessageRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  18496. switch name {
  18497. case messagerecords.FieldCreatedAt:
  18498. return m.OldCreatedAt(ctx)
  18499. case messagerecords.FieldUpdatedAt:
  18500. return m.OldUpdatedAt(ctx)
  18501. case messagerecords.FieldStatus:
  18502. return m.OldStatus(ctx)
  18503. case messagerecords.FieldBotWxid:
  18504. return m.OldBotWxid(ctx)
  18505. case messagerecords.FieldContactID:
  18506. return m.OldContactID(ctx)
  18507. case messagerecords.FieldContactType:
  18508. return m.OldContactType(ctx)
  18509. case messagerecords.FieldContactWxid:
  18510. return m.OldContactWxid(ctx)
  18511. case messagerecords.FieldContentType:
  18512. return m.OldContentType(ctx)
  18513. case messagerecords.FieldContent:
  18514. return m.OldContent(ctx)
  18515. case messagerecords.FieldMeta:
  18516. return m.OldMeta(ctx)
  18517. case messagerecords.FieldErrorDetail:
  18518. return m.OldErrorDetail(ctx)
  18519. case messagerecords.FieldSendTime:
  18520. return m.OldSendTime(ctx)
  18521. case messagerecords.FieldSourceType:
  18522. return m.OldSourceType(ctx)
  18523. case messagerecords.FieldSourceID:
  18524. return m.OldSourceID(ctx)
  18525. case messagerecords.FieldSubSourceID:
  18526. return m.OldSubSourceID(ctx)
  18527. case messagerecords.FieldOrganizationID:
  18528. return m.OldOrganizationID(ctx)
  18529. }
  18530. return nil, fmt.Errorf("unknown MessageRecords field %s", name)
  18531. }
  18532. // SetField sets the value of a field with the given name. It returns an error if
  18533. // the field is not defined in the schema, or if the type mismatched the field
  18534. // type.
  18535. func (m *MessageRecordsMutation) SetField(name string, value ent.Value) error {
  18536. switch name {
  18537. case messagerecords.FieldCreatedAt:
  18538. v, ok := value.(time.Time)
  18539. if !ok {
  18540. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18541. }
  18542. m.SetCreatedAt(v)
  18543. return nil
  18544. case messagerecords.FieldUpdatedAt:
  18545. v, ok := value.(time.Time)
  18546. if !ok {
  18547. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18548. }
  18549. m.SetUpdatedAt(v)
  18550. return nil
  18551. case messagerecords.FieldStatus:
  18552. v, ok := value.(uint8)
  18553. if !ok {
  18554. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18555. }
  18556. m.SetStatus(v)
  18557. return nil
  18558. case messagerecords.FieldBotWxid:
  18559. v, ok := value.(string)
  18560. if !ok {
  18561. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18562. }
  18563. m.SetBotWxid(v)
  18564. return nil
  18565. case messagerecords.FieldContactID:
  18566. v, ok := value.(uint64)
  18567. if !ok {
  18568. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18569. }
  18570. m.SetContactID(v)
  18571. return nil
  18572. case messagerecords.FieldContactType:
  18573. v, ok := value.(int)
  18574. if !ok {
  18575. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18576. }
  18577. m.SetContactType(v)
  18578. return nil
  18579. case messagerecords.FieldContactWxid:
  18580. v, ok := value.(string)
  18581. if !ok {
  18582. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18583. }
  18584. m.SetContactWxid(v)
  18585. return nil
  18586. case messagerecords.FieldContentType:
  18587. v, ok := value.(int)
  18588. if !ok {
  18589. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18590. }
  18591. m.SetContentType(v)
  18592. return nil
  18593. case messagerecords.FieldContent:
  18594. v, ok := value.(string)
  18595. if !ok {
  18596. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18597. }
  18598. m.SetContent(v)
  18599. return nil
  18600. case messagerecords.FieldMeta:
  18601. v, ok := value.(custom_types.Meta)
  18602. if !ok {
  18603. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18604. }
  18605. m.SetMeta(v)
  18606. return nil
  18607. case messagerecords.FieldErrorDetail:
  18608. v, ok := value.(string)
  18609. if !ok {
  18610. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18611. }
  18612. m.SetErrorDetail(v)
  18613. return nil
  18614. case messagerecords.FieldSendTime:
  18615. v, ok := value.(time.Time)
  18616. if !ok {
  18617. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18618. }
  18619. m.SetSendTime(v)
  18620. return nil
  18621. case messagerecords.FieldSourceType:
  18622. v, ok := value.(int)
  18623. if !ok {
  18624. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18625. }
  18626. m.SetSourceType(v)
  18627. return nil
  18628. case messagerecords.FieldSourceID:
  18629. v, ok := value.(uint64)
  18630. if !ok {
  18631. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18632. }
  18633. m.SetSourceID(v)
  18634. return nil
  18635. case messagerecords.FieldSubSourceID:
  18636. v, ok := value.(uint64)
  18637. if !ok {
  18638. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18639. }
  18640. m.SetSubSourceID(v)
  18641. return nil
  18642. case messagerecords.FieldOrganizationID:
  18643. v, ok := value.(uint64)
  18644. if !ok {
  18645. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18646. }
  18647. m.SetOrganizationID(v)
  18648. return nil
  18649. }
  18650. return fmt.Errorf("unknown MessageRecords field %s", name)
  18651. }
  18652. // AddedFields returns all numeric fields that were incremented/decremented during
  18653. // this mutation.
  18654. func (m *MessageRecordsMutation) AddedFields() []string {
  18655. var fields []string
  18656. if m.addstatus != nil {
  18657. fields = append(fields, messagerecords.FieldStatus)
  18658. }
  18659. if m.addcontact_type != nil {
  18660. fields = append(fields, messagerecords.FieldContactType)
  18661. }
  18662. if m.addcontent_type != nil {
  18663. fields = append(fields, messagerecords.FieldContentType)
  18664. }
  18665. if m.addsource_type != nil {
  18666. fields = append(fields, messagerecords.FieldSourceType)
  18667. }
  18668. if m.addorganization_id != nil {
  18669. fields = append(fields, messagerecords.FieldOrganizationID)
  18670. }
  18671. return fields
  18672. }
  18673. // AddedField returns the numeric value that was incremented/decremented on a field
  18674. // with the given name. The second boolean return value indicates that this field
  18675. // was not set, or was not defined in the schema.
  18676. func (m *MessageRecordsMutation) AddedField(name string) (ent.Value, bool) {
  18677. switch name {
  18678. case messagerecords.FieldStatus:
  18679. return m.AddedStatus()
  18680. case messagerecords.FieldContactType:
  18681. return m.AddedContactType()
  18682. case messagerecords.FieldContentType:
  18683. return m.AddedContentType()
  18684. case messagerecords.FieldSourceType:
  18685. return m.AddedSourceType()
  18686. case messagerecords.FieldOrganizationID:
  18687. return m.AddedOrganizationID()
  18688. }
  18689. return nil, false
  18690. }
  18691. // AddField adds the value to the field with the given name. It returns an error if
  18692. // the field is not defined in the schema, or if the type mismatched the field
  18693. // type.
  18694. func (m *MessageRecordsMutation) AddField(name string, value ent.Value) error {
  18695. switch name {
  18696. case messagerecords.FieldStatus:
  18697. v, ok := value.(int8)
  18698. if !ok {
  18699. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18700. }
  18701. m.AddStatus(v)
  18702. return nil
  18703. case messagerecords.FieldContactType:
  18704. v, ok := value.(int)
  18705. if !ok {
  18706. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18707. }
  18708. m.AddContactType(v)
  18709. return nil
  18710. case messagerecords.FieldContentType:
  18711. v, ok := value.(int)
  18712. if !ok {
  18713. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18714. }
  18715. m.AddContentType(v)
  18716. return nil
  18717. case messagerecords.FieldSourceType:
  18718. v, ok := value.(int)
  18719. if !ok {
  18720. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18721. }
  18722. m.AddSourceType(v)
  18723. return nil
  18724. case messagerecords.FieldOrganizationID:
  18725. v, ok := value.(int64)
  18726. if !ok {
  18727. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18728. }
  18729. m.AddOrganizationID(v)
  18730. return nil
  18731. }
  18732. return fmt.Errorf("unknown MessageRecords numeric field %s", name)
  18733. }
  18734. // ClearedFields returns all nullable fields that were cleared during this
  18735. // mutation.
  18736. func (m *MessageRecordsMutation) ClearedFields() []string {
  18737. var fields []string
  18738. if m.FieldCleared(messagerecords.FieldStatus) {
  18739. fields = append(fields, messagerecords.FieldStatus)
  18740. }
  18741. if m.FieldCleared(messagerecords.FieldContactID) {
  18742. fields = append(fields, messagerecords.FieldContactID)
  18743. }
  18744. if m.FieldCleared(messagerecords.FieldMeta) {
  18745. fields = append(fields, messagerecords.FieldMeta)
  18746. }
  18747. if m.FieldCleared(messagerecords.FieldSendTime) {
  18748. fields = append(fields, messagerecords.FieldSendTime)
  18749. }
  18750. if m.FieldCleared(messagerecords.FieldSourceID) {
  18751. fields = append(fields, messagerecords.FieldSourceID)
  18752. }
  18753. if m.FieldCleared(messagerecords.FieldSubSourceID) {
  18754. fields = append(fields, messagerecords.FieldSubSourceID)
  18755. }
  18756. if m.FieldCleared(messagerecords.FieldOrganizationID) {
  18757. fields = append(fields, messagerecords.FieldOrganizationID)
  18758. }
  18759. return fields
  18760. }
  18761. // FieldCleared returns a boolean indicating if a field with the given name was
  18762. // cleared in this mutation.
  18763. func (m *MessageRecordsMutation) FieldCleared(name string) bool {
  18764. _, ok := m.clearedFields[name]
  18765. return ok
  18766. }
  18767. // ClearField clears the value of the field with the given name. It returns an
  18768. // error if the field is not defined in the schema.
  18769. func (m *MessageRecordsMutation) ClearField(name string) error {
  18770. switch name {
  18771. case messagerecords.FieldStatus:
  18772. m.ClearStatus()
  18773. return nil
  18774. case messagerecords.FieldContactID:
  18775. m.ClearContactID()
  18776. return nil
  18777. case messagerecords.FieldMeta:
  18778. m.ClearMeta()
  18779. return nil
  18780. case messagerecords.FieldSendTime:
  18781. m.ClearSendTime()
  18782. return nil
  18783. case messagerecords.FieldSourceID:
  18784. m.ClearSourceID()
  18785. return nil
  18786. case messagerecords.FieldSubSourceID:
  18787. m.ClearSubSourceID()
  18788. return nil
  18789. case messagerecords.FieldOrganizationID:
  18790. m.ClearOrganizationID()
  18791. return nil
  18792. }
  18793. return fmt.Errorf("unknown MessageRecords nullable field %s", name)
  18794. }
  18795. // ResetField resets all changes in the mutation for the field with the given name.
  18796. // It returns an error if the field is not defined in the schema.
  18797. func (m *MessageRecordsMutation) ResetField(name string) error {
  18798. switch name {
  18799. case messagerecords.FieldCreatedAt:
  18800. m.ResetCreatedAt()
  18801. return nil
  18802. case messagerecords.FieldUpdatedAt:
  18803. m.ResetUpdatedAt()
  18804. return nil
  18805. case messagerecords.FieldStatus:
  18806. m.ResetStatus()
  18807. return nil
  18808. case messagerecords.FieldBotWxid:
  18809. m.ResetBotWxid()
  18810. return nil
  18811. case messagerecords.FieldContactID:
  18812. m.ResetContactID()
  18813. return nil
  18814. case messagerecords.FieldContactType:
  18815. m.ResetContactType()
  18816. return nil
  18817. case messagerecords.FieldContactWxid:
  18818. m.ResetContactWxid()
  18819. return nil
  18820. case messagerecords.FieldContentType:
  18821. m.ResetContentType()
  18822. return nil
  18823. case messagerecords.FieldContent:
  18824. m.ResetContent()
  18825. return nil
  18826. case messagerecords.FieldMeta:
  18827. m.ResetMeta()
  18828. return nil
  18829. case messagerecords.FieldErrorDetail:
  18830. m.ResetErrorDetail()
  18831. return nil
  18832. case messagerecords.FieldSendTime:
  18833. m.ResetSendTime()
  18834. return nil
  18835. case messagerecords.FieldSourceType:
  18836. m.ResetSourceType()
  18837. return nil
  18838. case messagerecords.FieldSourceID:
  18839. m.ResetSourceID()
  18840. return nil
  18841. case messagerecords.FieldSubSourceID:
  18842. m.ResetSubSourceID()
  18843. return nil
  18844. case messagerecords.FieldOrganizationID:
  18845. m.ResetOrganizationID()
  18846. return nil
  18847. }
  18848. return fmt.Errorf("unknown MessageRecords field %s", name)
  18849. }
  18850. // AddedEdges returns all edge names that were set/added in this mutation.
  18851. func (m *MessageRecordsMutation) AddedEdges() []string {
  18852. edges := make([]string, 0, 3)
  18853. if m.sop_stage != nil {
  18854. edges = append(edges, messagerecords.EdgeSopStage)
  18855. }
  18856. if m.sop_node != nil {
  18857. edges = append(edges, messagerecords.EdgeSopNode)
  18858. }
  18859. if m.message_contact != nil {
  18860. edges = append(edges, messagerecords.EdgeMessageContact)
  18861. }
  18862. return edges
  18863. }
  18864. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  18865. // name in this mutation.
  18866. func (m *MessageRecordsMutation) AddedIDs(name string) []ent.Value {
  18867. switch name {
  18868. case messagerecords.EdgeSopStage:
  18869. if id := m.sop_stage; id != nil {
  18870. return []ent.Value{*id}
  18871. }
  18872. case messagerecords.EdgeSopNode:
  18873. if id := m.sop_node; id != nil {
  18874. return []ent.Value{*id}
  18875. }
  18876. case messagerecords.EdgeMessageContact:
  18877. if id := m.message_contact; id != nil {
  18878. return []ent.Value{*id}
  18879. }
  18880. }
  18881. return nil
  18882. }
  18883. // RemovedEdges returns all edge names that were removed in this mutation.
  18884. func (m *MessageRecordsMutation) RemovedEdges() []string {
  18885. edges := make([]string, 0, 3)
  18886. return edges
  18887. }
  18888. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  18889. // the given name in this mutation.
  18890. func (m *MessageRecordsMutation) RemovedIDs(name string) []ent.Value {
  18891. return nil
  18892. }
  18893. // ClearedEdges returns all edge names that were cleared in this mutation.
  18894. func (m *MessageRecordsMutation) ClearedEdges() []string {
  18895. edges := make([]string, 0, 3)
  18896. if m.clearedsop_stage {
  18897. edges = append(edges, messagerecords.EdgeSopStage)
  18898. }
  18899. if m.clearedsop_node {
  18900. edges = append(edges, messagerecords.EdgeSopNode)
  18901. }
  18902. if m.clearedmessage_contact {
  18903. edges = append(edges, messagerecords.EdgeMessageContact)
  18904. }
  18905. return edges
  18906. }
  18907. // EdgeCleared returns a boolean which indicates if the edge with the given name
  18908. // was cleared in this mutation.
  18909. func (m *MessageRecordsMutation) EdgeCleared(name string) bool {
  18910. switch name {
  18911. case messagerecords.EdgeSopStage:
  18912. return m.clearedsop_stage
  18913. case messagerecords.EdgeSopNode:
  18914. return m.clearedsop_node
  18915. case messagerecords.EdgeMessageContact:
  18916. return m.clearedmessage_contact
  18917. }
  18918. return false
  18919. }
  18920. // ClearEdge clears the value of the edge with the given name. It returns an error
  18921. // if that edge is not defined in the schema.
  18922. func (m *MessageRecordsMutation) ClearEdge(name string) error {
  18923. switch name {
  18924. case messagerecords.EdgeSopStage:
  18925. m.ClearSopStage()
  18926. return nil
  18927. case messagerecords.EdgeSopNode:
  18928. m.ClearSopNode()
  18929. return nil
  18930. case messagerecords.EdgeMessageContact:
  18931. m.ClearMessageContact()
  18932. return nil
  18933. }
  18934. return fmt.Errorf("unknown MessageRecords unique edge %s", name)
  18935. }
  18936. // ResetEdge resets all changes to the edge with the given name in this mutation.
  18937. // It returns an error if the edge is not defined in the schema.
  18938. func (m *MessageRecordsMutation) ResetEdge(name string) error {
  18939. switch name {
  18940. case messagerecords.EdgeSopStage:
  18941. m.ResetSopStage()
  18942. return nil
  18943. case messagerecords.EdgeSopNode:
  18944. m.ResetSopNode()
  18945. return nil
  18946. case messagerecords.EdgeMessageContact:
  18947. m.ResetMessageContact()
  18948. return nil
  18949. }
  18950. return fmt.Errorf("unknown MessageRecords edge %s", name)
  18951. }
  18952. // MsgMutation represents an operation that mutates the Msg nodes in the graph.
  18953. type MsgMutation struct {
  18954. config
  18955. op Op
  18956. typ string
  18957. id *uint64
  18958. created_at *time.Time
  18959. updated_at *time.Time
  18960. deleted_at *time.Time
  18961. status *uint8
  18962. addstatus *int8
  18963. fromwxid *string
  18964. toid *string
  18965. msgtype *int32
  18966. addmsgtype *int32
  18967. msg *string
  18968. batch_no *string
  18969. cc *string
  18970. phone *string
  18971. clearedFields map[string]struct{}
  18972. done bool
  18973. oldValue func(context.Context) (*Msg, error)
  18974. predicates []predicate.Msg
  18975. }
  18976. var _ ent.Mutation = (*MsgMutation)(nil)
  18977. // msgOption allows management of the mutation configuration using functional options.
  18978. type msgOption func(*MsgMutation)
  18979. // newMsgMutation creates new mutation for the Msg entity.
  18980. func newMsgMutation(c config, op Op, opts ...msgOption) *MsgMutation {
  18981. m := &MsgMutation{
  18982. config: c,
  18983. op: op,
  18984. typ: TypeMsg,
  18985. clearedFields: make(map[string]struct{}),
  18986. }
  18987. for _, opt := range opts {
  18988. opt(m)
  18989. }
  18990. return m
  18991. }
  18992. // withMsgID sets the ID field of the mutation.
  18993. func withMsgID(id uint64) msgOption {
  18994. return func(m *MsgMutation) {
  18995. var (
  18996. err error
  18997. once sync.Once
  18998. value *Msg
  18999. )
  19000. m.oldValue = func(ctx context.Context) (*Msg, error) {
  19001. once.Do(func() {
  19002. if m.done {
  19003. err = errors.New("querying old values post mutation is not allowed")
  19004. } else {
  19005. value, err = m.Client().Msg.Get(ctx, id)
  19006. }
  19007. })
  19008. return value, err
  19009. }
  19010. m.id = &id
  19011. }
  19012. }
  19013. // withMsg sets the old Msg of the mutation.
  19014. func withMsg(node *Msg) msgOption {
  19015. return func(m *MsgMutation) {
  19016. m.oldValue = func(context.Context) (*Msg, error) {
  19017. return node, nil
  19018. }
  19019. m.id = &node.ID
  19020. }
  19021. }
  19022. // Client returns a new `ent.Client` from the mutation. If the mutation was
  19023. // executed in a transaction (ent.Tx), a transactional client is returned.
  19024. func (m MsgMutation) Client() *Client {
  19025. client := &Client{config: m.config}
  19026. client.init()
  19027. return client
  19028. }
  19029. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  19030. // it returns an error otherwise.
  19031. func (m MsgMutation) Tx() (*Tx, error) {
  19032. if _, ok := m.driver.(*txDriver); !ok {
  19033. return nil, errors.New("ent: mutation is not running in a transaction")
  19034. }
  19035. tx := &Tx{config: m.config}
  19036. tx.init()
  19037. return tx, nil
  19038. }
  19039. // SetID sets the value of the id field. Note that this
  19040. // operation is only accepted on creation of Msg entities.
  19041. func (m *MsgMutation) SetID(id uint64) {
  19042. m.id = &id
  19043. }
  19044. // ID returns the ID value in the mutation. Note that the ID is only available
  19045. // if it was provided to the builder or after it was returned from the database.
  19046. func (m *MsgMutation) ID() (id uint64, exists bool) {
  19047. if m.id == nil {
  19048. return
  19049. }
  19050. return *m.id, true
  19051. }
  19052. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  19053. // That means, if the mutation is applied within a transaction with an isolation level such
  19054. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  19055. // or updated by the mutation.
  19056. func (m *MsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  19057. switch {
  19058. case m.op.Is(OpUpdateOne | OpDeleteOne):
  19059. id, exists := m.ID()
  19060. if exists {
  19061. return []uint64{id}, nil
  19062. }
  19063. fallthrough
  19064. case m.op.Is(OpUpdate | OpDelete):
  19065. return m.Client().Msg.Query().Where(m.predicates...).IDs(ctx)
  19066. default:
  19067. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  19068. }
  19069. }
  19070. // SetCreatedAt sets the "created_at" field.
  19071. func (m *MsgMutation) SetCreatedAt(t time.Time) {
  19072. m.created_at = &t
  19073. }
  19074. // CreatedAt returns the value of the "created_at" field in the mutation.
  19075. func (m *MsgMutation) CreatedAt() (r time.Time, exists bool) {
  19076. v := m.created_at
  19077. if v == nil {
  19078. return
  19079. }
  19080. return *v, true
  19081. }
  19082. // OldCreatedAt returns the old "created_at" field's value of the Msg entity.
  19083. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  19084. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19085. func (m *MsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  19086. if !m.op.Is(OpUpdateOne) {
  19087. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  19088. }
  19089. if m.id == nil || m.oldValue == nil {
  19090. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  19091. }
  19092. oldValue, err := m.oldValue(ctx)
  19093. if err != nil {
  19094. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  19095. }
  19096. return oldValue.CreatedAt, nil
  19097. }
  19098. // ResetCreatedAt resets all changes to the "created_at" field.
  19099. func (m *MsgMutation) ResetCreatedAt() {
  19100. m.created_at = nil
  19101. }
  19102. // SetUpdatedAt sets the "updated_at" field.
  19103. func (m *MsgMutation) SetUpdatedAt(t time.Time) {
  19104. m.updated_at = &t
  19105. }
  19106. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  19107. func (m *MsgMutation) UpdatedAt() (r time.Time, exists bool) {
  19108. v := m.updated_at
  19109. if v == nil {
  19110. return
  19111. }
  19112. return *v, true
  19113. }
  19114. // OldUpdatedAt returns the old "updated_at" field's value of the Msg entity.
  19115. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  19116. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19117. func (m *MsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  19118. if !m.op.Is(OpUpdateOne) {
  19119. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  19120. }
  19121. if m.id == nil || m.oldValue == nil {
  19122. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  19123. }
  19124. oldValue, err := m.oldValue(ctx)
  19125. if err != nil {
  19126. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  19127. }
  19128. return oldValue.UpdatedAt, nil
  19129. }
  19130. // ResetUpdatedAt resets all changes to the "updated_at" field.
  19131. func (m *MsgMutation) ResetUpdatedAt() {
  19132. m.updated_at = nil
  19133. }
  19134. // SetDeletedAt sets the "deleted_at" field.
  19135. func (m *MsgMutation) SetDeletedAt(t time.Time) {
  19136. m.deleted_at = &t
  19137. }
  19138. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  19139. func (m *MsgMutation) DeletedAt() (r time.Time, exists bool) {
  19140. v := m.deleted_at
  19141. if v == nil {
  19142. return
  19143. }
  19144. return *v, true
  19145. }
  19146. // OldDeletedAt returns the old "deleted_at" field's value of the Msg entity.
  19147. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  19148. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19149. func (m *MsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  19150. if !m.op.Is(OpUpdateOne) {
  19151. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  19152. }
  19153. if m.id == nil || m.oldValue == nil {
  19154. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  19155. }
  19156. oldValue, err := m.oldValue(ctx)
  19157. if err != nil {
  19158. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  19159. }
  19160. return oldValue.DeletedAt, nil
  19161. }
  19162. // ClearDeletedAt clears the value of the "deleted_at" field.
  19163. func (m *MsgMutation) ClearDeletedAt() {
  19164. m.deleted_at = nil
  19165. m.clearedFields[msg.FieldDeletedAt] = struct{}{}
  19166. }
  19167. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  19168. func (m *MsgMutation) DeletedAtCleared() bool {
  19169. _, ok := m.clearedFields[msg.FieldDeletedAt]
  19170. return ok
  19171. }
  19172. // ResetDeletedAt resets all changes to the "deleted_at" field.
  19173. func (m *MsgMutation) ResetDeletedAt() {
  19174. m.deleted_at = nil
  19175. delete(m.clearedFields, msg.FieldDeletedAt)
  19176. }
  19177. // SetStatus sets the "status" field.
  19178. func (m *MsgMutation) SetStatus(u uint8) {
  19179. m.status = &u
  19180. m.addstatus = nil
  19181. }
  19182. // Status returns the value of the "status" field in the mutation.
  19183. func (m *MsgMutation) Status() (r uint8, exists bool) {
  19184. v := m.status
  19185. if v == nil {
  19186. return
  19187. }
  19188. return *v, true
  19189. }
  19190. // OldStatus returns the old "status" field's value of the Msg entity.
  19191. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  19192. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19193. func (m *MsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  19194. if !m.op.Is(OpUpdateOne) {
  19195. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  19196. }
  19197. if m.id == nil || m.oldValue == nil {
  19198. return v, errors.New("OldStatus requires an ID field in the mutation")
  19199. }
  19200. oldValue, err := m.oldValue(ctx)
  19201. if err != nil {
  19202. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  19203. }
  19204. return oldValue.Status, nil
  19205. }
  19206. // AddStatus adds u to the "status" field.
  19207. func (m *MsgMutation) AddStatus(u int8) {
  19208. if m.addstatus != nil {
  19209. *m.addstatus += u
  19210. } else {
  19211. m.addstatus = &u
  19212. }
  19213. }
  19214. // AddedStatus returns the value that was added to the "status" field in this mutation.
  19215. func (m *MsgMutation) AddedStatus() (r int8, exists bool) {
  19216. v := m.addstatus
  19217. if v == nil {
  19218. return
  19219. }
  19220. return *v, true
  19221. }
  19222. // ClearStatus clears the value of the "status" field.
  19223. func (m *MsgMutation) ClearStatus() {
  19224. m.status = nil
  19225. m.addstatus = nil
  19226. m.clearedFields[msg.FieldStatus] = struct{}{}
  19227. }
  19228. // StatusCleared returns if the "status" field was cleared in this mutation.
  19229. func (m *MsgMutation) StatusCleared() bool {
  19230. _, ok := m.clearedFields[msg.FieldStatus]
  19231. return ok
  19232. }
  19233. // ResetStatus resets all changes to the "status" field.
  19234. func (m *MsgMutation) ResetStatus() {
  19235. m.status = nil
  19236. m.addstatus = nil
  19237. delete(m.clearedFields, msg.FieldStatus)
  19238. }
  19239. // SetFromwxid sets the "fromwxid" field.
  19240. func (m *MsgMutation) SetFromwxid(s string) {
  19241. m.fromwxid = &s
  19242. }
  19243. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  19244. func (m *MsgMutation) Fromwxid() (r string, exists bool) {
  19245. v := m.fromwxid
  19246. if v == nil {
  19247. return
  19248. }
  19249. return *v, true
  19250. }
  19251. // OldFromwxid returns the old "fromwxid" field's value of the Msg entity.
  19252. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  19253. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19254. func (m *MsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  19255. if !m.op.Is(OpUpdateOne) {
  19256. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  19257. }
  19258. if m.id == nil || m.oldValue == nil {
  19259. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  19260. }
  19261. oldValue, err := m.oldValue(ctx)
  19262. if err != nil {
  19263. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  19264. }
  19265. return oldValue.Fromwxid, nil
  19266. }
  19267. // ClearFromwxid clears the value of the "fromwxid" field.
  19268. func (m *MsgMutation) ClearFromwxid() {
  19269. m.fromwxid = nil
  19270. m.clearedFields[msg.FieldFromwxid] = struct{}{}
  19271. }
  19272. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  19273. func (m *MsgMutation) FromwxidCleared() bool {
  19274. _, ok := m.clearedFields[msg.FieldFromwxid]
  19275. return ok
  19276. }
  19277. // ResetFromwxid resets all changes to the "fromwxid" field.
  19278. func (m *MsgMutation) ResetFromwxid() {
  19279. m.fromwxid = nil
  19280. delete(m.clearedFields, msg.FieldFromwxid)
  19281. }
  19282. // SetToid sets the "toid" field.
  19283. func (m *MsgMutation) SetToid(s string) {
  19284. m.toid = &s
  19285. }
  19286. // Toid returns the value of the "toid" field in the mutation.
  19287. func (m *MsgMutation) Toid() (r string, exists bool) {
  19288. v := m.toid
  19289. if v == nil {
  19290. return
  19291. }
  19292. return *v, true
  19293. }
  19294. // OldToid returns the old "toid" field's value of the Msg entity.
  19295. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  19296. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19297. func (m *MsgMutation) OldToid(ctx context.Context) (v string, err error) {
  19298. if !m.op.Is(OpUpdateOne) {
  19299. return v, errors.New("OldToid is only allowed on UpdateOne operations")
  19300. }
  19301. if m.id == nil || m.oldValue == nil {
  19302. return v, errors.New("OldToid requires an ID field in the mutation")
  19303. }
  19304. oldValue, err := m.oldValue(ctx)
  19305. if err != nil {
  19306. return v, fmt.Errorf("querying old value for OldToid: %w", err)
  19307. }
  19308. return oldValue.Toid, nil
  19309. }
  19310. // ClearToid clears the value of the "toid" field.
  19311. func (m *MsgMutation) ClearToid() {
  19312. m.toid = nil
  19313. m.clearedFields[msg.FieldToid] = struct{}{}
  19314. }
  19315. // ToidCleared returns if the "toid" field was cleared in this mutation.
  19316. func (m *MsgMutation) ToidCleared() bool {
  19317. _, ok := m.clearedFields[msg.FieldToid]
  19318. return ok
  19319. }
  19320. // ResetToid resets all changes to the "toid" field.
  19321. func (m *MsgMutation) ResetToid() {
  19322. m.toid = nil
  19323. delete(m.clearedFields, msg.FieldToid)
  19324. }
  19325. // SetMsgtype sets the "msgtype" field.
  19326. func (m *MsgMutation) SetMsgtype(i int32) {
  19327. m.msgtype = &i
  19328. m.addmsgtype = nil
  19329. }
  19330. // Msgtype returns the value of the "msgtype" field in the mutation.
  19331. func (m *MsgMutation) Msgtype() (r int32, exists bool) {
  19332. v := m.msgtype
  19333. if v == nil {
  19334. return
  19335. }
  19336. return *v, true
  19337. }
  19338. // OldMsgtype returns the old "msgtype" field's value of the Msg entity.
  19339. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  19340. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19341. func (m *MsgMutation) OldMsgtype(ctx context.Context) (v int32, err error) {
  19342. if !m.op.Is(OpUpdateOne) {
  19343. return v, errors.New("OldMsgtype is only allowed on UpdateOne operations")
  19344. }
  19345. if m.id == nil || m.oldValue == nil {
  19346. return v, errors.New("OldMsgtype requires an ID field in the mutation")
  19347. }
  19348. oldValue, err := m.oldValue(ctx)
  19349. if err != nil {
  19350. return v, fmt.Errorf("querying old value for OldMsgtype: %w", err)
  19351. }
  19352. return oldValue.Msgtype, nil
  19353. }
  19354. // AddMsgtype adds i to the "msgtype" field.
  19355. func (m *MsgMutation) AddMsgtype(i int32) {
  19356. if m.addmsgtype != nil {
  19357. *m.addmsgtype += i
  19358. } else {
  19359. m.addmsgtype = &i
  19360. }
  19361. }
  19362. // AddedMsgtype returns the value that was added to the "msgtype" field in this mutation.
  19363. func (m *MsgMutation) AddedMsgtype() (r int32, exists bool) {
  19364. v := m.addmsgtype
  19365. if v == nil {
  19366. return
  19367. }
  19368. return *v, true
  19369. }
  19370. // ClearMsgtype clears the value of the "msgtype" field.
  19371. func (m *MsgMutation) ClearMsgtype() {
  19372. m.msgtype = nil
  19373. m.addmsgtype = nil
  19374. m.clearedFields[msg.FieldMsgtype] = struct{}{}
  19375. }
  19376. // MsgtypeCleared returns if the "msgtype" field was cleared in this mutation.
  19377. func (m *MsgMutation) MsgtypeCleared() bool {
  19378. _, ok := m.clearedFields[msg.FieldMsgtype]
  19379. return ok
  19380. }
  19381. // ResetMsgtype resets all changes to the "msgtype" field.
  19382. func (m *MsgMutation) ResetMsgtype() {
  19383. m.msgtype = nil
  19384. m.addmsgtype = nil
  19385. delete(m.clearedFields, msg.FieldMsgtype)
  19386. }
  19387. // SetMsg sets the "msg" field.
  19388. func (m *MsgMutation) SetMsg(s string) {
  19389. m.msg = &s
  19390. }
  19391. // Msg returns the value of the "msg" field in the mutation.
  19392. func (m *MsgMutation) Msg() (r string, exists bool) {
  19393. v := m.msg
  19394. if v == nil {
  19395. return
  19396. }
  19397. return *v, true
  19398. }
  19399. // OldMsg returns the old "msg" field's value of the Msg entity.
  19400. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  19401. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19402. func (m *MsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  19403. if !m.op.Is(OpUpdateOne) {
  19404. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  19405. }
  19406. if m.id == nil || m.oldValue == nil {
  19407. return v, errors.New("OldMsg requires an ID field in the mutation")
  19408. }
  19409. oldValue, err := m.oldValue(ctx)
  19410. if err != nil {
  19411. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  19412. }
  19413. return oldValue.Msg, nil
  19414. }
  19415. // ClearMsg clears the value of the "msg" field.
  19416. func (m *MsgMutation) ClearMsg() {
  19417. m.msg = nil
  19418. m.clearedFields[msg.FieldMsg] = struct{}{}
  19419. }
  19420. // MsgCleared returns if the "msg" field was cleared in this mutation.
  19421. func (m *MsgMutation) MsgCleared() bool {
  19422. _, ok := m.clearedFields[msg.FieldMsg]
  19423. return ok
  19424. }
  19425. // ResetMsg resets all changes to the "msg" field.
  19426. func (m *MsgMutation) ResetMsg() {
  19427. m.msg = nil
  19428. delete(m.clearedFields, msg.FieldMsg)
  19429. }
  19430. // SetBatchNo sets the "batch_no" field.
  19431. func (m *MsgMutation) SetBatchNo(s string) {
  19432. m.batch_no = &s
  19433. }
  19434. // BatchNo returns the value of the "batch_no" field in the mutation.
  19435. func (m *MsgMutation) BatchNo() (r string, exists bool) {
  19436. v := m.batch_no
  19437. if v == nil {
  19438. return
  19439. }
  19440. return *v, true
  19441. }
  19442. // OldBatchNo returns the old "batch_no" field's value of the Msg entity.
  19443. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  19444. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19445. func (m *MsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  19446. if !m.op.Is(OpUpdateOne) {
  19447. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  19448. }
  19449. if m.id == nil || m.oldValue == nil {
  19450. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  19451. }
  19452. oldValue, err := m.oldValue(ctx)
  19453. if err != nil {
  19454. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  19455. }
  19456. return oldValue.BatchNo, nil
  19457. }
  19458. // ClearBatchNo clears the value of the "batch_no" field.
  19459. func (m *MsgMutation) ClearBatchNo() {
  19460. m.batch_no = nil
  19461. m.clearedFields[msg.FieldBatchNo] = struct{}{}
  19462. }
  19463. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  19464. func (m *MsgMutation) BatchNoCleared() bool {
  19465. _, ok := m.clearedFields[msg.FieldBatchNo]
  19466. return ok
  19467. }
  19468. // ResetBatchNo resets all changes to the "batch_no" field.
  19469. func (m *MsgMutation) ResetBatchNo() {
  19470. m.batch_no = nil
  19471. delete(m.clearedFields, msg.FieldBatchNo)
  19472. }
  19473. // SetCc sets the "cc" field.
  19474. func (m *MsgMutation) SetCc(s string) {
  19475. m.cc = &s
  19476. }
  19477. // Cc returns the value of the "cc" field in the mutation.
  19478. func (m *MsgMutation) Cc() (r string, exists bool) {
  19479. v := m.cc
  19480. if v == nil {
  19481. return
  19482. }
  19483. return *v, true
  19484. }
  19485. // OldCc returns the old "cc" field's value of the Msg entity.
  19486. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  19487. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19488. func (m *MsgMutation) OldCc(ctx context.Context) (v string, err error) {
  19489. if !m.op.Is(OpUpdateOne) {
  19490. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  19491. }
  19492. if m.id == nil || m.oldValue == nil {
  19493. return v, errors.New("OldCc requires an ID field in the mutation")
  19494. }
  19495. oldValue, err := m.oldValue(ctx)
  19496. if err != nil {
  19497. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  19498. }
  19499. return oldValue.Cc, nil
  19500. }
  19501. // ResetCc resets all changes to the "cc" field.
  19502. func (m *MsgMutation) ResetCc() {
  19503. m.cc = nil
  19504. }
  19505. // SetPhone sets the "phone" field.
  19506. func (m *MsgMutation) SetPhone(s string) {
  19507. m.phone = &s
  19508. }
  19509. // Phone returns the value of the "phone" field in the mutation.
  19510. func (m *MsgMutation) Phone() (r string, exists bool) {
  19511. v := m.phone
  19512. if v == nil {
  19513. return
  19514. }
  19515. return *v, true
  19516. }
  19517. // OldPhone returns the old "phone" field's value of the Msg entity.
  19518. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  19519. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19520. func (m *MsgMutation) OldPhone(ctx context.Context) (v string, err error) {
  19521. if !m.op.Is(OpUpdateOne) {
  19522. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  19523. }
  19524. if m.id == nil || m.oldValue == nil {
  19525. return v, errors.New("OldPhone requires an ID field in the mutation")
  19526. }
  19527. oldValue, err := m.oldValue(ctx)
  19528. if err != nil {
  19529. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  19530. }
  19531. return oldValue.Phone, nil
  19532. }
  19533. // ResetPhone resets all changes to the "phone" field.
  19534. func (m *MsgMutation) ResetPhone() {
  19535. m.phone = nil
  19536. }
  19537. // Where appends a list predicates to the MsgMutation builder.
  19538. func (m *MsgMutation) Where(ps ...predicate.Msg) {
  19539. m.predicates = append(m.predicates, ps...)
  19540. }
  19541. // WhereP appends storage-level predicates to the MsgMutation builder. Using this method,
  19542. // users can use type-assertion to append predicates that do not depend on any generated package.
  19543. func (m *MsgMutation) WhereP(ps ...func(*sql.Selector)) {
  19544. p := make([]predicate.Msg, len(ps))
  19545. for i := range ps {
  19546. p[i] = ps[i]
  19547. }
  19548. m.Where(p...)
  19549. }
  19550. // Op returns the operation name.
  19551. func (m *MsgMutation) Op() Op {
  19552. return m.op
  19553. }
  19554. // SetOp allows setting the mutation operation.
  19555. func (m *MsgMutation) SetOp(op Op) {
  19556. m.op = op
  19557. }
  19558. // Type returns the node type of this mutation (Msg).
  19559. func (m *MsgMutation) Type() string {
  19560. return m.typ
  19561. }
  19562. // Fields returns all fields that were changed during this mutation. Note that in
  19563. // order to get all numeric fields that were incremented/decremented, call
  19564. // AddedFields().
  19565. func (m *MsgMutation) Fields() []string {
  19566. fields := make([]string, 0, 11)
  19567. if m.created_at != nil {
  19568. fields = append(fields, msg.FieldCreatedAt)
  19569. }
  19570. if m.updated_at != nil {
  19571. fields = append(fields, msg.FieldUpdatedAt)
  19572. }
  19573. if m.deleted_at != nil {
  19574. fields = append(fields, msg.FieldDeletedAt)
  19575. }
  19576. if m.status != nil {
  19577. fields = append(fields, msg.FieldStatus)
  19578. }
  19579. if m.fromwxid != nil {
  19580. fields = append(fields, msg.FieldFromwxid)
  19581. }
  19582. if m.toid != nil {
  19583. fields = append(fields, msg.FieldToid)
  19584. }
  19585. if m.msgtype != nil {
  19586. fields = append(fields, msg.FieldMsgtype)
  19587. }
  19588. if m.msg != nil {
  19589. fields = append(fields, msg.FieldMsg)
  19590. }
  19591. if m.batch_no != nil {
  19592. fields = append(fields, msg.FieldBatchNo)
  19593. }
  19594. if m.cc != nil {
  19595. fields = append(fields, msg.FieldCc)
  19596. }
  19597. if m.phone != nil {
  19598. fields = append(fields, msg.FieldPhone)
  19599. }
  19600. return fields
  19601. }
  19602. // Field returns the value of a field with the given name. The second boolean
  19603. // return value indicates that this field was not set, or was not defined in the
  19604. // schema.
  19605. func (m *MsgMutation) Field(name string) (ent.Value, bool) {
  19606. switch name {
  19607. case msg.FieldCreatedAt:
  19608. return m.CreatedAt()
  19609. case msg.FieldUpdatedAt:
  19610. return m.UpdatedAt()
  19611. case msg.FieldDeletedAt:
  19612. return m.DeletedAt()
  19613. case msg.FieldStatus:
  19614. return m.Status()
  19615. case msg.FieldFromwxid:
  19616. return m.Fromwxid()
  19617. case msg.FieldToid:
  19618. return m.Toid()
  19619. case msg.FieldMsgtype:
  19620. return m.Msgtype()
  19621. case msg.FieldMsg:
  19622. return m.Msg()
  19623. case msg.FieldBatchNo:
  19624. return m.BatchNo()
  19625. case msg.FieldCc:
  19626. return m.Cc()
  19627. case msg.FieldPhone:
  19628. return m.Phone()
  19629. }
  19630. return nil, false
  19631. }
  19632. // OldField returns the old value of the field from the database. An error is
  19633. // returned if the mutation operation is not UpdateOne, or the query to the
  19634. // database failed.
  19635. func (m *MsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  19636. switch name {
  19637. case msg.FieldCreatedAt:
  19638. return m.OldCreatedAt(ctx)
  19639. case msg.FieldUpdatedAt:
  19640. return m.OldUpdatedAt(ctx)
  19641. case msg.FieldDeletedAt:
  19642. return m.OldDeletedAt(ctx)
  19643. case msg.FieldStatus:
  19644. return m.OldStatus(ctx)
  19645. case msg.FieldFromwxid:
  19646. return m.OldFromwxid(ctx)
  19647. case msg.FieldToid:
  19648. return m.OldToid(ctx)
  19649. case msg.FieldMsgtype:
  19650. return m.OldMsgtype(ctx)
  19651. case msg.FieldMsg:
  19652. return m.OldMsg(ctx)
  19653. case msg.FieldBatchNo:
  19654. return m.OldBatchNo(ctx)
  19655. case msg.FieldCc:
  19656. return m.OldCc(ctx)
  19657. case msg.FieldPhone:
  19658. return m.OldPhone(ctx)
  19659. }
  19660. return nil, fmt.Errorf("unknown Msg field %s", name)
  19661. }
  19662. // SetField sets the value of a field with the given name. It returns an error if
  19663. // the field is not defined in the schema, or if the type mismatched the field
  19664. // type.
  19665. func (m *MsgMutation) SetField(name string, value ent.Value) error {
  19666. switch name {
  19667. case msg.FieldCreatedAt:
  19668. v, ok := value.(time.Time)
  19669. if !ok {
  19670. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19671. }
  19672. m.SetCreatedAt(v)
  19673. return nil
  19674. case msg.FieldUpdatedAt:
  19675. v, ok := value.(time.Time)
  19676. if !ok {
  19677. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19678. }
  19679. m.SetUpdatedAt(v)
  19680. return nil
  19681. case msg.FieldDeletedAt:
  19682. v, ok := value.(time.Time)
  19683. if !ok {
  19684. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19685. }
  19686. m.SetDeletedAt(v)
  19687. return nil
  19688. case msg.FieldStatus:
  19689. v, ok := value.(uint8)
  19690. if !ok {
  19691. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19692. }
  19693. m.SetStatus(v)
  19694. return nil
  19695. case msg.FieldFromwxid:
  19696. v, ok := value.(string)
  19697. if !ok {
  19698. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19699. }
  19700. m.SetFromwxid(v)
  19701. return nil
  19702. case msg.FieldToid:
  19703. v, ok := value.(string)
  19704. if !ok {
  19705. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19706. }
  19707. m.SetToid(v)
  19708. return nil
  19709. case msg.FieldMsgtype:
  19710. v, ok := value.(int32)
  19711. if !ok {
  19712. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19713. }
  19714. m.SetMsgtype(v)
  19715. return nil
  19716. case msg.FieldMsg:
  19717. v, ok := value.(string)
  19718. if !ok {
  19719. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19720. }
  19721. m.SetMsg(v)
  19722. return nil
  19723. case msg.FieldBatchNo:
  19724. v, ok := value.(string)
  19725. if !ok {
  19726. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19727. }
  19728. m.SetBatchNo(v)
  19729. return nil
  19730. case msg.FieldCc:
  19731. v, ok := value.(string)
  19732. if !ok {
  19733. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19734. }
  19735. m.SetCc(v)
  19736. return nil
  19737. case msg.FieldPhone:
  19738. v, ok := value.(string)
  19739. if !ok {
  19740. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19741. }
  19742. m.SetPhone(v)
  19743. return nil
  19744. }
  19745. return fmt.Errorf("unknown Msg field %s", name)
  19746. }
  19747. // AddedFields returns all numeric fields that were incremented/decremented during
  19748. // this mutation.
  19749. func (m *MsgMutation) AddedFields() []string {
  19750. var fields []string
  19751. if m.addstatus != nil {
  19752. fields = append(fields, msg.FieldStatus)
  19753. }
  19754. if m.addmsgtype != nil {
  19755. fields = append(fields, msg.FieldMsgtype)
  19756. }
  19757. return fields
  19758. }
  19759. // AddedField returns the numeric value that was incremented/decremented on a field
  19760. // with the given name. The second boolean return value indicates that this field
  19761. // was not set, or was not defined in the schema.
  19762. func (m *MsgMutation) AddedField(name string) (ent.Value, bool) {
  19763. switch name {
  19764. case msg.FieldStatus:
  19765. return m.AddedStatus()
  19766. case msg.FieldMsgtype:
  19767. return m.AddedMsgtype()
  19768. }
  19769. return nil, false
  19770. }
  19771. // AddField adds the value to the field with the given name. It returns an error if
  19772. // the field is not defined in the schema, or if the type mismatched the field
  19773. // type.
  19774. func (m *MsgMutation) AddField(name string, value ent.Value) error {
  19775. switch name {
  19776. case msg.FieldStatus:
  19777. v, ok := value.(int8)
  19778. if !ok {
  19779. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19780. }
  19781. m.AddStatus(v)
  19782. return nil
  19783. case msg.FieldMsgtype:
  19784. v, ok := value.(int32)
  19785. if !ok {
  19786. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19787. }
  19788. m.AddMsgtype(v)
  19789. return nil
  19790. }
  19791. return fmt.Errorf("unknown Msg numeric field %s", name)
  19792. }
  19793. // ClearedFields returns all nullable fields that were cleared during this
  19794. // mutation.
  19795. func (m *MsgMutation) ClearedFields() []string {
  19796. var fields []string
  19797. if m.FieldCleared(msg.FieldDeletedAt) {
  19798. fields = append(fields, msg.FieldDeletedAt)
  19799. }
  19800. if m.FieldCleared(msg.FieldStatus) {
  19801. fields = append(fields, msg.FieldStatus)
  19802. }
  19803. if m.FieldCleared(msg.FieldFromwxid) {
  19804. fields = append(fields, msg.FieldFromwxid)
  19805. }
  19806. if m.FieldCleared(msg.FieldToid) {
  19807. fields = append(fields, msg.FieldToid)
  19808. }
  19809. if m.FieldCleared(msg.FieldMsgtype) {
  19810. fields = append(fields, msg.FieldMsgtype)
  19811. }
  19812. if m.FieldCleared(msg.FieldMsg) {
  19813. fields = append(fields, msg.FieldMsg)
  19814. }
  19815. if m.FieldCleared(msg.FieldBatchNo) {
  19816. fields = append(fields, msg.FieldBatchNo)
  19817. }
  19818. return fields
  19819. }
  19820. // FieldCleared returns a boolean indicating if a field with the given name was
  19821. // cleared in this mutation.
  19822. func (m *MsgMutation) FieldCleared(name string) bool {
  19823. _, ok := m.clearedFields[name]
  19824. return ok
  19825. }
  19826. // ClearField clears the value of the field with the given name. It returns an
  19827. // error if the field is not defined in the schema.
  19828. func (m *MsgMutation) ClearField(name string) error {
  19829. switch name {
  19830. case msg.FieldDeletedAt:
  19831. m.ClearDeletedAt()
  19832. return nil
  19833. case msg.FieldStatus:
  19834. m.ClearStatus()
  19835. return nil
  19836. case msg.FieldFromwxid:
  19837. m.ClearFromwxid()
  19838. return nil
  19839. case msg.FieldToid:
  19840. m.ClearToid()
  19841. return nil
  19842. case msg.FieldMsgtype:
  19843. m.ClearMsgtype()
  19844. return nil
  19845. case msg.FieldMsg:
  19846. m.ClearMsg()
  19847. return nil
  19848. case msg.FieldBatchNo:
  19849. m.ClearBatchNo()
  19850. return nil
  19851. }
  19852. return fmt.Errorf("unknown Msg nullable field %s", name)
  19853. }
  19854. // ResetField resets all changes in the mutation for the field with the given name.
  19855. // It returns an error if the field is not defined in the schema.
  19856. func (m *MsgMutation) ResetField(name string) error {
  19857. switch name {
  19858. case msg.FieldCreatedAt:
  19859. m.ResetCreatedAt()
  19860. return nil
  19861. case msg.FieldUpdatedAt:
  19862. m.ResetUpdatedAt()
  19863. return nil
  19864. case msg.FieldDeletedAt:
  19865. m.ResetDeletedAt()
  19866. return nil
  19867. case msg.FieldStatus:
  19868. m.ResetStatus()
  19869. return nil
  19870. case msg.FieldFromwxid:
  19871. m.ResetFromwxid()
  19872. return nil
  19873. case msg.FieldToid:
  19874. m.ResetToid()
  19875. return nil
  19876. case msg.FieldMsgtype:
  19877. m.ResetMsgtype()
  19878. return nil
  19879. case msg.FieldMsg:
  19880. m.ResetMsg()
  19881. return nil
  19882. case msg.FieldBatchNo:
  19883. m.ResetBatchNo()
  19884. return nil
  19885. case msg.FieldCc:
  19886. m.ResetCc()
  19887. return nil
  19888. case msg.FieldPhone:
  19889. m.ResetPhone()
  19890. return nil
  19891. }
  19892. return fmt.Errorf("unknown Msg field %s", name)
  19893. }
  19894. // AddedEdges returns all edge names that were set/added in this mutation.
  19895. func (m *MsgMutation) AddedEdges() []string {
  19896. edges := make([]string, 0, 0)
  19897. return edges
  19898. }
  19899. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  19900. // name in this mutation.
  19901. func (m *MsgMutation) AddedIDs(name string) []ent.Value {
  19902. return nil
  19903. }
  19904. // RemovedEdges returns all edge names that were removed in this mutation.
  19905. func (m *MsgMutation) RemovedEdges() []string {
  19906. edges := make([]string, 0, 0)
  19907. return edges
  19908. }
  19909. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  19910. // the given name in this mutation.
  19911. func (m *MsgMutation) RemovedIDs(name string) []ent.Value {
  19912. return nil
  19913. }
  19914. // ClearedEdges returns all edge names that were cleared in this mutation.
  19915. func (m *MsgMutation) ClearedEdges() []string {
  19916. edges := make([]string, 0, 0)
  19917. return edges
  19918. }
  19919. // EdgeCleared returns a boolean which indicates if the edge with the given name
  19920. // was cleared in this mutation.
  19921. func (m *MsgMutation) EdgeCleared(name string) bool {
  19922. return false
  19923. }
  19924. // ClearEdge clears the value of the edge with the given name. It returns an error
  19925. // if that edge is not defined in the schema.
  19926. func (m *MsgMutation) ClearEdge(name string) error {
  19927. return fmt.Errorf("unknown Msg unique edge %s", name)
  19928. }
  19929. // ResetEdge resets all changes to the edge with the given name in this mutation.
  19930. // It returns an error if the edge is not defined in the schema.
  19931. func (m *MsgMutation) ResetEdge(name string) error {
  19932. return fmt.Errorf("unknown Msg edge %s", name)
  19933. }
  19934. // PayRechargeMutation represents an operation that mutates the PayRecharge nodes in the graph.
  19935. type PayRechargeMutation struct {
  19936. config
  19937. op Op
  19938. typ string
  19939. id *uint64
  19940. created_at *time.Time
  19941. updated_at *time.Time
  19942. deleted_at *time.Time
  19943. user_id *string
  19944. number *float32
  19945. addnumber *float32
  19946. status *int
  19947. addstatus *int
  19948. money *float32
  19949. addmoney *float32
  19950. out_trade_no *string
  19951. organization_id *uint64
  19952. addorganization_id *int64
  19953. clearedFields map[string]struct{}
  19954. done bool
  19955. oldValue func(context.Context) (*PayRecharge, error)
  19956. predicates []predicate.PayRecharge
  19957. }
  19958. var _ ent.Mutation = (*PayRechargeMutation)(nil)
  19959. // payrechargeOption allows management of the mutation configuration using functional options.
  19960. type payrechargeOption func(*PayRechargeMutation)
  19961. // newPayRechargeMutation creates new mutation for the PayRecharge entity.
  19962. func newPayRechargeMutation(c config, op Op, opts ...payrechargeOption) *PayRechargeMutation {
  19963. m := &PayRechargeMutation{
  19964. config: c,
  19965. op: op,
  19966. typ: TypePayRecharge,
  19967. clearedFields: make(map[string]struct{}),
  19968. }
  19969. for _, opt := range opts {
  19970. opt(m)
  19971. }
  19972. return m
  19973. }
  19974. // withPayRechargeID sets the ID field of the mutation.
  19975. func withPayRechargeID(id uint64) payrechargeOption {
  19976. return func(m *PayRechargeMutation) {
  19977. var (
  19978. err error
  19979. once sync.Once
  19980. value *PayRecharge
  19981. )
  19982. m.oldValue = func(ctx context.Context) (*PayRecharge, error) {
  19983. once.Do(func() {
  19984. if m.done {
  19985. err = errors.New("querying old values post mutation is not allowed")
  19986. } else {
  19987. value, err = m.Client().PayRecharge.Get(ctx, id)
  19988. }
  19989. })
  19990. return value, err
  19991. }
  19992. m.id = &id
  19993. }
  19994. }
  19995. // withPayRecharge sets the old PayRecharge of the mutation.
  19996. func withPayRecharge(node *PayRecharge) payrechargeOption {
  19997. return func(m *PayRechargeMutation) {
  19998. m.oldValue = func(context.Context) (*PayRecharge, error) {
  19999. return node, nil
  20000. }
  20001. m.id = &node.ID
  20002. }
  20003. }
  20004. // Client returns a new `ent.Client` from the mutation. If the mutation was
  20005. // executed in a transaction (ent.Tx), a transactional client is returned.
  20006. func (m PayRechargeMutation) Client() *Client {
  20007. client := &Client{config: m.config}
  20008. client.init()
  20009. return client
  20010. }
  20011. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  20012. // it returns an error otherwise.
  20013. func (m PayRechargeMutation) Tx() (*Tx, error) {
  20014. if _, ok := m.driver.(*txDriver); !ok {
  20015. return nil, errors.New("ent: mutation is not running in a transaction")
  20016. }
  20017. tx := &Tx{config: m.config}
  20018. tx.init()
  20019. return tx, nil
  20020. }
  20021. // SetID sets the value of the id field. Note that this
  20022. // operation is only accepted on creation of PayRecharge entities.
  20023. func (m *PayRechargeMutation) SetID(id uint64) {
  20024. m.id = &id
  20025. }
  20026. // ID returns the ID value in the mutation. Note that the ID is only available
  20027. // if it was provided to the builder or after it was returned from the database.
  20028. func (m *PayRechargeMutation) ID() (id uint64, exists bool) {
  20029. if m.id == nil {
  20030. return
  20031. }
  20032. return *m.id, true
  20033. }
  20034. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  20035. // That means, if the mutation is applied within a transaction with an isolation level such
  20036. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  20037. // or updated by the mutation.
  20038. func (m *PayRechargeMutation) IDs(ctx context.Context) ([]uint64, error) {
  20039. switch {
  20040. case m.op.Is(OpUpdateOne | OpDeleteOne):
  20041. id, exists := m.ID()
  20042. if exists {
  20043. return []uint64{id}, nil
  20044. }
  20045. fallthrough
  20046. case m.op.Is(OpUpdate | OpDelete):
  20047. return m.Client().PayRecharge.Query().Where(m.predicates...).IDs(ctx)
  20048. default:
  20049. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  20050. }
  20051. }
  20052. // SetCreatedAt sets the "created_at" field.
  20053. func (m *PayRechargeMutation) SetCreatedAt(t time.Time) {
  20054. m.created_at = &t
  20055. }
  20056. // CreatedAt returns the value of the "created_at" field in the mutation.
  20057. func (m *PayRechargeMutation) CreatedAt() (r time.Time, exists bool) {
  20058. v := m.created_at
  20059. if v == nil {
  20060. return
  20061. }
  20062. return *v, true
  20063. }
  20064. // OldCreatedAt returns the old "created_at" field's value of the PayRecharge entity.
  20065. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  20066. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20067. func (m *PayRechargeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  20068. if !m.op.Is(OpUpdateOne) {
  20069. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  20070. }
  20071. if m.id == nil || m.oldValue == nil {
  20072. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  20073. }
  20074. oldValue, err := m.oldValue(ctx)
  20075. if err != nil {
  20076. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  20077. }
  20078. return oldValue.CreatedAt, nil
  20079. }
  20080. // ResetCreatedAt resets all changes to the "created_at" field.
  20081. func (m *PayRechargeMutation) ResetCreatedAt() {
  20082. m.created_at = nil
  20083. }
  20084. // SetUpdatedAt sets the "updated_at" field.
  20085. func (m *PayRechargeMutation) SetUpdatedAt(t time.Time) {
  20086. m.updated_at = &t
  20087. }
  20088. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  20089. func (m *PayRechargeMutation) UpdatedAt() (r time.Time, exists bool) {
  20090. v := m.updated_at
  20091. if v == nil {
  20092. return
  20093. }
  20094. return *v, true
  20095. }
  20096. // OldUpdatedAt returns the old "updated_at" field's value of the PayRecharge entity.
  20097. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  20098. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20099. func (m *PayRechargeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  20100. if !m.op.Is(OpUpdateOne) {
  20101. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  20102. }
  20103. if m.id == nil || m.oldValue == nil {
  20104. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  20105. }
  20106. oldValue, err := m.oldValue(ctx)
  20107. if err != nil {
  20108. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  20109. }
  20110. return oldValue.UpdatedAt, nil
  20111. }
  20112. // ResetUpdatedAt resets all changes to the "updated_at" field.
  20113. func (m *PayRechargeMutation) ResetUpdatedAt() {
  20114. m.updated_at = nil
  20115. }
  20116. // SetDeletedAt sets the "deleted_at" field.
  20117. func (m *PayRechargeMutation) SetDeletedAt(t time.Time) {
  20118. m.deleted_at = &t
  20119. }
  20120. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  20121. func (m *PayRechargeMutation) DeletedAt() (r time.Time, exists bool) {
  20122. v := m.deleted_at
  20123. if v == nil {
  20124. return
  20125. }
  20126. return *v, true
  20127. }
  20128. // OldDeletedAt returns the old "deleted_at" field's value of the PayRecharge entity.
  20129. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  20130. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20131. func (m *PayRechargeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  20132. if !m.op.Is(OpUpdateOne) {
  20133. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  20134. }
  20135. if m.id == nil || m.oldValue == nil {
  20136. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  20137. }
  20138. oldValue, err := m.oldValue(ctx)
  20139. if err != nil {
  20140. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  20141. }
  20142. return oldValue.DeletedAt, nil
  20143. }
  20144. // ClearDeletedAt clears the value of the "deleted_at" field.
  20145. func (m *PayRechargeMutation) ClearDeletedAt() {
  20146. m.deleted_at = nil
  20147. m.clearedFields[payrecharge.FieldDeletedAt] = struct{}{}
  20148. }
  20149. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  20150. func (m *PayRechargeMutation) DeletedAtCleared() bool {
  20151. _, ok := m.clearedFields[payrecharge.FieldDeletedAt]
  20152. return ok
  20153. }
  20154. // ResetDeletedAt resets all changes to the "deleted_at" field.
  20155. func (m *PayRechargeMutation) ResetDeletedAt() {
  20156. m.deleted_at = nil
  20157. delete(m.clearedFields, payrecharge.FieldDeletedAt)
  20158. }
  20159. // SetUserID sets the "user_id" field.
  20160. func (m *PayRechargeMutation) SetUserID(s string) {
  20161. m.user_id = &s
  20162. }
  20163. // UserID returns the value of the "user_id" field in the mutation.
  20164. func (m *PayRechargeMutation) UserID() (r string, exists bool) {
  20165. v := m.user_id
  20166. if v == nil {
  20167. return
  20168. }
  20169. return *v, true
  20170. }
  20171. // OldUserID returns the old "user_id" field's value of the PayRecharge entity.
  20172. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  20173. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20174. func (m *PayRechargeMutation) OldUserID(ctx context.Context) (v string, err error) {
  20175. if !m.op.Is(OpUpdateOne) {
  20176. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  20177. }
  20178. if m.id == nil || m.oldValue == nil {
  20179. return v, errors.New("OldUserID requires an ID field in the mutation")
  20180. }
  20181. oldValue, err := m.oldValue(ctx)
  20182. if err != nil {
  20183. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  20184. }
  20185. return oldValue.UserID, nil
  20186. }
  20187. // ResetUserID resets all changes to the "user_id" field.
  20188. func (m *PayRechargeMutation) ResetUserID() {
  20189. m.user_id = nil
  20190. }
  20191. // SetNumber sets the "number" field.
  20192. func (m *PayRechargeMutation) SetNumber(f float32) {
  20193. m.number = &f
  20194. m.addnumber = nil
  20195. }
  20196. // Number returns the value of the "number" field in the mutation.
  20197. func (m *PayRechargeMutation) Number() (r float32, exists bool) {
  20198. v := m.number
  20199. if v == nil {
  20200. return
  20201. }
  20202. return *v, true
  20203. }
  20204. // OldNumber returns the old "number" field's value of the PayRecharge entity.
  20205. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  20206. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20207. func (m *PayRechargeMutation) OldNumber(ctx context.Context) (v float32, err error) {
  20208. if !m.op.Is(OpUpdateOne) {
  20209. return v, errors.New("OldNumber is only allowed on UpdateOne operations")
  20210. }
  20211. if m.id == nil || m.oldValue == nil {
  20212. return v, errors.New("OldNumber requires an ID field in the mutation")
  20213. }
  20214. oldValue, err := m.oldValue(ctx)
  20215. if err != nil {
  20216. return v, fmt.Errorf("querying old value for OldNumber: %w", err)
  20217. }
  20218. return oldValue.Number, nil
  20219. }
  20220. // AddNumber adds f to the "number" field.
  20221. func (m *PayRechargeMutation) AddNumber(f float32) {
  20222. if m.addnumber != nil {
  20223. *m.addnumber += f
  20224. } else {
  20225. m.addnumber = &f
  20226. }
  20227. }
  20228. // AddedNumber returns the value that was added to the "number" field in this mutation.
  20229. func (m *PayRechargeMutation) AddedNumber() (r float32, exists bool) {
  20230. v := m.addnumber
  20231. if v == nil {
  20232. return
  20233. }
  20234. return *v, true
  20235. }
  20236. // ResetNumber resets all changes to the "number" field.
  20237. func (m *PayRechargeMutation) ResetNumber() {
  20238. m.number = nil
  20239. m.addnumber = nil
  20240. }
  20241. // SetStatus sets the "status" field.
  20242. func (m *PayRechargeMutation) SetStatus(i int) {
  20243. m.status = &i
  20244. m.addstatus = nil
  20245. }
  20246. // Status returns the value of the "status" field in the mutation.
  20247. func (m *PayRechargeMutation) Status() (r int, exists bool) {
  20248. v := m.status
  20249. if v == nil {
  20250. return
  20251. }
  20252. return *v, true
  20253. }
  20254. // OldStatus returns the old "status" field's value of the PayRecharge entity.
  20255. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  20256. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20257. func (m *PayRechargeMutation) OldStatus(ctx context.Context) (v int, err error) {
  20258. if !m.op.Is(OpUpdateOne) {
  20259. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  20260. }
  20261. if m.id == nil || m.oldValue == nil {
  20262. return v, errors.New("OldStatus requires an ID field in the mutation")
  20263. }
  20264. oldValue, err := m.oldValue(ctx)
  20265. if err != nil {
  20266. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  20267. }
  20268. return oldValue.Status, nil
  20269. }
  20270. // AddStatus adds i to the "status" field.
  20271. func (m *PayRechargeMutation) AddStatus(i int) {
  20272. if m.addstatus != nil {
  20273. *m.addstatus += i
  20274. } else {
  20275. m.addstatus = &i
  20276. }
  20277. }
  20278. // AddedStatus returns the value that was added to the "status" field in this mutation.
  20279. func (m *PayRechargeMutation) AddedStatus() (r int, exists bool) {
  20280. v := m.addstatus
  20281. if v == nil {
  20282. return
  20283. }
  20284. return *v, true
  20285. }
  20286. // ClearStatus clears the value of the "status" field.
  20287. func (m *PayRechargeMutation) ClearStatus() {
  20288. m.status = nil
  20289. m.addstatus = nil
  20290. m.clearedFields[payrecharge.FieldStatus] = struct{}{}
  20291. }
  20292. // StatusCleared returns if the "status" field was cleared in this mutation.
  20293. func (m *PayRechargeMutation) StatusCleared() bool {
  20294. _, ok := m.clearedFields[payrecharge.FieldStatus]
  20295. return ok
  20296. }
  20297. // ResetStatus resets all changes to the "status" field.
  20298. func (m *PayRechargeMutation) ResetStatus() {
  20299. m.status = nil
  20300. m.addstatus = nil
  20301. delete(m.clearedFields, payrecharge.FieldStatus)
  20302. }
  20303. // SetMoney sets the "money" field.
  20304. func (m *PayRechargeMutation) SetMoney(f float32) {
  20305. m.money = &f
  20306. m.addmoney = nil
  20307. }
  20308. // Money returns the value of the "money" field in the mutation.
  20309. func (m *PayRechargeMutation) Money() (r float32, exists bool) {
  20310. v := m.money
  20311. if v == nil {
  20312. return
  20313. }
  20314. return *v, true
  20315. }
  20316. // OldMoney returns the old "money" field's value of the PayRecharge entity.
  20317. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  20318. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20319. func (m *PayRechargeMutation) OldMoney(ctx context.Context) (v float32, err error) {
  20320. if !m.op.Is(OpUpdateOne) {
  20321. return v, errors.New("OldMoney is only allowed on UpdateOne operations")
  20322. }
  20323. if m.id == nil || m.oldValue == nil {
  20324. return v, errors.New("OldMoney requires an ID field in the mutation")
  20325. }
  20326. oldValue, err := m.oldValue(ctx)
  20327. if err != nil {
  20328. return v, fmt.Errorf("querying old value for OldMoney: %w", err)
  20329. }
  20330. return oldValue.Money, nil
  20331. }
  20332. // AddMoney adds f to the "money" field.
  20333. func (m *PayRechargeMutation) AddMoney(f float32) {
  20334. if m.addmoney != nil {
  20335. *m.addmoney += f
  20336. } else {
  20337. m.addmoney = &f
  20338. }
  20339. }
  20340. // AddedMoney returns the value that was added to the "money" field in this mutation.
  20341. func (m *PayRechargeMutation) AddedMoney() (r float32, exists bool) {
  20342. v := m.addmoney
  20343. if v == nil {
  20344. return
  20345. }
  20346. return *v, true
  20347. }
  20348. // ClearMoney clears the value of the "money" field.
  20349. func (m *PayRechargeMutation) ClearMoney() {
  20350. m.money = nil
  20351. m.addmoney = nil
  20352. m.clearedFields[payrecharge.FieldMoney] = struct{}{}
  20353. }
  20354. // MoneyCleared returns if the "money" field was cleared in this mutation.
  20355. func (m *PayRechargeMutation) MoneyCleared() bool {
  20356. _, ok := m.clearedFields[payrecharge.FieldMoney]
  20357. return ok
  20358. }
  20359. // ResetMoney resets all changes to the "money" field.
  20360. func (m *PayRechargeMutation) ResetMoney() {
  20361. m.money = nil
  20362. m.addmoney = nil
  20363. delete(m.clearedFields, payrecharge.FieldMoney)
  20364. }
  20365. // SetOutTradeNo sets the "out_trade_no" field.
  20366. func (m *PayRechargeMutation) SetOutTradeNo(s string) {
  20367. m.out_trade_no = &s
  20368. }
  20369. // OutTradeNo returns the value of the "out_trade_no" field in the mutation.
  20370. func (m *PayRechargeMutation) OutTradeNo() (r string, exists bool) {
  20371. v := m.out_trade_no
  20372. if v == nil {
  20373. return
  20374. }
  20375. return *v, true
  20376. }
  20377. // OldOutTradeNo returns the old "out_trade_no" field's value of the PayRecharge entity.
  20378. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  20379. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20380. func (m *PayRechargeMutation) OldOutTradeNo(ctx context.Context) (v string, err error) {
  20381. if !m.op.Is(OpUpdateOne) {
  20382. return v, errors.New("OldOutTradeNo is only allowed on UpdateOne operations")
  20383. }
  20384. if m.id == nil || m.oldValue == nil {
  20385. return v, errors.New("OldOutTradeNo requires an ID field in the mutation")
  20386. }
  20387. oldValue, err := m.oldValue(ctx)
  20388. if err != nil {
  20389. return v, fmt.Errorf("querying old value for OldOutTradeNo: %w", err)
  20390. }
  20391. return oldValue.OutTradeNo, nil
  20392. }
  20393. // ClearOutTradeNo clears the value of the "out_trade_no" field.
  20394. func (m *PayRechargeMutation) ClearOutTradeNo() {
  20395. m.out_trade_no = nil
  20396. m.clearedFields[payrecharge.FieldOutTradeNo] = struct{}{}
  20397. }
  20398. // OutTradeNoCleared returns if the "out_trade_no" field was cleared in this mutation.
  20399. func (m *PayRechargeMutation) OutTradeNoCleared() bool {
  20400. _, ok := m.clearedFields[payrecharge.FieldOutTradeNo]
  20401. return ok
  20402. }
  20403. // ResetOutTradeNo resets all changes to the "out_trade_no" field.
  20404. func (m *PayRechargeMutation) ResetOutTradeNo() {
  20405. m.out_trade_no = nil
  20406. delete(m.clearedFields, payrecharge.FieldOutTradeNo)
  20407. }
  20408. // SetOrganizationID sets the "organization_id" field.
  20409. func (m *PayRechargeMutation) SetOrganizationID(u uint64) {
  20410. m.organization_id = &u
  20411. m.addorganization_id = nil
  20412. }
  20413. // OrganizationID returns the value of the "organization_id" field in the mutation.
  20414. func (m *PayRechargeMutation) OrganizationID() (r uint64, exists bool) {
  20415. v := m.organization_id
  20416. if v == nil {
  20417. return
  20418. }
  20419. return *v, true
  20420. }
  20421. // OldOrganizationID returns the old "organization_id" field's value of the PayRecharge entity.
  20422. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  20423. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20424. func (m *PayRechargeMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  20425. if !m.op.Is(OpUpdateOne) {
  20426. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  20427. }
  20428. if m.id == nil || m.oldValue == nil {
  20429. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  20430. }
  20431. oldValue, err := m.oldValue(ctx)
  20432. if err != nil {
  20433. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  20434. }
  20435. return oldValue.OrganizationID, nil
  20436. }
  20437. // AddOrganizationID adds u to the "organization_id" field.
  20438. func (m *PayRechargeMutation) AddOrganizationID(u int64) {
  20439. if m.addorganization_id != nil {
  20440. *m.addorganization_id += u
  20441. } else {
  20442. m.addorganization_id = &u
  20443. }
  20444. }
  20445. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  20446. func (m *PayRechargeMutation) AddedOrganizationID() (r int64, exists bool) {
  20447. v := m.addorganization_id
  20448. if v == nil {
  20449. return
  20450. }
  20451. return *v, true
  20452. }
  20453. // ResetOrganizationID resets all changes to the "organization_id" field.
  20454. func (m *PayRechargeMutation) ResetOrganizationID() {
  20455. m.organization_id = nil
  20456. m.addorganization_id = nil
  20457. }
  20458. // Where appends a list predicates to the PayRechargeMutation builder.
  20459. func (m *PayRechargeMutation) Where(ps ...predicate.PayRecharge) {
  20460. m.predicates = append(m.predicates, ps...)
  20461. }
  20462. // WhereP appends storage-level predicates to the PayRechargeMutation builder. Using this method,
  20463. // users can use type-assertion to append predicates that do not depend on any generated package.
  20464. func (m *PayRechargeMutation) WhereP(ps ...func(*sql.Selector)) {
  20465. p := make([]predicate.PayRecharge, len(ps))
  20466. for i := range ps {
  20467. p[i] = ps[i]
  20468. }
  20469. m.Where(p...)
  20470. }
  20471. // Op returns the operation name.
  20472. func (m *PayRechargeMutation) Op() Op {
  20473. return m.op
  20474. }
  20475. // SetOp allows setting the mutation operation.
  20476. func (m *PayRechargeMutation) SetOp(op Op) {
  20477. m.op = op
  20478. }
  20479. // Type returns the node type of this mutation (PayRecharge).
  20480. func (m *PayRechargeMutation) Type() string {
  20481. return m.typ
  20482. }
  20483. // Fields returns all fields that were changed during this mutation. Note that in
  20484. // order to get all numeric fields that were incremented/decremented, call
  20485. // AddedFields().
  20486. func (m *PayRechargeMutation) Fields() []string {
  20487. fields := make([]string, 0, 9)
  20488. if m.created_at != nil {
  20489. fields = append(fields, payrecharge.FieldCreatedAt)
  20490. }
  20491. if m.updated_at != nil {
  20492. fields = append(fields, payrecharge.FieldUpdatedAt)
  20493. }
  20494. if m.deleted_at != nil {
  20495. fields = append(fields, payrecharge.FieldDeletedAt)
  20496. }
  20497. if m.user_id != nil {
  20498. fields = append(fields, payrecharge.FieldUserID)
  20499. }
  20500. if m.number != nil {
  20501. fields = append(fields, payrecharge.FieldNumber)
  20502. }
  20503. if m.status != nil {
  20504. fields = append(fields, payrecharge.FieldStatus)
  20505. }
  20506. if m.money != nil {
  20507. fields = append(fields, payrecharge.FieldMoney)
  20508. }
  20509. if m.out_trade_no != nil {
  20510. fields = append(fields, payrecharge.FieldOutTradeNo)
  20511. }
  20512. if m.organization_id != nil {
  20513. fields = append(fields, payrecharge.FieldOrganizationID)
  20514. }
  20515. return fields
  20516. }
  20517. // Field returns the value of a field with the given name. The second boolean
  20518. // return value indicates that this field was not set, or was not defined in the
  20519. // schema.
  20520. func (m *PayRechargeMutation) Field(name string) (ent.Value, bool) {
  20521. switch name {
  20522. case payrecharge.FieldCreatedAt:
  20523. return m.CreatedAt()
  20524. case payrecharge.FieldUpdatedAt:
  20525. return m.UpdatedAt()
  20526. case payrecharge.FieldDeletedAt:
  20527. return m.DeletedAt()
  20528. case payrecharge.FieldUserID:
  20529. return m.UserID()
  20530. case payrecharge.FieldNumber:
  20531. return m.Number()
  20532. case payrecharge.FieldStatus:
  20533. return m.Status()
  20534. case payrecharge.FieldMoney:
  20535. return m.Money()
  20536. case payrecharge.FieldOutTradeNo:
  20537. return m.OutTradeNo()
  20538. case payrecharge.FieldOrganizationID:
  20539. return m.OrganizationID()
  20540. }
  20541. return nil, false
  20542. }
  20543. // OldField returns the old value of the field from the database. An error is
  20544. // returned if the mutation operation is not UpdateOne, or the query to the
  20545. // database failed.
  20546. func (m *PayRechargeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  20547. switch name {
  20548. case payrecharge.FieldCreatedAt:
  20549. return m.OldCreatedAt(ctx)
  20550. case payrecharge.FieldUpdatedAt:
  20551. return m.OldUpdatedAt(ctx)
  20552. case payrecharge.FieldDeletedAt:
  20553. return m.OldDeletedAt(ctx)
  20554. case payrecharge.FieldUserID:
  20555. return m.OldUserID(ctx)
  20556. case payrecharge.FieldNumber:
  20557. return m.OldNumber(ctx)
  20558. case payrecharge.FieldStatus:
  20559. return m.OldStatus(ctx)
  20560. case payrecharge.FieldMoney:
  20561. return m.OldMoney(ctx)
  20562. case payrecharge.FieldOutTradeNo:
  20563. return m.OldOutTradeNo(ctx)
  20564. case payrecharge.FieldOrganizationID:
  20565. return m.OldOrganizationID(ctx)
  20566. }
  20567. return nil, fmt.Errorf("unknown PayRecharge field %s", name)
  20568. }
  20569. // SetField sets the value of a field with the given name. It returns an error if
  20570. // the field is not defined in the schema, or if the type mismatched the field
  20571. // type.
  20572. func (m *PayRechargeMutation) SetField(name string, value ent.Value) error {
  20573. switch name {
  20574. case payrecharge.FieldCreatedAt:
  20575. v, ok := value.(time.Time)
  20576. if !ok {
  20577. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20578. }
  20579. m.SetCreatedAt(v)
  20580. return nil
  20581. case payrecharge.FieldUpdatedAt:
  20582. v, ok := value.(time.Time)
  20583. if !ok {
  20584. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20585. }
  20586. m.SetUpdatedAt(v)
  20587. return nil
  20588. case payrecharge.FieldDeletedAt:
  20589. v, ok := value.(time.Time)
  20590. if !ok {
  20591. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20592. }
  20593. m.SetDeletedAt(v)
  20594. return nil
  20595. case payrecharge.FieldUserID:
  20596. v, ok := value.(string)
  20597. if !ok {
  20598. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20599. }
  20600. m.SetUserID(v)
  20601. return nil
  20602. case payrecharge.FieldNumber:
  20603. v, ok := value.(float32)
  20604. if !ok {
  20605. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20606. }
  20607. m.SetNumber(v)
  20608. return nil
  20609. case payrecharge.FieldStatus:
  20610. v, ok := value.(int)
  20611. if !ok {
  20612. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20613. }
  20614. m.SetStatus(v)
  20615. return nil
  20616. case payrecharge.FieldMoney:
  20617. v, ok := value.(float32)
  20618. if !ok {
  20619. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20620. }
  20621. m.SetMoney(v)
  20622. return nil
  20623. case payrecharge.FieldOutTradeNo:
  20624. v, ok := value.(string)
  20625. if !ok {
  20626. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20627. }
  20628. m.SetOutTradeNo(v)
  20629. return nil
  20630. case payrecharge.FieldOrganizationID:
  20631. v, ok := value.(uint64)
  20632. if !ok {
  20633. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20634. }
  20635. m.SetOrganizationID(v)
  20636. return nil
  20637. }
  20638. return fmt.Errorf("unknown PayRecharge field %s", name)
  20639. }
  20640. // AddedFields returns all numeric fields that were incremented/decremented during
  20641. // this mutation.
  20642. func (m *PayRechargeMutation) AddedFields() []string {
  20643. var fields []string
  20644. if m.addnumber != nil {
  20645. fields = append(fields, payrecharge.FieldNumber)
  20646. }
  20647. if m.addstatus != nil {
  20648. fields = append(fields, payrecharge.FieldStatus)
  20649. }
  20650. if m.addmoney != nil {
  20651. fields = append(fields, payrecharge.FieldMoney)
  20652. }
  20653. if m.addorganization_id != nil {
  20654. fields = append(fields, payrecharge.FieldOrganizationID)
  20655. }
  20656. return fields
  20657. }
  20658. // AddedField returns the numeric value that was incremented/decremented on a field
  20659. // with the given name. The second boolean return value indicates that this field
  20660. // was not set, or was not defined in the schema.
  20661. func (m *PayRechargeMutation) AddedField(name string) (ent.Value, bool) {
  20662. switch name {
  20663. case payrecharge.FieldNumber:
  20664. return m.AddedNumber()
  20665. case payrecharge.FieldStatus:
  20666. return m.AddedStatus()
  20667. case payrecharge.FieldMoney:
  20668. return m.AddedMoney()
  20669. case payrecharge.FieldOrganizationID:
  20670. return m.AddedOrganizationID()
  20671. }
  20672. return nil, false
  20673. }
  20674. // AddField adds the value to the field with the given name. It returns an error if
  20675. // the field is not defined in the schema, or if the type mismatched the field
  20676. // type.
  20677. func (m *PayRechargeMutation) AddField(name string, value ent.Value) error {
  20678. switch name {
  20679. case payrecharge.FieldNumber:
  20680. v, ok := value.(float32)
  20681. if !ok {
  20682. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20683. }
  20684. m.AddNumber(v)
  20685. return nil
  20686. case payrecharge.FieldStatus:
  20687. v, ok := value.(int)
  20688. if !ok {
  20689. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20690. }
  20691. m.AddStatus(v)
  20692. return nil
  20693. case payrecharge.FieldMoney:
  20694. v, ok := value.(float32)
  20695. if !ok {
  20696. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20697. }
  20698. m.AddMoney(v)
  20699. return nil
  20700. case payrecharge.FieldOrganizationID:
  20701. v, ok := value.(int64)
  20702. if !ok {
  20703. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20704. }
  20705. m.AddOrganizationID(v)
  20706. return nil
  20707. }
  20708. return fmt.Errorf("unknown PayRecharge numeric field %s", name)
  20709. }
  20710. // ClearedFields returns all nullable fields that were cleared during this
  20711. // mutation.
  20712. func (m *PayRechargeMutation) ClearedFields() []string {
  20713. var fields []string
  20714. if m.FieldCleared(payrecharge.FieldDeletedAt) {
  20715. fields = append(fields, payrecharge.FieldDeletedAt)
  20716. }
  20717. if m.FieldCleared(payrecharge.FieldStatus) {
  20718. fields = append(fields, payrecharge.FieldStatus)
  20719. }
  20720. if m.FieldCleared(payrecharge.FieldMoney) {
  20721. fields = append(fields, payrecharge.FieldMoney)
  20722. }
  20723. if m.FieldCleared(payrecharge.FieldOutTradeNo) {
  20724. fields = append(fields, payrecharge.FieldOutTradeNo)
  20725. }
  20726. return fields
  20727. }
  20728. // FieldCleared returns a boolean indicating if a field with the given name was
  20729. // cleared in this mutation.
  20730. func (m *PayRechargeMutation) FieldCleared(name string) bool {
  20731. _, ok := m.clearedFields[name]
  20732. return ok
  20733. }
  20734. // ClearField clears the value of the field with the given name. It returns an
  20735. // error if the field is not defined in the schema.
  20736. func (m *PayRechargeMutation) ClearField(name string) error {
  20737. switch name {
  20738. case payrecharge.FieldDeletedAt:
  20739. m.ClearDeletedAt()
  20740. return nil
  20741. case payrecharge.FieldStatus:
  20742. m.ClearStatus()
  20743. return nil
  20744. case payrecharge.FieldMoney:
  20745. m.ClearMoney()
  20746. return nil
  20747. case payrecharge.FieldOutTradeNo:
  20748. m.ClearOutTradeNo()
  20749. return nil
  20750. }
  20751. return fmt.Errorf("unknown PayRecharge nullable field %s", name)
  20752. }
  20753. // ResetField resets all changes in the mutation for the field with the given name.
  20754. // It returns an error if the field is not defined in the schema.
  20755. func (m *PayRechargeMutation) ResetField(name string) error {
  20756. switch name {
  20757. case payrecharge.FieldCreatedAt:
  20758. m.ResetCreatedAt()
  20759. return nil
  20760. case payrecharge.FieldUpdatedAt:
  20761. m.ResetUpdatedAt()
  20762. return nil
  20763. case payrecharge.FieldDeletedAt:
  20764. m.ResetDeletedAt()
  20765. return nil
  20766. case payrecharge.FieldUserID:
  20767. m.ResetUserID()
  20768. return nil
  20769. case payrecharge.FieldNumber:
  20770. m.ResetNumber()
  20771. return nil
  20772. case payrecharge.FieldStatus:
  20773. m.ResetStatus()
  20774. return nil
  20775. case payrecharge.FieldMoney:
  20776. m.ResetMoney()
  20777. return nil
  20778. case payrecharge.FieldOutTradeNo:
  20779. m.ResetOutTradeNo()
  20780. return nil
  20781. case payrecharge.FieldOrganizationID:
  20782. m.ResetOrganizationID()
  20783. return nil
  20784. }
  20785. return fmt.Errorf("unknown PayRecharge field %s", name)
  20786. }
  20787. // AddedEdges returns all edge names that were set/added in this mutation.
  20788. func (m *PayRechargeMutation) AddedEdges() []string {
  20789. edges := make([]string, 0, 0)
  20790. return edges
  20791. }
  20792. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  20793. // name in this mutation.
  20794. func (m *PayRechargeMutation) AddedIDs(name string) []ent.Value {
  20795. return nil
  20796. }
  20797. // RemovedEdges returns all edge names that were removed in this mutation.
  20798. func (m *PayRechargeMutation) RemovedEdges() []string {
  20799. edges := make([]string, 0, 0)
  20800. return edges
  20801. }
  20802. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  20803. // the given name in this mutation.
  20804. func (m *PayRechargeMutation) RemovedIDs(name string) []ent.Value {
  20805. return nil
  20806. }
  20807. // ClearedEdges returns all edge names that were cleared in this mutation.
  20808. func (m *PayRechargeMutation) ClearedEdges() []string {
  20809. edges := make([]string, 0, 0)
  20810. return edges
  20811. }
  20812. // EdgeCleared returns a boolean which indicates if the edge with the given name
  20813. // was cleared in this mutation.
  20814. func (m *PayRechargeMutation) EdgeCleared(name string) bool {
  20815. return false
  20816. }
  20817. // ClearEdge clears the value of the edge with the given name. It returns an error
  20818. // if that edge is not defined in the schema.
  20819. func (m *PayRechargeMutation) ClearEdge(name string) error {
  20820. return fmt.Errorf("unknown PayRecharge unique edge %s", name)
  20821. }
  20822. // ResetEdge resets all changes to the edge with the given name in this mutation.
  20823. // It returns an error if the edge is not defined in the schema.
  20824. func (m *PayRechargeMutation) ResetEdge(name string) error {
  20825. return fmt.Errorf("unknown PayRecharge edge %s", name)
  20826. }
  20827. // ServerMutation represents an operation that mutates the Server nodes in the graph.
  20828. type ServerMutation struct {
  20829. config
  20830. op Op
  20831. typ string
  20832. id *uint64
  20833. created_at *time.Time
  20834. updated_at *time.Time
  20835. status *uint8
  20836. addstatus *int8
  20837. deleted_at *time.Time
  20838. name *string
  20839. public_ip *string
  20840. private_ip *string
  20841. admin_port *string
  20842. clearedFields map[string]struct{}
  20843. wxs map[uint64]struct{}
  20844. removedwxs map[uint64]struct{}
  20845. clearedwxs bool
  20846. done bool
  20847. oldValue func(context.Context) (*Server, error)
  20848. predicates []predicate.Server
  20849. }
  20850. var _ ent.Mutation = (*ServerMutation)(nil)
  20851. // serverOption allows management of the mutation configuration using functional options.
  20852. type serverOption func(*ServerMutation)
  20853. // newServerMutation creates new mutation for the Server entity.
  20854. func newServerMutation(c config, op Op, opts ...serverOption) *ServerMutation {
  20855. m := &ServerMutation{
  20856. config: c,
  20857. op: op,
  20858. typ: TypeServer,
  20859. clearedFields: make(map[string]struct{}),
  20860. }
  20861. for _, opt := range opts {
  20862. opt(m)
  20863. }
  20864. return m
  20865. }
  20866. // withServerID sets the ID field of the mutation.
  20867. func withServerID(id uint64) serverOption {
  20868. return func(m *ServerMutation) {
  20869. var (
  20870. err error
  20871. once sync.Once
  20872. value *Server
  20873. )
  20874. m.oldValue = func(ctx context.Context) (*Server, error) {
  20875. once.Do(func() {
  20876. if m.done {
  20877. err = errors.New("querying old values post mutation is not allowed")
  20878. } else {
  20879. value, err = m.Client().Server.Get(ctx, id)
  20880. }
  20881. })
  20882. return value, err
  20883. }
  20884. m.id = &id
  20885. }
  20886. }
  20887. // withServer sets the old Server of the mutation.
  20888. func withServer(node *Server) serverOption {
  20889. return func(m *ServerMutation) {
  20890. m.oldValue = func(context.Context) (*Server, error) {
  20891. return node, nil
  20892. }
  20893. m.id = &node.ID
  20894. }
  20895. }
  20896. // Client returns a new `ent.Client` from the mutation. If the mutation was
  20897. // executed in a transaction (ent.Tx), a transactional client is returned.
  20898. func (m ServerMutation) Client() *Client {
  20899. client := &Client{config: m.config}
  20900. client.init()
  20901. return client
  20902. }
  20903. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  20904. // it returns an error otherwise.
  20905. func (m ServerMutation) Tx() (*Tx, error) {
  20906. if _, ok := m.driver.(*txDriver); !ok {
  20907. return nil, errors.New("ent: mutation is not running in a transaction")
  20908. }
  20909. tx := &Tx{config: m.config}
  20910. tx.init()
  20911. return tx, nil
  20912. }
  20913. // SetID sets the value of the id field. Note that this
  20914. // operation is only accepted on creation of Server entities.
  20915. func (m *ServerMutation) SetID(id uint64) {
  20916. m.id = &id
  20917. }
  20918. // ID returns the ID value in the mutation. Note that the ID is only available
  20919. // if it was provided to the builder or after it was returned from the database.
  20920. func (m *ServerMutation) ID() (id uint64, exists bool) {
  20921. if m.id == nil {
  20922. return
  20923. }
  20924. return *m.id, true
  20925. }
  20926. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  20927. // That means, if the mutation is applied within a transaction with an isolation level such
  20928. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  20929. // or updated by the mutation.
  20930. func (m *ServerMutation) IDs(ctx context.Context) ([]uint64, error) {
  20931. switch {
  20932. case m.op.Is(OpUpdateOne | OpDeleteOne):
  20933. id, exists := m.ID()
  20934. if exists {
  20935. return []uint64{id}, nil
  20936. }
  20937. fallthrough
  20938. case m.op.Is(OpUpdate | OpDelete):
  20939. return m.Client().Server.Query().Where(m.predicates...).IDs(ctx)
  20940. default:
  20941. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  20942. }
  20943. }
  20944. // SetCreatedAt sets the "created_at" field.
  20945. func (m *ServerMutation) SetCreatedAt(t time.Time) {
  20946. m.created_at = &t
  20947. }
  20948. // CreatedAt returns the value of the "created_at" field in the mutation.
  20949. func (m *ServerMutation) CreatedAt() (r time.Time, exists bool) {
  20950. v := m.created_at
  20951. if v == nil {
  20952. return
  20953. }
  20954. return *v, true
  20955. }
  20956. // OldCreatedAt returns the old "created_at" field's value of the Server entity.
  20957. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  20958. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20959. func (m *ServerMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  20960. if !m.op.Is(OpUpdateOne) {
  20961. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  20962. }
  20963. if m.id == nil || m.oldValue == nil {
  20964. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  20965. }
  20966. oldValue, err := m.oldValue(ctx)
  20967. if err != nil {
  20968. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  20969. }
  20970. return oldValue.CreatedAt, nil
  20971. }
  20972. // ResetCreatedAt resets all changes to the "created_at" field.
  20973. func (m *ServerMutation) ResetCreatedAt() {
  20974. m.created_at = nil
  20975. }
  20976. // SetUpdatedAt sets the "updated_at" field.
  20977. func (m *ServerMutation) SetUpdatedAt(t time.Time) {
  20978. m.updated_at = &t
  20979. }
  20980. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  20981. func (m *ServerMutation) UpdatedAt() (r time.Time, exists bool) {
  20982. v := m.updated_at
  20983. if v == nil {
  20984. return
  20985. }
  20986. return *v, true
  20987. }
  20988. // OldUpdatedAt returns the old "updated_at" field's value of the Server entity.
  20989. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  20990. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20991. func (m *ServerMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  20992. if !m.op.Is(OpUpdateOne) {
  20993. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  20994. }
  20995. if m.id == nil || m.oldValue == nil {
  20996. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  20997. }
  20998. oldValue, err := m.oldValue(ctx)
  20999. if err != nil {
  21000. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  21001. }
  21002. return oldValue.UpdatedAt, nil
  21003. }
  21004. // ResetUpdatedAt resets all changes to the "updated_at" field.
  21005. func (m *ServerMutation) ResetUpdatedAt() {
  21006. m.updated_at = nil
  21007. }
  21008. // SetStatus sets the "status" field.
  21009. func (m *ServerMutation) SetStatus(u uint8) {
  21010. m.status = &u
  21011. m.addstatus = nil
  21012. }
  21013. // Status returns the value of the "status" field in the mutation.
  21014. func (m *ServerMutation) Status() (r uint8, exists bool) {
  21015. v := m.status
  21016. if v == nil {
  21017. return
  21018. }
  21019. return *v, true
  21020. }
  21021. // OldStatus returns the old "status" field's value of the Server entity.
  21022. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  21023. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21024. func (m *ServerMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  21025. if !m.op.Is(OpUpdateOne) {
  21026. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  21027. }
  21028. if m.id == nil || m.oldValue == nil {
  21029. return v, errors.New("OldStatus requires an ID field in the mutation")
  21030. }
  21031. oldValue, err := m.oldValue(ctx)
  21032. if err != nil {
  21033. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  21034. }
  21035. return oldValue.Status, nil
  21036. }
  21037. // AddStatus adds u to the "status" field.
  21038. func (m *ServerMutation) AddStatus(u int8) {
  21039. if m.addstatus != nil {
  21040. *m.addstatus += u
  21041. } else {
  21042. m.addstatus = &u
  21043. }
  21044. }
  21045. // AddedStatus returns the value that was added to the "status" field in this mutation.
  21046. func (m *ServerMutation) AddedStatus() (r int8, exists bool) {
  21047. v := m.addstatus
  21048. if v == nil {
  21049. return
  21050. }
  21051. return *v, true
  21052. }
  21053. // ClearStatus clears the value of the "status" field.
  21054. func (m *ServerMutation) ClearStatus() {
  21055. m.status = nil
  21056. m.addstatus = nil
  21057. m.clearedFields[server.FieldStatus] = struct{}{}
  21058. }
  21059. // StatusCleared returns if the "status" field was cleared in this mutation.
  21060. func (m *ServerMutation) StatusCleared() bool {
  21061. _, ok := m.clearedFields[server.FieldStatus]
  21062. return ok
  21063. }
  21064. // ResetStatus resets all changes to the "status" field.
  21065. func (m *ServerMutation) ResetStatus() {
  21066. m.status = nil
  21067. m.addstatus = nil
  21068. delete(m.clearedFields, server.FieldStatus)
  21069. }
  21070. // SetDeletedAt sets the "deleted_at" field.
  21071. func (m *ServerMutation) SetDeletedAt(t time.Time) {
  21072. m.deleted_at = &t
  21073. }
  21074. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  21075. func (m *ServerMutation) DeletedAt() (r time.Time, exists bool) {
  21076. v := m.deleted_at
  21077. if v == nil {
  21078. return
  21079. }
  21080. return *v, true
  21081. }
  21082. // OldDeletedAt returns the old "deleted_at" field's value of the Server entity.
  21083. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  21084. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21085. func (m *ServerMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  21086. if !m.op.Is(OpUpdateOne) {
  21087. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  21088. }
  21089. if m.id == nil || m.oldValue == nil {
  21090. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  21091. }
  21092. oldValue, err := m.oldValue(ctx)
  21093. if err != nil {
  21094. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  21095. }
  21096. return oldValue.DeletedAt, nil
  21097. }
  21098. // ClearDeletedAt clears the value of the "deleted_at" field.
  21099. func (m *ServerMutation) ClearDeletedAt() {
  21100. m.deleted_at = nil
  21101. m.clearedFields[server.FieldDeletedAt] = struct{}{}
  21102. }
  21103. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  21104. func (m *ServerMutation) DeletedAtCleared() bool {
  21105. _, ok := m.clearedFields[server.FieldDeletedAt]
  21106. return ok
  21107. }
  21108. // ResetDeletedAt resets all changes to the "deleted_at" field.
  21109. func (m *ServerMutation) ResetDeletedAt() {
  21110. m.deleted_at = nil
  21111. delete(m.clearedFields, server.FieldDeletedAt)
  21112. }
  21113. // SetName sets the "name" field.
  21114. func (m *ServerMutation) SetName(s string) {
  21115. m.name = &s
  21116. }
  21117. // Name returns the value of the "name" field in the mutation.
  21118. func (m *ServerMutation) Name() (r string, exists bool) {
  21119. v := m.name
  21120. if v == nil {
  21121. return
  21122. }
  21123. return *v, true
  21124. }
  21125. // OldName returns the old "name" field's value of the Server entity.
  21126. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  21127. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21128. func (m *ServerMutation) OldName(ctx context.Context) (v string, err error) {
  21129. if !m.op.Is(OpUpdateOne) {
  21130. return v, errors.New("OldName is only allowed on UpdateOne operations")
  21131. }
  21132. if m.id == nil || m.oldValue == nil {
  21133. return v, errors.New("OldName requires an ID field in the mutation")
  21134. }
  21135. oldValue, err := m.oldValue(ctx)
  21136. if err != nil {
  21137. return v, fmt.Errorf("querying old value for OldName: %w", err)
  21138. }
  21139. return oldValue.Name, nil
  21140. }
  21141. // ResetName resets all changes to the "name" field.
  21142. func (m *ServerMutation) ResetName() {
  21143. m.name = nil
  21144. }
  21145. // SetPublicIP sets the "public_ip" field.
  21146. func (m *ServerMutation) SetPublicIP(s string) {
  21147. m.public_ip = &s
  21148. }
  21149. // PublicIP returns the value of the "public_ip" field in the mutation.
  21150. func (m *ServerMutation) PublicIP() (r string, exists bool) {
  21151. v := m.public_ip
  21152. if v == nil {
  21153. return
  21154. }
  21155. return *v, true
  21156. }
  21157. // OldPublicIP returns the old "public_ip" field's value of the Server entity.
  21158. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  21159. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21160. func (m *ServerMutation) OldPublicIP(ctx context.Context) (v string, err error) {
  21161. if !m.op.Is(OpUpdateOne) {
  21162. return v, errors.New("OldPublicIP is only allowed on UpdateOne operations")
  21163. }
  21164. if m.id == nil || m.oldValue == nil {
  21165. return v, errors.New("OldPublicIP requires an ID field in the mutation")
  21166. }
  21167. oldValue, err := m.oldValue(ctx)
  21168. if err != nil {
  21169. return v, fmt.Errorf("querying old value for OldPublicIP: %w", err)
  21170. }
  21171. return oldValue.PublicIP, nil
  21172. }
  21173. // ResetPublicIP resets all changes to the "public_ip" field.
  21174. func (m *ServerMutation) ResetPublicIP() {
  21175. m.public_ip = nil
  21176. }
  21177. // SetPrivateIP sets the "private_ip" field.
  21178. func (m *ServerMutation) SetPrivateIP(s string) {
  21179. m.private_ip = &s
  21180. }
  21181. // PrivateIP returns the value of the "private_ip" field in the mutation.
  21182. func (m *ServerMutation) PrivateIP() (r string, exists bool) {
  21183. v := m.private_ip
  21184. if v == nil {
  21185. return
  21186. }
  21187. return *v, true
  21188. }
  21189. // OldPrivateIP returns the old "private_ip" field's value of the Server entity.
  21190. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  21191. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21192. func (m *ServerMutation) OldPrivateIP(ctx context.Context) (v string, err error) {
  21193. if !m.op.Is(OpUpdateOne) {
  21194. return v, errors.New("OldPrivateIP is only allowed on UpdateOne operations")
  21195. }
  21196. if m.id == nil || m.oldValue == nil {
  21197. return v, errors.New("OldPrivateIP requires an ID field in the mutation")
  21198. }
  21199. oldValue, err := m.oldValue(ctx)
  21200. if err != nil {
  21201. return v, fmt.Errorf("querying old value for OldPrivateIP: %w", err)
  21202. }
  21203. return oldValue.PrivateIP, nil
  21204. }
  21205. // ResetPrivateIP resets all changes to the "private_ip" field.
  21206. func (m *ServerMutation) ResetPrivateIP() {
  21207. m.private_ip = nil
  21208. }
  21209. // SetAdminPort sets the "admin_port" field.
  21210. func (m *ServerMutation) SetAdminPort(s string) {
  21211. m.admin_port = &s
  21212. }
  21213. // AdminPort returns the value of the "admin_port" field in the mutation.
  21214. func (m *ServerMutation) AdminPort() (r string, exists bool) {
  21215. v := m.admin_port
  21216. if v == nil {
  21217. return
  21218. }
  21219. return *v, true
  21220. }
  21221. // OldAdminPort returns the old "admin_port" field's value of the Server entity.
  21222. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  21223. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21224. func (m *ServerMutation) OldAdminPort(ctx context.Context) (v string, err error) {
  21225. if !m.op.Is(OpUpdateOne) {
  21226. return v, errors.New("OldAdminPort is only allowed on UpdateOne operations")
  21227. }
  21228. if m.id == nil || m.oldValue == nil {
  21229. return v, errors.New("OldAdminPort requires an ID field in the mutation")
  21230. }
  21231. oldValue, err := m.oldValue(ctx)
  21232. if err != nil {
  21233. return v, fmt.Errorf("querying old value for OldAdminPort: %w", err)
  21234. }
  21235. return oldValue.AdminPort, nil
  21236. }
  21237. // ResetAdminPort resets all changes to the "admin_port" field.
  21238. func (m *ServerMutation) ResetAdminPort() {
  21239. m.admin_port = nil
  21240. }
  21241. // AddWxIDs adds the "wxs" edge to the Wx entity by ids.
  21242. func (m *ServerMutation) AddWxIDs(ids ...uint64) {
  21243. if m.wxs == nil {
  21244. m.wxs = make(map[uint64]struct{})
  21245. }
  21246. for i := range ids {
  21247. m.wxs[ids[i]] = struct{}{}
  21248. }
  21249. }
  21250. // ClearWxs clears the "wxs" edge to the Wx entity.
  21251. func (m *ServerMutation) ClearWxs() {
  21252. m.clearedwxs = true
  21253. }
  21254. // WxsCleared reports if the "wxs" edge to the Wx entity was cleared.
  21255. func (m *ServerMutation) WxsCleared() bool {
  21256. return m.clearedwxs
  21257. }
  21258. // RemoveWxIDs removes the "wxs" edge to the Wx entity by IDs.
  21259. func (m *ServerMutation) RemoveWxIDs(ids ...uint64) {
  21260. if m.removedwxs == nil {
  21261. m.removedwxs = make(map[uint64]struct{})
  21262. }
  21263. for i := range ids {
  21264. delete(m.wxs, ids[i])
  21265. m.removedwxs[ids[i]] = struct{}{}
  21266. }
  21267. }
  21268. // RemovedWxs returns the removed IDs of the "wxs" edge to the Wx entity.
  21269. func (m *ServerMutation) RemovedWxsIDs() (ids []uint64) {
  21270. for id := range m.removedwxs {
  21271. ids = append(ids, id)
  21272. }
  21273. return
  21274. }
  21275. // WxsIDs returns the "wxs" edge IDs in the mutation.
  21276. func (m *ServerMutation) WxsIDs() (ids []uint64) {
  21277. for id := range m.wxs {
  21278. ids = append(ids, id)
  21279. }
  21280. return
  21281. }
  21282. // ResetWxs resets all changes to the "wxs" edge.
  21283. func (m *ServerMutation) ResetWxs() {
  21284. m.wxs = nil
  21285. m.clearedwxs = false
  21286. m.removedwxs = nil
  21287. }
  21288. // Where appends a list predicates to the ServerMutation builder.
  21289. func (m *ServerMutation) Where(ps ...predicate.Server) {
  21290. m.predicates = append(m.predicates, ps...)
  21291. }
  21292. // WhereP appends storage-level predicates to the ServerMutation builder. Using this method,
  21293. // users can use type-assertion to append predicates that do not depend on any generated package.
  21294. func (m *ServerMutation) WhereP(ps ...func(*sql.Selector)) {
  21295. p := make([]predicate.Server, len(ps))
  21296. for i := range ps {
  21297. p[i] = ps[i]
  21298. }
  21299. m.Where(p...)
  21300. }
  21301. // Op returns the operation name.
  21302. func (m *ServerMutation) Op() Op {
  21303. return m.op
  21304. }
  21305. // SetOp allows setting the mutation operation.
  21306. func (m *ServerMutation) SetOp(op Op) {
  21307. m.op = op
  21308. }
  21309. // Type returns the node type of this mutation (Server).
  21310. func (m *ServerMutation) Type() string {
  21311. return m.typ
  21312. }
  21313. // Fields returns all fields that were changed during this mutation. Note that in
  21314. // order to get all numeric fields that were incremented/decremented, call
  21315. // AddedFields().
  21316. func (m *ServerMutation) Fields() []string {
  21317. fields := make([]string, 0, 8)
  21318. if m.created_at != nil {
  21319. fields = append(fields, server.FieldCreatedAt)
  21320. }
  21321. if m.updated_at != nil {
  21322. fields = append(fields, server.FieldUpdatedAt)
  21323. }
  21324. if m.status != nil {
  21325. fields = append(fields, server.FieldStatus)
  21326. }
  21327. if m.deleted_at != nil {
  21328. fields = append(fields, server.FieldDeletedAt)
  21329. }
  21330. if m.name != nil {
  21331. fields = append(fields, server.FieldName)
  21332. }
  21333. if m.public_ip != nil {
  21334. fields = append(fields, server.FieldPublicIP)
  21335. }
  21336. if m.private_ip != nil {
  21337. fields = append(fields, server.FieldPrivateIP)
  21338. }
  21339. if m.admin_port != nil {
  21340. fields = append(fields, server.FieldAdminPort)
  21341. }
  21342. return fields
  21343. }
  21344. // Field returns the value of a field with the given name. The second boolean
  21345. // return value indicates that this field was not set, or was not defined in the
  21346. // schema.
  21347. func (m *ServerMutation) Field(name string) (ent.Value, bool) {
  21348. switch name {
  21349. case server.FieldCreatedAt:
  21350. return m.CreatedAt()
  21351. case server.FieldUpdatedAt:
  21352. return m.UpdatedAt()
  21353. case server.FieldStatus:
  21354. return m.Status()
  21355. case server.FieldDeletedAt:
  21356. return m.DeletedAt()
  21357. case server.FieldName:
  21358. return m.Name()
  21359. case server.FieldPublicIP:
  21360. return m.PublicIP()
  21361. case server.FieldPrivateIP:
  21362. return m.PrivateIP()
  21363. case server.FieldAdminPort:
  21364. return m.AdminPort()
  21365. }
  21366. return nil, false
  21367. }
  21368. // OldField returns the old value of the field from the database. An error is
  21369. // returned if the mutation operation is not UpdateOne, or the query to the
  21370. // database failed.
  21371. func (m *ServerMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  21372. switch name {
  21373. case server.FieldCreatedAt:
  21374. return m.OldCreatedAt(ctx)
  21375. case server.FieldUpdatedAt:
  21376. return m.OldUpdatedAt(ctx)
  21377. case server.FieldStatus:
  21378. return m.OldStatus(ctx)
  21379. case server.FieldDeletedAt:
  21380. return m.OldDeletedAt(ctx)
  21381. case server.FieldName:
  21382. return m.OldName(ctx)
  21383. case server.FieldPublicIP:
  21384. return m.OldPublicIP(ctx)
  21385. case server.FieldPrivateIP:
  21386. return m.OldPrivateIP(ctx)
  21387. case server.FieldAdminPort:
  21388. return m.OldAdminPort(ctx)
  21389. }
  21390. return nil, fmt.Errorf("unknown Server field %s", name)
  21391. }
  21392. // SetField sets the value of a field with the given name. It returns an error if
  21393. // the field is not defined in the schema, or if the type mismatched the field
  21394. // type.
  21395. func (m *ServerMutation) SetField(name string, value ent.Value) error {
  21396. switch name {
  21397. case server.FieldCreatedAt:
  21398. v, ok := value.(time.Time)
  21399. if !ok {
  21400. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21401. }
  21402. m.SetCreatedAt(v)
  21403. return nil
  21404. case server.FieldUpdatedAt:
  21405. v, ok := value.(time.Time)
  21406. if !ok {
  21407. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21408. }
  21409. m.SetUpdatedAt(v)
  21410. return nil
  21411. case server.FieldStatus:
  21412. v, ok := value.(uint8)
  21413. if !ok {
  21414. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21415. }
  21416. m.SetStatus(v)
  21417. return nil
  21418. case server.FieldDeletedAt:
  21419. v, ok := value.(time.Time)
  21420. if !ok {
  21421. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21422. }
  21423. m.SetDeletedAt(v)
  21424. return nil
  21425. case server.FieldName:
  21426. v, ok := value.(string)
  21427. if !ok {
  21428. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21429. }
  21430. m.SetName(v)
  21431. return nil
  21432. case server.FieldPublicIP:
  21433. v, ok := value.(string)
  21434. if !ok {
  21435. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21436. }
  21437. m.SetPublicIP(v)
  21438. return nil
  21439. case server.FieldPrivateIP:
  21440. v, ok := value.(string)
  21441. if !ok {
  21442. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21443. }
  21444. m.SetPrivateIP(v)
  21445. return nil
  21446. case server.FieldAdminPort:
  21447. v, ok := value.(string)
  21448. if !ok {
  21449. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21450. }
  21451. m.SetAdminPort(v)
  21452. return nil
  21453. }
  21454. return fmt.Errorf("unknown Server field %s", name)
  21455. }
  21456. // AddedFields returns all numeric fields that were incremented/decremented during
  21457. // this mutation.
  21458. func (m *ServerMutation) AddedFields() []string {
  21459. var fields []string
  21460. if m.addstatus != nil {
  21461. fields = append(fields, server.FieldStatus)
  21462. }
  21463. return fields
  21464. }
  21465. // AddedField returns the numeric value that was incremented/decremented on a field
  21466. // with the given name. The second boolean return value indicates that this field
  21467. // was not set, or was not defined in the schema.
  21468. func (m *ServerMutation) AddedField(name string) (ent.Value, bool) {
  21469. switch name {
  21470. case server.FieldStatus:
  21471. return m.AddedStatus()
  21472. }
  21473. return nil, false
  21474. }
  21475. // AddField adds the value to the field with the given name. It returns an error if
  21476. // the field is not defined in the schema, or if the type mismatched the field
  21477. // type.
  21478. func (m *ServerMutation) AddField(name string, value ent.Value) error {
  21479. switch name {
  21480. case server.FieldStatus:
  21481. v, ok := value.(int8)
  21482. if !ok {
  21483. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21484. }
  21485. m.AddStatus(v)
  21486. return nil
  21487. }
  21488. return fmt.Errorf("unknown Server numeric field %s", name)
  21489. }
  21490. // ClearedFields returns all nullable fields that were cleared during this
  21491. // mutation.
  21492. func (m *ServerMutation) ClearedFields() []string {
  21493. var fields []string
  21494. if m.FieldCleared(server.FieldStatus) {
  21495. fields = append(fields, server.FieldStatus)
  21496. }
  21497. if m.FieldCleared(server.FieldDeletedAt) {
  21498. fields = append(fields, server.FieldDeletedAt)
  21499. }
  21500. return fields
  21501. }
  21502. // FieldCleared returns a boolean indicating if a field with the given name was
  21503. // cleared in this mutation.
  21504. func (m *ServerMutation) FieldCleared(name string) bool {
  21505. _, ok := m.clearedFields[name]
  21506. return ok
  21507. }
  21508. // ClearField clears the value of the field with the given name. It returns an
  21509. // error if the field is not defined in the schema.
  21510. func (m *ServerMutation) ClearField(name string) error {
  21511. switch name {
  21512. case server.FieldStatus:
  21513. m.ClearStatus()
  21514. return nil
  21515. case server.FieldDeletedAt:
  21516. m.ClearDeletedAt()
  21517. return nil
  21518. }
  21519. return fmt.Errorf("unknown Server nullable field %s", name)
  21520. }
  21521. // ResetField resets all changes in the mutation for the field with the given name.
  21522. // It returns an error if the field is not defined in the schema.
  21523. func (m *ServerMutation) ResetField(name string) error {
  21524. switch name {
  21525. case server.FieldCreatedAt:
  21526. m.ResetCreatedAt()
  21527. return nil
  21528. case server.FieldUpdatedAt:
  21529. m.ResetUpdatedAt()
  21530. return nil
  21531. case server.FieldStatus:
  21532. m.ResetStatus()
  21533. return nil
  21534. case server.FieldDeletedAt:
  21535. m.ResetDeletedAt()
  21536. return nil
  21537. case server.FieldName:
  21538. m.ResetName()
  21539. return nil
  21540. case server.FieldPublicIP:
  21541. m.ResetPublicIP()
  21542. return nil
  21543. case server.FieldPrivateIP:
  21544. m.ResetPrivateIP()
  21545. return nil
  21546. case server.FieldAdminPort:
  21547. m.ResetAdminPort()
  21548. return nil
  21549. }
  21550. return fmt.Errorf("unknown Server field %s", name)
  21551. }
  21552. // AddedEdges returns all edge names that were set/added in this mutation.
  21553. func (m *ServerMutation) AddedEdges() []string {
  21554. edges := make([]string, 0, 1)
  21555. if m.wxs != nil {
  21556. edges = append(edges, server.EdgeWxs)
  21557. }
  21558. return edges
  21559. }
  21560. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  21561. // name in this mutation.
  21562. func (m *ServerMutation) AddedIDs(name string) []ent.Value {
  21563. switch name {
  21564. case server.EdgeWxs:
  21565. ids := make([]ent.Value, 0, len(m.wxs))
  21566. for id := range m.wxs {
  21567. ids = append(ids, id)
  21568. }
  21569. return ids
  21570. }
  21571. return nil
  21572. }
  21573. // RemovedEdges returns all edge names that were removed in this mutation.
  21574. func (m *ServerMutation) RemovedEdges() []string {
  21575. edges := make([]string, 0, 1)
  21576. if m.removedwxs != nil {
  21577. edges = append(edges, server.EdgeWxs)
  21578. }
  21579. return edges
  21580. }
  21581. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  21582. // the given name in this mutation.
  21583. func (m *ServerMutation) RemovedIDs(name string) []ent.Value {
  21584. switch name {
  21585. case server.EdgeWxs:
  21586. ids := make([]ent.Value, 0, len(m.removedwxs))
  21587. for id := range m.removedwxs {
  21588. ids = append(ids, id)
  21589. }
  21590. return ids
  21591. }
  21592. return nil
  21593. }
  21594. // ClearedEdges returns all edge names that were cleared in this mutation.
  21595. func (m *ServerMutation) ClearedEdges() []string {
  21596. edges := make([]string, 0, 1)
  21597. if m.clearedwxs {
  21598. edges = append(edges, server.EdgeWxs)
  21599. }
  21600. return edges
  21601. }
  21602. // EdgeCleared returns a boolean which indicates if the edge with the given name
  21603. // was cleared in this mutation.
  21604. func (m *ServerMutation) EdgeCleared(name string) bool {
  21605. switch name {
  21606. case server.EdgeWxs:
  21607. return m.clearedwxs
  21608. }
  21609. return false
  21610. }
  21611. // ClearEdge clears the value of the edge with the given name. It returns an error
  21612. // if that edge is not defined in the schema.
  21613. func (m *ServerMutation) ClearEdge(name string) error {
  21614. switch name {
  21615. }
  21616. return fmt.Errorf("unknown Server unique edge %s", name)
  21617. }
  21618. // ResetEdge resets all changes to the edge with the given name in this mutation.
  21619. // It returns an error if the edge is not defined in the schema.
  21620. func (m *ServerMutation) ResetEdge(name string) error {
  21621. switch name {
  21622. case server.EdgeWxs:
  21623. m.ResetWxs()
  21624. return nil
  21625. }
  21626. return fmt.Errorf("unknown Server edge %s", name)
  21627. }
  21628. // SopNodeMutation represents an operation that mutates the SopNode nodes in the graph.
  21629. type SopNodeMutation struct {
  21630. config
  21631. op Op
  21632. typ string
  21633. id *uint64
  21634. created_at *time.Time
  21635. updated_at *time.Time
  21636. status *uint8
  21637. addstatus *int8
  21638. deleted_at *time.Time
  21639. parent_id *uint64
  21640. addparent_id *int64
  21641. name *string
  21642. condition_type *int
  21643. addcondition_type *int
  21644. condition_list *[]string
  21645. appendcondition_list []string
  21646. no_reply_condition *uint64
  21647. addno_reply_condition *int64
  21648. no_reply_unit *string
  21649. action_message *[]custom_types.Action
  21650. appendaction_message []custom_types.Action
  21651. action_label_add *[]uint64
  21652. appendaction_label_add []uint64
  21653. action_label_del *[]uint64
  21654. appendaction_label_del []uint64
  21655. action_forward **custom_types.ActionForward
  21656. clearedFields map[string]struct{}
  21657. sop_stage *uint64
  21658. clearedsop_stage bool
  21659. node_messages map[uint64]struct{}
  21660. removednode_messages map[uint64]struct{}
  21661. clearednode_messages bool
  21662. done bool
  21663. oldValue func(context.Context) (*SopNode, error)
  21664. predicates []predicate.SopNode
  21665. }
  21666. var _ ent.Mutation = (*SopNodeMutation)(nil)
  21667. // sopnodeOption allows management of the mutation configuration using functional options.
  21668. type sopnodeOption func(*SopNodeMutation)
  21669. // newSopNodeMutation creates new mutation for the SopNode entity.
  21670. func newSopNodeMutation(c config, op Op, opts ...sopnodeOption) *SopNodeMutation {
  21671. m := &SopNodeMutation{
  21672. config: c,
  21673. op: op,
  21674. typ: TypeSopNode,
  21675. clearedFields: make(map[string]struct{}),
  21676. }
  21677. for _, opt := range opts {
  21678. opt(m)
  21679. }
  21680. return m
  21681. }
  21682. // withSopNodeID sets the ID field of the mutation.
  21683. func withSopNodeID(id uint64) sopnodeOption {
  21684. return func(m *SopNodeMutation) {
  21685. var (
  21686. err error
  21687. once sync.Once
  21688. value *SopNode
  21689. )
  21690. m.oldValue = func(ctx context.Context) (*SopNode, error) {
  21691. once.Do(func() {
  21692. if m.done {
  21693. err = errors.New("querying old values post mutation is not allowed")
  21694. } else {
  21695. value, err = m.Client().SopNode.Get(ctx, id)
  21696. }
  21697. })
  21698. return value, err
  21699. }
  21700. m.id = &id
  21701. }
  21702. }
  21703. // withSopNode sets the old SopNode of the mutation.
  21704. func withSopNode(node *SopNode) sopnodeOption {
  21705. return func(m *SopNodeMutation) {
  21706. m.oldValue = func(context.Context) (*SopNode, error) {
  21707. return node, nil
  21708. }
  21709. m.id = &node.ID
  21710. }
  21711. }
  21712. // Client returns a new `ent.Client` from the mutation. If the mutation was
  21713. // executed in a transaction (ent.Tx), a transactional client is returned.
  21714. func (m SopNodeMutation) Client() *Client {
  21715. client := &Client{config: m.config}
  21716. client.init()
  21717. return client
  21718. }
  21719. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  21720. // it returns an error otherwise.
  21721. func (m SopNodeMutation) Tx() (*Tx, error) {
  21722. if _, ok := m.driver.(*txDriver); !ok {
  21723. return nil, errors.New("ent: mutation is not running in a transaction")
  21724. }
  21725. tx := &Tx{config: m.config}
  21726. tx.init()
  21727. return tx, nil
  21728. }
  21729. // SetID sets the value of the id field. Note that this
  21730. // operation is only accepted on creation of SopNode entities.
  21731. func (m *SopNodeMutation) SetID(id uint64) {
  21732. m.id = &id
  21733. }
  21734. // ID returns the ID value in the mutation. Note that the ID is only available
  21735. // if it was provided to the builder or after it was returned from the database.
  21736. func (m *SopNodeMutation) ID() (id uint64, exists bool) {
  21737. if m.id == nil {
  21738. return
  21739. }
  21740. return *m.id, true
  21741. }
  21742. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  21743. // That means, if the mutation is applied within a transaction with an isolation level such
  21744. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  21745. // or updated by the mutation.
  21746. func (m *SopNodeMutation) IDs(ctx context.Context) ([]uint64, error) {
  21747. switch {
  21748. case m.op.Is(OpUpdateOne | OpDeleteOne):
  21749. id, exists := m.ID()
  21750. if exists {
  21751. return []uint64{id}, nil
  21752. }
  21753. fallthrough
  21754. case m.op.Is(OpUpdate | OpDelete):
  21755. return m.Client().SopNode.Query().Where(m.predicates...).IDs(ctx)
  21756. default:
  21757. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  21758. }
  21759. }
  21760. // SetCreatedAt sets the "created_at" field.
  21761. func (m *SopNodeMutation) SetCreatedAt(t time.Time) {
  21762. m.created_at = &t
  21763. }
  21764. // CreatedAt returns the value of the "created_at" field in the mutation.
  21765. func (m *SopNodeMutation) CreatedAt() (r time.Time, exists bool) {
  21766. v := m.created_at
  21767. if v == nil {
  21768. return
  21769. }
  21770. return *v, true
  21771. }
  21772. // OldCreatedAt returns the old "created_at" field's value of the SopNode entity.
  21773. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21774. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21775. func (m *SopNodeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  21776. if !m.op.Is(OpUpdateOne) {
  21777. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  21778. }
  21779. if m.id == nil || m.oldValue == nil {
  21780. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  21781. }
  21782. oldValue, err := m.oldValue(ctx)
  21783. if err != nil {
  21784. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  21785. }
  21786. return oldValue.CreatedAt, nil
  21787. }
  21788. // ResetCreatedAt resets all changes to the "created_at" field.
  21789. func (m *SopNodeMutation) ResetCreatedAt() {
  21790. m.created_at = nil
  21791. }
  21792. // SetUpdatedAt sets the "updated_at" field.
  21793. func (m *SopNodeMutation) SetUpdatedAt(t time.Time) {
  21794. m.updated_at = &t
  21795. }
  21796. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  21797. func (m *SopNodeMutation) UpdatedAt() (r time.Time, exists bool) {
  21798. v := m.updated_at
  21799. if v == nil {
  21800. return
  21801. }
  21802. return *v, true
  21803. }
  21804. // OldUpdatedAt returns the old "updated_at" field's value of the SopNode entity.
  21805. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21806. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21807. func (m *SopNodeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  21808. if !m.op.Is(OpUpdateOne) {
  21809. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  21810. }
  21811. if m.id == nil || m.oldValue == nil {
  21812. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  21813. }
  21814. oldValue, err := m.oldValue(ctx)
  21815. if err != nil {
  21816. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  21817. }
  21818. return oldValue.UpdatedAt, nil
  21819. }
  21820. // ResetUpdatedAt resets all changes to the "updated_at" field.
  21821. func (m *SopNodeMutation) ResetUpdatedAt() {
  21822. m.updated_at = nil
  21823. }
  21824. // SetStatus sets the "status" field.
  21825. func (m *SopNodeMutation) SetStatus(u uint8) {
  21826. m.status = &u
  21827. m.addstatus = nil
  21828. }
  21829. // Status returns the value of the "status" field in the mutation.
  21830. func (m *SopNodeMutation) Status() (r uint8, exists bool) {
  21831. v := m.status
  21832. if v == nil {
  21833. return
  21834. }
  21835. return *v, true
  21836. }
  21837. // OldStatus returns the old "status" field's value of the SopNode entity.
  21838. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21839. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21840. func (m *SopNodeMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  21841. if !m.op.Is(OpUpdateOne) {
  21842. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  21843. }
  21844. if m.id == nil || m.oldValue == nil {
  21845. return v, errors.New("OldStatus requires an ID field in the mutation")
  21846. }
  21847. oldValue, err := m.oldValue(ctx)
  21848. if err != nil {
  21849. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  21850. }
  21851. return oldValue.Status, nil
  21852. }
  21853. // AddStatus adds u to the "status" field.
  21854. func (m *SopNodeMutation) AddStatus(u int8) {
  21855. if m.addstatus != nil {
  21856. *m.addstatus += u
  21857. } else {
  21858. m.addstatus = &u
  21859. }
  21860. }
  21861. // AddedStatus returns the value that was added to the "status" field in this mutation.
  21862. func (m *SopNodeMutation) AddedStatus() (r int8, exists bool) {
  21863. v := m.addstatus
  21864. if v == nil {
  21865. return
  21866. }
  21867. return *v, true
  21868. }
  21869. // ClearStatus clears the value of the "status" field.
  21870. func (m *SopNodeMutation) ClearStatus() {
  21871. m.status = nil
  21872. m.addstatus = nil
  21873. m.clearedFields[sopnode.FieldStatus] = struct{}{}
  21874. }
  21875. // StatusCleared returns if the "status" field was cleared in this mutation.
  21876. func (m *SopNodeMutation) StatusCleared() bool {
  21877. _, ok := m.clearedFields[sopnode.FieldStatus]
  21878. return ok
  21879. }
  21880. // ResetStatus resets all changes to the "status" field.
  21881. func (m *SopNodeMutation) ResetStatus() {
  21882. m.status = nil
  21883. m.addstatus = nil
  21884. delete(m.clearedFields, sopnode.FieldStatus)
  21885. }
  21886. // SetDeletedAt sets the "deleted_at" field.
  21887. func (m *SopNodeMutation) SetDeletedAt(t time.Time) {
  21888. m.deleted_at = &t
  21889. }
  21890. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  21891. func (m *SopNodeMutation) DeletedAt() (r time.Time, exists bool) {
  21892. v := m.deleted_at
  21893. if v == nil {
  21894. return
  21895. }
  21896. return *v, true
  21897. }
  21898. // OldDeletedAt returns the old "deleted_at" field's value of the SopNode entity.
  21899. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21900. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21901. func (m *SopNodeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  21902. if !m.op.Is(OpUpdateOne) {
  21903. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  21904. }
  21905. if m.id == nil || m.oldValue == nil {
  21906. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  21907. }
  21908. oldValue, err := m.oldValue(ctx)
  21909. if err != nil {
  21910. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  21911. }
  21912. return oldValue.DeletedAt, nil
  21913. }
  21914. // ClearDeletedAt clears the value of the "deleted_at" field.
  21915. func (m *SopNodeMutation) ClearDeletedAt() {
  21916. m.deleted_at = nil
  21917. m.clearedFields[sopnode.FieldDeletedAt] = struct{}{}
  21918. }
  21919. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  21920. func (m *SopNodeMutation) DeletedAtCleared() bool {
  21921. _, ok := m.clearedFields[sopnode.FieldDeletedAt]
  21922. return ok
  21923. }
  21924. // ResetDeletedAt resets all changes to the "deleted_at" field.
  21925. func (m *SopNodeMutation) ResetDeletedAt() {
  21926. m.deleted_at = nil
  21927. delete(m.clearedFields, sopnode.FieldDeletedAt)
  21928. }
  21929. // SetStageID sets the "stage_id" field.
  21930. func (m *SopNodeMutation) SetStageID(u uint64) {
  21931. m.sop_stage = &u
  21932. }
  21933. // StageID returns the value of the "stage_id" field in the mutation.
  21934. func (m *SopNodeMutation) StageID() (r uint64, exists bool) {
  21935. v := m.sop_stage
  21936. if v == nil {
  21937. return
  21938. }
  21939. return *v, true
  21940. }
  21941. // OldStageID returns the old "stage_id" field's value of the SopNode entity.
  21942. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21943. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21944. func (m *SopNodeMutation) OldStageID(ctx context.Context) (v uint64, err error) {
  21945. if !m.op.Is(OpUpdateOne) {
  21946. return v, errors.New("OldStageID is only allowed on UpdateOne operations")
  21947. }
  21948. if m.id == nil || m.oldValue == nil {
  21949. return v, errors.New("OldStageID requires an ID field in the mutation")
  21950. }
  21951. oldValue, err := m.oldValue(ctx)
  21952. if err != nil {
  21953. return v, fmt.Errorf("querying old value for OldStageID: %w", err)
  21954. }
  21955. return oldValue.StageID, nil
  21956. }
  21957. // ResetStageID resets all changes to the "stage_id" field.
  21958. func (m *SopNodeMutation) ResetStageID() {
  21959. m.sop_stage = nil
  21960. }
  21961. // SetParentID sets the "parent_id" field.
  21962. func (m *SopNodeMutation) SetParentID(u uint64) {
  21963. m.parent_id = &u
  21964. m.addparent_id = nil
  21965. }
  21966. // ParentID returns the value of the "parent_id" field in the mutation.
  21967. func (m *SopNodeMutation) ParentID() (r uint64, exists bool) {
  21968. v := m.parent_id
  21969. if v == nil {
  21970. return
  21971. }
  21972. return *v, true
  21973. }
  21974. // OldParentID returns the old "parent_id" field's value of the SopNode entity.
  21975. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21976. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21977. func (m *SopNodeMutation) OldParentID(ctx context.Context) (v uint64, err error) {
  21978. if !m.op.Is(OpUpdateOne) {
  21979. return v, errors.New("OldParentID is only allowed on UpdateOne operations")
  21980. }
  21981. if m.id == nil || m.oldValue == nil {
  21982. return v, errors.New("OldParentID requires an ID field in the mutation")
  21983. }
  21984. oldValue, err := m.oldValue(ctx)
  21985. if err != nil {
  21986. return v, fmt.Errorf("querying old value for OldParentID: %w", err)
  21987. }
  21988. return oldValue.ParentID, nil
  21989. }
  21990. // AddParentID adds u to the "parent_id" field.
  21991. func (m *SopNodeMutation) AddParentID(u int64) {
  21992. if m.addparent_id != nil {
  21993. *m.addparent_id += u
  21994. } else {
  21995. m.addparent_id = &u
  21996. }
  21997. }
  21998. // AddedParentID returns the value that was added to the "parent_id" field in this mutation.
  21999. func (m *SopNodeMutation) AddedParentID() (r int64, exists bool) {
  22000. v := m.addparent_id
  22001. if v == nil {
  22002. return
  22003. }
  22004. return *v, true
  22005. }
  22006. // ResetParentID resets all changes to the "parent_id" field.
  22007. func (m *SopNodeMutation) ResetParentID() {
  22008. m.parent_id = nil
  22009. m.addparent_id = nil
  22010. }
  22011. // SetName sets the "name" field.
  22012. func (m *SopNodeMutation) SetName(s string) {
  22013. m.name = &s
  22014. }
  22015. // Name returns the value of the "name" field in the mutation.
  22016. func (m *SopNodeMutation) Name() (r string, exists bool) {
  22017. v := m.name
  22018. if v == nil {
  22019. return
  22020. }
  22021. return *v, true
  22022. }
  22023. // OldName returns the old "name" field's value of the SopNode entity.
  22024. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  22025. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22026. func (m *SopNodeMutation) OldName(ctx context.Context) (v string, err error) {
  22027. if !m.op.Is(OpUpdateOne) {
  22028. return v, errors.New("OldName is only allowed on UpdateOne operations")
  22029. }
  22030. if m.id == nil || m.oldValue == nil {
  22031. return v, errors.New("OldName requires an ID field in the mutation")
  22032. }
  22033. oldValue, err := m.oldValue(ctx)
  22034. if err != nil {
  22035. return v, fmt.Errorf("querying old value for OldName: %w", err)
  22036. }
  22037. return oldValue.Name, nil
  22038. }
  22039. // ResetName resets all changes to the "name" field.
  22040. func (m *SopNodeMutation) ResetName() {
  22041. m.name = nil
  22042. }
  22043. // SetConditionType sets the "condition_type" field.
  22044. func (m *SopNodeMutation) SetConditionType(i int) {
  22045. m.condition_type = &i
  22046. m.addcondition_type = nil
  22047. }
  22048. // ConditionType returns the value of the "condition_type" field in the mutation.
  22049. func (m *SopNodeMutation) ConditionType() (r int, exists bool) {
  22050. v := m.condition_type
  22051. if v == nil {
  22052. return
  22053. }
  22054. return *v, true
  22055. }
  22056. // OldConditionType returns the old "condition_type" field's value of the SopNode entity.
  22057. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  22058. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22059. func (m *SopNodeMutation) OldConditionType(ctx context.Context) (v int, err error) {
  22060. if !m.op.Is(OpUpdateOne) {
  22061. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  22062. }
  22063. if m.id == nil || m.oldValue == nil {
  22064. return v, errors.New("OldConditionType requires an ID field in the mutation")
  22065. }
  22066. oldValue, err := m.oldValue(ctx)
  22067. if err != nil {
  22068. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  22069. }
  22070. return oldValue.ConditionType, nil
  22071. }
  22072. // AddConditionType adds i to the "condition_type" field.
  22073. func (m *SopNodeMutation) AddConditionType(i int) {
  22074. if m.addcondition_type != nil {
  22075. *m.addcondition_type += i
  22076. } else {
  22077. m.addcondition_type = &i
  22078. }
  22079. }
  22080. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  22081. func (m *SopNodeMutation) AddedConditionType() (r int, exists bool) {
  22082. v := m.addcondition_type
  22083. if v == nil {
  22084. return
  22085. }
  22086. return *v, true
  22087. }
  22088. // ResetConditionType resets all changes to the "condition_type" field.
  22089. func (m *SopNodeMutation) ResetConditionType() {
  22090. m.condition_type = nil
  22091. m.addcondition_type = nil
  22092. }
  22093. // SetConditionList sets the "condition_list" field.
  22094. func (m *SopNodeMutation) SetConditionList(s []string) {
  22095. m.condition_list = &s
  22096. m.appendcondition_list = nil
  22097. }
  22098. // ConditionList returns the value of the "condition_list" field in the mutation.
  22099. func (m *SopNodeMutation) ConditionList() (r []string, exists bool) {
  22100. v := m.condition_list
  22101. if v == nil {
  22102. return
  22103. }
  22104. return *v, true
  22105. }
  22106. // OldConditionList returns the old "condition_list" field's value of the SopNode entity.
  22107. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  22108. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22109. func (m *SopNodeMutation) OldConditionList(ctx context.Context) (v []string, err error) {
  22110. if !m.op.Is(OpUpdateOne) {
  22111. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  22112. }
  22113. if m.id == nil || m.oldValue == nil {
  22114. return v, errors.New("OldConditionList requires an ID field in the mutation")
  22115. }
  22116. oldValue, err := m.oldValue(ctx)
  22117. if err != nil {
  22118. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  22119. }
  22120. return oldValue.ConditionList, nil
  22121. }
  22122. // AppendConditionList adds s to the "condition_list" field.
  22123. func (m *SopNodeMutation) AppendConditionList(s []string) {
  22124. m.appendcondition_list = append(m.appendcondition_list, s...)
  22125. }
  22126. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  22127. func (m *SopNodeMutation) AppendedConditionList() ([]string, bool) {
  22128. if len(m.appendcondition_list) == 0 {
  22129. return nil, false
  22130. }
  22131. return m.appendcondition_list, true
  22132. }
  22133. // ClearConditionList clears the value of the "condition_list" field.
  22134. func (m *SopNodeMutation) ClearConditionList() {
  22135. m.condition_list = nil
  22136. m.appendcondition_list = nil
  22137. m.clearedFields[sopnode.FieldConditionList] = struct{}{}
  22138. }
  22139. // ConditionListCleared returns if the "condition_list" field was cleared in this mutation.
  22140. func (m *SopNodeMutation) ConditionListCleared() bool {
  22141. _, ok := m.clearedFields[sopnode.FieldConditionList]
  22142. return ok
  22143. }
  22144. // ResetConditionList resets all changes to the "condition_list" field.
  22145. func (m *SopNodeMutation) ResetConditionList() {
  22146. m.condition_list = nil
  22147. m.appendcondition_list = nil
  22148. delete(m.clearedFields, sopnode.FieldConditionList)
  22149. }
  22150. // SetNoReplyCondition sets the "no_reply_condition" field.
  22151. func (m *SopNodeMutation) SetNoReplyCondition(u uint64) {
  22152. m.no_reply_condition = &u
  22153. m.addno_reply_condition = nil
  22154. }
  22155. // NoReplyCondition returns the value of the "no_reply_condition" field in the mutation.
  22156. func (m *SopNodeMutation) NoReplyCondition() (r uint64, exists bool) {
  22157. v := m.no_reply_condition
  22158. if v == nil {
  22159. return
  22160. }
  22161. return *v, true
  22162. }
  22163. // OldNoReplyCondition returns the old "no_reply_condition" field's value of the SopNode entity.
  22164. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  22165. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22166. func (m *SopNodeMutation) OldNoReplyCondition(ctx context.Context) (v uint64, err error) {
  22167. if !m.op.Is(OpUpdateOne) {
  22168. return v, errors.New("OldNoReplyCondition is only allowed on UpdateOne operations")
  22169. }
  22170. if m.id == nil || m.oldValue == nil {
  22171. return v, errors.New("OldNoReplyCondition requires an ID field in the mutation")
  22172. }
  22173. oldValue, err := m.oldValue(ctx)
  22174. if err != nil {
  22175. return v, fmt.Errorf("querying old value for OldNoReplyCondition: %w", err)
  22176. }
  22177. return oldValue.NoReplyCondition, nil
  22178. }
  22179. // AddNoReplyCondition adds u to the "no_reply_condition" field.
  22180. func (m *SopNodeMutation) AddNoReplyCondition(u int64) {
  22181. if m.addno_reply_condition != nil {
  22182. *m.addno_reply_condition += u
  22183. } else {
  22184. m.addno_reply_condition = &u
  22185. }
  22186. }
  22187. // AddedNoReplyCondition returns the value that was added to the "no_reply_condition" field in this mutation.
  22188. func (m *SopNodeMutation) AddedNoReplyCondition() (r int64, exists bool) {
  22189. v := m.addno_reply_condition
  22190. if v == nil {
  22191. return
  22192. }
  22193. return *v, true
  22194. }
  22195. // ResetNoReplyCondition resets all changes to the "no_reply_condition" field.
  22196. func (m *SopNodeMutation) ResetNoReplyCondition() {
  22197. m.no_reply_condition = nil
  22198. m.addno_reply_condition = nil
  22199. }
  22200. // SetNoReplyUnit sets the "no_reply_unit" field.
  22201. func (m *SopNodeMutation) SetNoReplyUnit(s string) {
  22202. m.no_reply_unit = &s
  22203. }
  22204. // NoReplyUnit returns the value of the "no_reply_unit" field in the mutation.
  22205. func (m *SopNodeMutation) NoReplyUnit() (r string, exists bool) {
  22206. v := m.no_reply_unit
  22207. if v == nil {
  22208. return
  22209. }
  22210. return *v, true
  22211. }
  22212. // OldNoReplyUnit returns the old "no_reply_unit" field's value of the SopNode entity.
  22213. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  22214. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22215. func (m *SopNodeMutation) OldNoReplyUnit(ctx context.Context) (v string, err error) {
  22216. if !m.op.Is(OpUpdateOne) {
  22217. return v, errors.New("OldNoReplyUnit is only allowed on UpdateOne operations")
  22218. }
  22219. if m.id == nil || m.oldValue == nil {
  22220. return v, errors.New("OldNoReplyUnit requires an ID field in the mutation")
  22221. }
  22222. oldValue, err := m.oldValue(ctx)
  22223. if err != nil {
  22224. return v, fmt.Errorf("querying old value for OldNoReplyUnit: %w", err)
  22225. }
  22226. return oldValue.NoReplyUnit, nil
  22227. }
  22228. // ResetNoReplyUnit resets all changes to the "no_reply_unit" field.
  22229. func (m *SopNodeMutation) ResetNoReplyUnit() {
  22230. m.no_reply_unit = nil
  22231. }
  22232. // SetActionMessage sets the "action_message" field.
  22233. func (m *SopNodeMutation) SetActionMessage(ct []custom_types.Action) {
  22234. m.action_message = &ct
  22235. m.appendaction_message = nil
  22236. }
  22237. // ActionMessage returns the value of the "action_message" field in the mutation.
  22238. func (m *SopNodeMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  22239. v := m.action_message
  22240. if v == nil {
  22241. return
  22242. }
  22243. return *v, true
  22244. }
  22245. // OldActionMessage returns the old "action_message" field's value of the SopNode entity.
  22246. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  22247. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22248. func (m *SopNodeMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  22249. if !m.op.Is(OpUpdateOne) {
  22250. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  22251. }
  22252. if m.id == nil || m.oldValue == nil {
  22253. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  22254. }
  22255. oldValue, err := m.oldValue(ctx)
  22256. if err != nil {
  22257. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  22258. }
  22259. return oldValue.ActionMessage, nil
  22260. }
  22261. // AppendActionMessage adds ct to the "action_message" field.
  22262. func (m *SopNodeMutation) AppendActionMessage(ct []custom_types.Action) {
  22263. m.appendaction_message = append(m.appendaction_message, ct...)
  22264. }
  22265. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  22266. func (m *SopNodeMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  22267. if len(m.appendaction_message) == 0 {
  22268. return nil, false
  22269. }
  22270. return m.appendaction_message, true
  22271. }
  22272. // ClearActionMessage clears the value of the "action_message" field.
  22273. func (m *SopNodeMutation) ClearActionMessage() {
  22274. m.action_message = nil
  22275. m.appendaction_message = nil
  22276. m.clearedFields[sopnode.FieldActionMessage] = struct{}{}
  22277. }
  22278. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  22279. func (m *SopNodeMutation) ActionMessageCleared() bool {
  22280. _, ok := m.clearedFields[sopnode.FieldActionMessage]
  22281. return ok
  22282. }
  22283. // ResetActionMessage resets all changes to the "action_message" field.
  22284. func (m *SopNodeMutation) ResetActionMessage() {
  22285. m.action_message = nil
  22286. m.appendaction_message = nil
  22287. delete(m.clearedFields, sopnode.FieldActionMessage)
  22288. }
  22289. // SetActionLabelAdd sets the "action_label_add" field.
  22290. func (m *SopNodeMutation) SetActionLabelAdd(u []uint64) {
  22291. m.action_label_add = &u
  22292. m.appendaction_label_add = nil
  22293. }
  22294. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  22295. func (m *SopNodeMutation) ActionLabelAdd() (r []uint64, exists bool) {
  22296. v := m.action_label_add
  22297. if v == nil {
  22298. return
  22299. }
  22300. return *v, true
  22301. }
  22302. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopNode entity.
  22303. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  22304. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22305. func (m *SopNodeMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  22306. if !m.op.Is(OpUpdateOne) {
  22307. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  22308. }
  22309. if m.id == nil || m.oldValue == nil {
  22310. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  22311. }
  22312. oldValue, err := m.oldValue(ctx)
  22313. if err != nil {
  22314. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  22315. }
  22316. return oldValue.ActionLabelAdd, nil
  22317. }
  22318. // AppendActionLabelAdd adds u to the "action_label_add" field.
  22319. func (m *SopNodeMutation) AppendActionLabelAdd(u []uint64) {
  22320. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  22321. }
  22322. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  22323. func (m *SopNodeMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  22324. if len(m.appendaction_label_add) == 0 {
  22325. return nil, false
  22326. }
  22327. return m.appendaction_label_add, true
  22328. }
  22329. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  22330. func (m *SopNodeMutation) ClearActionLabelAdd() {
  22331. m.action_label_add = nil
  22332. m.appendaction_label_add = nil
  22333. m.clearedFields[sopnode.FieldActionLabelAdd] = struct{}{}
  22334. }
  22335. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  22336. func (m *SopNodeMutation) ActionLabelAddCleared() bool {
  22337. _, ok := m.clearedFields[sopnode.FieldActionLabelAdd]
  22338. return ok
  22339. }
  22340. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  22341. func (m *SopNodeMutation) ResetActionLabelAdd() {
  22342. m.action_label_add = nil
  22343. m.appendaction_label_add = nil
  22344. delete(m.clearedFields, sopnode.FieldActionLabelAdd)
  22345. }
  22346. // SetActionLabelDel sets the "action_label_del" field.
  22347. func (m *SopNodeMutation) SetActionLabelDel(u []uint64) {
  22348. m.action_label_del = &u
  22349. m.appendaction_label_del = nil
  22350. }
  22351. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  22352. func (m *SopNodeMutation) ActionLabelDel() (r []uint64, exists bool) {
  22353. v := m.action_label_del
  22354. if v == nil {
  22355. return
  22356. }
  22357. return *v, true
  22358. }
  22359. // OldActionLabelDel returns the old "action_label_del" field's value of the SopNode entity.
  22360. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  22361. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22362. func (m *SopNodeMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  22363. if !m.op.Is(OpUpdateOne) {
  22364. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  22365. }
  22366. if m.id == nil || m.oldValue == nil {
  22367. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  22368. }
  22369. oldValue, err := m.oldValue(ctx)
  22370. if err != nil {
  22371. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  22372. }
  22373. return oldValue.ActionLabelDel, nil
  22374. }
  22375. // AppendActionLabelDel adds u to the "action_label_del" field.
  22376. func (m *SopNodeMutation) AppendActionLabelDel(u []uint64) {
  22377. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  22378. }
  22379. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  22380. func (m *SopNodeMutation) AppendedActionLabelDel() ([]uint64, bool) {
  22381. if len(m.appendaction_label_del) == 0 {
  22382. return nil, false
  22383. }
  22384. return m.appendaction_label_del, true
  22385. }
  22386. // ClearActionLabelDel clears the value of the "action_label_del" field.
  22387. func (m *SopNodeMutation) ClearActionLabelDel() {
  22388. m.action_label_del = nil
  22389. m.appendaction_label_del = nil
  22390. m.clearedFields[sopnode.FieldActionLabelDel] = struct{}{}
  22391. }
  22392. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  22393. func (m *SopNodeMutation) ActionLabelDelCleared() bool {
  22394. _, ok := m.clearedFields[sopnode.FieldActionLabelDel]
  22395. return ok
  22396. }
  22397. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  22398. func (m *SopNodeMutation) ResetActionLabelDel() {
  22399. m.action_label_del = nil
  22400. m.appendaction_label_del = nil
  22401. delete(m.clearedFields, sopnode.FieldActionLabelDel)
  22402. }
  22403. // SetActionForward sets the "action_forward" field.
  22404. func (m *SopNodeMutation) SetActionForward(ctf *custom_types.ActionForward) {
  22405. m.action_forward = &ctf
  22406. }
  22407. // ActionForward returns the value of the "action_forward" field in the mutation.
  22408. func (m *SopNodeMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  22409. v := m.action_forward
  22410. if v == nil {
  22411. return
  22412. }
  22413. return *v, true
  22414. }
  22415. // OldActionForward returns the old "action_forward" field's value of the SopNode entity.
  22416. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  22417. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22418. func (m *SopNodeMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  22419. if !m.op.Is(OpUpdateOne) {
  22420. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  22421. }
  22422. if m.id == nil || m.oldValue == nil {
  22423. return v, errors.New("OldActionForward requires an ID field in the mutation")
  22424. }
  22425. oldValue, err := m.oldValue(ctx)
  22426. if err != nil {
  22427. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  22428. }
  22429. return oldValue.ActionForward, nil
  22430. }
  22431. // ClearActionForward clears the value of the "action_forward" field.
  22432. func (m *SopNodeMutation) ClearActionForward() {
  22433. m.action_forward = nil
  22434. m.clearedFields[sopnode.FieldActionForward] = struct{}{}
  22435. }
  22436. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  22437. func (m *SopNodeMutation) ActionForwardCleared() bool {
  22438. _, ok := m.clearedFields[sopnode.FieldActionForward]
  22439. return ok
  22440. }
  22441. // ResetActionForward resets all changes to the "action_forward" field.
  22442. func (m *SopNodeMutation) ResetActionForward() {
  22443. m.action_forward = nil
  22444. delete(m.clearedFields, sopnode.FieldActionForward)
  22445. }
  22446. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  22447. func (m *SopNodeMutation) SetSopStageID(id uint64) {
  22448. m.sop_stage = &id
  22449. }
  22450. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  22451. func (m *SopNodeMutation) ClearSopStage() {
  22452. m.clearedsop_stage = true
  22453. m.clearedFields[sopnode.FieldStageID] = struct{}{}
  22454. }
  22455. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  22456. func (m *SopNodeMutation) SopStageCleared() bool {
  22457. return m.clearedsop_stage
  22458. }
  22459. // SopStageID returns the "sop_stage" edge ID in the mutation.
  22460. func (m *SopNodeMutation) SopStageID() (id uint64, exists bool) {
  22461. if m.sop_stage != nil {
  22462. return *m.sop_stage, true
  22463. }
  22464. return
  22465. }
  22466. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  22467. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  22468. // SopStageID instead. It exists only for internal usage by the builders.
  22469. func (m *SopNodeMutation) SopStageIDs() (ids []uint64) {
  22470. if id := m.sop_stage; id != nil {
  22471. ids = append(ids, *id)
  22472. }
  22473. return
  22474. }
  22475. // ResetSopStage resets all changes to the "sop_stage" edge.
  22476. func (m *SopNodeMutation) ResetSopStage() {
  22477. m.sop_stage = nil
  22478. m.clearedsop_stage = false
  22479. }
  22480. // AddNodeMessageIDs adds the "node_messages" edge to the MessageRecords entity by ids.
  22481. func (m *SopNodeMutation) AddNodeMessageIDs(ids ...uint64) {
  22482. if m.node_messages == nil {
  22483. m.node_messages = make(map[uint64]struct{})
  22484. }
  22485. for i := range ids {
  22486. m.node_messages[ids[i]] = struct{}{}
  22487. }
  22488. }
  22489. // ClearNodeMessages clears the "node_messages" edge to the MessageRecords entity.
  22490. func (m *SopNodeMutation) ClearNodeMessages() {
  22491. m.clearednode_messages = true
  22492. }
  22493. // NodeMessagesCleared reports if the "node_messages" edge to the MessageRecords entity was cleared.
  22494. func (m *SopNodeMutation) NodeMessagesCleared() bool {
  22495. return m.clearednode_messages
  22496. }
  22497. // RemoveNodeMessageIDs removes the "node_messages" edge to the MessageRecords entity by IDs.
  22498. func (m *SopNodeMutation) RemoveNodeMessageIDs(ids ...uint64) {
  22499. if m.removednode_messages == nil {
  22500. m.removednode_messages = make(map[uint64]struct{})
  22501. }
  22502. for i := range ids {
  22503. delete(m.node_messages, ids[i])
  22504. m.removednode_messages[ids[i]] = struct{}{}
  22505. }
  22506. }
  22507. // RemovedNodeMessages returns the removed IDs of the "node_messages" edge to the MessageRecords entity.
  22508. func (m *SopNodeMutation) RemovedNodeMessagesIDs() (ids []uint64) {
  22509. for id := range m.removednode_messages {
  22510. ids = append(ids, id)
  22511. }
  22512. return
  22513. }
  22514. // NodeMessagesIDs returns the "node_messages" edge IDs in the mutation.
  22515. func (m *SopNodeMutation) NodeMessagesIDs() (ids []uint64) {
  22516. for id := range m.node_messages {
  22517. ids = append(ids, id)
  22518. }
  22519. return
  22520. }
  22521. // ResetNodeMessages resets all changes to the "node_messages" edge.
  22522. func (m *SopNodeMutation) ResetNodeMessages() {
  22523. m.node_messages = nil
  22524. m.clearednode_messages = false
  22525. m.removednode_messages = nil
  22526. }
  22527. // Where appends a list predicates to the SopNodeMutation builder.
  22528. func (m *SopNodeMutation) Where(ps ...predicate.SopNode) {
  22529. m.predicates = append(m.predicates, ps...)
  22530. }
  22531. // WhereP appends storage-level predicates to the SopNodeMutation builder. Using this method,
  22532. // users can use type-assertion to append predicates that do not depend on any generated package.
  22533. func (m *SopNodeMutation) WhereP(ps ...func(*sql.Selector)) {
  22534. p := make([]predicate.SopNode, len(ps))
  22535. for i := range ps {
  22536. p[i] = ps[i]
  22537. }
  22538. m.Where(p...)
  22539. }
  22540. // Op returns the operation name.
  22541. func (m *SopNodeMutation) Op() Op {
  22542. return m.op
  22543. }
  22544. // SetOp allows setting the mutation operation.
  22545. func (m *SopNodeMutation) SetOp(op Op) {
  22546. m.op = op
  22547. }
  22548. // Type returns the node type of this mutation (SopNode).
  22549. func (m *SopNodeMutation) Type() string {
  22550. return m.typ
  22551. }
  22552. // Fields returns all fields that were changed during this mutation. Note that in
  22553. // order to get all numeric fields that were incremented/decremented, call
  22554. // AddedFields().
  22555. func (m *SopNodeMutation) Fields() []string {
  22556. fields := make([]string, 0, 15)
  22557. if m.created_at != nil {
  22558. fields = append(fields, sopnode.FieldCreatedAt)
  22559. }
  22560. if m.updated_at != nil {
  22561. fields = append(fields, sopnode.FieldUpdatedAt)
  22562. }
  22563. if m.status != nil {
  22564. fields = append(fields, sopnode.FieldStatus)
  22565. }
  22566. if m.deleted_at != nil {
  22567. fields = append(fields, sopnode.FieldDeletedAt)
  22568. }
  22569. if m.sop_stage != nil {
  22570. fields = append(fields, sopnode.FieldStageID)
  22571. }
  22572. if m.parent_id != nil {
  22573. fields = append(fields, sopnode.FieldParentID)
  22574. }
  22575. if m.name != nil {
  22576. fields = append(fields, sopnode.FieldName)
  22577. }
  22578. if m.condition_type != nil {
  22579. fields = append(fields, sopnode.FieldConditionType)
  22580. }
  22581. if m.condition_list != nil {
  22582. fields = append(fields, sopnode.FieldConditionList)
  22583. }
  22584. if m.no_reply_condition != nil {
  22585. fields = append(fields, sopnode.FieldNoReplyCondition)
  22586. }
  22587. if m.no_reply_unit != nil {
  22588. fields = append(fields, sopnode.FieldNoReplyUnit)
  22589. }
  22590. if m.action_message != nil {
  22591. fields = append(fields, sopnode.FieldActionMessage)
  22592. }
  22593. if m.action_label_add != nil {
  22594. fields = append(fields, sopnode.FieldActionLabelAdd)
  22595. }
  22596. if m.action_label_del != nil {
  22597. fields = append(fields, sopnode.FieldActionLabelDel)
  22598. }
  22599. if m.action_forward != nil {
  22600. fields = append(fields, sopnode.FieldActionForward)
  22601. }
  22602. return fields
  22603. }
  22604. // Field returns the value of a field with the given name. The second boolean
  22605. // return value indicates that this field was not set, or was not defined in the
  22606. // schema.
  22607. func (m *SopNodeMutation) Field(name string) (ent.Value, bool) {
  22608. switch name {
  22609. case sopnode.FieldCreatedAt:
  22610. return m.CreatedAt()
  22611. case sopnode.FieldUpdatedAt:
  22612. return m.UpdatedAt()
  22613. case sopnode.FieldStatus:
  22614. return m.Status()
  22615. case sopnode.FieldDeletedAt:
  22616. return m.DeletedAt()
  22617. case sopnode.FieldStageID:
  22618. return m.StageID()
  22619. case sopnode.FieldParentID:
  22620. return m.ParentID()
  22621. case sopnode.FieldName:
  22622. return m.Name()
  22623. case sopnode.FieldConditionType:
  22624. return m.ConditionType()
  22625. case sopnode.FieldConditionList:
  22626. return m.ConditionList()
  22627. case sopnode.FieldNoReplyCondition:
  22628. return m.NoReplyCondition()
  22629. case sopnode.FieldNoReplyUnit:
  22630. return m.NoReplyUnit()
  22631. case sopnode.FieldActionMessage:
  22632. return m.ActionMessage()
  22633. case sopnode.FieldActionLabelAdd:
  22634. return m.ActionLabelAdd()
  22635. case sopnode.FieldActionLabelDel:
  22636. return m.ActionLabelDel()
  22637. case sopnode.FieldActionForward:
  22638. return m.ActionForward()
  22639. }
  22640. return nil, false
  22641. }
  22642. // OldField returns the old value of the field from the database. An error is
  22643. // returned if the mutation operation is not UpdateOne, or the query to the
  22644. // database failed.
  22645. func (m *SopNodeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  22646. switch name {
  22647. case sopnode.FieldCreatedAt:
  22648. return m.OldCreatedAt(ctx)
  22649. case sopnode.FieldUpdatedAt:
  22650. return m.OldUpdatedAt(ctx)
  22651. case sopnode.FieldStatus:
  22652. return m.OldStatus(ctx)
  22653. case sopnode.FieldDeletedAt:
  22654. return m.OldDeletedAt(ctx)
  22655. case sopnode.FieldStageID:
  22656. return m.OldStageID(ctx)
  22657. case sopnode.FieldParentID:
  22658. return m.OldParentID(ctx)
  22659. case sopnode.FieldName:
  22660. return m.OldName(ctx)
  22661. case sopnode.FieldConditionType:
  22662. return m.OldConditionType(ctx)
  22663. case sopnode.FieldConditionList:
  22664. return m.OldConditionList(ctx)
  22665. case sopnode.FieldNoReplyCondition:
  22666. return m.OldNoReplyCondition(ctx)
  22667. case sopnode.FieldNoReplyUnit:
  22668. return m.OldNoReplyUnit(ctx)
  22669. case sopnode.FieldActionMessage:
  22670. return m.OldActionMessage(ctx)
  22671. case sopnode.FieldActionLabelAdd:
  22672. return m.OldActionLabelAdd(ctx)
  22673. case sopnode.FieldActionLabelDel:
  22674. return m.OldActionLabelDel(ctx)
  22675. case sopnode.FieldActionForward:
  22676. return m.OldActionForward(ctx)
  22677. }
  22678. return nil, fmt.Errorf("unknown SopNode field %s", name)
  22679. }
  22680. // SetField sets the value of a field with the given name. It returns an error if
  22681. // the field is not defined in the schema, or if the type mismatched the field
  22682. // type.
  22683. func (m *SopNodeMutation) SetField(name string, value ent.Value) error {
  22684. switch name {
  22685. case sopnode.FieldCreatedAt:
  22686. v, ok := value.(time.Time)
  22687. if !ok {
  22688. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22689. }
  22690. m.SetCreatedAt(v)
  22691. return nil
  22692. case sopnode.FieldUpdatedAt:
  22693. v, ok := value.(time.Time)
  22694. if !ok {
  22695. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22696. }
  22697. m.SetUpdatedAt(v)
  22698. return nil
  22699. case sopnode.FieldStatus:
  22700. v, ok := value.(uint8)
  22701. if !ok {
  22702. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22703. }
  22704. m.SetStatus(v)
  22705. return nil
  22706. case sopnode.FieldDeletedAt:
  22707. v, ok := value.(time.Time)
  22708. if !ok {
  22709. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22710. }
  22711. m.SetDeletedAt(v)
  22712. return nil
  22713. case sopnode.FieldStageID:
  22714. v, ok := value.(uint64)
  22715. if !ok {
  22716. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22717. }
  22718. m.SetStageID(v)
  22719. return nil
  22720. case sopnode.FieldParentID:
  22721. v, ok := value.(uint64)
  22722. if !ok {
  22723. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22724. }
  22725. m.SetParentID(v)
  22726. return nil
  22727. case sopnode.FieldName:
  22728. v, ok := value.(string)
  22729. if !ok {
  22730. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22731. }
  22732. m.SetName(v)
  22733. return nil
  22734. case sopnode.FieldConditionType:
  22735. v, ok := value.(int)
  22736. if !ok {
  22737. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22738. }
  22739. m.SetConditionType(v)
  22740. return nil
  22741. case sopnode.FieldConditionList:
  22742. v, ok := value.([]string)
  22743. if !ok {
  22744. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22745. }
  22746. m.SetConditionList(v)
  22747. return nil
  22748. case sopnode.FieldNoReplyCondition:
  22749. v, ok := value.(uint64)
  22750. if !ok {
  22751. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22752. }
  22753. m.SetNoReplyCondition(v)
  22754. return nil
  22755. case sopnode.FieldNoReplyUnit:
  22756. v, ok := value.(string)
  22757. if !ok {
  22758. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22759. }
  22760. m.SetNoReplyUnit(v)
  22761. return nil
  22762. case sopnode.FieldActionMessage:
  22763. v, ok := value.([]custom_types.Action)
  22764. if !ok {
  22765. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22766. }
  22767. m.SetActionMessage(v)
  22768. return nil
  22769. case sopnode.FieldActionLabelAdd:
  22770. v, ok := value.([]uint64)
  22771. if !ok {
  22772. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22773. }
  22774. m.SetActionLabelAdd(v)
  22775. return nil
  22776. case sopnode.FieldActionLabelDel:
  22777. v, ok := value.([]uint64)
  22778. if !ok {
  22779. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22780. }
  22781. m.SetActionLabelDel(v)
  22782. return nil
  22783. case sopnode.FieldActionForward:
  22784. v, ok := value.(*custom_types.ActionForward)
  22785. if !ok {
  22786. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22787. }
  22788. m.SetActionForward(v)
  22789. return nil
  22790. }
  22791. return fmt.Errorf("unknown SopNode field %s", name)
  22792. }
  22793. // AddedFields returns all numeric fields that were incremented/decremented during
  22794. // this mutation.
  22795. func (m *SopNodeMutation) AddedFields() []string {
  22796. var fields []string
  22797. if m.addstatus != nil {
  22798. fields = append(fields, sopnode.FieldStatus)
  22799. }
  22800. if m.addparent_id != nil {
  22801. fields = append(fields, sopnode.FieldParentID)
  22802. }
  22803. if m.addcondition_type != nil {
  22804. fields = append(fields, sopnode.FieldConditionType)
  22805. }
  22806. if m.addno_reply_condition != nil {
  22807. fields = append(fields, sopnode.FieldNoReplyCondition)
  22808. }
  22809. return fields
  22810. }
  22811. // AddedField returns the numeric value that was incremented/decremented on a field
  22812. // with the given name. The second boolean return value indicates that this field
  22813. // was not set, or was not defined in the schema.
  22814. func (m *SopNodeMutation) AddedField(name string) (ent.Value, bool) {
  22815. switch name {
  22816. case sopnode.FieldStatus:
  22817. return m.AddedStatus()
  22818. case sopnode.FieldParentID:
  22819. return m.AddedParentID()
  22820. case sopnode.FieldConditionType:
  22821. return m.AddedConditionType()
  22822. case sopnode.FieldNoReplyCondition:
  22823. return m.AddedNoReplyCondition()
  22824. }
  22825. return nil, false
  22826. }
  22827. // AddField adds the value to the field with the given name. It returns an error if
  22828. // the field is not defined in the schema, or if the type mismatched the field
  22829. // type.
  22830. func (m *SopNodeMutation) AddField(name string, value ent.Value) error {
  22831. switch name {
  22832. case sopnode.FieldStatus:
  22833. v, ok := value.(int8)
  22834. if !ok {
  22835. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22836. }
  22837. m.AddStatus(v)
  22838. return nil
  22839. case sopnode.FieldParentID:
  22840. v, ok := value.(int64)
  22841. if !ok {
  22842. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22843. }
  22844. m.AddParentID(v)
  22845. return nil
  22846. case sopnode.FieldConditionType:
  22847. v, ok := value.(int)
  22848. if !ok {
  22849. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22850. }
  22851. m.AddConditionType(v)
  22852. return nil
  22853. case sopnode.FieldNoReplyCondition:
  22854. v, ok := value.(int64)
  22855. if !ok {
  22856. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22857. }
  22858. m.AddNoReplyCondition(v)
  22859. return nil
  22860. }
  22861. return fmt.Errorf("unknown SopNode numeric field %s", name)
  22862. }
  22863. // ClearedFields returns all nullable fields that were cleared during this
  22864. // mutation.
  22865. func (m *SopNodeMutation) ClearedFields() []string {
  22866. var fields []string
  22867. if m.FieldCleared(sopnode.FieldStatus) {
  22868. fields = append(fields, sopnode.FieldStatus)
  22869. }
  22870. if m.FieldCleared(sopnode.FieldDeletedAt) {
  22871. fields = append(fields, sopnode.FieldDeletedAt)
  22872. }
  22873. if m.FieldCleared(sopnode.FieldConditionList) {
  22874. fields = append(fields, sopnode.FieldConditionList)
  22875. }
  22876. if m.FieldCleared(sopnode.FieldActionMessage) {
  22877. fields = append(fields, sopnode.FieldActionMessage)
  22878. }
  22879. if m.FieldCleared(sopnode.FieldActionLabelAdd) {
  22880. fields = append(fields, sopnode.FieldActionLabelAdd)
  22881. }
  22882. if m.FieldCleared(sopnode.FieldActionLabelDel) {
  22883. fields = append(fields, sopnode.FieldActionLabelDel)
  22884. }
  22885. if m.FieldCleared(sopnode.FieldActionForward) {
  22886. fields = append(fields, sopnode.FieldActionForward)
  22887. }
  22888. return fields
  22889. }
  22890. // FieldCleared returns a boolean indicating if a field with the given name was
  22891. // cleared in this mutation.
  22892. func (m *SopNodeMutation) FieldCleared(name string) bool {
  22893. _, ok := m.clearedFields[name]
  22894. return ok
  22895. }
  22896. // ClearField clears the value of the field with the given name. It returns an
  22897. // error if the field is not defined in the schema.
  22898. func (m *SopNodeMutation) ClearField(name string) error {
  22899. switch name {
  22900. case sopnode.FieldStatus:
  22901. m.ClearStatus()
  22902. return nil
  22903. case sopnode.FieldDeletedAt:
  22904. m.ClearDeletedAt()
  22905. return nil
  22906. case sopnode.FieldConditionList:
  22907. m.ClearConditionList()
  22908. return nil
  22909. case sopnode.FieldActionMessage:
  22910. m.ClearActionMessage()
  22911. return nil
  22912. case sopnode.FieldActionLabelAdd:
  22913. m.ClearActionLabelAdd()
  22914. return nil
  22915. case sopnode.FieldActionLabelDel:
  22916. m.ClearActionLabelDel()
  22917. return nil
  22918. case sopnode.FieldActionForward:
  22919. m.ClearActionForward()
  22920. return nil
  22921. }
  22922. return fmt.Errorf("unknown SopNode nullable field %s", name)
  22923. }
  22924. // ResetField resets all changes in the mutation for the field with the given name.
  22925. // It returns an error if the field is not defined in the schema.
  22926. func (m *SopNodeMutation) ResetField(name string) error {
  22927. switch name {
  22928. case sopnode.FieldCreatedAt:
  22929. m.ResetCreatedAt()
  22930. return nil
  22931. case sopnode.FieldUpdatedAt:
  22932. m.ResetUpdatedAt()
  22933. return nil
  22934. case sopnode.FieldStatus:
  22935. m.ResetStatus()
  22936. return nil
  22937. case sopnode.FieldDeletedAt:
  22938. m.ResetDeletedAt()
  22939. return nil
  22940. case sopnode.FieldStageID:
  22941. m.ResetStageID()
  22942. return nil
  22943. case sopnode.FieldParentID:
  22944. m.ResetParentID()
  22945. return nil
  22946. case sopnode.FieldName:
  22947. m.ResetName()
  22948. return nil
  22949. case sopnode.FieldConditionType:
  22950. m.ResetConditionType()
  22951. return nil
  22952. case sopnode.FieldConditionList:
  22953. m.ResetConditionList()
  22954. return nil
  22955. case sopnode.FieldNoReplyCondition:
  22956. m.ResetNoReplyCondition()
  22957. return nil
  22958. case sopnode.FieldNoReplyUnit:
  22959. m.ResetNoReplyUnit()
  22960. return nil
  22961. case sopnode.FieldActionMessage:
  22962. m.ResetActionMessage()
  22963. return nil
  22964. case sopnode.FieldActionLabelAdd:
  22965. m.ResetActionLabelAdd()
  22966. return nil
  22967. case sopnode.FieldActionLabelDel:
  22968. m.ResetActionLabelDel()
  22969. return nil
  22970. case sopnode.FieldActionForward:
  22971. m.ResetActionForward()
  22972. return nil
  22973. }
  22974. return fmt.Errorf("unknown SopNode field %s", name)
  22975. }
  22976. // AddedEdges returns all edge names that were set/added in this mutation.
  22977. func (m *SopNodeMutation) AddedEdges() []string {
  22978. edges := make([]string, 0, 2)
  22979. if m.sop_stage != nil {
  22980. edges = append(edges, sopnode.EdgeSopStage)
  22981. }
  22982. if m.node_messages != nil {
  22983. edges = append(edges, sopnode.EdgeNodeMessages)
  22984. }
  22985. return edges
  22986. }
  22987. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  22988. // name in this mutation.
  22989. func (m *SopNodeMutation) AddedIDs(name string) []ent.Value {
  22990. switch name {
  22991. case sopnode.EdgeSopStage:
  22992. if id := m.sop_stage; id != nil {
  22993. return []ent.Value{*id}
  22994. }
  22995. case sopnode.EdgeNodeMessages:
  22996. ids := make([]ent.Value, 0, len(m.node_messages))
  22997. for id := range m.node_messages {
  22998. ids = append(ids, id)
  22999. }
  23000. return ids
  23001. }
  23002. return nil
  23003. }
  23004. // RemovedEdges returns all edge names that were removed in this mutation.
  23005. func (m *SopNodeMutation) RemovedEdges() []string {
  23006. edges := make([]string, 0, 2)
  23007. if m.removednode_messages != nil {
  23008. edges = append(edges, sopnode.EdgeNodeMessages)
  23009. }
  23010. return edges
  23011. }
  23012. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  23013. // the given name in this mutation.
  23014. func (m *SopNodeMutation) RemovedIDs(name string) []ent.Value {
  23015. switch name {
  23016. case sopnode.EdgeNodeMessages:
  23017. ids := make([]ent.Value, 0, len(m.removednode_messages))
  23018. for id := range m.removednode_messages {
  23019. ids = append(ids, id)
  23020. }
  23021. return ids
  23022. }
  23023. return nil
  23024. }
  23025. // ClearedEdges returns all edge names that were cleared in this mutation.
  23026. func (m *SopNodeMutation) ClearedEdges() []string {
  23027. edges := make([]string, 0, 2)
  23028. if m.clearedsop_stage {
  23029. edges = append(edges, sopnode.EdgeSopStage)
  23030. }
  23031. if m.clearednode_messages {
  23032. edges = append(edges, sopnode.EdgeNodeMessages)
  23033. }
  23034. return edges
  23035. }
  23036. // EdgeCleared returns a boolean which indicates if the edge with the given name
  23037. // was cleared in this mutation.
  23038. func (m *SopNodeMutation) EdgeCleared(name string) bool {
  23039. switch name {
  23040. case sopnode.EdgeSopStage:
  23041. return m.clearedsop_stage
  23042. case sopnode.EdgeNodeMessages:
  23043. return m.clearednode_messages
  23044. }
  23045. return false
  23046. }
  23047. // ClearEdge clears the value of the edge with the given name. It returns an error
  23048. // if that edge is not defined in the schema.
  23049. func (m *SopNodeMutation) ClearEdge(name string) error {
  23050. switch name {
  23051. case sopnode.EdgeSopStage:
  23052. m.ClearSopStage()
  23053. return nil
  23054. }
  23055. return fmt.Errorf("unknown SopNode unique edge %s", name)
  23056. }
  23057. // ResetEdge resets all changes to the edge with the given name in this mutation.
  23058. // It returns an error if the edge is not defined in the schema.
  23059. func (m *SopNodeMutation) ResetEdge(name string) error {
  23060. switch name {
  23061. case sopnode.EdgeSopStage:
  23062. m.ResetSopStage()
  23063. return nil
  23064. case sopnode.EdgeNodeMessages:
  23065. m.ResetNodeMessages()
  23066. return nil
  23067. }
  23068. return fmt.Errorf("unknown SopNode edge %s", name)
  23069. }
  23070. // SopStageMutation represents an operation that mutates the SopStage nodes in the graph.
  23071. type SopStageMutation struct {
  23072. config
  23073. op Op
  23074. typ string
  23075. id *uint64
  23076. created_at *time.Time
  23077. updated_at *time.Time
  23078. status *uint8
  23079. addstatus *int8
  23080. deleted_at *time.Time
  23081. name *string
  23082. condition_type *int
  23083. addcondition_type *int
  23084. condition_operator *int
  23085. addcondition_operator *int
  23086. condition_list *[]custom_types.Condition
  23087. appendcondition_list []custom_types.Condition
  23088. action_message *[]custom_types.Action
  23089. appendaction_message []custom_types.Action
  23090. action_label_add *[]uint64
  23091. appendaction_label_add []uint64
  23092. action_label_del *[]uint64
  23093. appendaction_label_del []uint64
  23094. action_forward **custom_types.ActionForward
  23095. index_sort *int
  23096. addindex_sort *int
  23097. clearedFields map[string]struct{}
  23098. sop_task *uint64
  23099. clearedsop_task bool
  23100. stage_nodes map[uint64]struct{}
  23101. removedstage_nodes map[uint64]struct{}
  23102. clearedstage_nodes bool
  23103. stage_messages map[uint64]struct{}
  23104. removedstage_messages map[uint64]struct{}
  23105. clearedstage_messages bool
  23106. done bool
  23107. oldValue func(context.Context) (*SopStage, error)
  23108. predicates []predicate.SopStage
  23109. }
  23110. var _ ent.Mutation = (*SopStageMutation)(nil)
  23111. // sopstageOption allows management of the mutation configuration using functional options.
  23112. type sopstageOption func(*SopStageMutation)
  23113. // newSopStageMutation creates new mutation for the SopStage entity.
  23114. func newSopStageMutation(c config, op Op, opts ...sopstageOption) *SopStageMutation {
  23115. m := &SopStageMutation{
  23116. config: c,
  23117. op: op,
  23118. typ: TypeSopStage,
  23119. clearedFields: make(map[string]struct{}),
  23120. }
  23121. for _, opt := range opts {
  23122. opt(m)
  23123. }
  23124. return m
  23125. }
  23126. // withSopStageID sets the ID field of the mutation.
  23127. func withSopStageID(id uint64) sopstageOption {
  23128. return func(m *SopStageMutation) {
  23129. var (
  23130. err error
  23131. once sync.Once
  23132. value *SopStage
  23133. )
  23134. m.oldValue = func(ctx context.Context) (*SopStage, error) {
  23135. once.Do(func() {
  23136. if m.done {
  23137. err = errors.New("querying old values post mutation is not allowed")
  23138. } else {
  23139. value, err = m.Client().SopStage.Get(ctx, id)
  23140. }
  23141. })
  23142. return value, err
  23143. }
  23144. m.id = &id
  23145. }
  23146. }
  23147. // withSopStage sets the old SopStage of the mutation.
  23148. func withSopStage(node *SopStage) sopstageOption {
  23149. return func(m *SopStageMutation) {
  23150. m.oldValue = func(context.Context) (*SopStage, error) {
  23151. return node, nil
  23152. }
  23153. m.id = &node.ID
  23154. }
  23155. }
  23156. // Client returns a new `ent.Client` from the mutation. If the mutation was
  23157. // executed in a transaction (ent.Tx), a transactional client is returned.
  23158. func (m SopStageMutation) Client() *Client {
  23159. client := &Client{config: m.config}
  23160. client.init()
  23161. return client
  23162. }
  23163. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  23164. // it returns an error otherwise.
  23165. func (m SopStageMutation) Tx() (*Tx, error) {
  23166. if _, ok := m.driver.(*txDriver); !ok {
  23167. return nil, errors.New("ent: mutation is not running in a transaction")
  23168. }
  23169. tx := &Tx{config: m.config}
  23170. tx.init()
  23171. return tx, nil
  23172. }
  23173. // SetID sets the value of the id field. Note that this
  23174. // operation is only accepted on creation of SopStage entities.
  23175. func (m *SopStageMutation) SetID(id uint64) {
  23176. m.id = &id
  23177. }
  23178. // ID returns the ID value in the mutation. Note that the ID is only available
  23179. // if it was provided to the builder or after it was returned from the database.
  23180. func (m *SopStageMutation) ID() (id uint64, exists bool) {
  23181. if m.id == nil {
  23182. return
  23183. }
  23184. return *m.id, true
  23185. }
  23186. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  23187. // That means, if the mutation is applied within a transaction with an isolation level such
  23188. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  23189. // or updated by the mutation.
  23190. func (m *SopStageMutation) IDs(ctx context.Context) ([]uint64, error) {
  23191. switch {
  23192. case m.op.Is(OpUpdateOne | OpDeleteOne):
  23193. id, exists := m.ID()
  23194. if exists {
  23195. return []uint64{id}, nil
  23196. }
  23197. fallthrough
  23198. case m.op.Is(OpUpdate | OpDelete):
  23199. return m.Client().SopStage.Query().Where(m.predicates...).IDs(ctx)
  23200. default:
  23201. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  23202. }
  23203. }
  23204. // SetCreatedAt sets the "created_at" field.
  23205. func (m *SopStageMutation) SetCreatedAt(t time.Time) {
  23206. m.created_at = &t
  23207. }
  23208. // CreatedAt returns the value of the "created_at" field in the mutation.
  23209. func (m *SopStageMutation) CreatedAt() (r time.Time, exists bool) {
  23210. v := m.created_at
  23211. if v == nil {
  23212. return
  23213. }
  23214. return *v, true
  23215. }
  23216. // OldCreatedAt returns the old "created_at" field's value of the SopStage entity.
  23217. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  23218. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23219. func (m *SopStageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  23220. if !m.op.Is(OpUpdateOne) {
  23221. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  23222. }
  23223. if m.id == nil || m.oldValue == nil {
  23224. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  23225. }
  23226. oldValue, err := m.oldValue(ctx)
  23227. if err != nil {
  23228. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  23229. }
  23230. return oldValue.CreatedAt, nil
  23231. }
  23232. // ResetCreatedAt resets all changes to the "created_at" field.
  23233. func (m *SopStageMutation) ResetCreatedAt() {
  23234. m.created_at = nil
  23235. }
  23236. // SetUpdatedAt sets the "updated_at" field.
  23237. func (m *SopStageMutation) SetUpdatedAt(t time.Time) {
  23238. m.updated_at = &t
  23239. }
  23240. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  23241. func (m *SopStageMutation) UpdatedAt() (r time.Time, exists bool) {
  23242. v := m.updated_at
  23243. if v == nil {
  23244. return
  23245. }
  23246. return *v, true
  23247. }
  23248. // OldUpdatedAt returns the old "updated_at" field's value of the SopStage entity.
  23249. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  23250. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23251. func (m *SopStageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  23252. if !m.op.Is(OpUpdateOne) {
  23253. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  23254. }
  23255. if m.id == nil || m.oldValue == nil {
  23256. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  23257. }
  23258. oldValue, err := m.oldValue(ctx)
  23259. if err != nil {
  23260. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  23261. }
  23262. return oldValue.UpdatedAt, nil
  23263. }
  23264. // ResetUpdatedAt resets all changes to the "updated_at" field.
  23265. func (m *SopStageMutation) ResetUpdatedAt() {
  23266. m.updated_at = nil
  23267. }
  23268. // SetStatus sets the "status" field.
  23269. func (m *SopStageMutation) SetStatus(u uint8) {
  23270. m.status = &u
  23271. m.addstatus = nil
  23272. }
  23273. // Status returns the value of the "status" field in the mutation.
  23274. func (m *SopStageMutation) Status() (r uint8, exists bool) {
  23275. v := m.status
  23276. if v == nil {
  23277. return
  23278. }
  23279. return *v, true
  23280. }
  23281. // OldStatus returns the old "status" field's value of the SopStage entity.
  23282. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  23283. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23284. func (m *SopStageMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  23285. if !m.op.Is(OpUpdateOne) {
  23286. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  23287. }
  23288. if m.id == nil || m.oldValue == nil {
  23289. return v, errors.New("OldStatus requires an ID field in the mutation")
  23290. }
  23291. oldValue, err := m.oldValue(ctx)
  23292. if err != nil {
  23293. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  23294. }
  23295. return oldValue.Status, nil
  23296. }
  23297. // AddStatus adds u to the "status" field.
  23298. func (m *SopStageMutation) AddStatus(u int8) {
  23299. if m.addstatus != nil {
  23300. *m.addstatus += u
  23301. } else {
  23302. m.addstatus = &u
  23303. }
  23304. }
  23305. // AddedStatus returns the value that was added to the "status" field in this mutation.
  23306. func (m *SopStageMutation) AddedStatus() (r int8, exists bool) {
  23307. v := m.addstatus
  23308. if v == nil {
  23309. return
  23310. }
  23311. return *v, true
  23312. }
  23313. // ClearStatus clears the value of the "status" field.
  23314. func (m *SopStageMutation) ClearStatus() {
  23315. m.status = nil
  23316. m.addstatus = nil
  23317. m.clearedFields[sopstage.FieldStatus] = struct{}{}
  23318. }
  23319. // StatusCleared returns if the "status" field was cleared in this mutation.
  23320. func (m *SopStageMutation) StatusCleared() bool {
  23321. _, ok := m.clearedFields[sopstage.FieldStatus]
  23322. return ok
  23323. }
  23324. // ResetStatus resets all changes to the "status" field.
  23325. func (m *SopStageMutation) ResetStatus() {
  23326. m.status = nil
  23327. m.addstatus = nil
  23328. delete(m.clearedFields, sopstage.FieldStatus)
  23329. }
  23330. // SetDeletedAt sets the "deleted_at" field.
  23331. func (m *SopStageMutation) SetDeletedAt(t time.Time) {
  23332. m.deleted_at = &t
  23333. }
  23334. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  23335. func (m *SopStageMutation) DeletedAt() (r time.Time, exists bool) {
  23336. v := m.deleted_at
  23337. if v == nil {
  23338. return
  23339. }
  23340. return *v, true
  23341. }
  23342. // OldDeletedAt returns the old "deleted_at" field's value of the SopStage entity.
  23343. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  23344. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23345. func (m *SopStageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  23346. if !m.op.Is(OpUpdateOne) {
  23347. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  23348. }
  23349. if m.id == nil || m.oldValue == nil {
  23350. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  23351. }
  23352. oldValue, err := m.oldValue(ctx)
  23353. if err != nil {
  23354. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  23355. }
  23356. return oldValue.DeletedAt, nil
  23357. }
  23358. // ClearDeletedAt clears the value of the "deleted_at" field.
  23359. func (m *SopStageMutation) ClearDeletedAt() {
  23360. m.deleted_at = nil
  23361. m.clearedFields[sopstage.FieldDeletedAt] = struct{}{}
  23362. }
  23363. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  23364. func (m *SopStageMutation) DeletedAtCleared() bool {
  23365. _, ok := m.clearedFields[sopstage.FieldDeletedAt]
  23366. return ok
  23367. }
  23368. // ResetDeletedAt resets all changes to the "deleted_at" field.
  23369. func (m *SopStageMutation) ResetDeletedAt() {
  23370. m.deleted_at = nil
  23371. delete(m.clearedFields, sopstage.FieldDeletedAt)
  23372. }
  23373. // SetTaskID sets the "task_id" field.
  23374. func (m *SopStageMutation) SetTaskID(u uint64) {
  23375. m.sop_task = &u
  23376. }
  23377. // TaskID returns the value of the "task_id" field in the mutation.
  23378. func (m *SopStageMutation) TaskID() (r uint64, exists bool) {
  23379. v := m.sop_task
  23380. if v == nil {
  23381. return
  23382. }
  23383. return *v, true
  23384. }
  23385. // OldTaskID returns the old "task_id" field's value of the SopStage entity.
  23386. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  23387. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23388. func (m *SopStageMutation) OldTaskID(ctx context.Context) (v uint64, err error) {
  23389. if !m.op.Is(OpUpdateOne) {
  23390. return v, errors.New("OldTaskID is only allowed on UpdateOne operations")
  23391. }
  23392. if m.id == nil || m.oldValue == nil {
  23393. return v, errors.New("OldTaskID requires an ID field in the mutation")
  23394. }
  23395. oldValue, err := m.oldValue(ctx)
  23396. if err != nil {
  23397. return v, fmt.Errorf("querying old value for OldTaskID: %w", err)
  23398. }
  23399. return oldValue.TaskID, nil
  23400. }
  23401. // ResetTaskID resets all changes to the "task_id" field.
  23402. func (m *SopStageMutation) ResetTaskID() {
  23403. m.sop_task = nil
  23404. }
  23405. // SetName sets the "name" field.
  23406. func (m *SopStageMutation) SetName(s string) {
  23407. m.name = &s
  23408. }
  23409. // Name returns the value of the "name" field in the mutation.
  23410. func (m *SopStageMutation) Name() (r string, exists bool) {
  23411. v := m.name
  23412. if v == nil {
  23413. return
  23414. }
  23415. return *v, true
  23416. }
  23417. // OldName returns the old "name" field's value of the SopStage entity.
  23418. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  23419. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23420. func (m *SopStageMutation) OldName(ctx context.Context) (v string, err error) {
  23421. if !m.op.Is(OpUpdateOne) {
  23422. return v, errors.New("OldName is only allowed on UpdateOne operations")
  23423. }
  23424. if m.id == nil || m.oldValue == nil {
  23425. return v, errors.New("OldName requires an ID field in the mutation")
  23426. }
  23427. oldValue, err := m.oldValue(ctx)
  23428. if err != nil {
  23429. return v, fmt.Errorf("querying old value for OldName: %w", err)
  23430. }
  23431. return oldValue.Name, nil
  23432. }
  23433. // ResetName resets all changes to the "name" field.
  23434. func (m *SopStageMutation) ResetName() {
  23435. m.name = nil
  23436. }
  23437. // SetConditionType sets the "condition_type" field.
  23438. func (m *SopStageMutation) SetConditionType(i int) {
  23439. m.condition_type = &i
  23440. m.addcondition_type = nil
  23441. }
  23442. // ConditionType returns the value of the "condition_type" field in the mutation.
  23443. func (m *SopStageMutation) ConditionType() (r int, exists bool) {
  23444. v := m.condition_type
  23445. if v == nil {
  23446. return
  23447. }
  23448. return *v, true
  23449. }
  23450. // OldConditionType returns the old "condition_type" field's value of the SopStage entity.
  23451. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  23452. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23453. func (m *SopStageMutation) OldConditionType(ctx context.Context) (v int, err error) {
  23454. if !m.op.Is(OpUpdateOne) {
  23455. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  23456. }
  23457. if m.id == nil || m.oldValue == nil {
  23458. return v, errors.New("OldConditionType requires an ID field in the mutation")
  23459. }
  23460. oldValue, err := m.oldValue(ctx)
  23461. if err != nil {
  23462. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  23463. }
  23464. return oldValue.ConditionType, nil
  23465. }
  23466. // AddConditionType adds i to the "condition_type" field.
  23467. func (m *SopStageMutation) AddConditionType(i int) {
  23468. if m.addcondition_type != nil {
  23469. *m.addcondition_type += i
  23470. } else {
  23471. m.addcondition_type = &i
  23472. }
  23473. }
  23474. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  23475. func (m *SopStageMutation) AddedConditionType() (r int, exists bool) {
  23476. v := m.addcondition_type
  23477. if v == nil {
  23478. return
  23479. }
  23480. return *v, true
  23481. }
  23482. // ResetConditionType resets all changes to the "condition_type" field.
  23483. func (m *SopStageMutation) ResetConditionType() {
  23484. m.condition_type = nil
  23485. m.addcondition_type = nil
  23486. }
  23487. // SetConditionOperator sets the "condition_operator" field.
  23488. func (m *SopStageMutation) SetConditionOperator(i int) {
  23489. m.condition_operator = &i
  23490. m.addcondition_operator = nil
  23491. }
  23492. // ConditionOperator returns the value of the "condition_operator" field in the mutation.
  23493. func (m *SopStageMutation) ConditionOperator() (r int, exists bool) {
  23494. v := m.condition_operator
  23495. if v == nil {
  23496. return
  23497. }
  23498. return *v, true
  23499. }
  23500. // OldConditionOperator returns the old "condition_operator" field's value of the SopStage entity.
  23501. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  23502. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23503. func (m *SopStageMutation) OldConditionOperator(ctx context.Context) (v int, err error) {
  23504. if !m.op.Is(OpUpdateOne) {
  23505. return v, errors.New("OldConditionOperator is only allowed on UpdateOne operations")
  23506. }
  23507. if m.id == nil || m.oldValue == nil {
  23508. return v, errors.New("OldConditionOperator requires an ID field in the mutation")
  23509. }
  23510. oldValue, err := m.oldValue(ctx)
  23511. if err != nil {
  23512. return v, fmt.Errorf("querying old value for OldConditionOperator: %w", err)
  23513. }
  23514. return oldValue.ConditionOperator, nil
  23515. }
  23516. // AddConditionOperator adds i to the "condition_operator" field.
  23517. func (m *SopStageMutation) AddConditionOperator(i int) {
  23518. if m.addcondition_operator != nil {
  23519. *m.addcondition_operator += i
  23520. } else {
  23521. m.addcondition_operator = &i
  23522. }
  23523. }
  23524. // AddedConditionOperator returns the value that was added to the "condition_operator" field in this mutation.
  23525. func (m *SopStageMutation) AddedConditionOperator() (r int, exists bool) {
  23526. v := m.addcondition_operator
  23527. if v == nil {
  23528. return
  23529. }
  23530. return *v, true
  23531. }
  23532. // ResetConditionOperator resets all changes to the "condition_operator" field.
  23533. func (m *SopStageMutation) ResetConditionOperator() {
  23534. m.condition_operator = nil
  23535. m.addcondition_operator = nil
  23536. }
  23537. // SetConditionList sets the "condition_list" field.
  23538. func (m *SopStageMutation) SetConditionList(ct []custom_types.Condition) {
  23539. m.condition_list = &ct
  23540. m.appendcondition_list = nil
  23541. }
  23542. // ConditionList returns the value of the "condition_list" field in the mutation.
  23543. func (m *SopStageMutation) ConditionList() (r []custom_types.Condition, exists bool) {
  23544. v := m.condition_list
  23545. if v == nil {
  23546. return
  23547. }
  23548. return *v, true
  23549. }
  23550. // OldConditionList returns the old "condition_list" field's value of the SopStage entity.
  23551. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  23552. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23553. func (m *SopStageMutation) OldConditionList(ctx context.Context) (v []custom_types.Condition, err error) {
  23554. if !m.op.Is(OpUpdateOne) {
  23555. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  23556. }
  23557. if m.id == nil || m.oldValue == nil {
  23558. return v, errors.New("OldConditionList requires an ID field in the mutation")
  23559. }
  23560. oldValue, err := m.oldValue(ctx)
  23561. if err != nil {
  23562. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  23563. }
  23564. return oldValue.ConditionList, nil
  23565. }
  23566. // AppendConditionList adds ct to the "condition_list" field.
  23567. func (m *SopStageMutation) AppendConditionList(ct []custom_types.Condition) {
  23568. m.appendcondition_list = append(m.appendcondition_list, ct...)
  23569. }
  23570. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  23571. func (m *SopStageMutation) AppendedConditionList() ([]custom_types.Condition, bool) {
  23572. if len(m.appendcondition_list) == 0 {
  23573. return nil, false
  23574. }
  23575. return m.appendcondition_list, true
  23576. }
  23577. // ResetConditionList resets all changes to the "condition_list" field.
  23578. func (m *SopStageMutation) ResetConditionList() {
  23579. m.condition_list = nil
  23580. m.appendcondition_list = nil
  23581. }
  23582. // SetActionMessage sets the "action_message" field.
  23583. func (m *SopStageMutation) SetActionMessage(ct []custom_types.Action) {
  23584. m.action_message = &ct
  23585. m.appendaction_message = nil
  23586. }
  23587. // ActionMessage returns the value of the "action_message" field in the mutation.
  23588. func (m *SopStageMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  23589. v := m.action_message
  23590. if v == nil {
  23591. return
  23592. }
  23593. return *v, true
  23594. }
  23595. // OldActionMessage returns the old "action_message" field's value of the SopStage entity.
  23596. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  23597. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23598. func (m *SopStageMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  23599. if !m.op.Is(OpUpdateOne) {
  23600. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  23601. }
  23602. if m.id == nil || m.oldValue == nil {
  23603. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  23604. }
  23605. oldValue, err := m.oldValue(ctx)
  23606. if err != nil {
  23607. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  23608. }
  23609. return oldValue.ActionMessage, nil
  23610. }
  23611. // AppendActionMessage adds ct to the "action_message" field.
  23612. func (m *SopStageMutation) AppendActionMessage(ct []custom_types.Action) {
  23613. m.appendaction_message = append(m.appendaction_message, ct...)
  23614. }
  23615. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  23616. func (m *SopStageMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  23617. if len(m.appendaction_message) == 0 {
  23618. return nil, false
  23619. }
  23620. return m.appendaction_message, true
  23621. }
  23622. // ClearActionMessage clears the value of the "action_message" field.
  23623. func (m *SopStageMutation) ClearActionMessage() {
  23624. m.action_message = nil
  23625. m.appendaction_message = nil
  23626. m.clearedFields[sopstage.FieldActionMessage] = struct{}{}
  23627. }
  23628. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  23629. func (m *SopStageMutation) ActionMessageCleared() bool {
  23630. _, ok := m.clearedFields[sopstage.FieldActionMessage]
  23631. return ok
  23632. }
  23633. // ResetActionMessage resets all changes to the "action_message" field.
  23634. func (m *SopStageMutation) ResetActionMessage() {
  23635. m.action_message = nil
  23636. m.appendaction_message = nil
  23637. delete(m.clearedFields, sopstage.FieldActionMessage)
  23638. }
  23639. // SetActionLabelAdd sets the "action_label_add" field.
  23640. func (m *SopStageMutation) SetActionLabelAdd(u []uint64) {
  23641. m.action_label_add = &u
  23642. m.appendaction_label_add = nil
  23643. }
  23644. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  23645. func (m *SopStageMutation) ActionLabelAdd() (r []uint64, exists bool) {
  23646. v := m.action_label_add
  23647. if v == nil {
  23648. return
  23649. }
  23650. return *v, true
  23651. }
  23652. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopStage entity.
  23653. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  23654. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23655. func (m *SopStageMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  23656. if !m.op.Is(OpUpdateOne) {
  23657. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  23658. }
  23659. if m.id == nil || m.oldValue == nil {
  23660. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  23661. }
  23662. oldValue, err := m.oldValue(ctx)
  23663. if err != nil {
  23664. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  23665. }
  23666. return oldValue.ActionLabelAdd, nil
  23667. }
  23668. // AppendActionLabelAdd adds u to the "action_label_add" field.
  23669. func (m *SopStageMutation) AppendActionLabelAdd(u []uint64) {
  23670. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  23671. }
  23672. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  23673. func (m *SopStageMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  23674. if len(m.appendaction_label_add) == 0 {
  23675. return nil, false
  23676. }
  23677. return m.appendaction_label_add, true
  23678. }
  23679. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  23680. func (m *SopStageMutation) ClearActionLabelAdd() {
  23681. m.action_label_add = nil
  23682. m.appendaction_label_add = nil
  23683. m.clearedFields[sopstage.FieldActionLabelAdd] = struct{}{}
  23684. }
  23685. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  23686. func (m *SopStageMutation) ActionLabelAddCleared() bool {
  23687. _, ok := m.clearedFields[sopstage.FieldActionLabelAdd]
  23688. return ok
  23689. }
  23690. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  23691. func (m *SopStageMutation) ResetActionLabelAdd() {
  23692. m.action_label_add = nil
  23693. m.appendaction_label_add = nil
  23694. delete(m.clearedFields, sopstage.FieldActionLabelAdd)
  23695. }
  23696. // SetActionLabelDel sets the "action_label_del" field.
  23697. func (m *SopStageMutation) SetActionLabelDel(u []uint64) {
  23698. m.action_label_del = &u
  23699. m.appendaction_label_del = nil
  23700. }
  23701. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  23702. func (m *SopStageMutation) ActionLabelDel() (r []uint64, exists bool) {
  23703. v := m.action_label_del
  23704. if v == nil {
  23705. return
  23706. }
  23707. return *v, true
  23708. }
  23709. // OldActionLabelDel returns the old "action_label_del" field's value of the SopStage entity.
  23710. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  23711. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23712. func (m *SopStageMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  23713. if !m.op.Is(OpUpdateOne) {
  23714. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  23715. }
  23716. if m.id == nil || m.oldValue == nil {
  23717. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  23718. }
  23719. oldValue, err := m.oldValue(ctx)
  23720. if err != nil {
  23721. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  23722. }
  23723. return oldValue.ActionLabelDel, nil
  23724. }
  23725. // AppendActionLabelDel adds u to the "action_label_del" field.
  23726. func (m *SopStageMutation) AppendActionLabelDel(u []uint64) {
  23727. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  23728. }
  23729. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  23730. func (m *SopStageMutation) AppendedActionLabelDel() ([]uint64, bool) {
  23731. if len(m.appendaction_label_del) == 0 {
  23732. return nil, false
  23733. }
  23734. return m.appendaction_label_del, true
  23735. }
  23736. // ClearActionLabelDel clears the value of the "action_label_del" field.
  23737. func (m *SopStageMutation) ClearActionLabelDel() {
  23738. m.action_label_del = nil
  23739. m.appendaction_label_del = nil
  23740. m.clearedFields[sopstage.FieldActionLabelDel] = struct{}{}
  23741. }
  23742. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  23743. func (m *SopStageMutation) ActionLabelDelCleared() bool {
  23744. _, ok := m.clearedFields[sopstage.FieldActionLabelDel]
  23745. return ok
  23746. }
  23747. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  23748. func (m *SopStageMutation) ResetActionLabelDel() {
  23749. m.action_label_del = nil
  23750. m.appendaction_label_del = nil
  23751. delete(m.clearedFields, sopstage.FieldActionLabelDel)
  23752. }
  23753. // SetActionForward sets the "action_forward" field.
  23754. func (m *SopStageMutation) SetActionForward(ctf *custom_types.ActionForward) {
  23755. m.action_forward = &ctf
  23756. }
  23757. // ActionForward returns the value of the "action_forward" field in the mutation.
  23758. func (m *SopStageMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  23759. v := m.action_forward
  23760. if v == nil {
  23761. return
  23762. }
  23763. return *v, true
  23764. }
  23765. // OldActionForward returns the old "action_forward" field's value of the SopStage entity.
  23766. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  23767. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23768. func (m *SopStageMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  23769. if !m.op.Is(OpUpdateOne) {
  23770. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  23771. }
  23772. if m.id == nil || m.oldValue == nil {
  23773. return v, errors.New("OldActionForward requires an ID field in the mutation")
  23774. }
  23775. oldValue, err := m.oldValue(ctx)
  23776. if err != nil {
  23777. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  23778. }
  23779. return oldValue.ActionForward, nil
  23780. }
  23781. // ClearActionForward clears the value of the "action_forward" field.
  23782. func (m *SopStageMutation) ClearActionForward() {
  23783. m.action_forward = nil
  23784. m.clearedFields[sopstage.FieldActionForward] = struct{}{}
  23785. }
  23786. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  23787. func (m *SopStageMutation) ActionForwardCleared() bool {
  23788. _, ok := m.clearedFields[sopstage.FieldActionForward]
  23789. return ok
  23790. }
  23791. // ResetActionForward resets all changes to the "action_forward" field.
  23792. func (m *SopStageMutation) ResetActionForward() {
  23793. m.action_forward = nil
  23794. delete(m.clearedFields, sopstage.FieldActionForward)
  23795. }
  23796. // SetIndexSort sets the "index_sort" field.
  23797. func (m *SopStageMutation) SetIndexSort(i int) {
  23798. m.index_sort = &i
  23799. m.addindex_sort = nil
  23800. }
  23801. // IndexSort returns the value of the "index_sort" field in the mutation.
  23802. func (m *SopStageMutation) IndexSort() (r int, exists bool) {
  23803. v := m.index_sort
  23804. if v == nil {
  23805. return
  23806. }
  23807. return *v, true
  23808. }
  23809. // OldIndexSort returns the old "index_sort" field's value of the SopStage entity.
  23810. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  23811. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23812. func (m *SopStageMutation) OldIndexSort(ctx context.Context) (v int, err error) {
  23813. if !m.op.Is(OpUpdateOne) {
  23814. return v, errors.New("OldIndexSort is only allowed on UpdateOne operations")
  23815. }
  23816. if m.id == nil || m.oldValue == nil {
  23817. return v, errors.New("OldIndexSort requires an ID field in the mutation")
  23818. }
  23819. oldValue, err := m.oldValue(ctx)
  23820. if err != nil {
  23821. return v, fmt.Errorf("querying old value for OldIndexSort: %w", err)
  23822. }
  23823. return oldValue.IndexSort, nil
  23824. }
  23825. // AddIndexSort adds i to the "index_sort" field.
  23826. func (m *SopStageMutation) AddIndexSort(i int) {
  23827. if m.addindex_sort != nil {
  23828. *m.addindex_sort += i
  23829. } else {
  23830. m.addindex_sort = &i
  23831. }
  23832. }
  23833. // AddedIndexSort returns the value that was added to the "index_sort" field in this mutation.
  23834. func (m *SopStageMutation) AddedIndexSort() (r int, exists bool) {
  23835. v := m.addindex_sort
  23836. if v == nil {
  23837. return
  23838. }
  23839. return *v, true
  23840. }
  23841. // ClearIndexSort clears the value of the "index_sort" field.
  23842. func (m *SopStageMutation) ClearIndexSort() {
  23843. m.index_sort = nil
  23844. m.addindex_sort = nil
  23845. m.clearedFields[sopstage.FieldIndexSort] = struct{}{}
  23846. }
  23847. // IndexSortCleared returns if the "index_sort" field was cleared in this mutation.
  23848. func (m *SopStageMutation) IndexSortCleared() bool {
  23849. _, ok := m.clearedFields[sopstage.FieldIndexSort]
  23850. return ok
  23851. }
  23852. // ResetIndexSort resets all changes to the "index_sort" field.
  23853. func (m *SopStageMutation) ResetIndexSort() {
  23854. m.index_sort = nil
  23855. m.addindex_sort = nil
  23856. delete(m.clearedFields, sopstage.FieldIndexSort)
  23857. }
  23858. // SetSopTaskID sets the "sop_task" edge to the SopTask entity by id.
  23859. func (m *SopStageMutation) SetSopTaskID(id uint64) {
  23860. m.sop_task = &id
  23861. }
  23862. // ClearSopTask clears the "sop_task" edge to the SopTask entity.
  23863. func (m *SopStageMutation) ClearSopTask() {
  23864. m.clearedsop_task = true
  23865. m.clearedFields[sopstage.FieldTaskID] = struct{}{}
  23866. }
  23867. // SopTaskCleared reports if the "sop_task" edge to the SopTask entity was cleared.
  23868. func (m *SopStageMutation) SopTaskCleared() bool {
  23869. return m.clearedsop_task
  23870. }
  23871. // SopTaskID returns the "sop_task" edge ID in the mutation.
  23872. func (m *SopStageMutation) SopTaskID() (id uint64, exists bool) {
  23873. if m.sop_task != nil {
  23874. return *m.sop_task, true
  23875. }
  23876. return
  23877. }
  23878. // SopTaskIDs returns the "sop_task" edge IDs in the mutation.
  23879. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  23880. // SopTaskID instead. It exists only for internal usage by the builders.
  23881. func (m *SopStageMutation) SopTaskIDs() (ids []uint64) {
  23882. if id := m.sop_task; id != nil {
  23883. ids = append(ids, *id)
  23884. }
  23885. return
  23886. }
  23887. // ResetSopTask resets all changes to the "sop_task" edge.
  23888. func (m *SopStageMutation) ResetSopTask() {
  23889. m.sop_task = nil
  23890. m.clearedsop_task = false
  23891. }
  23892. // AddStageNodeIDs adds the "stage_nodes" edge to the SopNode entity by ids.
  23893. func (m *SopStageMutation) AddStageNodeIDs(ids ...uint64) {
  23894. if m.stage_nodes == nil {
  23895. m.stage_nodes = make(map[uint64]struct{})
  23896. }
  23897. for i := range ids {
  23898. m.stage_nodes[ids[i]] = struct{}{}
  23899. }
  23900. }
  23901. // ClearStageNodes clears the "stage_nodes" edge to the SopNode entity.
  23902. func (m *SopStageMutation) ClearStageNodes() {
  23903. m.clearedstage_nodes = true
  23904. }
  23905. // StageNodesCleared reports if the "stage_nodes" edge to the SopNode entity was cleared.
  23906. func (m *SopStageMutation) StageNodesCleared() bool {
  23907. return m.clearedstage_nodes
  23908. }
  23909. // RemoveStageNodeIDs removes the "stage_nodes" edge to the SopNode entity by IDs.
  23910. func (m *SopStageMutation) RemoveStageNodeIDs(ids ...uint64) {
  23911. if m.removedstage_nodes == nil {
  23912. m.removedstage_nodes = make(map[uint64]struct{})
  23913. }
  23914. for i := range ids {
  23915. delete(m.stage_nodes, ids[i])
  23916. m.removedstage_nodes[ids[i]] = struct{}{}
  23917. }
  23918. }
  23919. // RemovedStageNodes returns the removed IDs of the "stage_nodes" edge to the SopNode entity.
  23920. func (m *SopStageMutation) RemovedStageNodesIDs() (ids []uint64) {
  23921. for id := range m.removedstage_nodes {
  23922. ids = append(ids, id)
  23923. }
  23924. return
  23925. }
  23926. // StageNodesIDs returns the "stage_nodes" edge IDs in the mutation.
  23927. func (m *SopStageMutation) StageNodesIDs() (ids []uint64) {
  23928. for id := range m.stage_nodes {
  23929. ids = append(ids, id)
  23930. }
  23931. return
  23932. }
  23933. // ResetStageNodes resets all changes to the "stage_nodes" edge.
  23934. func (m *SopStageMutation) ResetStageNodes() {
  23935. m.stage_nodes = nil
  23936. m.clearedstage_nodes = false
  23937. m.removedstage_nodes = nil
  23938. }
  23939. // AddStageMessageIDs adds the "stage_messages" edge to the MessageRecords entity by ids.
  23940. func (m *SopStageMutation) AddStageMessageIDs(ids ...uint64) {
  23941. if m.stage_messages == nil {
  23942. m.stage_messages = make(map[uint64]struct{})
  23943. }
  23944. for i := range ids {
  23945. m.stage_messages[ids[i]] = struct{}{}
  23946. }
  23947. }
  23948. // ClearStageMessages clears the "stage_messages" edge to the MessageRecords entity.
  23949. func (m *SopStageMutation) ClearStageMessages() {
  23950. m.clearedstage_messages = true
  23951. }
  23952. // StageMessagesCleared reports if the "stage_messages" edge to the MessageRecords entity was cleared.
  23953. func (m *SopStageMutation) StageMessagesCleared() bool {
  23954. return m.clearedstage_messages
  23955. }
  23956. // RemoveStageMessageIDs removes the "stage_messages" edge to the MessageRecords entity by IDs.
  23957. func (m *SopStageMutation) RemoveStageMessageIDs(ids ...uint64) {
  23958. if m.removedstage_messages == nil {
  23959. m.removedstage_messages = make(map[uint64]struct{})
  23960. }
  23961. for i := range ids {
  23962. delete(m.stage_messages, ids[i])
  23963. m.removedstage_messages[ids[i]] = struct{}{}
  23964. }
  23965. }
  23966. // RemovedStageMessages returns the removed IDs of the "stage_messages" edge to the MessageRecords entity.
  23967. func (m *SopStageMutation) RemovedStageMessagesIDs() (ids []uint64) {
  23968. for id := range m.removedstage_messages {
  23969. ids = append(ids, id)
  23970. }
  23971. return
  23972. }
  23973. // StageMessagesIDs returns the "stage_messages" edge IDs in the mutation.
  23974. func (m *SopStageMutation) StageMessagesIDs() (ids []uint64) {
  23975. for id := range m.stage_messages {
  23976. ids = append(ids, id)
  23977. }
  23978. return
  23979. }
  23980. // ResetStageMessages resets all changes to the "stage_messages" edge.
  23981. func (m *SopStageMutation) ResetStageMessages() {
  23982. m.stage_messages = nil
  23983. m.clearedstage_messages = false
  23984. m.removedstage_messages = nil
  23985. }
  23986. // Where appends a list predicates to the SopStageMutation builder.
  23987. func (m *SopStageMutation) Where(ps ...predicate.SopStage) {
  23988. m.predicates = append(m.predicates, ps...)
  23989. }
  23990. // WhereP appends storage-level predicates to the SopStageMutation builder. Using this method,
  23991. // users can use type-assertion to append predicates that do not depend on any generated package.
  23992. func (m *SopStageMutation) WhereP(ps ...func(*sql.Selector)) {
  23993. p := make([]predicate.SopStage, len(ps))
  23994. for i := range ps {
  23995. p[i] = ps[i]
  23996. }
  23997. m.Where(p...)
  23998. }
  23999. // Op returns the operation name.
  24000. func (m *SopStageMutation) Op() Op {
  24001. return m.op
  24002. }
  24003. // SetOp allows setting the mutation operation.
  24004. func (m *SopStageMutation) SetOp(op Op) {
  24005. m.op = op
  24006. }
  24007. // Type returns the node type of this mutation (SopStage).
  24008. func (m *SopStageMutation) Type() string {
  24009. return m.typ
  24010. }
  24011. // Fields returns all fields that were changed during this mutation. Note that in
  24012. // order to get all numeric fields that were incremented/decremented, call
  24013. // AddedFields().
  24014. func (m *SopStageMutation) Fields() []string {
  24015. fields := make([]string, 0, 14)
  24016. if m.created_at != nil {
  24017. fields = append(fields, sopstage.FieldCreatedAt)
  24018. }
  24019. if m.updated_at != nil {
  24020. fields = append(fields, sopstage.FieldUpdatedAt)
  24021. }
  24022. if m.status != nil {
  24023. fields = append(fields, sopstage.FieldStatus)
  24024. }
  24025. if m.deleted_at != nil {
  24026. fields = append(fields, sopstage.FieldDeletedAt)
  24027. }
  24028. if m.sop_task != nil {
  24029. fields = append(fields, sopstage.FieldTaskID)
  24030. }
  24031. if m.name != nil {
  24032. fields = append(fields, sopstage.FieldName)
  24033. }
  24034. if m.condition_type != nil {
  24035. fields = append(fields, sopstage.FieldConditionType)
  24036. }
  24037. if m.condition_operator != nil {
  24038. fields = append(fields, sopstage.FieldConditionOperator)
  24039. }
  24040. if m.condition_list != nil {
  24041. fields = append(fields, sopstage.FieldConditionList)
  24042. }
  24043. if m.action_message != nil {
  24044. fields = append(fields, sopstage.FieldActionMessage)
  24045. }
  24046. if m.action_label_add != nil {
  24047. fields = append(fields, sopstage.FieldActionLabelAdd)
  24048. }
  24049. if m.action_label_del != nil {
  24050. fields = append(fields, sopstage.FieldActionLabelDel)
  24051. }
  24052. if m.action_forward != nil {
  24053. fields = append(fields, sopstage.FieldActionForward)
  24054. }
  24055. if m.index_sort != nil {
  24056. fields = append(fields, sopstage.FieldIndexSort)
  24057. }
  24058. return fields
  24059. }
  24060. // Field returns the value of a field with the given name. The second boolean
  24061. // return value indicates that this field was not set, or was not defined in the
  24062. // schema.
  24063. func (m *SopStageMutation) Field(name string) (ent.Value, bool) {
  24064. switch name {
  24065. case sopstage.FieldCreatedAt:
  24066. return m.CreatedAt()
  24067. case sopstage.FieldUpdatedAt:
  24068. return m.UpdatedAt()
  24069. case sopstage.FieldStatus:
  24070. return m.Status()
  24071. case sopstage.FieldDeletedAt:
  24072. return m.DeletedAt()
  24073. case sopstage.FieldTaskID:
  24074. return m.TaskID()
  24075. case sopstage.FieldName:
  24076. return m.Name()
  24077. case sopstage.FieldConditionType:
  24078. return m.ConditionType()
  24079. case sopstage.FieldConditionOperator:
  24080. return m.ConditionOperator()
  24081. case sopstage.FieldConditionList:
  24082. return m.ConditionList()
  24083. case sopstage.FieldActionMessage:
  24084. return m.ActionMessage()
  24085. case sopstage.FieldActionLabelAdd:
  24086. return m.ActionLabelAdd()
  24087. case sopstage.FieldActionLabelDel:
  24088. return m.ActionLabelDel()
  24089. case sopstage.FieldActionForward:
  24090. return m.ActionForward()
  24091. case sopstage.FieldIndexSort:
  24092. return m.IndexSort()
  24093. }
  24094. return nil, false
  24095. }
  24096. // OldField returns the old value of the field from the database. An error is
  24097. // returned if the mutation operation is not UpdateOne, or the query to the
  24098. // database failed.
  24099. func (m *SopStageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  24100. switch name {
  24101. case sopstage.FieldCreatedAt:
  24102. return m.OldCreatedAt(ctx)
  24103. case sopstage.FieldUpdatedAt:
  24104. return m.OldUpdatedAt(ctx)
  24105. case sopstage.FieldStatus:
  24106. return m.OldStatus(ctx)
  24107. case sopstage.FieldDeletedAt:
  24108. return m.OldDeletedAt(ctx)
  24109. case sopstage.FieldTaskID:
  24110. return m.OldTaskID(ctx)
  24111. case sopstage.FieldName:
  24112. return m.OldName(ctx)
  24113. case sopstage.FieldConditionType:
  24114. return m.OldConditionType(ctx)
  24115. case sopstage.FieldConditionOperator:
  24116. return m.OldConditionOperator(ctx)
  24117. case sopstage.FieldConditionList:
  24118. return m.OldConditionList(ctx)
  24119. case sopstage.FieldActionMessage:
  24120. return m.OldActionMessage(ctx)
  24121. case sopstage.FieldActionLabelAdd:
  24122. return m.OldActionLabelAdd(ctx)
  24123. case sopstage.FieldActionLabelDel:
  24124. return m.OldActionLabelDel(ctx)
  24125. case sopstage.FieldActionForward:
  24126. return m.OldActionForward(ctx)
  24127. case sopstage.FieldIndexSort:
  24128. return m.OldIndexSort(ctx)
  24129. }
  24130. return nil, fmt.Errorf("unknown SopStage field %s", name)
  24131. }
  24132. // SetField sets the value of a field with the given name. It returns an error if
  24133. // the field is not defined in the schema, or if the type mismatched the field
  24134. // type.
  24135. func (m *SopStageMutation) SetField(name string, value ent.Value) error {
  24136. switch name {
  24137. case sopstage.FieldCreatedAt:
  24138. v, ok := value.(time.Time)
  24139. if !ok {
  24140. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24141. }
  24142. m.SetCreatedAt(v)
  24143. return nil
  24144. case sopstage.FieldUpdatedAt:
  24145. v, ok := value.(time.Time)
  24146. if !ok {
  24147. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24148. }
  24149. m.SetUpdatedAt(v)
  24150. return nil
  24151. case sopstage.FieldStatus:
  24152. v, ok := value.(uint8)
  24153. if !ok {
  24154. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24155. }
  24156. m.SetStatus(v)
  24157. return nil
  24158. case sopstage.FieldDeletedAt:
  24159. v, ok := value.(time.Time)
  24160. if !ok {
  24161. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24162. }
  24163. m.SetDeletedAt(v)
  24164. return nil
  24165. case sopstage.FieldTaskID:
  24166. v, ok := value.(uint64)
  24167. if !ok {
  24168. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24169. }
  24170. m.SetTaskID(v)
  24171. return nil
  24172. case sopstage.FieldName:
  24173. v, ok := value.(string)
  24174. if !ok {
  24175. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24176. }
  24177. m.SetName(v)
  24178. return nil
  24179. case sopstage.FieldConditionType:
  24180. v, ok := value.(int)
  24181. if !ok {
  24182. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24183. }
  24184. m.SetConditionType(v)
  24185. return nil
  24186. case sopstage.FieldConditionOperator:
  24187. v, ok := value.(int)
  24188. if !ok {
  24189. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24190. }
  24191. m.SetConditionOperator(v)
  24192. return nil
  24193. case sopstage.FieldConditionList:
  24194. v, ok := value.([]custom_types.Condition)
  24195. if !ok {
  24196. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24197. }
  24198. m.SetConditionList(v)
  24199. return nil
  24200. case sopstage.FieldActionMessage:
  24201. v, ok := value.([]custom_types.Action)
  24202. if !ok {
  24203. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24204. }
  24205. m.SetActionMessage(v)
  24206. return nil
  24207. case sopstage.FieldActionLabelAdd:
  24208. v, ok := value.([]uint64)
  24209. if !ok {
  24210. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24211. }
  24212. m.SetActionLabelAdd(v)
  24213. return nil
  24214. case sopstage.FieldActionLabelDel:
  24215. v, ok := value.([]uint64)
  24216. if !ok {
  24217. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24218. }
  24219. m.SetActionLabelDel(v)
  24220. return nil
  24221. case sopstage.FieldActionForward:
  24222. v, ok := value.(*custom_types.ActionForward)
  24223. if !ok {
  24224. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24225. }
  24226. m.SetActionForward(v)
  24227. return nil
  24228. case sopstage.FieldIndexSort:
  24229. v, ok := value.(int)
  24230. if !ok {
  24231. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24232. }
  24233. m.SetIndexSort(v)
  24234. return nil
  24235. }
  24236. return fmt.Errorf("unknown SopStage field %s", name)
  24237. }
  24238. // AddedFields returns all numeric fields that were incremented/decremented during
  24239. // this mutation.
  24240. func (m *SopStageMutation) AddedFields() []string {
  24241. var fields []string
  24242. if m.addstatus != nil {
  24243. fields = append(fields, sopstage.FieldStatus)
  24244. }
  24245. if m.addcondition_type != nil {
  24246. fields = append(fields, sopstage.FieldConditionType)
  24247. }
  24248. if m.addcondition_operator != nil {
  24249. fields = append(fields, sopstage.FieldConditionOperator)
  24250. }
  24251. if m.addindex_sort != nil {
  24252. fields = append(fields, sopstage.FieldIndexSort)
  24253. }
  24254. return fields
  24255. }
  24256. // AddedField returns the numeric value that was incremented/decremented on a field
  24257. // with the given name. The second boolean return value indicates that this field
  24258. // was not set, or was not defined in the schema.
  24259. func (m *SopStageMutation) AddedField(name string) (ent.Value, bool) {
  24260. switch name {
  24261. case sopstage.FieldStatus:
  24262. return m.AddedStatus()
  24263. case sopstage.FieldConditionType:
  24264. return m.AddedConditionType()
  24265. case sopstage.FieldConditionOperator:
  24266. return m.AddedConditionOperator()
  24267. case sopstage.FieldIndexSort:
  24268. return m.AddedIndexSort()
  24269. }
  24270. return nil, false
  24271. }
  24272. // AddField adds the value to the field with the given name. It returns an error if
  24273. // the field is not defined in the schema, or if the type mismatched the field
  24274. // type.
  24275. func (m *SopStageMutation) AddField(name string, value ent.Value) error {
  24276. switch name {
  24277. case sopstage.FieldStatus:
  24278. v, ok := value.(int8)
  24279. if !ok {
  24280. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24281. }
  24282. m.AddStatus(v)
  24283. return nil
  24284. case sopstage.FieldConditionType:
  24285. v, ok := value.(int)
  24286. if !ok {
  24287. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24288. }
  24289. m.AddConditionType(v)
  24290. return nil
  24291. case sopstage.FieldConditionOperator:
  24292. v, ok := value.(int)
  24293. if !ok {
  24294. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24295. }
  24296. m.AddConditionOperator(v)
  24297. return nil
  24298. case sopstage.FieldIndexSort:
  24299. v, ok := value.(int)
  24300. if !ok {
  24301. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24302. }
  24303. m.AddIndexSort(v)
  24304. return nil
  24305. }
  24306. return fmt.Errorf("unknown SopStage numeric field %s", name)
  24307. }
  24308. // ClearedFields returns all nullable fields that were cleared during this
  24309. // mutation.
  24310. func (m *SopStageMutation) ClearedFields() []string {
  24311. var fields []string
  24312. if m.FieldCleared(sopstage.FieldStatus) {
  24313. fields = append(fields, sopstage.FieldStatus)
  24314. }
  24315. if m.FieldCleared(sopstage.FieldDeletedAt) {
  24316. fields = append(fields, sopstage.FieldDeletedAt)
  24317. }
  24318. if m.FieldCleared(sopstage.FieldActionMessage) {
  24319. fields = append(fields, sopstage.FieldActionMessage)
  24320. }
  24321. if m.FieldCleared(sopstage.FieldActionLabelAdd) {
  24322. fields = append(fields, sopstage.FieldActionLabelAdd)
  24323. }
  24324. if m.FieldCleared(sopstage.FieldActionLabelDel) {
  24325. fields = append(fields, sopstage.FieldActionLabelDel)
  24326. }
  24327. if m.FieldCleared(sopstage.FieldActionForward) {
  24328. fields = append(fields, sopstage.FieldActionForward)
  24329. }
  24330. if m.FieldCleared(sopstage.FieldIndexSort) {
  24331. fields = append(fields, sopstage.FieldIndexSort)
  24332. }
  24333. return fields
  24334. }
  24335. // FieldCleared returns a boolean indicating if a field with the given name was
  24336. // cleared in this mutation.
  24337. func (m *SopStageMutation) FieldCleared(name string) bool {
  24338. _, ok := m.clearedFields[name]
  24339. return ok
  24340. }
  24341. // ClearField clears the value of the field with the given name. It returns an
  24342. // error if the field is not defined in the schema.
  24343. func (m *SopStageMutation) ClearField(name string) error {
  24344. switch name {
  24345. case sopstage.FieldStatus:
  24346. m.ClearStatus()
  24347. return nil
  24348. case sopstage.FieldDeletedAt:
  24349. m.ClearDeletedAt()
  24350. return nil
  24351. case sopstage.FieldActionMessage:
  24352. m.ClearActionMessage()
  24353. return nil
  24354. case sopstage.FieldActionLabelAdd:
  24355. m.ClearActionLabelAdd()
  24356. return nil
  24357. case sopstage.FieldActionLabelDel:
  24358. m.ClearActionLabelDel()
  24359. return nil
  24360. case sopstage.FieldActionForward:
  24361. m.ClearActionForward()
  24362. return nil
  24363. case sopstage.FieldIndexSort:
  24364. m.ClearIndexSort()
  24365. return nil
  24366. }
  24367. return fmt.Errorf("unknown SopStage nullable field %s", name)
  24368. }
  24369. // ResetField resets all changes in the mutation for the field with the given name.
  24370. // It returns an error if the field is not defined in the schema.
  24371. func (m *SopStageMutation) ResetField(name string) error {
  24372. switch name {
  24373. case sopstage.FieldCreatedAt:
  24374. m.ResetCreatedAt()
  24375. return nil
  24376. case sopstage.FieldUpdatedAt:
  24377. m.ResetUpdatedAt()
  24378. return nil
  24379. case sopstage.FieldStatus:
  24380. m.ResetStatus()
  24381. return nil
  24382. case sopstage.FieldDeletedAt:
  24383. m.ResetDeletedAt()
  24384. return nil
  24385. case sopstage.FieldTaskID:
  24386. m.ResetTaskID()
  24387. return nil
  24388. case sopstage.FieldName:
  24389. m.ResetName()
  24390. return nil
  24391. case sopstage.FieldConditionType:
  24392. m.ResetConditionType()
  24393. return nil
  24394. case sopstage.FieldConditionOperator:
  24395. m.ResetConditionOperator()
  24396. return nil
  24397. case sopstage.FieldConditionList:
  24398. m.ResetConditionList()
  24399. return nil
  24400. case sopstage.FieldActionMessage:
  24401. m.ResetActionMessage()
  24402. return nil
  24403. case sopstage.FieldActionLabelAdd:
  24404. m.ResetActionLabelAdd()
  24405. return nil
  24406. case sopstage.FieldActionLabelDel:
  24407. m.ResetActionLabelDel()
  24408. return nil
  24409. case sopstage.FieldActionForward:
  24410. m.ResetActionForward()
  24411. return nil
  24412. case sopstage.FieldIndexSort:
  24413. m.ResetIndexSort()
  24414. return nil
  24415. }
  24416. return fmt.Errorf("unknown SopStage field %s", name)
  24417. }
  24418. // AddedEdges returns all edge names that were set/added in this mutation.
  24419. func (m *SopStageMutation) AddedEdges() []string {
  24420. edges := make([]string, 0, 3)
  24421. if m.sop_task != nil {
  24422. edges = append(edges, sopstage.EdgeSopTask)
  24423. }
  24424. if m.stage_nodes != nil {
  24425. edges = append(edges, sopstage.EdgeStageNodes)
  24426. }
  24427. if m.stage_messages != nil {
  24428. edges = append(edges, sopstage.EdgeStageMessages)
  24429. }
  24430. return edges
  24431. }
  24432. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  24433. // name in this mutation.
  24434. func (m *SopStageMutation) AddedIDs(name string) []ent.Value {
  24435. switch name {
  24436. case sopstage.EdgeSopTask:
  24437. if id := m.sop_task; id != nil {
  24438. return []ent.Value{*id}
  24439. }
  24440. case sopstage.EdgeStageNodes:
  24441. ids := make([]ent.Value, 0, len(m.stage_nodes))
  24442. for id := range m.stage_nodes {
  24443. ids = append(ids, id)
  24444. }
  24445. return ids
  24446. case sopstage.EdgeStageMessages:
  24447. ids := make([]ent.Value, 0, len(m.stage_messages))
  24448. for id := range m.stage_messages {
  24449. ids = append(ids, id)
  24450. }
  24451. return ids
  24452. }
  24453. return nil
  24454. }
  24455. // RemovedEdges returns all edge names that were removed in this mutation.
  24456. func (m *SopStageMutation) RemovedEdges() []string {
  24457. edges := make([]string, 0, 3)
  24458. if m.removedstage_nodes != nil {
  24459. edges = append(edges, sopstage.EdgeStageNodes)
  24460. }
  24461. if m.removedstage_messages != nil {
  24462. edges = append(edges, sopstage.EdgeStageMessages)
  24463. }
  24464. return edges
  24465. }
  24466. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  24467. // the given name in this mutation.
  24468. func (m *SopStageMutation) RemovedIDs(name string) []ent.Value {
  24469. switch name {
  24470. case sopstage.EdgeStageNodes:
  24471. ids := make([]ent.Value, 0, len(m.removedstage_nodes))
  24472. for id := range m.removedstage_nodes {
  24473. ids = append(ids, id)
  24474. }
  24475. return ids
  24476. case sopstage.EdgeStageMessages:
  24477. ids := make([]ent.Value, 0, len(m.removedstage_messages))
  24478. for id := range m.removedstage_messages {
  24479. ids = append(ids, id)
  24480. }
  24481. return ids
  24482. }
  24483. return nil
  24484. }
  24485. // ClearedEdges returns all edge names that were cleared in this mutation.
  24486. func (m *SopStageMutation) ClearedEdges() []string {
  24487. edges := make([]string, 0, 3)
  24488. if m.clearedsop_task {
  24489. edges = append(edges, sopstage.EdgeSopTask)
  24490. }
  24491. if m.clearedstage_nodes {
  24492. edges = append(edges, sopstage.EdgeStageNodes)
  24493. }
  24494. if m.clearedstage_messages {
  24495. edges = append(edges, sopstage.EdgeStageMessages)
  24496. }
  24497. return edges
  24498. }
  24499. // EdgeCleared returns a boolean which indicates if the edge with the given name
  24500. // was cleared in this mutation.
  24501. func (m *SopStageMutation) EdgeCleared(name string) bool {
  24502. switch name {
  24503. case sopstage.EdgeSopTask:
  24504. return m.clearedsop_task
  24505. case sopstage.EdgeStageNodes:
  24506. return m.clearedstage_nodes
  24507. case sopstage.EdgeStageMessages:
  24508. return m.clearedstage_messages
  24509. }
  24510. return false
  24511. }
  24512. // ClearEdge clears the value of the edge with the given name. It returns an error
  24513. // if that edge is not defined in the schema.
  24514. func (m *SopStageMutation) ClearEdge(name string) error {
  24515. switch name {
  24516. case sopstage.EdgeSopTask:
  24517. m.ClearSopTask()
  24518. return nil
  24519. }
  24520. return fmt.Errorf("unknown SopStage unique edge %s", name)
  24521. }
  24522. // ResetEdge resets all changes to the edge with the given name in this mutation.
  24523. // It returns an error if the edge is not defined in the schema.
  24524. func (m *SopStageMutation) ResetEdge(name string) error {
  24525. switch name {
  24526. case sopstage.EdgeSopTask:
  24527. m.ResetSopTask()
  24528. return nil
  24529. case sopstage.EdgeStageNodes:
  24530. m.ResetStageNodes()
  24531. return nil
  24532. case sopstage.EdgeStageMessages:
  24533. m.ResetStageMessages()
  24534. return nil
  24535. }
  24536. return fmt.Errorf("unknown SopStage edge %s", name)
  24537. }
  24538. // SopTaskMutation represents an operation that mutates the SopTask nodes in the graph.
  24539. type SopTaskMutation struct {
  24540. config
  24541. op Op
  24542. typ string
  24543. id *uint64
  24544. created_at *time.Time
  24545. updated_at *time.Time
  24546. status *uint8
  24547. addstatus *int8
  24548. deleted_at *time.Time
  24549. name *string
  24550. bot_wxid_list *[]string
  24551. appendbot_wxid_list []string
  24552. _type *int
  24553. add_type *int
  24554. plan_start_time *time.Time
  24555. plan_end_time *time.Time
  24556. creator_id *string
  24557. organization_id *uint64
  24558. addorganization_id *int64
  24559. token *[]string
  24560. appendtoken []string
  24561. clearedFields map[string]struct{}
  24562. task_stages map[uint64]struct{}
  24563. removedtask_stages map[uint64]struct{}
  24564. clearedtask_stages bool
  24565. done bool
  24566. oldValue func(context.Context) (*SopTask, error)
  24567. predicates []predicate.SopTask
  24568. }
  24569. var _ ent.Mutation = (*SopTaskMutation)(nil)
  24570. // soptaskOption allows management of the mutation configuration using functional options.
  24571. type soptaskOption func(*SopTaskMutation)
  24572. // newSopTaskMutation creates new mutation for the SopTask entity.
  24573. func newSopTaskMutation(c config, op Op, opts ...soptaskOption) *SopTaskMutation {
  24574. m := &SopTaskMutation{
  24575. config: c,
  24576. op: op,
  24577. typ: TypeSopTask,
  24578. clearedFields: make(map[string]struct{}),
  24579. }
  24580. for _, opt := range opts {
  24581. opt(m)
  24582. }
  24583. return m
  24584. }
  24585. // withSopTaskID sets the ID field of the mutation.
  24586. func withSopTaskID(id uint64) soptaskOption {
  24587. return func(m *SopTaskMutation) {
  24588. var (
  24589. err error
  24590. once sync.Once
  24591. value *SopTask
  24592. )
  24593. m.oldValue = func(ctx context.Context) (*SopTask, error) {
  24594. once.Do(func() {
  24595. if m.done {
  24596. err = errors.New("querying old values post mutation is not allowed")
  24597. } else {
  24598. value, err = m.Client().SopTask.Get(ctx, id)
  24599. }
  24600. })
  24601. return value, err
  24602. }
  24603. m.id = &id
  24604. }
  24605. }
  24606. // withSopTask sets the old SopTask of the mutation.
  24607. func withSopTask(node *SopTask) soptaskOption {
  24608. return func(m *SopTaskMutation) {
  24609. m.oldValue = func(context.Context) (*SopTask, error) {
  24610. return node, nil
  24611. }
  24612. m.id = &node.ID
  24613. }
  24614. }
  24615. // Client returns a new `ent.Client` from the mutation. If the mutation was
  24616. // executed in a transaction (ent.Tx), a transactional client is returned.
  24617. func (m SopTaskMutation) Client() *Client {
  24618. client := &Client{config: m.config}
  24619. client.init()
  24620. return client
  24621. }
  24622. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  24623. // it returns an error otherwise.
  24624. func (m SopTaskMutation) Tx() (*Tx, error) {
  24625. if _, ok := m.driver.(*txDriver); !ok {
  24626. return nil, errors.New("ent: mutation is not running in a transaction")
  24627. }
  24628. tx := &Tx{config: m.config}
  24629. tx.init()
  24630. return tx, nil
  24631. }
  24632. // SetID sets the value of the id field. Note that this
  24633. // operation is only accepted on creation of SopTask entities.
  24634. func (m *SopTaskMutation) SetID(id uint64) {
  24635. m.id = &id
  24636. }
  24637. // ID returns the ID value in the mutation. Note that the ID is only available
  24638. // if it was provided to the builder or after it was returned from the database.
  24639. func (m *SopTaskMutation) ID() (id uint64, exists bool) {
  24640. if m.id == nil {
  24641. return
  24642. }
  24643. return *m.id, true
  24644. }
  24645. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  24646. // That means, if the mutation is applied within a transaction with an isolation level such
  24647. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  24648. // or updated by the mutation.
  24649. func (m *SopTaskMutation) IDs(ctx context.Context) ([]uint64, error) {
  24650. switch {
  24651. case m.op.Is(OpUpdateOne | OpDeleteOne):
  24652. id, exists := m.ID()
  24653. if exists {
  24654. return []uint64{id}, nil
  24655. }
  24656. fallthrough
  24657. case m.op.Is(OpUpdate | OpDelete):
  24658. return m.Client().SopTask.Query().Where(m.predicates...).IDs(ctx)
  24659. default:
  24660. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  24661. }
  24662. }
  24663. // SetCreatedAt sets the "created_at" field.
  24664. func (m *SopTaskMutation) SetCreatedAt(t time.Time) {
  24665. m.created_at = &t
  24666. }
  24667. // CreatedAt returns the value of the "created_at" field in the mutation.
  24668. func (m *SopTaskMutation) CreatedAt() (r time.Time, exists bool) {
  24669. v := m.created_at
  24670. if v == nil {
  24671. return
  24672. }
  24673. return *v, true
  24674. }
  24675. // OldCreatedAt returns the old "created_at" field's value of the SopTask entity.
  24676. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  24677. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24678. func (m *SopTaskMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  24679. if !m.op.Is(OpUpdateOne) {
  24680. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  24681. }
  24682. if m.id == nil || m.oldValue == nil {
  24683. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  24684. }
  24685. oldValue, err := m.oldValue(ctx)
  24686. if err != nil {
  24687. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  24688. }
  24689. return oldValue.CreatedAt, nil
  24690. }
  24691. // ResetCreatedAt resets all changes to the "created_at" field.
  24692. func (m *SopTaskMutation) ResetCreatedAt() {
  24693. m.created_at = nil
  24694. }
  24695. // SetUpdatedAt sets the "updated_at" field.
  24696. func (m *SopTaskMutation) SetUpdatedAt(t time.Time) {
  24697. m.updated_at = &t
  24698. }
  24699. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  24700. func (m *SopTaskMutation) UpdatedAt() (r time.Time, exists bool) {
  24701. v := m.updated_at
  24702. if v == nil {
  24703. return
  24704. }
  24705. return *v, true
  24706. }
  24707. // OldUpdatedAt returns the old "updated_at" field's value of the SopTask entity.
  24708. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  24709. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24710. func (m *SopTaskMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  24711. if !m.op.Is(OpUpdateOne) {
  24712. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  24713. }
  24714. if m.id == nil || m.oldValue == nil {
  24715. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  24716. }
  24717. oldValue, err := m.oldValue(ctx)
  24718. if err != nil {
  24719. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  24720. }
  24721. return oldValue.UpdatedAt, nil
  24722. }
  24723. // ResetUpdatedAt resets all changes to the "updated_at" field.
  24724. func (m *SopTaskMutation) ResetUpdatedAt() {
  24725. m.updated_at = nil
  24726. }
  24727. // SetStatus sets the "status" field.
  24728. func (m *SopTaskMutation) SetStatus(u uint8) {
  24729. m.status = &u
  24730. m.addstatus = nil
  24731. }
  24732. // Status returns the value of the "status" field in the mutation.
  24733. func (m *SopTaskMutation) Status() (r uint8, exists bool) {
  24734. v := m.status
  24735. if v == nil {
  24736. return
  24737. }
  24738. return *v, true
  24739. }
  24740. // OldStatus returns the old "status" field's value of the SopTask entity.
  24741. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  24742. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24743. func (m *SopTaskMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  24744. if !m.op.Is(OpUpdateOne) {
  24745. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  24746. }
  24747. if m.id == nil || m.oldValue == nil {
  24748. return v, errors.New("OldStatus requires an ID field in the mutation")
  24749. }
  24750. oldValue, err := m.oldValue(ctx)
  24751. if err != nil {
  24752. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  24753. }
  24754. return oldValue.Status, nil
  24755. }
  24756. // AddStatus adds u to the "status" field.
  24757. func (m *SopTaskMutation) AddStatus(u int8) {
  24758. if m.addstatus != nil {
  24759. *m.addstatus += u
  24760. } else {
  24761. m.addstatus = &u
  24762. }
  24763. }
  24764. // AddedStatus returns the value that was added to the "status" field in this mutation.
  24765. func (m *SopTaskMutation) AddedStatus() (r int8, exists bool) {
  24766. v := m.addstatus
  24767. if v == nil {
  24768. return
  24769. }
  24770. return *v, true
  24771. }
  24772. // ClearStatus clears the value of the "status" field.
  24773. func (m *SopTaskMutation) ClearStatus() {
  24774. m.status = nil
  24775. m.addstatus = nil
  24776. m.clearedFields[soptask.FieldStatus] = struct{}{}
  24777. }
  24778. // StatusCleared returns if the "status" field was cleared in this mutation.
  24779. func (m *SopTaskMutation) StatusCleared() bool {
  24780. _, ok := m.clearedFields[soptask.FieldStatus]
  24781. return ok
  24782. }
  24783. // ResetStatus resets all changes to the "status" field.
  24784. func (m *SopTaskMutation) ResetStatus() {
  24785. m.status = nil
  24786. m.addstatus = nil
  24787. delete(m.clearedFields, soptask.FieldStatus)
  24788. }
  24789. // SetDeletedAt sets the "deleted_at" field.
  24790. func (m *SopTaskMutation) SetDeletedAt(t time.Time) {
  24791. m.deleted_at = &t
  24792. }
  24793. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  24794. func (m *SopTaskMutation) DeletedAt() (r time.Time, exists bool) {
  24795. v := m.deleted_at
  24796. if v == nil {
  24797. return
  24798. }
  24799. return *v, true
  24800. }
  24801. // OldDeletedAt returns the old "deleted_at" field's value of the SopTask entity.
  24802. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  24803. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24804. func (m *SopTaskMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  24805. if !m.op.Is(OpUpdateOne) {
  24806. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  24807. }
  24808. if m.id == nil || m.oldValue == nil {
  24809. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  24810. }
  24811. oldValue, err := m.oldValue(ctx)
  24812. if err != nil {
  24813. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  24814. }
  24815. return oldValue.DeletedAt, nil
  24816. }
  24817. // ClearDeletedAt clears the value of the "deleted_at" field.
  24818. func (m *SopTaskMutation) ClearDeletedAt() {
  24819. m.deleted_at = nil
  24820. m.clearedFields[soptask.FieldDeletedAt] = struct{}{}
  24821. }
  24822. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  24823. func (m *SopTaskMutation) DeletedAtCleared() bool {
  24824. _, ok := m.clearedFields[soptask.FieldDeletedAt]
  24825. return ok
  24826. }
  24827. // ResetDeletedAt resets all changes to the "deleted_at" field.
  24828. func (m *SopTaskMutation) ResetDeletedAt() {
  24829. m.deleted_at = nil
  24830. delete(m.clearedFields, soptask.FieldDeletedAt)
  24831. }
  24832. // SetName sets the "name" field.
  24833. func (m *SopTaskMutation) SetName(s string) {
  24834. m.name = &s
  24835. }
  24836. // Name returns the value of the "name" field in the mutation.
  24837. func (m *SopTaskMutation) Name() (r string, exists bool) {
  24838. v := m.name
  24839. if v == nil {
  24840. return
  24841. }
  24842. return *v, true
  24843. }
  24844. // OldName returns the old "name" field's value of the SopTask entity.
  24845. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  24846. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24847. func (m *SopTaskMutation) OldName(ctx context.Context) (v string, err error) {
  24848. if !m.op.Is(OpUpdateOne) {
  24849. return v, errors.New("OldName is only allowed on UpdateOne operations")
  24850. }
  24851. if m.id == nil || m.oldValue == nil {
  24852. return v, errors.New("OldName requires an ID field in the mutation")
  24853. }
  24854. oldValue, err := m.oldValue(ctx)
  24855. if err != nil {
  24856. return v, fmt.Errorf("querying old value for OldName: %w", err)
  24857. }
  24858. return oldValue.Name, nil
  24859. }
  24860. // ResetName resets all changes to the "name" field.
  24861. func (m *SopTaskMutation) ResetName() {
  24862. m.name = nil
  24863. }
  24864. // SetBotWxidList sets the "bot_wxid_list" field.
  24865. func (m *SopTaskMutation) SetBotWxidList(s []string) {
  24866. m.bot_wxid_list = &s
  24867. m.appendbot_wxid_list = nil
  24868. }
  24869. // BotWxidList returns the value of the "bot_wxid_list" field in the mutation.
  24870. func (m *SopTaskMutation) BotWxidList() (r []string, exists bool) {
  24871. v := m.bot_wxid_list
  24872. if v == nil {
  24873. return
  24874. }
  24875. return *v, true
  24876. }
  24877. // OldBotWxidList returns the old "bot_wxid_list" field's value of the SopTask entity.
  24878. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  24879. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24880. func (m *SopTaskMutation) OldBotWxidList(ctx context.Context) (v []string, err error) {
  24881. if !m.op.Is(OpUpdateOne) {
  24882. return v, errors.New("OldBotWxidList is only allowed on UpdateOne operations")
  24883. }
  24884. if m.id == nil || m.oldValue == nil {
  24885. return v, errors.New("OldBotWxidList requires an ID field in the mutation")
  24886. }
  24887. oldValue, err := m.oldValue(ctx)
  24888. if err != nil {
  24889. return v, fmt.Errorf("querying old value for OldBotWxidList: %w", err)
  24890. }
  24891. return oldValue.BotWxidList, nil
  24892. }
  24893. // AppendBotWxidList adds s to the "bot_wxid_list" field.
  24894. func (m *SopTaskMutation) AppendBotWxidList(s []string) {
  24895. m.appendbot_wxid_list = append(m.appendbot_wxid_list, s...)
  24896. }
  24897. // AppendedBotWxidList returns the list of values that were appended to the "bot_wxid_list" field in this mutation.
  24898. func (m *SopTaskMutation) AppendedBotWxidList() ([]string, bool) {
  24899. if len(m.appendbot_wxid_list) == 0 {
  24900. return nil, false
  24901. }
  24902. return m.appendbot_wxid_list, true
  24903. }
  24904. // ClearBotWxidList clears the value of the "bot_wxid_list" field.
  24905. func (m *SopTaskMutation) ClearBotWxidList() {
  24906. m.bot_wxid_list = nil
  24907. m.appendbot_wxid_list = nil
  24908. m.clearedFields[soptask.FieldBotWxidList] = struct{}{}
  24909. }
  24910. // BotWxidListCleared returns if the "bot_wxid_list" field was cleared in this mutation.
  24911. func (m *SopTaskMutation) BotWxidListCleared() bool {
  24912. _, ok := m.clearedFields[soptask.FieldBotWxidList]
  24913. return ok
  24914. }
  24915. // ResetBotWxidList resets all changes to the "bot_wxid_list" field.
  24916. func (m *SopTaskMutation) ResetBotWxidList() {
  24917. m.bot_wxid_list = nil
  24918. m.appendbot_wxid_list = nil
  24919. delete(m.clearedFields, soptask.FieldBotWxidList)
  24920. }
  24921. // SetType sets the "type" field.
  24922. func (m *SopTaskMutation) SetType(i int) {
  24923. m._type = &i
  24924. m.add_type = nil
  24925. }
  24926. // GetType returns the value of the "type" field in the mutation.
  24927. func (m *SopTaskMutation) GetType() (r int, exists bool) {
  24928. v := m._type
  24929. if v == nil {
  24930. return
  24931. }
  24932. return *v, true
  24933. }
  24934. // OldType returns the old "type" field's value of the SopTask entity.
  24935. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  24936. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24937. func (m *SopTaskMutation) OldType(ctx context.Context) (v int, err error) {
  24938. if !m.op.Is(OpUpdateOne) {
  24939. return v, errors.New("OldType is only allowed on UpdateOne operations")
  24940. }
  24941. if m.id == nil || m.oldValue == nil {
  24942. return v, errors.New("OldType requires an ID field in the mutation")
  24943. }
  24944. oldValue, err := m.oldValue(ctx)
  24945. if err != nil {
  24946. return v, fmt.Errorf("querying old value for OldType: %w", err)
  24947. }
  24948. return oldValue.Type, nil
  24949. }
  24950. // AddType adds i to the "type" field.
  24951. func (m *SopTaskMutation) AddType(i int) {
  24952. if m.add_type != nil {
  24953. *m.add_type += i
  24954. } else {
  24955. m.add_type = &i
  24956. }
  24957. }
  24958. // AddedType returns the value that was added to the "type" field in this mutation.
  24959. func (m *SopTaskMutation) AddedType() (r int, exists bool) {
  24960. v := m.add_type
  24961. if v == nil {
  24962. return
  24963. }
  24964. return *v, true
  24965. }
  24966. // ResetType resets all changes to the "type" field.
  24967. func (m *SopTaskMutation) ResetType() {
  24968. m._type = nil
  24969. m.add_type = nil
  24970. }
  24971. // SetPlanStartTime sets the "plan_start_time" field.
  24972. func (m *SopTaskMutation) SetPlanStartTime(t time.Time) {
  24973. m.plan_start_time = &t
  24974. }
  24975. // PlanStartTime returns the value of the "plan_start_time" field in the mutation.
  24976. func (m *SopTaskMutation) PlanStartTime() (r time.Time, exists bool) {
  24977. v := m.plan_start_time
  24978. if v == nil {
  24979. return
  24980. }
  24981. return *v, true
  24982. }
  24983. // OldPlanStartTime returns the old "plan_start_time" 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) OldPlanStartTime(ctx context.Context) (v time.Time, err error) {
  24987. if !m.op.Is(OpUpdateOne) {
  24988. return v, errors.New("OldPlanStartTime is only allowed on UpdateOne operations")
  24989. }
  24990. if m.id == nil || m.oldValue == nil {
  24991. return v, errors.New("OldPlanStartTime 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 OldPlanStartTime: %w", err)
  24996. }
  24997. return oldValue.PlanStartTime, nil
  24998. }
  24999. // ClearPlanStartTime clears the value of the "plan_start_time" field.
  25000. func (m *SopTaskMutation) ClearPlanStartTime() {
  25001. m.plan_start_time = nil
  25002. m.clearedFields[soptask.FieldPlanStartTime] = struct{}{}
  25003. }
  25004. // PlanStartTimeCleared returns if the "plan_start_time" field was cleared in this mutation.
  25005. func (m *SopTaskMutation) PlanStartTimeCleared() bool {
  25006. _, ok := m.clearedFields[soptask.FieldPlanStartTime]
  25007. return ok
  25008. }
  25009. // ResetPlanStartTime resets all changes to the "plan_start_time" field.
  25010. func (m *SopTaskMutation) ResetPlanStartTime() {
  25011. m.plan_start_time = nil
  25012. delete(m.clearedFields, soptask.FieldPlanStartTime)
  25013. }
  25014. // SetPlanEndTime sets the "plan_end_time" field.
  25015. func (m *SopTaskMutation) SetPlanEndTime(t time.Time) {
  25016. m.plan_end_time = &t
  25017. }
  25018. // PlanEndTime returns the value of the "plan_end_time" field in the mutation.
  25019. func (m *SopTaskMutation) PlanEndTime() (r time.Time, exists bool) {
  25020. v := m.plan_end_time
  25021. if v == nil {
  25022. return
  25023. }
  25024. return *v, true
  25025. }
  25026. // OldPlanEndTime returns the old "plan_end_time" field's value of the SopTask entity.
  25027. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  25028. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25029. func (m *SopTaskMutation) OldPlanEndTime(ctx context.Context) (v time.Time, err error) {
  25030. if !m.op.Is(OpUpdateOne) {
  25031. return v, errors.New("OldPlanEndTime is only allowed on UpdateOne operations")
  25032. }
  25033. if m.id == nil || m.oldValue == nil {
  25034. return v, errors.New("OldPlanEndTime requires an ID field in the mutation")
  25035. }
  25036. oldValue, err := m.oldValue(ctx)
  25037. if err != nil {
  25038. return v, fmt.Errorf("querying old value for OldPlanEndTime: %w", err)
  25039. }
  25040. return oldValue.PlanEndTime, nil
  25041. }
  25042. // ClearPlanEndTime clears the value of the "plan_end_time" field.
  25043. func (m *SopTaskMutation) ClearPlanEndTime() {
  25044. m.plan_end_time = nil
  25045. m.clearedFields[soptask.FieldPlanEndTime] = struct{}{}
  25046. }
  25047. // PlanEndTimeCleared returns if the "plan_end_time" field was cleared in this mutation.
  25048. func (m *SopTaskMutation) PlanEndTimeCleared() bool {
  25049. _, ok := m.clearedFields[soptask.FieldPlanEndTime]
  25050. return ok
  25051. }
  25052. // ResetPlanEndTime resets all changes to the "plan_end_time" field.
  25053. func (m *SopTaskMutation) ResetPlanEndTime() {
  25054. m.plan_end_time = nil
  25055. delete(m.clearedFields, soptask.FieldPlanEndTime)
  25056. }
  25057. // SetCreatorID sets the "creator_id" field.
  25058. func (m *SopTaskMutation) SetCreatorID(s string) {
  25059. m.creator_id = &s
  25060. }
  25061. // CreatorID returns the value of the "creator_id" field in the mutation.
  25062. func (m *SopTaskMutation) CreatorID() (r string, exists bool) {
  25063. v := m.creator_id
  25064. if v == nil {
  25065. return
  25066. }
  25067. return *v, true
  25068. }
  25069. // OldCreatorID returns the old "creator_id" field's value of the SopTask entity.
  25070. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  25071. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25072. func (m *SopTaskMutation) OldCreatorID(ctx context.Context) (v string, err error) {
  25073. if !m.op.Is(OpUpdateOne) {
  25074. return v, errors.New("OldCreatorID is only allowed on UpdateOne operations")
  25075. }
  25076. if m.id == nil || m.oldValue == nil {
  25077. return v, errors.New("OldCreatorID requires an ID field in the mutation")
  25078. }
  25079. oldValue, err := m.oldValue(ctx)
  25080. if err != nil {
  25081. return v, fmt.Errorf("querying old value for OldCreatorID: %w", err)
  25082. }
  25083. return oldValue.CreatorID, nil
  25084. }
  25085. // ClearCreatorID clears the value of the "creator_id" field.
  25086. func (m *SopTaskMutation) ClearCreatorID() {
  25087. m.creator_id = nil
  25088. m.clearedFields[soptask.FieldCreatorID] = struct{}{}
  25089. }
  25090. // CreatorIDCleared returns if the "creator_id" field was cleared in this mutation.
  25091. func (m *SopTaskMutation) CreatorIDCleared() bool {
  25092. _, ok := m.clearedFields[soptask.FieldCreatorID]
  25093. return ok
  25094. }
  25095. // ResetCreatorID resets all changes to the "creator_id" field.
  25096. func (m *SopTaskMutation) ResetCreatorID() {
  25097. m.creator_id = nil
  25098. delete(m.clearedFields, soptask.FieldCreatorID)
  25099. }
  25100. // SetOrganizationID sets the "organization_id" field.
  25101. func (m *SopTaskMutation) SetOrganizationID(u uint64) {
  25102. m.organization_id = &u
  25103. m.addorganization_id = nil
  25104. }
  25105. // OrganizationID returns the value of the "organization_id" field in the mutation.
  25106. func (m *SopTaskMutation) OrganizationID() (r uint64, exists bool) {
  25107. v := m.organization_id
  25108. if v == nil {
  25109. return
  25110. }
  25111. return *v, true
  25112. }
  25113. // OldOrganizationID returns the old "organization_id" field's value of the SopTask entity.
  25114. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  25115. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25116. func (m *SopTaskMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  25117. if !m.op.Is(OpUpdateOne) {
  25118. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  25119. }
  25120. if m.id == nil || m.oldValue == nil {
  25121. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  25122. }
  25123. oldValue, err := m.oldValue(ctx)
  25124. if err != nil {
  25125. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  25126. }
  25127. return oldValue.OrganizationID, nil
  25128. }
  25129. // AddOrganizationID adds u to the "organization_id" field.
  25130. func (m *SopTaskMutation) AddOrganizationID(u int64) {
  25131. if m.addorganization_id != nil {
  25132. *m.addorganization_id += u
  25133. } else {
  25134. m.addorganization_id = &u
  25135. }
  25136. }
  25137. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  25138. func (m *SopTaskMutation) AddedOrganizationID() (r int64, exists bool) {
  25139. v := m.addorganization_id
  25140. if v == nil {
  25141. return
  25142. }
  25143. return *v, true
  25144. }
  25145. // ClearOrganizationID clears the value of the "organization_id" field.
  25146. func (m *SopTaskMutation) ClearOrganizationID() {
  25147. m.organization_id = nil
  25148. m.addorganization_id = nil
  25149. m.clearedFields[soptask.FieldOrganizationID] = struct{}{}
  25150. }
  25151. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  25152. func (m *SopTaskMutation) OrganizationIDCleared() bool {
  25153. _, ok := m.clearedFields[soptask.FieldOrganizationID]
  25154. return ok
  25155. }
  25156. // ResetOrganizationID resets all changes to the "organization_id" field.
  25157. func (m *SopTaskMutation) ResetOrganizationID() {
  25158. m.organization_id = nil
  25159. m.addorganization_id = nil
  25160. delete(m.clearedFields, soptask.FieldOrganizationID)
  25161. }
  25162. // SetToken sets the "token" field.
  25163. func (m *SopTaskMutation) SetToken(s []string) {
  25164. m.token = &s
  25165. m.appendtoken = nil
  25166. }
  25167. // Token returns the value of the "token" field in the mutation.
  25168. func (m *SopTaskMutation) Token() (r []string, exists bool) {
  25169. v := m.token
  25170. if v == nil {
  25171. return
  25172. }
  25173. return *v, true
  25174. }
  25175. // OldToken returns the old "token" field's value of the SopTask entity.
  25176. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  25177. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25178. func (m *SopTaskMutation) OldToken(ctx context.Context) (v []string, err error) {
  25179. if !m.op.Is(OpUpdateOne) {
  25180. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  25181. }
  25182. if m.id == nil || m.oldValue == nil {
  25183. return v, errors.New("OldToken requires an ID field in the mutation")
  25184. }
  25185. oldValue, err := m.oldValue(ctx)
  25186. if err != nil {
  25187. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  25188. }
  25189. return oldValue.Token, nil
  25190. }
  25191. // AppendToken adds s to the "token" field.
  25192. func (m *SopTaskMutation) AppendToken(s []string) {
  25193. m.appendtoken = append(m.appendtoken, s...)
  25194. }
  25195. // AppendedToken returns the list of values that were appended to the "token" field in this mutation.
  25196. func (m *SopTaskMutation) AppendedToken() ([]string, bool) {
  25197. if len(m.appendtoken) == 0 {
  25198. return nil, false
  25199. }
  25200. return m.appendtoken, true
  25201. }
  25202. // ClearToken clears the value of the "token" field.
  25203. func (m *SopTaskMutation) ClearToken() {
  25204. m.token = nil
  25205. m.appendtoken = nil
  25206. m.clearedFields[soptask.FieldToken] = struct{}{}
  25207. }
  25208. // TokenCleared returns if the "token" field was cleared in this mutation.
  25209. func (m *SopTaskMutation) TokenCleared() bool {
  25210. _, ok := m.clearedFields[soptask.FieldToken]
  25211. return ok
  25212. }
  25213. // ResetToken resets all changes to the "token" field.
  25214. func (m *SopTaskMutation) ResetToken() {
  25215. m.token = nil
  25216. m.appendtoken = nil
  25217. delete(m.clearedFields, soptask.FieldToken)
  25218. }
  25219. // AddTaskStageIDs adds the "task_stages" edge to the SopStage entity by ids.
  25220. func (m *SopTaskMutation) AddTaskStageIDs(ids ...uint64) {
  25221. if m.task_stages == nil {
  25222. m.task_stages = make(map[uint64]struct{})
  25223. }
  25224. for i := range ids {
  25225. m.task_stages[ids[i]] = struct{}{}
  25226. }
  25227. }
  25228. // ClearTaskStages clears the "task_stages" edge to the SopStage entity.
  25229. func (m *SopTaskMutation) ClearTaskStages() {
  25230. m.clearedtask_stages = true
  25231. }
  25232. // TaskStagesCleared reports if the "task_stages" edge to the SopStage entity was cleared.
  25233. func (m *SopTaskMutation) TaskStagesCleared() bool {
  25234. return m.clearedtask_stages
  25235. }
  25236. // RemoveTaskStageIDs removes the "task_stages" edge to the SopStage entity by IDs.
  25237. func (m *SopTaskMutation) RemoveTaskStageIDs(ids ...uint64) {
  25238. if m.removedtask_stages == nil {
  25239. m.removedtask_stages = make(map[uint64]struct{})
  25240. }
  25241. for i := range ids {
  25242. delete(m.task_stages, ids[i])
  25243. m.removedtask_stages[ids[i]] = struct{}{}
  25244. }
  25245. }
  25246. // RemovedTaskStages returns the removed IDs of the "task_stages" edge to the SopStage entity.
  25247. func (m *SopTaskMutation) RemovedTaskStagesIDs() (ids []uint64) {
  25248. for id := range m.removedtask_stages {
  25249. ids = append(ids, id)
  25250. }
  25251. return
  25252. }
  25253. // TaskStagesIDs returns the "task_stages" edge IDs in the mutation.
  25254. func (m *SopTaskMutation) TaskStagesIDs() (ids []uint64) {
  25255. for id := range m.task_stages {
  25256. ids = append(ids, id)
  25257. }
  25258. return
  25259. }
  25260. // ResetTaskStages resets all changes to the "task_stages" edge.
  25261. func (m *SopTaskMutation) ResetTaskStages() {
  25262. m.task_stages = nil
  25263. m.clearedtask_stages = false
  25264. m.removedtask_stages = nil
  25265. }
  25266. // Where appends a list predicates to the SopTaskMutation builder.
  25267. func (m *SopTaskMutation) Where(ps ...predicate.SopTask) {
  25268. m.predicates = append(m.predicates, ps...)
  25269. }
  25270. // WhereP appends storage-level predicates to the SopTaskMutation builder. Using this method,
  25271. // users can use type-assertion to append predicates that do not depend on any generated package.
  25272. func (m *SopTaskMutation) WhereP(ps ...func(*sql.Selector)) {
  25273. p := make([]predicate.SopTask, len(ps))
  25274. for i := range ps {
  25275. p[i] = ps[i]
  25276. }
  25277. m.Where(p...)
  25278. }
  25279. // Op returns the operation name.
  25280. func (m *SopTaskMutation) Op() Op {
  25281. return m.op
  25282. }
  25283. // SetOp allows setting the mutation operation.
  25284. func (m *SopTaskMutation) SetOp(op Op) {
  25285. m.op = op
  25286. }
  25287. // Type returns the node type of this mutation (SopTask).
  25288. func (m *SopTaskMutation) Type() string {
  25289. return m.typ
  25290. }
  25291. // Fields returns all fields that were changed during this mutation. Note that in
  25292. // order to get all numeric fields that were incremented/decremented, call
  25293. // AddedFields().
  25294. func (m *SopTaskMutation) Fields() []string {
  25295. fields := make([]string, 0, 12)
  25296. if m.created_at != nil {
  25297. fields = append(fields, soptask.FieldCreatedAt)
  25298. }
  25299. if m.updated_at != nil {
  25300. fields = append(fields, soptask.FieldUpdatedAt)
  25301. }
  25302. if m.status != nil {
  25303. fields = append(fields, soptask.FieldStatus)
  25304. }
  25305. if m.deleted_at != nil {
  25306. fields = append(fields, soptask.FieldDeletedAt)
  25307. }
  25308. if m.name != nil {
  25309. fields = append(fields, soptask.FieldName)
  25310. }
  25311. if m.bot_wxid_list != nil {
  25312. fields = append(fields, soptask.FieldBotWxidList)
  25313. }
  25314. if m._type != nil {
  25315. fields = append(fields, soptask.FieldType)
  25316. }
  25317. if m.plan_start_time != nil {
  25318. fields = append(fields, soptask.FieldPlanStartTime)
  25319. }
  25320. if m.plan_end_time != nil {
  25321. fields = append(fields, soptask.FieldPlanEndTime)
  25322. }
  25323. if m.creator_id != nil {
  25324. fields = append(fields, soptask.FieldCreatorID)
  25325. }
  25326. if m.organization_id != nil {
  25327. fields = append(fields, soptask.FieldOrganizationID)
  25328. }
  25329. if m.token != nil {
  25330. fields = append(fields, soptask.FieldToken)
  25331. }
  25332. return fields
  25333. }
  25334. // Field returns the value of a field with the given name. The second boolean
  25335. // return value indicates that this field was not set, or was not defined in the
  25336. // schema.
  25337. func (m *SopTaskMutation) Field(name string) (ent.Value, bool) {
  25338. switch name {
  25339. case soptask.FieldCreatedAt:
  25340. return m.CreatedAt()
  25341. case soptask.FieldUpdatedAt:
  25342. return m.UpdatedAt()
  25343. case soptask.FieldStatus:
  25344. return m.Status()
  25345. case soptask.FieldDeletedAt:
  25346. return m.DeletedAt()
  25347. case soptask.FieldName:
  25348. return m.Name()
  25349. case soptask.FieldBotWxidList:
  25350. return m.BotWxidList()
  25351. case soptask.FieldType:
  25352. return m.GetType()
  25353. case soptask.FieldPlanStartTime:
  25354. return m.PlanStartTime()
  25355. case soptask.FieldPlanEndTime:
  25356. return m.PlanEndTime()
  25357. case soptask.FieldCreatorID:
  25358. return m.CreatorID()
  25359. case soptask.FieldOrganizationID:
  25360. return m.OrganizationID()
  25361. case soptask.FieldToken:
  25362. return m.Token()
  25363. }
  25364. return nil, false
  25365. }
  25366. // OldField returns the old value of the field from the database. An error is
  25367. // returned if the mutation operation is not UpdateOne, or the query to the
  25368. // database failed.
  25369. func (m *SopTaskMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  25370. switch name {
  25371. case soptask.FieldCreatedAt:
  25372. return m.OldCreatedAt(ctx)
  25373. case soptask.FieldUpdatedAt:
  25374. return m.OldUpdatedAt(ctx)
  25375. case soptask.FieldStatus:
  25376. return m.OldStatus(ctx)
  25377. case soptask.FieldDeletedAt:
  25378. return m.OldDeletedAt(ctx)
  25379. case soptask.FieldName:
  25380. return m.OldName(ctx)
  25381. case soptask.FieldBotWxidList:
  25382. return m.OldBotWxidList(ctx)
  25383. case soptask.FieldType:
  25384. return m.OldType(ctx)
  25385. case soptask.FieldPlanStartTime:
  25386. return m.OldPlanStartTime(ctx)
  25387. case soptask.FieldPlanEndTime:
  25388. return m.OldPlanEndTime(ctx)
  25389. case soptask.FieldCreatorID:
  25390. return m.OldCreatorID(ctx)
  25391. case soptask.FieldOrganizationID:
  25392. return m.OldOrganizationID(ctx)
  25393. case soptask.FieldToken:
  25394. return m.OldToken(ctx)
  25395. }
  25396. return nil, fmt.Errorf("unknown SopTask field %s", name)
  25397. }
  25398. // SetField sets the value of a field with the given name. It returns an error if
  25399. // the field is not defined in the schema, or if the type mismatched the field
  25400. // type.
  25401. func (m *SopTaskMutation) SetField(name string, value ent.Value) error {
  25402. switch name {
  25403. case soptask.FieldCreatedAt:
  25404. v, ok := value.(time.Time)
  25405. if !ok {
  25406. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25407. }
  25408. m.SetCreatedAt(v)
  25409. return nil
  25410. case soptask.FieldUpdatedAt:
  25411. v, ok := value.(time.Time)
  25412. if !ok {
  25413. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25414. }
  25415. m.SetUpdatedAt(v)
  25416. return nil
  25417. case soptask.FieldStatus:
  25418. v, ok := value.(uint8)
  25419. if !ok {
  25420. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25421. }
  25422. m.SetStatus(v)
  25423. return nil
  25424. case soptask.FieldDeletedAt:
  25425. v, ok := value.(time.Time)
  25426. if !ok {
  25427. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25428. }
  25429. m.SetDeletedAt(v)
  25430. return nil
  25431. case soptask.FieldName:
  25432. v, ok := value.(string)
  25433. if !ok {
  25434. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25435. }
  25436. m.SetName(v)
  25437. return nil
  25438. case soptask.FieldBotWxidList:
  25439. v, ok := value.([]string)
  25440. if !ok {
  25441. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25442. }
  25443. m.SetBotWxidList(v)
  25444. return nil
  25445. case soptask.FieldType:
  25446. v, ok := value.(int)
  25447. if !ok {
  25448. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25449. }
  25450. m.SetType(v)
  25451. return nil
  25452. case soptask.FieldPlanStartTime:
  25453. v, ok := value.(time.Time)
  25454. if !ok {
  25455. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25456. }
  25457. m.SetPlanStartTime(v)
  25458. return nil
  25459. case soptask.FieldPlanEndTime:
  25460. v, ok := value.(time.Time)
  25461. if !ok {
  25462. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25463. }
  25464. m.SetPlanEndTime(v)
  25465. return nil
  25466. case soptask.FieldCreatorID:
  25467. v, ok := value.(string)
  25468. if !ok {
  25469. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25470. }
  25471. m.SetCreatorID(v)
  25472. return nil
  25473. case soptask.FieldOrganizationID:
  25474. v, ok := value.(uint64)
  25475. if !ok {
  25476. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25477. }
  25478. m.SetOrganizationID(v)
  25479. return nil
  25480. case soptask.FieldToken:
  25481. v, ok := value.([]string)
  25482. if !ok {
  25483. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25484. }
  25485. m.SetToken(v)
  25486. return nil
  25487. }
  25488. return fmt.Errorf("unknown SopTask field %s", name)
  25489. }
  25490. // AddedFields returns all numeric fields that were incremented/decremented during
  25491. // this mutation.
  25492. func (m *SopTaskMutation) AddedFields() []string {
  25493. var fields []string
  25494. if m.addstatus != nil {
  25495. fields = append(fields, soptask.FieldStatus)
  25496. }
  25497. if m.add_type != nil {
  25498. fields = append(fields, soptask.FieldType)
  25499. }
  25500. if m.addorganization_id != nil {
  25501. fields = append(fields, soptask.FieldOrganizationID)
  25502. }
  25503. return fields
  25504. }
  25505. // AddedField returns the numeric value that was incremented/decremented on a field
  25506. // with the given name. The second boolean return value indicates that this field
  25507. // was not set, or was not defined in the schema.
  25508. func (m *SopTaskMutation) AddedField(name string) (ent.Value, bool) {
  25509. switch name {
  25510. case soptask.FieldStatus:
  25511. return m.AddedStatus()
  25512. case soptask.FieldType:
  25513. return m.AddedType()
  25514. case soptask.FieldOrganizationID:
  25515. return m.AddedOrganizationID()
  25516. }
  25517. return nil, false
  25518. }
  25519. // AddField adds the value to the field with the given name. It returns an error if
  25520. // the field is not defined in the schema, or if the type mismatched the field
  25521. // type.
  25522. func (m *SopTaskMutation) AddField(name string, value ent.Value) error {
  25523. switch name {
  25524. case soptask.FieldStatus:
  25525. v, ok := value.(int8)
  25526. if !ok {
  25527. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25528. }
  25529. m.AddStatus(v)
  25530. return nil
  25531. case soptask.FieldType:
  25532. v, ok := value.(int)
  25533. if !ok {
  25534. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25535. }
  25536. m.AddType(v)
  25537. return nil
  25538. case soptask.FieldOrganizationID:
  25539. v, ok := value.(int64)
  25540. if !ok {
  25541. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25542. }
  25543. m.AddOrganizationID(v)
  25544. return nil
  25545. }
  25546. return fmt.Errorf("unknown SopTask numeric field %s", name)
  25547. }
  25548. // ClearedFields returns all nullable fields that were cleared during this
  25549. // mutation.
  25550. func (m *SopTaskMutation) ClearedFields() []string {
  25551. var fields []string
  25552. if m.FieldCleared(soptask.FieldStatus) {
  25553. fields = append(fields, soptask.FieldStatus)
  25554. }
  25555. if m.FieldCleared(soptask.FieldDeletedAt) {
  25556. fields = append(fields, soptask.FieldDeletedAt)
  25557. }
  25558. if m.FieldCleared(soptask.FieldBotWxidList) {
  25559. fields = append(fields, soptask.FieldBotWxidList)
  25560. }
  25561. if m.FieldCleared(soptask.FieldPlanStartTime) {
  25562. fields = append(fields, soptask.FieldPlanStartTime)
  25563. }
  25564. if m.FieldCleared(soptask.FieldPlanEndTime) {
  25565. fields = append(fields, soptask.FieldPlanEndTime)
  25566. }
  25567. if m.FieldCleared(soptask.FieldCreatorID) {
  25568. fields = append(fields, soptask.FieldCreatorID)
  25569. }
  25570. if m.FieldCleared(soptask.FieldOrganizationID) {
  25571. fields = append(fields, soptask.FieldOrganizationID)
  25572. }
  25573. if m.FieldCleared(soptask.FieldToken) {
  25574. fields = append(fields, soptask.FieldToken)
  25575. }
  25576. return fields
  25577. }
  25578. // FieldCleared returns a boolean indicating if a field with the given name was
  25579. // cleared in this mutation.
  25580. func (m *SopTaskMutation) FieldCleared(name string) bool {
  25581. _, ok := m.clearedFields[name]
  25582. return ok
  25583. }
  25584. // ClearField clears the value of the field with the given name. It returns an
  25585. // error if the field is not defined in the schema.
  25586. func (m *SopTaskMutation) ClearField(name string) error {
  25587. switch name {
  25588. case soptask.FieldStatus:
  25589. m.ClearStatus()
  25590. return nil
  25591. case soptask.FieldDeletedAt:
  25592. m.ClearDeletedAt()
  25593. return nil
  25594. case soptask.FieldBotWxidList:
  25595. m.ClearBotWxidList()
  25596. return nil
  25597. case soptask.FieldPlanStartTime:
  25598. m.ClearPlanStartTime()
  25599. return nil
  25600. case soptask.FieldPlanEndTime:
  25601. m.ClearPlanEndTime()
  25602. return nil
  25603. case soptask.FieldCreatorID:
  25604. m.ClearCreatorID()
  25605. return nil
  25606. case soptask.FieldOrganizationID:
  25607. m.ClearOrganizationID()
  25608. return nil
  25609. case soptask.FieldToken:
  25610. m.ClearToken()
  25611. return nil
  25612. }
  25613. return fmt.Errorf("unknown SopTask nullable field %s", name)
  25614. }
  25615. // ResetField resets all changes in the mutation for the field with the given name.
  25616. // It returns an error if the field is not defined in the schema.
  25617. func (m *SopTaskMutation) ResetField(name string) error {
  25618. switch name {
  25619. case soptask.FieldCreatedAt:
  25620. m.ResetCreatedAt()
  25621. return nil
  25622. case soptask.FieldUpdatedAt:
  25623. m.ResetUpdatedAt()
  25624. return nil
  25625. case soptask.FieldStatus:
  25626. m.ResetStatus()
  25627. return nil
  25628. case soptask.FieldDeletedAt:
  25629. m.ResetDeletedAt()
  25630. return nil
  25631. case soptask.FieldName:
  25632. m.ResetName()
  25633. return nil
  25634. case soptask.FieldBotWxidList:
  25635. m.ResetBotWxidList()
  25636. return nil
  25637. case soptask.FieldType:
  25638. m.ResetType()
  25639. return nil
  25640. case soptask.FieldPlanStartTime:
  25641. m.ResetPlanStartTime()
  25642. return nil
  25643. case soptask.FieldPlanEndTime:
  25644. m.ResetPlanEndTime()
  25645. return nil
  25646. case soptask.FieldCreatorID:
  25647. m.ResetCreatorID()
  25648. return nil
  25649. case soptask.FieldOrganizationID:
  25650. m.ResetOrganizationID()
  25651. return nil
  25652. case soptask.FieldToken:
  25653. m.ResetToken()
  25654. return nil
  25655. }
  25656. return fmt.Errorf("unknown SopTask field %s", name)
  25657. }
  25658. // AddedEdges returns all edge names that were set/added in this mutation.
  25659. func (m *SopTaskMutation) AddedEdges() []string {
  25660. edges := make([]string, 0, 1)
  25661. if m.task_stages != nil {
  25662. edges = append(edges, soptask.EdgeTaskStages)
  25663. }
  25664. return edges
  25665. }
  25666. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  25667. // name in this mutation.
  25668. func (m *SopTaskMutation) AddedIDs(name string) []ent.Value {
  25669. switch name {
  25670. case soptask.EdgeTaskStages:
  25671. ids := make([]ent.Value, 0, len(m.task_stages))
  25672. for id := range m.task_stages {
  25673. ids = append(ids, id)
  25674. }
  25675. return ids
  25676. }
  25677. return nil
  25678. }
  25679. // RemovedEdges returns all edge names that were removed in this mutation.
  25680. func (m *SopTaskMutation) RemovedEdges() []string {
  25681. edges := make([]string, 0, 1)
  25682. if m.removedtask_stages != nil {
  25683. edges = append(edges, soptask.EdgeTaskStages)
  25684. }
  25685. return edges
  25686. }
  25687. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  25688. // the given name in this mutation.
  25689. func (m *SopTaskMutation) RemovedIDs(name string) []ent.Value {
  25690. switch name {
  25691. case soptask.EdgeTaskStages:
  25692. ids := make([]ent.Value, 0, len(m.removedtask_stages))
  25693. for id := range m.removedtask_stages {
  25694. ids = append(ids, id)
  25695. }
  25696. return ids
  25697. }
  25698. return nil
  25699. }
  25700. // ClearedEdges returns all edge names that were cleared in this mutation.
  25701. func (m *SopTaskMutation) ClearedEdges() []string {
  25702. edges := make([]string, 0, 1)
  25703. if m.clearedtask_stages {
  25704. edges = append(edges, soptask.EdgeTaskStages)
  25705. }
  25706. return edges
  25707. }
  25708. // EdgeCleared returns a boolean which indicates if the edge with the given name
  25709. // was cleared in this mutation.
  25710. func (m *SopTaskMutation) EdgeCleared(name string) bool {
  25711. switch name {
  25712. case soptask.EdgeTaskStages:
  25713. return m.clearedtask_stages
  25714. }
  25715. return false
  25716. }
  25717. // ClearEdge clears the value of the edge with the given name. It returns an error
  25718. // if that edge is not defined in the schema.
  25719. func (m *SopTaskMutation) ClearEdge(name string) error {
  25720. switch name {
  25721. }
  25722. return fmt.Errorf("unknown SopTask unique edge %s", name)
  25723. }
  25724. // ResetEdge resets all changes to the edge with the given name in this mutation.
  25725. // It returns an error if the edge is not defined in the schema.
  25726. func (m *SopTaskMutation) ResetEdge(name string) error {
  25727. switch name {
  25728. case soptask.EdgeTaskStages:
  25729. m.ResetTaskStages()
  25730. return nil
  25731. }
  25732. return fmt.Errorf("unknown SopTask edge %s", name)
  25733. }
  25734. // TokenMutation represents an operation that mutates the Token nodes in the graph.
  25735. type TokenMutation struct {
  25736. config
  25737. op Op
  25738. typ string
  25739. id *uint64
  25740. created_at *time.Time
  25741. updated_at *time.Time
  25742. deleted_at *time.Time
  25743. expire_at *time.Time
  25744. token *string
  25745. mac *string
  25746. organization_id *uint64
  25747. addorganization_id *int64
  25748. custom_agent_base *string
  25749. custom_agent_key *string
  25750. openai_base *string
  25751. openai_key *string
  25752. clearedFields map[string]struct{}
  25753. agent *uint64
  25754. clearedagent bool
  25755. done bool
  25756. oldValue func(context.Context) (*Token, error)
  25757. predicates []predicate.Token
  25758. }
  25759. var _ ent.Mutation = (*TokenMutation)(nil)
  25760. // tokenOption allows management of the mutation configuration using functional options.
  25761. type tokenOption func(*TokenMutation)
  25762. // newTokenMutation creates new mutation for the Token entity.
  25763. func newTokenMutation(c config, op Op, opts ...tokenOption) *TokenMutation {
  25764. m := &TokenMutation{
  25765. config: c,
  25766. op: op,
  25767. typ: TypeToken,
  25768. clearedFields: make(map[string]struct{}),
  25769. }
  25770. for _, opt := range opts {
  25771. opt(m)
  25772. }
  25773. return m
  25774. }
  25775. // withTokenID sets the ID field of the mutation.
  25776. func withTokenID(id uint64) tokenOption {
  25777. return func(m *TokenMutation) {
  25778. var (
  25779. err error
  25780. once sync.Once
  25781. value *Token
  25782. )
  25783. m.oldValue = func(ctx context.Context) (*Token, error) {
  25784. once.Do(func() {
  25785. if m.done {
  25786. err = errors.New("querying old values post mutation is not allowed")
  25787. } else {
  25788. value, err = m.Client().Token.Get(ctx, id)
  25789. }
  25790. })
  25791. return value, err
  25792. }
  25793. m.id = &id
  25794. }
  25795. }
  25796. // withToken sets the old Token of the mutation.
  25797. func withToken(node *Token) tokenOption {
  25798. return func(m *TokenMutation) {
  25799. m.oldValue = func(context.Context) (*Token, error) {
  25800. return node, nil
  25801. }
  25802. m.id = &node.ID
  25803. }
  25804. }
  25805. // Client returns a new `ent.Client` from the mutation. If the mutation was
  25806. // executed in a transaction (ent.Tx), a transactional client is returned.
  25807. func (m TokenMutation) Client() *Client {
  25808. client := &Client{config: m.config}
  25809. client.init()
  25810. return client
  25811. }
  25812. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  25813. // it returns an error otherwise.
  25814. func (m TokenMutation) Tx() (*Tx, error) {
  25815. if _, ok := m.driver.(*txDriver); !ok {
  25816. return nil, errors.New("ent: mutation is not running in a transaction")
  25817. }
  25818. tx := &Tx{config: m.config}
  25819. tx.init()
  25820. return tx, nil
  25821. }
  25822. // SetID sets the value of the id field. Note that this
  25823. // operation is only accepted on creation of Token entities.
  25824. func (m *TokenMutation) SetID(id uint64) {
  25825. m.id = &id
  25826. }
  25827. // ID returns the ID value in the mutation. Note that the ID is only available
  25828. // if it was provided to the builder or after it was returned from the database.
  25829. func (m *TokenMutation) ID() (id uint64, exists bool) {
  25830. if m.id == nil {
  25831. return
  25832. }
  25833. return *m.id, true
  25834. }
  25835. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  25836. // That means, if the mutation is applied within a transaction with an isolation level such
  25837. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  25838. // or updated by the mutation.
  25839. func (m *TokenMutation) IDs(ctx context.Context) ([]uint64, error) {
  25840. switch {
  25841. case m.op.Is(OpUpdateOne | OpDeleteOne):
  25842. id, exists := m.ID()
  25843. if exists {
  25844. return []uint64{id}, nil
  25845. }
  25846. fallthrough
  25847. case m.op.Is(OpUpdate | OpDelete):
  25848. return m.Client().Token.Query().Where(m.predicates...).IDs(ctx)
  25849. default:
  25850. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  25851. }
  25852. }
  25853. // SetCreatedAt sets the "created_at" field.
  25854. func (m *TokenMutation) SetCreatedAt(t time.Time) {
  25855. m.created_at = &t
  25856. }
  25857. // CreatedAt returns the value of the "created_at" field in the mutation.
  25858. func (m *TokenMutation) CreatedAt() (r time.Time, exists bool) {
  25859. v := m.created_at
  25860. if v == nil {
  25861. return
  25862. }
  25863. return *v, true
  25864. }
  25865. // OldCreatedAt returns the old "created_at" field's value of the Token entity.
  25866. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  25867. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25868. func (m *TokenMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  25869. if !m.op.Is(OpUpdateOne) {
  25870. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  25871. }
  25872. if m.id == nil || m.oldValue == nil {
  25873. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  25874. }
  25875. oldValue, err := m.oldValue(ctx)
  25876. if err != nil {
  25877. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  25878. }
  25879. return oldValue.CreatedAt, nil
  25880. }
  25881. // ResetCreatedAt resets all changes to the "created_at" field.
  25882. func (m *TokenMutation) ResetCreatedAt() {
  25883. m.created_at = nil
  25884. }
  25885. // SetUpdatedAt sets the "updated_at" field.
  25886. func (m *TokenMutation) SetUpdatedAt(t time.Time) {
  25887. m.updated_at = &t
  25888. }
  25889. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  25890. func (m *TokenMutation) UpdatedAt() (r time.Time, exists bool) {
  25891. v := m.updated_at
  25892. if v == nil {
  25893. return
  25894. }
  25895. return *v, true
  25896. }
  25897. // OldUpdatedAt returns the old "updated_at" field's value of the Token entity.
  25898. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  25899. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25900. func (m *TokenMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  25901. if !m.op.Is(OpUpdateOne) {
  25902. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  25903. }
  25904. if m.id == nil || m.oldValue == nil {
  25905. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  25906. }
  25907. oldValue, err := m.oldValue(ctx)
  25908. if err != nil {
  25909. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  25910. }
  25911. return oldValue.UpdatedAt, nil
  25912. }
  25913. // ResetUpdatedAt resets all changes to the "updated_at" field.
  25914. func (m *TokenMutation) ResetUpdatedAt() {
  25915. m.updated_at = nil
  25916. }
  25917. // SetDeletedAt sets the "deleted_at" field.
  25918. func (m *TokenMutation) SetDeletedAt(t time.Time) {
  25919. m.deleted_at = &t
  25920. }
  25921. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  25922. func (m *TokenMutation) DeletedAt() (r time.Time, exists bool) {
  25923. v := m.deleted_at
  25924. if v == nil {
  25925. return
  25926. }
  25927. return *v, true
  25928. }
  25929. // OldDeletedAt returns the old "deleted_at" field's value of the Token entity.
  25930. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  25931. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25932. func (m *TokenMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  25933. if !m.op.Is(OpUpdateOne) {
  25934. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  25935. }
  25936. if m.id == nil || m.oldValue == nil {
  25937. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  25938. }
  25939. oldValue, err := m.oldValue(ctx)
  25940. if err != nil {
  25941. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  25942. }
  25943. return oldValue.DeletedAt, nil
  25944. }
  25945. // ClearDeletedAt clears the value of the "deleted_at" field.
  25946. func (m *TokenMutation) ClearDeletedAt() {
  25947. m.deleted_at = nil
  25948. m.clearedFields[token.FieldDeletedAt] = struct{}{}
  25949. }
  25950. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  25951. func (m *TokenMutation) DeletedAtCleared() bool {
  25952. _, ok := m.clearedFields[token.FieldDeletedAt]
  25953. return ok
  25954. }
  25955. // ResetDeletedAt resets all changes to the "deleted_at" field.
  25956. func (m *TokenMutation) ResetDeletedAt() {
  25957. m.deleted_at = nil
  25958. delete(m.clearedFields, token.FieldDeletedAt)
  25959. }
  25960. // SetExpireAt sets the "expire_at" field.
  25961. func (m *TokenMutation) SetExpireAt(t time.Time) {
  25962. m.expire_at = &t
  25963. }
  25964. // ExpireAt returns the value of the "expire_at" field in the mutation.
  25965. func (m *TokenMutation) ExpireAt() (r time.Time, exists bool) {
  25966. v := m.expire_at
  25967. if v == nil {
  25968. return
  25969. }
  25970. return *v, true
  25971. }
  25972. // OldExpireAt returns the old "expire_at" field's value of the Token entity.
  25973. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  25974. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25975. func (m *TokenMutation) OldExpireAt(ctx context.Context) (v time.Time, err error) {
  25976. if !m.op.Is(OpUpdateOne) {
  25977. return v, errors.New("OldExpireAt is only allowed on UpdateOne operations")
  25978. }
  25979. if m.id == nil || m.oldValue == nil {
  25980. return v, errors.New("OldExpireAt requires an ID field in the mutation")
  25981. }
  25982. oldValue, err := m.oldValue(ctx)
  25983. if err != nil {
  25984. return v, fmt.Errorf("querying old value for OldExpireAt: %w", err)
  25985. }
  25986. return oldValue.ExpireAt, nil
  25987. }
  25988. // ClearExpireAt clears the value of the "expire_at" field.
  25989. func (m *TokenMutation) ClearExpireAt() {
  25990. m.expire_at = nil
  25991. m.clearedFields[token.FieldExpireAt] = struct{}{}
  25992. }
  25993. // ExpireAtCleared returns if the "expire_at" field was cleared in this mutation.
  25994. func (m *TokenMutation) ExpireAtCleared() bool {
  25995. _, ok := m.clearedFields[token.FieldExpireAt]
  25996. return ok
  25997. }
  25998. // ResetExpireAt resets all changes to the "expire_at" field.
  25999. func (m *TokenMutation) ResetExpireAt() {
  26000. m.expire_at = nil
  26001. delete(m.clearedFields, token.FieldExpireAt)
  26002. }
  26003. // SetToken sets the "token" field.
  26004. func (m *TokenMutation) SetToken(s string) {
  26005. m.token = &s
  26006. }
  26007. // Token returns the value of the "token" field in the mutation.
  26008. func (m *TokenMutation) Token() (r string, exists bool) {
  26009. v := m.token
  26010. if v == nil {
  26011. return
  26012. }
  26013. return *v, true
  26014. }
  26015. // OldToken returns the old "token" field's value of the Token entity.
  26016. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  26017. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26018. func (m *TokenMutation) OldToken(ctx context.Context) (v string, err error) {
  26019. if !m.op.Is(OpUpdateOne) {
  26020. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  26021. }
  26022. if m.id == nil || m.oldValue == nil {
  26023. return v, errors.New("OldToken requires an ID field in the mutation")
  26024. }
  26025. oldValue, err := m.oldValue(ctx)
  26026. if err != nil {
  26027. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  26028. }
  26029. return oldValue.Token, nil
  26030. }
  26031. // ClearToken clears the value of the "token" field.
  26032. func (m *TokenMutation) ClearToken() {
  26033. m.token = nil
  26034. m.clearedFields[token.FieldToken] = struct{}{}
  26035. }
  26036. // TokenCleared returns if the "token" field was cleared in this mutation.
  26037. func (m *TokenMutation) TokenCleared() bool {
  26038. _, ok := m.clearedFields[token.FieldToken]
  26039. return ok
  26040. }
  26041. // ResetToken resets all changes to the "token" field.
  26042. func (m *TokenMutation) ResetToken() {
  26043. m.token = nil
  26044. delete(m.clearedFields, token.FieldToken)
  26045. }
  26046. // SetMAC sets the "mac" field.
  26047. func (m *TokenMutation) SetMAC(s string) {
  26048. m.mac = &s
  26049. }
  26050. // MAC returns the value of the "mac" field in the mutation.
  26051. func (m *TokenMutation) MAC() (r string, exists bool) {
  26052. v := m.mac
  26053. if v == nil {
  26054. return
  26055. }
  26056. return *v, true
  26057. }
  26058. // OldMAC returns the old "mac" field's value of the Token entity.
  26059. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  26060. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26061. func (m *TokenMutation) OldMAC(ctx context.Context) (v string, err error) {
  26062. if !m.op.Is(OpUpdateOne) {
  26063. return v, errors.New("OldMAC is only allowed on UpdateOne operations")
  26064. }
  26065. if m.id == nil || m.oldValue == nil {
  26066. return v, errors.New("OldMAC requires an ID field in the mutation")
  26067. }
  26068. oldValue, err := m.oldValue(ctx)
  26069. if err != nil {
  26070. return v, fmt.Errorf("querying old value for OldMAC: %w", err)
  26071. }
  26072. return oldValue.MAC, nil
  26073. }
  26074. // ClearMAC clears the value of the "mac" field.
  26075. func (m *TokenMutation) ClearMAC() {
  26076. m.mac = nil
  26077. m.clearedFields[token.FieldMAC] = struct{}{}
  26078. }
  26079. // MACCleared returns if the "mac" field was cleared in this mutation.
  26080. func (m *TokenMutation) MACCleared() bool {
  26081. _, ok := m.clearedFields[token.FieldMAC]
  26082. return ok
  26083. }
  26084. // ResetMAC resets all changes to the "mac" field.
  26085. func (m *TokenMutation) ResetMAC() {
  26086. m.mac = nil
  26087. delete(m.clearedFields, token.FieldMAC)
  26088. }
  26089. // SetOrganizationID sets the "organization_id" field.
  26090. func (m *TokenMutation) SetOrganizationID(u uint64) {
  26091. m.organization_id = &u
  26092. m.addorganization_id = nil
  26093. }
  26094. // OrganizationID returns the value of the "organization_id" field in the mutation.
  26095. func (m *TokenMutation) OrganizationID() (r uint64, exists bool) {
  26096. v := m.organization_id
  26097. if v == nil {
  26098. return
  26099. }
  26100. return *v, true
  26101. }
  26102. // OldOrganizationID returns the old "organization_id" field's value of the Token entity.
  26103. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  26104. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26105. func (m *TokenMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  26106. if !m.op.Is(OpUpdateOne) {
  26107. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  26108. }
  26109. if m.id == nil || m.oldValue == nil {
  26110. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  26111. }
  26112. oldValue, err := m.oldValue(ctx)
  26113. if err != nil {
  26114. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  26115. }
  26116. return oldValue.OrganizationID, nil
  26117. }
  26118. // AddOrganizationID adds u to the "organization_id" field.
  26119. func (m *TokenMutation) AddOrganizationID(u int64) {
  26120. if m.addorganization_id != nil {
  26121. *m.addorganization_id += u
  26122. } else {
  26123. m.addorganization_id = &u
  26124. }
  26125. }
  26126. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  26127. func (m *TokenMutation) AddedOrganizationID() (r int64, exists bool) {
  26128. v := m.addorganization_id
  26129. if v == nil {
  26130. return
  26131. }
  26132. return *v, true
  26133. }
  26134. // ResetOrganizationID resets all changes to the "organization_id" field.
  26135. func (m *TokenMutation) ResetOrganizationID() {
  26136. m.organization_id = nil
  26137. m.addorganization_id = nil
  26138. }
  26139. // SetAgentID sets the "agent_id" field.
  26140. func (m *TokenMutation) SetAgentID(u uint64) {
  26141. m.agent = &u
  26142. }
  26143. // AgentID returns the value of the "agent_id" field in the mutation.
  26144. func (m *TokenMutation) AgentID() (r uint64, exists bool) {
  26145. v := m.agent
  26146. if v == nil {
  26147. return
  26148. }
  26149. return *v, true
  26150. }
  26151. // OldAgentID returns the old "agent_id" field's value of the Token entity.
  26152. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  26153. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26154. func (m *TokenMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  26155. if !m.op.Is(OpUpdateOne) {
  26156. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  26157. }
  26158. if m.id == nil || m.oldValue == nil {
  26159. return v, errors.New("OldAgentID requires an ID field in the mutation")
  26160. }
  26161. oldValue, err := m.oldValue(ctx)
  26162. if err != nil {
  26163. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  26164. }
  26165. return oldValue.AgentID, nil
  26166. }
  26167. // ResetAgentID resets all changes to the "agent_id" field.
  26168. func (m *TokenMutation) ResetAgentID() {
  26169. m.agent = nil
  26170. }
  26171. // SetCustomAgentBase sets the "custom_agent_base" field.
  26172. func (m *TokenMutation) SetCustomAgentBase(s string) {
  26173. m.custom_agent_base = &s
  26174. }
  26175. // CustomAgentBase returns the value of the "custom_agent_base" field in the mutation.
  26176. func (m *TokenMutation) CustomAgentBase() (r string, exists bool) {
  26177. v := m.custom_agent_base
  26178. if v == nil {
  26179. return
  26180. }
  26181. return *v, true
  26182. }
  26183. // OldCustomAgentBase returns the old "custom_agent_base" field's value of the Token entity.
  26184. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  26185. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26186. func (m *TokenMutation) OldCustomAgentBase(ctx context.Context) (v string, err error) {
  26187. if !m.op.Is(OpUpdateOne) {
  26188. return v, errors.New("OldCustomAgentBase is only allowed on UpdateOne operations")
  26189. }
  26190. if m.id == nil || m.oldValue == nil {
  26191. return v, errors.New("OldCustomAgentBase requires an ID field in the mutation")
  26192. }
  26193. oldValue, err := m.oldValue(ctx)
  26194. if err != nil {
  26195. return v, fmt.Errorf("querying old value for OldCustomAgentBase: %w", err)
  26196. }
  26197. return oldValue.CustomAgentBase, nil
  26198. }
  26199. // ClearCustomAgentBase clears the value of the "custom_agent_base" field.
  26200. func (m *TokenMutation) ClearCustomAgentBase() {
  26201. m.custom_agent_base = nil
  26202. m.clearedFields[token.FieldCustomAgentBase] = struct{}{}
  26203. }
  26204. // CustomAgentBaseCleared returns if the "custom_agent_base" field was cleared in this mutation.
  26205. func (m *TokenMutation) CustomAgentBaseCleared() bool {
  26206. _, ok := m.clearedFields[token.FieldCustomAgentBase]
  26207. return ok
  26208. }
  26209. // ResetCustomAgentBase resets all changes to the "custom_agent_base" field.
  26210. func (m *TokenMutation) ResetCustomAgentBase() {
  26211. m.custom_agent_base = nil
  26212. delete(m.clearedFields, token.FieldCustomAgentBase)
  26213. }
  26214. // SetCustomAgentKey sets the "custom_agent_key" field.
  26215. func (m *TokenMutation) SetCustomAgentKey(s string) {
  26216. m.custom_agent_key = &s
  26217. }
  26218. // CustomAgentKey returns the value of the "custom_agent_key" field in the mutation.
  26219. func (m *TokenMutation) CustomAgentKey() (r string, exists bool) {
  26220. v := m.custom_agent_key
  26221. if v == nil {
  26222. return
  26223. }
  26224. return *v, true
  26225. }
  26226. // OldCustomAgentKey returns the old "custom_agent_key" field's value of the Token entity.
  26227. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  26228. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26229. func (m *TokenMutation) OldCustomAgentKey(ctx context.Context) (v string, err error) {
  26230. if !m.op.Is(OpUpdateOne) {
  26231. return v, errors.New("OldCustomAgentKey is only allowed on UpdateOne operations")
  26232. }
  26233. if m.id == nil || m.oldValue == nil {
  26234. return v, errors.New("OldCustomAgentKey requires an ID field in the mutation")
  26235. }
  26236. oldValue, err := m.oldValue(ctx)
  26237. if err != nil {
  26238. return v, fmt.Errorf("querying old value for OldCustomAgentKey: %w", err)
  26239. }
  26240. return oldValue.CustomAgentKey, nil
  26241. }
  26242. // ClearCustomAgentKey clears the value of the "custom_agent_key" field.
  26243. func (m *TokenMutation) ClearCustomAgentKey() {
  26244. m.custom_agent_key = nil
  26245. m.clearedFields[token.FieldCustomAgentKey] = struct{}{}
  26246. }
  26247. // CustomAgentKeyCleared returns if the "custom_agent_key" field was cleared in this mutation.
  26248. func (m *TokenMutation) CustomAgentKeyCleared() bool {
  26249. _, ok := m.clearedFields[token.FieldCustomAgentKey]
  26250. return ok
  26251. }
  26252. // ResetCustomAgentKey resets all changes to the "custom_agent_key" field.
  26253. func (m *TokenMutation) ResetCustomAgentKey() {
  26254. m.custom_agent_key = nil
  26255. delete(m.clearedFields, token.FieldCustomAgentKey)
  26256. }
  26257. // SetOpenaiBase sets the "openai_base" field.
  26258. func (m *TokenMutation) SetOpenaiBase(s string) {
  26259. m.openai_base = &s
  26260. }
  26261. // OpenaiBase returns the value of the "openai_base" field in the mutation.
  26262. func (m *TokenMutation) OpenaiBase() (r string, exists bool) {
  26263. v := m.openai_base
  26264. if v == nil {
  26265. return
  26266. }
  26267. return *v, true
  26268. }
  26269. // OldOpenaiBase returns the old "openai_base" field's value of the Token entity.
  26270. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  26271. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26272. func (m *TokenMutation) OldOpenaiBase(ctx context.Context) (v string, err error) {
  26273. if !m.op.Is(OpUpdateOne) {
  26274. return v, errors.New("OldOpenaiBase is only allowed on UpdateOne operations")
  26275. }
  26276. if m.id == nil || m.oldValue == nil {
  26277. return v, errors.New("OldOpenaiBase requires an ID field in the mutation")
  26278. }
  26279. oldValue, err := m.oldValue(ctx)
  26280. if err != nil {
  26281. return v, fmt.Errorf("querying old value for OldOpenaiBase: %w", err)
  26282. }
  26283. return oldValue.OpenaiBase, nil
  26284. }
  26285. // ClearOpenaiBase clears the value of the "openai_base" field.
  26286. func (m *TokenMutation) ClearOpenaiBase() {
  26287. m.openai_base = nil
  26288. m.clearedFields[token.FieldOpenaiBase] = struct{}{}
  26289. }
  26290. // OpenaiBaseCleared returns if the "openai_base" field was cleared in this mutation.
  26291. func (m *TokenMutation) OpenaiBaseCleared() bool {
  26292. _, ok := m.clearedFields[token.FieldOpenaiBase]
  26293. return ok
  26294. }
  26295. // ResetOpenaiBase resets all changes to the "openai_base" field.
  26296. func (m *TokenMutation) ResetOpenaiBase() {
  26297. m.openai_base = nil
  26298. delete(m.clearedFields, token.FieldOpenaiBase)
  26299. }
  26300. // SetOpenaiKey sets the "openai_key" field.
  26301. func (m *TokenMutation) SetOpenaiKey(s string) {
  26302. m.openai_key = &s
  26303. }
  26304. // OpenaiKey returns the value of the "openai_key" field in the mutation.
  26305. func (m *TokenMutation) OpenaiKey() (r string, exists bool) {
  26306. v := m.openai_key
  26307. if v == nil {
  26308. return
  26309. }
  26310. return *v, true
  26311. }
  26312. // OldOpenaiKey returns the old "openai_key" field's value of the Token entity.
  26313. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  26314. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26315. func (m *TokenMutation) OldOpenaiKey(ctx context.Context) (v string, err error) {
  26316. if !m.op.Is(OpUpdateOne) {
  26317. return v, errors.New("OldOpenaiKey is only allowed on UpdateOne operations")
  26318. }
  26319. if m.id == nil || m.oldValue == nil {
  26320. return v, errors.New("OldOpenaiKey requires an ID field in the mutation")
  26321. }
  26322. oldValue, err := m.oldValue(ctx)
  26323. if err != nil {
  26324. return v, fmt.Errorf("querying old value for OldOpenaiKey: %w", err)
  26325. }
  26326. return oldValue.OpenaiKey, nil
  26327. }
  26328. // ClearOpenaiKey clears the value of the "openai_key" field.
  26329. func (m *TokenMutation) ClearOpenaiKey() {
  26330. m.openai_key = nil
  26331. m.clearedFields[token.FieldOpenaiKey] = struct{}{}
  26332. }
  26333. // OpenaiKeyCleared returns if the "openai_key" field was cleared in this mutation.
  26334. func (m *TokenMutation) OpenaiKeyCleared() bool {
  26335. _, ok := m.clearedFields[token.FieldOpenaiKey]
  26336. return ok
  26337. }
  26338. // ResetOpenaiKey resets all changes to the "openai_key" field.
  26339. func (m *TokenMutation) ResetOpenaiKey() {
  26340. m.openai_key = nil
  26341. delete(m.clearedFields, token.FieldOpenaiKey)
  26342. }
  26343. // ClearAgent clears the "agent" edge to the Agent entity.
  26344. func (m *TokenMutation) ClearAgent() {
  26345. m.clearedagent = true
  26346. m.clearedFields[token.FieldAgentID] = struct{}{}
  26347. }
  26348. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  26349. func (m *TokenMutation) AgentCleared() bool {
  26350. return m.clearedagent
  26351. }
  26352. // AgentIDs returns the "agent" edge IDs in the mutation.
  26353. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  26354. // AgentID instead. It exists only for internal usage by the builders.
  26355. func (m *TokenMutation) AgentIDs() (ids []uint64) {
  26356. if id := m.agent; id != nil {
  26357. ids = append(ids, *id)
  26358. }
  26359. return
  26360. }
  26361. // ResetAgent resets all changes to the "agent" edge.
  26362. func (m *TokenMutation) ResetAgent() {
  26363. m.agent = nil
  26364. m.clearedagent = false
  26365. }
  26366. // Where appends a list predicates to the TokenMutation builder.
  26367. func (m *TokenMutation) Where(ps ...predicate.Token) {
  26368. m.predicates = append(m.predicates, ps...)
  26369. }
  26370. // WhereP appends storage-level predicates to the TokenMutation builder. Using this method,
  26371. // users can use type-assertion to append predicates that do not depend on any generated package.
  26372. func (m *TokenMutation) WhereP(ps ...func(*sql.Selector)) {
  26373. p := make([]predicate.Token, len(ps))
  26374. for i := range ps {
  26375. p[i] = ps[i]
  26376. }
  26377. m.Where(p...)
  26378. }
  26379. // Op returns the operation name.
  26380. func (m *TokenMutation) Op() Op {
  26381. return m.op
  26382. }
  26383. // SetOp allows setting the mutation operation.
  26384. func (m *TokenMutation) SetOp(op Op) {
  26385. m.op = op
  26386. }
  26387. // Type returns the node type of this mutation (Token).
  26388. func (m *TokenMutation) Type() string {
  26389. return m.typ
  26390. }
  26391. // Fields returns all fields that were changed during this mutation. Note that in
  26392. // order to get all numeric fields that were incremented/decremented, call
  26393. // AddedFields().
  26394. func (m *TokenMutation) Fields() []string {
  26395. fields := make([]string, 0, 12)
  26396. if m.created_at != nil {
  26397. fields = append(fields, token.FieldCreatedAt)
  26398. }
  26399. if m.updated_at != nil {
  26400. fields = append(fields, token.FieldUpdatedAt)
  26401. }
  26402. if m.deleted_at != nil {
  26403. fields = append(fields, token.FieldDeletedAt)
  26404. }
  26405. if m.expire_at != nil {
  26406. fields = append(fields, token.FieldExpireAt)
  26407. }
  26408. if m.token != nil {
  26409. fields = append(fields, token.FieldToken)
  26410. }
  26411. if m.mac != nil {
  26412. fields = append(fields, token.FieldMAC)
  26413. }
  26414. if m.organization_id != nil {
  26415. fields = append(fields, token.FieldOrganizationID)
  26416. }
  26417. if m.agent != nil {
  26418. fields = append(fields, token.FieldAgentID)
  26419. }
  26420. if m.custom_agent_base != nil {
  26421. fields = append(fields, token.FieldCustomAgentBase)
  26422. }
  26423. if m.custom_agent_key != nil {
  26424. fields = append(fields, token.FieldCustomAgentKey)
  26425. }
  26426. if m.openai_base != nil {
  26427. fields = append(fields, token.FieldOpenaiBase)
  26428. }
  26429. if m.openai_key != nil {
  26430. fields = append(fields, token.FieldOpenaiKey)
  26431. }
  26432. return fields
  26433. }
  26434. // Field returns the value of a field with the given name. The second boolean
  26435. // return value indicates that this field was not set, or was not defined in the
  26436. // schema.
  26437. func (m *TokenMutation) Field(name string) (ent.Value, bool) {
  26438. switch name {
  26439. case token.FieldCreatedAt:
  26440. return m.CreatedAt()
  26441. case token.FieldUpdatedAt:
  26442. return m.UpdatedAt()
  26443. case token.FieldDeletedAt:
  26444. return m.DeletedAt()
  26445. case token.FieldExpireAt:
  26446. return m.ExpireAt()
  26447. case token.FieldToken:
  26448. return m.Token()
  26449. case token.FieldMAC:
  26450. return m.MAC()
  26451. case token.FieldOrganizationID:
  26452. return m.OrganizationID()
  26453. case token.FieldAgentID:
  26454. return m.AgentID()
  26455. case token.FieldCustomAgentBase:
  26456. return m.CustomAgentBase()
  26457. case token.FieldCustomAgentKey:
  26458. return m.CustomAgentKey()
  26459. case token.FieldOpenaiBase:
  26460. return m.OpenaiBase()
  26461. case token.FieldOpenaiKey:
  26462. return m.OpenaiKey()
  26463. }
  26464. return nil, false
  26465. }
  26466. // OldField returns the old value of the field from the database. An error is
  26467. // returned if the mutation operation is not UpdateOne, or the query to the
  26468. // database failed.
  26469. func (m *TokenMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  26470. switch name {
  26471. case token.FieldCreatedAt:
  26472. return m.OldCreatedAt(ctx)
  26473. case token.FieldUpdatedAt:
  26474. return m.OldUpdatedAt(ctx)
  26475. case token.FieldDeletedAt:
  26476. return m.OldDeletedAt(ctx)
  26477. case token.FieldExpireAt:
  26478. return m.OldExpireAt(ctx)
  26479. case token.FieldToken:
  26480. return m.OldToken(ctx)
  26481. case token.FieldMAC:
  26482. return m.OldMAC(ctx)
  26483. case token.FieldOrganizationID:
  26484. return m.OldOrganizationID(ctx)
  26485. case token.FieldAgentID:
  26486. return m.OldAgentID(ctx)
  26487. case token.FieldCustomAgentBase:
  26488. return m.OldCustomAgentBase(ctx)
  26489. case token.FieldCustomAgentKey:
  26490. return m.OldCustomAgentKey(ctx)
  26491. case token.FieldOpenaiBase:
  26492. return m.OldOpenaiBase(ctx)
  26493. case token.FieldOpenaiKey:
  26494. return m.OldOpenaiKey(ctx)
  26495. }
  26496. return nil, fmt.Errorf("unknown Token field %s", name)
  26497. }
  26498. // SetField sets the value of a field with the given name. It returns an error if
  26499. // the field is not defined in the schema, or if the type mismatched the field
  26500. // type.
  26501. func (m *TokenMutation) SetField(name string, value ent.Value) error {
  26502. switch name {
  26503. case token.FieldCreatedAt:
  26504. v, ok := value.(time.Time)
  26505. if !ok {
  26506. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26507. }
  26508. m.SetCreatedAt(v)
  26509. return nil
  26510. case token.FieldUpdatedAt:
  26511. v, ok := value.(time.Time)
  26512. if !ok {
  26513. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26514. }
  26515. m.SetUpdatedAt(v)
  26516. return nil
  26517. case token.FieldDeletedAt:
  26518. v, ok := value.(time.Time)
  26519. if !ok {
  26520. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26521. }
  26522. m.SetDeletedAt(v)
  26523. return nil
  26524. case token.FieldExpireAt:
  26525. v, ok := value.(time.Time)
  26526. if !ok {
  26527. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26528. }
  26529. m.SetExpireAt(v)
  26530. return nil
  26531. case token.FieldToken:
  26532. v, ok := value.(string)
  26533. if !ok {
  26534. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26535. }
  26536. m.SetToken(v)
  26537. return nil
  26538. case token.FieldMAC:
  26539. v, ok := value.(string)
  26540. if !ok {
  26541. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26542. }
  26543. m.SetMAC(v)
  26544. return nil
  26545. case token.FieldOrganizationID:
  26546. v, ok := value.(uint64)
  26547. if !ok {
  26548. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26549. }
  26550. m.SetOrganizationID(v)
  26551. return nil
  26552. case token.FieldAgentID:
  26553. v, ok := value.(uint64)
  26554. if !ok {
  26555. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26556. }
  26557. m.SetAgentID(v)
  26558. return nil
  26559. case token.FieldCustomAgentBase:
  26560. v, ok := value.(string)
  26561. if !ok {
  26562. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26563. }
  26564. m.SetCustomAgentBase(v)
  26565. return nil
  26566. case token.FieldCustomAgentKey:
  26567. v, ok := value.(string)
  26568. if !ok {
  26569. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26570. }
  26571. m.SetCustomAgentKey(v)
  26572. return nil
  26573. case token.FieldOpenaiBase:
  26574. v, ok := value.(string)
  26575. if !ok {
  26576. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26577. }
  26578. m.SetOpenaiBase(v)
  26579. return nil
  26580. case token.FieldOpenaiKey:
  26581. v, ok := value.(string)
  26582. if !ok {
  26583. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26584. }
  26585. m.SetOpenaiKey(v)
  26586. return nil
  26587. }
  26588. return fmt.Errorf("unknown Token field %s", name)
  26589. }
  26590. // AddedFields returns all numeric fields that were incremented/decremented during
  26591. // this mutation.
  26592. func (m *TokenMutation) AddedFields() []string {
  26593. var fields []string
  26594. if m.addorganization_id != nil {
  26595. fields = append(fields, token.FieldOrganizationID)
  26596. }
  26597. return fields
  26598. }
  26599. // AddedField returns the numeric value that was incremented/decremented on a field
  26600. // with the given name. The second boolean return value indicates that this field
  26601. // was not set, or was not defined in the schema.
  26602. func (m *TokenMutation) AddedField(name string) (ent.Value, bool) {
  26603. switch name {
  26604. case token.FieldOrganizationID:
  26605. return m.AddedOrganizationID()
  26606. }
  26607. return nil, false
  26608. }
  26609. // AddField adds the value to the field with the given name. It returns an error if
  26610. // the field is not defined in the schema, or if the type mismatched the field
  26611. // type.
  26612. func (m *TokenMutation) AddField(name string, value ent.Value) error {
  26613. switch name {
  26614. case token.FieldOrganizationID:
  26615. v, ok := value.(int64)
  26616. if !ok {
  26617. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26618. }
  26619. m.AddOrganizationID(v)
  26620. return nil
  26621. }
  26622. return fmt.Errorf("unknown Token numeric field %s", name)
  26623. }
  26624. // ClearedFields returns all nullable fields that were cleared during this
  26625. // mutation.
  26626. func (m *TokenMutation) ClearedFields() []string {
  26627. var fields []string
  26628. if m.FieldCleared(token.FieldDeletedAt) {
  26629. fields = append(fields, token.FieldDeletedAt)
  26630. }
  26631. if m.FieldCleared(token.FieldExpireAt) {
  26632. fields = append(fields, token.FieldExpireAt)
  26633. }
  26634. if m.FieldCleared(token.FieldToken) {
  26635. fields = append(fields, token.FieldToken)
  26636. }
  26637. if m.FieldCleared(token.FieldMAC) {
  26638. fields = append(fields, token.FieldMAC)
  26639. }
  26640. if m.FieldCleared(token.FieldCustomAgentBase) {
  26641. fields = append(fields, token.FieldCustomAgentBase)
  26642. }
  26643. if m.FieldCleared(token.FieldCustomAgentKey) {
  26644. fields = append(fields, token.FieldCustomAgentKey)
  26645. }
  26646. if m.FieldCleared(token.FieldOpenaiBase) {
  26647. fields = append(fields, token.FieldOpenaiBase)
  26648. }
  26649. if m.FieldCleared(token.FieldOpenaiKey) {
  26650. fields = append(fields, token.FieldOpenaiKey)
  26651. }
  26652. return fields
  26653. }
  26654. // FieldCleared returns a boolean indicating if a field with the given name was
  26655. // cleared in this mutation.
  26656. func (m *TokenMutation) FieldCleared(name string) bool {
  26657. _, ok := m.clearedFields[name]
  26658. return ok
  26659. }
  26660. // ClearField clears the value of the field with the given name. It returns an
  26661. // error if the field is not defined in the schema.
  26662. func (m *TokenMutation) ClearField(name string) error {
  26663. switch name {
  26664. case token.FieldDeletedAt:
  26665. m.ClearDeletedAt()
  26666. return nil
  26667. case token.FieldExpireAt:
  26668. m.ClearExpireAt()
  26669. return nil
  26670. case token.FieldToken:
  26671. m.ClearToken()
  26672. return nil
  26673. case token.FieldMAC:
  26674. m.ClearMAC()
  26675. return nil
  26676. case token.FieldCustomAgentBase:
  26677. m.ClearCustomAgentBase()
  26678. return nil
  26679. case token.FieldCustomAgentKey:
  26680. m.ClearCustomAgentKey()
  26681. return nil
  26682. case token.FieldOpenaiBase:
  26683. m.ClearOpenaiBase()
  26684. return nil
  26685. case token.FieldOpenaiKey:
  26686. m.ClearOpenaiKey()
  26687. return nil
  26688. }
  26689. return fmt.Errorf("unknown Token nullable field %s", name)
  26690. }
  26691. // ResetField resets all changes in the mutation for the field with the given name.
  26692. // It returns an error if the field is not defined in the schema.
  26693. func (m *TokenMutation) ResetField(name string) error {
  26694. switch name {
  26695. case token.FieldCreatedAt:
  26696. m.ResetCreatedAt()
  26697. return nil
  26698. case token.FieldUpdatedAt:
  26699. m.ResetUpdatedAt()
  26700. return nil
  26701. case token.FieldDeletedAt:
  26702. m.ResetDeletedAt()
  26703. return nil
  26704. case token.FieldExpireAt:
  26705. m.ResetExpireAt()
  26706. return nil
  26707. case token.FieldToken:
  26708. m.ResetToken()
  26709. return nil
  26710. case token.FieldMAC:
  26711. m.ResetMAC()
  26712. return nil
  26713. case token.FieldOrganizationID:
  26714. m.ResetOrganizationID()
  26715. return nil
  26716. case token.FieldAgentID:
  26717. m.ResetAgentID()
  26718. return nil
  26719. case token.FieldCustomAgentBase:
  26720. m.ResetCustomAgentBase()
  26721. return nil
  26722. case token.FieldCustomAgentKey:
  26723. m.ResetCustomAgentKey()
  26724. return nil
  26725. case token.FieldOpenaiBase:
  26726. m.ResetOpenaiBase()
  26727. return nil
  26728. case token.FieldOpenaiKey:
  26729. m.ResetOpenaiKey()
  26730. return nil
  26731. }
  26732. return fmt.Errorf("unknown Token field %s", name)
  26733. }
  26734. // AddedEdges returns all edge names that were set/added in this mutation.
  26735. func (m *TokenMutation) AddedEdges() []string {
  26736. edges := make([]string, 0, 1)
  26737. if m.agent != nil {
  26738. edges = append(edges, token.EdgeAgent)
  26739. }
  26740. return edges
  26741. }
  26742. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  26743. // name in this mutation.
  26744. func (m *TokenMutation) AddedIDs(name string) []ent.Value {
  26745. switch name {
  26746. case token.EdgeAgent:
  26747. if id := m.agent; id != nil {
  26748. return []ent.Value{*id}
  26749. }
  26750. }
  26751. return nil
  26752. }
  26753. // RemovedEdges returns all edge names that were removed in this mutation.
  26754. func (m *TokenMutation) RemovedEdges() []string {
  26755. edges := make([]string, 0, 1)
  26756. return edges
  26757. }
  26758. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  26759. // the given name in this mutation.
  26760. func (m *TokenMutation) RemovedIDs(name string) []ent.Value {
  26761. return nil
  26762. }
  26763. // ClearedEdges returns all edge names that were cleared in this mutation.
  26764. func (m *TokenMutation) ClearedEdges() []string {
  26765. edges := make([]string, 0, 1)
  26766. if m.clearedagent {
  26767. edges = append(edges, token.EdgeAgent)
  26768. }
  26769. return edges
  26770. }
  26771. // EdgeCleared returns a boolean which indicates if the edge with the given name
  26772. // was cleared in this mutation.
  26773. func (m *TokenMutation) EdgeCleared(name string) bool {
  26774. switch name {
  26775. case token.EdgeAgent:
  26776. return m.clearedagent
  26777. }
  26778. return false
  26779. }
  26780. // ClearEdge clears the value of the edge with the given name. It returns an error
  26781. // if that edge is not defined in the schema.
  26782. func (m *TokenMutation) ClearEdge(name string) error {
  26783. switch name {
  26784. case token.EdgeAgent:
  26785. m.ClearAgent()
  26786. return nil
  26787. }
  26788. return fmt.Errorf("unknown Token unique edge %s", name)
  26789. }
  26790. // ResetEdge resets all changes to the edge with the given name in this mutation.
  26791. // It returns an error if the edge is not defined in the schema.
  26792. func (m *TokenMutation) ResetEdge(name string) error {
  26793. switch name {
  26794. case token.EdgeAgent:
  26795. m.ResetAgent()
  26796. return nil
  26797. }
  26798. return fmt.Errorf("unknown Token edge %s", name)
  26799. }
  26800. // TutorialMutation represents an operation that mutates the Tutorial nodes in the graph.
  26801. type TutorialMutation struct {
  26802. config
  26803. op Op
  26804. typ string
  26805. id *uint64
  26806. created_at *time.Time
  26807. updated_at *time.Time
  26808. deleted_at *time.Time
  26809. index *int
  26810. addindex *int
  26811. title *string
  26812. content *string
  26813. organization_id *uint64
  26814. addorganization_id *int64
  26815. clearedFields map[string]struct{}
  26816. employee *uint64
  26817. clearedemployee bool
  26818. done bool
  26819. oldValue func(context.Context) (*Tutorial, error)
  26820. predicates []predicate.Tutorial
  26821. }
  26822. var _ ent.Mutation = (*TutorialMutation)(nil)
  26823. // tutorialOption allows management of the mutation configuration using functional options.
  26824. type tutorialOption func(*TutorialMutation)
  26825. // newTutorialMutation creates new mutation for the Tutorial entity.
  26826. func newTutorialMutation(c config, op Op, opts ...tutorialOption) *TutorialMutation {
  26827. m := &TutorialMutation{
  26828. config: c,
  26829. op: op,
  26830. typ: TypeTutorial,
  26831. clearedFields: make(map[string]struct{}),
  26832. }
  26833. for _, opt := range opts {
  26834. opt(m)
  26835. }
  26836. return m
  26837. }
  26838. // withTutorialID sets the ID field of the mutation.
  26839. func withTutorialID(id uint64) tutorialOption {
  26840. return func(m *TutorialMutation) {
  26841. var (
  26842. err error
  26843. once sync.Once
  26844. value *Tutorial
  26845. )
  26846. m.oldValue = func(ctx context.Context) (*Tutorial, error) {
  26847. once.Do(func() {
  26848. if m.done {
  26849. err = errors.New("querying old values post mutation is not allowed")
  26850. } else {
  26851. value, err = m.Client().Tutorial.Get(ctx, id)
  26852. }
  26853. })
  26854. return value, err
  26855. }
  26856. m.id = &id
  26857. }
  26858. }
  26859. // withTutorial sets the old Tutorial of the mutation.
  26860. func withTutorial(node *Tutorial) tutorialOption {
  26861. return func(m *TutorialMutation) {
  26862. m.oldValue = func(context.Context) (*Tutorial, error) {
  26863. return node, nil
  26864. }
  26865. m.id = &node.ID
  26866. }
  26867. }
  26868. // Client returns a new `ent.Client` from the mutation. If the mutation was
  26869. // executed in a transaction (ent.Tx), a transactional client is returned.
  26870. func (m TutorialMutation) Client() *Client {
  26871. client := &Client{config: m.config}
  26872. client.init()
  26873. return client
  26874. }
  26875. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  26876. // it returns an error otherwise.
  26877. func (m TutorialMutation) Tx() (*Tx, error) {
  26878. if _, ok := m.driver.(*txDriver); !ok {
  26879. return nil, errors.New("ent: mutation is not running in a transaction")
  26880. }
  26881. tx := &Tx{config: m.config}
  26882. tx.init()
  26883. return tx, nil
  26884. }
  26885. // SetID sets the value of the id field. Note that this
  26886. // operation is only accepted on creation of Tutorial entities.
  26887. func (m *TutorialMutation) SetID(id uint64) {
  26888. m.id = &id
  26889. }
  26890. // ID returns the ID value in the mutation. Note that the ID is only available
  26891. // if it was provided to the builder or after it was returned from the database.
  26892. func (m *TutorialMutation) ID() (id uint64, exists bool) {
  26893. if m.id == nil {
  26894. return
  26895. }
  26896. return *m.id, true
  26897. }
  26898. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  26899. // That means, if the mutation is applied within a transaction with an isolation level such
  26900. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  26901. // or updated by the mutation.
  26902. func (m *TutorialMutation) IDs(ctx context.Context) ([]uint64, error) {
  26903. switch {
  26904. case m.op.Is(OpUpdateOne | OpDeleteOne):
  26905. id, exists := m.ID()
  26906. if exists {
  26907. return []uint64{id}, nil
  26908. }
  26909. fallthrough
  26910. case m.op.Is(OpUpdate | OpDelete):
  26911. return m.Client().Tutorial.Query().Where(m.predicates...).IDs(ctx)
  26912. default:
  26913. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  26914. }
  26915. }
  26916. // SetCreatedAt sets the "created_at" field.
  26917. func (m *TutorialMutation) SetCreatedAt(t time.Time) {
  26918. m.created_at = &t
  26919. }
  26920. // CreatedAt returns the value of the "created_at" field in the mutation.
  26921. func (m *TutorialMutation) CreatedAt() (r time.Time, exists bool) {
  26922. v := m.created_at
  26923. if v == nil {
  26924. return
  26925. }
  26926. return *v, true
  26927. }
  26928. // OldCreatedAt returns the old "created_at" field's value of the Tutorial entity.
  26929. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  26930. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26931. func (m *TutorialMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  26932. if !m.op.Is(OpUpdateOne) {
  26933. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  26934. }
  26935. if m.id == nil || m.oldValue == nil {
  26936. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  26937. }
  26938. oldValue, err := m.oldValue(ctx)
  26939. if err != nil {
  26940. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  26941. }
  26942. return oldValue.CreatedAt, nil
  26943. }
  26944. // ResetCreatedAt resets all changes to the "created_at" field.
  26945. func (m *TutorialMutation) ResetCreatedAt() {
  26946. m.created_at = nil
  26947. }
  26948. // SetUpdatedAt sets the "updated_at" field.
  26949. func (m *TutorialMutation) SetUpdatedAt(t time.Time) {
  26950. m.updated_at = &t
  26951. }
  26952. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  26953. func (m *TutorialMutation) UpdatedAt() (r time.Time, exists bool) {
  26954. v := m.updated_at
  26955. if v == nil {
  26956. return
  26957. }
  26958. return *v, true
  26959. }
  26960. // OldUpdatedAt returns the old "updated_at" field's value of the Tutorial entity.
  26961. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  26962. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26963. func (m *TutorialMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  26964. if !m.op.Is(OpUpdateOne) {
  26965. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  26966. }
  26967. if m.id == nil || m.oldValue == nil {
  26968. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  26969. }
  26970. oldValue, err := m.oldValue(ctx)
  26971. if err != nil {
  26972. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  26973. }
  26974. return oldValue.UpdatedAt, nil
  26975. }
  26976. // ResetUpdatedAt resets all changes to the "updated_at" field.
  26977. func (m *TutorialMutation) ResetUpdatedAt() {
  26978. m.updated_at = nil
  26979. }
  26980. // SetDeletedAt sets the "deleted_at" field.
  26981. func (m *TutorialMutation) SetDeletedAt(t time.Time) {
  26982. m.deleted_at = &t
  26983. }
  26984. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  26985. func (m *TutorialMutation) DeletedAt() (r time.Time, exists bool) {
  26986. v := m.deleted_at
  26987. if v == nil {
  26988. return
  26989. }
  26990. return *v, true
  26991. }
  26992. // OldDeletedAt returns the old "deleted_at" field's value of the Tutorial entity.
  26993. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  26994. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26995. func (m *TutorialMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  26996. if !m.op.Is(OpUpdateOne) {
  26997. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  26998. }
  26999. if m.id == nil || m.oldValue == nil {
  27000. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  27001. }
  27002. oldValue, err := m.oldValue(ctx)
  27003. if err != nil {
  27004. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  27005. }
  27006. return oldValue.DeletedAt, nil
  27007. }
  27008. // ClearDeletedAt clears the value of the "deleted_at" field.
  27009. func (m *TutorialMutation) ClearDeletedAt() {
  27010. m.deleted_at = nil
  27011. m.clearedFields[tutorial.FieldDeletedAt] = struct{}{}
  27012. }
  27013. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  27014. func (m *TutorialMutation) DeletedAtCleared() bool {
  27015. _, ok := m.clearedFields[tutorial.FieldDeletedAt]
  27016. return ok
  27017. }
  27018. // ResetDeletedAt resets all changes to the "deleted_at" field.
  27019. func (m *TutorialMutation) ResetDeletedAt() {
  27020. m.deleted_at = nil
  27021. delete(m.clearedFields, tutorial.FieldDeletedAt)
  27022. }
  27023. // SetEmployeeID sets the "employee_id" field.
  27024. func (m *TutorialMutation) SetEmployeeID(u uint64) {
  27025. m.employee = &u
  27026. }
  27027. // EmployeeID returns the value of the "employee_id" field in the mutation.
  27028. func (m *TutorialMutation) EmployeeID() (r uint64, exists bool) {
  27029. v := m.employee
  27030. if v == nil {
  27031. return
  27032. }
  27033. return *v, true
  27034. }
  27035. // OldEmployeeID returns the old "employee_id" field's value of the Tutorial entity.
  27036. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  27037. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27038. func (m *TutorialMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  27039. if !m.op.Is(OpUpdateOne) {
  27040. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  27041. }
  27042. if m.id == nil || m.oldValue == nil {
  27043. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  27044. }
  27045. oldValue, err := m.oldValue(ctx)
  27046. if err != nil {
  27047. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  27048. }
  27049. return oldValue.EmployeeID, nil
  27050. }
  27051. // ResetEmployeeID resets all changes to the "employee_id" field.
  27052. func (m *TutorialMutation) ResetEmployeeID() {
  27053. m.employee = nil
  27054. }
  27055. // SetIndex sets the "index" field.
  27056. func (m *TutorialMutation) SetIndex(i int) {
  27057. m.index = &i
  27058. m.addindex = nil
  27059. }
  27060. // Index returns the value of the "index" field in the mutation.
  27061. func (m *TutorialMutation) Index() (r int, exists bool) {
  27062. v := m.index
  27063. if v == nil {
  27064. return
  27065. }
  27066. return *v, true
  27067. }
  27068. // OldIndex returns the old "index" field's value of the Tutorial entity.
  27069. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  27070. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27071. func (m *TutorialMutation) OldIndex(ctx context.Context) (v int, err error) {
  27072. if !m.op.Is(OpUpdateOne) {
  27073. return v, errors.New("OldIndex is only allowed on UpdateOne operations")
  27074. }
  27075. if m.id == nil || m.oldValue == nil {
  27076. return v, errors.New("OldIndex requires an ID field in the mutation")
  27077. }
  27078. oldValue, err := m.oldValue(ctx)
  27079. if err != nil {
  27080. return v, fmt.Errorf("querying old value for OldIndex: %w", err)
  27081. }
  27082. return oldValue.Index, nil
  27083. }
  27084. // AddIndex adds i to the "index" field.
  27085. func (m *TutorialMutation) AddIndex(i int) {
  27086. if m.addindex != nil {
  27087. *m.addindex += i
  27088. } else {
  27089. m.addindex = &i
  27090. }
  27091. }
  27092. // AddedIndex returns the value that was added to the "index" field in this mutation.
  27093. func (m *TutorialMutation) AddedIndex() (r int, exists bool) {
  27094. v := m.addindex
  27095. if v == nil {
  27096. return
  27097. }
  27098. return *v, true
  27099. }
  27100. // ResetIndex resets all changes to the "index" field.
  27101. func (m *TutorialMutation) ResetIndex() {
  27102. m.index = nil
  27103. m.addindex = nil
  27104. }
  27105. // SetTitle sets the "title" field.
  27106. func (m *TutorialMutation) SetTitle(s string) {
  27107. m.title = &s
  27108. }
  27109. // Title returns the value of the "title" field in the mutation.
  27110. func (m *TutorialMutation) Title() (r string, exists bool) {
  27111. v := m.title
  27112. if v == nil {
  27113. return
  27114. }
  27115. return *v, true
  27116. }
  27117. // OldTitle returns the old "title" field's value of the Tutorial entity.
  27118. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  27119. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27120. func (m *TutorialMutation) OldTitle(ctx context.Context) (v string, err error) {
  27121. if !m.op.Is(OpUpdateOne) {
  27122. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  27123. }
  27124. if m.id == nil || m.oldValue == nil {
  27125. return v, errors.New("OldTitle requires an ID field in the mutation")
  27126. }
  27127. oldValue, err := m.oldValue(ctx)
  27128. if err != nil {
  27129. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  27130. }
  27131. return oldValue.Title, nil
  27132. }
  27133. // ResetTitle resets all changes to the "title" field.
  27134. func (m *TutorialMutation) ResetTitle() {
  27135. m.title = nil
  27136. }
  27137. // SetContent sets the "content" field.
  27138. func (m *TutorialMutation) SetContent(s string) {
  27139. m.content = &s
  27140. }
  27141. // Content returns the value of the "content" field in the mutation.
  27142. func (m *TutorialMutation) Content() (r string, exists bool) {
  27143. v := m.content
  27144. if v == nil {
  27145. return
  27146. }
  27147. return *v, true
  27148. }
  27149. // OldContent returns the old "content" field's value of the Tutorial entity.
  27150. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  27151. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27152. func (m *TutorialMutation) OldContent(ctx context.Context) (v string, err error) {
  27153. if !m.op.Is(OpUpdateOne) {
  27154. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  27155. }
  27156. if m.id == nil || m.oldValue == nil {
  27157. return v, errors.New("OldContent requires an ID field in the mutation")
  27158. }
  27159. oldValue, err := m.oldValue(ctx)
  27160. if err != nil {
  27161. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  27162. }
  27163. return oldValue.Content, nil
  27164. }
  27165. // ResetContent resets all changes to the "content" field.
  27166. func (m *TutorialMutation) ResetContent() {
  27167. m.content = nil
  27168. }
  27169. // SetOrganizationID sets the "organization_id" field.
  27170. func (m *TutorialMutation) SetOrganizationID(u uint64) {
  27171. m.organization_id = &u
  27172. m.addorganization_id = nil
  27173. }
  27174. // OrganizationID returns the value of the "organization_id" field in the mutation.
  27175. func (m *TutorialMutation) OrganizationID() (r uint64, exists bool) {
  27176. v := m.organization_id
  27177. if v == nil {
  27178. return
  27179. }
  27180. return *v, true
  27181. }
  27182. // OldOrganizationID returns the old "organization_id" field's value of the Tutorial entity.
  27183. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  27184. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27185. func (m *TutorialMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  27186. if !m.op.Is(OpUpdateOne) {
  27187. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  27188. }
  27189. if m.id == nil || m.oldValue == nil {
  27190. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  27191. }
  27192. oldValue, err := m.oldValue(ctx)
  27193. if err != nil {
  27194. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  27195. }
  27196. return oldValue.OrganizationID, nil
  27197. }
  27198. // AddOrganizationID adds u to the "organization_id" field.
  27199. func (m *TutorialMutation) AddOrganizationID(u int64) {
  27200. if m.addorganization_id != nil {
  27201. *m.addorganization_id += u
  27202. } else {
  27203. m.addorganization_id = &u
  27204. }
  27205. }
  27206. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  27207. func (m *TutorialMutation) AddedOrganizationID() (r int64, exists bool) {
  27208. v := m.addorganization_id
  27209. if v == nil {
  27210. return
  27211. }
  27212. return *v, true
  27213. }
  27214. // ResetOrganizationID resets all changes to the "organization_id" field.
  27215. func (m *TutorialMutation) ResetOrganizationID() {
  27216. m.organization_id = nil
  27217. m.addorganization_id = nil
  27218. }
  27219. // ClearEmployee clears the "employee" edge to the Employee entity.
  27220. func (m *TutorialMutation) ClearEmployee() {
  27221. m.clearedemployee = true
  27222. m.clearedFields[tutorial.FieldEmployeeID] = struct{}{}
  27223. }
  27224. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  27225. func (m *TutorialMutation) EmployeeCleared() bool {
  27226. return m.clearedemployee
  27227. }
  27228. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  27229. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  27230. // EmployeeID instead. It exists only for internal usage by the builders.
  27231. func (m *TutorialMutation) EmployeeIDs() (ids []uint64) {
  27232. if id := m.employee; id != nil {
  27233. ids = append(ids, *id)
  27234. }
  27235. return
  27236. }
  27237. // ResetEmployee resets all changes to the "employee" edge.
  27238. func (m *TutorialMutation) ResetEmployee() {
  27239. m.employee = nil
  27240. m.clearedemployee = false
  27241. }
  27242. // Where appends a list predicates to the TutorialMutation builder.
  27243. func (m *TutorialMutation) Where(ps ...predicate.Tutorial) {
  27244. m.predicates = append(m.predicates, ps...)
  27245. }
  27246. // WhereP appends storage-level predicates to the TutorialMutation builder. Using this method,
  27247. // users can use type-assertion to append predicates that do not depend on any generated package.
  27248. func (m *TutorialMutation) WhereP(ps ...func(*sql.Selector)) {
  27249. p := make([]predicate.Tutorial, len(ps))
  27250. for i := range ps {
  27251. p[i] = ps[i]
  27252. }
  27253. m.Where(p...)
  27254. }
  27255. // Op returns the operation name.
  27256. func (m *TutorialMutation) Op() Op {
  27257. return m.op
  27258. }
  27259. // SetOp allows setting the mutation operation.
  27260. func (m *TutorialMutation) SetOp(op Op) {
  27261. m.op = op
  27262. }
  27263. // Type returns the node type of this mutation (Tutorial).
  27264. func (m *TutorialMutation) Type() string {
  27265. return m.typ
  27266. }
  27267. // Fields returns all fields that were changed during this mutation. Note that in
  27268. // order to get all numeric fields that were incremented/decremented, call
  27269. // AddedFields().
  27270. func (m *TutorialMutation) Fields() []string {
  27271. fields := make([]string, 0, 8)
  27272. if m.created_at != nil {
  27273. fields = append(fields, tutorial.FieldCreatedAt)
  27274. }
  27275. if m.updated_at != nil {
  27276. fields = append(fields, tutorial.FieldUpdatedAt)
  27277. }
  27278. if m.deleted_at != nil {
  27279. fields = append(fields, tutorial.FieldDeletedAt)
  27280. }
  27281. if m.employee != nil {
  27282. fields = append(fields, tutorial.FieldEmployeeID)
  27283. }
  27284. if m.index != nil {
  27285. fields = append(fields, tutorial.FieldIndex)
  27286. }
  27287. if m.title != nil {
  27288. fields = append(fields, tutorial.FieldTitle)
  27289. }
  27290. if m.content != nil {
  27291. fields = append(fields, tutorial.FieldContent)
  27292. }
  27293. if m.organization_id != nil {
  27294. fields = append(fields, tutorial.FieldOrganizationID)
  27295. }
  27296. return fields
  27297. }
  27298. // Field returns the value of a field with the given name. The second boolean
  27299. // return value indicates that this field was not set, or was not defined in the
  27300. // schema.
  27301. func (m *TutorialMutation) Field(name string) (ent.Value, bool) {
  27302. switch name {
  27303. case tutorial.FieldCreatedAt:
  27304. return m.CreatedAt()
  27305. case tutorial.FieldUpdatedAt:
  27306. return m.UpdatedAt()
  27307. case tutorial.FieldDeletedAt:
  27308. return m.DeletedAt()
  27309. case tutorial.FieldEmployeeID:
  27310. return m.EmployeeID()
  27311. case tutorial.FieldIndex:
  27312. return m.Index()
  27313. case tutorial.FieldTitle:
  27314. return m.Title()
  27315. case tutorial.FieldContent:
  27316. return m.Content()
  27317. case tutorial.FieldOrganizationID:
  27318. return m.OrganizationID()
  27319. }
  27320. return nil, false
  27321. }
  27322. // OldField returns the old value of the field from the database. An error is
  27323. // returned if the mutation operation is not UpdateOne, or the query to the
  27324. // database failed.
  27325. func (m *TutorialMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  27326. switch name {
  27327. case tutorial.FieldCreatedAt:
  27328. return m.OldCreatedAt(ctx)
  27329. case tutorial.FieldUpdatedAt:
  27330. return m.OldUpdatedAt(ctx)
  27331. case tutorial.FieldDeletedAt:
  27332. return m.OldDeletedAt(ctx)
  27333. case tutorial.FieldEmployeeID:
  27334. return m.OldEmployeeID(ctx)
  27335. case tutorial.FieldIndex:
  27336. return m.OldIndex(ctx)
  27337. case tutorial.FieldTitle:
  27338. return m.OldTitle(ctx)
  27339. case tutorial.FieldContent:
  27340. return m.OldContent(ctx)
  27341. case tutorial.FieldOrganizationID:
  27342. return m.OldOrganizationID(ctx)
  27343. }
  27344. return nil, fmt.Errorf("unknown Tutorial field %s", name)
  27345. }
  27346. // SetField sets the value of a field with the given name. It returns an error if
  27347. // the field is not defined in the schema, or if the type mismatched the field
  27348. // type.
  27349. func (m *TutorialMutation) SetField(name string, value ent.Value) error {
  27350. switch name {
  27351. case tutorial.FieldCreatedAt:
  27352. v, ok := value.(time.Time)
  27353. if !ok {
  27354. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27355. }
  27356. m.SetCreatedAt(v)
  27357. return nil
  27358. case tutorial.FieldUpdatedAt:
  27359. v, ok := value.(time.Time)
  27360. if !ok {
  27361. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27362. }
  27363. m.SetUpdatedAt(v)
  27364. return nil
  27365. case tutorial.FieldDeletedAt:
  27366. v, ok := value.(time.Time)
  27367. if !ok {
  27368. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27369. }
  27370. m.SetDeletedAt(v)
  27371. return nil
  27372. case tutorial.FieldEmployeeID:
  27373. v, ok := value.(uint64)
  27374. if !ok {
  27375. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27376. }
  27377. m.SetEmployeeID(v)
  27378. return nil
  27379. case tutorial.FieldIndex:
  27380. v, ok := value.(int)
  27381. if !ok {
  27382. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27383. }
  27384. m.SetIndex(v)
  27385. return nil
  27386. case tutorial.FieldTitle:
  27387. v, ok := value.(string)
  27388. if !ok {
  27389. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27390. }
  27391. m.SetTitle(v)
  27392. return nil
  27393. case tutorial.FieldContent:
  27394. v, ok := value.(string)
  27395. if !ok {
  27396. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27397. }
  27398. m.SetContent(v)
  27399. return nil
  27400. case tutorial.FieldOrganizationID:
  27401. v, ok := value.(uint64)
  27402. if !ok {
  27403. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27404. }
  27405. m.SetOrganizationID(v)
  27406. return nil
  27407. }
  27408. return fmt.Errorf("unknown Tutorial field %s", name)
  27409. }
  27410. // AddedFields returns all numeric fields that were incremented/decremented during
  27411. // this mutation.
  27412. func (m *TutorialMutation) AddedFields() []string {
  27413. var fields []string
  27414. if m.addindex != nil {
  27415. fields = append(fields, tutorial.FieldIndex)
  27416. }
  27417. if m.addorganization_id != nil {
  27418. fields = append(fields, tutorial.FieldOrganizationID)
  27419. }
  27420. return fields
  27421. }
  27422. // AddedField returns the numeric value that was incremented/decremented on a field
  27423. // with the given name. The second boolean return value indicates that this field
  27424. // was not set, or was not defined in the schema.
  27425. func (m *TutorialMutation) AddedField(name string) (ent.Value, bool) {
  27426. switch name {
  27427. case tutorial.FieldIndex:
  27428. return m.AddedIndex()
  27429. case tutorial.FieldOrganizationID:
  27430. return m.AddedOrganizationID()
  27431. }
  27432. return nil, false
  27433. }
  27434. // AddField adds the value to the field with the given name. It returns an error if
  27435. // the field is not defined in the schema, or if the type mismatched the field
  27436. // type.
  27437. func (m *TutorialMutation) AddField(name string, value ent.Value) error {
  27438. switch name {
  27439. case tutorial.FieldIndex:
  27440. v, ok := value.(int)
  27441. if !ok {
  27442. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27443. }
  27444. m.AddIndex(v)
  27445. return nil
  27446. case tutorial.FieldOrganizationID:
  27447. v, ok := value.(int64)
  27448. if !ok {
  27449. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27450. }
  27451. m.AddOrganizationID(v)
  27452. return nil
  27453. }
  27454. return fmt.Errorf("unknown Tutorial numeric field %s", name)
  27455. }
  27456. // ClearedFields returns all nullable fields that were cleared during this
  27457. // mutation.
  27458. func (m *TutorialMutation) ClearedFields() []string {
  27459. var fields []string
  27460. if m.FieldCleared(tutorial.FieldDeletedAt) {
  27461. fields = append(fields, tutorial.FieldDeletedAt)
  27462. }
  27463. return fields
  27464. }
  27465. // FieldCleared returns a boolean indicating if a field with the given name was
  27466. // cleared in this mutation.
  27467. func (m *TutorialMutation) FieldCleared(name string) bool {
  27468. _, ok := m.clearedFields[name]
  27469. return ok
  27470. }
  27471. // ClearField clears the value of the field with the given name. It returns an
  27472. // error if the field is not defined in the schema.
  27473. func (m *TutorialMutation) ClearField(name string) error {
  27474. switch name {
  27475. case tutorial.FieldDeletedAt:
  27476. m.ClearDeletedAt()
  27477. return nil
  27478. }
  27479. return fmt.Errorf("unknown Tutorial nullable field %s", name)
  27480. }
  27481. // ResetField resets all changes in the mutation for the field with the given name.
  27482. // It returns an error if the field is not defined in the schema.
  27483. func (m *TutorialMutation) ResetField(name string) error {
  27484. switch name {
  27485. case tutorial.FieldCreatedAt:
  27486. m.ResetCreatedAt()
  27487. return nil
  27488. case tutorial.FieldUpdatedAt:
  27489. m.ResetUpdatedAt()
  27490. return nil
  27491. case tutorial.FieldDeletedAt:
  27492. m.ResetDeletedAt()
  27493. return nil
  27494. case tutorial.FieldEmployeeID:
  27495. m.ResetEmployeeID()
  27496. return nil
  27497. case tutorial.FieldIndex:
  27498. m.ResetIndex()
  27499. return nil
  27500. case tutorial.FieldTitle:
  27501. m.ResetTitle()
  27502. return nil
  27503. case tutorial.FieldContent:
  27504. m.ResetContent()
  27505. return nil
  27506. case tutorial.FieldOrganizationID:
  27507. m.ResetOrganizationID()
  27508. return nil
  27509. }
  27510. return fmt.Errorf("unknown Tutorial field %s", name)
  27511. }
  27512. // AddedEdges returns all edge names that were set/added in this mutation.
  27513. func (m *TutorialMutation) AddedEdges() []string {
  27514. edges := make([]string, 0, 1)
  27515. if m.employee != nil {
  27516. edges = append(edges, tutorial.EdgeEmployee)
  27517. }
  27518. return edges
  27519. }
  27520. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  27521. // name in this mutation.
  27522. func (m *TutorialMutation) AddedIDs(name string) []ent.Value {
  27523. switch name {
  27524. case tutorial.EdgeEmployee:
  27525. if id := m.employee; id != nil {
  27526. return []ent.Value{*id}
  27527. }
  27528. }
  27529. return nil
  27530. }
  27531. // RemovedEdges returns all edge names that were removed in this mutation.
  27532. func (m *TutorialMutation) RemovedEdges() []string {
  27533. edges := make([]string, 0, 1)
  27534. return edges
  27535. }
  27536. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  27537. // the given name in this mutation.
  27538. func (m *TutorialMutation) RemovedIDs(name string) []ent.Value {
  27539. return nil
  27540. }
  27541. // ClearedEdges returns all edge names that were cleared in this mutation.
  27542. func (m *TutorialMutation) ClearedEdges() []string {
  27543. edges := make([]string, 0, 1)
  27544. if m.clearedemployee {
  27545. edges = append(edges, tutorial.EdgeEmployee)
  27546. }
  27547. return edges
  27548. }
  27549. // EdgeCleared returns a boolean which indicates if the edge with the given name
  27550. // was cleared in this mutation.
  27551. func (m *TutorialMutation) EdgeCleared(name string) bool {
  27552. switch name {
  27553. case tutorial.EdgeEmployee:
  27554. return m.clearedemployee
  27555. }
  27556. return false
  27557. }
  27558. // ClearEdge clears the value of the edge with the given name. It returns an error
  27559. // if that edge is not defined in the schema.
  27560. func (m *TutorialMutation) ClearEdge(name string) error {
  27561. switch name {
  27562. case tutorial.EdgeEmployee:
  27563. m.ClearEmployee()
  27564. return nil
  27565. }
  27566. return fmt.Errorf("unknown Tutorial unique edge %s", name)
  27567. }
  27568. // ResetEdge resets all changes to the edge with the given name in this mutation.
  27569. // It returns an error if the edge is not defined in the schema.
  27570. func (m *TutorialMutation) ResetEdge(name string) error {
  27571. switch name {
  27572. case tutorial.EdgeEmployee:
  27573. m.ResetEmployee()
  27574. return nil
  27575. }
  27576. return fmt.Errorf("unknown Tutorial edge %s", name)
  27577. }
  27578. // UsageDetailMutation represents an operation that mutates the UsageDetail nodes in the graph.
  27579. type UsageDetailMutation struct {
  27580. config
  27581. op Op
  27582. typ string
  27583. id *uint64
  27584. created_at *time.Time
  27585. updated_at *time.Time
  27586. status *uint8
  27587. addstatus *int8
  27588. _type *int
  27589. add_type *int
  27590. bot_id *string
  27591. receiver_id *string
  27592. app *int
  27593. addapp *int
  27594. session_id *uint64
  27595. addsession_id *int64
  27596. request *string
  27597. response *string
  27598. original_data *custom_types.OriginalData
  27599. total_tokens *uint64
  27600. addtotal_tokens *int64
  27601. prompt_tokens *uint64
  27602. addprompt_tokens *int64
  27603. completion_tokens *uint64
  27604. addcompletion_tokens *int64
  27605. organization_id *uint64
  27606. addorganization_id *int64
  27607. clearedFields map[string]struct{}
  27608. done bool
  27609. oldValue func(context.Context) (*UsageDetail, error)
  27610. predicates []predicate.UsageDetail
  27611. }
  27612. var _ ent.Mutation = (*UsageDetailMutation)(nil)
  27613. // usagedetailOption allows management of the mutation configuration using functional options.
  27614. type usagedetailOption func(*UsageDetailMutation)
  27615. // newUsageDetailMutation creates new mutation for the UsageDetail entity.
  27616. func newUsageDetailMutation(c config, op Op, opts ...usagedetailOption) *UsageDetailMutation {
  27617. m := &UsageDetailMutation{
  27618. config: c,
  27619. op: op,
  27620. typ: TypeUsageDetail,
  27621. clearedFields: make(map[string]struct{}),
  27622. }
  27623. for _, opt := range opts {
  27624. opt(m)
  27625. }
  27626. return m
  27627. }
  27628. // withUsageDetailID sets the ID field of the mutation.
  27629. func withUsageDetailID(id uint64) usagedetailOption {
  27630. return func(m *UsageDetailMutation) {
  27631. var (
  27632. err error
  27633. once sync.Once
  27634. value *UsageDetail
  27635. )
  27636. m.oldValue = func(ctx context.Context) (*UsageDetail, error) {
  27637. once.Do(func() {
  27638. if m.done {
  27639. err = errors.New("querying old values post mutation is not allowed")
  27640. } else {
  27641. value, err = m.Client().UsageDetail.Get(ctx, id)
  27642. }
  27643. })
  27644. return value, err
  27645. }
  27646. m.id = &id
  27647. }
  27648. }
  27649. // withUsageDetail sets the old UsageDetail of the mutation.
  27650. func withUsageDetail(node *UsageDetail) usagedetailOption {
  27651. return func(m *UsageDetailMutation) {
  27652. m.oldValue = func(context.Context) (*UsageDetail, error) {
  27653. return node, nil
  27654. }
  27655. m.id = &node.ID
  27656. }
  27657. }
  27658. // Client returns a new `ent.Client` from the mutation. If the mutation was
  27659. // executed in a transaction (ent.Tx), a transactional client is returned.
  27660. func (m UsageDetailMutation) Client() *Client {
  27661. client := &Client{config: m.config}
  27662. client.init()
  27663. return client
  27664. }
  27665. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  27666. // it returns an error otherwise.
  27667. func (m UsageDetailMutation) Tx() (*Tx, error) {
  27668. if _, ok := m.driver.(*txDriver); !ok {
  27669. return nil, errors.New("ent: mutation is not running in a transaction")
  27670. }
  27671. tx := &Tx{config: m.config}
  27672. tx.init()
  27673. return tx, nil
  27674. }
  27675. // SetID sets the value of the id field. Note that this
  27676. // operation is only accepted on creation of UsageDetail entities.
  27677. func (m *UsageDetailMutation) SetID(id uint64) {
  27678. m.id = &id
  27679. }
  27680. // ID returns the ID value in the mutation. Note that the ID is only available
  27681. // if it was provided to the builder or after it was returned from the database.
  27682. func (m *UsageDetailMutation) ID() (id uint64, exists bool) {
  27683. if m.id == nil {
  27684. return
  27685. }
  27686. return *m.id, true
  27687. }
  27688. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  27689. // That means, if the mutation is applied within a transaction with an isolation level such
  27690. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  27691. // or updated by the mutation.
  27692. func (m *UsageDetailMutation) IDs(ctx context.Context) ([]uint64, error) {
  27693. switch {
  27694. case m.op.Is(OpUpdateOne | OpDeleteOne):
  27695. id, exists := m.ID()
  27696. if exists {
  27697. return []uint64{id}, nil
  27698. }
  27699. fallthrough
  27700. case m.op.Is(OpUpdate | OpDelete):
  27701. return m.Client().UsageDetail.Query().Where(m.predicates...).IDs(ctx)
  27702. default:
  27703. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  27704. }
  27705. }
  27706. // SetCreatedAt sets the "created_at" field.
  27707. func (m *UsageDetailMutation) SetCreatedAt(t time.Time) {
  27708. m.created_at = &t
  27709. }
  27710. // CreatedAt returns the value of the "created_at" field in the mutation.
  27711. func (m *UsageDetailMutation) CreatedAt() (r time.Time, exists bool) {
  27712. v := m.created_at
  27713. if v == nil {
  27714. return
  27715. }
  27716. return *v, true
  27717. }
  27718. // OldCreatedAt returns the old "created_at" field's value of the UsageDetail entity.
  27719. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27720. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27721. func (m *UsageDetailMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  27722. if !m.op.Is(OpUpdateOne) {
  27723. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  27724. }
  27725. if m.id == nil || m.oldValue == nil {
  27726. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  27727. }
  27728. oldValue, err := m.oldValue(ctx)
  27729. if err != nil {
  27730. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  27731. }
  27732. return oldValue.CreatedAt, nil
  27733. }
  27734. // ResetCreatedAt resets all changes to the "created_at" field.
  27735. func (m *UsageDetailMutation) ResetCreatedAt() {
  27736. m.created_at = nil
  27737. }
  27738. // SetUpdatedAt sets the "updated_at" field.
  27739. func (m *UsageDetailMutation) SetUpdatedAt(t time.Time) {
  27740. m.updated_at = &t
  27741. }
  27742. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  27743. func (m *UsageDetailMutation) UpdatedAt() (r time.Time, exists bool) {
  27744. v := m.updated_at
  27745. if v == nil {
  27746. return
  27747. }
  27748. return *v, true
  27749. }
  27750. // OldUpdatedAt returns the old "updated_at" field's value of the UsageDetail entity.
  27751. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27752. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27753. func (m *UsageDetailMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  27754. if !m.op.Is(OpUpdateOne) {
  27755. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  27756. }
  27757. if m.id == nil || m.oldValue == nil {
  27758. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  27759. }
  27760. oldValue, err := m.oldValue(ctx)
  27761. if err != nil {
  27762. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  27763. }
  27764. return oldValue.UpdatedAt, nil
  27765. }
  27766. // ResetUpdatedAt resets all changes to the "updated_at" field.
  27767. func (m *UsageDetailMutation) ResetUpdatedAt() {
  27768. m.updated_at = nil
  27769. }
  27770. // SetStatus sets the "status" field.
  27771. func (m *UsageDetailMutation) SetStatus(u uint8) {
  27772. m.status = &u
  27773. m.addstatus = nil
  27774. }
  27775. // Status returns the value of the "status" field in the mutation.
  27776. func (m *UsageDetailMutation) Status() (r uint8, exists bool) {
  27777. v := m.status
  27778. if v == nil {
  27779. return
  27780. }
  27781. return *v, true
  27782. }
  27783. // OldStatus returns the old "status" field's value of the UsageDetail entity.
  27784. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27785. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27786. func (m *UsageDetailMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  27787. if !m.op.Is(OpUpdateOne) {
  27788. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  27789. }
  27790. if m.id == nil || m.oldValue == nil {
  27791. return v, errors.New("OldStatus requires an ID field in the mutation")
  27792. }
  27793. oldValue, err := m.oldValue(ctx)
  27794. if err != nil {
  27795. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  27796. }
  27797. return oldValue.Status, nil
  27798. }
  27799. // AddStatus adds u to the "status" field.
  27800. func (m *UsageDetailMutation) AddStatus(u int8) {
  27801. if m.addstatus != nil {
  27802. *m.addstatus += u
  27803. } else {
  27804. m.addstatus = &u
  27805. }
  27806. }
  27807. // AddedStatus returns the value that was added to the "status" field in this mutation.
  27808. func (m *UsageDetailMutation) AddedStatus() (r int8, exists bool) {
  27809. v := m.addstatus
  27810. if v == nil {
  27811. return
  27812. }
  27813. return *v, true
  27814. }
  27815. // ClearStatus clears the value of the "status" field.
  27816. func (m *UsageDetailMutation) ClearStatus() {
  27817. m.status = nil
  27818. m.addstatus = nil
  27819. m.clearedFields[usagedetail.FieldStatus] = struct{}{}
  27820. }
  27821. // StatusCleared returns if the "status" field was cleared in this mutation.
  27822. func (m *UsageDetailMutation) StatusCleared() bool {
  27823. _, ok := m.clearedFields[usagedetail.FieldStatus]
  27824. return ok
  27825. }
  27826. // ResetStatus resets all changes to the "status" field.
  27827. func (m *UsageDetailMutation) ResetStatus() {
  27828. m.status = nil
  27829. m.addstatus = nil
  27830. delete(m.clearedFields, usagedetail.FieldStatus)
  27831. }
  27832. // SetType sets the "type" field.
  27833. func (m *UsageDetailMutation) SetType(i int) {
  27834. m._type = &i
  27835. m.add_type = nil
  27836. }
  27837. // GetType returns the value of the "type" field in the mutation.
  27838. func (m *UsageDetailMutation) GetType() (r int, exists bool) {
  27839. v := m._type
  27840. if v == nil {
  27841. return
  27842. }
  27843. return *v, true
  27844. }
  27845. // OldType returns the old "type" field's value of the UsageDetail entity.
  27846. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27847. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27848. func (m *UsageDetailMutation) OldType(ctx context.Context) (v int, err error) {
  27849. if !m.op.Is(OpUpdateOne) {
  27850. return v, errors.New("OldType is only allowed on UpdateOne operations")
  27851. }
  27852. if m.id == nil || m.oldValue == nil {
  27853. return v, errors.New("OldType requires an ID field in the mutation")
  27854. }
  27855. oldValue, err := m.oldValue(ctx)
  27856. if err != nil {
  27857. return v, fmt.Errorf("querying old value for OldType: %w", err)
  27858. }
  27859. return oldValue.Type, nil
  27860. }
  27861. // AddType adds i to the "type" field.
  27862. func (m *UsageDetailMutation) AddType(i int) {
  27863. if m.add_type != nil {
  27864. *m.add_type += i
  27865. } else {
  27866. m.add_type = &i
  27867. }
  27868. }
  27869. // AddedType returns the value that was added to the "type" field in this mutation.
  27870. func (m *UsageDetailMutation) AddedType() (r int, exists bool) {
  27871. v := m.add_type
  27872. if v == nil {
  27873. return
  27874. }
  27875. return *v, true
  27876. }
  27877. // ClearType clears the value of the "type" field.
  27878. func (m *UsageDetailMutation) ClearType() {
  27879. m._type = nil
  27880. m.add_type = nil
  27881. m.clearedFields[usagedetail.FieldType] = struct{}{}
  27882. }
  27883. // TypeCleared returns if the "type" field was cleared in this mutation.
  27884. func (m *UsageDetailMutation) TypeCleared() bool {
  27885. _, ok := m.clearedFields[usagedetail.FieldType]
  27886. return ok
  27887. }
  27888. // ResetType resets all changes to the "type" field.
  27889. func (m *UsageDetailMutation) ResetType() {
  27890. m._type = nil
  27891. m.add_type = nil
  27892. delete(m.clearedFields, usagedetail.FieldType)
  27893. }
  27894. // SetBotID sets the "bot_id" field.
  27895. func (m *UsageDetailMutation) SetBotID(s string) {
  27896. m.bot_id = &s
  27897. }
  27898. // BotID returns the value of the "bot_id" field in the mutation.
  27899. func (m *UsageDetailMutation) BotID() (r string, exists bool) {
  27900. v := m.bot_id
  27901. if v == nil {
  27902. return
  27903. }
  27904. return *v, true
  27905. }
  27906. // OldBotID returns the old "bot_id" field's value of the UsageDetail entity.
  27907. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27908. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27909. func (m *UsageDetailMutation) OldBotID(ctx context.Context) (v string, err error) {
  27910. if !m.op.Is(OpUpdateOne) {
  27911. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  27912. }
  27913. if m.id == nil || m.oldValue == nil {
  27914. return v, errors.New("OldBotID requires an ID field in the mutation")
  27915. }
  27916. oldValue, err := m.oldValue(ctx)
  27917. if err != nil {
  27918. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  27919. }
  27920. return oldValue.BotID, nil
  27921. }
  27922. // ResetBotID resets all changes to the "bot_id" field.
  27923. func (m *UsageDetailMutation) ResetBotID() {
  27924. m.bot_id = nil
  27925. }
  27926. // SetReceiverID sets the "receiver_id" field.
  27927. func (m *UsageDetailMutation) SetReceiverID(s string) {
  27928. m.receiver_id = &s
  27929. }
  27930. // ReceiverID returns the value of the "receiver_id" field in the mutation.
  27931. func (m *UsageDetailMutation) ReceiverID() (r string, exists bool) {
  27932. v := m.receiver_id
  27933. if v == nil {
  27934. return
  27935. }
  27936. return *v, true
  27937. }
  27938. // OldReceiverID returns the old "receiver_id" field's value of the UsageDetail entity.
  27939. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27940. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27941. func (m *UsageDetailMutation) OldReceiverID(ctx context.Context) (v string, err error) {
  27942. if !m.op.Is(OpUpdateOne) {
  27943. return v, errors.New("OldReceiverID is only allowed on UpdateOne operations")
  27944. }
  27945. if m.id == nil || m.oldValue == nil {
  27946. return v, errors.New("OldReceiverID requires an ID field in the mutation")
  27947. }
  27948. oldValue, err := m.oldValue(ctx)
  27949. if err != nil {
  27950. return v, fmt.Errorf("querying old value for OldReceiverID: %w", err)
  27951. }
  27952. return oldValue.ReceiverID, nil
  27953. }
  27954. // ResetReceiverID resets all changes to the "receiver_id" field.
  27955. func (m *UsageDetailMutation) ResetReceiverID() {
  27956. m.receiver_id = nil
  27957. }
  27958. // SetApp sets the "app" field.
  27959. func (m *UsageDetailMutation) SetApp(i int) {
  27960. m.app = &i
  27961. m.addapp = nil
  27962. }
  27963. // App returns the value of the "app" field in the mutation.
  27964. func (m *UsageDetailMutation) App() (r int, exists bool) {
  27965. v := m.app
  27966. if v == nil {
  27967. return
  27968. }
  27969. return *v, true
  27970. }
  27971. // OldApp returns the old "app" field's value of the UsageDetail entity.
  27972. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27973. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27974. func (m *UsageDetailMutation) OldApp(ctx context.Context) (v int, err error) {
  27975. if !m.op.Is(OpUpdateOne) {
  27976. return v, errors.New("OldApp is only allowed on UpdateOne operations")
  27977. }
  27978. if m.id == nil || m.oldValue == nil {
  27979. return v, errors.New("OldApp requires an ID field in the mutation")
  27980. }
  27981. oldValue, err := m.oldValue(ctx)
  27982. if err != nil {
  27983. return v, fmt.Errorf("querying old value for OldApp: %w", err)
  27984. }
  27985. return oldValue.App, nil
  27986. }
  27987. // AddApp adds i to the "app" field.
  27988. func (m *UsageDetailMutation) AddApp(i int) {
  27989. if m.addapp != nil {
  27990. *m.addapp += i
  27991. } else {
  27992. m.addapp = &i
  27993. }
  27994. }
  27995. // AddedApp returns the value that was added to the "app" field in this mutation.
  27996. func (m *UsageDetailMutation) AddedApp() (r int, exists bool) {
  27997. v := m.addapp
  27998. if v == nil {
  27999. return
  28000. }
  28001. return *v, true
  28002. }
  28003. // ClearApp clears the value of the "app" field.
  28004. func (m *UsageDetailMutation) ClearApp() {
  28005. m.app = nil
  28006. m.addapp = nil
  28007. m.clearedFields[usagedetail.FieldApp] = struct{}{}
  28008. }
  28009. // AppCleared returns if the "app" field was cleared in this mutation.
  28010. func (m *UsageDetailMutation) AppCleared() bool {
  28011. _, ok := m.clearedFields[usagedetail.FieldApp]
  28012. return ok
  28013. }
  28014. // ResetApp resets all changes to the "app" field.
  28015. func (m *UsageDetailMutation) ResetApp() {
  28016. m.app = nil
  28017. m.addapp = nil
  28018. delete(m.clearedFields, usagedetail.FieldApp)
  28019. }
  28020. // SetSessionID sets the "session_id" field.
  28021. func (m *UsageDetailMutation) SetSessionID(u uint64) {
  28022. m.session_id = &u
  28023. m.addsession_id = nil
  28024. }
  28025. // SessionID returns the value of the "session_id" field in the mutation.
  28026. func (m *UsageDetailMutation) SessionID() (r uint64, exists bool) {
  28027. v := m.session_id
  28028. if v == nil {
  28029. return
  28030. }
  28031. return *v, true
  28032. }
  28033. // OldSessionID returns the old "session_id" field's value of the UsageDetail entity.
  28034. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  28035. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28036. func (m *UsageDetailMutation) OldSessionID(ctx context.Context) (v uint64, err error) {
  28037. if !m.op.Is(OpUpdateOne) {
  28038. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  28039. }
  28040. if m.id == nil || m.oldValue == nil {
  28041. return v, errors.New("OldSessionID requires an ID field in the mutation")
  28042. }
  28043. oldValue, err := m.oldValue(ctx)
  28044. if err != nil {
  28045. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  28046. }
  28047. return oldValue.SessionID, nil
  28048. }
  28049. // AddSessionID adds u to the "session_id" field.
  28050. func (m *UsageDetailMutation) AddSessionID(u int64) {
  28051. if m.addsession_id != nil {
  28052. *m.addsession_id += u
  28053. } else {
  28054. m.addsession_id = &u
  28055. }
  28056. }
  28057. // AddedSessionID returns the value that was added to the "session_id" field in this mutation.
  28058. func (m *UsageDetailMutation) AddedSessionID() (r int64, exists bool) {
  28059. v := m.addsession_id
  28060. if v == nil {
  28061. return
  28062. }
  28063. return *v, true
  28064. }
  28065. // ClearSessionID clears the value of the "session_id" field.
  28066. func (m *UsageDetailMutation) ClearSessionID() {
  28067. m.session_id = nil
  28068. m.addsession_id = nil
  28069. m.clearedFields[usagedetail.FieldSessionID] = struct{}{}
  28070. }
  28071. // SessionIDCleared returns if the "session_id" field was cleared in this mutation.
  28072. func (m *UsageDetailMutation) SessionIDCleared() bool {
  28073. _, ok := m.clearedFields[usagedetail.FieldSessionID]
  28074. return ok
  28075. }
  28076. // ResetSessionID resets all changes to the "session_id" field.
  28077. func (m *UsageDetailMutation) ResetSessionID() {
  28078. m.session_id = nil
  28079. m.addsession_id = nil
  28080. delete(m.clearedFields, usagedetail.FieldSessionID)
  28081. }
  28082. // SetRequest sets the "request" field.
  28083. func (m *UsageDetailMutation) SetRequest(s string) {
  28084. m.request = &s
  28085. }
  28086. // Request returns the value of the "request" field in the mutation.
  28087. func (m *UsageDetailMutation) Request() (r string, exists bool) {
  28088. v := m.request
  28089. if v == nil {
  28090. return
  28091. }
  28092. return *v, true
  28093. }
  28094. // OldRequest returns the old "request" field's value of the UsageDetail entity.
  28095. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  28096. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28097. func (m *UsageDetailMutation) OldRequest(ctx context.Context) (v string, err error) {
  28098. if !m.op.Is(OpUpdateOne) {
  28099. return v, errors.New("OldRequest is only allowed on UpdateOne operations")
  28100. }
  28101. if m.id == nil || m.oldValue == nil {
  28102. return v, errors.New("OldRequest requires an ID field in the mutation")
  28103. }
  28104. oldValue, err := m.oldValue(ctx)
  28105. if err != nil {
  28106. return v, fmt.Errorf("querying old value for OldRequest: %w", err)
  28107. }
  28108. return oldValue.Request, nil
  28109. }
  28110. // ResetRequest resets all changes to the "request" field.
  28111. func (m *UsageDetailMutation) ResetRequest() {
  28112. m.request = nil
  28113. }
  28114. // SetResponse sets the "response" field.
  28115. func (m *UsageDetailMutation) SetResponse(s string) {
  28116. m.response = &s
  28117. }
  28118. // Response returns the value of the "response" field in the mutation.
  28119. func (m *UsageDetailMutation) Response() (r string, exists bool) {
  28120. v := m.response
  28121. if v == nil {
  28122. return
  28123. }
  28124. return *v, true
  28125. }
  28126. // OldResponse returns the old "response" field's value of the UsageDetail entity.
  28127. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  28128. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28129. func (m *UsageDetailMutation) OldResponse(ctx context.Context) (v string, err error) {
  28130. if !m.op.Is(OpUpdateOne) {
  28131. return v, errors.New("OldResponse is only allowed on UpdateOne operations")
  28132. }
  28133. if m.id == nil || m.oldValue == nil {
  28134. return v, errors.New("OldResponse requires an ID field in the mutation")
  28135. }
  28136. oldValue, err := m.oldValue(ctx)
  28137. if err != nil {
  28138. return v, fmt.Errorf("querying old value for OldResponse: %w", err)
  28139. }
  28140. return oldValue.Response, nil
  28141. }
  28142. // ResetResponse resets all changes to the "response" field.
  28143. func (m *UsageDetailMutation) ResetResponse() {
  28144. m.response = nil
  28145. }
  28146. // SetOriginalData sets the "original_data" field.
  28147. func (m *UsageDetailMutation) SetOriginalData(ctd custom_types.OriginalData) {
  28148. m.original_data = &ctd
  28149. }
  28150. // OriginalData returns the value of the "original_data" field in the mutation.
  28151. func (m *UsageDetailMutation) OriginalData() (r custom_types.OriginalData, exists bool) {
  28152. v := m.original_data
  28153. if v == nil {
  28154. return
  28155. }
  28156. return *v, true
  28157. }
  28158. // OldOriginalData returns the old "original_data" field's value of the UsageDetail entity.
  28159. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  28160. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28161. func (m *UsageDetailMutation) OldOriginalData(ctx context.Context) (v custom_types.OriginalData, err error) {
  28162. if !m.op.Is(OpUpdateOne) {
  28163. return v, errors.New("OldOriginalData is only allowed on UpdateOne operations")
  28164. }
  28165. if m.id == nil || m.oldValue == nil {
  28166. return v, errors.New("OldOriginalData requires an ID field in the mutation")
  28167. }
  28168. oldValue, err := m.oldValue(ctx)
  28169. if err != nil {
  28170. return v, fmt.Errorf("querying old value for OldOriginalData: %w", err)
  28171. }
  28172. return oldValue.OriginalData, nil
  28173. }
  28174. // ResetOriginalData resets all changes to the "original_data" field.
  28175. func (m *UsageDetailMutation) ResetOriginalData() {
  28176. m.original_data = nil
  28177. }
  28178. // SetTotalTokens sets the "total_tokens" field.
  28179. func (m *UsageDetailMutation) SetTotalTokens(u uint64) {
  28180. m.total_tokens = &u
  28181. m.addtotal_tokens = nil
  28182. }
  28183. // TotalTokens returns the value of the "total_tokens" field in the mutation.
  28184. func (m *UsageDetailMutation) TotalTokens() (r uint64, exists bool) {
  28185. v := m.total_tokens
  28186. if v == nil {
  28187. return
  28188. }
  28189. return *v, true
  28190. }
  28191. // OldTotalTokens returns the old "total_tokens" field's value of the UsageDetail entity.
  28192. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  28193. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28194. func (m *UsageDetailMutation) OldTotalTokens(ctx context.Context) (v uint64, err error) {
  28195. if !m.op.Is(OpUpdateOne) {
  28196. return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
  28197. }
  28198. if m.id == nil || m.oldValue == nil {
  28199. return v, errors.New("OldTotalTokens requires an ID field in the mutation")
  28200. }
  28201. oldValue, err := m.oldValue(ctx)
  28202. if err != nil {
  28203. return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
  28204. }
  28205. return oldValue.TotalTokens, nil
  28206. }
  28207. // AddTotalTokens adds u to the "total_tokens" field.
  28208. func (m *UsageDetailMutation) AddTotalTokens(u int64) {
  28209. if m.addtotal_tokens != nil {
  28210. *m.addtotal_tokens += u
  28211. } else {
  28212. m.addtotal_tokens = &u
  28213. }
  28214. }
  28215. // AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
  28216. func (m *UsageDetailMutation) AddedTotalTokens() (r int64, exists bool) {
  28217. v := m.addtotal_tokens
  28218. if v == nil {
  28219. return
  28220. }
  28221. return *v, true
  28222. }
  28223. // ClearTotalTokens clears the value of the "total_tokens" field.
  28224. func (m *UsageDetailMutation) ClearTotalTokens() {
  28225. m.total_tokens = nil
  28226. m.addtotal_tokens = nil
  28227. m.clearedFields[usagedetail.FieldTotalTokens] = struct{}{}
  28228. }
  28229. // TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
  28230. func (m *UsageDetailMutation) TotalTokensCleared() bool {
  28231. _, ok := m.clearedFields[usagedetail.FieldTotalTokens]
  28232. return ok
  28233. }
  28234. // ResetTotalTokens resets all changes to the "total_tokens" field.
  28235. func (m *UsageDetailMutation) ResetTotalTokens() {
  28236. m.total_tokens = nil
  28237. m.addtotal_tokens = nil
  28238. delete(m.clearedFields, usagedetail.FieldTotalTokens)
  28239. }
  28240. // SetPromptTokens sets the "prompt_tokens" field.
  28241. func (m *UsageDetailMutation) SetPromptTokens(u uint64) {
  28242. m.prompt_tokens = &u
  28243. m.addprompt_tokens = nil
  28244. }
  28245. // PromptTokens returns the value of the "prompt_tokens" field in the mutation.
  28246. func (m *UsageDetailMutation) PromptTokens() (r uint64, exists bool) {
  28247. v := m.prompt_tokens
  28248. if v == nil {
  28249. return
  28250. }
  28251. return *v, true
  28252. }
  28253. // OldPromptTokens returns the old "prompt_tokens" field's value of the UsageDetail entity.
  28254. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  28255. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28256. func (m *UsageDetailMutation) OldPromptTokens(ctx context.Context) (v uint64, err error) {
  28257. if !m.op.Is(OpUpdateOne) {
  28258. return v, errors.New("OldPromptTokens is only allowed on UpdateOne operations")
  28259. }
  28260. if m.id == nil || m.oldValue == nil {
  28261. return v, errors.New("OldPromptTokens requires an ID field in the mutation")
  28262. }
  28263. oldValue, err := m.oldValue(ctx)
  28264. if err != nil {
  28265. return v, fmt.Errorf("querying old value for OldPromptTokens: %w", err)
  28266. }
  28267. return oldValue.PromptTokens, nil
  28268. }
  28269. // AddPromptTokens adds u to the "prompt_tokens" field.
  28270. func (m *UsageDetailMutation) AddPromptTokens(u int64) {
  28271. if m.addprompt_tokens != nil {
  28272. *m.addprompt_tokens += u
  28273. } else {
  28274. m.addprompt_tokens = &u
  28275. }
  28276. }
  28277. // AddedPromptTokens returns the value that was added to the "prompt_tokens" field in this mutation.
  28278. func (m *UsageDetailMutation) AddedPromptTokens() (r int64, exists bool) {
  28279. v := m.addprompt_tokens
  28280. if v == nil {
  28281. return
  28282. }
  28283. return *v, true
  28284. }
  28285. // ClearPromptTokens clears the value of the "prompt_tokens" field.
  28286. func (m *UsageDetailMutation) ClearPromptTokens() {
  28287. m.prompt_tokens = nil
  28288. m.addprompt_tokens = nil
  28289. m.clearedFields[usagedetail.FieldPromptTokens] = struct{}{}
  28290. }
  28291. // PromptTokensCleared returns if the "prompt_tokens" field was cleared in this mutation.
  28292. func (m *UsageDetailMutation) PromptTokensCleared() bool {
  28293. _, ok := m.clearedFields[usagedetail.FieldPromptTokens]
  28294. return ok
  28295. }
  28296. // ResetPromptTokens resets all changes to the "prompt_tokens" field.
  28297. func (m *UsageDetailMutation) ResetPromptTokens() {
  28298. m.prompt_tokens = nil
  28299. m.addprompt_tokens = nil
  28300. delete(m.clearedFields, usagedetail.FieldPromptTokens)
  28301. }
  28302. // SetCompletionTokens sets the "completion_tokens" field.
  28303. func (m *UsageDetailMutation) SetCompletionTokens(u uint64) {
  28304. m.completion_tokens = &u
  28305. m.addcompletion_tokens = nil
  28306. }
  28307. // CompletionTokens returns the value of the "completion_tokens" field in the mutation.
  28308. func (m *UsageDetailMutation) CompletionTokens() (r uint64, exists bool) {
  28309. v := m.completion_tokens
  28310. if v == nil {
  28311. return
  28312. }
  28313. return *v, true
  28314. }
  28315. // OldCompletionTokens returns the old "completion_tokens" field's value of the UsageDetail entity.
  28316. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  28317. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28318. func (m *UsageDetailMutation) OldCompletionTokens(ctx context.Context) (v uint64, err error) {
  28319. if !m.op.Is(OpUpdateOne) {
  28320. return v, errors.New("OldCompletionTokens is only allowed on UpdateOne operations")
  28321. }
  28322. if m.id == nil || m.oldValue == nil {
  28323. return v, errors.New("OldCompletionTokens requires an ID field in the mutation")
  28324. }
  28325. oldValue, err := m.oldValue(ctx)
  28326. if err != nil {
  28327. return v, fmt.Errorf("querying old value for OldCompletionTokens: %w", err)
  28328. }
  28329. return oldValue.CompletionTokens, nil
  28330. }
  28331. // AddCompletionTokens adds u to the "completion_tokens" field.
  28332. func (m *UsageDetailMutation) AddCompletionTokens(u int64) {
  28333. if m.addcompletion_tokens != nil {
  28334. *m.addcompletion_tokens += u
  28335. } else {
  28336. m.addcompletion_tokens = &u
  28337. }
  28338. }
  28339. // AddedCompletionTokens returns the value that was added to the "completion_tokens" field in this mutation.
  28340. func (m *UsageDetailMutation) AddedCompletionTokens() (r int64, exists bool) {
  28341. v := m.addcompletion_tokens
  28342. if v == nil {
  28343. return
  28344. }
  28345. return *v, true
  28346. }
  28347. // ClearCompletionTokens clears the value of the "completion_tokens" field.
  28348. func (m *UsageDetailMutation) ClearCompletionTokens() {
  28349. m.completion_tokens = nil
  28350. m.addcompletion_tokens = nil
  28351. m.clearedFields[usagedetail.FieldCompletionTokens] = struct{}{}
  28352. }
  28353. // CompletionTokensCleared returns if the "completion_tokens" field was cleared in this mutation.
  28354. func (m *UsageDetailMutation) CompletionTokensCleared() bool {
  28355. _, ok := m.clearedFields[usagedetail.FieldCompletionTokens]
  28356. return ok
  28357. }
  28358. // ResetCompletionTokens resets all changes to the "completion_tokens" field.
  28359. func (m *UsageDetailMutation) ResetCompletionTokens() {
  28360. m.completion_tokens = nil
  28361. m.addcompletion_tokens = nil
  28362. delete(m.clearedFields, usagedetail.FieldCompletionTokens)
  28363. }
  28364. // SetOrganizationID sets the "organization_id" field.
  28365. func (m *UsageDetailMutation) SetOrganizationID(u uint64) {
  28366. m.organization_id = &u
  28367. m.addorganization_id = nil
  28368. }
  28369. // OrganizationID returns the value of the "organization_id" field in the mutation.
  28370. func (m *UsageDetailMutation) OrganizationID() (r uint64, exists bool) {
  28371. v := m.organization_id
  28372. if v == nil {
  28373. return
  28374. }
  28375. return *v, true
  28376. }
  28377. // OldOrganizationID returns the old "organization_id" field's value of the UsageDetail entity.
  28378. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  28379. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28380. func (m *UsageDetailMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  28381. if !m.op.Is(OpUpdateOne) {
  28382. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  28383. }
  28384. if m.id == nil || m.oldValue == nil {
  28385. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  28386. }
  28387. oldValue, err := m.oldValue(ctx)
  28388. if err != nil {
  28389. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  28390. }
  28391. return oldValue.OrganizationID, nil
  28392. }
  28393. // AddOrganizationID adds u to the "organization_id" field.
  28394. func (m *UsageDetailMutation) AddOrganizationID(u int64) {
  28395. if m.addorganization_id != nil {
  28396. *m.addorganization_id += u
  28397. } else {
  28398. m.addorganization_id = &u
  28399. }
  28400. }
  28401. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  28402. func (m *UsageDetailMutation) AddedOrganizationID() (r int64, exists bool) {
  28403. v := m.addorganization_id
  28404. if v == nil {
  28405. return
  28406. }
  28407. return *v, true
  28408. }
  28409. // ClearOrganizationID clears the value of the "organization_id" field.
  28410. func (m *UsageDetailMutation) ClearOrganizationID() {
  28411. m.organization_id = nil
  28412. m.addorganization_id = nil
  28413. m.clearedFields[usagedetail.FieldOrganizationID] = struct{}{}
  28414. }
  28415. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  28416. func (m *UsageDetailMutation) OrganizationIDCleared() bool {
  28417. _, ok := m.clearedFields[usagedetail.FieldOrganizationID]
  28418. return ok
  28419. }
  28420. // ResetOrganizationID resets all changes to the "organization_id" field.
  28421. func (m *UsageDetailMutation) ResetOrganizationID() {
  28422. m.organization_id = nil
  28423. m.addorganization_id = nil
  28424. delete(m.clearedFields, usagedetail.FieldOrganizationID)
  28425. }
  28426. // Where appends a list predicates to the UsageDetailMutation builder.
  28427. func (m *UsageDetailMutation) Where(ps ...predicate.UsageDetail) {
  28428. m.predicates = append(m.predicates, ps...)
  28429. }
  28430. // WhereP appends storage-level predicates to the UsageDetailMutation builder. Using this method,
  28431. // users can use type-assertion to append predicates that do not depend on any generated package.
  28432. func (m *UsageDetailMutation) WhereP(ps ...func(*sql.Selector)) {
  28433. p := make([]predicate.UsageDetail, len(ps))
  28434. for i := range ps {
  28435. p[i] = ps[i]
  28436. }
  28437. m.Where(p...)
  28438. }
  28439. // Op returns the operation name.
  28440. func (m *UsageDetailMutation) Op() Op {
  28441. return m.op
  28442. }
  28443. // SetOp allows setting the mutation operation.
  28444. func (m *UsageDetailMutation) SetOp(op Op) {
  28445. m.op = op
  28446. }
  28447. // Type returns the node type of this mutation (UsageDetail).
  28448. func (m *UsageDetailMutation) Type() string {
  28449. return m.typ
  28450. }
  28451. // Fields returns all fields that were changed during this mutation. Note that in
  28452. // order to get all numeric fields that were incremented/decremented, call
  28453. // AddedFields().
  28454. func (m *UsageDetailMutation) Fields() []string {
  28455. fields := make([]string, 0, 15)
  28456. if m.created_at != nil {
  28457. fields = append(fields, usagedetail.FieldCreatedAt)
  28458. }
  28459. if m.updated_at != nil {
  28460. fields = append(fields, usagedetail.FieldUpdatedAt)
  28461. }
  28462. if m.status != nil {
  28463. fields = append(fields, usagedetail.FieldStatus)
  28464. }
  28465. if m._type != nil {
  28466. fields = append(fields, usagedetail.FieldType)
  28467. }
  28468. if m.bot_id != nil {
  28469. fields = append(fields, usagedetail.FieldBotID)
  28470. }
  28471. if m.receiver_id != nil {
  28472. fields = append(fields, usagedetail.FieldReceiverID)
  28473. }
  28474. if m.app != nil {
  28475. fields = append(fields, usagedetail.FieldApp)
  28476. }
  28477. if m.session_id != nil {
  28478. fields = append(fields, usagedetail.FieldSessionID)
  28479. }
  28480. if m.request != nil {
  28481. fields = append(fields, usagedetail.FieldRequest)
  28482. }
  28483. if m.response != nil {
  28484. fields = append(fields, usagedetail.FieldResponse)
  28485. }
  28486. if m.original_data != nil {
  28487. fields = append(fields, usagedetail.FieldOriginalData)
  28488. }
  28489. if m.total_tokens != nil {
  28490. fields = append(fields, usagedetail.FieldTotalTokens)
  28491. }
  28492. if m.prompt_tokens != nil {
  28493. fields = append(fields, usagedetail.FieldPromptTokens)
  28494. }
  28495. if m.completion_tokens != nil {
  28496. fields = append(fields, usagedetail.FieldCompletionTokens)
  28497. }
  28498. if m.organization_id != nil {
  28499. fields = append(fields, usagedetail.FieldOrganizationID)
  28500. }
  28501. return fields
  28502. }
  28503. // Field returns the value of a field with the given name. The second boolean
  28504. // return value indicates that this field was not set, or was not defined in the
  28505. // schema.
  28506. func (m *UsageDetailMutation) Field(name string) (ent.Value, bool) {
  28507. switch name {
  28508. case usagedetail.FieldCreatedAt:
  28509. return m.CreatedAt()
  28510. case usagedetail.FieldUpdatedAt:
  28511. return m.UpdatedAt()
  28512. case usagedetail.FieldStatus:
  28513. return m.Status()
  28514. case usagedetail.FieldType:
  28515. return m.GetType()
  28516. case usagedetail.FieldBotID:
  28517. return m.BotID()
  28518. case usagedetail.FieldReceiverID:
  28519. return m.ReceiverID()
  28520. case usagedetail.FieldApp:
  28521. return m.App()
  28522. case usagedetail.FieldSessionID:
  28523. return m.SessionID()
  28524. case usagedetail.FieldRequest:
  28525. return m.Request()
  28526. case usagedetail.FieldResponse:
  28527. return m.Response()
  28528. case usagedetail.FieldOriginalData:
  28529. return m.OriginalData()
  28530. case usagedetail.FieldTotalTokens:
  28531. return m.TotalTokens()
  28532. case usagedetail.FieldPromptTokens:
  28533. return m.PromptTokens()
  28534. case usagedetail.FieldCompletionTokens:
  28535. return m.CompletionTokens()
  28536. case usagedetail.FieldOrganizationID:
  28537. return m.OrganizationID()
  28538. }
  28539. return nil, false
  28540. }
  28541. // OldField returns the old value of the field from the database. An error is
  28542. // returned if the mutation operation is not UpdateOne, or the query to the
  28543. // database failed.
  28544. func (m *UsageDetailMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  28545. switch name {
  28546. case usagedetail.FieldCreatedAt:
  28547. return m.OldCreatedAt(ctx)
  28548. case usagedetail.FieldUpdatedAt:
  28549. return m.OldUpdatedAt(ctx)
  28550. case usagedetail.FieldStatus:
  28551. return m.OldStatus(ctx)
  28552. case usagedetail.FieldType:
  28553. return m.OldType(ctx)
  28554. case usagedetail.FieldBotID:
  28555. return m.OldBotID(ctx)
  28556. case usagedetail.FieldReceiverID:
  28557. return m.OldReceiverID(ctx)
  28558. case usagedetail.FieldApp:
  28559. return m.OldApp(ctx)
  28560. case usagedetail.FieldSessionID:
  28561. return m.OldSessionID(ctx)
  28562. case usagedetail.FieldRequest:
  28563. return m.OldRequest(ctx)
  28564. case usagedetail.FieldResponse:
  28565. return m.OldResponse(ctx)
  28566. case usagedetail.FieldOriginalData:
  28567. return m.OldOriginalData(ctx)
  28568. case usagedetail.FieldTotalTokens:
  28569. return m.OldTotalTokens(ctx)
  28570. case usagedetail.FieldPromptTokens:
  28571. return m.OldPromptTokens(ctx)
  28572. case usagedetail.FieldCompletionTokens:
  28573. return m.OldCompletionTokens(ctx)
  28574. case usagedetail.FieldOrganizationID:
  28575. return m.OldOrganizationID(ctx)
  28576. }
  28577. return nil, fmt.Errorf("unknown UsageDetail field %s", name)
  28578. }
  28579. // SetField sets the value of a field with the given name. It returns an error if
  28580. // the field is not defined in the schema, or if the type mismatched the field
  28581. // type.
  28582. func (m *UsageDetailMutation) SetField(name string, value ent.Value) error {
  28583. switch name {
  28584. case usagedetail.FieldCreatedAt:
  28585. v, ok := value.(time.Time)
  28586. if !ok {
  28587. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28588. }
  28589. m.SetCreatedAt(v)
  28590. return nil
  28591. case usagedetail.FieldUpdatedAt:
  28592. v, ok := value.(time.Time)
  28593. if !ok {
  28594. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28595. }
  28596. m.SetUpdatedAt(v)
  28597. return nil
  28598. case usagedetail.FieldStatus:
  28599. v, ok := value.(uint8)
  28600. if !ok {
  28601. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28602. }
  28603. m.SetStatus(v)
  28604. return nil
  28605. case usagedetail.FieldType:
  28606. v, ok := value.(int)
  28607. if !ok {
  28608. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28609. }
  28610. m.SetType(v)
  28611. return nil
  28612. case usagedetail.FieldBotID:
  28613. v, ok := value.(string)
  28614. if !ok {
  28615. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28616. }
  28617. m.SetBotID(v)
  28618. return nil
  28619. case usagedetail.FieldReceiverID:
  28620. v, ok := value.(string)
  28621. if !ok {
  28622. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28623. }
  28624. m.SetReceiverID(v)
  28625. return nil
  28626. case usagedetail.FieldApp:
  28627. v, ok := value.(int)
  28628. if !ok {
  28629. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28630. }
  28631. m.SetApp(v)
  28632. return nil
  28633. case usagedetail.FieldSessionID:
  28634. v, ok := value.(uint64)
  28635. if !ok {
  28636. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28637. }
  28638. m.SetSessionID(v)
  28639. return nil
  28640. case usagedetail.FieldRequest:
  28641. v, ok := value.(string)
  28642. if !ok {
  28643. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28644. }
  28645. m.SetRequest(v)
  28646. return nil
  28647. case usagedetail.FieldResponse:
  28648. v, ok := value.(string)
  28649. if !ok {
  28650. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28651. }
  28652. m.SetResponse(v)
  28653. return nil
  28654. case usagedetail.FieldOriginalData:
  28655. v, ok := value.(custom_types.OriginalData)
  28656. if !ok {
  28657. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28658. }
  28659. m.SetOriginalData(v)
  28660. return nil
  28661. case usagedetail.FieldTotalTokens:
  28662. v, ok := value.(uint64)
  28663. if !ok {
  28664. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28665. }
  28666. m.SetTotalTokens(v)
  28667. return nil
  28668. case usagedetail.FieldPromptTokens:
  28669. v, ok := value.(uint64)
  28670. if !ok {
  28671. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28672. }
  28673. m.SetPromptTokens(v)
  28674. return nil
  28675. case usagedetail.FieldCompletionTokens:
  28676. v, ok := value.(uint64)
  28677. if !ok {
  28678. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28679. }
  28680. m.SetCompletionTokens(v)
  28681. return nil
  28682. case usagedetail.FieldOrganizationID:
  28683. v, ok := value.(uint64)
  28684. if !ok {
  28685. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28686. }
  28687. m.SetOrganizationID(v)
  28688. return nil
  28689. }
  28690. return fmt.Errorf("unknown UsageDetail field %s", name)
  28691. }
  28692. // AddedFields returns all numeric fields that were incremented/decremented during
  28693. // this mutation.
  28694. func (m *UsageDetailMutation) AddedFields() []string {
  28695. var fields []string
  28696. if m.addstatus != nil {
  28697. fields = append(fields, usagedetail.FieldStatus)
  28698. }
  28699. if m.add_type != nil {
  28700. fields = append(fields, usagedetail.FieldType)
  28701. }
  28702. if m.addapp != nil {
  28703. fields = append(fields, usagedetail.FieldApp)
  28704. }
  28705. if m.addsession_id != nil {
  28706. fields = append(fields, usagedetail.FieldSessionID)
  28707. }
  28708. if m.addtotal_tokens != nil {
  28709. fields = append(fields, usagedetail.FieldTotalTokens)
  28710. }
  28711. if m.addprompt_tokens != nil {
  28712. fields = append(fields, usagedetail.FieldPromptTokens)
  28713. }
  28714. if m.addcompletion_tokens != nil {
  28715. fields = append(fields, usagedetail.FieldCompletionTokens)
  28716. }
  28717. if m.addorganization_id != nil {
  28718. fields = append(fields, usagedetail.FieldOrganizationID)
  28719. }
  28720. return fields
  28721. }
  28722. // AddedField returns the numeric value that was incremented/decremented on a field
  28723. // with the given name. The second boolean return value indicates that this field
  28724. // was not set, or was not defined in the schema.
  28725. func (m *UsageDetailMutation) AddedField(name string) (ent.Value, bool) {
  28726. switch name {
  28727. case usagedetail.FieldStatus:
  28728. return m.AddedStatus()
  28729. case usagedetail.FieldType:
  28730. return m.AddedType()
  28731. case usagedetail.FieldApp:
  28732. return m.AddedApp()
  28733. case usagedetail.FieldSessionID:
  28734. return m.AddedSessionID()
  28735. case usagedetail.FieldTotalTokens:
  28736. return m.AddedTotalTokens()
  28737. case usagedetail.FieldPromptTokens:
  28738. return m.AddedPromptTokens()
  28739. case usagedetail.FieldCompletionTokens:
  28740. return m.AddedCompletionTokens()
  28741. case usagedetail.FieldOrganizationID:
  28742. return m.AddedOrganizationID()
  28743. }
  28744. return nil, false
  28745. }
  28746. // AddField adds the value to the field with the given name. It returns an error if
  28747. // the field is not defined in the schema, or if the type mismatched the field
  28748. // type.
  28749. func (m *UsageDetailMutation) AddField(name string, value ent.Value) error {
  28750. switch name {
  28751. case usagedetail.FieldStatus:
  28752. v, ok := value.(int8)
  28753. if !ok {
  28754. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28755. }
  28756. m.AddStatus(v)
  28757. return nil
  28758. case usagedetail.FieldType:
  28759. v, ok := value.(int)
  28760. if !ok {
  28761. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28762. }
  28763. m.AddType(v)
  28764. return nil
  28765. case usagedetail.FieldApp:
  28766. v, ok := value.(int)
  28767. if !ok {
  28768. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28769. }
  28770. m.AddApp(v)
  28771. return nil
  28772. case usagedetail.FieldSessionID:
  28773. v, ok := value.(int64)
  28774. if !ok {
  28775. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28776. }
  28777. m.AddSessionID(v)
  28778. return nil
  28779. case usagedetail.FieldTotalTokens:
  28780. v, ok := value.(int64)
  28781. if !ok {
  28782. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28783. }
  28784. m.AddTotalTokens(v)
  28785. return nil
  28786. case usagedetail.FieldPromptTokens:
  28787. v, ok := value.(int64)
  28788. if !ok {
  28789. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28790. }
  28791. m.AddPromptTokens(v)
  28792. return nil
  28793. case usagedetail.FieldCompletionTokens:
  28794. v, ok := value.(int64)
  28795. if !ok {
  28796. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28797. }
  28798. m.AddCompletionTokens(v)
  28799. return nil
  28800. case usagedetail.FieldOrganizationID:
  28801. v, ok := value.(int64)
  28802. if !ok {
  28803. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28804. }
  28805. m.AddOrganizationID(v)
  28806. return nil
  28807. }
  28808. return fmt.Errorf("unknown UsageDetail numeric field %s", name)
  28809. }
  28810. // ClearedFields returns all nullable fields that were cleared during this
  28811. // mutation.
  28812. func (m *UsageDetailMutation) ClearedFields() []string {
  28813. var fields []string
  28814. if m.FieldCleared(usagedetail.FieldStatus) {
  28815. fields = append(fields, usagedetail.FieldStatus)
  28816. }
  28817. if m.FieldCleared(usagedetail.FieldType) {
  28818. fields = append(fields, usagedetail.FieldType)
  28819. }
  28820. if m.FieldCleared(usagedetail.FieldApp) {
  28821. fields = append(fields, usagedetail.FieldApp)
  28822. }
  28823. if m.FieldCleared(usagedetail.FieldSessionID) {
  28824. fields = append(fields, usagedetail.FieldSessionID)
  28825. }
  28826. if m.FieldCleared(usagedetail.FieldTotalTokens) {
  28827. fields = append(fields, usagedetail.FieldTotalTokens)
  28828. }
  28829. if m.FieldCleared(usagedetail.FieldPromptTokens) {
  28830. fields = append(fields, usagedetail.FieldPromptTokens)
  28831. }
  28832. if m.FieldCleared(usagedetail.FieldCompletionTokens) {
  28833. fields = append(fields, usagedetail.FieldCompletionTokens)
  28834. }
  28835. if m.FieldCleared(usagedetail.FieldOrganizationID) {
  28836. fields = append(fields, usagedetail.FieldOrganizationID)
  28837. }
  28838. return fields
  28839. }
  28840. // FieldCleared returns a boolean indicating if a field with the given name was
  28841. // cleared in this mutation.
  28842. func (m *UsageDetailMutation) FieldCleared(name string) bool {
  28843. _, ok := m.clearedFields[name]
  28844. return ok
  28845. }
  28846. // ClearField clears the value of the field with the given name. It returns an
  28847. // error if the field is not defined in the schema.
  28848. func (m *UsageDetailMutation) ClearField(name string) error {
  28849. switch name {
  28850. case usagedetail.FieldStatus:
  28851. m.ClearStatus()
  28852. return nil
  28853. case usagedetail.FieldType:
  28854. m.ClearType()
  28855. return nil
  28856. case usagedetail.FieldApp:
  28857. m.ClearApp()
  28858. return nil
  28859. case usagedetail.FieldSessionID:
  28860. m.ClearSessionID()
  28861. return nil
  28862. case usagedetail.FieldTotalTokens:
  28863. m.ClearTotalTokens()
  28864. return nil
  28865. case usagedetail.FieldPromptTokens:
  28866. m.ClearPromptTokens()
  28867. return nil
  28868. case usagedetail.FieldCompletionTokens:
  28869. m.ClearCompletionTokens()
  28870. return nil
  28871. case usagedetail.FieldOrganizationID:
  28872. m.ClearOrganizationID()
  28873. return nil
  28874. }
  28875. return fmt.Errorf("unknown UsageDetail nullable field %s", name)
  28876. }
  28877. // ResetField resets all changes in the mutation for the field with the given name.
  28878. // It returns an error if the field is not defined in the schema.
  28879. func (m *UsageDetailMutation) ResetField(name string) error {
  28880. switch name {
  28881. case usagedetail.FieldCreatedAt:
  28882. m.ResetCreatedAt()
  28883. return nil
  28884. case usagedetail.FieldUpdatedAt:
  28885. m.ResetUpdatedAt()
  28886. return nil
  28887. case usagedetail.FieldStatus:
  28888. m.ResetStatus()
  28889. return nil
  28890. case usagedetail.FieldType:
  28891. m.ResetType()
  28892. return nil
  28893. case usagedetail.FieldBotID:
  28894. m.ResetBotID()
  28895. return nil
  28896. case usagedetail.FieldReceiverID:
  28897. m.ResetReceiverID()
  28898. return nil
  28899. case usagedetail.FieldApp:
  28900. m.ResetApp()
  28901. return nil
  28902. case usagedetail.FieldSessionID:
  28903. m.ResetSessionID()
  28904. return nil
  28905. case usagedetail.FieldRequest:
  28906. m.ResetRequest()
  28907. return nil
  28908. case usagedetail.FieldResponse:
  28909. m.ResetResponse()
  28910. return nil
  28911. case usagedetail.FieldOriginalData:
  28912. m.ResetOriginalData()
  28913. return nil
  28914. case usagedetail.FieldTotalTokens:
  28915. m.ResetTotalTokens()
  28916. return nil
  28917. case usagedetail.FieldPromptTokens:
  28918. m.ResetPromptTokens()
  28919. return nil
  28920. case usagedetail.FieldCompletionTokens:
  28921. m.ResetCompletionTokens()
  28922. return nil
  28923. case usagedetail.FieldOrganizationID:
  28924. m.ResetOrganizationID()
  28925. return nil
  28926. }
  28927. return fmt.Errorf("unknown UsageDetail field %s", name)
  28928. }
  28929. // AddedEdges returns all edge names that were set/added in this mutation.
  28930. func (m *UsageDetailMutation) AddedEdges() []string {
  28931. edges := make([]string, 0, 0)
  28932. return edges
  28933. }
  28934. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  28935. // name in this mutation.
  28936. func (m *UsageDetailMutation) AddedIDs(name string) []ent.Value {
  28937. return nil
  28938. }
  28939. // RemovedEdges returns all edge names that were removed in this mutation.
  28940. func (m *UsageDetailMutation) RemovedEdges() []string {
  28941. edges := make([]string, 0, 0)
  28942. return edges
  28943. }
  28944. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  28945. // the given name in this mutation.
  28946. func (m *UsageDetailMutation) RemovedIDs(name string) []ent.Value {
  28947. return nil
  28948. }
  28949. // ClearedEdges returns all edge names that were cleared in this mutation.
  28950. func (m *UsageDetailMutation) ClearedEdges() []string {
  28951. edges := make([]string, 0, 0)
  28952. return edges
  28953. }
  28954. // EdgeCleared returns a boolean which indicates if the edge with the given name
  28955. // was cleared in this mutation.
  28956. func (m *UsageDetailMutation) EdgeCleared(name string) bool {
  28957. return false
  28958. }
  28959. // ClearEdge clears the value of the edge with the given name. It returns an error
  28960. // if that edge is not defined in the schema.
  28961. func (m *UsageDetailMutation) ClearEdge(name string) error {
  28962. return fmt.Errorf("unknown UsageDetail unique edge %s", name)
  28963. }
  28964. // ResetEdge resets all changes to the edge with the given name in this mutation.
  28965. // It returns an error if the edge is not defined in the schema.
  28966. func (m *UsageDetailMutation) ResetEdge(name string) error {
  28967. return fmt.Errorf("unknown UsageDetail edge %s", name)
  28968. }
  28969. // UsageStatisticDayMutation represents an operation that mutates the UsageStatisticDay nodes in the graph.
  28970. type UsageStatisticDayMutation struct {
  28971. config
  28972. op Op
  28973. typ string
  28974. id *uint64
  28975. created_at *time.Time
  28976. updated_at *time.Time
  28977. status *uint8
  28978. addstatus *int8
  28979. deleted_at *time.Time
  28980. addtime *uint64
  28981. addaddtime *int64
  28982. _type *int
  28983. add_type *int
  28984. bot_id *string
  28985. organization_id *uint64
  28986. addorganization_id *int64
  28987. ai_response *uint64
  28988. addai_response *int64
  28989. sop_run *uint64
  28990. addsop_run *int64
  28991. total_friend *uint64
  28992. addtotal_friend *int64
  28993. total_group *uint64
  28994. addtotal_group *int64
  28995. account_balance *uint64
  28996. addaccount_balance *int64
  28997. consume_token *uint64
  28998. addconsume_token *int64
  28999. active_user *uint64
  29000. addactive_user *int64
  29001. new_user *int64
  29002. addnew_user *int64
  29003. label_dist *[]custom_types.LabelDist
  29004. appendlabel_dist []custom_types.LabelDist
  29005. clearedFields map[string]struct{}
  29006. done bool
  29007. oldValue func(context.Context) (*UsageStatisticDay, error)
  29008. predicates []predicate.UsageStatisticDay
  29009. }
  29010. var _ ent.Mutation = (*UsageStatisticDayMutation)(nil)
  29011. // usagestatisticdayOption allows management of the mutation configuration using functional options.
  29012. type usagestatisticdayOption func(*UsageStatisticDayMutation)
  29013. // newUsageStatisticDayMutation creates new mutation for the UsageStatisticDay entity.
  29014. func newUsageStatisticDayMutation(c config, op Op, opts ...usagestatisticdayOption) *UsageStatisticDayMutation {
  29015. m := &UsageStatisticDayMutation{
  29016. config: c,
  29017. op: op,
  29018. typ: TypeUsageStatisticDay,
  29019. clearedFields: make(map[string]struct{}),
  29020. }
  29021. for _, opt := range opts {
  29022. opt(m)
  29023. }
  29024. return m
  29025. }
  29026. // withUsageStatisticDayID sets the ID field of the mutation.
  29027. func withUsageStatisticDayID(id uint64) usagestatisticdayOption {
  29028. return func(m *UsageStatisticDayMutation) {
  29029. var (
  29030. err error
  29031. once sync.Once
  29032. value *UsageStatisticDay
  29033. )
  29034. m.oldValue = func(ctx context.Context) (*UsageStatisticDay, error) {
  29035. once.Do(func() {
  29036. if m.done {
  29037. err = errors.New("querying old values post mutation is not allowed")
  29038. } else {
  29039. value, err = m.Client().UsageStatisticDay.Get(ctx, id)
  29040. }
  29041. })
  29042. return value, err
  29043. }
  29044. m.id = &id
  29045. }
  29046. }
  29047. // withUsageStatisticDay sets the old UsageStatisticDay of the mutation.
  29048. func withUsageStatisticDay(node *UsageStatisticDay) usagestatisticdayOption {
  29049. return func(m *UsageStatisticDayMutation) {
  29050. m.oldValue = func(context.Context) (*UsageStatisticDay, error) {
  29051. return node, nil
  29052. }
  29053. m.id = &node.ID
  29054. }
  29055. }
  29056. // Client returns a new `ent.Client` from the mutation. If the mutation was
  29057. // executed in a transaction (ent.Tx), a transactional client is returned.
  29058. func (m UsageStatisticDayMutation) Client() *Client {
  29059. client := &Client{config: m.config}
  29060. client.init()
  29061. return client
  29062. }
  29063. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  29064. // it returns an error otherwise.
  29065. func (m UsageStatisticDayMutation) Tx() (*Tx, error) {
  29066. if _, ok := m.driver.(*txDriver); !ok {
  29067. return nil, errors.New("ent: mutation is not running in a transaction")
  29068. }
  29069. tx := &Tx{config: m.config}
  29070. tx.init()
  29071. return tx, nil
  29072. }
  29073. // SetID sets the value of the id field. Note that this
  29074. // operation is only accepted on creation of UsageStatisticDay entities.
  29075. func (m *UsageStatisticDayMutation) SetID(id uint64) {
  29076. m.id = &id
  29077. }
  29078. // ID returns the ID value in the mutation. Note that the ID is only available
  29079. // if it was provided to the builder or after it was returned from the database.
  29080. func (m *UsageStatisticDayMutation) ID() (id uint64, exists bool) {
  29081. if m.id == nil {
  29082. return
  29083. }
  29084. return *m.id, true
  29085. }
  29086. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  29087. // That means, if the mutation is applied within a transaction with an isolation level such
  29088. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  29089. // or updated by the mutation.
  29090. func (m *UsageStatisticDayMutation) IDs(ctx context.Context) ([]uint64, error) {
  29091. switch {
  29092. case m.op.Is(OpUpdateOne | OpDeleteOne):
  29093. id, exists := m.ID()
  29094. if exists {
  29095. return []uint64{id}, nil
  29096. }
  29097. fallthrough
  29098. case m.op.Is(OpUpdate | OpDelete):
  29099. return m.Client().UsageStatisticDay.Query().Where(m.predicates...).IDs(ctx)
  29100. default:
  29101. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  29102. }
  29103. }
  29104. // SetCreatedAt sets the "created_at" field.
  29105. func (m *UsageStatisticDayMutation) SetCreatedAt(t time.Time) {
  29106. m.created_at = &t
  29107. }
  29108. // CreatedAt returns the value of the "created_at" field in the mutation.
  29109. func (m *UsageStatisticDayMutation) CreatedAt() (r time.Time, exists bool) {
  29110. v := m.created_at
  29111. if v == nil {
  29112. return
  29113. }
  29114. return *v, true
  29115. }
  29116. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticDay entity.
  29117. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  29118. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29119. func (m *UsageStatisticDayMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  29120. if !m.op.Is(OpUpdateOne) {
  29121. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  29122. }
  29123. if m.id == nil || m.oldValue == nil {
  29124. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  29125. }
  29126. oldValue, err := m.oldValue(ctx)
  29127. if err != nil {
  29128. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  29129. }
  29130. return oldValue.CreatedAt, nil
  29131. }
  29132. // ResetCreatedAt resets all changes to the "created_at" field.
  29133. func (m *UsageStatisticDayMutation) ResetCreatedAt() {
  29134. m.created_at = nil
  29135. }
  29136. // SetUpdatedAt sets the "updated_at" field.
  29137. func (m *UsageStatisticDayMutation) SetUpdatedAt(t time.Time) {
  29138. m.updated_at = &t
  29139. }
  29140. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  29141. func (m *UsageStatisticDayMutation) UpdatedAt() (r time.Time, exists bool) {
  29142. v := m.updated_at
  29143. if v == nil {
  29144. return
  29145. }
  29146. return *v, true
  29147. }
  29148. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticDay entity.
  29149. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  29150. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29151. func (m *UsageStatisticDayMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  29152. if !m.op.Is(OpUpdateOne) {
  29153. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  29154. }
  29155. if m.id == nil || m.oldValue == nil {
  29156. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  29157. }
  29158. oldValue, err := m.oldValue(ctx)
  29159. if err != nil {
  29160. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  29161. }
  29162. return oldValue.UpdatedAt, nil
  29163. }
  29164. // ResetUpdatedAt resets all changes to the "updated_at" field.
  29165. func (m *UsageStatisticDayMutation) ResetUpdatedAt() {
  29166. m.updated_at = nil
  29167. }
  29168. // SetStatus sets the "status" field.
  29169. func (m *UsageStatisticDayMutation) SetStatus(u uint8) {
  29170. m.status = &u
  29171. m.addstatus = nil
  29172. }
  29173. // Status returns the value of the "status" field in the mutation.
  29174. func (m *UsageStatisticDayMutation) Status() (r uint8, exists bool) {
  29175. v := m.status
  29176. if v == nil {
  29177. return
  29178. }
  29179. return *v, true
  29180. }
  29181. // OldStatus returns the old "status" field's value of the UsageStatisticDay entity.
  29182. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  29183. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29184. func (m *UsageStatisticDayMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  29185. if !m.op.Is(OpUpdateOne) {
  29186. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  29187. }
  29188. if m.id == nil || m.oldValue == nil {
  29189. return v, errors.New("OldStatus requires an ID field in the mutation")
  29190. }
  29191. oldValue, err := m.oldValue(ctx)
  29192. if err != nil {
  29193. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  29194. }
  29195. return oldValue.Status, nil
  29196. }
  29197. // AddStatus adds u to the "status" field.
  29198. func (m *UsageStatisticDayMutation) AddStatus(u int8) {
  29199. if m.addstatus != nil {
  29200. *m.addstatus += u
  29201. } else {
  29202. m.addstatus = &u
  29203. }
  29204. }
  29205. // AddedStatus returns the value that was added to the "status" field in this mutation.
  29206. func (m *UsageStatisticDayMutation) AddedStatus() (r int8, exists bool) {
  29207. v := m.addstatus
  29208. if v == nil {
  29209. return
  29210. }
  29211. return *v, true
  29212. }
  29213. // ClearStatus clears the value of the "status" field.
  29214. func (m *UsageStatisticDayMutation) ClearStatus() {
  29215. m.status = nil
  29216. m.addstatus = nil
  29217. m.clearedFields[usagestatisticday.FieldStatus] = struct{}{}
  29218. }
  29219. // StatusCleared returns if the "status" field was cleared in this mutation.
  29220. func (m *UsageStatisticDayMutation) StatusCleared() bool {
  29221. _, ok := m.clearedFields[usagestatisticday.FieldStatus]
  29222. return ok
  29223. }
  29224. // ResetStatus resets all changes to the "status" field.
  29225. func (m *UsageStatisticDayMutation) ResetStatus() {
  29226. m.status = nil
  29227. m.addstatus = nil
  29228. delete(m.clearedFields, usagestatisticday.FieldStatus)
  29229. }
  29230. // SetDeletedAt sets the "deleted_at" field.
  29231. func (m *UsageStatisticDayMutation) SetDeletedAt(t time.Time) {
  29232. m.deleted_at = &t
  29233. }
  29234. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  29235. func (m *UsageStatisticDayMutation) DeletedAt() (r time.Time, exists bool) {
  29236. v := m.deleted_at
  29237. if v == nil {
  29238. return
  29239. }
  29240. return *v, true
  29241. }
  29242. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticDay entity.
  29243. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  29244. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29245. func (m *UsageStatisticDayMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  29246. if !m.op.Is(OpUpdateOne) {
  29247. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  29248. }
  29249. if m.id == nil || m.oldValue == nil {
  29250. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  29251. }
  29252. oldValue, err := m.oldValue(ctx)
  29253. if err != nil {
  29254. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  29255. }
  29256. return oldValue.DeletedAt, nil
  29257. }
  29258. // ClearDeletedAt clears the value of the "deleted_at" field.
  29259. func (m *UsageStatisticDayMutation) ClearDeletedAt() {
  29260. m.deleted_at = nil
  29261. m.clearedFields[usagestatisticday.FieldDeletedAt] = struct{}{}
  29262. }
  29263. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  29264. func (m *UsageStatisticDayMutation) DeletedAtCleared() bool {
  29265. _, ok := m.clearedFields[usagestatisticday.FieldDeletedAt]
  29266. return ok
  29267. }
  29268. // ResetDeletedAt resets all changes to the "deleted_at" field.
  29269. func (m *UsageStatisticDayMutation) ResetDeletedAt() {
  29270. m.deleted_at = nil
  29271. delete(m.clearedFields, usagestatisticday.FieldDeletedAt)
  29272. }
  29273. // SetAddtime sets the "addtime" field.
  29274. func (m *UsageStatisticDayMutation) SetAddtime(u uint64) {
  29275. m.addtime = &u
  29276. m.addaddtime = nil
  29277. }
  29278. // Addtime returns the value of the "addtime" field in the mutation.
  29279. func (m *UsageStatisticDayMutation) Addtime() (r uint64, exists bool) {
  29280. v := m.addtime
  29281. if v == nil {
  29282. return
  29283. }
  29284. return *v, true
  29285. }
  29286. // OldAddtime returns the old "addtime" field's value of the UsageStatisticDay entity.
  29287. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  29288. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29289. func (m *UsageStatisticDayMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  29290. if !m.op.Is(OpUpdateOne) {
  29291. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  29292. }
  29293. if m.id == nil || m.oldValue == nil {
  29294. return v, errors.New("OldAddtime requires an ID field in the mutation")
  29295. }
  29296. oldValue, err := m.oldValue(ctx)
  29297. if err != nil {
  29298. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  29299. }
  29300. return oldValue.Addtime, nil
  29301. }
  29302. // AddAddtime adds u to the "addtime" field.
  29303. func (m *UsageStatisticDayMutation) AddAddtime(u int64) {
  29304. if m.addaddtime != nil {
  29305. *m.addaddtime += u
  29306. } else {
  29307. m.addaddtime = &u
  29308. }
  29309. }
  29310. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  29311. func (m *UsageStatisticDayMutation) AddedAddtime() (r int64, exists bool) {
  29312. v := m.addaddtime
  29313. if v == nil {
  29314. return
  29315. }
  29316. return *v, true
  29317. }
  29318. // ResetAddtime resets all changes to the "addtime" field.
  29319. func (m *UsageStatisticDayMutation) ResetAddtime() {
  29320. m.addtime = nil
  29321. m.addaddtime = nil
  29322. }
  29323. // SetType sets the "type" field.
  29324. func (m *UsageStatisticDayMutation) SetType(i int) {
  29325. m._type = &i
  29326. m.add_type = nil
  29327. }
  29328. // GetType returns the value of the "type" field in the mutation.
  29329. func (m *UsageStatisticDayMutation) GetType() (r int, exists bool) {
  29330. v := m._type
  29331. if v == nil {
  29332. return
  29333. }
  29334. return *v, true
  29335. }
  29336. // OldType returns the old "type" field's value of the UsageStatisticDay entity.
  29337. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  29338. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29339. func (m *UsageStatisticDayMutation) OldType(ctx context.Context) (v int, err error) {
  29340. if !m.op.Is(OpUpdateOne) {
  29341. return v, errors.New("OldType is only allowed on UpdateOne operations")
  29342. }
  29343. if m.id == nil || m.oldValue == nil {
  29344. return v, errors.New("OldType requires an ID field in the mutation")
  29345. }
  29346. oldValue, err := m.oldValue(ctx)
  29347. if err != nil {
  29348. return v, fmt.Errorf("querying old value for OldType: %w", err)
  29349. }
  29350. return oldValue.Type, nil
  29351. }
  29352. // AddType adds i to the "type" field.
  29353. func (m *UsageStatisticDayMutation) AddType(i int) {
  29354. if m.add_type != nil {
  29355. *m.add_type += i
  29356. } else {
  29357. m.add_type = &i
  29358. }
  29359. }
  29360. // AddedType returns the value that was added to the "type" field in this mutation.
  29361. func (m *UsageStatisticDayMutation) AddedType() (r int, exists bool) {
  29362. v := m.add_type
  29363. if v == nil {
  29364. return
  29365. }
  29366. return *v, true
  29367. }
  29368. // ResetType resets all changes to the "type" field.
  29369. func (m *UsageStatisticDayMutation) ResetType() {
  29370. m._type = nil
  29371. m.add_type = nil
  29372. }
  29373. // SetBotID sets the "bot_id" field.
  29374. func (m *UsageStatisticDayMutation) SetBotID(s string) {
  29375. m.bot_id = &s
  29376. }
  29377. // BotID returns the value of the "bot_id" field in the mutation.
  29378. func (m *UsageStatisticDayMutation) BotID() (r string, exists bool) {
  29379. v := m.bot_id
  29380. if v == nil {
  29381. return
  29382. }
  29383. return *v, true
  29384. }
  29385. // OldBotID returns the old "bot_id" field's value of the UsageStatisticDay entity.
  29386. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  29387. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29388. func (m *UsageStatisticDayMutation) OldBotID(ctx context.Context) (v string, err error) {
  29389. if !m.op.Is(OpUpdateOne) {
  29390. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  29391. }
  29392. if m.id == nil || m.oldValue == nil {
  29393. return v, errors.New("OldBotID requires an ID field in the mutation")
  29394. }
  29395. oldValue, err := m.oldValue(ctx)
  29396. if err != nil {
  29397. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  29398. }
  29399. return oldValue.BotID, nil
  29400. }
  29401. // ClearBotID clears the value of the "bot_id" field.
  29402. func (m *UsageStatisticDayMutation) ClearBotID() {
  29403. m.bot_id = nil
  29404. m.clearedFields[usagestatisticday.FieldBotID] = struct{}{}
  29405. }
  29406. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  29407. func (m *UsageStatisticDayMutation) BotIDCleared() bool {
  29408. _, ok := m.clearedFields[usagestatisticday.FieldBotID]
  29409. return ok
  29410. }
  29411. // ResetBotID resets all changes to the "bot_id" field.
  29412. func (m *UsageStatisticDayMutation) ResetBotID() {
  29413. m.bot_id = nil
  29414. delete(m.clearedFields, usagestatisticday.FieldBotID)
  29415. }
  29416. // SetOrganizationID sets the "organization_id" field.
  29417. func (m *UsageStatisticDayMutation) SetOrganizationID(u uint64) {
  29418. m.organization_id = &u
  29419. m.addorganization_id = nil
  29420. }
  29421. // OrganizationID returns the value of the "organization_id" field in the mutation.
  29422. func (m *UsageStatisticDayMutation) OrganizationID() (r uint64, exists bool) {
  29423. v := m.organization_id
  29424. if v == nil {
  29425. return
  29426. }
  29427. return *v, true
  29428. }
  29429. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticDay entity.
  29430. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  29431. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29432. func (m *UsageStatisticDayMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  29433. if !m.op.Is(OpUpdateOne) {
  29434. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  29435. }
  29436. if m.id == nil || m.oldValue == nil {
  29437. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  29438. }
  29439. oldValue, err := m.oldValue(ctx)
  29440. if err != nil {
  29441. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  29442. }
  29443. return oldValue.OrganizationID, nil
  29444. }
  29445. // AddOrganizationID adds u to the "organization_id" field.
  29446. func (m *UsageStatisticDayMutation) AddOrganizationID(u int64) {
  29447. if m.addorganization_id != nil {
  29448. *m.addorganization_id += u
  29449. } else {
  29450. m.addorganization_id = &u
  29451. }
  29452. }
  29453. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  29454. func (m *UsageStatisticDayMutation) AddedOrganizationID() (r int64, exists bool) {
  29455. v := m.addorganization_id
  29456. if v == nil {
  29457. return
  29458. }
  29459. return *v, true
  29460. }
  29461. // ClearOrganizationID clears the value of the "organization_id" field.
  29462. func (m *UsageStatisticDayMutation) ClearOrganizationID() {
  29463. m.organization_id = nil
  29464. m.addorganization_id = nil
  29465. m.clearedFields[usagestatisticday.FieldOrganizationID] = struct{}{}
  29466. }
  29467. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  29468. func (m *UsageStatisticDayMutation) OrganizationIDCleared() bool {
  29469. _, ok := m.clearedFields[usagestatisticday.FieldOrganizationID]
  29470. return ok
  29471. }
  29472. // ResetOrganizationID resets all changes to the "organization_id" field.
  29473. func (m *UsageStatisticDayMutation) ResetOrganizationID() {
  29474. m.organization_id = nil
  29475. m.addorganization_id = nil
  29476. delete(m.clearedFields, usagestatisticday.FieldOrganizationID)
  29477. }
  29478. // SetAiResponse sets the "ai_response" field.
  29479. func (m *UsageStatisticDayMutation) SetAiResponse(u uint64) {
  29480. m.ai_response = &u
  29481. m.addai_response = nil
  29482. }
  29483. // AiResponse returns the value of the "ai_response" field in the mutation.
  29484. func (m *UsageStatisticDayMutation) AiResponse() (r uint64, exists bool) {
  29485. v := m.ai_response
  29486. if v == nil {
  29487. return
  29488. }
  29489. return *v, true
  29490. }
  29491. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticDay entity.
  29492. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  29493. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29494. func (m *UsageStatisticDayMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  29495. if !m.op.Is(OpUpdateOne) {
  29496. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  29497. }
  29498. if m.id == nil || m.oldValue == nil {
  29499. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  29500. }
  29501. oldValue, err := m.oldValue(ctx)
  29502. if err != nil {
  29503. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  29504. }
  29505. return oldValue.AiResponse, nil
  29506. }
  29507. // AddAiResponse adds u to the "ai_response" field.
  29508. func (m *UsageStatisticDayMutation) AddAiResponse(u int64) {
  29509. if m.addai_response != nil {
  29510. *m.addai_response += u
  29511. } else {
  29512. m.addai_response = &u
  29513. }
  29514. }
  29515. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  29516. func (m *UsageStatisticDayMutation) AddedAiResponse() (r int64, exists bool) {
  29517. v := m.addai_response
  29518. if v == nil {
  29519. return
  29520. }
  29521. return *v, true
  29522. }
  29523. // ResetAiResponse resets all changes to the "ai_response" field.
  29524. func (m *UsageStatisticDayMutation) ResetAiResponse() {
  29525. m.ai_response = nil
  29526. m.addai_response = nil
  29527. }
  29528. // SetSopRun sets the "sop_run" field.
  29529. func (m *UsageStatisticDayMutation) SetSopRun(u uint64) {
  29530. m.sop_run = &u
  29531. m.addsop_run = nil
  29532. }
  29533. // SopRun returns the value of the "sop_run" field in the mutation.
  29534. func (m *UsageStatisticDayMutation) SopRun() (r uint64, exists bool) {
  29535. v := m.sop_run
  29536. if v == nil {
  29537. return
  29538. }
  29539. return *v, true
  29540. }
  29541. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticDay entity.
  29542. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  29543. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29544. func (m *UsageStatisticDayMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  29545. if !m.op.Is(OpUpdateOne) {
  29546. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  29547. }
  29548. if m.id == nil || m.oldValue == nil {
  29549. return v, errors.New("OldSopRun requires an ID field in the mutation")
  29550. }
  29551. oldValue, err := m.oldValue(ctx)
  29552. if err != nil {
  29553. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  29554. }
  29555. return oldValue.SopRun, nil
  29556. }
  29557. // AddSopRun adds u to the "sop_run" field.
  29558. func (m *UsageStatisticDayMutation) AddSopRun(u int64) {
  29559. if m.addsop_run != nil {
  29560. *m.addsop_run += u
  29561. } else {
  29562. m.addsop_run = &u
  29563. }
  29564. }
  29565. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  29566. func (m *UsageStatisticDayMutation) AddedSopRun() (r int64, exists bool) {
  29567. v := m.addsop_run
  29568. if v == nil {
  29569. return
  29570. }
  29571. return *v, true
  29572. }
  29573. // ResetSopRun resets all changes to the "sop_run" field.
  29574. func (m *UsageStatisticDayMutation) ResetSopRun() {
  29575. m.sop_run = nil
  29576. m.addsop_run = nil
  29577. }
  29578. // SetTotalFriend sets the "total_friend" field.
  29579. func (m *UsageStatisticDayMutation) SetTotalFriend(u uint64) {
  29580. m.total_friend = &u
  29581. m.addtotal_friend = nil
  29582. }
  29583. // TotalFriend returns the value of the "total_friend" field in the mutation.
  29584. func (m *UsageStatisticDayMutation) TotalFriend() (r uint64, exists bool) {
  29585. v := m.total_friend
  29586. if v == nil {
  29587. return
  29588. }
  29589. return *v, true
  29590. }
  29591. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticDay entity.
  29592. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  29593. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29594. func (m *UsageStatisticDayMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  29595. if !m.op.Is(OpUpdateOne) {
  29596. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  29597. }
  29598. if m.id == nil || m.oldValue == nil {
  29599. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  29600. }
  29601. oldValue, err := m.oldValue(ctx)
  29602. if err != nil {
  29603. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  29604. }
  29605. return oldValue.TotalFriend, nil
  29606. }
  29607. // AddTotalFriend adds u to the "total_friend" field.
  29608. func (m *UsageStatisticDayMutation) AddTotalFriend(u int64) {
  29609. if m.addtotal_friend != nil {
  29610. *m.addtotal_friend += u
  29611. } else {
  29612. m.addtotal_friend = &u
  29613. }
  29614. }
  29615. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  29616. func (m *UsageStatisticDayMutation) AddedTotalFriend() (r int64, exists bool) {
  29617. v := m.addtotal_friend
  29618. if v == nil {
  29619. return
  29620. }
  29621. return *v, true
  29622. }
  29623. // ResetTotalFriend resets all changes to the "total_friend" field.
  29624. func (m *UsageStatisticDayMutation) ResetTotalFriend() {
  29625. m.total_friend = nil
  29626. m.addtotal_friend = nil
  29627. }
  29628. // SetTotalGroup sets the "total_group" field.
  29629. func (m *UsageStatisticDayMutation) SetTotalGroup(u uint64) {
  29630. m.total_group = &u
  29631. m.addtotal_group = nil
  29632. }
  29633. // TotalGroup returns the value of the "total_group" field in the mutation.
  29634. func (m *UsageStatisticDayMutation) TotalGroup() (r uint64, exists bool) {
  29635. v := m.total_group
  29636. if v == nil {
  29637. return
  29638. }
  29639. return *v, true
  29640. }
  29641. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticDay entity.
  29642. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  29643. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29644. func (m *UsageStatisticDayMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  29645. if !m.op.Is(OpUpdateOne) {
  29646. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  29647. }
  29648. if m.id == nil || m.oldValue == nil {
  29649. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  29650. }
  29651. oldValue, err := m.oldValue(ctx)
  29652. if err != nil {
  29653. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  29654. }
  29655. return oldValue.TotalGroup, nil
  29656. }
  29657. // AddTotalGroup adds u to the "total_group" field.
  29658. func (m *UsageStatisticDayMutation) AddTotalGroup(u int64) {
  29659. if m.addtotal_group != nil {
  29660. *m.addtotal_group += u
  29661. } else {
  29662. m.addtotal_group = &u
  29663. }
  29664. }
  29665. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  29666. func (m *UsageStatisticDayMutation) AddedTotalGroup() (r int64, exists bool) {
  29667. v := m.addtotal_group
  29668. if v == nil {
  29669. return
  29670. }
  29671. return *v, true
  29672. }
  29673. // ResetTotalGroup resets all changes to the "total_group" field.
  29674. func (m *UsageStatisticDayMutation) ResetTotalGroup() {
  29675. m.total_group = nil
  29676. m.addtotal_group = nil
  29677. }
  29678. // SetAccountBalance sets the "account_balance" field.
  29679. func (m *UsageStatisticDayMutation) SetAccountBalance(u uint64) {
  29680. m.account_balance = &u
  29681. m.addaccount_balance = nil
  29682. }
  29683. // AccountBalance returns the value of the "account_balance" field in the mutation.
  29684. func (m *UsageStatisticDayMutation) AccountBalance() (r uint64, exists bool) {
  29685. v := m.account_balance
  29686. if v == nil {
  29687. return
  29688. }
  29689. return *v, true
  29690. }
  29691. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticDay entity.
  29692. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  29693. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29694. func (m *UsageStatisticDayMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  29695. if !m.op.Is(OpUpdateOne) {
  29696. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  29697. }
  29698. if m.id == nil || m.oldValue == nil {
  29699. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  29700. }
  29701. oldValue, err := m.oldValue(ctx)
  29702. if err != nil {
  29703. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  29704. }
  29705. return oldValue.AccountBalance, nil
  29706. }
  29707. // AddAccountBalance adds u to the "account_balance" field.
  29708. func (m *UsageStatisticDayMutation) AddAccountBalance(u int64) {
  29709. if m.addaccount_balance != nil {
  29710. *m.addaccount_balance += u
  29711. } else {
  29712. m.addaccount_balance = &u
  29713. }
  29714. }
  29715. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  29716. func (m *UsageStatisticDayMutation) AddedAccountBalance() (r int64, exists bool) {
  29717. v := m.addaccount_balance
  29718. if v == nil {
  29719. return
  29720. }
  29721. return *v, true
  29722. }
  29723. // ResetAccountBalance resets all changes to the "account_balance" field.
  29724. func (m *UsageStatisticDayMutation) ResetAccountBalance() {
  29725. m.account_balance = nil
  29726. m.addaccount_balance = nil
  29727. }
  29728. // SetConsumeToken sets the "consume_token" field.
  29729. func (m *UsageStatisticDayMutation) SetConsumeToken(u uint64) {
  29730. m.consume_token = &u
  29731. m.addconsume_token = nil
  29732. }
  29733. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  29734. func (m *UsageStatisticDayMutation) ConsumeToken() (r uint64, exists bool) {
  29735. v := m.consume_token
  29736. if v == nil {
  29737. return
  29738. }
  29739. return *v, true
  29740. }
  29741. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticDay entity.
  29742. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  29743. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29744. func (m *UsageStatisticDayMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  29745. if !m.op.Is(OpUpdateOne) {
  29746. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  29747. }
  29748. if m.id == nil || m.oldValue == nil {
  29749. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  29750. }
  29751. oldValue, err := m.oldValue(ctx)
  29752. if err != nil {
  29753. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  29754. }
  29755. return oldValue.ConsumeToken, nil
  29756. }
  29757. // AddConsumeToken adds u to the "consume_token" field.
  29758. func (m *UsageStatisticDayMutation) AddConsumeToken(u int64) {
  29759. if m.addconsume_token != nil {
  29760. *m.addconsume_token += u
  29761. } else {
  29762. m.addconsume_token = &u
  29763. }
  29764. }
  29765. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  29766. func (m *UsageStatisticDayMutation) AddedConsumeToken() (r int64, exists bool) {
  29767. v := m.addconsume_token
  29768. if v == nil {
  29769. return
  29770. }
  29771. return *v, true
  29772. }
  29773. // ResetConsumeToken resets all changes to the "consume_token" field.
  29774. func (m *UsageStatisticDayMutation) ResetConsumeToken() {
  29775. m.consume_token = nil
  29776. m.addconsume_token = nil
  29777. }
  29778. // SetActiveUser sets the "active_user" field.
  29779. func (m *UsageStatisticDayMutation) SetActiveUser(u uint64) {
  29780. m.active_user = &u
  29781. m.addactive_user = nil
  29782. }
  29783. // ActiveUser returns the value of the "active_user" field in the mutation.
  29784. func (m *UsageStatisticDayMutation) ActiveUser() (r uint64, exists bool) {
  29785. v := m.active_user
  29786. if v == nil {
  29787. return
  29788. }
  29789. return *v, true
  29790. }
  29791. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticDay entity.
  29792. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  29793. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29794. func (m *UsageStatisticDayMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  29795. if !m.op.Is(OpUpdateOne) {
  29796. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  29797. }
  29798. if m.id == nil || m.oldValue == nil {
  29799. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  29800. }
  29801. oldValue, err := m.oldValue(ctx)
  29802. if err != nil {
  29803. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  29804. }
  29805. return oldValue.ActiveUser, nil
  29806. }
  29807. // AddActiveUser adds u to the "active_user" field.
  29808. func (m *UsageStatisticDayMutation) AddActiveUser(u int64) {
  29809. if m.addactive_user != nil {
  29810. *m.addactive_user += u
  29811. } else {
  29812. m.addactive_user = &u
  29813. }
  29814. }
  29815. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  29816. func (m *UsageStatisticDayMutation) AddedActiveUser() (r int64, exists bool) {
  29817. v := m.addactive_user
  29818. if v == nil {
  29819. return
  29820. }
  29821. return *v, true
  29822. }
  29823. // ResetActiveUser resets all changes to the "active_user" field.
  29824. func (m *UsageStatisticDayMutation) ResetActiveUser() {
  29825. m.active_user = nil
  29826. m.addactive_user = nil
  29827. }
  29828. // SetNewUser sets the "new_user" field.
  29829. func (m *UsageStatisticDayMutation) SetNewUser(i int64) {
  29830. m.new_user = &i
  29831. m.addnew_user = nil
  29832. }
  29833. // NewUser returns the value of the "new_user" field in the mutation.
  29834. func (m *UsageStatisticDayMutation) NewUser() (r int64, exists bool) {
  29835. v := m.new_user
  29836. if v == nil {
  29837. return
  29838. }
  29839. return *v, true
  29840. }
  29841. // OldNewUser returns the old "new_user" field's value of the UsageStatisticDay entity.
  29842. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  29843. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29844. func (m *UsageStatisticDayMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  29845. if !m.op.Is(OpUpdateOne) {
  29846. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  29847. }
  29848. if m.id == nil || m.oldValue == nil {
  29849. return v, errors.New("OldNewUser requires an ID field in the mutation")
  29850. }
  29851. oldValue, err := m.oldValue(ctx)
  29852. if err != nil {
  29853. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  29854. }
  29855. return oldValue.NewUser, nil
  29856. }
  29857. // AddNewUser adds i to the "new_user" field.
  29858. func (m *UsageStatisticDayMutation) AddNewUser(i int64) {
  29859. if m.addnew_user != nil {
  29860. *m.addnew_user += i
  29861. } else {
  29862. m.addnew_user = &i
  29863. }
  29864. }
  29865. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  29866. func (m *UsageStatisticDayMutation) AddedNewUser() (r int64, exists bool) {
  29867. v := m.addnew_user
  29868. if v == nil {
  29869. return
  29870. }
  29871. return *v, true
  29872. }
  29873. // ResetNewUser resets all changes to the "new_user" field.
  29874. func (m *UsageStatisticDayMutation) ResetNewUser() {
  29875. m.new_user = nil
  29876. m.addnew_user = nil
  29877. }
  29878. // SetLabelDist sets the "label_dist" field.
  29879. func (m *UsageStatisticDayMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  29880. m.label_dist = &ctd
  29881. m.appendlabel_dist = nil
  29882. }
  29883. // LabelDist returns the value of the "label_dist" field in the mutation.
  29884. func (m *UsageStatisticDayMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  29885. v := m.label_dist
  29886. if v == nil {
  29887. return
  29888. }
  29889. return *v, true
  29890. }
  29891. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticDay entity.
  29892. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  29893. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29894. func (m *UsageStatisticDayMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  29895. if !m.op.Is(OpUpdateOne) {
  29896. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  29897. }
  29898. if m.id == nil || m.oldValue == nil {
  29899. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  29900. }
  29901. oldValue, err := m.oldValue(ctx)
  29902. if err != nil {
  29903. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  29904. }
  29905. return oldValue.LabelDist, nil
  29906. }
  29907. // AppendLabelDist adds ctd to the "label_dist" field.
  29908. func (m *UsageStatisticDayMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  29909. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  29910. }
  29911. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  29912. func (m *UsageStatisticDayMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  29913. if len(m.appendlabel_dist) == 0 {
  29914. return nil, false
  29915. }
  29916. return m.appendlabel_dist, true
  29917. }
  29918. // ResetLabelDist resets all changes to the "label_dist" field.
  29919. func (m *UsageStatisticDayMutation) ResetLabelDist() {
  29920. m.label_dist = nil
  29921. m.appendlabel_dist = nil
  29922. }
  29923. // Where appends a list predicates to the UsageStatisticDayMutation builder.
  29924. func (m *UsageStatisticDayMutation) Where(ps ...predicate.UsageStatisticDay) {
  29925. m.predicates = append(m.predicates, ps...)
  29926. }
  29927. // WhereP appends storage-level predicates to the UsageStatisticDayMutation builder. Using this method,
  29928. // users can use type-assertion to append predicates that do not depend on any generated package.
  29929. func (m *UsageStatisticDayMutation) WhereP(ps ...func(*sql.Selector)) {
  29930. p := make([]predicate.UsageStatisticDay, len(ps))
  29931. for i := range ps {
  29932. p[i] = ps[i]
  29933. }
  29934. m.Where(p...)
  29935. }
  29936. // Op returns the operation name.
  29937. func (m *UsageStatisticDayMutation) Op() Op {
  29938. return m.op
  29939. }
  29940. // SetOp allows setting the mutation operation.
  29941. func (m *UsageStatisticDayMutation) SetOp(op Op) {
  29942. m.op = op
  29943. }
  29944. // Type returns the node type of this mutation (UsageStatisticDay).
  29945. func (m *UsageStatisticDayMutation) Type() string {
  29946. return m.typ
  29947. }
  29948. // Fields returns all fields that were changed during this mutation. Note that in
  29949. // order to get all numeric fields that were incremented/decremented, call
  29950. // AddedFields().
  29951. func (m *UsageStatisticDayMutation) Fields() []string {
  29952. fields := make([]string, 0, 17)
  29953. if m.created_at != nil {
  29954. fields = append(fields, usagestatisticday.FieldCreatedAt)
  29955. }
  29956. if m.updated_at != nil {
  29957. fields = append(fields, usagestatisticday.FieldUpdatedAt)
  29958. }
  29959. if m.status != nil {
  29960. fields = append(fields, usagestatisticday.FieldStatus)
  29961. }
  29962. if m.deleted_at != nil {
  29963. fields = append(fields, usagestatisticday.FieldDeletedAt)
  29964. }
  29965. if m.addtime != nil {
  29966. fields = append(fields, usagestatisticday.FieldAddtime)
  29967. }
  29968. if m._type != nil {
  29969. fields = append(fields, usagestatisticday.FieldType)
  29970. }
  29971. if m.bot_id != nil {
  29972. fields = append(fields, usagestatisticday.FieldBotID)
  29973. }
  29974. if m.organization_id != nil {
  29975. fields = append(fields, usagestatisticday.FieldOrganizationID)
  29976. }
  29977. if m.ai_response != nil {
  29978. fields = append(fields, usagestatisticday.FieldAiResponse)
  29979. }
  29980. if m.sop_run != nil {
  29981. fields = append(fields, usagestatisticday.FieldSopRun)
  29982. }
  29983. if m.total_friend != nil {
  29984. fields = append(fields, usagestatisticday.FieldTotalFriend)
  29985. }
  29986. if m.total_group != nil {
  29987. fields = append(fields, usagestatisticday.FieldTotalGroup)
  29988. }
  29989. if m.account_balance != nil {
  29990. fields = append(fields, usagestatisticday.FieldAccountBalance)
  29991. }
  29992. if m.consume_token != nil {
  29993. fields = append(fields, usagestatisticday.FieldConsumeToken)
  29994. }
  29995. if m.active_user != nil {
  29996. fields = append(fields, usagestatisticday.FieldActiveUser)
  29997. }
  29998. if m.new_user != nil {
  29999. fields = append(fields, usagestatisticday.FieldNewUser)
  30000. }
  30001. if m.label_dist != nil {
  30002. fields = append(fields, usagestatisticday.FieldLabelDist)
  30003. }
  30004. return fields
  30005. }
  30006. // Field returns the value of a field with the given name. The second boolean
  30007. // return value indicates that this field was not set, or was not defined in the
  30008. // schema.
  30009. func (m *UsageStatisticDayMutation) Field(name string) (ent.Value, bool) {
  30010. switch name {
  30011. case usagestatisticday.FieldCreatedAt:
  30012. return m.CreatedAt()
  30013. case usagestatisticday.FieldUpdatedAt:
  30014. return m.UpdatedAt()
  30015. case usagestatisticday.FieldStatus:
  30016. return m.Status()
  30017. case usagestatisticday.FieldDeletedAt:
  30018. return m.DeletedAt()
  30019. case usagestatisticday.FieldAddtime:
  30020. return m.Addtime()
  30021. case usagestatisticday.FieldType:
  30022. return m.GetType()
  30023. case usagestatisticday.FieldBotID:
  30024. return m.BotID()
  30025. case usagestatisticday.FieldOrganizationID:
  30026. return m.OrganizationID()
  30027. case usagestatisticday.FieldAiResponse:
  30028. return m.AiResponse()
  30029. case usagestatisticday.FieldSopRun:
  30030. return m.SopRun()
  30031. case usagestatisticday.FieldTotalFriend:
  30032. return m.TotalFriend()
  30033. case usagestatisticday.FieldTotalGroup:
  30034. return m.TotalGroup()
  30035. case usagestatisticday.FieldAccountBalance:
  30036. return m.AccountBalance()
  30037. case usagestatisticday.FieldConsumeToken:
  30038. return m.ConsumeToken()
  30039. case usagestatisticday.FieldActiveUser:
  30040. return m.ActiveUser()
  30041. case usagestatisticday.FieldNewUser:
  30042. return m.NewUser()
  30043. case usagestatisticday.FieldLabelDist:
  30044. return m.LabelDist()
  30045. }
  30046. return nil, false
  30047. }
  30048. // OldField returns the old value of the field from the database. An error is
  30049. // returned if the mutation operation is not UpdateOne, or the query to the
  30050. // database failed.
  30051. func (m *UsageStatisticDayMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  30052. switch name {
  30053. case usagestatisticday.FieldCreatedAt:
  30054. return m.OldCreatedAt(ctx)
  30055. case usagestatisticday.FieldUpdatedAt:
  30056. return m.OldUpdatedAt(ctx)
  30057. case usagestatisticday.FieldStatus:
  30058. return m.OldStatus(ctx)
  30059. case usagestatisticday.FieldDeletedAt:
  30060. return m.OldDeletedAt(ctx)
  30061. case usagestatisticday.FieldAddtime:
  30062. return m.OldAddtime(ctx)
  30063. case usagestatisticday.FieldType:
  30064. return m.OldType(ctx)
  30065. case usagestatisticday.FieldBotID:
  30066. return m.OldBotID(ctx)
  30067. case usagestatisticday.FieldOrganizationID:
  30068. return m.OldOrganizationID(ctx)
  30069. case usagestatisticday.FieldAiResponse:
  30070. return m.OldAiResponse(ctx)
  30071. case usagestatisticday.FieldSopRun:
  30072. return m.OldSopRun(ctx)
  30073. case usagestatisticday.FieldTotalFriend:
  30074. return m.OldTotalFriend(ctx)
  30075. case usagestatisticday.FieldTotalGroup:
  30076. return m.OldTotalGroup(ctx)
  30077. case usagestatisticday.FieldAccountBalance:
  30078. return m.OldAccountBalance(ctx)
  30079. case usagestatisticday.FieldConsumeToken:
  30080. return m.OldConsumeToken(ctx)
  30081. case usagestatisticday.FieldActiveUser:
  30082. return m.OldActiveUser(ctx)
  30083. case usagestatisticday.FieldNewUser:
  30084. return m.OldNewUser(ctx)
  30085. case usagestatisticday.FieldLabelDist:
  30086. return m.OldLabelDist(ctx)
  30087. }
  30088. return nil, fmt.Errorf("unknown UsageStatisticDay field %s", name)
  30089. }
  30090. // SetField sets the value of a field with the given name. It returns an error if
  30091. // the field is not defined in the schema, or if the type mismatched the field
  30092. // type.
  30093. func (m *UsageStatisticDayMutation) SetField(name string, value ent.Value) error {
  30094. switch name {
  30095. case usagestatisticday.FieldCreatedAt:
  30096. v, ok := value.(time.Time)
  30097. if !ok {
  30098. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30099. }
  30100. m.SetCreatedAt(v)
  30101. return nil
  30102. case usagestatisticday.FieldUpdatedAt:
  30103. v, ok := value.(time.Time)
  30104. if !ok {
  30105. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30106. }
  30107. m.SetUpdatedAt(v)
  30108. return nil
  30109. case usagestatisticday.FieldStatus:
  30110. v, ok := value.(uint8)
  30111. if !ok {
  30112. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30113. }
  30114. m.SetStatus(v)
  30115. return nil
  30116. case usagestatisticday.FieldDeletedAt:
  30117. v, ok := value.(time.Time)
  30118. if !ok {
  30119. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30120. }
  30121. m.SetDeletedAt(v)
  30122. return nil
  30123. case usagestatisticday.FieldAddtime:
  30124. v, ok := value.(uint64)
  30125. if !ok {
  30126. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30127. }
  30128. m.SetAddtime(v)
  30129. return nil
  30130. case usagestatisticday.FieldType:
  30131. v, ok := value.(int)
  30132. if !ok {
  30133. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30134. }
  30135. m.SetType(v)
  30136. return nil
  30137. case usagestatisticday.FieldBotID:
  30138. v, ok := value.(string)
  30139. if !ok {
  30140. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30141. }
  30142. m.SetBotID(v)
  30143. return nil
  30144. case usagestatisticday.FieldOrganizationID:
  30145. v, ok := value.(uint64)
  30146. if !ok {
  30147. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30148. }
  30149. m.SetOrganizationID(v)
  30150. return nil
  30151. case usagestatisticday.FieldAiResponse:
  30152. v, ok := value.(uint64)
  30153. if !ok {
  30154. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30155. }
  30156. m.SetAiResponse(v)
  30157. return nil
  30158. case usagestatisticday.FieldSopRun:
  30159. v, ok := value.(uint64)
  30160. if !ok {
  30161. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30162. }
  30163. m.SetSopRun(v)
  30164. return nil
  30165. case usagestatisticday.FieldTotalFriend:
  30166. v, ok := value.(uint64)
  30167. if !ok {
  30168. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30169. }
  30170. m.SetTotalFriend(v)
  30171. return nil
  30172. case usagestatisticday.FieldTotalGroup:
  30173. v, ok := value.(uint64)
  30174. if !ok {
  30175. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30176. }
  30177. m.SetTotalGroup(v)
  30178. return nil
  30179. case usagestatisticday.FieldAccountBalance:
  30180. v, ok := value.(uint64)
  30181. if !ok {
  30182. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30183. }
  30184. m.SetAccountBalance(v)
  30185. return nil
  30186. case usagestatisticday.FieldConsumeToken:
  30187. v, ok := value.(uint64)
  30188. if !ok {
  30189. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30190. }
  30191. m.SetConsumeToken(v)
  30192. return nil
  30193. case usagestatisticday.FieldActiveUser:
  30194. v, ok := value.(uint64)
  30195. if !ok {
  30196. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30197. }
  30198. m.SetActiveUser(v)
  30199. return nil
  30200. case usagestatisticday.FieldNewUser:
  30201. v, ok := value.(int64)
  30202. if !ok {
  30203. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30204. }
  30205. m.SetNewUser(v)
  30206. return nil
  30207. case usagestatisticday.FieldLabelDist:
  30208. v, ok := value.([]custom_types.LabelDist)
  30209. if !ok {
  30210. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30211. }
  30212. m.SetLabelDist(v)
  30213. return nil
  30214. }
  30215. return fmt.Errorf("unknown UsageStatisticDay field %s", name)
  30216. }
  30217. // AddedFields returns all numeric fields that were incremented/decremented during
  30218. // this mutation.
  30219. func (m *UsageStatisticDayMutation) AddedFields() []string {
  30220. var fields []string
  30221. if m.addstatus != nil {
  30222. fields = append(fields, usagestatisticday.FieldStatus)
  30223. }
  30224. if m.addaddtime != nil {
  30225. fields = append(fields, usagestatisticday.FieldAddtime)
  30226. }
  30227. if m.add_type != nil {
  30228. fields = append(fields, usagestatisticday.FieldType)
  30229. }
  30230. if m.addorganization_id != nil {
  30231. fields = append(fields, usagestatisticday.FieldOrganizationID)
  30232. }
  30233. if m.addai_response != nil {
  30234. fields = append(fields, usagestatisticday.FieldAiResponse)
  30235. }
  30236. if m.addsop_run != nil {
  30237. fields = append(fields, usagestatisticday.FieldSopRun)
  30238. }
  30239. if m.addtotal_friend != nil {
  30240. fields = append(fields, usagestatisticday.FieldTotalFriend)
  30241. }
  30242. if m.addtotal_group != nil {
  30243. fields = append(fields, usagestatisticday.FieldTotalGroup)
  30244. }
  30245. if m.addaccount_balance != nil {
  30246. fields = append(fields, usagestatisticday.FieldAccountBalance)
  30247. }
  30248. if m.addconsume_token != nil {
  30249. fields = append(fields, usagestatisticday.FieldConsumeToken)
  30250. }
  30251. if m.addactive_user != nil {
  30252. fields = append(fields, usagestatisticday.FieldActiveUser)
  30253. }
  30254. if m.addnew_user != nil {
  30255. fields = append(fields, usagestatisticday.FieldNewUser)
  30256. }
  30257. return fields
  30258. }
  30259. // AddedField returns the numeric value that was incremented/decremented on a field
  30260. // with the given name. The second boolean return value indicates that this field
  30261. // was not set, or was not defined in the schema.
  30262. func (m *UsageStatisticDayMutation) AddedField(name string) (ent.Value, bool) {
  30263. switch name {
  30264. case usagestatisticday.FieldStatus:
  30265. return m.AddedStatus()
  30266. case usagestatisticday.FieldAddtime:
  30267. return m.AddedAddtime()
  30268. case usagestatisticday.FieldType:
  30269. return m.AddedType()
  30270. case usagestatisticday.FieldOrganizationID:
  30271. return m.AddedOrganizationID()
  30272. case usagestatisticday.FieldAiResponse:
  30273. return m.AddedAiResponse()
  30274. case usagestatisticday.FieldSopRun:
  30275. return m.AddedSopRun()
  30276. case usagestatisticday.FieldTotalFriend:
  30277. return m.AddedTotalFriend()
  30278. case usagestatisticday.FieldTotalGroup:
  30279. return m.AddedTotalGroup()
  30280. case usagestatisticday.FieldAccountBalance:
  30281. return m.AddedAccountBalance()
  30282. case usagestatisticday.FieldConsumeToken:
  30283. return m.AddedConsumeToken()
  30284. case usagestatisticday.FieldActiveUser:
  30285. return m.AddedActiveUser()
  30286. case usagestatisticday.FieldNewUser:
  30287. return m.AddedNewUser()
  30288. }
  30289. return nil, false
  30290. }
  30291. // AddField adds the value to the field with the given name. It returns an error if
  30292. // the field is not defined in the schema, or if the type mismatched the field
  30293. // type.
  30294. func (m *UsageStatisticDayMutation) AddField(name string, value ent.Value) error {
  30295. switch name {
  30296. case usagestatisticday.FieldStatus:
  30297. v, ok := value.(int8)
  30298. if !ok {
  30299. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30300. }
  30301. m.AddStatus(v)
  30302. return nil
  30303. case usagestatisticday.FieldAddtime:
  30304. v, ok := value.(int64)
  30305. if !ok {
  30306. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30307. }
  30308. m.AddAddtime(v)
  30309. return nil
  30310. case usagestatisticday.FieldType:
  30311. v, ok := value.(int)
  30312. if !ok {
  30313. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30314. }
  30315. m.AddType(v)
  30316. return nil
  30317. case usagestatisticday.FieldOrganizationID:
  30318. v, ok := value.(int64)
  30319. if !ok {
  30320. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30321. }
  30322. m.AddOrganizationID(v)
  30323. return nil
  30324. case usagestatisticday.FieldAiResponse:
  30325. v, ok := value.(int64)
  30326. if !ok {
  30327. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30328. }
  30329. m.AddAiResponse(v)
  30330. return nil
  30331. case usagestatisticday.FieldSopRun:
  30332. v, ok := value.(int64)
  30333. if !ok {
  30334. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30335. }
  30336. m.AddSopRun(v)
  30337. return nil
  30338. case usagestatisticday.FieldTotalFriend:
  30339. v, ok := value.(int64)
  30340. if !ok {
  30341. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30342. }
  30343. m.AddTotalFriend(v)
  30344. return nil
  30345. case usagestatisticday.FieldTotalGroup:
  30346. v, ok := value.(int64)
  30347. if !ok {
  30348. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30349. }
  30350. m.AddTotalGroup(v)
  30351. return nil
  30352. case usagestatisticday.FieldAccountBalance:
  30353. v, ok := value.(int64)
  30354. if !ok {
  30355. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30356. }
  30357. m.AddAccountBalance(v)
  30358. return nil
  30359. case usagestatisticday.FieldConsumeToken:
  30360. v, ok := value.(int64)
  30361. if !ok {
  30362. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30363. }
  30364. m.AddConsumeToken(v)
  30365. return nil
  30366. case usagestatisticday.FieldActiveUser:
  30367. v, ok := value.(int64)
  30368. if !ok {
  30369. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30370. }
  30371. m.AddActiveUser(v)
  30372. return nil
  30373. case usagestatisticday.FieldNewUser:
  30374. v, ok := value.(int64)
  30375. if !ok {
  30376. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30377. }
  30378. m.AddNewUser(v)
  30379. return nil
  30380. }
  30381. return fmt.Errorf("unknown UsageStatisticDay numeric field %s", name)
  30382. }
  30383. // ClearedFields returns all nullable fields that were cleared during this
  30384. // mutation.
  30385. func (m *UsageStatisticDayMutation) ClearedFields() []string {
  30386. var fields []string
  30387. if m.FieldCleared(usagestatisticday.FieldStatus) {
  30388. fields = append(fields, usagestatisticday.FieldStatus)
  30389. }
  30390. if m.FieldCleared(usagestatisticday.FieldDeletedAt) {
  30391. fields = append(fields, usagestatisticday.FieldDeletedAt)
  30392. }
  30393. if m.FieldCleared(usagestatisticday.FieldBotID) {
  30394. fields = append(fields, usagestatisticday.FieldBotID)
  30395. }
  30396. if m.FieldCleared(usagestatisticday.FieldOrganizationID) {
  30397. fields = append(fields, usagestatisticday.FieldOrganizationID)
  30398. }
  30399. return fields
  30400. }
  30401. // FieldCleared returns a boolean indicating if a field with the given name was
  30402. // cleared in this mutation.
  30403. func (m *UsageStatisticDayMutation) FieldCleared(name string) bool {
  30404. _, ok := m.clearedFields[name]
  30405. return ok
  30406. }
  30407. // ClearField clears the value of the field with the given name. It returns an
  30408. // error if the field is not defined in the schema.
  30409. func (m *UsageStatisticDayMutation) ClearField(name string) error {
  30410. switch name {
  30411. case usagestatisticday.FieldStatus:
  30412. m.ClearStatus()
  30413. return nil
  30414. case usagestatisticday.FieldDeletedAt:
  30415. m.ClearDeletedAt()
  30416. return nil
  30417. case usagestatisticday.FieldBotID:
  30418. m.ClearBotID()
  30419. return nil
  30420. case usagestatisticday.FieldOrganizationID:
  30421. m.ClearOrganizationID()
  30422. return nil
  30423. }
  30424. return fmt.Errorf("unknown UsageStatisticDay nullable field %s", name)
  30425. }
  30426. // ResetField resets all changes in the mutation for the field with the given name.
  30427. // It returns an error if the field is not defined in the schema.
  30428. func (m *UsageStatisticDayMutation) ResetField(name string) error {
  30429. switch name {
  30430. case usagestatisticday.FieldCreatedAt:
  30431. m.ResetCreatedAt()
  30432. return nil
  30433. case usagestatisticday.FieldUpdatedAt:
  30434. m.ResetUpdatedAt()
  30435. return nil
  30436. case usagestatisticday.FieldStatus:
  30437. m.ResetStatus()
  30438. return nil
  30439. case usagestatisticday.FieldDeletedAt:
  30440. m.ResetDeletedAt()
  30441. return nil
  30442. case usagestatisticday.FieldAddtime:
  30443. m.ResetAddtime()
  30444. return nil
  30445. case usagestatisticday.FieldType:
  30446. m.ResetType()
  30447. return nil
  30448. case usagestatisticday.FieldBotID:
  30449. m.ResetBotID()
  30450. return nil
  30451. case usagestatisticday.FieldOrganizationID:
  30452. m.ResetOrganizationID()
  30453. return nil
  30454. case usagestatisticday.FieldAiResponse:
  30455. m.ResetAiResponse()
  30456. return nil
  30457. case usagestatisticday.FieldSopRun:
  30458. m.ResetSopRun()
  30459. return nil
  30460. case usagestatisticday.FieldTotalFriend:
  30461. m.ResetTotalFriend()
  30462. return nil
  30463. case usagestatisticday.FieldTotalGroup:
  30464. m.ResetTotalGroup()
  30465. return nil
  30466. case usagestatisticday.FieldAccountBalance:
  30467. m.ResetAccountBalance()
  30468. return nil
  30469. case usagestatisticday.FieldConsumeToken:
  30470. m.ResetConsumeToken()
  30471. return nil
  30472. case usagestatisticday.FieldActiveUser:
  30473. m.ResetActiveUser()
  30474. return nil
  30475. case usagestatisticday.FieldNewUser:
  30476. m.ResetNewUser()
  30477. return nil
  30478. case usagestatisticday.FieldLabelDist:
  30479. m.ResetLabelDist()
  30480. return nil
  30481. }
  30482. return fmt.Errorf("unknown UsageStatisticDay field %s", name)
  30483. }
  30484. // AddedEdges returns all edge names that were set/added in this mutation.
  30485. func (m *UsageStatisticDayMutation) AddedEdges() []string {
  30486. edges := make([]string, 0, 0)
  30487. return edges
  30488. }
  30489. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  30490. // name in this mutation.
  30491. func (m *UsageStatisticDayMutation) AddedIDs(name string) []ent.Value {
  30492. return nil
  30493. }
  30494. // RemovedEdges returns all edge names that were removed in this mutation.
  30495. func (m *UsageStatisticDayMutation) RemovedEdges() []string {
  30496. edges := make([]string, 0, 0)
  30497. return edges
  30498. }
  30499. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  30500. // the given name in this mutation.
  30501. func (m *UsageStatisticDayMutation) RemovedIDs(name string) []ent.Value {
  30502. return nil
  30503. }
  30504. // ClearedEdges returns all edge names that were cleared in this mutation.
  30505. func (m *UsageStatisticDayMutation) ClearedEdges() []string {
  30506. edges := make([]string, 0, 0)
  30507. return edges
  30508. }
  30509. // EdgeCleared returns a boolean which indicates if the edge with the given name
  30510. // was cleared in this mutation.
  30511. func (m *UsageStatisticDayMutation) EdgeCleared(name string) bool {
  30512. return false
  30513. }
  30514. // ClearEdge clears the value of the edge with the given name. It returns an error
  30515. // if that edge is not defined in the schema.
  30516. func (m *UsageStatisticDayMutation) ClearEdge(name string) error {
  30517. return fmt.Errorf("unknown UsageStatisticDay unique edge %s", name)
  30518. }
  30519. // ResetEdge resets all changes to the edge with the given name in this mutation.
  30520. // It returns an error if the edge is not defined in the schema.
  30521. func (m *UsageStatisticDayMutation) ResetEdge(name string) error {
  30522. return fmt.Errorf("unknown UsageStatisticDay edge %s", name)
  30523. }
  30524. // UsageStatisticHourMutation represents an operation that mutates the UsageStatisticHour nodes in the graph.
  30525. type UsageStatisticHourMutation struct {
  30526. config
  30527. op Op
  30528. typ string
  30529. id *uint64
  30530. created_at *time.Time
  30531. updated_at *time.Time
  30532. status *uint8
  30533. addstatus *int8
  30534. deleted_at *time.Time
  30535. addtime *uint64
  30536. addaddtime *int64
  30537. _type *int
  30538. add_type *int
  30539. bot_id *string
  30540. organization_id *uint64
  30541. addorganization_id *int64
  30542. ai_response *uint64
  30543. addai_response *int64
  30544. sop_run *uint64
  30545. addsop_run *int64
  30546. total_friend *uint64
  30547. addtotal_friend *int64
  30548. total_group *uint64
  30549. addtotal_group *int64
  30550. account_balance *uint64
  30551. addaccount_balance *int64
  30552. consume_token *uint64
  30553. addconsume_token *int64
  30554. active_user *uint64
  30555. addactive_user *int64
  30556. new_user *int64
  30557. addnew_user *int64
  30558. label_dist *[]custom_types.LabelDist
  30559. appendlabel_dist []custom_types.LabelDist
  30560. clearedFields map[string]struct{}
  30561. done bool
  30562. oldValue func(context.Context) (*UsageStatisticHour, error)
  30563. predicates []predicate.UsageStatisticHour
  30564. }
  30565. var _ ent.Mutation = (*UsageStatisticHourMutation)(nil)
  30566. // usagestatistichourOption allows management of the mutation configuration using functional options.
  30567. type usagestatistichourOption func(*UsageStatisticHourMutation)
  30568. // newUsageStatisticHourMutation creates new mutation for the UsageStatisticHour entity.
  30569. func newUsageStatisticHourMutation(c config, op Op, opts ...usagestatistichourOption) *UsageStatisticHourMutation {
  30570. m := &UsageStatisticHourMutation{
  30571. config: c,
  30572. op: op,
  30573. typ: TypeUsageStatisticHour,
  30574. clearedFields: make(map[string]struct{}),
  30575. }
  30576. for _, opt := range opts {
  30577. opt(m)
  30578. }
  30579. return m
  30580. }
  30581. // withUsageStatisticHourID sets the ID field of the mutation.
  30582. func withUsageStatisticHourID(id uint64) usagestatistichourOption {
  30583. return func(m *UsageStatisticHourMutation) {
  30584. var (
  30585. err error
  30586. once sync.Once
  30587. value *UsageStatisticHour
  30588. )
  30589. m.oldValue = func(ctx context.Context) (*UsageStatisticHour, error) {
  30590. once.Do(func() {
  30591. if m.done {
  30592. err = errors.New("querying old values post mutation is not allowed")
  30593. } else {
  30594. value, err = m.Client().UsageStatisticHour.Get(ctx, id)
  30595. }
  30596. })
  30597. return value, err
  30598. }
  30599. m.id = &id
  30600. }
  30601. }
  30602. // withUsageStatisticHour sets the old UsageStatisticHour of the mutation.
  30603. func withUsageStatisticHour(node *UsageStatisticHour) usagestatistichourOption {
  30604. return func(m *UsageStatisticHourMutation) {
  30605. m.oldValue = func(context.Context) (*UsageStatisticHour, error) {
  30606. return node, nil
  30607. }
  30608. m.id = &node.ID
  30609. }
  30610. }
  30611. // Client returns a new `ent.Client` from the mutation. If the mutation was
  30612. // executed in a transaction (ent.Tx), a transactional client is returned.
  30613. func (m UsageStatisticHourMutation) Client() *Client {
  30614. client := &Client{config: m.config}
  30615. client.init()
  30616. return client
  30617. }
  30618. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  30619. // it returns an error otherwise.
  30620. func (m UsageStatisticHourMutation) Tx() (*Tx, error) {
  30621. if _, ok := m.driver.(*txDriver); !ok {
  30622. return nil, errors.New("ent: mutation is not running in a transaction")
  30623. }
  30624. tx := &Tx{config: m.config}
  30625. tx.init()
  30626. return tx, nil
  30627. }
  30628. // SetID sets the value of the id field. Note that this
  30629. // operation is only accepted on creation of UsageStatisticHour entities.
  30630. func (m *UsageStatisticHourMutation) SetID(id uint64) {
  30631. m.id = &id
  30632. }
  30633. // ID returns the ID value in the mutation. Note that the ID is only available
  30634. // if it was provided to the builder or after it was returned from the database.
  30635. func (m *UsageStatisticHourMutation) ID() (id uint64, exists bool) {
  30636. if m.id == nil {
  30637. return
  30638. }
  30639. return *m.id, true
  30640. }
  30641. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  30642. // That means, if the mutation is applied within a transaction with an isolation level such
  30643. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  30644. // or updated by the mutation.
  30645. func (m *UsageStatisticHourMutation) IDs(ctx context.Context) ([]uint64, error) {
  30646. switch {
  30647. case m.op.Is(OpUpdateOne | OpDeleteOne):
  30648. id, exists := m.ID()
  30649. if exists {
  30650. return []uint64{id}, nil
  30651. }
  30652. fallthrough
  30653. case m.op.Is(OpUpdate | OpDelete):
  30654. return m.Client().UsageStatisticHour.Query().Where(m.predicates...).IDs(ctx)
  30655. default:
  30656. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  30657. }
  30658. }
  30659. // SetCreatedAt sets the "created_at" field.
  30660. func (m *UsageStatisticHourMutation) SetCreatedAt(t time.Time) {
  30661. m.created_at = &t
  30662. }
  30663. // CreatedAt returns the value of the "created_at" field in the mutation.
  30664. func (m *UsageStatisticHourMutation) CreatedAt() (r time.Time, exists bool) {
  30665. v := m.created_at
  30666. if v == nil {
  30667. return
  30668. }
  30669. return *v, true
  30670. }
  30671. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticHour entity.
  30672. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30673. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30674. func (m *UsageStatisticHourMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  30675. if !m.op.Is(OpUpdateOne) {
  30676. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  30677. }
  30678. if m.id == nil || m.oldValue == nil {
  30679. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  30680. }
  30681. oldValue, err := m.oldValue(ctx)
  30682. if err != nil {
  30683. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  30684. }
  30685. return oldValue.CreatedAt, nil
  30686. }
  30687. // ResetCreatedAt resets all changes to the "created_at" field.
  30688. func (m *UsageStatisticHourMutation) ResetCreatedAt() {
  30689. m.created_at = nil
  30690. }
  30691. // SetUpdatedAt sets the "updated_at" field.
  30692. func (m *UsageStatisticHourMutation) SetUpdatedAt(t time.Time) {
  30693. m.updated_at = &t
  30694. }
  30695. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  30696. func (m *UsageStatisticHourMutation) UpdatedAt() (r time.Time, exists bool) {
  30697. v := m.updated_at
  30698. if v == nil {
  30699. return
  30700. }
  30701. return *v, true
  30702. }
  30703. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticHour entity.
  30704. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30705. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30706. func (m *UsageStatisticHourMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  30707. if !m.op.Is(OpUpdateOne) {
  30708. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  30709. }
  30710. if m.id == nil || m.oldValue == nil {
  30711. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  30712. }
  30713. oldValue, err := m.oldValue(ctx)
  30714. if err != nil {
  30715. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  30716. }
  30717. return oldValue.UpdatedAt, nil
  30718. }
  30719. // ResetUpdatedAt resets all changes to the "updated_at" field.
  30720. func (m *UsageStatisticHourMutation) ResetUpdatedAt() {
  30721. m.updated_at = nil
  30722. }
  30723. // SetStatus sets the "status" field.
  30724. func (m *UsageStatisticHourMutation) SetStatus(u uint8) {
  30725. m.status = &u
  30726. m.addstatus = nil
  30727. }
  30728. // Status returns the value of the "status" field in the mutation.
  30729. func (m *UsageStatisticHourMutation) Status() (r uint8, exists bool) {
  30730. v := m.status
  30731. if v == nil {
  30732. return
  30733. }
  30734. return *v, true
  30735. }
  30736. // OldStatus returns the old "status" field's value of the UsageStatisticHour entity.
  30737. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30738. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30739. func (m *UsageStatisticHourMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  30740. if !m.op.Is(OpUpdateOne) {
  30741. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  30742. }
  30743. if m.id == nil || m.oldValue == nil {
  30744. return v, errors.New("OldStatus requires an ID field in the mutation")
  30745. }
  30746. oldValue, err := m.oldValue(ctx)
  30747. if err != nil {
  30748. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  30749. }
  30750. return oldValue.Status, nil
  30751. }
  30752. // AddStatus adds u to the "status" field.
  30753. func (m *UsageStatisticHourMutation) AddStatus(u int8) {
  30754. if m.addstatus != nil {
  30755. *m.addstatus += u
  30756. } else {
  30757. m.addstatus = &u
  30758. }
  30759. }
  30760. // AddedStatus returns the value that was added to the "status" field in this mutation.
  30761. func (m *UsageStatisticHourMutation) AddedStatus() (r int8, exists bool) {
  30762. v := m.addstatus
  30763. if v == nil {
  30764. return
  30765. }
  30766. return *v, true
  30767. }
  30768. // ClearStatus clears the value of the "status" field.
  30769. func (m *UsageStatisticHourMutation) ClearStatus() {
  30770. m.status = nil
  30771. m.addstatus = nil
  30772. m.clearedFields[usagestatistichour.FieldStatus] = struct{}{}
  30773. }
  30774. // StatusCleared returns if the "status" field was cleared in this mutation.
  30775. func (m *UsageStatisticHourMutation) StatusCleared() bool {
  30776. _, ok := m.clearedFields[usagestatistichour.FieldStatus]
  30777. return ok
  30778. }
  30779. // ResetStatus resets all changes to the "status" field.
  30780. func (m *UsageStatisticHourMutation) ResetStatus() {
  30781. m.status = nil
  30782. m.addstatus = nil
  30783. delete(m.clearedFields, usagestatistichour.FieldStatus)
  30784. }
  30785. // SetDeletedAt sets the "deleted_at" field.
  30786. func (m *UsageStatisticHourMutation) SetDeletedAt(t time.Time) {
  30787. m.deleted_at = &t
  30788. }
  30789. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  30790. func (m *UsageStatisticHourMutation) DeletedAt() (r time.Time, exists bool) {
  30791. v := m.deleted_at
  30792. if v == nil {
  30793. return
  30794. }
  30795. return *v, true
  30796. }
  30797. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticHour entity.
  30798. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30799. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30800. func (m *UsageStatisticHourMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  30801. if !m.op.Is(OpUpdateOne) {
  30802. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  30803. }
  30804. if m.id == nil || m.oldValue == nil {
  30805. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  30806. }
  30807. oldValue, err := m.oldValue(ctx)
  30808. if err != nil {
  30809. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  30810. }
  30811. return oldValue.DeletedAt, nil
  30812. }
  30813. // ClearDeletedAt clears the value of the "deleted_at" field.
  30814. func (m *UsageStatisticHourMutation) ClearDeletedAt() {
  30815. m.deleted_at = nil
  30816. m.clearedFields[usagestatistichour.FieldDeletedAt] = struct{}{}
  30817. }
  30818. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  30819. func (m *UsageStatisticHourMutation) DeletedAtCleared() bool {
  30820. _, ok := m.clearedFields[usagestatistichour.FieldDeletedAt]
  30821. return ok
  30822. }
  30823. // ResetDeletedAt resets all changes to the "deleted_at" field.
  30824. func (m *UsageStatisticHourMutation) ResetDeletedAt() {
  30825. m.deleted_at = nil
  30826. delete(m.clearedFields, usagestatistichour.FieldDeletedAt)
  30827. }
  30828. // SetAddtime sets the "addtime" field.
  30829. func (m *UsageStatisticHourMutation) SetAddtime(u uint64) {
  30830. m.addtime = &u
  30831. m.addaddtime = nil
  30832. }
  30833. // Addtime returns the value of the "addtime" field in the mutation.
  30834. func (m *UsageStatisticHourMutation) Addtime() (r uint64, exists bool) {
  30835. v := m.addtime
  30836. if v == nil {
  30837. return
  30838. }
  30839. return *v, true
  30840. }
  30841. // OldAddtime returns the old "addtime" field's value of the UsageStatisticHour entity.
  30842. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30843. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30844. func (m *UsageStatisticHourMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  30845. if !m.op.Is(OpUpdateOne) {
  30846. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  30847. }
  30848. if m.id == nil || m.oldValue == nil {
  30849. return v, errors.New("OldAddtime requires an ID field in the mutation")
  30850. }
  30851. oldValue, err := m.oldValue(ctx)
  30852. if err != nil {
  30853. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  30854. }
  30855. return oldValue.Addtime, nil
  30856. }
  30857. // AddAddtime adds u to the "addtime" field.
  30858. func (m *UsageStatisticHourMutation) AddAddtime(u int64) {
  30859. if m.addaddtime != nil {
  30860. *m.addaddtime += u
  30861. } else {
  30862. m.addaddtime = &u
  30863. }
  30864. }
  30865. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  30866. func (m *UsageStatisticHourMutation) AddedAddtime() (r int64, exists bool) {
  30867. v := m.addaddtime
  30868. if v == nil {
  30869. return
  30870. }
  30871. return *v, true
  30872. }
  30873. // ResetAddtime resets all changes to the "addtime" field.
  30874. func (m *UsageStatisticHourMutation) ResetAddtime() {
  30875. m.addtime = nil
  30876. m.addaddtime = nil
  30877. }
  30878. // SetType sets the "type" field.
  30879. func (m *UsageStatisticHourMutation) SetType(i int) {
  30880. m._type = &i
  30881. m.add_type = nil
  30882. }
  30883. // GetType returns the value of the "type" field in the mutation.
  30884. func (m *UsageStatisticHourMutation) GetType() (r int, exists bool) {
  30885. v := m._type
  30886. if v == nil {
  30887. return
  30888. }
  30889. return *v, true
  30890. }
  30891. // OldType returns the old "type" field's value of the UsageStatisticHour entity.
  30892. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30893. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30894. func (m *UsageStatisticHourMutation) OldType(ctx context.Context) (v int, err error) {
  30895. if !m.op.Is(OpUpdateOne) {
  30896. return v, errors.New("OldType is only allowed on UpdateOne operations")
  30897. }
  30898. if m.id == nil || m.oldValue == nil {
  30899. return v, errors.New("OldType requires an ID field in the mutation")
  30900. }
  30901. oldValue, err := m.oldValue(ctx)
  30902. if err != nil {
  30903. return v, fmt.Errorf("querying old value for OldType: %w", err)
  30904. }
  30905. return oldValue.Type, nil
  30906. }
  30907. // AddType adds i to the "type" field.
  30908. func (m *UsageStatisticHourMutation) AddType(i int) {
  30909. if m.add_type != nil {
  30910. *m.add_type += i
  30911. } else {
  30912. m.add_type = &i
  30913. }
  30914. }
  30915. // AddedType returns the value that was added to the "type" field in this mutation.
  30916. func (m *UsageStatisticHourMutation) AddedType() (r int, exists bool) {
  30917. v := m.add_type
  30918. if v == nil {
  30919. return
  30920. }
  30921. return *v, true
  30922. }
  30923. // ResetType resets all changes to the "type" field.
  30924. func (m *UsageStatisticHourMutation) ResetType() {
  30925. m._type = nil
  30926. m.add_type = nil
  30927. }
  30928. // SetBotID sets the "bot_id" field.
  30929. func (m *UsageStatisticHourMutation) SetBotID(s string) {
  30930. m.bot_id = &s
  30931. }
  30932. // BotID returns the value of the "bot_id" field in the mutation.
  30933. func (m *UsageStatisticHourMutation) BotID() (r string, exists bool) {
  30934. v := m.bot_id
  30935. if v == nil {
  30936. return
  30937. }
  30938. return *v, true
  30939. }
  30940. // OldBotID returns the old "bot_id" field's value of the UsageStatisticHour entity.
  30941. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30942. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30943. func (m *UsageStatisticHourMutation) OldBotID(ctx context.Context) (v string, err error) {
  30944. if !m.op.Is(OpUpdateOne) {
  30945. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  30946. }
  30947. if m.id == nil || m.oldValue == nil {
  30948. return v, errors.New("OldBotID requires an ID field in the mutation")
  30949. }
  30950. oldValue, err := m.oldValue(ctx)
  30951. if err != nil {
  30952. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  30953. }
  30954. return oldValue.BotID, nil
  30955. }
  30956. // ClearBotID clears the value of the "bot_id" field.
  30957. func (m *UsageStatisticHourMutation) ClearBotID() {
  30958. m.bot_id = nil
  30959. m.clearedFields[usagestatistichour.FieldBotID] = struct{}{}
  30960. }
  30961. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  30962. func (m *UsageStatisticHourMutation) BotIDCleared() bool {
  30963. _, ok := m.clearedFields[usagestatistichour.FieldBotID]
  30964. return ok
  30965. }
  30966. // ResetBotID resets all changes to the "bot_id" field.
  30967. func (m *UsageStatisticHourMutation) ResetBotID() {
  30968. m.bot_id = nil
  30969. delete(m.clearedFields, usagestatistichour.FieldBotID)
  30970. }
  30971. // SetOrganizationID sets the "organization_id" field.
  30972. func (m *UsageStatisticHourMutation) SetOrganizationID(u uint64) {
  30973. m.organization_id = &u
  30974. m.addorganization_id = nil
  30975. }
  30976. // OrganizationID returns the value of the "organization_id" field in the mutation.
  30977. func (m *UsageStatisticHourMutation) OrganizationID() (r uint64, exists bool) {
  30978. v := m.organization_id
  30979. if v == nil {
  30980. return
  30981. }
  30982. return *v, true
  30983. }
  30984. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticHour entity.
  30985. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30986. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30987. func (m *UsageStatisticHourMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  30988. if !m.op.Is(OpUpdateOne) {
  30989. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  30990. }
  30991. if m.id == nil || m.oldValue == nil {
  30992. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  30993. }
  30994. oldValue, err := m.oldValue(ctx)
  30995. if err != nil {
  30996. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  30997. }
  30998. return oldValue.OrganizationID, nil
  30999. }
  31000. // AddOrganizationID adds u to the "organization_id" field.
  31001. func (m *UsageStatisticHourMutation) AddOrganizationID(u int64) {
  31002. if m.addorganization_id != nil {
  31003. *m.addorganization_id += u
  31004. } else {
  31005. m.addorganization_id = &u
  31006. }
  31007. }
  31008. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  31009. func (m *UsageStatisticHourMutation) AddedOrganizationID() (r int64, exists bool) {
  31010. v := m.addorganization_id
  31011. if v == nil {
  31012. return
  31013. }
  31014. return *v, true
  31015. }
  31016. // ClearOrganizationID clears the value of the "organization_id" field.
  31017. func (m *UsageStatisticHourMutation) ClearOrganizationID() {
  31018. m.organization_id = nil
  31019. m.addorganization_id = nil
  31020. m.clearedFields[usagestatistichour.FieldOrganizationID] = struct{}{}
  31021. }
  31022. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  31023. func (m *UsageStatisticHourMutation) OrganizationIDCleared() bool {
  31024. _, ok := m.clearedFields[usagestatistichour.FieldOrganizationID]
  31025. return ok
  31026. }
  31027. // ResetOrganizationID resets all changes to the "organization_id" field.
  31028. func (m *UsageStatisticHourMutation) ResetOrganizationID() {
  31029. m.organization_id = nil
  31030. m.addorganization_id = nil
  31031. delete(m.clearedFields, usagestatistichour.FieldOrganizationID)
  31032. }
  31033. // SetAiResponse sets the "ai_response" field.
  31034. func (m *UsageStatisticHourMutation) SetAiResponse(u uint64) {
  31035. m.ai_response = &u
  31036. m.addai_response = nil
  31037. }
  31038. // AiResponse returns the value of the "ai_response" field in the mutation.
  31039. func (m *UsageStatisticHourMutation) AiResponse() (r uint64, exists bool) {
  31040. v := m.ai_response
  31041. if v == nil {
  31042. return
  31043. }
  31044. return *v, true
  31045. }
  31046. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticHour entity.
  31047. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  31048. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31049. func (m *UsageStatisticHourMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  31050. if !m.op.Is(OpUpdateOne) {
  31051. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  31052. }
  31053. if m.id == nil || m.oldValue == nil {
  31054. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  31055. }
  31056. oldValue, err := m.oldValue(ctx)
  31057. if err != nil {
  31058. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  31059. }
  31060. return oldValue.AiResponse, nil
  31061. }
  31062. // AddAiResponse adds u to the "ai_response" field.
  31063. func (m *UsageStatisticHourMutation) AddAiResponse(u int64) {
  31064. if m.addai_response != nil {
  31065. *m.addai_response += u
  31066. } else {
  31067. m.addai_response = &u
  31068. }
  31069. }
  31070. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  31071. func (m *UsageStatisticHourMutation) AddedAiResponse() (r int64, exists bool) {
  31072. v := m.addai_response
  31073. if v == nil {
  31074. return
  31075. }
  31076. return *v, true
  31077. }
  31078. // ResetAiResponse resets all changes to the "ai_response" field.
  31079. func (m *UsageStatisticHourMutation) ResetAiResponse() {
  31080. m.ai_response = nil
  31081. m.addai_response = nil
  31082. }
  31083. // SetSopRun sets the "sop_run" field.
  31084. func (m *UsageStatisticHourMutation) SetSopRun(u uint64) {
  31085. m.sop_run = &u
  31086. m.addsop_run = nil
  31087. }
  31088. // SopRun returns the value of the "sop_run" field in the mutation.
  31089. func (m *UsageStatisticHourMutation) SopRun() (r uint64, exists bool) {
  31090. v := m.sop_run
  31091. if v == nil {
  31092. return
  31093. }
  31094. return *v, true
  31095. }
  31096. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticHour entity.
  31097. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  31098. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31099. func (m *UsageStatisticHourMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  31100. if !m.op.Is(OpUpdateOne) {
  31101. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  31102. }
  31103. if m.id == nil || m.oldValue == nil {
  31104. return v, errors.New("OldSopRun requires an ID field in the mutation")
  31105. }
  31106. oldValue, err := m.oldValue(ctx)
  31107. if err != nil {
  31108. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  31109. }
  31110. return oldValue.SopRun, nil
  31111. }
  31112. // AddSopRun adds u to the "sop_run" field.
  31113. func (m *UsageStatisticHourMutation) AddSopRun(u int64) {
  31114. if m.addsop_run != nil {
  31115. *m.addsop_run += u
  31116. } else {
  31117. m.addsop_run = &u
  31118. }
  31119. }
  31120. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  31121. func (m *UsageStatisticHourMutation) AddedSopRun() (r int64, exists bool) {
  31122. v := m.addsop_run
  31123. if v == nil {
  31124. return
  31125. }
  31126. return *v, true
  31127. }
  31128. // ResetSopRun resets all changes to the "sop_run" field.
  31129. func (m *UsageStatisticHourMutation) ResetSopRun() {
  31130. m.sop_run = nil
  31131. m.addsop_run = nil
  31132. }
  31133. // SetTotalFriend sets the "total_friend" field.
  31134. func (m *UsageStatisticHourMutation) SetTotalFriend(u uint64) {
  31135. m.total_friend = &u
  31136. m.addtotal_friend = nil
  31137. }
  31138. // TotalFriend returns the value of the "total_friend" field in the mutation.
  31139. func (m *UsageStatisticHourMutation) TotalFriend() (r uint64, exists bool) {
  31140. v := m.total_friend
  31141. if v == nil {
  31142. return
  31143. }
  31144. return *v, true
  31145. }
  31146. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticHour entity.
  31147. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  31148. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31149. func (m *UsageStatisticHourMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  31150. if !m.op.Is(OpUpdateOne) {
  31151. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  31152. }
  31153. if m.id == nil || m.oldValue == nil {
  31154. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  31155. }
  31156. oldValue, err := m.oldValue(ctx)
  31157. if err != nil {
  31158. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  31159. }
  31160. return oldValue.TotalFriend, nil
  31161. }
  31162. // AddTotalFriend adds u to the "total_friend" field.
  31163. func (m *UsageStatisticHourMutation) AddTotalFriend(u int64) {
  31164. if m.addtotal_friend != nil {
  31165. *m.addtotal_friend += u
  31166. } else {
  31167. m.addtotal_friend = &u
  31168. }
  31169. }
  31170. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  31171. func (m *UsageStatisticHourMutation) AddedTotalFriend() (r int64, exists bool) {
  31172. v := m.addtotal_friend
  31173. if v == nil {
  31174. return
  31175. }
  31176. return *v, true
  31177. }
  31178. // ResetTotalFriend resets all changes to the "total_friend" field.
  31179. func (m *UsageStatisticHourMutation) ResetTotalFriend() {
  31180. m.total_friend = nil
  31181. m.addtotal_friend = nil
  31182. }
  31183. // SetTotalGroup sets the "total_group" field.
  31184. func (m *UsageStatisticHourMutation) SetTotalGroup(u uint64) {
  31185. m.total_group = &u
  31186. m.addtotal_group = nil
  31187. }
  31188. // TotalGroup returns the value of the "total_group" field in the mutation.
  31189. func (m *UsageStatisticHourMutation) TotalGroup() (r uint64, exists bool) {
  31190. v := m.total_group
  31191. if v == nil {
  31192. return
  31193. }
  31194. return *v, true
  31195. }
  31196. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticHour entity.
  31197. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  31198. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31199. func (m *UsageStatisticHourMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  31200. if !m.op.Is(OpUpdateOne) {
  31201. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  31202. }
  31203. if m.id == nil || m.oldValue == nil {
  31204. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  31205. }
  31206. oldValue, err := m.oldValue(ctx)
  31207. if err != nil {
  31208. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  31209. }
  31210. return oldValue.TotalGroup, nil
  31211. }
  31212. // AddTotalGroup adds u to the "total_group" field.
  31213. func (m *UsageStatisticHourMutation) AddTotalGroup(u int64) {
  31214. if m.addtotal_group != nil {
  31215. *m.addtotal_group += u
  31216. } else {
  31217. m.addtotal_group = &u
  31218. }
  31219. }
  31220. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  31221. func (m *UsageStatisticHourMutation) AddedTotalGroup() (r int64, exists bool) {
  31222. v := m.addtotal_group
  31223. if v == nil {
  31224. return
  31225. }
  31226. return *v, true
  31227. }
  31228. // ResetTotalGroup resets all changes to the "total_group" field.
  31229. func (m *UsageStatisticHourMutation) ResetTotalGroup() {
  31230. m.total_group = nil
  31231. m.addtotal_group = nil
  31232. }
  31233. // SetAccountBalance sets the "account_balance" field.
  31234. func (m *UsageStatisticHourMutation) SetAccountBalance(u uint64) {
  31235. m.account_balance = &u
  31236. m.addaccount_balance = nil
  31237. }
  31238. // AccountBalance returns the value of the "account_balance" field in the mutation.
  31239. func (m *UsageStatisticHourMutation) AccountBalance() (r uint64, exists bool) {
  31240. v := m.account_balance
  31241. if v == nil {
  31242. return
  31243. }
  31244. return *v, true
  31245. }
  31246. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticHour entity.
  31247. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  31248. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31249. func (m *UsageStatisticHourMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  31250. if !m.op.Is(OpUpdateOne) {
  31251. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  31252. }
  31253. if m.id == nil || m.oldValue == nil {
  31254. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  31255. }
  31256. oldValue, err := m.oldValue(ctx)
  31257. if err != nil {
  31258. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  31259. }
  31260. return oldValue.AccountBalance, nil
  31261. }
  31262. // AddAccountBalance adds u to the "account_balance" field.
  31263. func (m *UsageStatisticHourMutation) AddAccountBalance(u int64) {
  31264. if m.addaccount_balance != nil {
  31265. *m.addaccount_balance += u
  31266. } else {
  31267. m.addaccount_balance = &u
  31268. }
  31269. }
  31270. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  31271. func (m *UsageStatisticHourMutation) AddedAccountBalance() (r int64, exists bool) {
  31272. v := m.addaccount_balance
  31273. if v == nil {
  31274. return
  31275. }
  31276. return *v, true
  31277. }
  31278. // ResetAccountBalance resets all changes to the "account_balance" field.
  31279. func (m *UsageStatisticHourMutation) ResetAccountBalance() {
  31280. m.account_balance = nil
  31281. m.addaccount_balance = nil
  31282. }
  31283. // SetConsumeToken sets the "consume_token" field.
  31284. func (m *UsageStatisticHourMutation) SetConsumeToken(u uint64) {
  31285. m.consume_token = &u
  31286. m.addconsume_token = nil
  31287. }
  31288. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  31289. func (m *UsageStatisticHourMutation) ConsumeToken() (r uint64, exists bool) {
  31290. v := m.consume_token
  31291. if v == nil {
  31292. return
  31293. }
  31294. return *v, true
  31295. }
  31296. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticHour entity.
  31297. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  31298. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31299. func (m *UsageStatisticHourMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  31300. if !m.op.Is(OpUpdateOne) {
  31301. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  31302. }
  31303. if m.id == nil || m.oldValue == nil {
  31304. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  31305. }
  31306. oldValue, err := m.oldValue(ctx)
  31307. if err != nil {
  31308. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  31309. }
  31310. return oldValue.ConsumeToken, nil
  31311. }
  31312. // AddConsumeToken adds u to the "consume_token" field.
  31313. func (m *UsageStatisticHourMutation) AddConsumeToken(u int64) {
  31314. if m.addconsume_token != nil {
  31315. *m.addconsume_token += u
  31316. } else {
  31317. m.addconsume_token = &u
  31318. }
  31319. }
  31320. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  31321. func (m *UsageStatisticHourMutation) AddedConsumeToken() (r int64, exists bool) {
  31322. v := m.addconsume_token
  31323. if v == nil {
  31324. return
  31325. }
  31326. return *v, true
  31327. }
  31328. // ResetConsumeToken resets all changes to the "consume_token" field.
  31329. func (m *UsageStatisticHourMutation) ResetConsumeToken() {
  31330. m.consume_token = nil
  31331. m.addconsume_token = nil
  31332. }
  31333. // SetActiveUser sets the "active_user" field.
  31334. func (m *UsageStatisticHourMutation) SetActiveUser(u uint64) {
  31335. m.active_user = &u
  31336. m.addactive_user = nil
  31337. }
  31338. // ActiveUser returns the value of the "active_user" field in the mutation.
  31339. func (m *UsageStatisticHourMutation) ActiveUser() (r uint64, exists bool) {
  31340. v := m.active_user
  31341. if v == nil {
  31342. return
  31343. }
  31344. return *v, true
  31345. }
  31346. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticHour entity.
  31347. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  31348. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31349. func (m *UsageStatisticHourMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  31350. if !m.op.Is(OpUpdateOne) {
  31351. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  31352. }
  31353. if m.id == nil || m.oldValue == nil {
  31354. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  31355. }
  31356. oldValue, err := m.oldValue(ctx)
  31357. if err != nil {
  31358. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  31359. }
  31360. return oldValue.ActiveUser, nil
  31361. }
  31362. // AddActiveUser adds u to the "active_user" field.
  31363. func (m *UsageStatisticHourMutation) AddActiveUser(u int64) {
  31364. if m.addactive_user != nil {
  31365. *m.addactive_user += u
  31366. } else {
  31367. m.addactive_user = &u
  31368. }
  31369. }
  31370. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  31371. func (m *UsageStatisticHourMutation) AddedActiveUser() (r int64, exists bool) {
  31372. v := m.addactive_user
  31373. if v == nil {
  31374. return
  31375. }
  31376. return *v, true
  31377. }
  31378. // ResetActiveUser resets all changes to the "active_user" field.
  31379. func (m *UsageStatisticHourMutation) ResetActiveUser() {
  31380. m.active_user = nil
  31381. m.addactive_user = nil
  31382. }
  31383. // SetNewUser sets the "new_user" field.
  31384. func (m *UsageStatisticHourMutation) SetNewUser(i int64) {
  31385. m.new_user = &i
  31386. m.addnew_user = nil
  31387. }
  31388. // NewUser returns the value of the "new_user" field in the mutation.
  31389. func (m *UsageStatisticHourMutation) NewUser() (r int64, exists bool) {
  31390. v := m.new_user
  31391. if v == nil {
  31392. return
  31393. }
  31394. return *v, true
  31395. }
  31396. // OldNewUser returns the old "new_user" field's value of the UsageStatisticHour entity.
  31397. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  31398. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31399. func (m *UsageStatisticHourMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  31400. if !m.op.Is(OpUpdateOne) {
  31401. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  31402. }
  31403. if m.id == nil || m.oldValue == nil {
  31404. return v, errors.New("OldNewUser requires an ID field in the mutation")
  31405. }
  31406. oldValue, err := m.oldValue(ctx)
  31407. if err != nil {
  31408. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  31409. }
  31410. return oldValue.NewUser, nil
  31411. }
  31412. // AddNewUser adds i to the "new_user" field.
  31413. func (m *UsageStatisticHourMutation) AddNewUser(i int64) {
  31414. if m.addnew_user != nil {
  31415. *m.addnew_user += i
  31416. } else {
  31417. m.addnew_user = &i
  31418. }
  31419. }
  31420. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  31421. func (m *UsageStatisticHourMutation) AddedNewUser() (r int64, exists bool) {
  31422. v := m.addnew_user
  31423. if v == nil {
  31424. return
  31425. }
  31426. return *v, true
  31427. }
  31428. // ResetNewUser resets all changes to the "new_user" field.
  31429. func (m *UsageStatisticHourMutation) ResetNewUser() {
  31430. m.new_user = nil
  31431. m.addnew_user = nil
  31432. }
  31433. // SetLabelDist sets the "label_dist" field.
  31434. func (m *UsageStatisticHourMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  31435. m.label_dist = &ctd
  31436. m.appendlabel_dist = nil
  31437. }
  31438. // LabelDist returns the value of the "label_dist" field in the mutation.
  31439. func (m *UsageStatisticHourMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  31440. v := m.label_dist
  31441. if v == nil {
  31442. return
  31443. }
  31444. return *v, true
  31445. }
  31446. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticHour entity.
  31447. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  31448. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31449. func (m *UsageStatisticHourMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  31450. if !m.op.Is(OpUpdateOne) {
  31451. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  31452. }
  31453. if m.id == nil || m.oldValue == nil {
  31454. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  31455. }
  31456. oldValue, err := m.oldValue(ctx)
  31457. if err != nil {
  31458. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  31459. }
  31460. return oldValue.LabelDist, nil
  31461. }
  31462. // AppendLabelDist adds ctd to the "label_dist" field.
  31463. func (m *UsageStatisticHourMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  31464. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  31465. }
  31466. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  31467. func (m *UsageStatisticHourMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  31468. if len(m.appendlabel_dist) == 0 {
  31469. return nil, false
  31470. }
  31471. return m.appendlabel_dist, true
  31472. }
  31473. // ResetLabelDist resets all changes to the "label_dist" field.
  31474. func (m *UsageStatisticHourMutation) ResetLabelDist() {
  31475. m.label_dist = nil
  31476. m.appendlabel_dist = nil
  31477. }
  31478. // Where appends a list predicates to the UsageStatisticHourMutation builder.
  31479. func (m *UsageStatisticHourMutation) Where(ps ...predicate.UsageStatisticHour) {
  31480. m.predicates = append(m.predicates, ps...)
  31481. }
  31482. // WhereP appends storage-level predicates to the UsageStatisticHourMutation builder. Using this method,
  31483. // users can use type-assertion to append predicates that do not depend on any generated package.
  31484. func (m *UsageStatisticHourMutation) WhereP(ps ...func(*sql.Selector)) {
  31485. p := make([]predicate.UsageStatisticHour, len(ps))
  31486. for i := range ps {
  31487. p[i] = ps[i]
  31488. }
  31489. m.Where(p...)
  31490. }
  31491. // Op returns the operation name.
  31492. func (m *UsageStatisticHourMutation) Op() Op {
  31493. return m.op
  31494. }
  31495. // SetOp allows setting the mutation operation.
  31496. func (m *UsageStatisticHourMutation) SetOp(op Op) {
  31497. m.op = op
  31498. }
  31499. // Type returns the node type of this mutation (UsageStatisticHour).
  31500. func (m *UsageStatisticHourMutation) Type() string {
  31501. return m.typ
  31502. }
  31503. // Fields returns all fields that were changed during this mutation. Note that in
  31504. // order to get all numeric fields that were incremented/decremented, call
  31505. // AddedFields().
  31506. func (m *UsageStatisticHourMutation) Fields() []string {
  31507. fields := make([]string, 0, 17)
  31508. if m.created_at != nil {
  31509. fields = append(fields, usagestatistichour.FieldCreatedAt)
  31510. }
  31511. if m.updated_at != nil {
  31512. fields = append(fields, usagestatistichour.FieldUpdatedAt)
  31513. }
  31514. if m.status != nil {
  31515. fields = append(fields, usagestatistichour.FieldStatus)
  31516. }
  31517. if m.deleted_at != nil {
  31518. fields = append(fields, usagestatistichour.FieldDeletedAt)
  31519. }
  31520. if m.addtime != nil {
  31521. fields = append(fields, usagestatistichour.FieldAddtime)
  31522. }
  31523. if m._type != nil {
  31524. fields = append(fields, usagestatistichour.FieldType)
  31525. }
  31526. if m.bot_id != nil {
  31527. fields = append(fields, usagestatistichour.FieldBotID)
  31528. }
  31529. if m.organization_id != nil {
  31530. fields = append(fields, usagestatistichour.FieldOrganizationID)
  31531. }
  31532. if m.ai_response != nil {
  31533. fields = append(fields, usagestatistichour.FieldAiResponse)
  31534. }
  31535. if m.sop_run != nil {
  31536. fields = append(fields, usagestatistichour.FieldSopRun)
  31537. }
  31538. if m.total_friend != nil {
  31539. fields = append(fields, usagestatistichour.FieldTotalFriend)
  31540. }
  31541. if m.total_group != nil {
  31542. fields = append(fields, usagestatistichour.FieldTotalGroup)
  31543. }
  31544. if m.account_balance != nil {
  31545. fields = append(fields, usagestatistichour.FieldAccountBalance)
  31546. }
  31547. if m.consume_token != nil {
  31548. fields = append(fields, usagestatistichour.FieldConsumeToken)
  31549. }
  31550. if m.active_user != nil {
  31551. fields = append(fields, usagestatistichour.FieldActiveUser)
  31552. }
  31553. if m.new_user != nil {
  31554. fields = append(fields, usagestatistichour.FieldNewUser)
  31555. }
  31556. if m.label_dist != nil {
  31557. fields = append(fields, usagestatistichour.FieldLabelDist)
  31558. }
  31559. return fields
  31560. }
  31561. // Field returns the value of a field with the given name. The second boolean
  31562. // return value indicates that this field was not set, or was not defined in the
  31563. // schema.
  31564. func (m *UsageStatisticHourMutation) Field(name string) (ent.Value, bool) {
  31565. switch name {
  31566. case usagestatistichour.FieldCreatedAt:
  31567. return m.CreatedAt()
  31568. case usagestatistichour.FieldUpdatedAt:
  31569. return m.UpdatedAt()
  31570. case usagestatistichour.FieldStatus:
  31571. return m.Status()
  31572. case usagestatistichour.FieldDeletedAt:
  31573. return m.DeletedAt()
  31574. case usagestatistichour.FieldAddtime:
  31575. return m.Addtime()
  31576. case usagestatistichour.FieldType:
  31577. return m.GetType()
  31578. case usagestatistichour.FieldBotID:
  31579. return m.BotID()
  31580. case usagestatistichour.FieldOrganizationID:
  31581. return m.OrganizationID()
  31582. case usagestatistichour.FieldAiResponse:
  31583. return m.AiResponse()
  31584. case usagestatistichour.FieldSopRun:
  31585. return m.SopRun()
  31586. case usagestatistichour.FieldTotalFriend:
  31587. return m.TotalFriend()
  31588. case usagestatistichour.FieldTotalGroup:
  31589. return m.TotalGroup()
  31590. case usagestatistichour.FieldAccountBalance:
  31591. return m.AccountBalance()
  31592. case usagestatistichour.FieldConsumeToken:
  31593. return m.ConsumeToken()
  31594. case usagestatistichour.FieldActiveUser:
  31595. return m.ActiveUser()
  31596. case usagestatistichour.FieldNewUser:
  31597. return m.NewUser()
  31598. case usagestatistichour.FieldLabelDist:
  31599. return m.LabelDist()
  31600. }
  31601. return nil, false
  31602. }
  31603. // OldField returns the old value of the field from the database. An error is
  31604. // returned if the mutation operation is not UpdateOne, or the query to the
  31605. // database failed.
  31606. func (m *UsageStatisticHourMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  31607. switch name {
  31608. case usagestatistichour.FieldCreatedAt:
  31609. return m.OldCreatedAt(ctx)
  31610. case usagestatistichour.FieldUpdatedAt:
  31611. return m.OldUpdatedAt(ctx)
  31612. case usagestatistichour.FieldStatus:
  31613. return m.OldStatus(ctx)
  31614. case usagestatistichour.FieldDeletedAt:
  31615. return m.OldDeletedAt(ctx)
  31616. case usagestatistichour.FieldAddtime:
  31617. return m.OldAddtime(ctx)
  31618. case usagestatistichour.FieldType:
  31619. return m.OldType(ctx)
  31620. case usagestatistichour.FieldBotID:
  31621. return m.OldBotID(ctx)
  31622. case usagestatistichour.FieldOrganizationID:
  31623. return m.OldOrganizationID(ctx)
  31624. case usagestatistichour.FieldAiResponse:
  31625. return m.OldAiResponse(ctx)
  31626. case usagestatistichour.FieldSopRun:
  31627. return m.OldSopRun(ctx)
  31628. case usagestatistichour.FieldTotalFriend:
  31629. return m.OldTotalFriend(ctx)
  31630. case usagestatistichour.FieldTotalGroup:
  31631. return m.OldTotalGroup(ctx)
  31632. case usagestatistichour.FieldAccountBalance:
  31633. return m.OldAccountBalance(ctx)
  31634. case usagestatistichour.FieldConsumeToken:
  31635. return m.OldConsumeToken(ctx)
  31636. case usagestatistichour.FieldActiveUser:
  31637. return m.OldActiveUser(ctx)
  31638. case usagestatistichour.FieldNewUser:
  31639. return m.OldNewUser(ctx)
  31640. case usagestatistichour.FieldLabelDist:
  31641. return m.OldLabelDist(ctx)
  31642. }
  31643. return nil, fmt.Errorf("unknown UsageStatisticHour field %s", name)
  31644. }
  31645. // SetField sets the value of a field with the given name. It returns an error if
  31646. // the field is not defined in the schema, or if the type mismatched the field
  31647. // type.
  31648. func (m *UsageStatisticHourMutation) SetField(name string, value ent.Value) error {
  31649. switch name {
  31650. case usagestatistichour.FieldCreatedAt:
  31651. v, ok := value.(time.Time)
  31652. if !ok {
  31653. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31654. }
  31655. m.SetCreatedAt(v)
  31656. return nil
  31657. case usagestatistichour.FieldUpdatedAt:
  31658. v, ok := value.(time.Time)
  31659. if !ok {
  31660. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31661. }
  31662. m.SetUpdatedAt(v)
  31663. return nil
  31664. case usagestatistichour.FieldStatus:
  31665. v, ok := value.(uint8)
  31666. if !ok {
  31667. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31668. }
  31669. m.SetStatus(v)
  31670. return nil
  31671. case usagestatistichour.FieldDeletedAt:
  31672. v, ok := value.(time.Time)
  31673. if !ok {
  31674. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31675. }
  31676. m.SetDeletedAt(v)
  31677. return nil
  31678. case usagestatistichour.FieldAddtime:
  31679. v, ok := value.(uint64)
  31680. if !ok {
  31681. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31682. }
  31683. m.SetAddtime(v)
  31684. return nil
  31685. case usagestatistichour.FieldType:
  31686. v, ok := value.(int)
  31687. if !ok {
  31688. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31689. }
  31690. m.SetType(v)
  31691. return nil
  31692. case usagestatistichour.FieldBotID:
  31693. v, ok := value.(string)
  31694. if !ok {
  31695. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31696. }
  31697. m.SetBotID(v)
  31698. return nil
  31699. case usagestatistichour.FieldOrganizationID:
  31700. v, ok := value.(uint64)
  31701. if !ok {
  31702. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31703. }
  31704. m.SetOrganizationID(v)
  31705. return nil
  31706. case usagestatistichour.FieldAiResponse:
  31707. v, ok := value.(uint64)
  31708. if !ok {
  31709. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31710. }
  31711. m.SetAiResponse(v)
  31712. return nil
  31713. case usagestatistichour.FieldSopRun:
  31714. v, ok := value.(uint64)
  31715. if !ok {
  31716. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31717. }
  31718. m.SetSopRun(v)
  31719. return nil
  31720. case usagestatistichour.FieldTotalFriend:
  31721. v, ok := value.(uint64)
  31722. if !ok {
  31723. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31724. }
  31725. m.SetTotalFriend(v)
  31726. return nil
  31727. case usagestatistichour.FieldTotalGroup:
  31728. v, ok := value.(uint64)
  31729. if !ok {
  31730. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31731. }
  31732. m.SetTotalGroup(v)
  31733. return nil
  31734. case usagestatistichour.FieldAccountBalance:
  31735. v, ok := value.(uint64)
  31736. if !ok {
  31737. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31738. }
  31739. m.SetAccountBalance(v)
  31740. return nil
  31741. case usagestatistichour.FieldConsumeToken:
  31742. v, ok := value.(uint64)
  31743. if !ok {
  31744. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31745. }
  31746. m.SetConsumeToken(v)
  31747. return nil
  31748. case usagestatistichour.FieldActiveUser:
  31749. v, ok := value.(uint64)
  31750. if !ok {
  31751. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31752. }
  31753. m.SetActiveUser(v)
  31754. return nil
  31755. case usagestatistichour.FieldNewUser:
  31756. v, ok := value.(int64)
  31757. if !ok {
  31758. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31759. }
  31760. m.SetNewUser(v)
  31761. return nil
  31762. case usagestatistichour.FieldLabelDist:
  31763. v, ok := value.([]custom_types.LabelDist)
  31764. if !ok {
  31765. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31766. }
  31767. m.SetLabelDist(v)
  31768. return nil
  31769. }
  31770. return fmt.Errorf("unknown UsageStatisticHour field %s", name)
  31771. }
  31772. // AddedFields returns all numeric fields that were incremented/decremented during
  31773. // this mutation.
  31774. func (m *UsageStatisticHourMutation) AddedFields() []string {
  31775. var fields []string
  31776. if m.addstatus != nil {
  31777. fields = append(fields, usagestatistichour.FieldStatus)
  31778. }
  31779. if m.addaddtime != nil {
  31780. fields = append(fields, usagestatistichour.FieldAddtime)
  31781. }
  31782. if m.add_type != nil {
  31783. fields = append(fields, usagestatistichour.FieldType)
  31784. }
  31785. if m.addorganization_id != nil {
  31786. fields = append(fields, usagestatistichour.FieldOrganizationID)
  31787. }
  31788. if m.addai_response != nil {
  31789. fields = append(fields, usagestatistichour.FieldAiResponse)
  31790. }
  31791. if m.addsop_run != nil {
  31792. fields = append(fields, usagestatistichour.FieldSopRun)
  31793. }
  31794. if m.addtotal_friend != nil {
  31795. fields = append(fields, usagestatistichour.FieldTotalFriend)
  31796. }
  31797. if m.addtotal_group != nil {
  31798. fields = append(fields, usagestatistichour.FieldTotalGroup)
  31799. }
  31800. if m.addaccount_balance != nil {
  31801. fields = append(fields, usagestatistichour.FieldAccountBalance)
  31802. }
  31803. if m.addconsume_token != nil {
  31804. fields = append(fields, usagestatistichour.FieldConsumeToken)
  31805. }
  31806. if m.addactive_user != nil {
  31807. fields = append(fields, usagestatistichour.FieldActiveUser)
  31808. }
  31809. if m.addnew_user != nil {
  31810. fields = append(fields, usagestatistichour.FieldNewUser)
  31811. }
  31812. return fields
  31813. }
  31814. // AddedField returns the numeric value that was incremented/decremented on a field
  31815. // with the given name. The second boolean return value indicates that this field
  31816. // was not set, or was not defined in the schema.
  31817. func (m *UsageStatisticHourMutation) AddedField(name string) (ent.Value, bool) {
  31818. switch name {
  31819. case usagestatistichour.FieldStatus:
  31820. return m.AddedStatus()
  31821. case usagestatistichour.FieldAddtime:
  31822. return m.AddedAddtime()
  31823. case usagestatistichour.FieldType:
  31824. return m.AddedType()
  31825. case usagestatistichour.FieldOrganizationID:
  31826. return m.AddedOrganizationID()
  31827. case usagestatistichour.FieldAiResponse:
  31828. return m.AddedAiResponse()
  31829. case usagestatistichour.FieldSopRun:
  31830. return m.AddedSopRun()
  31831. case usagestatistichour.FieldTotalFriend:
  31832. return m.AddedTotalFriend()
  31833. case usagestatistichour.FieldTotalGroup:
  31834. return m.AddedTotalGroup()
  31835. case usagestatistichour.FieldAccountBalance:
  31836. return m.AddedAccountBalance()
  31837. case usagestatistichour.FieldConsumeToken:
  31838. return m.AddedConsumeToken()
  31839. case usagestatistichour.FieldActiveUser:
  31840. return m.AddedActiveUser()
  31841. case usagestatistichour.FieldNewUser:
  31842. return m.AddedNewUser()
  31843. }
  31844. return nil, false
  31845. }
  31846. // AddField adds the value to the field with the given name. It returns an error if
  31847. // the field is not defined in the schema, or if the type mismatched the field
  31848. // type.
  31849. func (m *UsageStatisticHourMutation) AddField(name string, value ent.Value) error {
  31850. switch name {
  31851. case usagestatistichour.FieldStatus:
  31852. v, ok := value.(int8)
  31853. if !ok {
  31854. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31855. }
  31856. m.AddStatus(v)
  31857. return nil
  31858. case usagestatistichour.FieldAddtime:
  31859. v, ok := value.(int64)
  31860. if !ok {
  31861. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31862. }
  31863. m.AddAddtime(v)
  31864. return nil
  31865. case usagestatistichour.FieldType:
  31866. v, ok := value.(int)
  31867. if !ok {
  31868. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31869. }
  31870. m.AddType(v)
  31871. return nil
  31872. case usagestatistichour.FieldOrganizationID:
  31873. v, ok := value.(int64)
  31874. if !ok {
  31875. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31876. }
  31877. m.AddOrganizationID(v)
  31878. return nil
  31879. case usagestatistichour.FieldAiResponse:
  31880. v, ok := value.(int64)
  31881. if !ok {
  31882. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31883. }
  31884. m.AddAiResponse(v)
  31885. return nil
  31886. case usagestatistichour.FieldSopRun:
  31887. v, ok := value.(int64)
  31888. if !ok {
  31889. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31890. }
  31891. m.AddSopRun(v)
  31892. return nil
  31893. case usagestatistichour.FieldTotalFriend:
  31894. v, ok := value.(int64)
  31895. if !ok {
  31896. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31897. }
  31898. m.AddTotalFriend(v)
  31899. return nil
  31900. case usagestatistichour.FieldTotalGroup:
  31901. v, ok := value.(int64)
  31902. if !ok {
  31903. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31904. }
  31905. m.AddTotalGroup(v)
  31906. return nil
  31907. case usagestatistichour.FieldAccountBalance:
  31908. v, ok := value.(int64)
  31909. if !ok {
  31910. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31911. }
  31912. m.AddAccountBalance(v)
  31913. return nil
  31914. case usagestatistichour.FieldConsumeToken:
  31915. v, ok := value.(int64)
  31916. if !ok {
  31917. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31918. }
  31919. m.AddConsumeToken(v)
  31920. return nil
  31921. case usagestatistichour.FieldActiveUser:
  31922. v, ok := value.(int64)
  31923. if !ok {
  31924. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31925. }
  31926. m.AddActiveUser(v)
  31927. return nil
  31928. case usagestatistichour.FieldNewUser:
  31929. v, ok := value.(int64)
  31930. if !ok {
  31931. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31932. }
  31933. m.AddNewUser(v)
  31934. return nil
  31935. }
  31936. return fmt.Errorf("unknown UsageStatisticHour numeric field %s", name)
  31937. }
  31938. // ClearedFields returns all nullable fields that were cleared during this
  31939. // mutation.
  31940. func (m *UsageStatisticHourMutation) ClearedFields() []string {
  31941. var fields []string
  31942. if m.FieldCleared(usagestatistichour.FieldStatus) {
  31943. fields = append(fields, usagestatistichour.FieldStatus)
  31944. }
  31945. if m.FieldCleared(usagestatistichour.FieldDeletedAt) {
  31946. fields = append(fields, usagestatistichour.FieldDeletedAt)
  31947. }
  31948. if m.FieldCleared(usagestatistichour.FieldBotID) {
  31949. fields = append(fields, usagestatistichour.FieldBotID)
  31950. }
  31951. if m.FieldCleared(usagestatistichour.FieldOrganizationID) {
  31952. fields = append(fields, usagestatistichour.FieldOrganizationID)
  31953. }
  31954. return fields
  31955. }
  31956. // FieldCleared returns a boolean indicating if a field with the given name was
  31957. // cleared in this mutation.
  31958. func (m *UsageStatisticHourMutation) FieldCleared(name string) bool {
  31959. _, ok := m.clearedFields[name]
  31960. return ok
  31961. }
  31962. // ClearField clears the value of the field with the given name. It returns an
  31963. // error if the field is not defined in the schema.
  31964. func (m *UsageStatisticHourMutation) ClearField(name string) error {
  31965. switch name {
  31966. case usagestatistichour.FieldStatus:
  31967. m.ClearStatus()
  31968. return nil
  31969. case usagestatistichour.FieldDeletedAt:
  31970. m.ClearDeletedAt()
  31971. return nil
  31972. case usagestatistichour.FieldBotID:
  31973. m.ClearBotID()
  31974. return nil
  31975. case usagestatistichour.FieldOrganizationID:
  31976. m.ClearOrganizationID()
  31977. return nil
  31978. }
  31979. return fmt.Errorf("unknown UsageStatisticHour nullable field %s", name)
  31980. }
  31981. // ResetField resets all changes in the mutation for the field with the given name.
  31982. // It returns an error if the field is not defined in the schema.
  31983. func (m *UsageStatisticHourMutation) ResetField(name string) error {
  31984. switch name {
  31985. case usagestatistichour.FieldCreatedAt:
  31986. m.ResetCreatedAt()
  31987. return nil
  31988. case usagestatistichour.FieldUpdatedAt:
  31989. m.ResetUpdatedAt()
  31990. return nil
  31991. case usagestatistichour.FieldStatus:
  31992. m.ResetStatus()
  31993. return nil
  31994. case usagestatistichour.FieldDeletedAt:
  31995. m.ResetDeletedAt()
  31996. return nil
  31997. case usagestatistichour.FieldAddtime:
  31998. m.ResetAddtime()
  31999. return nil
  32000. case usagestatistichour.FieldType:
  32001. m.ResetType()
  32002. return nil
  32003. case usagestatistichour.FieldBotID:
  32004. m.ResetBotID()
  32005. return nil
  32006. case usagestatistichour.FieldOrganizationID:
  32007. m.ResetOrganizationID()
  32008. return nil
  32009. case usagestatistichour.FieldAiResponse:
  32010. m.ResetAiResponse()
  32011. return nil
  32012. case usagestatistichour.FieldSopRun:
  32013. m.ResetSopRun()
  32014. return nil
  32015. case usagestatistichour.FieldTotalFriend:
  32016. m.ResetTotalFriend()
  32017. return nil
  32018. case usagestatistichour.FieldTotalGroup:
  32019. m.ResetTotalGroup()
  32020. return nil
  32021. case usagestatistichour.FieldAccountBalance:
  32022. m.ResetAccountBalance()
  32023. return nil
  32024. case usagestatistichour.FieldConsumeToken:
  32025. m.ResetConsumeToken()
  32026. return nil
  32027. case usagestatistichour.FieldActiveUser:
  32028. m.ResetActiveUser()
  32029. return nil
  32030. case usagestatistichour.FieldNewUser:
  32031. m.ResetNewUser()
  32032. return nil
  32033. case usagestatistichour.FieldLabelDist:
  32034. m.ResetLabelDist()
  32035. return nil
  32036. }
  32037. return fmt.Errorf("unknown UsageStatisticHour field %s", name)
  32038. }
  32039. // AddedEdges returns all edge names that were set/added in this mutation.
  32040. func (m *UsageStatisticHourMutation) AddedEdges() []string {
  32041. edges := make([]string, 0, 0)
  32042. return edges
  32043. }
  32044. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  32045. // name in this mutation.
  32046. func (m *UsageStatisticHourMutation) AddedIDs(name string) []ent.Value {
  32047. return nil
  32048. }
  32049. // RemovedEdges returns all edge names that were removed in this mutation.
  32050. func (m *UsageStatisticHourMutation) RemovedEdges() []string {
  32051. edges := make([]string, 0, 0)
  32052. return edges
  32053. }
  32054. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  32055. // the given name in this mutation.
  32056. func (m *UsageStatisticHourMutation) RemovedIDs(name string) []ent.Value {
  32057. return nil
  32058. }
  32059. // ClearedEdges returns all edge names that were cleared in this mutation.
  32060. func (m *UsageStatisticHourMutation) ClearedEdges() []string {
  32061. edges := make([]string, 0, 0)
  32062. return edges
  32063. }
  32064. // EdgeCleared returns a boolean which indicates if the edge with the given name
  32065. // was cleared in this mutation.
  32066. func (m *UsageStatisticHourMutation) EdgeCleared(name string) bool {
  32067. return false
  32068. }
  32069. // ClearEdge clears the value of the edge with the given name. It returns an error
  32070. // if that edge is not defined in the schema.
  32071. func (m *UsageStatisticHourMutation) ClearEdge(name string) error {
  32072. return fmt.Errorf("unknown UsageStatisticHour unique edge %s", name)
  32073. }
  32074. // ResetEdge resets all changes to the edge with the given name in this mutation.
  32075. // It returns an error if the edge is not defined in the schema.
  32076. func (m *UsageStatisticHourMutation) ResetEdge(name string) error {
  32077. return fmt.Errorf("unknown UsageStatisticHour edge %s", name)
  32078. }
  32079. // UsageStatisticMonthMutation represents an operation that mutates the UsageStatisticMonth nodes in the graph.
  32080. type UsageStatisticMonthMutation struct {
  32081. config
  32082. op Op
  32083. typ string
  32084. id *uint64
  32085. created_at *time.Time
  32086. updated_at *time.Time
  32087. status *uint8
  32088. addstatus *int8
  32089. deleted_at *time.Time
  32090. addtime *uint64
  32091. addaddtime *int64
  32092. _type *int
  32093. add_type *int
  32094. bot_id *string
  32095. organization_id *uint64
  32096. addorganization_id *int64
  32097. ai_response *uint64
  32098. addai_response *int64
  32099. sop_run *uint64
  32100. addsop_run *int64
  32101. total_friend *uint64
  32102. addtotal_friend *int64
  32103. total_group *uint64
  32104. addtotal_group *int64
  32105. account_balance *uint64
  32106. addaccount_balance *int64
  32107. consume_token *uint64
  32108. addconsume_token *int64
  32109. active_user *uint64
  32110. addactive_user *int64
  32111. new_user *int64
  32112. addnew_user *int64
  32113. label_dist *[]custom_types.LabelDist
  32114. appendlabel_dist []custom_types.LabelDist
  32115. clearedFields map[string]struct{}
  32116. done bool
  32117. oldValue func(context.Context) (*UsageStatisticMonth, error)
  32118. predicates []predicate.UsageStatisticMonth
  32119. }
  32120. var _ ent.Mutation = (*UsageStatisticMonthMutation)(nil)
  32121. // usagestatisticmonthOption allows management of the mutation configuration using functional options.
  32122. type usagestatisticmonthOption func(*UsageStatisticMonthMutation)
  32123. // newUsageStatisticMonthMutation creates new mutation for the UsageStatisticMonth entity.
  32124. func newUsageStatisticMonthMutation(c config, op Op, opts ...usagestatisticmonthOption) *UsageStatisticMonthMutation {
  32125. m := &UsageStatisticMonthMutation{
  32126. config: c,
  32127. op: op,
  32128. typ: TypeUsageStatisticMonth,
  32129. clearedFields: make(map[string]struct{}),
  32130. }
  32131. for _, opt := range opts {
  32132. opt(m)
  32133. }
  32134. return m
  32135. }
  32136. // withUsageStatisticMonthID sets the ID field of the mutation.
  32137. func withUsageStatisticMonthID(id uint64) usagestatisticmonthOption {
  32138. return func(m *UsageStatisticMonthMutation) {
  32139. var (
  32140. err error
  32141. once sync.Once
  32142. value *UsageStatisticMonth
  32143. )
  32144. m.oldValue = func(ctx context.Context) (*UsageStatisticMonth, error) {
  32145. once.Do(func() {
  32146. if m.done {
  32147. err = errors.New("querying old values post mutation is not allowed")
  32148. } else {
  32149. value, err = m.Client().UsageStatisticMonth.Get(ctx, id)
  32150. }
  32151. })
  32152. return value, err
  32153. }
  32154. m.id = &id
  32155. }
  32156. }
  32157. // withUsageStatisticMonth sets the old UsageStatisticMonth of the mutation.
  32158. func withUsageStatisticMonth(node *UsageStatisticMonth) usagestatisticmonthOption {
  32159. return func(m *UsageStatisticMonthMutation) {
  32160. m.oldValue = func(context.Context) (*UsageStatisticMonth, error) {
  32161. return node, nil
  32162. }
  32163. m.id = &node.ID
  32164. }
  32165. }
  32166. // Client returns a new `ent.Client` from the mutation. If the mutation was
  32167. // executed in a transaction (ent.Tx), a transactional client is returned.
  32168. func (m UsageStatisticMonthMutation) Client() *Client {
  32169. client := &Client{config: m.config}
  32170. client.init()
  32171. return client
  32172. }
  32173. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  32174. // it returns an error otherwise.
  32175. func (m UsageStatisticMonthMutation) Tx() (*Tx, error) {
  32176. if _, ok := m.driver.(*txDriver); !ok {
  32177. return nil, errors.New("ent: mutation is not running in a transaction")
  32178. }
  32179. tx := &Tx{config: m.config}
  32180. tx.init()
  32181. return tx, nil
  32182. }
  32183. // SetID sets the value of the id field. Note that this
  32184. // operation is only accepted on creation of UsageStatisticMonth entities.
  32185. func (m *UsageStatisticMonthMutation) SetID(id uint64) {
  32186. m.id = &id
  32187. }
  32188. // ID returns the ID value in the mutation. Note that the ID is only available
  32189. // if it was provided to the builder or after it was returned from the database.
  32190. func (m *UsageStatisticMonthMutation) ID() (id uint64, exists bool) {
  32191. if m.id == nil {
  32192. return
  32193. }
  32194. return *m.id, true
  32195. }
  32196. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  32197. // That means, if the mutation is applied within a transaction with an isolation level such
  32198. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  32199. // or updated by the mutation.
  32200. func (m *UsageStatisticMonthMutation) IDs(ctx context.Context) ([]uint64, error) {
  32201. switch {
  32202. case m.op.Is(OpUpdateOne | OpDeleteOne):
  32203. id, exists := m.ID()
  32204. if exists {
  32205. return []uint64{id}, nil
  32206. }
  32207. fallthrough
  32208. case m.op.Is(OpUpdate | OpDelete):
  32209. return m.Client().UsageStatisticMonth.Query().Where(m.predicates...).IDs(ctx)
  32210. default:
  32211. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  32212. }
  32213. }
  32214. // SetCreatedAt sets the "created_at" field.
  32215. func (m *UsageStatisticMonthMutation) SetCreatedAt(t time.Time) {
  32216. m.created_at = &t
  32217. }
  32218. // CreatedAt returns the value of the "created_at" field in the mutation.
  32219. func (m *UsageStatisticMonthMutation) CreatedAt() (r time.Time, exists bool) {
  32220. v := m.created_at
  32221. if v == nil {
  32222. return
  32223. }
  32224. return *v, true
  32225. }
  32226. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticMonth entity.
  32227. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  32228. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32229. func (m *UsageStatisticMonthMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  32230. if !m.op.Is(OpUpdateOne) {
  32231. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  32232. }
  32233. if m.id == nil || m.oldValue == nil {
  32234. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  32235. }
  32236. oldValue, err := m.oldValue(ctx)
  32237. if err != nil {
  32238. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  32239. }
  32240. return oldValue.CreatedAt, nil
  32241. }
  32242. // ResetCreatedAt resets all changes to the "created_at" field.
  32243. func (m *UsageStatisticMonthMutation) ResetCreatedAt() {
  32244. m.created_at = nil
  32245. }
  32246. // SetUpdatedAt sets the "updated_at" field.
  32247. func (m *UsageStatisticMonthMutation) SetUpdatedAt(t time.Time) {
  32248. m.updated_at = &t
  32249. }
  32250. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  32251. func (m *UsageStatisticMonthMutation) UpdatedAt() (r time.Time, exists bool) {
  32252. v := m.updated_at
  32253. if v == nil {
  32254. return
  32255. }
  32256. return *v, true
  32257. }
  32258. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticMonth entity.
  32259. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  32260. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32261. func (m *UsageStatisticMonthMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  32262. if !m.op.Is(OpUpdateOne) {
  32263. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  32264. }
  32265. if m.id == nil || m.oldValue == nil {
  32266. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  32267. }
  32268. oldValue, err := m.oldValue(ctx)
  32269. if err != nil {
  32270. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  32271. }
  32272. return oldValue.UpdatedAt, nil
  32273. }
  32274. // ResetUpdatedAt resets all changes to the "updated_at" field.
  32275. func (m *UsageStatisticMonthMutation) ResetUpdatedAt() {
  32276. m.updated_at = nil
  32277. }
  32278. // SetStatus sets the "status" field.
  32279. func (m *UsageStatisticMonthMutation) SetStatus(u uint8) {
  32280. m.status = &u
  32281. m.addstatus = nil
  32282. }
  32283. // Status returns the value of the "status" field in the mutation.
  32284. func (m *UsageStatisticMonthMutation) Status() (r uint8, exists bool) {
  32285. v := m.status
  32286. if v == nil {
  32287. return
  32288. }
  32289. return *v, true
  32290. }
  32291. // OldStatus returns the old "status" field's value of the UsageStatisticMonth entity.
  32292. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  32293. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32294. func (m *UsageStatisticMonthMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  32295. if !m.op.Is(OpUpdateOne) {
  32296. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  32297. }
  32298. if m.id == nil || m.oldValue == nil {
  32299. return v, errors.New("OldStatus requires an ID field in the mutation")
  32300. }
  32301. oldValue, err := m.oldValue(ctx)
  32302. if err != nil {
  32303. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  32304. }
  32305. return oldValue.Status, nil
  32306. }
  32307. // AddStatus adds u to the "status" field.
  32308. func (m *UsageStatisticMonthMutation) AddStatus(u int8) {
  32309. if m.addstatus != nil {
  32310. *m.addstatus += u
  32311. } else {
  32312. m.addstatus = &u
  32313. }
  32314. }
  32315. // AddedStatus returns the value that was added to the "status" field in this mutation.
  32316. func (m *UsageStatisticMonthMutation) AddedStatus() (r int8, exists bool) {
  32317. v := m.addstatus
  32318. if v == nil {
  32319. return
  32320. }
  32321. return *v, true
  32322. }
  32323. // ClearStatus clears the value of the "status" field.
  32324. func (m *UsageStatisticMonthMutation) ClearStatus() {
  32325. m.status = nil
  32326. m.addstatus = nil
  32327. m.clearedFields[usagestatisticmonth.FieldStatus] = struct{}{}
  32328. }
  32329. // StatusCleared returns if the "status" field was cleared in this mutation.
  32330. func (m *UsageStatisticMonthMutation) StatusCleared() bool {
  32331. _, ok := m.clearedFields[usagestatisticmonth.FieldStatus]
  32332. return ok
  32333. }
  32334. // ResetStatus resets all changes to the "status" field.
  32335. func (m *UsageStatisticMonthMutation) ResetStatus() {
  32336. m.status = nil
  32337. m.addstatus = nil
  32338. delete(m.clearedFields, usagestatisticmonth.FieldStatus)
  32339. }
  32340. // SetDeletedAt sets the "deleted_at" field.
  32341. func (m *UsageStatisticMonthMutation) SetDeletedAt(t time.Time) {
  32342. m.deleted_at = &t
  32343. }
  32344. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  32345. func (m *UsageStatisticMonthMutation) DeletedAt() (r time.Time, exists bool) {
  32346. v := m.deleted_at
  32347. if v == nil {
  32348. return
  32349. }
  32350. return *v, true
  32351. }
  32352. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticMonth entity.
  32353. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  32354. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32355. func (m *UsageStatisticMonthMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  32356. if !m.op.Is(OpUpdateOne) {
  32357. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  32358. }
  32359. if m.id == nil || m.oldValue == nil {
  32360. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  32361. }
  32362. oldValue, err := m.oldValue(ctx)
  32363. if err != nil {
  32364. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  32365. }
  32366. return oldValue.DeletedAt, nil
  32367. }
  32368. // ClearDeletedAt clears the value of the "deleted_at" field.
  32369. func (m *UsageStatisticMonthMutation) ClearDeletedAt() {
  32370. m.deleted_at = nil
  32371. m.clearedFields[usagestatisticmonth.FieldDeletedAt] = struct{}{}
  32372. }
  32373. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  32374. func (m *UsageStatisticMonthMutation) DeletedAtCleared() bool {
  32375. _, ok := m.clearedFields[usagestatisticmonth.FieldDeletedAt]
  32376. return ok
  32377. }
  32378. // ResetDeletedAt resets all changes to the "deleted_at" field.
  32379. func (m *UsageStatisticMonthMutation) ResetDeletedAt() {
  32380. m.deleted_at = nil
  32381. delete(m.clearedFields, usagestatisticmonth.FieldDeletedAt)
  32382. }
  32383. // SetAddtime sets the "addtime" field.
  32384. func (m *UsageStatisticMonthMutation) SetAddtime(u uint64) {
  32385. m.addtime = &u
  32386. m.addaddtime = nil
  32387. }
  32388. // Addtime returns the value of the "addtime" field in the mutation.
  32389. func (m *UsageStatisticMonthMutation) Addtime() (r uint64, exists bool) {
  32390. v := m.addtime
  32391. if v == nil {
  32392. return
  32393. }
  32394. return *v, true
  32395. }
  32396. // OldAddtime returns the old "addtime" field's value of the UsageStatisticMonth entity.
  32397. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  32398. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32399. func (m *UsageStatisticMonthMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  32400. if !m.op.Is(OpUpdateOne) {
  32401. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  32402. }
  32403. if m.id == nil || m.oldValue == nil {
  32404. return v, errors.New("OldAddtime requires an ID field in the mutation")
  32405. }
  32406. oldValue, err := m.oldValue(ctx)
  32407. if err != nil {
  32408. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  32409. }
  32410. return oldValue.Addtime, nil
  32411. }
  32412. // AddAddtime adds u to the "addtime" field.
  32413. func (m *UsageStatisticMonthMutation) AddAddtime(u int64) {
  32414. if m.addaddtime != nil {
  32415. *m.addaddtime += u
  32416. } else {
  32417. m.addaddtime = &u
  32418. }
  32419. }
  32420. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  32421. func (m *UsageStatisticMonthMutation) AddedAddtime() (r int64, exists bool) {
  32422. v := m.addaddtime
  32423. if v == nil {
  32424. return
  32425. }
  32426. return *v, true
  32427. }
  32428. // ResetAddtime resets all changes to the "addtime" field.
  32429. func (m *UsageStatisticMonthMutation) ResetAddtime() {
  32430. m.addtime = nil
  32431. m.addaddtime = nil
  32432. }
  32433. // SetType sets the "type" field.
  32434. func (m *UsageStatisticMonthMutation) SetType(i int) {
  32435. m._type = &i
  32436. m.add_type = nil
  32437. }
  32438. // GetType returns the value of the "type" field in the mutation.
  32439. func (m *UsageStatisticMonthMutation) GetType() (r int, exists bool) {
  32440. v := m._type
  32441. if v == nil {
  32442. return
  32443. }
  32444. return *v, true
  32445. }
  32446. // OldType returns the old "type" field's value of the UsageStatisticMonth entity.
  32447. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  32448. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32449. func (m *UsageStatisticMonthMutation) OldType(ctx context.Context) (v int, err error) {
  32450. if !m.op.Is(OpUpdateOne) {
  32451. return v, errors.New("OldType is only allowed on UpdateOne operations")
  32452. }
  32453. if m.id == nil || m.oldValue == nil {
  32454. return v, errors.New("OldType requires an ID field in the mutation")
  32455. }
  32456. oldValue, err := m.oldValue(ctx)
  32457. if err != nil {
  32458. return v, fmt.Errorf("querying old value for OldType: %w", err)
  32459. }
  32460. return oldValue.Type, nil
  32461. }
  32462. // AddType adds i to the "type" field.
  32463. func (m *UsageStatisticMonthMutation) AddType(i int) {
  32464. if m.add_type != nil {
  32465. *m.add_type += i
  32466. } else {
  32467. m.add_type = &i
  32468. }
  32469. }
  32470. // AddedType returns the value that was added to the "type" field in this mutation.
  32471. func (m *UsageStatisticMonthMutation) AddedType() (r int, exists bool) {
  32472. v := m.add_type
  32473. if v == nil {
  32474. return
  32475. }
  32476. return *v, true
  32477. }
  32478. // ResetType resets all changes to the "type" field.
  32479. func (m *UsageStatisticMonthMutation) ResetType() {
  32480. m._type = nil
  32481. m.add_type = nil
  32482. }
  32483. // SetBotID sets the "bot_id" field.
  32484. func (m *UsageStatisticMonthMutation) SetBotID(s string) {
  32485. m.bot_id = &s
  32486. }
  32487. // BotID returns the value of the "bot_id" field in the mutation.
  32488. func (m *UsageStatisticMonthMutation) BotID() (r string, exists bool) {
  32489. v := m.bot_id
  32490. if v == nil {
  32491. return
  32492. }
  32493. return *v, true
  32494. }
  32495. // OldBotID returns the old "bot_id" field's value of the UsageStatisticMonth entity.
  32496. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  32497. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32498. func (m *UsageStatisticMonthMutation) OldBotID(ctx context.Context) (v string, err error) {
  32499. if !m.op.Is(OpUpdateOne) {
  32500. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  32501. }
  32502. if m.id == nil || m.oldValue == nil {
  32503. return v, errors.New("OldBotID requires an ID field in the mutation")
  32504. }
  32505. oldValue, err := m.oldValue(ctx)
  32506. if err != nil {
  32507. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  32508. }
  32509. return oldValue.BotID, nil
  32510. }
  32511. // ClearBotID clears the value of the "bot_id" field.
  32512. func (m *UsageStatisticMonthMutation) ClearBotID() {
  32513. m.bot_id = nil
  32514. m.clearedFields[usagestatisticmonth.FieldBotID] = struct{}{}
  32515. }
  32516. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  32517. func (m *UsageStatisticMonthMutation) BotIDCleared() bool {
  32518. _, ok := m.clearedFields[usagestatisticmonth.FieldBotID]
  32519. return ok
  32520. }
  32521. // ResetBotID resets all changes to the "bot_id" field.
  32522. func (m *UsageStatisticMonthMutation) ResetBotID() {
  32523. m.bot_id = nil
  32524. delete(m.clearedFields, usagestatisticmonth.FieldBotID)
  32525. }
  32526. // SetOrganizationID sets the "organization_id" field.
  32527. func (m *UsageStatisticMonthMutation) SetOrganizationID(u uint64) {
  32528. m.organization_id = &u
  32529. m.addorganization_id = nil
  32530. }
  32531. // OrganizationID returns the value of the "organization_id" field in the mutation.
  32532. func (m *UsageStatisticMonthMutation) OrganizationID() (r uint64, exists bool) {
  32533. v := m.organization_id
  32534. if v == nil {
  32535. return
  32536. }
  32537. return *v, true
  32538. }
  32539. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticMonth entity.
  32540. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  32541. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32542. func (m *UsageStatisticMonthMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  32543. if !m.op.Is(OpUpdateOne) {
  32544. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  32545. }
  32546. if m.id == nil || m.oldValue == nil {
  32547. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  32548. }
  32549. oldValue, err := m.oldValue(ctx)
  32550. if err != nil {
  32551. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  32552. }
  32553. return oldValue.OrganizationID, nil
  32554. }
  32555. // AddOrganizationID adds u to the "organization_id" field.
  32556. func (m *UsageStatisticMonthMutation) AddOrganizationID(u int64) {
  32557. if m.addorganization_id != nil {
  32558. *m.addorganization_id += u
  32559. } else {
  32560. m.addorganization_id = &u
  32561. }
  32562. }
  32563. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  32564. func (m *UsageStatisticMonthMutation) AddedOrganizationID() (r int64, exists bool) {
  32565. v := m.addorganization_id
  32566. if v == nil {
  32567. return
  32568. }
  32569. return *v, true
  32570. }
  32571. // ClearOrganizationID clears the value of the "organization_id" field.
  32572. func (m *UsageStatisticMonthMutation) ClearOrganizationID() {
  32573. m.organization_id = nil
  32574. m.addorganization_id = nil
  32575. m.clearedFields[usagestatisticmonth.FieldOrganizationID] = struct{}{}
  32576. }
  32577. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  32578. func (m *UsageStatisticMonthMutation) OrganizationIDCleared() bool {
  32579. _, ok := m.clearedFields[usagestatisticmonth.FieldOrganizationID]
  32580. return ok
  32581. }
  32582. // ResetOrganizationID resets all changes to the "organization_id" field.
  32583. func (m *UsageStatisticMonthMutation) ResetOrganizationID() {
  32584. m.organization_id = nil
  32585. m.addorganization_id = nil
  32586. delete(m.clearedFields, usagestatisticmonth.FieldOrganizationID)
  32587. }
  32588. // SetAiResponse sets the "ai_response" field.
  32589. func (m *UsageStatisticMonthMutation) SetAiResponse(u uint64) {
  32590. m.ai_response = &u
  32591. m.addai_response = nil
  32592. }
  32593. // AiResponse returns the value of the "ai_response" field in the mutation.
  32594. func (m *UsageStatisticMonthMutation) AiResponse() (r uint64, exists bool) {
  32595. v := m.ai_response
  32596. if v == nil {
  32597. return
  32598. }
  32599. return *v, true
  32600. }
  32601. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticMonth entity.
  32602. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  32603. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32604. func (m *UsageStatisticMonthMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  32605. if !m.op.Is(OpUpdateOne) {
  32606. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  32607. }
  32608. if m.id == nil || m.oldValue == nil {
  32609. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  32610. }
  32611. oldValue, err := m.oldValue(ctx)
  32612. if err != nil {
  32613. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  32614. }
  32615. return oldValue.AiResponse, nil
  32616. }
  32617. // AddAiResponse adds u to the "ai_response" field.
  32618. func (m *UsageStatisticMonthMutation) AddAiResponse(u int64) {
  32619. if m.addai_response != nil {
  32620. *m.addai_response += u
  32621. } else {
  32622. m.addai_response = &u
  32623. }
  32624. }
  32625. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  32626. func (m *UsageStatisticMonthMutation) AddedAiResponse() (r int64, exists bool) {
  32627. v := m.addai_response
  32628. if v == nil {
  32629. return
  32630. }
  32631. return *v, true
  32632. }
  32633. // ResetAiResponse resets all changes to the "ai_response" field.
  32634. func (m *UsageStatisticMonthMutation) ResetAiResponse() {
  32635. m.ai_response = nil
  32636. m.addai_response = nil
  32637. }
  32638. // SetSopRun sets the "sop_run" field.
  32639. func (m *UsageStatisticMonthMutation) SetSopRun(u uint64) {
  32640. m.sop_run = &u
  32641. m.addsop_run = nil
  32642. }
  32643. // SopRun returns the value of the "sop_run" field in the mutation.
  32644. func (m *UsageStatisticMonthMutation) SopRun() (r uint64, exists bool) {
  32645. v := m.sop_run
  32646. if v == nil {
  32647. return
  32648. }
  32649. return *v, true
  32650. }
  32651. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticMonth entity.
  32652. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  32653. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32654. func (m *UsageStatisticMonthMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  32655. if !m.op.Is(OpUpdateOne) {
  32656. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  32657. }
  32658. if m.id == nil || m.oldValue == nil {
  32659. return v, errors.New("OldSopRun requires an ID field in the mutation")
  32660. }
  32661. oldValue, err := m.oldValue(ctx)
  32662. if err != nil {
  32663. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  32664. }
  32665. return oldValue.SopRun, nil
  32666. }
  32667. // AddSopRun adds u to the "sop_run" field.
  32668. func (m *UsageStatisticMonthMutation) AddSopRun(u int64) {
  32669. if m.addsop_run != nil {
  32670. *m.addsop_run += u
  32671. } else {
  32672. m.addsop_run = &u
  32673. }
  32674. }
  32675. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  32676. func (m *UsageStatisticMonthMutation) AddedSopRun() (r int64, exists bool) {
  32677. v := m.addsop_run
  32678. if v == nil {
  32679. return
  32680. }
  32681. return *v, true
  32682. }
  32683. // ResetSopRun resets all changes to the "sop_run" field.
  32684. func (m *UsageStatisticMonthMutation) ResetSopRun() {
  32685. m.sop_run = nil
  32686. m.addsop_run = nil
  32687. }
  32688. // SetTotalFriend sets the "total_friend" field.
  32689. func (m *UsageStatisticMonthMutation) SetTotalFriend(u uint64) {
  32690. m.total_friend = &u
  32691. m.addtotal_friend = nil
  32692. }
  32693. // TotalFriend returns the value of the "total_friend" field in the mutation.
  32694. func (m *UsageStatisticMonthMutation) TotalFriend() (r uint64, exists bool) {
  32695. v := m.total_friend
  32696. if v == nil {
  32697. return
  32698. }
  32699. return *v, true
  32700. }
  32701. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticMonth entity.
  32702. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  32703. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32704. func (m *UsageStatisticMonthMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  32705. if !m.op.Is(OpUpdateOne) {
  32706. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  32707. }
  32708. if m.id == nil || m.oldValue == nil {
  32709. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  32710. }
  32711. oldValue, err := m.oldValue(ctx)
  32712. if err != nil {
  32713. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  32714. }
  32715. return oldValue.TotalFriend, nil
  32716. }
  32717. // AddTotalFriend adds u to the "total_friend" field.
  32718. func (m *UsageStatisticMonthMutation) AddTotalFriend(u int64) {
  32719. if m.addtotal_friend != nil {
  32720. *m.addtotal_friend += u
  32721. } else {
  32722. m.addtotal_friend = &u
  32723. }
  32724. }
  32725. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  32726. func (m *UsageStatisticMonthMutation) AddedTotalFriend() (r int64, exists bool) {
  32727. v := m.addtotal_friend
  32728. if v == nil {
  32729. return
  32730. }
  32731. return *v, true
  32732. }
  32733. // ResetTotalFriend resets all changes to the "total_friend" field.
  32734. func (m *UsageStatisticMonthMutation) ResetTotalFriend() {
  32735. m.total_friend = nil
  32736. m.addtotal_friend = nil
  32737. }
  32738. // SetTotalGroup sets the "total_group" field.
  32739. func (m *UsageStatisticMonthMutation) SetTotalGroup(u uint64) {
  32740. m.total_group = &u
  32741. m.addtotal_group = nil
  32742. }
  32743. // TotalGroup returns the value of the "total_group" field in the mutation.
  32744. func (m *UsageStatisticMonthMutation) TotalGroup() (r uint64, exists bool) {
  32745. v := m.total_group
  32746. if v == nil {
  32747. return
  32748. }
  32749. return *v, true
  32750. }
  32751. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticMonth entity.
  32752. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  32753. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32754. func (m *UsageStatisticMonthMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  32755. if !m.op.Is(OpUpdateOne) {
  32756. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  32757. }
  32758. if m.id == nil || m.oldValue == nil {
  32759. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  32760. }
  32761. oldValue, err := m.oldValue(ctx)
  32762. if err != nil {
  32763. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  32764. }
  32765. return oldValue.TotalGroup, nil
  32766. }
  32767. // AddTotalGroup adds u to the "total_group" field.
  32768. func (m *UsageStatisticMonthMutation) AddTotalGroup(u int64) {
  32769. if m.addtotal_group != nil {
  32770. *m.addtotal_group += u
  32771. } else {
  32772. m.addtotal_group = &u
  32773. }
  32774. }
  32775. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  32776. func (m *UsageStatisticMonthMutation) AddedTotalGroup() (r int64, exists bool) {
  32777. v := m.addtotal_group
  32778. if v == nil {
  32779. return
  32780. }
  32781. return *v, true
  32782. }
  32783. // ResetTotalGroup resets all changes to the "total_group" field.
  32784. func (m *UsageStatisticMonthMutation) ResetTotalGroup() {
  32785. m.total_group = nil
  32786. m.addtotal_group = nil
  32787. }
  32788. // SetAccountBalance sets the "account_balance" field.
  32789. func (m *UsageStatisticMonthMutation) SetAccountBalance(u uint64) {
  32790. m.account_balance = &u
  32791. m.addaccount_balance = nil
  32792. }
  32793. // AccountBalance returns the value of the "account_balance" field in the mutation.
  32794. func (m *UsageStatisticMonthMutation) AccountBalance() (r uint64, exists bool) {
  32795. v := m.account_balance
  32796. if v == nil {
  32797. return
  32798. }
  32799. return *v, true
  32800. }
  32801. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticMonth entity.
  32802. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  32803. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32804. func (m *UsageStatisticMonthMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  32805. if !m.op.Is(OpUpdateOne) {
  32806. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  32807. }
  32808. if m.id == nil || m.oldValue == nil {
  32809. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  32810. }
  32811. oldValue, err := m.oldValue(ctx)
  32812. if err != nil {
  32813. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  32814. }
  32815. return oldValue.AccountBalance, nil
  32816. }
  32817. // AddAccountBalance adds u to the "account_balance" field.
  32818. func (m *UsageStatisticMonthMutation) AddAccountBalance(u int64) {
  32819. if m.addaccount_balance != nil {
  32820. *m.addaccount_balance += u
  32821. } else {
  32822. m.addaccount_balance = &u
  32823. }
  32824. }
  32825. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  32826. func (m *UsageStatisticMonthMutation) AddedAccountBalance() (r int64, exists bool) {
  32827. v := m.addaccount_balance
  32828. if v == nil {
  32829. return
  32830. }
  32831. return *v, true
  32832. }
  32833. // ResetAccountBalance resets all changes to the "account_balance" field.
  32834. func (m *UsageStatisticMonthMutation) ResetAccountBalance() {
  32835. m.account_balance = nil
  32836. m.addaccount_balance = nil
  32837. }
  32838. // SetConsumeToken sets the "consume_token" field.
  32839. func (m *UsageStatisticMonthMutation) SetConsumeToken(u uint64) {
  32840. m.consume_token = &u
  32841. m.addconsume_token = nil
  32842. }
  32843. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  32844. func (m *UsageStatisticMonthMutation) ConsumeToken() (r uint64, exists bool) {
  32845. v := m.consume_token
  32846. if v == nil {
  32847. return
  32848. }
  32849. return *v, true
  32850. }
  32851. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticMonth entity.
  32852. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  32853. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32854. func (m *UsageStatisticMonthMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  32855. if !m.op.Is(OpUpdateOne) {
  32856. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  32857. }
  32858. if m.id == nil || m.oldValue == nil {
  32859. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  32860. }
  32861. oldValue, err := m.oldValue(ctx)
  32862. if err != nil {
  32863. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  32864. }
  32865. return oldValue.ConsumeToken, nil
  32866. }
  32867. // AddConsumeToken adds u to the "consume_token" field.
  32868. func (m *UsageStatisticMonthMutation) AddConsumeToken(u int64) {
  32869. if m.addconsume_token != nil {
  32870. *m.addconsume_token += u
  32871. } else {
  32872. m.addconsume_token = &u
  32873. }
  32874. }
  32875. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  32876. func (m *UsageStatisticMonthMutation) AddedConsumeToken() (r int64, exists bool) {
  32877. v := m.addconsume_token
  32878. if v == nil {
  32879. return
  32880. }
  32881. return *v, true
  32882. }
  32883. // ResetConsumeToken resets all changes to the "consume_token" field.
  32884. func (m *UsageStatisticMonthMutation) ResetConsumeToken() {
  32885. m.consume_token = nil
  32886. m.addconsume_token = nil
  32887. }
  32888. // SetActiveUser sets the "active_user" field.
  32889. func (m *UsageStatisticMonthMutation) SetActiveUser(u uint64) {
  32890. m.active_user = &u
  32891. m.addactive_user = nil
  32892. }
  32893. // ActiveUser returns the value of the "active_user" field in the mutation.
  32894. func (m *UsageStatisticMonthMutation) ActiveUser() (r uint64, exists bool) {
  32895. v := m.active_user
  32896. if v == nil {
  32897. return
  32898. }
  32899. return *v, true
  32900. }
  32901. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticMonth entity.
  32902. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  32903. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32904. func (m *UsageStatisticMonthMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  32905. if !m.op.Is(OpUpdateOne) {
  32906. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  32907. }
  32908. if m.id == nil || m.oldValue == nil {
  32909. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  32910. }
  32911. oldValue, err := m.oldValue(ctx)
  32912. if err != nil {
  32913. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  32914. }
  32915. return oldValue.ActiveUser, nil
  32916. }
  32917. // AddActiveUser adds u to the "active_user" field.
  32918. func (m *UsageStatisticMonthMutation) AddActiveUser(u int64) {
  32919. if m.addactive_user != nil {
  32920. *m.addactive_user += u
  32921. } else {
  32922. m.addactive_user = &u
  32923. }
  32924. }
  32925. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  32926. func (m *UsageStatisticMonthMutation) AddedActiveUser() (r int64, exists bool) {
  32927. v := m.addactive_user
  32928. if v == nil {
  32929. return
  32930. }
  32931. return *v, true
  32932. }
  32933. // ResetActiveUser resets all changes to the "active_user" field.
  32934. func (m *UsageStatisticMonthMutation) ResetActiveUser() {
  32935. m.active_user = nil
  32936. m.addactive_user = nil
  32937. }
  32938. // SetNewUser sets the "new_user" field.
  32939. func (m *UsageStatisticMonthMutation) SetNewUser(i int64) {
  32940. m.new_user = &i
  32941. m.addnew_user = nil
  32942. }
  32943. // NewUser returns the value of the "new_user" field in the mutation.
  32944. func (m *UsageStatisticMonthMutation) NewUser() (r int64, exists bool) {
  32945. v := m.new_user
  32946. if v == nil {
  32947. return
  32948. }
  32949. return *v, true
  32950. }
  32951. // OldNewUser returns the old "new_user" field's value of the UsageStatisticMonth entity.
  32952. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  32953. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32954. func (m *UsageStatisticMonthMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  32955. if !m.op.Is(OpUpdateOne) {
  32956. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  32957. }
  32958. if m.id == nil || m.oldValue == nil {
  32959. return v, errors.New("OldNewUser requires an ID field in the mutation")
  32960. }
  32961. oldValue, err := m.oldValue(ctx)
  32962. if err != nil {
  32963. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  32964. }
  32965. return oldValue.NewUser, nil
  32966. }
  32967. // AddNewUser adds i to the "new_user" field.
  32968. func (m *UsageStatisticMonthMutation) AddNewUser(i int64) {
  32969. if m.addnew_user != nil {
  32970. *m.addnew_user += i
  32971. } else {
  32972. m.addnew_user = &i
  32973. }
  32974. }
  32975. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  32976. func (m *UsageStatisticMonthMutation) AddedNewUser() (r int64, exists bool) {
  32977. v := m.addnew_user
  32978. if v == nil {
  32979. return
  32980. }
  32981. return *v, true
  32982. }
  32983. // ResetNewUser resets all changes to the "new_user" field.
  32984. func (m *UsageStatisticMonthMutation) ResetNewUser() {
  32985. m.new_user = nil
  32986. m.addnew_user = nil
  32987. }
  32988. // SetLabelDist sets the "label_dist" field.
  32989. func (m *UsageStatisticMonthMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  32990. m.label_dist = &ctd
  32991. m.appendlabel_dist = nil
  32992. }
  32993. // LabelDist returns the value of the "label_dist" field in the mutation.
  32994. func (m *UsageStatisticMonthMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  32995. v := m.label_dist
  32996. if v == nil {
  32997. return
  32998. }
  32999. return *v, true
  33000. }
  33001. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticMonth entity.
  33002. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  33003. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33004. func (m *UsageStatisticMonthMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  33005. if !m.op.Is(OpUpdateOne) {
  33006. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  33007. }
  33008. if m.id == nil || m.oldValue == nil {
  33009. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  33010. }
  33011. oldValue, err := m.oldValue(ctx)
  33012. if err != nil {
  33013. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  33014. }
  33015. return oldValue.LabelDist, nil
  33016. }
  33017. // AppendLabelDist adds ctd to the "label_dist" field.
  33018. func (m *UsageStatisticMonthMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  33019. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  33020. }
  33021. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  33022. func (m *UsageStatisticMonthMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  33023. if len(m.appendlabel_dist) == 0 {
  33024. return nil, false
  33025. }
  33026. return m.appendlabel_dist, true
  33027. }
  33028. // ResetLabelDist resets all changes to the "label_dist" field.
  33029. func (m *UsageStatisticMonthMutation) ResetLabelDist() {
  33030. m.label_dist = nil
  33031. m.appendlabel_dist = nil
  33032. }
  33033. // Where appends a list predicates to the UsageStatisticMonthMutation builder.
  33034. func (m *UsageStatisticMonthMutation) Where(ps ...predicate.UsageStatisticMonth) {
  33035. m.predicates = append(m.predicates, ps...)
  33036. }
  33037. // WhereP appends storage-level predicates to the UsageStatisticMonthMutation builder. Using this method,
  33038. // users can use type-assertion to append predicates that do not depend on any generated package.
  33039. func (m *UsageStatisticMonthMutation) WhereP(ps ...func(*sql.Selector)) {
  33040. p := make([]predicate.UsageStatisticMonth, len(ps))
  33041. for i := range ps {
  33042. p[i] = ps[i]
  33043. }
  33044. m.Where(p...)
  33045. }
  33046. // Op returns the operation name.
  33047. func (m *UsageStatisticMonthMutation) Op() Op {
  33048. return m.op
  33049. }
  33050. // SetOp allows setting the mutation operation.
  33051. func (m *UsageStatisticMonthMutation) SetOp(op Op) {
  33052. m.op = op
  33053. }
  33054. // Type returns the node type of this mutation (UsageStatisticMonth).
  33055. func (m *UsageStatisticMonthMutation) Type() string {
  33056. return m.typ
  33057. }
  33058. // Fields returns all fields that were changed during this mutation. Note that in
  33059. // order to get all numeric fields that were incremented/decremented, call
  33060. // AddedFields().
  33061. func (m *UsageStatisticMonthMutation) Fields() []string {
  33062. fields := make([]string, 0, 17)
  33063. if m.created_at != nil {
  33064. fields = append(fields, usagestatisticmonth.FieldCreatedAt)
  33065. }
  33066. if m.updated_at != nil {
  33067. fields = append(fields, usagestatisticmonth.FieldUpdatedAt)
  33068. }
  33069. if m.status != nil {
  33070. fields = append(fields, usagestatisticmonth.FieldStatus)
  33071. }
  33072. if m.deleted_at != nil {
  33073. fields = append(fields, usagestatisticmonth.FieldDeletedAt)
  33074. }
  33075. if m.addtime != nil {
  33076. fields = append(fields, usagestatisticmonth.FieldAddtime)
  33077. }
  33078. if m._type != nil {
  33079. fields = append(fields, usagestatisticmonth.FieldType)
  33080. }
  33081. if m.bot_id != nil {
  33082. fields = append(fields, usagestatisticmonth.FieldBotID)
  33083. }
  33084. if m.organization_id != nil {
  33085. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  33086. }
  33087. if m.ai_response != nil {
  33088. fields = append(fields, usagestatisticmonth.FieldAiResponse)
  33089. }
  33090. if m.sop_run != nil {
  33091. fields = append(fields, usagestatisticmonth.FieldSopRun)
  33092. }
  33093. if m.total_friend != nil {
  33094. fields = append(fields, usagestatisticmonth.FieldTotalFriend)
  33095. }
  33096. if m.total_group != nil {
  33097. fields = append(fields, usagestatisticmonth.FieldTotalGroup)
  33098. }
  33099. if m.account_balance != nil {
  33100. fields = append(fields, usagestatisticmonth.FieldAccountBalance)
  33101. }
  33102. if m.consume_token != nil {
  33103. fields = append(fields, usagestatisticmonth.FieldConsumeToken)
  33104. }
  33105. if m.active_user != nil {
  33106. fields = append(fields, usagestatisticmonth.FieldActiveUser)
  33107. }
  33108. if m.new_user != nil {
  33109. fields = append(fields, usagestatisticmonth.FieldNewUser)
  33110. }
  33111. if m.label_dist != nil {
  33112. fields = append(fields, usagestatisticmonth.FieldLabelDist)
  33113. }
  33114. return fields
  33115. }
  33116. // Field returns the value of a field with the given name. The second boolean
  33117. // return value indicates that this field was not set, or was not defined in the
  33118. // schema.
  33119. func (m *UsageStatisticMonthMutation) Field(name string) (ent.Value, bool) {
  33120. switch name {
  33121. case usagestatisticmonth.FieldCreatedAt:
  33122. return m.CreatedAt()
  33123. case usagestatisticmonth.FieldUpdatedAt:
  33124. return m.UpdatedAt()
  33125. case usagestatisticmonth.FieldStatus:
  33126. return m.Status()
  33127. case usagestatisticmonth.FieldDeletedAt:
  33128. return m.DeletedAt()
  33129. case usagestatisticmonth.FieldAddtime:
  33130. return m.Addtime()
  33131. case usagestatisticmonth.FieldType:
  33132. return m.GetType()
  33133. case usagestatisticmonth.FieldBotID:
  33134. return m.BotID()
  33135. case usagestatisticmonth.FieldOrganizationID:
  33136. return m.OrganizationID()
  33137. case usagestatisticmonth.FieldAiResponse:
  33138. return m.AiResponse()
  33139. case usagestatisticmonth.FieldSopRun:
  33140. return m.SopRun()
  33141. case usagestatisticmonth.FieldTotalFriend:
  33142. return m.TotalFriend()
  33143. case usagestatisticmonth.FieldTotalGroup:
  33144. return m.TotalGroup()
  33145. case usagestatisticmonth.FieldAccountBalance:
  33146. return m.AccountBalance()
  33147. case usagestatisticmonth.FieldConsumeToken:
  33148. return m.ConsumeToken()
  33149. case usagestatisticmonth.FieldActiveUser:
  33150. return m.ActiveUser()
  33151. case usagestatisticmonth.FieldNewUser:
  33152. return m.NewUser()
  33153. case usagestatisticmonth.FieldLabelDist:
  33154. return m.LabelDist()
  33155. }
  33156. return nil, false
  33157. }
  33158. // OldField returns the old value of the field from the database. An error is
  33159. // returned if the mutation operation is not UpdateOne, or the query to the
  33160. // database failed.
  33161. func (m *UsageStatisticMonthMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  33162. switch name {
  33163. case usagestatisticmonth.FieldCreatedAt:
  33164. return m.OldCreatedAt(ctx)
  33165. case usagestatisticmonth.FieldUpdatedAt:
  33166. return m.OldUpdatedAt(ctx)
  33167. case usagestatisticmonth.FieldStatus:
  33168. return m.OldStatus(ctx)
  33169. case usagestatisticmonth.FieldDeletedAt:
  33170. return m.OldDeletedAt(ctx)
  33171. case usagestatisticmonth.FieldAddtime:
  33172. return m.OldAddtime(ctx)
  33173. case usagestatisticmonth.FieldType:
  33174. return m.OldType(ctx)
  33175. case usagestatisticmonth.FieldBotID:
  33176. return m.OldBotID(ctx)
  33177. case usagestatisticmonth.FieldOrganizationID:
  33178. return m.OldOrganizationID(ctx)
  33179. case usagestatisticmonth.FieldAiResponse:
  33180. return m.OldAiResponse(ctx)
  33181. case usagestatisticmonth.FieldSopRun:
  33182. return m.OldSopRun(ctx)
  33183. case usagestatisticmonth.FieldTotalFriend:
  33184. return m.OldTotalFriend(ctx)
  33185. case usagestatisticmonth.FieldTotalGroup:
  33186. return m.OldTotalGroup(ctx)
  33187. case usagestatisticmonth.FieldAccountBalance:
  33188. return m.OldAccountBalance(ctx)
  33189. case usagestatisticmonth.FieldConsumeToken:
  33190. return m.OldConsumeToken(ctx)
  33191. case usagestatisticmonth.FieldActiveUser:
  33192. return m.OldActiveUser(ctx)
  33193. case usagestatisticmonth.FieldNewUser:
  33194. return m.OldNewUser(ctx)
  33195. case usagestatisticmonth.FieldLabelDist:
  33196. return m.OldLabelDist(ctx)
  33197. }
  33198. return nil, fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  33199. }
  33200. // SetField sets the value of a field with the given name. It returns an error if
  33201. // the field is not defined in the schema, or if the type mismatched the field
  33202. // type.
  33203. func (m *UsageStatisticMonthMutation) SetField(name string, value ent.Value) error {
  33204. switch name {
  33205. case usagestatisticmonth.FieldCreatedAt:
  33206. v, ok := value.(time.Time)
  33207. if !ok {
  33208. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33209. }
  33210. m.SetCreatedAt(v)
  33211. return nil
  33212. case usagestatisticmonth.FieldUpdatedAt:
  33213. v, ok := value.(time.Time)
  33214. if !ok {
  33215. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33216. }
  33217. m.SetUpdatedAt(v)
  33218. return nil
  33219. case usagestatisticmonth.FieldStatus:
  33220. v, ok := value.(uint8)
  33221. if !ok {
  33222. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33223. }
  33224. m.SetStatus(v)
  33225. return nil
  33226. case usagestatisticmonth.FieldDeletedAt:
  33227. v, ok := value.(time.Time)
  33228. if !ok {
  33229. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33230. }
  33231. m.SetDeletedAt(v)
  33232. return nil
  33233. case usagestatisticmonth.FieldAddtime:
  33234. v, ok := value.(uint64)
  33235. if !ok {
  33236. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33237. }
  33238. m.SetAddtime(v)
  33239. return nil
  33240. case usagestatisticmonth.FieldType:
  33241. v, ok := value.(int)
  33242. if !ok {
  33243. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33244. }
  33245. m.SetType(v)
  33246. return nil
  33247. case usagestatisticmonth.FieldBotID:
  33248. v, ok := value.(string)
  33249. if !ok {
  33250. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33251. }
  33252. m.SetBotID(v)
  33253. return nil
  33254. case usagestatisticmonth.FieldOrganizationID:
  33255. v, ok := value.(uint64)
  33256. if !ok {
  33257. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33258. }
  33259. m.SetOrganizationID(v)
  33260. return nil
  33261. case usagestatisticmonth.FieldAiResponse:
  33262. v, ok := value.(uint64)
  33263. if !ok {
  33264. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33265. }
  33266. m.SetAiResponse(v)
  33267. return nil
  33268. case usagestatisticmonth.FieldSopRun:
  33269. v, ok := value.(uint64)
  33270. if !ok {
  33271. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33272. }
  33273. m.SetSopRun(v)
  33274. return nil
  33275. case usagestatisticmonth.FieldTotalFriend:
  33276. v, ok := value.(uint64)
  33277. if !ok {
  33278. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33279. }
  33280. m.SetTotalFriend(v)
  33281. return nil
  33282. case usagestatisticmonth.FieldTotalGroup:
  33283. v, ok := value.(uint64)
  33284. if !ok {
  33285. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33286. }
  33287. m.SetTotalGroup(v)
  33288. return nil
  33289. case usagestatisticmonth.FieldAccountBalance:
  33290. v, ok := value.(uint64)
  33291. if !ok {
  33292. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33293. }
  33294. m.SetAccountBalance(v)
  33295. return nil
  33296. case usagestatisticmonth.FieldConsumeToken:
  33297. v, ok := value.(uint64)
  33298. if !ok {
  33299. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33300. }
  33301. m.SetConsumeToken(v)
  33302. return nil
  33303. case usagestatisticmonth.FieldActiveUser:
  33304. v, ok := value.(uint64)
  33305. if !ok {
  33306. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33307. }
  33308. m.SetActiveUser(v)
  33309. return nil
  33310. case usagestatisticmonth.FieldNewUser:
  33311. v, ok := value.(int64)
  33312. if !ok {
  33313. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33314. }
  33315. m.SetNewUser(v)
  33316. return nil
  33317. case usagestatisticmonth.FieldLabelDist:
  33318. v, ok := value.([]custom_types.LabelDist)
  33319. if !ok {
  33320. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33321. }
  33322. m.SetLabelDist(v)
  33323. return nil
  33324. }
  33325. return fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  33326. }
  33327. // AddedFields returns all numeric fields that were incremented/decremented during
  33328. // this mutation.
  33329. func (m *UsageStatisticMonthMutation) AddedFields() []string {
  33330. var fields []string
  33331. if m.addstatus != nil {
  33332. fields = append(fields, usagestatisticmonth.FieldStatus)
  33333. }
  33334. if m.addaddtime != nil {
  33335. fields = append(fields, usagestatisticmonth.FieldAddtime)
  33336. }
  33337. if m.add_type != nil {
  33338. fields = append(fields, usagestatisticmonth.FieldType)
  33339. }
  33340. if m.addorganization_id != nil {
  33341. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  33342. }
  33343. if m.addai_response != nil {
  33344. fields = append(fields, usagestatisticmonth.FieldAiResponse)
  33345. }
  33346. if m.addsop_run != nil {
  33347. fields = append(fields, usagestatisticmonth.FieldSopRun)
  33348. }
  33349. if m.addtotal_friend != nil {
  33350. fields = append(fields, usagestatisticmonth.FieldTotalFriend)
  33351. }
  33352. if m.addtotal_group != nil {
  33353. fields = append(fields, usagestatisticmonth.FieldTotalGroup)
  33354. }
  33355. if m.addaccount_balance != nil {
  33356. fields = append(fields, usagestatisticmonth.FieldAccountBalance)
  33357. }
  33358. if m.addconsume_token != nil {
  33359. fields = append(fields, usagestatisticmonth.FieldConsumeToken)
  33360. }
  33361. if m.addactive_user != nil {
  33362. fields = append(fields, usagestatisticmonth.FieldActiveUser)
  33363. }
  33364. if m.addnew_user != nil {
  33365. fields = append(fields, usagestatisticmonth.FieldNewUser)
  33366. }
  33367. return fields
  33368. }
  33369. // AddedField returns the numeric value that was incremented/decremented on a field
  33370. // with the given name. The second boolean return value indicates that this field
  33371. // was not set, or was not defined in the schema.
  33372. func (m *UsageStatisticMonthMutation) AddedField(name string) (ent.Value, bool) {
  33373. switch name {
  33374. case usagestatisticmonth.FieldStatus:
  33375. return m.AddedStatus()
  33376. case usagestatisticmonth.FieldAddtime:
  33377. return m.AddedAddtime()
  33378. case usagestatisticmonth.FieldType:
  33379. return m.AddedType()
  33380. case usagestatisticmonth.FieldOrganizationID:
  33381. return m.AddedOrganizationID()
  33382. case usagestatisticmonth.FieldAiResponse:
  33383. return m.AddedAiResponse()
  33384. case usagestatisticmonth.FieldSopRun:
  33385. return m.AddedSopRun()
  33386. case usagestatisticmonth.FieldTotalFriend:
  33387. return m.AddedTotalFriend()
  33388. case usagestatisticmonth.FieldTotalGroup:
  33389. return m.AddedTotalGroup()
  33390. case usagestatisticmonth.FieldAccountBalance:
  33391. return m.AddedAccountBalance()
  33392. case usagestatisticmonth.FieldConsumeToken:
  33393. return m.AddedConsumeToken()
  33394. case usagestatisticmonth.FieldActiveUser:
  33395. return m.AddedActiveUser()
  33396. case usagestatisticmonth.FieldNewUser:
  33397. return m.AddedNewUser()
  33398. }
  33399. return nil, false
  33400. }
  33401. // AddField adds the value to the field with the given name. It returns an error if
  33402. // the field is not defined in the schema, or if the type mismatched the field
  33403. // type.
  33404. func (m *UsageStatisticMonthMutation) AddField(name string, value ent.Value) error {
  33405. switch name {
  33406. case usagestatisticmonth.FieldStatus:
  33407. v, ok := value.(int8)
  33408. if !ok {
  33409. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33410. }
  33411. m.AddStatus(v)
  33412. return nil
  33413. case usagestatisticmonth.FieldAddtime:
  33414. v, ok := value.(int64)
  33415. if !ok {
  33416. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33417. }
  33418. m.AddAddtime(v)
  33419. return nil
  33420. case usagestatisticmonth.FieldType:
  33421. v, ok := value.(int)
  33422. if !ok {
  33423. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33424. }
  33425. m.AddType(v)
  33426. return nil
  33427. case usagestatisticmonth.FieldOrganizationID:
  33428. v, ok := value.(int64)
  33429. if !ok {
  33430. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33431. }
  33432. m.AddOrganizationID(v)
  33433. return nil
  33434. case usagestatisticmonth.FieldAiResponse:
  33435. v, ok := value.(int64)
  33436. if !ok {
  33437. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33438. }
  33439. m.AddAiResponse(v)
  33440. return nil
  33441. case usagestatisticmonth.FieldSopRun:
  33442. v, ok := value.(int64)
  33443. if !ok {
  33444. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33445. }
  33446. m.AddSopRun(v)
  33447. return nil
  33448. case usagestatisticmonth.FieldTotalFriend:
  33449. v, ok := value.(int64)
  33450. if !ok {
  33451. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33452. }
  33453. m.AddTotalFriend(v)
  33454. return nil
  33455. case usagestatisticmonth.FieldTotalGroup:
  33456. v, ok := value.(int64)
  33457. if !ok {
  33458. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33459. }
  33460. m.AddTotalGroup(v)
  33461. return nil
  33462. case usagestatisticmonth.FieldAccountBalance:
  33463. v, ok := value.(int64)
  33464. if !ok {
  33465. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33466. }
  33467. m.AddAccountBalance(v)
  33468. return nil
  33469. case usagestatisticmonth.FieldConsumeToken:
  33470. v, ok := value.(int64)
  33471. if !ok {
  33472. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33473. }
  33474. m.AddConsumeToken(v)
  33475. return nil
  33476. case usagestatisticmonth.FieldActiveUser:
  33477. v, ok := value.(int64)
  33478. if !ok {
  33479. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33480. }
  33481. m.AddActiveUser(v)
  33482. return nil
  33483. case usagestatisticmonth.FieldNewUser:
  33484. v, ok := value.(int64)
  33485. if !ok {
  33486. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33487. }
  33488. m.AddNewUser(v)
  33489. return nil
  33490. }
  33491. return fmt.Errorf("unknown UsageStatisticMonth numeric field %s", name)
  33492. }
  33493. // ClearedFields returns all nullable fields that were cleared during this
  33494. // mutation.
  33495. func (m *UsageStatisticMonthMutation) ClearedFields() []string {
  33496. var fields []string
  33497. if m.FieldCleared(usagestatisticmonth.FieldStatus) {
  33498. fields = append(fields, usagestatisticmonth.FieldStatus)
  33499. }
  33500. if m.FieldCleared(usagestatisticmonth.FieldDeletedAt) {
  33501. fields = append(fields, usagestatisticmonth.FieldDeletedAt)
  33502. }
  33503. if m.FieldCleared(usagestatisticmonth.FieldBotID) {
  33504. fields = append(fields, usagestatisticmonth.FieldBotID)
  33505. }
  33506. if m.FieldCleared(usagestatisticmonth.FieldOrganizationID) {
  33507. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  33508. }
  33509. return fields
  33510. }
  33511. // FieldCleared returns a boolean indicating if a field with the given name was
  33512. // cleared in this mutation.
  33513. func (m *UsageStatisticMonthMutation) FieldCleared(name string) bool {
  33514. _, ok := m.clearedFields[name]
  33515. return ok
  33516. }
  33517. // ClearField clears the value of the field with the given name. It returns an
  33518. // error if the field is not defined in the schema.
  33519. func (m *UsageStatisticMonthMutation) ClearField(name string) error {
  33520. switch name {
  33521. case usagestatisticmonth.FieldStatus:
  33522. m.ClearStatus()
  33523. return nil
  33524. case usagestatisticmonth.FieldDeletedAt:
  33525. m.ClearDeletedAt()
  33526. return nil
  33527. case usagestatisticmonth.FieldBotID:
  33528. m.ClearBotID()
  33529. return nil
  33530. case usagestatisticmonth.FieldOrganizationID:
  33531. m.ClearOrganizationID()
  33532. return nil
  33533. }
  33534. return fmt.Errorf("unknown UsageStatisticMonth nullable field %s", name)
  33535. }
  33536. // ResetField resets all changes in the mutation for the field with the given name.
  33537. // It returns an error if the field is not defined in the schema.
  33538. func (m *UsageStatisticMonthMutation) ResetField(name string) error {
  33539. switch name {
  33540. case usagestatisticmonth.FieldCreatedAt:
  33541. m.ResetCreatedAt()
  33542. return nil
  33543. case usagestatisticmonth.FieldUpdatedAt:
  33544. m.ResetUpdatedAt()
  33545. return nil
  33546. case usagestatisticmonth.FieldStatus:
  33547. m.ResetStatus()
  33548. return nil
  33549. case usagestatisticmonth.FieldDeletedAt:
  33550. m.ResetDeletedAt()
  33551. return nil
  33552. case usagestatisticmonth.FieldAddtime:
  33553. m.ResetAddtime()
  33554. return nil
  33555. case usagestatisticmonth.FieldType:
  33556. m.ResetType()
  33557. return nil
  33558. case usagestatisticmonth.FieldBotID:
  33559. m.ResetBotID()
  33560. return nil
  33561. case usagestatisticmonth.FieldOrganizationID:
  33562. m.ResetOrganizationID()
  33563. return nil
  33564. case usagestatisticmonth.FieldAiResponse:
  33565. m.ResetAiResponse()
  33566. return nil
  33567. case usagestatisticmonth.FieldSopRun:
  33568. m.ResetSopRun()
  33569. return nil
  33570. case usagestatisticmonth.FieldTotalFriend:
  33571. m.ResetTotalFriend()
  33572. return nil
  33573. case usagestatisticmonth.FieldTotalGroup:
  33574. m.ResetTotalGroup()
  33575. return nil
  33576. case usagestatisticmonth.FieldAccountBalance:
  33577. m.ResetAccountBalance()
  33578. return nil
  33579. case usagestatisticmonth.FieldConsumeToken:
  33580. m.ResetConsumeToken()
  33581. return nil
  33582. case usagestatisticmonth.FieldActiveUser:
  33583. m.ResetActiveUser()
  33584. return nil
  33585. case usagestatisticmonth.FieldNewUser:
  33586. m.ResetNewUser()
  33587. return nil
  33588. case usagestatisticmonth.FieldLabelDist:
  33589. m.ResetLabelDist()
  33590. return nil
  33591. }
  33592. return fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  33593. }
  33594. // AddedEdges returns all edge names that were set/added in this mutation.
  33595. func (m *UsageStatisticMonthMutation) AddedEdges() []string {
  33596. edges := make([]string, 0, 0)
  33597. return edges
  33598. }
  33599. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  33600. // name in this mutation.
  33601. func (m *UsageStatisticMonthMutation) AddedIDs(name string) []ent.Value {
  33602. return nil
  33603. }
  33604. // RemovedEdges returns all edge names that were removed in this mutation.
  33605. func (m *UsageStatisticMonthMutation) RemovedEdges() []string {
  33606. edges := make([]string, 0, 0)
  33607. return edges
  33608. }
  33609. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  33610. // the given name in this mutation.
  33611. func (m *UsageStatisticMonthMutation) RemovedIDs(name string) []ent.Value {
  33612. return nil
  33613. }
  33614. // ClearedEdges returns all edge names that were cleared in this mutation.
  33615. func (m *UsageStatisticMonthMutation) ClearedEdges() []string {
  33616. edges := make([]string, 0, 0)
  33617. return edges
  33618. }
  33619. // EdgeCleared returns a boolean which indicates if the edge with the given name
  33620. // was cleared in this mutation.
  33621. func (m *UsageStatisticMonthMutation) EdgeCleared(name string) bool {
  33622. return false
  33623. }
  33624. // ClearEdge clears the value of the edge with the given name. It returns an error
  33625. // if that edge is not defined in the schema.
  33626. func (m *UsageStatisticMonthMutation) ClearEdge(name string) error {
  33627. return fmt.Errorf("unknown UsageStatisticMonth unique edge %s", name)
  33628. }
  33629. // ResetEdge resets all changes to the edge with the given name in this mutation.
  33630. // It returns an error if the edge is not defined in the schema.
  33631. func (m *UsageStatisticMonthMutation) ResetEdge(name string) error {
  33632. return fmt.Errorf("unknown UsageStatisticMonth edge %s", name)
  33633. }
  33634. // UsageTotalMutation represents an operation that mutates the UsageTotal nodes in the graph.
  33635. type UsageTotalMutation struct {
  33636. config
  33637. op Op
  33638. typ string
  33639. id *uint64
  33640. created_at *time.Time
  33641. updated_at *time.Time
  33642. status *uint8
  33643. addstatus *int8
  33644. _type *int
  33645. add_type *int
  33646. bot_id *string
  33647. total_tokens *uint64
  33648. addtotal_tokens *int64
  33649. start_index *uint64
  33650. addstart_index *int64
  33651. end_index *uint64
  33652. addend_index *int64
  33653. organization_id *uint64
  33654. addorganization_id *int64
  33655. clearedFields map[string]struct{}
  33656. done bool
  33657. oldValue func(context.Context) (*UsageTotal, error)
  33658. predicates []predicate.UsageTotal
  33659. }
  33660. var _ ent.Mutation = (*UsageTotalMutation)(nil)
  33661. // usagetotalOption allows management of the mutation configuration using functional options.
  33662. type usagetotalOption func(*UsageTotalMutation)
  33663. // newUsageTotalMutation creates new mutation for the UsageTotal entity.
  33664. func newUsageTotalMutation(c config, op Op, opts ...usagetotalOption) *UsageTotalMutation {
  33665. m := &UsageTotalMutation{
  33666. config: c,
  33667. op: op,
  33668. typ: TypeUsageTotal,
  33669. clearedFields: make(map[string]struct{}),
  33670. }
  33671. for _, opt := range opts {
  33672. opt(m)
  33673. }
  33674. return m
  33675. }
  33676. // withUsageTotalID sets the ID field of the mutation.
  33677. func withUsageTotalID(id uint64) usagetotalOption {
  33678. return func(m *UsageTotalMutation) {
  33679. var (
  33680. err error
  33681. once sync.Once
  33682. value *UsageTotal
  33683. )
  33684. m.oldValue = func(ctx context.Context) (*UsageTotal, error) {
  33685. once.Do(func() {
  33686. if m.done {
  33687. err = errors.New("querying old values post mutation is not allowed")
  33688. } else {
  33689. value, err = m.Client().UsageTotal.Get(ctx, id)
  33690. }
  33691. })
  33692. return value, err
  33693. }
  33694. m.id = &id
  33695. }
  33696. }
  33697. // withUsageTotal sets the old UsageTotal of the mutation.
  33698. func withUsageTotal(node *UsageTotal) usagetotalOption {
  33699. return func(m *UsageTotalMutation) {
  33700. m.oldValue = func(context.Context) (*UsageTotal, error) {
  33701. return node, nil
  33702. }
  33703. m.id = &node.ID
  33704. }
  33705. }
  33706. // Client returns a new `ent.Client` from the mutation. If the mutation was
  33707. // executed in a transaction (ent.Tx), a transactional client is returned.
  33708. func (m UsageTotalMutation) Client() *Client {
  33709. client := &Client{config: m.config}
  33710. client.init()
  33711. return client
  33712. }
  33713. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  33714. // it returns an error otherwise.
  33715. func (m UsageTotalMutation) Tx() (*Tx, error) {
  33716. if _, ok := m.driver.(*txDriver); !ok {
  33717. return nil, errors.New("ent: mutation is not running in a transaction")
  33718. }
  33719. tx := &Tx{config: m.config}
  33720. tx.init()
  33721. return tx, nil
  33722. }
  33723. // SetID sets the value of the id field. Note that this
  33724. // operation is only accepted on creation of UsageTotal entities.
  33725. func (m *UsageTotalMutation) SetID(id uint64) {
  33726. m.id = &id
  33727. }
  33728. // ID returns the ID value in the mutation. Note that the ID is only available
  33729. // if it was provided to the builder or after it was returned from the database.
  33730. func (m *UsageTotalMutation) ID() (id uint64, exists bool) {
  33731. if m.id == nil {
  33732. return
  33733. }
  33734. return *m.id, true
  33735. }
  33736. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  33737. // That means, if the mutation is applied within a transaction with an isolation level such
  33738. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  33739. // or updated by the mutation.
  33740. func (m *UsageTotalMutation) IDs(ctx context.Context) ([]uint64, error) {
  33741. switch {
  33742. case m.op.Is(OpUpdateOne | OpDeleteOne):
  33743. id, exists := m.ID()
  33744. if exists {
  33745. return []uint64{id}, nil
  33746. }
  33747. fallthrough
  33748. case m.op.Is(OpUpdate | OpDelete):
  33749. return m.Client().UsageTotal.Query().Where(m.predicates...).IDs(ctx)
  33750. default:
  33751. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  33752. }
  33753. }
  33754. // SetCreatedAt sets the "created_at" field.
  33755. func (m *UsageTotalMutation) SetCreatedAt(t time.Time) {
  33756. m.created_at = &t
  33757. }
  33758. // CreatedAt returns the value of the "created_at" field in the mutation.
  33759. func (m *UsageTotalMutation) CreatedAt() (r time.Time, exists bool) {
  33760. v := m.created_at
  33761. if v == nil {
  33762. return
  33763. }
  33764. return *v, true
  33765. }
  33766. // OldCreatedAt returns the old "created_at" field's value of the UsageTotal entity.
  33767. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  33768. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33769. func (m *UsageTotalMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  33770. if !m.op.Is(OpUpdateOne) {
  33771. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  33772. }
  33773. if m.id == nil || m.oldValue == nil {
  33774. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  33775. }
  33776. oldValue, err := m.oldValue(ctx)
  33777. if err != nil {
  33778. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  33779. }
  33780. return oldValue.CreatedAt, nil
  33781. }
  33782. // ResetCreatedAt resets all changes to the "created_at" field.
  33783. func (m *UsageTotalMutation) ResetCreatedAt() {
  33784. m.created_at = nil
  33785. }
  33786. // SetUpdatedAt sets the "updated_at" field.
  33787. func (m *UsageTotalMutation) SetUpdatedAt(t time.Time) {
  33788. m.updated_at = &t
  33789. }
  33790. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  33791. func (m *UsageTotalMutation) UpdatedAt() (r time.Time, exists bool) {
  33792. v := m.updated_at
  33793. if v == nil {
  33794. return
  33795. }
  33796. return *v, true
  33797. }
  33798. // OldUpdatedAt returns the old "updated_at" field's value of the UsageTotal entity.
  33799. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  33800. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33801. func (m *UsageTotalMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  33802. if !m.op.Is(OpUpdateOne) {
  33803. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  33804. }
  33805. if m.id == nil || m.oldValue == nil {
  33806. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  33807. }
  33808. oldValue, err := m.oldValue(ctx)
  33809. if err != nil {
  33810. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  33811. }
  33812. return oldValue.UpdatedAt, nil
  33813. }
  33814. // ResetUpdatedAt resets all changes to the "updated_at" field.
  33815. func (m *UsageTotalMutation) ResetUpdatedAt() {
  33816. m.updated_at = nil
  33817. }
  33818. // SetStatus sets the "status" field.
  33819. func (m *UsageTotalMutation) SetStatus(u uint8) {
  33820. m.status = &u
  33821. m.addstatus = nil
  33822. }
  33823. // Status returns the value of the "status" field in the mutation.
  33824. func (m *UsageTotalMutation) Status() (r uint8, exists bool) {
  33825. v := m.status
  33826. if v == nil {
  33827. return
  33828. }
  33829. return *v, true
  33830. }
  33831. // OldStatus returns the old "status" field's value of the UsageTotal entity.
  33832. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  33833. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33834. func (m *UsageTotalMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  33835. if !m.op.Is(OpUpdateOne) {
  33836. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  33837. }
  33838. if m.id == nil || m.oldValue == nil {
  33839. return v, errors.New("OldStatus requires an ID field in the mutation")
  33840. }
  33841. oldValue, err := m.oldValue(ctx)
  33842. if err != nil {
  33843. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  33844. }
  33845. return oldValue.Status, nil
  33846. }
  33847. // AddStatus adds u to the "status" field.
  33848. func (m *UsageTotalMutation) AddStatus(u int8) {
  33849. if m.addstatus != nil {
  33850. *m.addstatus += u
  33851. } else {
  33852. m.addstatus = &u
  33853. }
  33854. }
  33855. // AddedStatus returns the value that was added to the "status" field in this mutation.
  33856. func (m *UsageTotalMutation) AddedStatus() (r int8, exists bool) {
  33857. v := m.addstatus
  33858. if v == nil {
  33859. return
  33860. }
  33861. return *v, true
  33862. }
  33863. // ClearStatus clears the value of the "status" field.
  33864. func (m *UsageTotalMutation) ClearStatus() {
  33865. m.status = nil
  33866. m.addstatus = nil
  33867. m.clearedFields[usagetotal.FieldStatus] = struct{}{}
  33868. }
  33869. // StatusCleared returns if the "status" field was cleared in this mutation.
  33870. func (m *UsageTotalMutation) StatusCleared() bool {
  33871. _, ok := m.clearedFields[usagetotal.FieldStatus]
  33872. return ok
  33873. }
  33874. // ResetStatus resets all changes to the "status" field.
  33875. func (m *UsageTotalMutation) ResetStatus() {
  33876. m.status = nil
  33877. m.addstatus = nil
  33878. delete(m.clearedFields, usagetotal.FieldStatus)
  33879. }
  33880. // SetType sets the "type" field.
  33881. func (m *UsageTotalMutation) SetType(i int) {
  33882. m._type = &i
  33883. m.add_type = nil
  33884. }
  33885. // GetType returns the value of the "type" field in the mutation.
  33886. func (m *UsageTotalMutation) GetType() (r int, exists bool) {
  33887. v := m._type
  33888. if v == nil {
  33889. return
  33890. }
  33891. return *v, true
  33892. }
  33893. // OldType returns the old "type" field's value of the UsageTotal entity.
  33894. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  33895. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33896. func (m *UsageTotalMutation) OldType(ctx context.Context) (v int, err error) {
  33897. if !m.op.Is(OpUpdateOne) {
  33898. return v, errors.New("OldType is only allowed on UpdateOne operations")
  33899. }
  33900. if m.id == nil || m.oldValue == nil {
  33901. return v, errors.New("OldType requires an ID field in the mutation")
  33902. }
  33903. oldValue, err := m.oldValue(ctx)
  33904. if err != nil {
  33905. return v, fmt.Errorf("querying old value for OldType: %w", err)
  33906. }
  33907. return oldValue.Type, nil
  33908. }
  33909. // AddType adds i to the "type" field.
  33910. func (m *UsageTotalMutation) AddType(i int) {
  33911. if m.add_type != nil {
  33912. *m.add_type += i
  33913. } else {
  33914. m.add_type = &i
  33915. }
  33916. }
  33917. // AddedType returns the value that was added to the "type" field in this mutation.
  33918. func (m *UsageTotalMutation) AddedType() (r int, exists bool) {
  33919. v := m.add_type
  33920. if v == nil {
  33921. return
  33922. }
  33923. return *v, true
  33924. }
  33925. // ClearType clears the value of the "type" field.
  33926. func (m *UsageTotalMutation) ClearType() {
  33927. m._type = nil
  33928. m.add_type = nil
  33929. m.clearedFields[usagetotal.FieldType] = struct{}{}
  33930. }
  33931. // TypeCleared returns if the "type" field was cleared in this mutation.
  33932. func (m *UsageTotalMutation) TypeCleared() bool {
  33933. _, ok := m.clearedFields[usagetotal.FieldType]
  33934. return ok
  33935. }
  33936. // ResetType resets all changes to the "type" field.
  33937. func (m *UsageTotalMutation) ResetType() {
  33938. m._type = nil
  33939. m.add_type = nil
  33940. delete(m.clearedFields, usagetotal.FieldType)
  33941. }
  33942. // SetBotID sets the "bot_id" field.
  33943. func (m *UsageTotalMutation) SetBotID(s string) {
  33944. m.bot_id = &s
  33945. }
  33946. // BotID returns the value of the "bot_id" field in the mutation.
  33947. func (m *UsageTotalMutation) BotID() (r string, exists bool) {
  33948. v := m.bot_id
  33949. if v == nil {
  33950. return
  33951. }
  33952. return *v, true
  33953. }
  33954. // OldBotID returns the old "bot_id" field's value of the UsageTotal entity.
  33955. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  33956. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33957. func (m *UsageTotalMutation) OldBotID(ctx context.Context) (v string, err error) {
  33958. if !m.op.Is(OpUpdateOne) {
  33959. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  33960. }
  33961. if m.id == nil || m.oldValue == nil {
  33962. return v, errors.New("OldBotID requires an ID field in the mutation")
  33963. }
  33964. oldValue, err := m.oldValue(ctx)
  33965. if err != nil {
  33966. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  33967. }
  33968. return oldValue.BotID, nil
  33969. }
  33970. // ResetBotID resets all changes to the "bot_id" field.
  33971. func (m *UsageTotalMutation) ResetBotID() {
  33972. m.bot_id = nil
  33973. }
  33974. // SetTotalTokens sets the "total_tokens" field.
  33975. func (m *UsageTotalMutation) SetTotalTokens(u uint64) {
  33976. m.total_tokens = &u
  33977. m.addtotal_tokens = nil
  33978. }
  33979. // TotalTokens returns the value of the "total_tokens" field in the mutation.
  33980. func (m *UsageTotalMutation) TotalTokens() (r uint64, exists bool) {
  33981. v := m.total_tokens
  33982. if v == nil {
  33983. return
  33984. }
  33985. return *v, true
  33986. }
  33987. // OldTotalTokens returns the old "total_tokens" field's value of the UsageTotal entity.
  33988. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  33989. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33990. func (m *UsageTotalMutation) OldTotalTokens(ctx context.Context) (v uint64, err error) {
  33991. if !m.op.Is(OpUpdateOne) {
  33992. return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
  33993. }
  33994. if m.id == nil || m.oldValue == nil {
  33995. return v, errors.New("OldTotalTokens requires an ID field in the mutation")
  33996. }
  33997. oldValue, err := m.oldValue(ctx)
  33998. if err != nil {
  33999. return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
  34000. }
  34001. return oldValue.TotalTokens, nil
  34002. }
  34003. // AddTotalTokens adds u to the "total_tokens" field.
  34004. func (m *UsageTotalMutation) AddTotalTokens(u int64) {
  34005. if m.addtotal_tokens != nil {
  34006. *m.addtotal_tokens += u
  34007. } else {
  34008. m.addtotal_tokens = &u
  34009. }
  34010. }
  34011. // AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
  34012. func (m *UsageTotalMutation) AddedTotalTokens() (r int64, exists bool) {
  34013. v := m.addtotal_tokens
  34014. if v == nil {
  34015. return
  34016. }
  34017. return *v, true
  34018. }
  34019. // ClearTotalTokens clears the value of the "total_tokens" field.
  34020. func (m *UsageTotalMutation) ClearTotalTokens() {
  34021. m.total_tokens = nil
  34022. m.addtotal_tokens = nil
  34023. m.clearedFields[usagetotal.FieldTotalTokens] = struct{}{}
  34024. }
  34025. // TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
  34026. func (m *UsageTotalMutation) TotalTokensCleared() bool {
  34027. _, ok := m.clearedFields[usagetotal.FieldTotalTokens]
  34028. return ok
  34029. }
  34030. // ResetTotalTokens resets all changes to the "total_tokens" field.
  34031. func (m *UsageTotalMutation) ResetTotalTokens() {
  34032. m.total_tokens = nil
  34033. m.addtotal_tokens = nil
  34034. delete(m.clearedFields, usagetotal.FieldTotalTokens)
  34035. }
  34036. // SetStartIndex sets the "start_index" field.
  34037. func (m *UsageTotalMutation) SetStartIndex(u uint64) {
  34038. m.start_index = &u
  34039. m.addstart_index = nil
  34040. }
  34041. // StartIndex returns the value of the "start_index" field in the mutation.
  34042. func (m *UsageTotalMutation) StartIndex() (r uint64, exists bool) {
  34043. v := m.start_index
  34044. if v == nil {
  34045. return
  34046. }
  34047. return *v, true
  34048. }
  34049. // OldStartIndex returns the old "start_index" field's value of the UsageTotal entity.
  34050. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  34051. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34052. func (m *UsageTotalMutation) OldStartIndex(ctx context.Context) (v uint64, err error) {
  34053. if !m.op.Is(OpUpdateOne) {
  34054. return v, errors.New("OldStartIndex is only allowed on UpdateOne operations")
  34055. }
  34056. if m.id == nil || m.oldValue == nil {
  34057. return v, errors.New("OldStartIndex requires an ID field in the mutation")
  34058. }
  34059. oldValue, err := m.oldValue(ctx)
  34060. if err != nil {
  34061. return v, fmt.Errorf("querying old value for OldStartIndex: %w", err)
  34062. }
  34063. return oldValue.StartIndex, nil
  34064. }
  34065. // AddStartIndex adds u to the "start_index" field.
  34066. func (m *UsageTotalMutation) AddStartIndex(u int64) {
  34067. if m.addstart_index != nil {
  34068. *m.addstart_index += u
  34069. } else {
  34070. m.addstart_index = &u
  34071. }
  34072. }
  34073. // AddedStartIndex returns the value that was added to the "start_index" field in this mutation.
  34074. func (m *UsageTotalMutation) AddedStartIndex() (r int64, exists bool) {
  34075. v := m.addstart_index
  34076. if v == nil {
  34077. return
  34078. }
  34079. return *v, true
  34080. }
  34081. // ClearStartIndex clears the value of the "start_index" field.
  34082. func (m *UsageTotalMutation) ClearStartIndex() {
  34083. m.start_index = nil
  34084. m.addstart_index = nil
  34085. m.clearedFields[usagetotal.FieldStartIndex] = struct{}{}
  34086. }
  34087. // StartIndexCleared returns if the "start_index" field was cleared in this mutation.
  34088. func (m *UsageTotalMutation) StartIndexCleared() bool {
  34089. _, ok := m.clearedFields[usagetotal.FieldStartIndex]
  34090. return ok
  34091. }
  34092. // ResetStartIndex resets all changes to the "start_index" field.
  34093. func (m *UsageTotalMutation) ResetStartIndex() {
  34094. m.start_index = nil
  34095. m.addstart_index = nil
  34096. delete(m.clearedFields, usagetotal.FieldStartIndex)
  34097. }
  34098. // SetEndIndex sets the "end_index" field.
  34099. func (m *UsageTotalMutation) SetEndIndex(u uint64) {
  34100. m.end_index = &u
  34101. m.addend_index = nil
  34102. }
  34103. // EndIndex returns the value of the "end_index" field in the mutation.
  34104. func (m *UsageTotalMutation) EndIndex() (r uint64, exists bool) {
  34105. v := m.end_index
  34106. if v == nil {
  34107. return
  34108. }
  34109. return *v, true
  34110. }
  34111. // OldEndIndex returns the old "end_index" field's value of the UsageTotal entity.
  34112. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  34113. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34114. func (m *UsageTotalMutation) OldEndIndex(ctx context.Context) (v uint64, err error) {
  34115. if !m.op.Is(OpUpdateOne) {
  34116. return v, errors.New("OldEndIndex is only allowed on UpdateOne operations")
  34117. }
  34118. if m.id == nil || m.oldValue == nil {
  34119. return v, errors.New("OldEndIndex requires an ID field in the mutation")
  34120. }
  34121. oldValue, err := m.oldValue(ctx)
  34122. if err != nil {
  34123. return v, fmt.Errorf("querying old value for OldEndIndex: %w", err)
  34124. }
  34125. return oldValue.EndIndex, nil
  34126. }
  34127. // AddEndIndex adds u to the "end_index" field.
  34128. func (m *UsageTotalMutation) AddEndIndex(u int64) {
  34129. if m.addend_index != nil {
  34130. *m.addend_index += u
  34131. } else {
  34132. m.addend_index = &u
  34133. }
  34134. }
  34135. // AddedEndIndex returns the value that was added to the "end_index" field in this mutation.
  34136. func (m *UsageTotalMutation) AddedEndIndex() (r int64, exists bool) {
  34137. v := m.addend_index
  34138. if v == nil {
  34139. return
  34140. }
  34141. return *v, true
  34142. }
  34143. // ClearEndIndex clears the value of the "end_index" field.
  34144. func (m *UsageTotalMutation) ClearEndIndex() {
  34145. m.end_index = nil
  34146. m.addend_index = nil
  34147. m.clearedFields[usagetotal.FieldEndIndex] = struct{}{}
  34148. }
  34149. // EndIndexCleared returns if the "end_index" field was cleared in this mutation.
  34150. func (m *UsageTotalMutation) EndIndexCleared() bool {
  34151. _, ok := m.clearedFields[usagetotal.FieldEndIndex]
  34152. return ok
  34153. }
  34154. // ResetEndIndex resets all changes to the "end_index" field.
  34155. func (m *UsageTotalMutation) ResetEndIndex() {
  34156. m.end_index = nil
  34157. m.addend_index = nil
  34158. delete(m.clearedFields, usagetotal.FieldEndIndex)
  34159. }
  34160. // SetOrganizationID sets the "organization_id" field.
  34161. func (m *UsageTotalMutation) SetOrganizationID(u uint64) {
  34162. m.organization_id = &u
  34163. m.addorganization_id = nil
  34164. }
  34165. // OrganizationID returns the value of the "organization_id" field in the mutation.
  34166. func (m *UsageTotalMutation) OrganizationID() (r uint64, exists bool) {
  34167. v := m.organization_id
  34168. if v == nil {
  34169. return
  34170. }
  34171. return *v, true
  34172. }
  34173. // OldOrganizationID returns the old "organization_id" field's value of the UsageTotal entity.
  34174. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  34175. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34176. func (m *UsageTotalMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  34177. if !m.op.Is(OpUpdateOne) {
  34178. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  34179. }
  34180. if m.id == nil || m.oldValue == nil {
  34181. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  34182. }
  34183. oldValue, err := m.oldValue(ctx)
  34184. if err != nil {
  34185. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  34186. }
  34187. return oldValue.OrganizationID, nil
  34188. }
  34189. // AddOrganizationID adds u to the "organization_id" field.
  34190. func (m *UsageTotalMutation) AddOrganizationID(u int64) {
  34191. if m.addorganization_id != nil {
  34192. *m.addorganization_id += u
  34193. } else {
  34194. m.addorganization_id = &u
  34195. }
  34196. }
  34197. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  34198. func (m *UsageTotalMutation) AddedOrganizationID() (r int64, exists bool) {
  34199. v := m.addorganization_id
  34200. if v == nil {
  34201. return
  34202. }
  34203. return *v, true
  34204. }
  34205. // ClearOrganizationID clears the value of the "organization_id" field.
  34206. func (m *UsageTotalMutation) ClearOrganizationID() {
  34207. m.organization_id = nil
  34208. m.addorganization_id = nil
  34209. m.clearedFields[usagetotal.FieldOrganizationID] = struct{}{}
  34210. }
  34211. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  34212. func (m *UsageTotalMutation) OrganizationIDCleared() bool {
  34213. _, ok := m.clearedFields[usagetotal.FieldOrganizationID]
  34214. return ok
  34215. }
  34216. // ResetOrganizationID resets all changes to the "organization_id" field.
  34217. func (m *UsageTotalMutation) ResetOrganizationID() {
  34218. m.organization_id = nil
  34219. m.addorganization_id = nil
  34220. delete(m.clearedFields, usagetotal.FieldOrganizationID)
  34221. }
  34222. // Where appends a list predicates to the UsageTotalMutation builder.
  34223. func (m *UsageTotalMutation) Where(ps ...predicate.UsageTotal) {
  34224. m.predicates = append(m.predicates, ps...)
  34225. }
  34226. // WhereP appends storage-level predicates to the UsageTotalMutation builder. Using this method,
  34227. // users can use type-assertion to append predicates that do not depend on any generated package.
  34228. func (m *UsageTotalMutation) WhereP(ps ...func(*sql.Selector)) {
  34229. p := make([]predicate.UsageTotal, len(ps))
  34230. for i := range ps {
  34231. p[i] = ps[i]
  34232. }
  34233. m.Where(p...)
  34234. }
  34235. // Op returns the operation name.
  34236. func (m *UsageTotalMutation) Op() Op {
  34237. return m.op
  34238. }
  34239. // SetOp allows setting the mutation operation.
  34240. func (m *UsageTotalMutation) SetOp(op Op) {
  34241. m.op = op
  34242. }
  34243. // Type returns the node type of this mutation (UsageTotal).
  34244. func (m *UsageTotalMutation) Type() string {
  34245. return m.typ
  34246. }
  34247. // Fields returns all fields that were changed during this mutation. Note that in
  34248. // order to get all numeric fields that were incremented/decremented, call
  34249. // AddedFields().
  34250. func (m *UsageTotalMutation) Fields() []string {
  34251. fields := make([]string, 0, 9)
  34252. if m.created_at != nil {
  34253. fields = append(fields, usagetotal.FieldCreatedAt)
  34254. }
  34255. if m.updated_at != nil {
  34256. fields = append(fields, usagetotal.FieldUpdatedAt)
  34257. }
  34258. if m.status != nil {
  34259. fields = append(fields, usagetotal.FieldStatus)
  34260. }
  34261. if m._type != nil {
  34262. fields = append(fields, usagetotal.FieldType)
  34263. }
  34264. if m.bot_id != nil {
  34265. fields = append(fields, usagetotal.FieldBotID)
  34266. }
  34267. if m.total_tokens != nil {
  34268. fields = append(fields, usagetotal.FieldTotalTokens)
  34269. }
  34270. if m.start_index != nil {
  34271. fields = append(fields, usagetotal.FieldStartIndex)
  34272. }
  34273. if m.end_index != nil {
  34274. fields = append(fields, usagetotal.FieldEndIndex)
  34275. }
  34276. if m.organization_id != nil {
  34277. fields = append(fields, usagetotal.FieldOrganizationID)
  34278. }
  34279. return fields
  34280. }
  34281. // Field returns the value of a field with the given name. The second boolean
  34282. // return value indicates that this field was not set, or was not defined in the
  34283. // schema.
  34284. func (m *UsageTotalMutation) Field(name string) (ent.Value, bool) {
  34285. switch name {
  34286. case usagetotal.FieldCreatedAt:
  34287. return m.CreatedAt()
  34288. case usagetotal.FieldUpdatedAt:
  34289. return m.UpdatedAt()
  34290. case usagetotal.FieldStatus:
  34291. return m.Status()
  34292. case usagetotal.FieldType:
  34293. return m.GetType()
  34294. case usagetotal.FieldBotID:
  34295. return m.BotID()
  34296. case usagetotal.FieldTotalTokens:
  34297. return m.TotalTokens()
  34298. case usagetotal.FieldStartIndex:
  34299. return m.StartIndex()
  34300. case usagetotal.FieldEndIndex:
  34301. return m.EndIndex()
  34302. case usagetotal.FieldOrganizationID:
  34303. return m.OrganizationID()
  34304. }
  34305. return nil, false
  34306. }
  34307. // OldField returns the old value of the field from the database. An error is
  34308. // returned if the mutation operation is not UpdateOne, or the query to the
  34309. // database failed.
  34310. func (m *UsageTotalMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  34311. switch name {
  34312. case usagetotal.FieldCreatedAt:
  34313. return m.OldCreatedAt(ctx)
  34314. case usagetotal.FieldUpdatedAt:
  34315. return m.OldUpdatedAt(ctx)
  34316. case usagetotal.FieldStatus:
  34317. return m.OldStatus(ctx)
  34318. case usagetotal.FieldType:
  34319. return m.OldType(ctx)
  34320. case usagetotal.FieldBotID:
  34321. return m.OldBotID(ctx)
  34322. case usagetotal.FieldTotalTokens:
  34323. return m.OldTotalTokens(ctx)
  34324. case usagetotal.FieldStartIndex:
  34325. return m.OldStartIndex(ctx)
  34326. case usagetotal.FieldEndIndex:
  34327. return m.OldEndIndex(ctx)
  34328. case usagetotal.FieldOrganizationID:
  34329. return m.OldOrganizationID(ctx)
  34330. }
  34331. return nil, fmt.Errorf("unknown UsageTotal field %s", name)
  34332. }
  34333. // SetField sets the value of a field with the given name. It returns an error if
  34334. // the field is not defined in the schema, or if the type mismatched the field
  34335. // type.
  34336. func (m *UsageTotalMutation) SetField(name string, value ent.Value) error {
  34337. switch name {
  34338. case usagetotal.FieldCreatedAt:
  34339. v, ok := value.(time.Time)
  34340. if !ok {
  34341. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34342. }
  34343. m.SetCreatedAt(v)
  34344. return nil
  34345. case usagetotal.FieldUpdatedAt:
  34346. v, ok := value.(time.Time)
  34347. if !ok {
  34348. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34349. }
  34350. m.SetUpdatedAt(v)
  34351. return nil
  34352. case usagetotal.FieldStatus:
  34353. v, ok := value.(uint8)
  34354. if !ok {
  34355. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34356. }
  34357. m.SetStatus(v)
  34358. return nil
  34359. case usagetotal.FieldType:
  34360. v, ok := value.(int)
  34361. if !ok {
  34362. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34363. }
  34364. m.SetType(v)
  34365. return nil
  34366. case usagetotal.FieldBotID:
  34367. v, ok := value.(string)
  34368. if !ok {
  34369. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34370. }
  34371. m.SetBotID(v)
  34372. return nil
  34373. case usagetotal.FieldTotalTokens:
  34374. v, ok := value.(uint64)
  34375. if !ok {
  34376. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34377. }
  34378. m.SetTotalTokens(v)
  34379. return nil
  34380. case usagetotal.FieldStartIndex:
  34381. v, ok := value.(uint64)
  34382. if !ok {
  34383. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34384. }
  34385. m.SetStartIndex(v)
  34386. return nil
  34387. case usagetotal.FieldEndIndex:
  34388. v, ok := value.(uint64)
  34389. if !ok {
  34390. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34391. }
  34392. m.SetEndIndex(v)
  34393. return nil
  34394. case usagetotal.FieldOrganizationID:
  34395. v, ok := value.(uint64)
  34396. if !ok {
  34397. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34398. }
  34399. m.SetOrganizationID(v)
  34400. return nil
  34401. }
  34402. return fmt.Errorf("unknown UsageTotal field %s", name)
  34403. }
  34404. // AddedFields returns all numeric fields that were incremented/decremented during
  34405. // this mutation.
  34406. func (m *UsageTotalMutation) AddedFields() []string {
  34407. var fields []string
  34408. if m.addstatus != nil {
  34409. fields = append(fields, usagetotal.FieldStatus)
  34410. }
  34411. if m.add_type != nil {
  34412. fields = append(fields, usagetotal.FieldType)
  34413. }
  34414. if m.addtotal_tokens != nil {
  34415. fields = append(fields, usagetotal.FieldTotalTokens)
  34416. }
  34417. if m.addstart_index != nil {
  34418. fields = append(fields, usagetotal.FieldStartIndex)
  34419. }
  34420. if m.addend_index != nil {
  34421. fields = append(fields, usagetotal.FieldEndIndex)
  34422. }
  34423. if m.addorganization_id != nil {
  34424. fields = append(fields, usagetotal.FieldOrganizationID)
  34425. }
  34426. return fields
  34427. }
  34428. // AddedField returns the numeric value that was incremented/decremented on a field
  34429. // with the given name. The second boolean return value indicates that this field
  34430. // was not set, or was not defined in the schema.
  34431. func (m *UsageTotalMutation) AddedField(name string) (ent.Value, bool) {
  34432. switch name {
  34433. case usagetotal.FieldStatus:
  34434. return m.AddedStatus()
  34435. case usagetotal.FieldType:
  34436. return m.AddedType()
  34437. case usagetotal.FieldTotalTokens:
  34438. return m.AddedTotalTokens()
  34439. case usagetotal.FieldStartIndex:
  34440. return m.AddedStartIndex()
  34441. case usagetotal.FieldEndIndex:
  34442. return m.AddedEndIndex()
  34443. case usagetotal.FieldOrganizationID:
  34444. return m.AddedOrganizationID()
  34445. }
  34446. return nil, false
  34447. }
  34448. // AddField adds the value to the field with the given name. It returns an error if
  34449. // the field is not defined in the schema, or if the type mismatched the field
  34450. // type.
  34451. func (m *UsageTotalMutation) AddField(name string, value ent.Value) error {
  34452. switch name {
  34453. case usagetotal.FieldStatus:
  34454. v, ok := value.(int8)
  34455. if !ok {
  34456. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34457. }
  34458. m.AddStatus(v)
  34459. return nil
  34460. case usagetotal.FieldType:
  34461. v, ok := value.(int)
  34462. if !ok {
  34463. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34464. }
  34465. m.AddType(v)
  34466. return nil
  34467. case usagetotal.FieldTotalTokens:
  34468. v, ok := value.(int64)
  34469. if !ok {
  34470. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34471. }
  34472. m.AddTotalTokens(v)
  34473. return nil
  34474. case usagetotal.FieldStartIndex:
  34475. v, ok := value.(int64)
  34476. if !ok {
  34477. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34478. }
  34479. m.AddStartIndex(v)
  34480. return nil
  34481. case usagetotal.FieldEndIndex:
  34482. v, ok := value.(int64)
  34483. if !ok {
  34484. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34485. }
  34486. m.AddEndIndex(v)
  34487. return nil
  34488. case usagetotal.FieldOrganizationID:
  34489. v, ok := value.(int64)
  34490. if !ok {
  34491. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34492. }
  34493. m.AddOrganizationID(v)
  34494. return nil
  34495. }
  34496. return fmt.Errorf("unknown UsageTotal numeric field %s", name)
  34497. }
  34498. // ClearedFields returns all nullable fields that were cleared during this
  34499. // mutation.
  34500. func (m *UsageTotalMutation) ClearedFields() []string {
  34501. var fields []string
  34502. if m.FieldCleared(usagetotal.FieldStatus) {
  34503. fields = append(fields, usagetotal.FieldStatus)
  34504. }
  34505. if m.FieldCleared(usagetotal.FieldType) {
  34506. fields = append(fields, usagetotal.FieldType)
  34507. }
  34508. if m.FieldCleared(usagetotal.FieldTotalTokens) {
  34509. fields = append(fields, usagetotal.FieldTotalTokens)
  34510. }
  34511. if m.FieldCleared(usagetotal.FieldStartIndex) {
  34512. fields = append(fields, usagetotal.FieldStartIndex)
  34513. }
  34514. if m.FieldCleared(usagetotal.FieldEndIndex) {
  34515. fields = append(fields, usagetotal.FieldEndIndex)
  34516. }
  34517. if m.FieldCleared(usagetotal.FieldOrganizationID) {
  34518. fields = append(fields, usagetotal.FieldOrganizationID)
  34519. }
  34520. return fields
  34521. }
  34522. // FieldCleared returns a boolean indicating if a field with the given name was
  34523. // cleared in this mutation.
  34524. func (m *UsageTotalMutation) FieldCleared(name string) bool {
  34525. _, ok := m.clearedFields[name]
  34526. return ok
  34527. }
  34528. // ClearField clears the value of the field with the given name. It returns an
  34529. // error if the field is not defined in the schema.
  34530. func (m *UsageTotalMutation) ClearField(name string) error {
  34531. switch name {
  34532. case usagetotal.FieldStatus:
  34533. m.ClearStatus()
  34534. return nil
  34535. case usagetotal.FieldType:
  34536. m.ClearType()
  34537. return nil
  34538. case usagetotal.FieldTotalTokens:
  34539. m.ClearTotalTokens()
  34540. return nil
  34541. case usagetotal.FieldStartIndex:
  34542. m.ClearStartIndex()
  34543. return nil
  34544. case usagetotal.FieldEndIndex:
  34545. m.ClearEndIndex()
  34546. return nil
  34547. case usagetotal.FieldOrganizationID:
  34548. m.ClearOrganizationID()
  34549. return nil
  34550. }
  34551. return fmt.Errorf("unknown UsageTotal nullable field %s", name)
  34552. }
  34553. // ResetField resets all changes in the mutation for the field with the given name.
  34554. // It returns an error if the field is not defined in the schema.
  34555. func (m *UsageTotalMutation) ResetField(name string) error {
  34556. switch name {
  34557. case usagetotal.FieldCreatedAt:
  34558. m.ResetCreatedAt()
  34559. return nil
  34560. case usagetotal.FieldUpdatedAt:
  34561. m.ResetUpdatedAt()
  34562. return nil
  34563. case usagetotal.FieldStatus:
  34564. m.ResetStatus()
  34565. return nil
  34566. case usagetotal.FieldType:
  34567. m.ResetType()
  34568. return nil
  34569. case usagetotal.FieldBotID:
  34570. m.ResetBotID()
  34571. return nil
  34572. case usagetotal.FieldTotalTokens:
  34573. m.ResetTotalTokens()
  34574. return nil
  34575. case usagetotal.FieldStartIndex:
  34576. m.ResetStartIndex()
  34577. return nil
  34578. case usagetotal.FieldEndIndex:
  34579. m.ResetEndIndex()
  34580. return nil
  34581. case usagetotal.FieldOrganizationID:
  34582. m.ResetOrganizationID()
  34583. return nil
  34584. }
  34585. return fmt.Errorf("unknown UsageTotal field %s", name)
  34586. }
  34587. // AddedEdges returns all edge names that were set/added in this mutation.
  34588. func (m *UsageTotalMutation) AddedEdges() []string {
  34589. edges := make([]string, 0, 0)
  34590. return edges
  34591. }
  34592. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  34593. // name in this mutation.
  34594. func (m *UsageTotalMutation) AddedIDs(name string) []ent.Value {
  34595. return nil
  34596. }
  34597. // RemovedEdges returns all edge names that were removed in this mutation.
  34598. func (m *UsageTotalMutation) RemovedEdges() []string {
  34599. edges := make([]string, 0, 0)
  34600. return edges
  34601. }
  34602. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  34603. // the given name in this mutation.
  34604. func (m *UsageTotalMutation) RemovedIDs(name string) []ent.Value {
  34605. return nil
  34606. }
  34607. // ClearedEdges returns all edge names that were cleared in this mutation.
  34608. func (m *UsageTotalMutation) ClearedEdges() []string {
  34609. edges := make([]string, 0, 0)
  34610. return edges
  34611. }
  34612. // EdgeCleared returns a boolean which indicates if the edge with the given name
  34613. // was cleared in this mutation.
  34614. func (m *UsageTotalMutation) EdgeCleared(name string) bool {
  34615. return false
  34616. }
  34617. // ClearEdge clears the value of the edge with the given name. It returns an error
  34618. // if that edge is not defined in the schema.
  34619. func (m *UsageTotalMutation) ClearEdge(name string) error {
  34620. return fmt.Errorf("unknown UsageTotal unique edge %s", name)
  34621. }
  34622. // ResetEdge resets all changes to the edge with the given name in this mutation.
  34623. // It returns an error if the edge is not defined in the schema.
  34624. func (m *UsageTotalMutation) ResetEdge(name string) error {
  34625. return fmt.Errorf("unknown UsageTotal edge %s", name)
  34626. }
  34627. // WhatsappMutation represents an operation that mutates the Whatsapp nodes in the graph.
  34628. type WhatsappMutation struct {
  34629. config
  34630. op Op
  34631. typ string
  34632. id *uint64
  34633. created_at *time.Time
  34634. updated_at *time.Time
  34635. status *uint8
  34636. addstatus *int8
  34637. deleted_at *time.Time
  34638. wa_id *string
  34639. wa_name *string
  34640. callback *string
  34641. account *string
  34642. cc *string
  34643. phone *string
  34644. cc_phone *string
  34645. phone_name *string
  34646. phone_status *int8
  34647. addphone_status *int8
  34648. organization_id *uint64
  34649. addorganization_id *int64
  34650. api_base *string
  34651. api_key *string
  34652. allow_list *[]string
  34653. appendallow_list []string
  34654. group_allow_list *[]string
  34655. appendgroup_allow_list []string
  34656. block_list *[]string
  34657. appendblock_list []string
  34658. group_block_list *[]string
  34659. appendgroup_block_list []string
  34660. clearedFields map[string]struct{}
  34661. agent *uint64
  34662. clearedagent bool
  34663. done bool
  34664. oldValue func(context.Context) (*Whatsapp, error)
  34665. predicates []predicate.Whatsapp
  34666. }
  34667. var _ ent.Mutation = (*WhatsappMutation)(nil)
  34668. // whatsappOption allows management of the mutation configuration using functional options.
  34669. type whatsappOption func(*WhatsappMutation)
  34670. // newWhatsappMutation creates new mutation for the Whatsapp entity.
  34671. func newWhatsappMutation(c config, op Op, opts ...whatsappOption) *WhatsappMutation {
  34672. m := &WhatsappMutation{
  34673. config: c,
  34674. op: op,
  34675. typ: TypeWhatsapp,
  34676. clearedFields: make(map[string]struct{}),
  34677. }
  34678. for _, opt := range opts {
  34679. opt(m)
  34680. }
  34681. return m
  34682. }
  34683. // withWhatsappID sets the ID field of the mutation.
  34684. func withWhatsappID(id uint64) whatsappOption {
  34685. return func(m *WhatsappMutation) {
  34686. var (
  34687. err error
  34688. once sync.Once
  34689. value *Whatsapp
  34690. )
  34691. m.oldValue = func(ctx context.Context) (*Whatsapp, error) {
  34692. once.Do(func() {
  34693. if m.done {
  34694. err = errors.New("querying old values post mutation is not allowed")
  34695. } else {
  34696. value, err = m.Client().Whatsapp.Get(ctx, id)
  34697. }
  34698. })
  34699. return value, err
  34700. }
  34701. m.id = &id
  34702. }
  34703. }
  34704. // withWhatsapp sets the old Whatsapp of the mutation.
  34705. func withWhatsapp(node *Whatsapp) whatsappOption {
  34706. return func(m *WhatsappMutation) {
  34707. m.oldValue = func(context.Context) (*Whatsapp, error) {
  34708. return node, nil
  34709. }
  34710. m.id = &node.ID
  34711. }
  34712. }
  34713. // Client returns a new `ent.Client` from the mutation. If the mutation was
  34714. // executed in a transaction (ent.Tx), a transactional client is returned.
  34715. func (m WhatsappMutation) Client() *Client {
  34716. client := &Client{config: m.config}
  34717. client.init()
  34718. return client
  34719. }
  34720. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  34721. // it returns an error otherwise.
  34722. func (m WhatsappMutation) Tx() (*Tx, error) {
  34723. if _, ok := m.driver.(*txDriver); !ok {
  34724. return nil, errors.New("ent: mutation is not running in a transaction")
  34725. }
  34726. tx := &Tx{config: m.config}
  34727. tx.init()
  34728. return tx, nil
  34729. }
  34730. // SetID sets the value of the id field. Note that this
  34731. // operation is only accepted on creation of Whatsapp entities.
  34732. func (m *WhatsappMutation) SetID(id uint64) {
  34733. m.id = &id
  34734. }
  34735. // ID returns the ID value in the mutation. Note that the ID is only available
  34736. // if it was provided to the builder or after it was returned from the database.
  34737. func (m *WhatsappMutation) ID() (id uint64, exists bool) {
  34738. if m.id == nil {
  34739. return
  34740. }
  34741. return *m.id, true
  34742. }
  34743. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  34744. // That means, if the mutation is applied within a transaction with an isolation level such
  34745. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  34746. // or updated by the mutation.
  34747. func (m *WhatsappMutation) IDs(ctx context.Context) ([]uint64, error) {
  34748. switch {
  34749. case m.op.Is(OpUpdateOne | OpDeleteOne):
  34750. id, exists := m.ID()
  34751. if exists {
  34752. return []uint64{id}, nil
  34753. }
  34754. fallthrough
  34755. case m.op.Is(OpUpdate | OpDelete):
  34756. return m.Client().Whatsapp.Query().Where(m.predicates...).IDs(ctx)
  34757. default:
  34758. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  34759. }
  34760. }
  34761. // SetCreatedAt sets the "created_at" field.
  34762. func (m *WhatsappMutation) SetCreatedAt(t time.Time) {
  34763. m.created_at = &t
  34764. }
  34765. // CreatedAt returns the value of the "created_at" field in the mutation.
  34766. func (m *WhatsappMutation) CreatedAt() (r time.Time, exists bool) {
  34767. v := m.created_at
  34768. if v == nil {
  34769. return
  34770. }
  34771. return *v, true
  34772. }
  34773. // OldCreatedAt returns the old "created_at" field's value of the Whatsapp entity.
  34774. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34775. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34776. func (m *WhatsappMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  34777. if !m.op.Is(OpUpdateOne) {
  34778. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  34779. }
  34780. if m.id == nil || m.oldValue == nil {
  34781. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  34782. }
  34783. oldValue, err := m.oldValue(ctx)
  34784. if err != nil {
  34785. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  34786. }
  34787. return oldValue.CreatedAt, nil
  34788. }
  34789. // ResetCreatedAt resets all changes to the "created_at" field.
  34790. func (m *WhatsappMutation) ResetCreatedAt() {
  34791. m.created_at = nil
  34792. }
  34793. // SetUpdatedAt sets the "updated_at" field.
  34794. func (m *WhatsappMutation) SetUpdatedAt(t time.Time) {
  34795. m.updated_at = &t
  34796. }
  34797. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  34798. func (m *WhatsappMutation) UpdatedAt() (r time.Time, exists bool) {
  34799. v := m.updated_at
  34800. if v == nil {
  34801. return
  34802. }
  34803. return *v, true
  34804. }
  34805. // OldUpdatedAt returns the old "updated_at" field's value of the Whatsapp entity.
  34806. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34807. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34808. func (m *WhatsappMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  34809. if !m.op.Is(OpUpdateOne) {
  34810. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  34811. }
  34812. if m.id == nil || m.oldValue == nil {
  34813. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  34814. }
  34815. oldValue, err := m.oldValue(ctx)
  34816. if err != nil {
  34817. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  34818. }
  34819. return oldValue.UpdatedAt, nil
  34820. }
  34821. // ResetUpdatedAt resets all changes to the "updated_at" field.
  34822. func (m *WhatsappMutation) ResetUpdatedAt() {
  34823. m.updated_at = nil
  34824. }
  34825. // SetStatus sets the "status" field.
  34826. func (m *WhatsappMutation) SetStatus(u uint8) {
  34827. m.status = &u
  34828. m.addstatus = nil
  34829. }
  34830. // Status returns the value of the "status" field in the mutation.
  34831. func (m *WhatsappMutation) Status() (r uint8, exists bool) {
  34832. v := m.status
  34833. if v == nil {
  34834. return
  34835. }
  34836. return *v, true
  34837. }
  34838. // OldStatus returns the old "status" field's value of the Whatsapp entity.
  34839. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34840. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34841. func (m *WhatsappMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  34842. if !m.op.Is(OpUpdateOne) {
  34843. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  34844. }
  34845. if m.id == nil || m.oldValue == nil {
  34846. return v, errors.New("OldStatus requires an ID field in the mutation")
  34847. }
  34848. oldValue, err := m.oldValue(ctx)
  34849. if err != nil {
  34850. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  34851. }
  34852. return oldValue.Status, nil
  34853. }
  34854. // AddStatus adds u to the "status" field.
  34855. func (m *WhatsappMutation) AddStatus(u int8) {
  34856. if m.addstatus != nil {
  34857. *m.addstatus += u
  34858. } else {
  34859. m.addstatus = &u
  34860. }
  34861. }
  34862. // AddedStatus returns the value that was added to the "status" field in this mutation.
  34863. func (m *WhatsappMutation) AddedStatus() (r int8, exists bool) {
  34864. v := m.addstatus
  34865. if v == nil {
  34866. return
  34867. }
  34868. return *v, true
  34869. }
  34870. // ClearStatus clears the value of the "status" field.
  34871. func (m *WhatsappMutation) ClearStatus() {
  34872. m.status = nil
  34873. m.addstatus = nil
  34874. m.clearedFields[whatsapp.FieldStatus] = struct{}{}
  34875. }
  34876. // StatusCleared returns if the "status" field was cleared in this mutation.
  34877. func (m *WhatsappMutation) StatusCleared() bool {
  34878. _, ok := m.clearedFields[whatsapp.FieldStatus]
  34879. return ok
  34880. }
  34881. // ResetStatus resets all changes to the "status" field.
  34882. func (m *WhatsappMutation) ResetStatus() {
  34883. m.status = nil
  34884. m.addstatus = nil
  34885. delete(m.clearedFields, whatsapp.FieldStatus)
  34886. }
  34887. // SetDeletedAt sets the "deleted_at" field.
  34888. func (m *WhatsappMutation) SetDeletedAt(t time.Time) {
  34889. m.deleted_at = &t
  34890. }
  34891. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  34892. func (m *WhatsappMutation) DeletedAt() (r time.Time, exists bool) {
  34893. v := m.deleted_at
  34894. if v == nil {
  34895. return
  34896. }
  34897. return *v, true
  34898. }
  34899. // OldDeletedAt returns the old "deleted_at" field's value of the Whatsapp entity.
  34900. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34901. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34902. func (m *WhatsappMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  34903. if !m.op.Is(OpUpdateOne) {
  34904. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  34905. }
  34906. if m.id == nil || m.oldValue == nil {
  34907. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  34908. }
  34909. oldValue, err := m.oldValue(ctx)
  34910. if err != nil {
  34911. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  34912. }
  34913. return oldValue.DeletedAt, nil
  34914. }
  34915. // ClearDeletedAt clears the value of the "deleted_at" field.
  34916. func (m *WhatsappMutation) ClearDeletedAt() {
  34917. m.deleted_at = nil
  34918. m.clearedFields[whatsapp.FieldDeletedAt] = struct{}{}
  34919. }
  34920. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  34921. func (m *WhatsappMutation) DeletedAtCleared() bool {
  34922. _, ok := m.clearedFields[whatsapp.FieldDeletedAt]
  34923. return ok
  34924. }
  34925. // ResetDeletedAt resets all changes to the "deleted_at" field.
  34926. func (m *WhatsappMutation) ResetDeletedAt() {
  34927. m.deleted_at = nil
  34928. delete(m.clearedFields, whatsapp.FieldDeletedAt)
  34929. }
  34930. // SetWaID sets the "wa_id" field.
  34931. func (m *WhatsappMutation) SetWaID(s string) {
  34932. m.wa_id = &s
  34933. }
  34934. // WaID returns the value of the "wa_id" field in the mutation.
  34935. func (m *WhatsappMutation) WaID() (r string, exists bool) {
  34936. v := m.wa_id
  34937. if v == nil {
  34938. return
  34939. }
  34940. return *v, true
  34941. }
  34942. // OldWaID returns the old "wa_id" field's value of the Whatsapp entity.
  34943. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34944. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34945. func (m *WhatsappMutation) OldWaID(ctx context.Context) (v string, err error) {
  34946. if !m.op.Is(OpUpdateOne) {
  34947. return v, errors.New("OldWaID is only allowed on UpdateOne operations")
  34948. }
  34949. if m.id == nil || m.oldValue == nil {
  34950. return v, errors.New("OldWaID requires an ID field in the mutation")
  34951. }
  34952. oldValue, err := m.oldValue(ctx)
  34953. if err != nil {
  34954. return v, fmt.Errorf("querying old value for OldWaID: %w", err)
  34955. }
  34956. return oldValue.WaID, nil
  34957. }
  34958. // ClearWaID clears the value of the "wa_id" field.
  34959. func (m *WhatsappMutation) ClearWaID() {
  34960. m.wa_id = nil
  34961. m.clearedFields[whatsapp.FieldWaID] = struct{}{}
  34962. }
  34963. // WaIDCleared returns if the "wa_id" field was cleared in this mutation.
  34964. func (m *WhatsappMutation) WaIDCleared() bool {
  34965. _, ok := m.clearedFields[whatsapp.FieldWaID]
  34966. return ok
  34967. }
  34968. // ResetWaID resets all changes to the "wa_id" field.
  34969. func (m *WhatsappMutation) ResetWaID() {
  34970. m.wa_id = nil
  34971. delete(m.clearedFields, whatsapp.FieldWaID)
  34972. }
  34973. // SetWaName sets the "wa_name" field.
  34974. func (m *WhatsappMutation) SetWaName(s string) {
  34975. m.wa_name = &s
  34976. }
  34977. // WaName returns the value of the "wa_name" field in the mutation.
  34978. func (m *WhatsappMutation) WaName() (r string, exists bool) {
  34979. v := m.wa_name
  34980. if v == nil {
  34981. return
  34982. }
  34983. return *v, true
  34984. }
  34985. // OldWaName returns the old "wa_name" field's value of the Whatsapp entity.
  34986. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34987. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34988. func (m *WhatsappMutation) OldWaName(ctx context.Context) (v string, err error) {
  34989. if !m.op.Is(OpUpdateOne) {
  34990. return v, errors.New("OldWaName is only allowed on UpdateOne operations")
  34991. }
  34992. if m.id == nil || m.oldValue == nil {
  34993. return v, errors.New("OldWaName requires an ID field in the mutation")
  34994. }
  34995. oldValue, err := m.oldValue(ctx)
  34996. if err != nil {
  34997. return v, fmt.Errorf("querying old value for OldWaName: %w", err)
  34998. }
  34999. return oldValue.WaName, nil
  35000. }
  35001. // ClearWaName clears the value of the "wa_name" field.
  35002. func (m *WhatsappMutation) ClearWaName() {
  35003. m.wa_name = nil
  35004. m.clearedFields[whatsapp.FieldWaName] = struct{}{}
  35005. }
  35006. // WaNameCleared returns if the "wa_name" field was cleared in this mutation.
  35007. func (m *WhatsappMutation) WaNameCleared() bool {
  35008. _, ok := m.clearedFields[whatsapp.FieldWaName]
  35009. return ok
  35010. }
  35011. // ResetWaName resets all changes to the "wa_name" field.
  35012. func (m *WhatsappMutation) ResetWaName() {
  35013. m.wa_name = nil
  35014. delete(m.clearedFields, whatsapp.FieldWaName)
  35015. }
  35016. // SetCallback sets the "callback" field.
  35017. func (m *WhatsappMutation) SetCallback(s string) {
  35018. m.callback = &s
  35019. }
  35020. // Callback returns the value of the "callback" field in the mutation.
  35021. func (m *WhatsappMutation) Callback() (r string, exists bool) {
  35022. v := m.callback
  35023. if v == nil {
  35024. return
  35025. }
  35026. return *v, true
  35027. }
  35028. // OldCallback returns the old "callback" field's value of the Whatsapp entity.
  35029. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35030. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35031. func (m *WhatsappMutation) OldCallback(ctx context.Context) (v string, err error) {
  35032. if !m.op.Is(OpUpdateOne) {
  35033. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  35034. }
  35035. if m.id == nil || m.oldValue == nil {
  35036. return v, errors.New("OldCallback requires an ID field in the mutation")
  35037. }
  35038. oldValue, err := m.oldValue(ctx)
  35039. if err != nil {
  35040. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  35041. }
  35042. return oldValue.Callback, nil
  35043. }
  35044. // ClearCallback clears the value of the "callback" field.
  35045. func (m *WhatsappMutation) ClearCallback() {
  35046. m.callback = nil
  35047. m.clearedFields[whatsapp.FieldCallback] = struct{}{}
  35048. }
  35049. // CallbackCleared returns if the "callback" field was cleared in this mutation.
  35050. func (m *WhatsappMutation) CallbackCleared() bool {
  35051. _, ok := m.clearedFields[whatsapp.FieldCallback]
  35052. return ok
  35053. }
  35054. // ResetCallback resets all changes to the "callback" field.
  35055. func (m *WhatsappMutation) ResetCallback() {
  35056. m.callback = nil
  35057. delete(m.clearedFields, whatsapp.FieldCallback)
  35058. }
  35059. // SetAgentID sets the "agent_id" field.
  35060. func (m *WhatsappMutation) SetAgentID(u uint64) {
  35061. m.agent = &u
  35062. }
  35063. // AgentID returns the value of the "agent_id" field in the mutation.
  35064. func (m *WhatsappMutation) AgentID() (r uint64, exists bool) {
  35065. v := m.agent
  35066. if v == nil {
  35067. return
  35068. }
  35069. return *v, true
  35070. }
  35071. // OldAgentID returns the old "agent_id" field's value of the Whatsapp entity.
  35072. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35073. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35074. func (m *WhatsappMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  35075. if !m.op.Is(OpUpdateOne) {
  35076. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  35077. }
  35078. if m.id == nil || m.oldValue == nil {
  35079. return v, errors.New("OldAgentID requires an ID field in the mutation")
  35080. }
  35081. oldValue, err := m.oldValue(ctx)
  35082. if err != nil {
  35083. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  35084. }
  35085. return oldValue.AgentID, nil
  35086. }
  35087. // ResetAgentID resets all changes to the "agent_id" field.
  35088. func (m *WhatsappMutation) ResetAgentID() {
  35089. m.agent = nil
  35090. }
  35091. // SetAccount sets the "account" field.
  35092. func (m *WhatsappMutation) SetAccount(s string) {
  35093. m.account = &s
  35094. }
  35095. // Account returns the value of the "account" field in the mutation.
  35096. func (m *WhatsappMutation) Account() (r string, exists bool) {
  35097. v := m.account
  35098. if v == nil {
  35099. return
  35100. }
  35101. return *v, true
  35102. }
  35103. // OldAccount returns the old "account" field's value of the Whatsapp entity.
  35104. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35105. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35106. func (m *WhatsappMutation) OldAccount(ctx context.Context) (v string, err error) {
  35107. if !m.op.Is(OpUpdateOne) {
  35108. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  35109. }
  35110. if m.id == nil || m.oldValue == nil {
  35111. return v, errors.New("OldAccount requires an ID field in the mutation")
  35112. }
  35113. oldValue, err := m.oldValue(ctx)
  35114. if err != nil {
  35115. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  35116. }
  35117. return oldValue.Account, nil
  35118. }
  35119. // ClearAccount clears the value of the "account" field.
  35120. func (m *WhatsappMutation) ClearAccount() {
  35121. m.account = nil
  35122. m.clearedFields[whatsapp.FieldAccount] = struct{}{}
  35123. }
  35124. // AccountCleared returns if the "account" field was cleared in this mutation.
  35125. func (m *WhatsappMutation) AccountCleared() bool {
  35126. _, ok := m.clearedFields[whatsapp.FieldAccount]
  35127. return ok
  35128. }
  35129. // ResetAccount resets all changes to the "account" field.
  35130. func (m *WhatsappMutation) ResetAccount() {
  35131. m.account = nil
  35132. delete(m.clearedFields, whatsapp.FieldAccount)
  35133. }
  35134. // SetCc sets the "cc" field.
  35135. func (m *WhatsappMutation) SetCc(s string) {
  35136. m.cc = &s
  35137. }
  35138. // Cc returns the value of the "cc" field in the mutation.
  35139. func (m *WhatsappMutation) Cc() (r string, exists bool) {
  35140. v := m.cc
  35141. if v == nil {
  35142. return
  35143. }
  35144. return *v, true
  35145. }
  35146. // OldCc returns the old "cc" field's value of the Whatsapp entity.
  35147. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35148. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35149. func (m *WhatsappMutation) OldCc(ctx context.Context) (v string, err error) {
  35150. if !m.op.Is(OpUpdateOne) {
  35151. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  35152. }
  35153. if m.id == nil || m.oldValue == nil {
  35154. return v, errors.New("OldCc requires an ID field in the mutation")
  35155. }
  35156. oldValue, err := m.oldValue(ctx)
  35157. if err != nil {
  35158. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  35159. }
  35160. return oldValue.Cc, nil
  35161. }
  35162. // ResetCc resets all changes to the "cc" field.
  35163. func (m *WhatsappMutation) ResetCc() {
  35164. m.cc = nil
  35165. }
  35166. // SetPhone sets the "phone" field.
  35167. func (m *WhatsappMutation) SetPhone(s string) {
  35168. m.phone = &s
  35169. }
  35170. // Phone returns the value of the "phone" field in the mutation.
  35171. func (m *WhatsappMutation) Phone() (r string, exists bool) {
  35172. v := m.phone
  35173. if v == nil {
  35174. return
  35175. }
  35176. return *v, true
  35177. }
  35178. // OldPhone returns the old "phone" field's value of the Whatsapp entity.
  35179. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35180. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35181. func (m *WhatsappMutation) OldPhone(ctx context.Context) (v string, err error) {
  35182. if !m.op.Is(OpUpdateOne) {
  35183. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  35184. }
  35185. if m.id == nil || m.oldValue == nil {
  35186. return v, errors.New("OldPhone requires an ID field in the mutation")
  35187. }
  35188. oldValue, err := m.oldValue(ctx)
  35189. if err != nil {
  35190. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  35191. }
  35192. return oldValue.Phone, nil
  35193. }
  35194. // ResetPhone resets all changes to the "phone" field.
  35195. func (m *WhatsappMutation) ResetPhone() {
  35196. m.phone = nil
  35197. }
  35198. // SetCcPhone sets the "cc_phone" field.
  35199. func (m *WhatsappMutation) SetCcPhone(s string) {
  35200. m.cc_phone = &s
  35201. }
  35202. // CcPhone returns the value of the "cc_phone" field in the mutation.
  35203. func (m *WhatsappMutation) CcPhone() (r string, exists bool) {
  35204. v := m.cc_phone
  35205. if v == nil {
  35206. return
  35207. }
  35208. return *v, true
  35209. }
  35210. // OldCcPhone returns the old "cc_phone" field's value of the Whatsapp entity.
  35211. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35212. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35213. func (m *WhatsappMutation) OldCcPhone(ctx context.Context) (v string, err error) {
  35214. if !m.op.Is(OpUpdateOne) {
  35215. return v, errors.New("OldCcPhone is only allowed on UpdateOne operations")
  35216. }
  35217. if m.id == nil || m.oldValue == nil {
  35218. return v, errors.New("OldCcPhone requires an ID field in the mutation")
  35219. }
  35220. oldValue, err := m.oldValue(ctx)
  35221. if err != nil {
  35222. return v, fmt.Errorf("querying old value for OldCcPhone: %w", err)
  35223. }
  35224. return oldValue.CcPhone, nil
  35225. }
  35226. // ResetCcPhone resets all changes to the "cc_phone" field.
  35227. func (m *WhatsappMutation) ResetCcPhone() {
  35228. m.cc_phone = nil
  35229. }
  35230. // SetPhoneName sets the "phone_name" field.
  35231. func (m *WhatsappMutation) SetPhoneName(s string) {
  35232. m.phone_name = &s
  35233. }
  35234. // PhoneName returns the value of the "phone_name" field in the mutation.
  35235. func (m *WhatsappMutation) PhoneName() (r string, exists bool) {
  35236. v := m.phone_name
  35237. if v == nil {
  35238. return
  35239. }
  35240. return *v, true
  35241. }
  35242. // OldPhoneName returns the old "phone_name" field's value of the Whatsapp entity.
  35243. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35244. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35245. func (m *WhatsappMutation) OldPhoneName(ctx context.Context) (v string, err error) {
  35246. if !m.op.Is(OpUpdateOne) {
  35247. return v, errors.New("OldPhoneName is only allowed on UpdateOne operations")
  35248. }
  35249. if m.id == nil || m.oldValue == nil {
  35250. return v, errors.New("OldPhoneName requires an ID field in the mutation")
  35251. }
  35252. oldValue, err := m.oldValue(ctx)
  35253. if err != nil {
  35254. return v, fmt.Errorf("querying old value for OldPhoneName: %w", err)
  35255. }
  35256. return oldValue.PhoneName, nil
  35257. }
  35258. // ResetPhoneName resets all changes to the "phone_name" field.
  35259. func (m *WhatsappMutation) ResetPhoneName() {
  35260. m.phone_name = nil
  35261. }
  35262. // SetPhoneStatus sets the "phone_status" field.
  35263. func (m *WhatsappMutation) SetPhoneStatus(i int8) {
  35264. m.phone_status = &i
  35265. m.addphone_status = nil
  35266. }
  35267. // PhoneStatus returns the value of the "phone_status" field in the mutation.
  35268. func (m *WhatsappMutation) PhoneStatus() (r int8, exists bool) {
  35269. v := m.phone_status
  35270. if v == nil {
  35271. return
  35272. }
  35273. return *v, true
  35274. }
  35275. // OldPhoneStatus returns the old "phone_status" field's value of the Whatsapp entity.
  35276. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35277. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35278. func (m *WhatsappMutation) OldPhoneStatus(ctx context.Context) (v int8, err error) {
  35279. if !m.op.Is(OpUpdateOne) {
  35280. return v, errors.New("OldPhoneStatus is only allowed on UpdateOne operations")
  35281. }
  35282. if m.id == nil || m.oldValue == nil {
  35283. return v, errors.New("OldPhoneStatus requires an ID field in the mutation")
  35284. }
  35285. oldValue, err := m.oldValue(ctx)
  35286. if err != nil {
  35287. return v, fmt.Errorf("querying old value for OldPhoneStatus: %w", err)
  35288. }
  35289. return oldValue.PhoneStatus, nil
  35290. }
  35291. // AddPhoneStatus adds i to the "phone_status" field.
  35292. func (m *WhatsappMutation) AddPhoneStatus(i int8) {
  35293. if m.addphone_status != nil {
  35294. *m.addphone_status += i
  35295. } else {
  35296. m.addphone_status = &i
  35297. }
  35298. }
  35299. // AddedPhoneStatus returns the value that was added to the "phone_status" field in this mutation.
  35300. func (m *WhatsappMutation) AddedPhoneStatus() (r int8, exists bool) {
  35301. v := m.addphone_status
  35302. if v == nil {
  35303. return
  35304. }
  35305. return *v, true
  35306. }
  35307. // ResetPhoneStatus resets all changes to the "phone_status" field.
  35308. func (m *WhatsappMutation) ResetPhoneStatus() {
  35309. m.phone_status = nil
  35310. m.addphone_status = nil
  35311. }
  35312. // SetOrganizationID sets the "organization_id" field.
  35313. func (m *WhatsappMutation) SetOrganizationID(u uint64) {
  35314. m.organization_id = &u
  35315. m.addorganization_id = nil
  35316. }
  35317. // OrganizationID returns the value of the "organization_id" field in the mutation.
  35318. func (m *WhatsappMutation) OrganizationID() (r uint64, exists bool) {
  35319. v := m.organization_id
  35320. if v == nil {
  35321. return
  35322. }
  35323. return *v, true
  35324. }
  35325. // OldOrganizationID returns the old "organization_id" field's value of the Whatsapp entity.
  35326. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35327. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35328. func (m *WhatsappMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  35329. if !m.op.Is(OpUpdateOne) {
  35330. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  35331. }
  35332. if m.id == nil || m.oldValue == nil {
  35333. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  35334. }
  35335. oldValue, err := m.oldValue(ctx)
  35336. if err != nil {
  35337. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  35338. }
  35339. return oldValue.OrganizationID, nil
  35340. }
  35341. // AddOrganizationID adds u to the "organization_id" field.
  35342. func (m *WhatsappMutation) AddOrganizationID(u int64) {
  35343. if m.addorganization_id != nil {
  35344. *m.addorganization_id += u
  35345. } else {
  35346. m.addorganization_id = &u
  35347. }
  35348. }
  35349. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  35350. func (m *WhatsappMutation) AddedOrganizationID() (r int64, exists bool) {
  35351. v := m.addorganization_id
  35352. if v == nil {
  35353. return
  35354. }
  35355. return *v, true
  35356. }
  35357. // ClearOrganizationID clears the value of the "organization_id" field.
  35358. func (m *WhatsappMutation) ClearOrganizationID() {
  35359. m.organization_id = nil
  35360. m.addorganization_id = nil
  35361. m.clearedFields[whatsapp.FieldOrganizationID] = struct{}{}
  35362. }
  35363. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  35364. func (m *WhatsappMutation) OrganizationIDCleared() bool {
  35365. _, ok := m.clearedFields[whatsapp.FieldOrganizationID]
  35366. return ok
  35367. }
  35368. // ResetOrganizationID resets all changes to the "organization_id" field.
  35369. func (m *WhatsappMutation) ResetOrganizationID() {
  35370. m.organization_id = nil
  35371. m.addorganization_id = nil
  35372. delete(m.clearedFields, whatsapp.FieldOrganizationID)
  35373. }
  35374. // SetAPIBase sets the "api_base" field.
  35375. func (m *WhatsappMutation) SetAPIBase(s string) {
  35376. m.api_base = &s
  35377. }
  35378. // APIBase returns the value of the "api_base" field in the mutation.
  35379. func (m *WhatsappMutation) APIBase() (r string, exists bool) {
  35380. v := m.api_base
  35381. if v == nil {
  35382. return
  35383. }
  35384. return *v, true
  35385. }
  35386. // OldAPIBase returns the old "api_base" field's value of the Whatsapp entity.
  35387. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35388. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35389. func (m *WhatsappMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  35390. if !m.op.Is(OpUpdateOne) {
  35391. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  35392. }
  35393. if m.id == nil || m.oldValue == nil {
  35394. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  35395. }
  35396. oldValue, err := m.oldValue(ctx)
  35397. if err != nil {
  35398. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  35399. }
  35400. return oldValue.APIBase, nil
  35401. }
  35402. // ClearAPIBase clears the value of the "api_base" field.
  35403. func (m *WhatsappMutation) ClearAPIBase() {
  35404. m.api_base = nil
  35405. m.clearedFields[whatsapp.FieldAPIBase] = struct{}{}
  35406. }
  35407. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  35408. func (m *WhatsappMutation) APIBaseCleared() bool {
  35409. _, ok := m.clearedFields[whatsapp.FieldAPIBase]
  35410. return ok
  35411. }
  35412. // ResetAPIBase resets all changes to the "api_base" field.
  35413. func (m *WhatsappMutation) ResetAPIBase() {
  35414. m.api_base = nil
  35415. delete(m.clearedFields, whatsapp.FieldAPIBase)
  35416. }
  35417. // SetAPIKey sets the "api_key" field.
  35418. func (m *WhatsappMutation) SetAPIKey(s string) {
  35419. m.api_key = &s
  35420. }
  35421. // APIKey returns the value of the "api_key" field in the mutation.
  35422. func (m *WhatsappMutation) APIKey() (r string, exists bool) {
  35423. v := m.api_key
  35424. if v == nil {
  35425. return
  35426. }
  35427. return *v, true
  35428. }
  35429. // OldAPIKey returns the old "api_key" field's value of the Whatsapp entity.
  35430. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35431. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35432. func (m *WhatsappMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  35433. if !m.op.Is(OpUpdateOne) {
  35434. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  35435. }
  35436. if m.id == nil || m.oldValue == nil {
  35437. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  35438. }
  35439. oldValue, err := m.oldValue(ctx)
  35440. if err != nil {
  35441. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  35442. }
  35443. return oldValue.APIKey, nil
  35444. }
  35445. // ClearAPIKey clears the value of the "api_key" field.
  35446. func (m *WhatsappMutation) ClearAPIKey() {
  35447. m.api_key = nil
  35448. m.clearedFields[whatsapp.FieldAPIKey] = struct{}{}
  35449. }
  35450. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  35451. func (m *WhatsappMutation) APIKeyCleared() bool {
  35452. _, ok := m.clearedFields[whatsapp.FieldAPIKey]
  35453. return ok
  35454. }
  35455. // ResetAPIKey resets all changes to the "api_key" field.
  35456. func (m *WhatsappMutation) ResetAPIKey() {
  35457. m.api_key = nil
  35458. delete(m.clearedFields, whatsapp.FieldAPIKey)
  35459. }
  35460. // SetAllowList sets the "allow_list" field.
  35461. func (m *WhatsappMutation) SetAllowList(s []string) {
  35462. m.allow_list = &s
  35463. m.appendallow_list = nil
  35464. }
  35465. // AllowList returns the value of the "allow_list" field in the mutation.
  35466. func (m *WhatsappMutation) AllowList() (r []string, exists bool) {
  35467. v := m.allow_list
  35468. if v == nil {
  35469. return
  35470. }
  35471. return *v, true
  35472. }
  35473. // OldAllowList returns the old "allow_list" field's value of the Whatsapp entity.
  35474. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35475. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35476. func (m *WhatsappMutation) OldAllowList(ctx context.Context) (v []string, err error) {
  35477. if !m.op.Is(OpUpdateOne) {
  35478. return v, errors.New("OldAllowList is only allowed on UpdateOne operations")
  35479. }
  35480. if m.id == nil || m.oldValue == nil {
  35481. return v, errors.New("OldAllowList requires an ID field in the mutation")
  35482. }
  35483. oldValue, err := m.oldValue(ctx)
  35484. if err != nil {
  35485. return v, fmt.Errorf("querying old value for OldAllowList: %w", err)
  35486. }
  35487. return oldValue.AllowList, nil
  35488. }
  35489. // AppendAllowList adds s to the "allow_list" field.
  35490. func (m *WhatsappMutation) AppendAllowList(s []string) {
  35491. m.appendallow_list = append(m.appendallow_list, s...)
  35492. }
  35493. // AppendedAllowList returns the list of values that were appended to the "allow_list" field in this mutation.
  35494. func (m *WhatsappMutation) AppendedAllowList() ([]string, bool) {
  35495. if len(m.appendallow_list) == 0 {
  35496. return nil, false
  35497. }
  35498. return m.appendallow_list, true
  35499. }
  35500. // ClearAllowList clears the value of the "allow_list" field.
  35501. func (m *WhatsappMutation) ClearAllowList() {
  35502. m.allow_list = nil
  35503. m.appendallow_list = nil
  35504. m.clearedFields[whatsapp.FieldAllowList] = struct{}{}
  35505. }
  35506. // AllowListCleared returns if the "allow_list" field was cleared in this mutation.
  35507. func (m *WhatsappMutation) AllowListCleared() bool {
  35508. _, ok := m.clearedFields[whatsapp.FieldAllowList]
  35509. return ok
  35510. }
  35511. // ResetAllowList resets all changes to the "allow_list" field.
  35512. func (m *WhatsappMutation) ResetAllowList() {
  35513. m.allow_list = nil
  35514. m.appendallow_list = nil
  35515. delete(m.clearedFields, whatsapp.FieldAllowList)
  35516. }
  35517. // SetGroupAllowList sets the "group_allow_list" field.
  35518. func (m *WhatsappMutation) SetGroupAllowList(s []string) {
  35519. m.group_allow_list = &s
  35520. m.appendgroup_allow_list = nil
  35521. }
  35522. // GroupAllowList returns the value of the "group_allow_list" field in the mutation.
  35523. func (m *WhatsappMutation) GroupAllowList() (r []string, exists bool) {
  35524. v := m.group_allow_list
  35525. if v == nil {
  35526. return
  35527. }
  35528. return *v, true
  35529. }
  35530. // OldGroupAllowList returns the old "group_allow_list" field's value of the Whatsapp entity.
  35531. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35532. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35533. func (m *WhatsappMutation) OldGroupAllowList(ctx context.Context) (v []string, err error) {
  35534. if !m.op.Is(OpUpdateOne) {
  35535. return v, errors.New("OldGroupAllowList is only allowed on UpdateOne operations")
  35536. }
  35537. if m.id == nil || m.oldValue == nil {
  35538. return v, errors.New("OldGroupAllowList requires an ID field in the mutation")
  35539. }
  35540. oldValue, err := m.oldValue(ctx)
  35541. if err != nil {
  35542. return v, fmt.Errorf("querying old value for OldGroupAllowList: %w", err)
  35543. }
  35544. return oldValue.GroupAllowList, nil
  35545. }
  35546. // AppendGroupAllowList adds s to the "group_allow_list" field.
  35547. func (m *WhatsappMutation) AppendGroupAllowList(s []string) {
  35548. m.appendgroup_allow_list = append(m.appendgroup_allow_list, s...)
  35549. }
  35550. // AppendedGroupAllowList returns the list of values that were appended to the "group_allow_list" field in this mutation.
  35551. func (m *WhatsappMutation) AppendedGroupAllowList() ([]string, bool) {
  35552. if len(m.appendgroup_allow_list) == 0 {
  35553. return nil, false
  35554. }
  35555. return m.appendgroup_allow_list, true
  35556. }
  35557. // ClearGroupAllowList clears the value of the "group_allow_list" field.
  35558. func (m *WhatsappMutation) ClearGroupAllowList() {
  35559. m.group_allow_list = nil
  35560. m.appendgroup_allow_list = nil
  35561. m.clearedFields[whatsapp.FieldGroupAllowList] = struct{}{}
  35562. }
  35563. // GroupAllowListCleared returns if the "group_allow_list" field was cleared in this mutation.
  35564. func (m *WhatsappMutation) GroupAllowListCleared() bool {
  35565. _, ok := m.clearedFields[whatsapp.FieldGroupAllowList]
  35566. return ok
  35567. }
  35568. // ResetGroupAllowList resets all changes to the "group_allow_list" field.
  35569. func (m *WhatsappMutation) ResetGroupAllowList() {
  35570. m.group_allow_list = nil
  35571. m.appendgroup_allow_list = nil
  35572. delete(m.clearedFields, whatsapp.FieldGroupAllowList)
  35573. }
  35574. // SetBlockList sets the "block_list" field.
  35575. func (m *WhatsappMutation) SetBlockList(s []string) {
  35576. m.block_list = &s
  35577. m.appendblock_list = nil
  35578. }
  35579. // BlockList returns the value of the "block_list" field in the mutation.
  35580. func (m *WhatsappMutation) BlockList() (r []string, exists bool) {
  35581. v := m.block_list
  35582. if v == nil {
  35583. return
  35584. }
  35585. return *v, true
  35586. }
  35587. // OldBlockList returns the old "block_list" field's value of the Whatsapp entity.
  35588. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35589. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35590. func (m *WhatsappMutation) OldBlockList(ctx context.Context) (v []string, err error) {
  35591. if !m.op.Is(OpUpdateOne) {
  35592. return v, errors.New("OldBlockList is only allowed on UpdateOne operations")
  35593. }
  35594. if m.id == nil || m.oldValue == nil {
  35595. return v, errors.New("OldBlockList requires an ID field in the mutation")
  35596. }
  35597. oldValue, err := m.oldValue(ctx)
  35598. if err != nil {
  35599. return v, fmt.Errorf("querying old value for OldBlockList: %w", err)
  35600. }
  35601. return oldValue.BlockList, nil
  35602. }
  35603. // AppendBlockList adds s to the "block_list" field.
  35604. func (m *WhatsappMutation) AppendBlockList(s []string) {
  35605. m.appendblock_list = append(m.appendblock_list, s...)
  35606. }
  35607. // AppendedBlockList returns the list of values that were appended to the "block_list" field in this mutation.
  35608. func (m *WhatsappMutation) AppendedBlockList() ([]string, bool) {
  35609. if len(m.appendblock_list) == 0 {
  35610. return nil, false
  35611. }
  35612. return m.appendblock_list, true
  35613. }
  35614. // ClearBlockList clears the value of the "block_list" field.
  35615. func (m *WhatsappMutation) ClearBlockList() {
  35616. m.block_list = nil
  35617. m.appendblock_list = nil
  35618. m.clearedFields[whatsapp.FieldBlockList] = struct{}{}
  35619. }
  35620. // BlockListCleared returns if the "block_list" field was cleared in this mutation.
  35621. func (m *WhatsappMutation) BlockListCleared() bool {
  35622. _, ok := m.clearedFields[whatsapp.FieldBlockList]
  35623. return ok
  35624. }
  35625. // ResetBlockList resets all changes to the "block_list" field.
  35626. func (m *WhatsappMutation) ResetBlockList() {
  35627. m.block_list = nil
  35628. m.appendblock_list = nil
  35629. delete(m.clearedFields, whatsapp.FieldBlockList)
  35630. }
  35631. // SetGroupBlockList sets the "group_block_list" field.
  35632. func (m *WhatsappMutation) SetGroupBlockList(s []string) {
  35633. m.group_block_list = &s
  35634. m.appendgroup_block_list = nil
  35635. }
  35636. // GroupBlockList returns the value of the "group_block_list" field in the mutation.
  35637. func (m *WhatsappMutation) GroupBlockList() (r []string, exists bool) {
  35638. v := m.group_block_list
  35639. if v == nil {
  35640. return
  35641. }
  35642. return *v, true
  35643. }
  35644. // OldGroupBlockList returns the old "group_block_list" field's value of the Whatsapp entity.
  35645. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35646. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35647. func (m *WhatsappMutation) OldGroupBlockList(ctx context.Context) (v []string, err error) {
  35648. if !m.op.Is(OpUpdateOne) {
  35649. return v, errors.New("OldGroupBlockList is only allowed on UpdateOne operations")
  35650. }
  35651. if m.id == nil || m.oldValue == nil {
  35652. return v, errors.New("OldGroupBlockList requires an ID field in the mutation")
  35653. }
  35654. oldValue, err := m.oldValue(ctx)
  35655. if err != nil {
  35656. return v, fmt.Errorf("querying old value for OldGroupBlockList: %w", err)
  35657. }
  35658. return oldValue.GroupBlockList, nil
  35659. }
  35660. // AppendGroupBlockList adds s to the "group_block_list" field.
  35661. func (m *WhatsappMutation) AppendGroupBlockList(s []string) {
  35662. m.appendgroup_block_list = append(m.appendgroup_block_list, s...)
  35663. }
  35664. // AppendedGroupBlockList returns the list of values that were appended to the "group_block_list" field in this mutation.
  35665. func (m *WhatsappMutation) AppendedGroupBlockList() ([]string, bool) {
  35666. if len(m.appendgroup_block_list) == 0 {
  35667. return nil, false
  35668. }
  35669. return m.appendgroup_block_list, true
  35670. }
  35671. // ClearGroupBlockList clears the value of the "group_block_list" field.
  35672. func (m *WhatsappMutation) ClearGroupBlockList() {
  35673. m.group_block_list = nil
  35674. m.appendgroup_block_list = nil
  35675. m.clearedFields[whatsapp.FieldGroupBlockList] = struct{}{}
  35676. }
  35677. // GroupBlockListCleared returns if the "group_block_list" field was cleared in this mutation.
  35678. func (m *WhatsappMutation) GroupBlockListCleared() bool {
  35679. _, ok := m.clearedFields[whatsapp.FieldGroupBlockList]
  35680. return ok
  35681. }
  35682. // ResetGroupBlockList resets all changes to the "group_block_list" field.
  35683. func (m *WhatsappMutation) ResetGroupBlockList() {
  35684. m.group_block_list = nil
  35685. m.appendgroup_block_list = nil
  35686. delete(m.clearedFields, whatsapp.FieldGroupBlockList)
  35687. }
  35688. // ClearAgent clears the "agent" edge to the Agent entity.
  35689. func (m *WhatsappMutation) ClearAgent() {
  35690. m.clearedagent = true
  35691. m.clearedFields[whatsapp.FieldAgentID] = struct{}{}
  35692. }
  35693. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  35694. func (m *WhatsappMutation) AgentCleared() bool {
  35695. return m.clearedagent
  35696. }
  35697. // AgentIDs returns the "agent" edge IDs in the mutation.
  35698. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  35699. // AgentID instead. It exists only for internal usage by the builders.
  35700. func (m *WhatsappMutation) AgentIDs() (ids []uint64) {
  35701. if id := m.agent; id != nil {
  35702. ids = append(ids, *id)
  35703. }
  35704. return
  35705. }
  35706. // ResetAgent resets all changes to the "agent" edge.
  35707. func (m *WhatsappMutation) ResetAgent() {
  35708. m.agent = nil
  35709. m.clearedagent = false
  35710. }
  35711. // Where appends a list predicates to the WhatsappMutation builder.
  35712. func (m *WhatsappMutation) Where(ps ...predicate.Whatsapp) {
  35713. m.predicates = append(m.predicates, ps...)
  35714. }
  35715. // WhereP appends storage-level predicates to the WhatsappMutation builder. Using this method,
  35716. // users can use type-assertion to append predicates that do not depend on any generated package.
  35717. func (m *WhatsappMutation) WhereP(ps ...func(*sql.Selector)) {
  35718. p := make([]predicate.Whatsapp, len(ps))
  35719. for i := range ps {
  35720. p[i] = ps[i]
  35721. }
  35722. m.Where(p...)
  35723. }
  35724. // Op returns the operation name.
  35725. func (m *WhatsappMutation) Op() Op {
  35726. return m.op
  35727. }
  35728. // SetOp allows setting the mutation operation.
  35729. func (m *WhatsappMutation) SetOp(op Op) {
  35730. m.op = op
  35731. }
  35732. // Type returns the node type of this mutation (Whatsapp).
  35733. func (m *WhatsappMutation) Type() string {
  35734. return m.typ
  35735. }
  35736. // Fields returns all fields that were changed during this mutation. Note that in
  35737. // order to get all numeric fields that were incremented/decremented, call
  35738. // AddedFields().
  35739. func (m *WhatsappMutation) Fields() []string {
  35740. fields := make([]string, 0, 21)
  35741. if m.created_at != nil {
  35742. fields = append(fields, whatsapp.FieldCreatedAt)
  35743. }
  35744. if m.updated_at != nil {
  35745. fields = append(fields, whatsapp.FieldUpdatedAt)
  35746. }
  35747. if m.status != nil {
  35748. fields = append(fields, whatsapp.FieldStatus)
  35749. }
  35750. if m.deleted_at != nil {
  35751. fields = append(fields, whatsapp.FieldDeletedAt)
  35752. }
  35753. if m.wa_id != nil {
  35754. fields = append(fields, whatsapp.FieldWaID)
  35755. }
  35756. if m.wa_name != nil {
  35757. fields = append(fields, whatsapp.FieldWaName)
  35758. }
  35759. if m.callback != nil {
  35760. fields = append(fields, whatsapp.FieldCallback)
  35761. }
  35762. if m.agent != nil {
  35763. fields = append(fields, whatsapp.FieldAgentID)
  35764. }
  35765. if m.account != nil {
  35766. fields = append(fields, whatsapp.FieldAccount)
  35767. }
  35768. if m.cc != nil {
  35769. fields = append(fields, whatsapp.FieldCc)
  35770. }
  35771. if m.phone != nil {
  35772. fields = append(fields, whatsapp.FieldPhone)
  35773. }
  35774. if m.cc_phone != nil {
  35775. fields = append(fields, whatsapp.FieldCcPhone)
  35776. }
  35777. if m.phone_name != nil {
  35778. fields = append(fields, whatsapp.FieldPhoneName)
  35779. }
  35780. if m.phone_status != nil {
  35781. fields = append(fields, whatsapp.FieldPhoneStatus)
  35782. }
  35783. if m.organization_id != nil {
  35784. fields = append(fields, whatsapp.FieldOrganizationID)
  35785. }
  35786. if m.api_base != nil {
  35787. fields = append(fields, whatsapp.FieldAPIBase)
  35788. }
  35789. if m.api_key != nil {
  35790. fields = append(fields, whatsapp.FieldAPIKey)
  35791. }
  35792. if m.allow_list != nil {
  35793. fields = append(fields, whatsapp.FieldAllowList)
  35794. }
  35795. if m.group_allow_list != nil {
  35796. fields = append(fields, whatsapp.FieldGroupAllowList)
  35797. }
  35798. if m.block_list != nil {
  35799. fields = append(fields, whatsapp.FieldBlockList)
  35800. }
  35801. if m.group_block_list != nil {
  35802. fields = append(fields, whatsapp.FieldGroupBlockList)
  35803. }
  35804. return fields
  35805. }
  35806. // Field returns the value of a field with the given name. The second boolean
  35807. // return value indicates that this field was not set, or was not defined in the
  35808. // schema.
  35809. func (m *WhatsappMutation) Field(name string) (ent.Value, bool) {
  35810. switch name {
  35811. case whatsapp.FieldCreatedAt:
  35812. return m.CreatedAt()
  35813. case whatsapp.FieldUpdatedAt:
  35814. return m.UpdatedAt()
  35815. case whatsapp.FieldStatus:
  35816. return m.Status()
  35817. case whatsapp.FieldDeletedAt:
  35818. return m.DeletedAt()
  35819. case whatsapp.FieldWaID:
  35820. return m.WaID()
  35821. case whatsapp.FieldWaName:
  35822. return m.WaName()
  35823. case whatsapp.FieldCallback:
  35824. return m.Callback()
  35825. case whatsapp.FieldAgentID:
  35826. return m.AgentID()
  35827. case whatsapp.FieldAccount:
  35828. return m.Account()
  35829. case whatsapp.FieldCc:
  35830. return m.Cc()
  35831. case whatsapp.FieldPhone:
  35832. return m.Phone()
  35833. case whatsapp.FieldCcPhone:
  35834. return m.CcPhone()
  35835. case whatsapp.FieldPhoneName:
  35836. return m.PhoneName()
  35837. case whatsapp.FieldPhoneStatus:
  35838. return m.PhoneStatus()
  35839. case whatsapp.FieldOrganizationID:
  35840. return m.OrganizationID()
  35841. case whatsapp.FieldAPIBase:
  35842. return m.APIBase()
  35843. case whatsapp.FieldAPIKey:
  35844. return m.APIKey()
  35845. case whatsapp.FieldAllowList:
  35846. return m.AllowList()
  35847. case whatsapp.FieldGroupAllowList:
  35848. return m.GroupAllowList()
  35849. case whatsapp.FieldBlockList:
  35850. return m.BlockList()
  35851. case whatsapp.FieldGroupBlockList:
  35852. return m.GroupBlockList()
  35853. }
  35854. return nil, false
  35855. }
  35856. // OldField returns the old value of the field from the database. An error is
  35857. // returned if the mutation operation is not UpdateOne, or the query to the
  35858. // database failed.
  35859. func (m *WhatsappMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  35860. switch name {
  35861. case whatsapp.FieldCreatedAt:
  35862. return m.OldCreatedAt(ctx)
  35863. case whatsapp.FieldUpdatedAt:
  35864. return m.OldUpdatedAt(ctx)
  35865. case whatsapp.FieldStatus:
  35866. return m.OldStatus(ctx)
  35867. case whatsapp.FieldDeletedAt:
  35868. return m.OldDeletedAt(ctx)
  35869. case whatsapp.FieldWaID:
  35870. return m.OldWaID(ctx)
  35871. case whatsapp.FieldWaName:
  35872. return m.OldWaName(ctx)
  35873. case whatsapp.FieldCallback:
  35874. return m.OldCallback(ctx)
  35875. case whatsapp.FieldAgentID:
  35876. return m.OldAgentID(ctx)
  35877. case whatsapp.FieldAccount:
  35878. return m.OldAccount(ctx)
  35879. case whatsapp.FieldCc:
  35880. return m.OldCc(ctx)
  35881. case whatsapp.FieldPhone:
  35882. return m.OldPhone(ctx)
  35883. case whatsapp.FieldCcPhone:
  35884. return m.OldCcPhone(ctx)
  35885. case whatsapp.FieldPhoneName:
  35886. return m.OldPhoneName(ctx)
  35887. case whatsapp.FieldPhoneStatus:
  35888. return m.OldPhoneStatus(ctx)
  35889. case whatsapp.FieldOrganizationID:
  35890. return m.OldOrganizationID(ctx)
  35891. case whatsapp.FieldAPIBase:
  35892. return m.OldAPIBase(ctx)
  35893. case whatsapp.FieldAPIKey:
  35894. return m.OldAPIKey(ctx)
  35895. case whatsapp.FieldAllowList:
  35896. return m.OldAllowList(ctx)
  35897. case whatsapp.FieldGroupAllowList:
  35898. return m.OldGroupAllowList(ctx)
  35899. case whatsapp.FieldBlockList:
  35900. return m.OldBlockList(ctx)
  35901. case whatsapp.FieldGroupBlockList:
  35902. return m.OldGroupBlockList(ctx)
  35903. }
  35904. return nil, fmt.Errorf("unknown Whatsapp field %s", name)
  35905. }
  35906. // SetField sets the value of a field with the given name. It returns an error if
  35907. // the field is not defined in the schema, or if the type mismatched the field
  35908. // type.
  35909. func (m *WhatsappMutation) SetField(name string, value ent.Value) error {
  35910. switch name {
  35911. case whatsapp.FieldCreatedAt:
  35912. v, ok := value.(time.Time)
  35913. if !ok {
  35914. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35915. }
  35916. m.SetCreatedAt(v)
  35917. return nil
  35918. case whatsapp.FieldUpdatedAt:
  35919. v, ok := value.(time.Time)
  35920. if !ok {
  35921. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35922. }
  35923. m.SetUpdatedAt(v)
  35924. return nil
  35925. case whatsapp.FieldStatus:
  35926. v, ok := value.(uint8)
  35927. if !ok {
  35928. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35929. }
  35930. m.SetStatus(v)
  35931. return nil
  35932. case whatsapp.FieldDeletedAt:
  35933. v, ok := value.(time.Time)
  35934. if !ok {
  35935. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35936. }
  35937. m.SetDeletedAt(v)
  35938. return nil
  35939. case whatsapp.FieldWaID:
  35940. v, ok := value.(string)
  35941. if !ok {
  35942. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35943. }
  35944. m.SetWaID(v)
  35945. return nil
  35946. case whatsapp.FieldWaName:
  35947. v, ok := value.(string)
  35948. if !ok {
  35949. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35950. }
  35951. m.SetWaName(v)
  35952. return nil
  35953. case whatsapp.FieldCallback:
  35954. v, ok := value.(string)
  35955. if !ok {
  35956. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35957. }
  35958. m.SetCallback(v)
  35959. return nil
  35960. case whatsapp.FieldAgentID:
  35961. v, ok := value.(uint64)
  35962. if !ok {
  35963. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35964. }
  35965. m.SetAgentID(v)
  35966. return nil
  35967. case whatsapp.FieldAccount:
  35968. v, ok := value.(string)
  35969. if !ok {
  35970. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35971. }
  35972. m.SetAccount(v)
  35973. return nil
  35974. case whatsapp.FieldCc:
  35975. v, ok := value.(string)
  35976. if !ok {
  35977. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35978. }
  35979. m.SetCc(v)
  35980. return nil
  35981. case whatsapp.FieldPhone:
  35982. v, ok := value.(string)
  35983. if !ok {
  35984. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35985. }
  35986. m.SetPhone(v)
  35987. return nil
  35988. case whatsapp.FieldCcPhone:
  35989. v, ok := value.(string)
  35990. if !ok {
  35991. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35992. }
  35993. m.SetCcPhone(v)
  35994. return nil
  35995. case whatsapp.FieldPhoneName:
  35996. v, ok := value.(string)
  35997. if !ok {
  35998. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35999. }
  36000. m.SetPhoneName(v)
  36001. return nil
  36002. case whatsapp.FieldPhoneStatus:
  36003. v, ok := value.(int8)
  36004. if !ok {
  36005. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36006. }
  36007. m.SetPhoneStatus(v)
  36008. return nil
  36009. case whatsapp.FieldOrganizationID:
  36010. v, ok := value.(uint64)
  36011. if !ok {
  36012. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36013. }
  36014. m.SetOrganizationID(v)
  36015. return nil
  36016. case whatsapp.FieldAPIBase:
  36017. v, ok := value.(string)
  36018. if !ok {
  36019. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36020. }
  36021. m.SetAPIBase(v)
  36022. return nil
  36023. case whatsapp.FieldAPIKey:
  36024. v, ok := value.(string)
  36025. if !ok {
  36026. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36027. }
  36028. m.SetAPIKey(v)
  36029. return nil
  36030. case whatsapp.FieldAllowList:
  36031. v, ok := value.([]string)
  36032. if !ok {
  36033. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36034. }
  36035. m.SetAllowList(v)
  36036. return nil
  36037. case whatsapp.FieldGroupAllowList:
  36038. v, ok := value.([]string)
  36039. if !ok {
  36040. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36041. }
  36042. m.SetGroupAllowList(v)
  36043. return nil
  36044. case whatsapp.FieldBlockList:
  36045. v, ok := value.([]string)
  36046. if !ok {
  36047. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36048. }
  36049. m.SetBlockList(v)
  36050. return nil
  36051. case whatsapp.FieldGroupBlockList:
  36052. v, ok := value.([]string)
  36053. if !ok {
  36054. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36055. }
  36056. m.SetGroupBlockList(v)
  36057. return nil
  36058. }
  36059. return fmt.Errorf("unknown Whatsapp field %s", name)
  36060. }
  36061. // AddedFields returns all numeric fields that were incremented/decremented during
  36062. // this mutation.
  36063. func (m *WhatsappMutation) AddedFields() []string {
  36064. var fields []string
  36065. if m.addstatus != nil {
  36066. fields = append(fields, whatsapp.FieldStatus)
  36067. }
  36068. if m.addphone_status != nil {
  36069. fields = append(fields, whatsapp.FieldPhoneStatus)
  36070. }
  36071. if m.addorganization_id != nil {
  36072. fields = append(fields, whatsapp.FieldOrganizationID)
  36073. }
  36074. return fields
  36075. }
  36076. // AddedField returns the numeric value that was incremented/decremented on a field
  36077. // with the given name. The second boolean return value indicates that this field
  36078. // was not set, or was not defined in the schema.
  36079. func (m *WhatsappMutation) AddedField(name string) (ent.Value, bool) {
  36080. switch name {
  36081. case whatsapp.FieldStatus:
  36082. return m.AddedStatus()
  36083. case whatsapp.FieldPhoneStatus:
  36084. return m.AddedPhoneStatus()
  36085. case whatsapp.FieldOrganizationID:
  36086. return m.AddedOrganizationID()
  36087. }
  36088. return nil, false
  36089. }
  36090. // AddField adds the value to the field with the given name. It returns an error if
  36091. // the field is not defined in the schema, or if the type mismatched the field
  36092. // type.
  36093. func (m *WhatsappMutation) AddField(name string, value ent.Value) error {
  36094. switch name {
  36095. case whatsapp.FieldStatus:
  36096. v, ok := value.(int8)
  36097. if !ok {
  36098. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36099. }
  36100. m.AddStatus(v)
  36101. return nil
  36102. case whatsapp.FieldPhoneStatus:
  36103. v, ok := value.(int8)
  36104. if !ok {
  36105. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36106. }
  36107. m.AddPhoneStatus(v)
  36108. return nil
  36109. case whatsapp.FieldOrganizationID:
  36110. v, ok := value.(int64)
  36111. if !ok {
  36112. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36113. }
  36114. m.AddOrganizationID(v)
  36115. return nil
  36116. }
  36117. return fmt.Errorf("unknown Whatsapp numeric field %s", name)
  36118. }
  36119. // ClearedFields returns all nullable fields that were cleared during this
  36120. // mutation.
  36121. func (m *WhatsappMutation) ClearedFields() []string {
  36122. var fields []string
  36123. if m.FieldCleared(whatsapp.FieldStatus) {
  36124. fields = append(fields, whatsapp.FieldStatus)
  36125. }
  36126. if m.FieldCleared(whatsapp.FieldDeletedAt) {
  36127. fields = append(fields, whatsapp.FieldDeletedAt)
  36128. }
  36129. if m.FieldCleared(whatsapp.FieldWaID) {
  36130. fields = append(fields, whatsapp.FieldWaID)
  36131. }
  36132. if m.FieldCleared(whatsapp.FieldWaName) {
  36133. fields = append(fields, whatsapp.FieldWaName)
  36134. }
  36135. if m.FieldCleared(whatsapp.FieldCallback) {
  36136. fields = append(fields, whatsapp.FieldCallback)
  36137. }
  36138. if m.FieldCleared(whatsapp.FieldAccount) {
  36139. fields = append(fields, whatsapp.FieldAccount)
  36140. }
  36141. if m.FieldCleared(whatsapp.FieldOrganizationID) {
  36142. fields = append(fields, whatsapp.FieldOrganizationID)
  36143. }
  36144. if m.FieldCleared(whatsapp.FieldAPIBase) {
  36145. fields = append(fields, whatsapp.FieldAPIBase)
  36146. }
  36147. if m.FieldCleared(whatsapp.FieldAPIKey) {
  36148. fields = append(fields, whatsapp.FieldAPIKey)
  36149. }
  36150. if m.FieldCleared(whatsapp.FieldAllowList) {
  36151. fields = append(fields, whatsapp.FieldAllowList)
  36152. }
  36153. if m.FieldCleared(whatsapp.FieldGroupAllowList) {
  36154. fields = append(fields, whatsapp.FieldGroupAllowList)
  36155. }
  36156. if m.FieldCleared(whatsapp.FieldBlockList) {
  36157. fields = append(fields, whatsapp.FieldBlockList)
  36158. }
  36159. if m.FieldCleared(whatsapp.FieldGroupBlockList) {
  36160. fields = append(fields, whatsapp.FieldGroupBlockList)
  36161. }
  36162. return fields
  36163. }
  36164. // FieldCleared returns a boolean indicating if a field with the given name was
  36165. // cleared in this mutation.
  36166. func (m *WhatsappMutation) FieldCleared(name string) bool {
  36167. _, ok := m.clearedFields[name]
  36168. return ok
  36169. }
  36170. // ClearField clears the value of the field with the given name. It returns an
  36171. // error if the field is not defined in the schema.
  36172. func (m *WhatsappMutation) ClearField(name string) error {
  36173. switch name {
  36174. case whatsapp.FieldStatus:
  36175. m.ClearStatus()
  36176. return nil
  36177. case whatsapp.FieldDeletedAt:
  36178. m.ClearDeletedAt()
  36179. return nil
  36180. case whatsapp.FieldWaID:
  36181. m.ClearWaID()
  36182. return nil
  36183. case whatsapp.FieldWaName:
  36184. m.ClearWaName()
  36185. return nil
  36186. case whatsapp.FieldCallback:
  36187. m.ClearCallback()
  36188. return nil
  36189. case whatsapp.FieldAccount:
  36190. m.ClearAccount()
  36191. return nil
  36192. case whatsapp.FieldOrganizationID:
  36193. m.ClearOrganizationID()
  36194. return nil
  36195. case whatsapp.FieldAPIBase:
  36196. m.ClearAPIBase()
  36197. return nil
  36198. case whatsapp.FieldAPIKey:
  36199. m.ClearAPIKey()
  36200. return nil
  36201. case whatsapp.FieldAllowList:
  36202. m.ClearAllowList()
  36203. return nil
  36204. case whatsapp.FieldGroupAllowList:
  36205. m.ClearGroupAllowList()
  36206. return nil
  36207. case whatsapp.FieldBlockList:
  36208. m.ClearBlockList()
  36209. return nil
  36210. case whatsapp.FieldGroupBlockList:
  36211. m.ClearGroupBlockList()
  36212. return nil
  36213. }
  36214. return fmt.Errorf("unknown Whatsapp nullable field %s", name)
  36215. }
  36216. // ResetField resets all changes in the mutation for the field with the given name.
  36217. // It returns an error if the field is not defined in the schema.
  36218. func (m *WhatsappMutation) ResetField(name string) error {
  36219. switch name {
  36220. case whatsapp.FieldCreatedAt:
  36221. m.ResetCreatedAt()
  36222. return nil
  36223. case whatsapp.FieldUpdatedAt:
  36224. m.ResetUpdatedAt()
  36225. return nil
  36226. case whatsapp.FieldStatus:
  36227. m.ResetStatus()
  36228. return nil
  36229. case whatsapp.FieldDeletedAt:
  36230. m.ResetDeletedAt()
  36231. return nil
  36232. case whatsapp.FieldWaID:
  36233. m.ResetWaID()
  36234. return nil
  36235. case whatsapp.FieldWaName:
  36236. m.ResetWaName()
  36237. return nil
  36238. case whatsapp.FieldCallback:
  36239. m.ResetCallback()
  36240. return nil
  36241. case whatsapp.FieldAgentID:
  36242. m.ResetAgentID()
  36243. return nil
  36244. case whatsapp.FieldAccount:
  36245. m.ResetAccount()
  36246. return nil
  36247. case whatsapp.FieldCc:
  36248. m.ResetCc()
  36249. return nil
  36250. case whatsapp.FieldPhone:
  36251. m.ResetPhone()
  36252. return nil
  36253. case whatsapp.FieldCcPhone:
  36254. m.ResetCcPhone()
  36255. return nil
  36256. case whatsapp.FieldPhoneName:
  36257. m.ResetPhoneName()
  36258. return nil
  36259. case whatsapp.FieldPhoneStatus:
  36260. m.ResetPhoneStatus()
  36261. return nil
  36262. case whatsapp.FieldOrganizationID:
  36263. m.ResetOrganizationID()
  36264. return nil
  36265. case whatsapp.FieldAPIBase:
  36266. m.ResetAPIBase()
  36267. return nil
  36268. case whatsapp.FieldAPIKey:
  36269. m.ResetAPIKey()
  36270. return nil
  36271. case whatsapp.FieldAllowList:
  36272. m.ResetAllowList()
  36273. return nil
  36274. case whatsapp.FieldGroupAllowList:
  36275. m.ResetGroupAllowList()
  36276. return nil
  36277. case whatsapp.FieldBlockList:
  36278. m.ResetBlockList()
  36279. return nil
  36280. case whatsapp.FieldGroupBlockList:
  36281. m.ResetGroupBlockList()
  36282. return nil
  36283. }
  36284. return fmt.Errorf("unknown Whatsapp field %s", name)
  36285. }
  36286. // AddedEdges returns all edge names that were set/added in this mutation.
  36287. func (m *WhatsappMutation) AddedEdges() []string {
  36288. edges := make([]string, 0, 1)
  36289. if m.agent != nil {
  36290. edges = append(edges, whatsapp.EdgeAgent)
  36291. }
  36292. return edges
  36293. }
  36294. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  36295. // name in this mutation.
  36296. func (m *WhatsappMutation) AddedIDs(name string) []ent.Value {
  36297. switch name {
  36298. case whatsapp.EdgeAgent:
  36299. if id := m.agent; id != nil {
  36300. return []ent.Value{*id}
  36301. }
  36302. }
  36303. return nil
  36304. }
  36305. // RemovedEdges returns all edge names that were removed in this mutation.
  36306. func (m *WhatsappMutation) RemovedEdges() []string {
  36307. edges := make([]string, 0, 1)
  36308. return edges
  36309. }
  36310. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  36311. // the given name in this mutation.
  36312. func (m *WhatsappMutation) RemovedIDs(name string) []ent.Value {
  36313. return nil
  36314. }
  36315. // ClearedEdges returns all edge names that were cleared in this mutation.
  36316. func (m *WhatsappMutation) ClearedEdges() []string {
  36317. edges := make([]string, 0, 1)
  36318. if m.clearedagent {
  36319. edges = append(edges, whatsapp.EdgeAgent)
  36320. }
  36321. return edges
  36322. }
  36323. // EdgeCleared returns a boolean which indicates if the edge with the given name
  36324. // was cleared in this mutation.
  36325. func (m *WhatsappMutation) EdgeCleared(name string) bool {
  36326. switch name {
  36327. case whatsapp.EdgeAgent:
  36328. return m.clearedagent
  36329. }
  36330. return false
  36331. }
  36332. // ClearEdge clears the value of the edge with the given name. It returns an error
  36333. // if that edge is not defined in the schema.
  36334. func (m *WhatsappMutation) ClearEdge(name string) error {
  36335. switch name {
  36336. case whatsapp.EdgeAgent:
  36337. m.ClearAgent()
  36338. return nil
  36339. }
  36340. return fmt.Errorf("unknown Whatsapp unique edge %s", name)
  36341. }
  36342. // ResetEdge resets all changes to the edge with the given name in this mutation.
  36343. // It returns an error if the edge is not defined in the schema.
  36344. func (m *WhatsappMutation) ResetEdge(name string) error {
  36345. switch name {
  36346. case whatsapp.EdgeAgent:
  36347. m.ResetAgent()
  36348. return nil
  36349. }
  36350. return fmt.Errorf("unknown Whatsapp edge %s", name)
  36351. }
  36352. // WhatsappChannelMutation represents an operation that mutates the WhatsappChannel nodes in the graph.
  36353. type WhatsappChannelMutation struct {
  36354. config
  36355. op Op
  36356. typ string
  36357. id *uint64
  36358. created_at *time.Time
  36359. updated_at *time.Time
  36360. status *uint8
  36361. addstatus *int8
  36362. deleted_at *time.Time
  36363. ak *string
  36364. sk *string
  36365. wa_id *string
  36366. wa_name *string
  36367. waba_id *uint64
  36368. addwaba_id *int64
  36369. business_id *uint64
  36370. addbusiness_id *int64
  36371. organization_id *uint64
  36372. addorganization_id *int64
  36373. verify_account *string
  36374. clearedFields map[string]struct{}
  36375. done bool
  36376. oldValue func(context.Context) (*WhatsappChannel, error)
  36377. predicates []predicate.WhatsappChannel
  36378. }
  36379. var _ ent.Mutation = (*WhatsappChannelMutation)(nil)
  36380. // whatsappchannelOption allows management of the mutation configuration using functional options.
  36381. type whatsappchannelOption func(*WhatsappChannelMutation)
  36382. // newWhatsappChannelMutation creates new mutation for the WhatsappChannel entity.
  36383. func newWhatsappChannelMutation(c config, op Op, opts ...whatsappchannelOption) *WhatsappChannelMutation {
  36384. m := &WhatsappChannelMutation{
  36385. config: c,
  36386. op: op,
  36387. typ: TypeWhatsappChannel,
  36388. clearedFields: make(map[string]struct{}),
  36389. }
  36390. for _, opt := range opts {
  36391. opt(m)
  36392. }
  36393. return m
  36394. }
  36395. // withWhatsappChannelID sets the ID field of the mutation.
  36396. func withWhatsappChannelID(id uint64) whatsappchannelOption {
  36397. return func(m *WhatsappChannelMutation) {
  36398. var (
  36399. err error
  36400. once sync.Once
  36401. value *WhatsappChannel
  36402. )
  36403. m.oldValue = func(ctx context.Context) (*WhatsappChannel, error) {
  36404. once.Do(func() {
  36405. if m.done {
  36406. err = errors.New("querying old values post mutation is not allowed")
  36407. } else {
  36408. value, err = m.Client().WhatsappChannel.Get(ctx, id)
  36409. }
  36410. })
  36411. return value, err
  36412. }
  36413. m.id = &id
  36414. }
  36415. }
  36416. // withWhatsappChannel sets the old WhatsappChannel of the mutation.
  36417. func withWhatsappChannel(node *WhatsappChannel) whatsappchannelOption {
  36418. return func(m *WhatsappChannelMutation) {
  36419. m.oldValue = func(context.Context) (*WhatsappChannel, error) {
  36420. return node, nil
  36421. }
  36422. m.id = &node.ID
  36423. }
  36424. }
  36425. // Client returns a new `ent.Client` from the mutation. If the mutation was
  36426. // executed in a transaction (ent.Tx), a transactional client is returned.
  36427. func (m WhatsappChannelMutation) Client() *Client {
  36428. client := &Client{config: m.config}
  36429. client.init()
  36430. return client
  36431. }
  36432. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  36433. // it returns an error otherwise.
  36434. func (m WhatsappChannelMutation) Tx() (*Tx, error) {
  36435. if _, ok := m.driver.(*txDriver); !ok {
  36436. return nil, errors.New("ent: mutation is not running in a transaction")
  36437. }
  36438. tx := &Tx{config: m.config}
  36439. tx.init()
  36440. return tx, nil
  36441. }
  36442. // SetID sets the value of the id field. Note that this
  36443. // operation is only accepted on creation of WhatsappChannel entities.
  36444. func (m *WhatsappChannelMutation) SetID(id uint64) {
  36445. m.id = &id
  36446. }
  36447. // ID returns the ID value in the mutation. Note that the ID is only available
  36448. // if it was provided to the builder or after it was returned from the database.
  36449. func (m *WhatsappChannelMutation) ID() (id uint64, exists bool) {
  36450. if m.id == nil {
  36451. return
  36452. }
  36453. return *m.id, true
  36454. }
  36455. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  36456. // That means, if the mutation is applied within a transaction with an isolation level such
  36457. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  36458. // or updated by the mutation.
  36459. func (m *WhatsappChannelMutation) IDs(ctx context.Context) ([]uint64, error) {
  36460. switch {
  36461. case m.op.Is(OpUpdateOne | OpDeleteOne):
  36462. id, exists := m.ID()
  36463. if exists {
  36464. return []uint64{id}, nil
  36465. }
  36466. fallthrough
  36467. case m.op.Is(OpUpdate | OpDelete):
  36468. return m.Client().WhatsappChannel.Query().Where(m.predicates...).IDs(ctx)
  36469. default:
  36470. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  36471. }
  36472. }
  36473. // SetCreatedAt sets the "created_at" field.
  36474. func (m *WhatsappChannelMutation) SetCreatedAt(t time.Time) {
  36475. m.created_at = &t
  36476. }
  36477. // CreatedAt returns the value of the "created_at" field in the mutation.
  36478. func (m *WhatsappChannelMutation) CreatedAt() (r time.Time, exists bool) {
  36479. v := m.created_at
  36480. if v == nil {
  36481. return
  36482. }
  36483. return *v, true
  36484. }
  36485. // OldCreatedAt returns the old "created_at" field's value of the WhatsappChannel entity.
  36486. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  36487. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36488. func (m *WhatsappChannelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  36489. if !m.op.Is(OpUpdateOne) {
  36490. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  36491. }
  36492. if m.id == nil || m.oldValue == nil {
  36493. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  36494. }
  36495. oldValue, err := m.oldValue(ctx)
  36496. if err != nil {
  36497. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  36498. }
  36499. return oldValue.CreatedAt, nil
  36500. }
  36501. // ResetCreatedAt resets all changes to the "created_at" field.
  36502. func (m *WhatsappChannelMutation) ResetCreatedAt() {
  36503. m.created_at = nil
  36504. }
  36505. // SetUpdatedAt sets the "updated_at" field.
  36506. func (m *WhatsappChannelMutation) SetUpdatedAt(t time.Time) {
  36507. m.updated_at = &t
  36508. }
  36509. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  36510. func (m *WhatsappChannelMutation) UpdatedAt() (r time.Time, exists bool) {
  36511. v := m.updated_at
  36512. if v == nil {
  36513. return
  36514. }
  36515. return *v, true
  36516. }
  36517. // OldUpdatedAt returns the old "updated_at" field's value of the WhatsappChannel entity.
  36518. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  36519. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36520. func (m *WhatsappChannelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  36521. if !m.op.Is(OpUpdateOne) {
  36522. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  36523. }
  36524. if m.id == nil || m.oldValue == nil {
  36525. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  36526. }
  36527. oldValue, err := m.oldValue(ctx)
  36528. if err != nil {
  36529. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  36530. }
  36531. return oldValue.UpdatedAt, nil
  36532. }
  36533. // ResetUpdatedAt resets all changes to the "updated_at" field.
  36534. func (m *WhatsappChannelMutation) ResetUpdatedAt() {
  36535. m.updated_at = nil
  36536. }
  36537. // SetStatus sets the "status" field.
  36538. func (m *WhatsappChannelMutation) SetStatus(u uint8) {
  36539. m.status = &u
  36540. m.addstatus = nil
  36541. }
  36542. // Status returns the value of the "status" field in the mutation.
  36543. func (m *WhatsappChannelMutation) Status() (r uint8, exists bool) {
  36544. v := m.status
  36545. if v == nil {
  36546. return
  36547. }
  36548. return *v, true
  36549. }
  36550. // OldStatus returns the old "status" field's value of the WhatsappChannel entity.
  36551. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  36552. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36553. func (m *WhatsappChannelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  36554. if !m.op.Is(OpUpdateOne) {
  36555. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  36556. }
  36557. if m.id == nil || m.oldValue == nil {
  36558. return v, errors.New("OldStatus requires an ID field in the mutation")
  36559. }
  36560. oldValue, err := m.oldValue(ctx)
  36561. if err != nil {
  36562. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  36563. }
  36564. return oldValue.Status, nil
  36565. }
  36566. // AddStatus adds u to the "status" field.
  36567. func (m *WhatsappChannelMutation) AddStatus(u int8) {
  36568. if m.addstatus != nil {
  36569. *m.addstatus += u
  36570. } else {
  36571. m.addstatus = &u
  36572. }
  36573. }
  36574. // AddedStatus returns the value that was added to the "status" field in this mutation.
  36575. func (m *WhatsappChannelMutation) AddedStatus() (r int8, exists bool) {
  36576. v := m.addstatus
  36577. if v == nil {
  36578. return
  36579. }
  36580. return *v, true
  36581. }
  36582. // ClearStatus clears the value of the "status" field.
  36583. func (m *WhatsappChannelMutation) ClearStatus() {
  36584. m.status = nil
  36585. m.addstatus = nil
  36586. m.clearedFields[whatsappchannel.FieldStatus] = struct{}{}
  36587. }
  36588. // StatusCleared returns if the "status" field was cleared in this mutation.
  36589. func (m *WhatsappChannelMutation) StatusCleared() bool {
  36590. _, ok := m.clearedFields[whatsappchannel.FieldStatus]
  36591. return ok
  36592. }
  36593. // ResetStatus resets all changes to the "status" field.
  36594. func (m *WhatsappChannelMutation) ResetStatus() {
  36595. m.status = nil
  36596. m.addstatus = nil
  36597. delete(m.clearedFields, whatsappchannel.FieldStatus)
  36598. }
  36599. // SetDeletedAt sets the "deleted_at" field.
  36600. func (m *WhatsappChannelMutation) SetDeletedAt(t time.Time) {
  36601. m.deleted_at = &t
  36602. }
  36603. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  36604. func (m *WhatsappChannelMutation) DeletedAt() (r time.Time, exists bool) {
  36605. v := m.deleted_at
  36606. if v == nil {
  36607. return
  36608. }
  36609. return *v, true
  36610. }
  36611. // OldDeletedAt returns the old "deleted_at" field's value of the WhatsappChannel entity.
  36612. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  36613. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36614. func (m *WhatsappChannelMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  36615. if !m.op.Is(OpUpdateOne) {
  36616. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  36617. }
  36618. if m.id == nil || m.oldValue == nil {
  36619. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  36620. }
  36621. oldValue, err := m.oldValue(ctx)
  36622. if err != nil {
  36623. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  36624. }
  36625. return oldValue.DeletedAt, nil
  36626. }
  36627. // ClearDeletedAt clears the value of the "deleted_at" field.
  36628. func (m *WhatsappChannelMutation) ClearDeletedAt() {
  36629. m.deleted_at = nil
  36630. m.clearedFields[whatsappchannel.FieldDeletedAt] = struct{}{}
  36631. }
  36632. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  36633. func (m *WhatsappChannelMutation) DeletedAtCleared() bool {
  36634. _, ok := m.clearedFields[whatsappchannel.FieldDeletedAt]
  36635. return ok
  36636. }
  36637. // ResetDeletedAt resets all changes to the "deleted_at" field.
  36638. func (m *WhatsappChannelMutation) ResetDeletedAt() {
  36639. m.deleted_at = nil
  36640. delete(m.clearedFields, whatsappchannel.FieldDeletedAt)
  36641. }
  36642. // SetAk sets the "ak" field.
  36643. func (m *WhatsappChannelMutation) SetAk(s string) {
  36644. m.ak = &s
  36645. }
  36646. // Ak returns the value of the "ak" field in the mutation.
  36647. func (m *WhatsappChannelMutation) Ak() (r string, exists bool) {
  36648. v := m.ak
  36649. if v == nil {
  36650. return
  36651. }
  36652. return *v, true
  36653. }
  36654. // OldAk returns the old "ak" field's value of the WhatsappChannel entity.
  36655. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  36656. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36657. func (m *WhatsappChannelMutation) OldAk(ctx context.Context) (v string, err error) {
  36658. if !m.op.Is(OpUpdateOne) {
  36659. return v, errors.New("OldAk is only allowed on UpdateOne operations")
  36660. }
  36661. if m.id == nil || m.oldValue == nil {
  36662. return v, errors.New("OldAk requires an ID field in the mutation")
  36663. }
  36664. oldValue, err := m.oldValue(ctx)
  36665. if err != nil {
  36666. return v, fmt.Errorf("querying old value for OldAk: %w", err)
  36667. }
  36668. return oldValue.Ak, nil
  36669. }
  36670. // ClearAk clears the value of the "ak" field.
  36671. func (m *WhatsappChannelMutation) ClearAk() {
  36672. m.ak = nil
  36673. m.clearedFields[whatsappchannel.FieldAk] = struct{}{}
  36674. }
  36675. // AkCleared returns if the "ak" field was cleared in this mutation.
  36676. func (m *WhatsappChannelMutation) AkCleared() bool {
  36677. _, ok := m.clearedFields[whatsappchannel.FieldAk]
  36678. return ok
  36679. }
  36680. // ResetAk resets all changes to the "ak" field.
  36681. func (m *WhatsappChannelMutation) ResetAk() {
  36682. m.ak = nil
  36683. delete(m.clearedFields, whatsappchannel.FieldAk)
  36684. }
  36685. // SetSk sets the "sk" field.
  36686. func (m *WhatsappChannelMutation) SetSk(s string) {
  36687. m.sk = &s
  36688. }
  36689. // Sk returns the value of the "sk" field in the mutation.
  36690. func (m *WhatsappChannelMutation) Sk() (r string, exists bool) {
  36691. v := m.sk
  36692. if v == nil {
  36693. return
  36694. }
  36695. return *v, true
  36696. }
  36697. // OldSk returns the old "sk" field's value of the WhatsappChannel entity.
  36698. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  36699. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36700. func (m *WhatsappChannelMutation) OldSk(ctx context.Context) (v string, err error) {
  36701. if !m.op.Is(OpUpdateOne) {
  36702. return v, errors.New("OldSk is only allowed on UpdateOne operations")
  36703. }
  36704. if m.id == nil || m.oldValue == nil {
  36705. return v, errors.New("OldSk requires an ID field in the mutation")
  36706. }
  36707. oldValue, err := m.oldValue(ctx)
  36708. if err != nil {
  36709. return v, fmt.Errorf("querying old value for OldSk: %w", err)
  36710. }
  36711. return oldValue.Sk, nil
  36712. }
  36713. // ResetSk resets all changes to the "sk" field.
  36714. func (m *WhatsappChannelMutation) ResetSk() {
  36715. m.sk = nil
  36716. }
  36717. // SetWaID sets the "wa_id" field.
  36718. func (m *WhatsappChannelMutation) SetWaID(s string) {
  36719. m.wa_id = &s
  36720. }
  36721. // WaID returns the value of the "wa_id" field in the mutation.
  36722. func (m *WhatsappChannelMutation) WaID() (r string, exists bool) {
  36723. v := m.wa_id
  36724. if v == nil {
  36725. return
  36726. }
  36727. return *v, true
  36728. }
  36729. // OldWaID returns the old "wa_id" field's value of the WhatsappChannel entity.
  36730. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  36731. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36732. func (m *WhatsappChannelMutation) OldWaID(ctx context.Context) (v string, err error) {
  36733. if !m.op.Is(OpUpdateOne) {
  36734. return v, errors.New("OldWaID is only allowed on UpdateOne operations")
  36735. }
  36736. if m.id == nil || m.oldValue == nil {
  36737. return v, errors.New("OldWaID requires an ID field in the mutation")
  36738. }
  36739. oldValue, err := m.oldValue(ctx)
  36740. if err != nil {
  36741. return v, fmt.Errorf("querying old value for OldWaID: %w", err)
  36742. }
  36743. return oldValue.WaID, nil
  36744. }
  36745. // ClearWaID clears the value of the "wa_id" field.
  36746. func (m *WhatsappChannelMutation) ClearWaID() {
  36747. m.wa_id = nil
  36748. m.clearedFields[whatsappchannel.FieldWaID] = struct{}{}
  36749. }
  36750. // WaIDCleared returns if the "wa_id" field was cleared in this mutation.
  36751. func (m *WhatsappChannelMutation) WaIDCleared() bool {
  36752. _, ok := m.clearedFields[whatsappchannel.FieldWaID]
  36753. return ok
  36754. }
  36755. // ResetWaID resets all changes to the "wa_id" field.
  36756. func (m *WhatsappChannelMutation) ResetWaID() {
  36757. m.wa_id = nil
  36758. delete(m.clearedFields, whatsappchannel.FieldWaID)
  36759. }
  36760. // SetWaName sets the "wa_name" field.
  36761. func (m *WhatsappChannelMutation) SetWaName(s string) {
  36762. m.wa_name = &s
  36763. }
  36764. // WaName returns the value of the "wa_name" field in the mutation.
  36765. func (m *WhatsappChannelMutation) WaName() (r string, exists bool) {
  36766. v := m.wa_name
  36767. if v == nil {
  36768. return
  36769. }
  36770. return *v, true
  36771. }
  36772. // OldWaName returns the old "wa_name" field's value of the WhatsappChannel entity.
  36773. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  36774. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36775. func (m *WhatsappChannelMutation) OldWaName(ctx context.Context) (v string, err error) {
  36776. if !m.op.Is(OpUpdateOne) {
  36777. return v, errors.New("OldWaName is only allowed on UpdateOne operations")
  36778. }
  36779. if m.id == nil || m.oldValue == nil {
  36780. return v, errors.New("OldWaName requires an ID field in the mutation")
  36781. }
  36782. oldValue, err := m.oldValue(ctx)
  36783. if err != nil {
  36784. return v, fmt.Errorf("querying old value for OldWaName: %w", err)
  36785. }
  36786. return oldValue.WaName, nil
  36787. }
  36788. // ClearWaName clears the value of the "wa_name" field.
  36789. func (m *WhatsappChannelMutation) ClearWaName() {
  36790. m.wa_name = nil
  36791. m.clearedFields[whatsappchannel.FieldWaName] = struct{}{}
  36792. }
  36793. // WaNameCleared returns if the "wa_name" field was cleared in this mutation.
  36794. func (m *WhatsappChannelMutation) WaNameCleared() bool {
  36795. _, ok := m.clearedFields[whatsappchannel.FieldWaName]
  36796. return ok
  36797. }
  36798. // ResetWaName resets all changes to the "wa_name" field.
  36799. func (m *WhatsappChannelMutation) ResetWaName() {
  36800. m.wa_name = nil
  36801. delete(m.clearedFields, whatsappchannel.FieldWaName)
  36802. }
  36803. // SetWabaID sets the "waba_id" field.
  36804. func (m *WhatsappChannelMutation) SetWabaID(u uint64) {
  36805. m.waba_id = &u
  36806. m.addwaba_id = nil
  36807. }
  36808. // WabaID returns the value of the "waba_id" field in the mutation.
  36809. func (m *WhatsappChannelMutation) WabaID() (r uint64, exists bool) {
  36810. v := m.waba_id
  36811. if v == nil {
  36812. return
  36813. }
  36814. return *v, true
  36815. }
  36816. // OldWabaID returns the old "waba_id" field's value of the WhatsappChannel entity.
  36817. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  36818. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36819. func (m *WhatsappChannelMutation) OldWabaID(ctx context.Context) (v uint64, err error) {
  36820. if !m.op.Is(OpUpdateOne) {
  36821. return v, errors.New("OldWabaID is only allowed on UpdateOne operations")
  36822. }
  36823. if m.id == nil || m.oldValue == nil {
  36824. return v, errors.New("OldWabaID requires an ID field in the mutation")
  36825. }
  36826. oldValue, err := m.oldValue(ctx)
  36827. if err != nil {
  36828. return v, fmt.Errorf("querying old value for OldWabaID: %w", err)
  36829. }
  36830. return oldValue.WabaID, nil
  36831. }
  36832. // AddWabaID adds u to the "waba_id" field.
  36833. func (m *WhatsappChannelMutation) AddWabaID(u int64) {
  36834. if m.addwaba_id != nil {
  36835. *m.addwaba_id += u
  36836. } else {
  36837. m.addwaba_id = &u
  36838. }
  36839. }
  36840. // AddedWabaID returns the value that was added to the "waba_id" field in this mutation.
  36841. func (m *WhatsappChannelMutation) AddedWabaID() (r int64, exists bool) {
  36842. v := m.addwaba_id
  36843. if v == nil {
  36844. return
  36845. }
  36846. return *v, true
  36847. }
  36848. // ResetWabaID resets all changes to the "waba_id" field.
  36849. func (m *WhatsappChannelMutation) ResetWabaID() {
  36850. m.waba_id = nil
  36851. m.addwaba_id = nil
  36852. }
  36853. // SetBusinessID sets the "business_id" field.
  36854. func (m *WhatsappChannelMutation) SetBusinessID(u uint64) {
  36855. m.business_id = &u
  36856. m.addbusiness_id = nil
  36857. }
  36858. // BusinessID returns the value of the "business_id" field in the mutation.
  36859. func (m *WhatsappChannelMutation) BusinessID() (r uint64, exists bool) {
  36860. v := m.business_id
  36861. if v == nil {
  36862. return
  36863. }
  36864. return *v, true
  36865. }
  36866. // OldBusinessID returns the old "business_id" field's value of the WhatsappChannel entity.
  36867. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  36868. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36869. func (m *WhatsappChannelMutation) OldBusinessID(ctx context.Context) (v uint64, err error) {
  36870. if !m.op.Is(OpUpdateOne) {
  36871. return v, errors.New("OldBusinessID is only allowed on UpdateOne operations")
  36872. }
  36873. if m.id == nil || m.oldValue == nil {
  36874. return v, errors.New("OldBusinessID requires an ID field in the mutation")
  36875. }
  36876. oldValue, err := m.oldValue(ctx)
  36877. if err != nil {
  36878. return v, fmt.Errorf("querying old value for OldBusinessID: %w", err)
  36879. }
  36880. return oldValue.BusinessID, nil
  36881. }
  36882. // AddBusinessID adds u to the "business_id" field.
  36883. func (m *WhatsappChannelMutation) AddBusinessID(u int64) {
  36884. if m.addbusiness_id != nil {
  36885. *m.addbusiness_id += u
  36886. } else {
  36887. m.addbusiness_id = &u
  36888. }
  36889. }
  36890. // AddedBusinessID returns the value that was added to the "business_id" field in this mutation.
  36891. func (m *WhatsappChannelMutation) AddedBusinessID() (r int64, exists bool) {
  36892. v := m.addbusiness_id
  36893. if v == nil {
  36894. return
  36895. }
  36896. return *v, true
  36897. }
  36898. // ResetBusinessID resets all changes to the "business_id" field.
  36899. func (m *WhatsappChannelMutation) ResetBusinessID() {
  36900. m.business_id = nil
  36901. m.addbusiness_id = nil
  36902. }
  36903. // SetOrganizationID sets the "organization_id" field.
  36904. func (m *WhatsappChannelMutation) SetOrganizationID(u uint64) {
  36905. m.organization_id = &u
  36906. m.addorganization_id = nil
  36907. }
  36908. // OrganizationID returns the value of the "organization_id" field in the mutation.
  36909. func (m *WhatsappChannelMutation) OrganizationID() (r uint64, exists bool) {
  36910. v := m.organization_id
  36911. if v == nil {
  36912. return
  36913. }
  36914. return *v, true
  36915. }
  36916. // OldOrganizationID returns the old "organization_id" field's value of the WhatsappChannel entity.
  36917. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  36918. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36919. func (m *WhatsappChannelMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  36920. if !m.op.Is(OpUpdateOne) {
  36921. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  36922. }
  36923. if m.id == nil || m.oldValue == nil {
  36924. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  36925. }
  36926. oldValue, err := m.oldValue(ctx)
  36927. if err != nil {
  36928. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  36929. }
  36930. return oldValue.OrganizationID, nil
  36931. }
  36932. // AddOrganizationID adds u to the "organization_id" field.
  36933. func (m *WhatsappChannelMutation) AddOrganizationID(u int64) {
  36934. if m.addorganization_id != nil {
  36935. *m.addorganization_id += u
  36936. } else {
  36937. m.addorganization_id = &u
  36938. }
  36939. }
  36940. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  36941. func (m *WhatsappChannelMutation) AddedOrganizationID() (r int64, exists bool) {
  36942. v := m.addorganization_id
  36943. if v == nil {
  36944. return
  36945. }
  36946. return *v, true
  36947. }
  36948. // ClearOrganizationID clears the value of the "organization_id" field.
  36949. func (m *WhatsappChannelMutation) ClearOrganizationID() {
  36950. m.organization_id = nil
  36951. m.addorganization_id = nil
  36952. m.clearedFields[whatsappchannel.FieldOrganizationID] = struct{}{}
  36953. }
  36954. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  36955. func (m *WhatsappChannelMutation) OrganizationIDCleared() bool {
  36956. _, ok := m.clearedFields[whatsappchannel.FieldOrganizationID]
  36957. return ok
  36958. }
  36959. // ResetOrganizationID resets all changes to the "organization_id" field.
  36960. func (m *WhatsappChannelMutation) ResetOrganizationID() {
  36961. m.organization_id = nil
  36962. m.addorganization_id = nil
  36963. delete(m.clearedFields, whatsappchannel.FieldOrganizationID)
  36964. }
  36965. // SetVerifyAccount sets the "verify_account" field.
  36966. func (m *WhatsappChannelMutation) SetVerifyAccount(s string) {
  36967. m.verify_account = &s
  36968. }
  36969. // VerifyAccount returns the value of the "verify_account" field in the mutation.
  36970. func (m *WhatsappChannelMutation) VerifyAccount() (r string, exists bool) {
  36971. v := m.verify_account
  36972. if v == nil {
  36973. return
  36974. }
  36975. return *v, true
  36976. }
  36977. // OldVerifyAccount returns the old "verify_account" field's value of the WhatsappChannel entity.
  36978. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  36979. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36980. func (m *WhatsappChannelMutation) OldVerifyAccount(ctx context.Context) (v string, err error) {
  36981. if !m.op.Is(OpUpdateOne) {
  36982. return v, errors.New("OldVerifyAccount is only allowed on UpdateOne operations")
  36983. }
  36984. if m.id == nil || m.oldValue == nil {
  36985. return v, errors.New("OldVerifyAccount requires an ID field in the mutation")
  36986. }
  36987. oldValue, err := m.oldValue(ctx)
  36988. if err != nil {
  36989. return v, fmt.Errorf("querying old value for OldVerifyAccount: %w", err)
  36990. }
  36991. return oldValue.VerifyAccount, nil
  36992. }
  36993. // ResetVerifyAccount resets all changes to the "verify_account" field.
  36994. func (m *WhatsappChannelMutation) ResetVerifyAccount() {
  36995. m.verify_account = nil
  36996. }
  36997. // Where appends a list predicates to the WhatsappChannelMutation builder.
  36998. func (m *WhatsappChannelMutation) Where(ps ...predicate.WhatsappChannel) {
  36999. m.predicates = append(m.predicates, ps...)
  37000. }
  37001. // WhereP appends storage-level predicates to the WhatsappChannelMutation builder. Using this method,
  37002. // users can use type-assertion to append predicates that do not depend on any generated package.
  37003. func (m *WhatsappChannelMutation) WhereP(ps ...func(*sql.Selector)) {
  37004. p := make([]predicate.WhatsappChannel, len(ps))
  37005. for i := range ps {
  37006. p[i] = ps[i]
  37007. }
  37008. m.Where(p...)
  37009. }
  37010. // Op returns the operation name.
  37011. func (m *WhatsappChannelMutation) Op() Op {
  37012. return m.op
  37013. }
  37014. // SetOp allows setting the mutation operation.
  37015. func (m *WhatsappChannelMutation) SetOp(op Op) {
  37016. m.op = op
  37017. }
  37018. // Type returns the node type of this mutation (WhatsappChannel).
  37019. func (m *WhatsappChannelMutation) Type() string {
  37020. return m.typ
  37021. }
  37022. // Fields returns all fields that were changed during this mutation. Note that in
  37023. // order to get all numeric fields that were incremented/decremented, call
  37024. // AddedFields().
  37025. func (m *WhatsappChannelMutation) Fields() []string {
  37026. fields := make([]string, 0, 12)
  37027. if m.created_at != nil {
  37028. fields = append(fields, whatsappchannel.FieldCreatedAt)
  37029. }
  37030. if m.updated_at != nil {
  37031. fields = append(fields, whatsappchannel.FieldUpdatedAt)
  37032. }
  37033. if m.status != nil {
  37034. fields = append(fields, whatsappchannel.FieldStatus)
  37035. }
  37036. if m.deleted_at != nil {
  37037. fields = append(fields, whatsappchannel.FieldDeletedAt)
  37038. }
  37039. if m.ak != nil {
  37040. fields = append(fields, whatsappchannel.FieldAk)
  37041. }
  37042. if m.sk != nil {
  37043. fields = append(fields, whatsappchannel.FieldSk)
  37044. }
  37045. if m.wa_id != nil {
  37046. fields = append(fields, whatsappchannel.FieldWaID)
  37047. }
  37048. if m.wa_name != nil {
  37049. fields = append(fields, whatsappchannel.FieldWaName)
  37050. }
  37051. if m.waba_id != nil {
  37052. fields = append(fields, whatsappchannel.FieldWabaID)
  37053. }
  37054. if m.business_id != nil {
  37055. fields = append(fields, whatsappchannel.FieldBusinessID)
  37056. }
  37057. if m.organization_id != nil {
  37058. fields = append(fields, whatsappchannel.FieldOrganizationID)
  37059. }
  37060. if m.verify_account != nil {
  37061. fields = append(fields, whatsappchannel.FieldVerifyAccount)
  37062. }
  37063. return fields
  37064. }
  37065. // Field returns the value of a field with the given name. The second boolean
  37066. // return value indicates that this field was not set, or was not defined in the
  37067. // schema.
  37068. func (m *WhatsappChannelMutation) Field(name string) (ent.Value, bool) {
  37069. switch name {
  37070. case whatsappchannel.FieldCreatedAt:
  37071. return m.CreatedAt()
  37072. case whatsappchannel.FieldUpdatedAt:
  37073. return m.UpdatedAt()
  37074. case whatsappchannel.FieldStatus:
  37075. return m.Status()
  37076. case whatsappchannel.FieldDeletedAt:
  37077. return m.DeletedAt()
  37078. case whatsappchannel.FieldAk:
  37079. return m.Ak()
  37080. case whatsappchannel.FieldSk:
  37081. return m.Sk()
  37082. case whatsappchannel.FieldWaID:
  37083. return m.WaID()
  37084. case whatsappchannel.FieldWaName:
  37085. return m.WaName()
  37086. case whatsappchannel.FieldWabaID:
  37087. return m.WabaID()
  37088. case whatsappchannel.FieldBusinessID:
  37089. return m.BusinessID()
  37090. case whatsappchannel.FieldOrganizationID:
  37091. return m.OrganizationID()
  37092. case whatsappchannel.FieldVerifyAccount:
  37093. return m.VerifyAccount()
  37094. }
  37095. return nil, false
  37096. }
  37097. // OldField returns the old value of the field from the database. An error is
  37098. // returned if the mutation operation is not UpdateOne, or the query to the
  37099. // database failed.
  37100. func (m *WhatsappChannelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  37101. switch name {
  37102. case whatsappchannel.FieldCreatedAt:
  37103. return m.OldCreatedAt(ctx)
  37104. case whatsappchannel.FieldUpdatedAt:
  37105. return m.OldUpdatedAt(ctx)
  37106. case whatsappchannel.FieldStatus:
  37107. return m.OldStatus(ctx)
  37108. case whatsappchannel.FieldDeletedAt:
  37109. return m.OldDeletedAt(ctx)
  37110. case whatsappchannel.FieldAk:
  37111. return m.OldAk(ctx)
  37112. case whatsappchannel.FieldSk:
  37113. return m.OldSk(ctx)
  37114. case whatsappchannel.FieldWaID:
  37115. return m.OldWaID(ctx)
  37116. case whatsappchannel.FieldWaName:
  37117. return m.OldWaName(ctx)
  37118. case whatsappchannel.FieldWabaID:
  37119. return m.OldWabaID(ctx)
  37120. case whatsappchannel.FieldBusinessID:
  37121. return m.OldBusinessID(ctx)
  37122. case whatsappchannel.FieldOrganizationID:
  37123. return m.OldOrganizationID(ctx)
  37124. case whatsappchannel.FieldVerifyAccount:
  37125. return m.OldVerifyAccount(ctx)
  37126. }
  37127. return nil, fmt.Errorf("unknown WhatsappChannel field %s", name)
  37128. }
  37129. // SetField sets the value of a field with the given name. It returns an error if
  37130. // the field is not defined in the schema, or if the type mismatched the field
  37131. // type.
  37132. func (m *WhatsappChannelMutation) SetField(name string, value ent.Value) error {
  37133. switch name {
  37134. case whatsappchannel.FieldCreatedAt:
  37135. v, ok := value.(time.Time)
  37136. if !ok {
  37137. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37138. }
  37139. m.SetCreatedAt(v)
  37140. return nil
  37141. case whatsappchannel.FieldUpdatedAt:
  37142. v, ok := value.(time.Time)
  37143. if !ok {
  37144. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37145. }
  37146. m.SetUpdatedAt(v)
  37147. return nil
  37148. case whatsappchannel.FieldStatus:
  37149. v, ok := value.(uint8)
  37150. if !ok {
  37151. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37152. }
  37153. m.SetStatus(v)
  37154. return nil
  37155. case whatsappchannel.FieldDeletedAt:
  37156. v, ok := value.(time.Time)
  37157. if !ok {
  37158. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37159. }
  37160. m.SetDeletedAt(v)
  37161. return nil
  37162. case whatsappchannel.FieldAk:
  37163. v, ok := value.(string)
  37164. if !ok {
  37165. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37166. }
  37167. m.SetAk(v)
  37168. return nil
  37169. case whatsappchannel.FieldSk:
  37170. v, ok := value.(string)
  37171. if !ok {
  37172. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37173. }
  37174. m.SetSk(v)
  37175. return nil
  37176. case whatsappchannel.FieldWaID:
  37177. v, ok := value.(string)
  37178. if !ok {
  37179. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37180. }
  37181. m.SetWaID(v)
  37182. return nil
  37183. case whatsappchannel.FieldWaName:
  37184. v, ok := value.(string)
  37185. if !ok {
  37186. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37187. }
  37188. m.SetWaName(v)
  37189. return nil
  37190. case whatsappchannel.FieldWabaID:
  37191. v, ok := value.(uint64)
  37192. if !ok {
  37193. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37194. }
  37195. m.SetWabaID(v)
  37196. return nil
  37197. case whatsappchannel.FieldBusinessID:
  37198. v, ok := value.(uint64)
  37199. if !ok {
  37200. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37201. }
  37202. m.SetBusinessID(v)
  37203. return nil
  37204. case whatsappchannel.FieldOrganizationID:
  37205. v, ok := value.(uint64)
  37206. if !ok {
  37207. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37208. }
  37209. m.SetOrganizationID(v)
  37210. return nil
  37211. case whatsappchannel.FieldVerifyAccount:
  37212. v, ok := value.(string)
  37213. if !ok {
  37214. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37215. }
  37216. m.SetVerifyAccount(v)
  37217. return nil
  37218. }
  37219. return fmt.Errorf("unknown WhatsappChannel field %s", name)
  37220. }
  37221. // AddedFields returns all numeric fields that were incremented/decremented during
  37222. // this mutation.
  37223. func (m *WhatsappChannelMutation) AddedFields() []string {
  37224. var fields []string
  37225. if m.addstatus != nil {
  37226. fields = append(fields, whatsappchannel.FieldStatus)
  37227. }
  37228. if m.addwaba_id != nil {
  37229. fields = append(fields, whatsappchannel.FieldWabaID)
  37230. }
  37231. if m.addbusiness_id != nil {
  37232. fields = append(fields, whatsappchannel.FieldBusinessID)
  37233. }
  37234. if m.addorganization_id != nil {
  37235. fields = append(fields, whatsappchannel.FieldOrganizationID)
  37236. }
  37237. return fields
  37238. }
  37239. // AddedField returns the numeric value that was incremented/decremented on a field
  37240. // with the given name. The second boolean return value indicates that this field
  37241. // was not set, or was not defined in the schema.
  37242. func (m *WhatsappChannelMutation) AddedField(name string) (ent.Value, bool) {
  37243. switch name {
  37244. case whatsappchannel.FieldStatus:
  37245. return m.AddedStatus()
  37246. case whatsappchannel.FieldWabaID:
  37247. return m.AddedWabaID()
  37248. case whatsappchannel.FieldBusinessID:
  37249. return m.AddedBusinessID()
  37250. case whatsappchannel.FieldOrganizationID:
  37251. return m.AddedOrganizationID()
  37252. }
  37253. return nil, false
  37254. }
  37255. // AddField adds the value to the field with the given name. It returns an error if
  37256. // the field is not defined in the schema, or if the type mismatched the field
  37257. // type.
  37258. func (m *WhatsappChannelMutation) AddField(name string, value ent.Value) error {
  37259. switch name {
  37260. case whatsappchannel.FieldStatus:
  37261. v, ok := value.(int8)
  37262. if !ok {
  37263. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37264. }
  37265. m.AddStatus(v)
  37266. return nil
  37267. case whatsappchannel.FieldWabaID:
  37268. v, ok := value.(int64)
  37269. if !ok {
  37270. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37271. }
  37272. m.AddWabaID(v)
  37273. return nil
  37274. case whatsappchannel.FieldBusinessID:
  37275. v, ok := value.(int64)
  37276. if !ok {
  37277. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37278. }
  37279. m.AddBusinessID(v)
  37280. return nil
  37281. case whatsappchannel.FieldOrganizationID:
  37282. v, ok := value.(int64)
  37283. if !ok {
  37284. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37285. }
  37286. m.AddOrganizationID(v)
  37287. return nil
  37288. }
  37289. return fmt.Errorf("unknown WhatsappChannel numeric field %s", name)
  37290. }
  37291. // ClearedFields returns all nullable fields that were cleared during this
  37292. // mutation.
  37293. func (m *WhatsappChannelMutation) ClearedFields() []string {
  37294. var fields []string
  37295. if m.FieldCleared(whatsappchannel.FieldStatus) {
  37296. fields = append(fields, whatsappchannel.FieldStatus)
  37297. }
  37298. if m.FieldCleared(whatsappchannel.FieldDeletedAt) {
  37299. fields = append(fields, whatsappchannel.FieldDeletedAt)
  37300. }
  37301. if m.FieldCleared(whatsappchannel.FieldAk) {
  37302. fields = append(fields, whatsappchannel.FieldAk)
  37303. }
  37304. if m.FieldCleared(whatsappchannel.FieldWaID) {
  37305. fields = append(fields, whatsappchannel.FieldWaID)
  37306. }
  37307. if m.FieldCleared(whatsappchannel.FieldWaName) {
  37308. fields = append(fields, whatsappchannel.FieldWaName)
  37309. }
  37310. if m.FieldCleared(whatsappchannel.FieldOrganizationID) {
  37311. fields = append(fields, whatsappchannel.FieldOrganizationID)
  37312. }
  37313. return fields
  37314. }
  37315. // FieldCleared returns a boolean indicating if a field with the given name was
  37316. // cleared in this mutation.
  37317. func (m *WhatsappChannelMutation) FieldCleared(name string) bool {
  37318. _, ok := m.clearedFields[name]
  37319. return ok
  37320. }
  37321. // ClearField clears the value of the field with the given name. It returns an
  37322. // error if the field is not defined in the schema.
  37323. func (m *WhatsappChannelMutation) ClearField(name string) error {
  37324. switch name {
  37325. case whatsappchannel.FieldStatus:
  37326. m.ClearStatus()
  37327. return nil
  37328. case whatsappchannel.FieldDeletedAt:
  37329. m.ClearDeletedAt()
  37330. return nil
  37331. case whatsappchannel.FieldAk:
  37332. m.ClearAk()
  37333. return nil
  37334. case whatsappchannel.FieldWaID:
  37335. m.ClearWaID()
  37336. return nil
  37337. case whatsappchannel.FieldWaName:
  37338. m.ClearWaName()
  37339. return nil
  37340. case whatsappchannel.FieldOrganizationID:
  37341. m.ClearOrganizationID()
  37342. return nil
  37343. }
  37344. return fmt.Errorf("unknown WhatsappChannel nullable field %s", name)
  37345. }
  37346. // ResetField resets all changes in the mutation for the field with the given name.
  37347. // It returns an error if the field is not defined in the schema.
  37348. func (m *WhatsappChannelMutation) ResetField(name string) error {
  37349. switch name {
  37350. case whatsappchannel.FieldCreatedAt:
  37351. m.ResetCreatedAt()
  37352. return nil
  37353. case whatsappchannel.FieldUpdatedAt:
  37354. m.ResetUpdatedAt()
  37355. return nil
  37356. case whatsappchannel.FieldStatus:
  37357. m.ResetStatus()
  37358. return nil
  37359. case whatsappchannel.FieldDeletedAt:
  37360. m.ResetDeletedAt()
  37361. return nil
  37362. case whatsappchannel.FieldAk:
  37363. m.ResetAk()
  37364. return nil
  37365. case whatsappchannel.FieldSk:
  37366. m.ResetSk()
  37367. return nil
  37368. case whatsappchannel.FieldWaID:
  37369. m.ResetWaID()
  37370. return nil
  37371. case whatsappchannel.FieldWaName:
  37372. m.ResetWaName()
  37373. return nil
  37374. case whatsappchannel.FieldWabaID:
  37375. m.ResetWabaID()
  37376. return nil
  37377. case whatsappchannel.FieldBusinessID:
  37378. m.ResetBusinessID()
  37379. return nil
  37380. case whatsappchannel.FieldOrganizationID:
  37381. m.ResetOrganizationID()
  37382. return nil
  37383. case whatsappchannel.FieldVerifyAccount:
  37384. m.ResetVerifyAccount()
  37385. return nil
  37386. }
  37387. return fmt.Errorf("unknown WhatsappChannel field %s", name)
  37388. }
  37389. // AddedEdges returns all edge names that were set/added in this mutation.
  37390. func (m *WhatsappChannelMutation) AddedEdges() []string {
  37391. edges := make([]string, 0, 0)
  37392. return edges
  37393. }
  37394. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  37395. // name in this mutation.
  37396. func (m *WhatsappChannelMutation) AddedIDs(name string) []ent.Value {
  37397. return nil
  37398. }
  37399. // RemovedEdges returns all edge names that were removed in this mutation.
  37400. func (m *WhatsappChannelMutation) RemovedEdges() []string {
  37401. edges := make([]string, 0, 0)
  37402. return edges
  37403. }
  37404. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  37405. // the given name in this mutation.
  37406. func (m *WhatsappChannelMutation) RemovedIDs(name string) []ent.Value {
  37407. return nil
  37408. }
  37409. // ClearedEdges returns all edge names that were cleared in this mutation.
  37410. func (m *WhatsappChannelMutation) ClearedEdges() []string {
  37411. edges := make([]string, 0, 0)
  37412. return edges
  37413. }
  37414. // EdgeCleared returns a boolean which indicates if the edge with the given name
  37415. // was cleared in this mutation.
  37416. func (m *WhatsappChannelMutation) EdgeCleared(name string) bool {
  37417. return false
  37418. }
  37419. // ClearEdge clears the value of the edge with the given name. It returns an error
  37420. // if that edge is not defined in the schema.
  37421. func (m *WhatsappChannelMutation) ClearEdge(name string) error {
  37422. return fmt.Errorf("unknown WhatsappChannel unique edge %s", name)
  37423. }
  37424. // ResetEdge resets all changes to the edge with the given name in this mutation.
  37425. // It returns an error if the edge is not defined in the schema.
  37426. func (m *WhatsappChannelMutation) ResetEdge(name string) error {
  37427. return fmt.Errorf("unknown WhatsappChannel edge %s", name)
  37428. }
  37429. // WorkExperienceMutation represents an operation that mutates the WorkExperience nodes in the graph.
  37430. type WorkExperienceMutation struct {
  37431. config
  37432. op Op
  37433. typ string
  37434. id *uint64
  37435. created_at *time.Time
  37436. updated_at *time.Time
  37437. deleted_at *time.Time
  37438. start_date *time.Time
  37439. end_date *time.Time
  37440. company *string
  37441. experience *string
  37442. organization_id *uint64
  37443. addorganization_id *int64
  37444. clearedFields map[string]struct{}
  37445. employee *uint64
  37446. clearedemployee bool
  37447. done bool
  37448. oldValue func(context.Context) (*WorkExperience, error)
  37449. predicates []predicate.WorkExperience
  37450. }
  37451. var _ ent.Mutation = (*WorkExperienceMutation)(nil)
  37452. // workexperienceOption allows management of the mutation configuration using functional options.
  37453. type workexperienceOption func(*WorkExperienceMutation)
  37454. // newWorkExperienceMutation creates new mutation for the WorkExperience entity.
  37455. func newWorkExperienceMutation(c config, op Op, opts ...workexperienceOption) *WorkExperienceMutation {
  37456. m := &WorkExperienceMutation{
  37457. config: c,
  37458. op: op,
  37459. typ: TypeWorkExperience,
  37460. clearedFields: make(map[string]struct{}),
  37461. }
  37462. for _, opt := range opts {
  37463. opt(m)
  37464. }
  37465. return m
  37466. }
  37467. // withWorkExperienceID sets the ID field of the mutation.
  37468. func withWorkExperienceID(id uint64) workexperienceOption {
  37469. return func(m *WorkExperienceMutation) {
  37470. var (
  37471. err error
  37472. once sync.Once
  37473. value *WorkExperience
  37474. )
  37475. m.oldValue = func(ctx context.Context) (*WorkExperience, error) {
  37476. once.Do(func() {
  37477. if m.done {
  37478. err = errors.New("querying old values post mutation is not allowed")
  37479. } else {
  37480. value, err = m.Client().WorkExperience.Get(ctx, id)
  37481. }
  37482. })
  37483. return value, err
  37484. }
  37485. m.id = &id
  37486. }
  37487. }
  37488. // withWorkExperience sets the old WorkExperience of the mutation.
  37489. func withWorkExperience(node *WorkExperience) workexperienceOption {
  37490. return func(m *WorkExperienceMutation) {
  37491. m.oldValue = func(context.Context) (*WorkExperience, error) {
  37492. return node, nil
  37493. }
  37494. m.id = &node.ID
  37495. }
  37496. }
  37497. // Client returns a new `ent.Client` from the mutation. If the mutation was
  37498. // executed in a transaction (ent.Tx), a transactional client is returned.
  37499. func (m WorkExperienceMutation) Client() *Client {
  37500. client := &Client{config: m.config}
  37501. client.init()
  37502. return client
  37503. }
  37504. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  37505. // it returns an error otherwise.
  37506. func (m WorkExperienceMutation) Tx() (*Tx, error) {
  37507. if _, ok := m.driver.(*txDriver); !ok {
  37508. return nil, errors.New("ent: mutation is not running in a transaction")
  37509. }
  37510. tx := &Tx{config: m.config}
  37511. tx.init()
  37512. return tx, nil
  37513. }
  37514. // SetID sets the value of the id field. Note that this
  37515. // operation is only accepted on creation of WorkExperience entities.
  37516. func (m *WorkExperienceMutation) SetID(id uint64) {
  37517. m.id = &id
  37518. }
  37519. // ID returns the ID value in the mutation. Note that the ID is only available
  37520. // if it was provided to the builder or after it was returned from the database.
  37521. func (m *WorkExperienceMutation) ID() (id uint64, exists bool) {
  37522. if m.id == nil {
  37523. return
  37524. }
  37525. return *m.id, true
  37526. }
  37527. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  37528. // That means, if the mutation is applied within a transaction with an isolation level such
  37529. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  37530. // or updated by the mutation.
  37531. func (m *WorkExperienceMutation) IDs(ctx context.Context) ([]uint64, error) {
  37532. switch {
  37533. case m.op.Is(OpUpdateOne | OpDeleteOne):
  37534. id, exists := m.ID()
  37535. if exists {
  37536. return []uint64{id}, nil
  37537. }
  37538. fallthrough
  37539. case m.op.Is(OpUpdate | OpDelete):
  37540. return m.Client().WorkExperience.Query().Where(m.predicates...).IDs(ctx)
  37541. default:
  37542. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  37543. }
  37544. }
  37545. // SetCreatedAt sets the "created_at" field.
  37546. func (m *WorkExperienceMutation) SetCreatedAt(t time.Time) {
  37547. m.created_at = &t
  37548. }
  37549. // CreatedAt returns the value of the "created_at" field in the mutation.
  37550. func (m *WorkExperienceMutation) CreatedAt() (r time.Time, exists bool) {
  37551. v := m.created_at
  37552. if v == nil {
  37553. return
  37554. }
  37555. return *v, true
  37556. }
  37557. // OldCreatedAt returns the old "created_at" field's value of the WorkExperience entity.
  37558. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  37559. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37560. func (m *WorkExperienceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  37561. if !m.op.Is(OpUpdateOne) {
  37562. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  37563. }
  37564. if m.id == nil || m.oldValue == nil {
  37565. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  37566. }
  37567. oldValue, err := m.oldValue(ctx)
  37568. if err != nil {
  37569. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  37570. }
  37571. return oldValue.CreatedAt, nil
  37572. }
  37573. // ResetCreatedAt resets all changes to the "created_at" field.
  37574. func (m *WorkExperienceMutation) ResetCreatedAt() {
  37575. m.created_at = nil
  37576. }
  37577. // SetUpdatedAt sets the "updated_at" field.
  37578. func (m *WorkExperienceMutation) SetUpdatedAt(t time.Time) {
  37579. m.updated_at = &t
  37580. }
  37581. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  37582. func (m *WorkExperienceMutation) UpdatedAt() (r time.Time, exists bool) {
  37583. v := m.updated_at
  37584. if v == nil {
  37585. return
  37586. }
  37587. return *v, true
  37588. }
  37589. // OldUpdatedAt returns the old "updated_at" field's value of the WorkExperience entity.
  37590. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  37591. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37592. func (m *WorkExperienceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  37593. if !m.op.Is(OpUpdateOne) {
  37594. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  37595. }
  37596. if m.id == nil || m.oldValue == nil {
  37597. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  37598. }
  37599. oldValue, err := m.oldValue(ctx)
  37600. if err != nil {
  37601. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  37602. }
  37603. return oldValue.UpdatedAt, nil
  37604. }
  37605. // ResetUpdatedAt resets all changes to the "updated_at" field.
  37606. func (m *WorkExperienceMutation) ResetUpdatedAt() {
  37607. m.updated_at = nil
  37608. }
  37609. // SetDeletedAt sets the "deleted_at" field.
  37610. func (m *WorkExperienceMutation) SetDeletedAt(t time.Time) {
  37611. m.deleted_at = &t
  37612. }
  37613. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  37614. func (m *WorkExperienceMutation) DeletedAt() (r time.Time, exists bool) {
  37615. v := m.deleted_at
  37616. if v == nil {
  37617. return
  37618. }
  37619. return *v, true
  37620. }
  37621. // OldDeletedAt returns the old "deleted_at" field's value of the WorkExperience entity.
  37622. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  37623. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37624. func (m *WorkExperienceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  37625. if !m.op.Is(OpUpdateOne) {
  37626. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  37627. }
  37628. if m.id == nil || m.oldValue == nil {
  37629. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  37630. }
  37631. oldValue, err := m.oldValue(ctx)
  37632. if err != nil {
  37633. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  37634. }
  37635. return oldValue.DeletedAt, nil
  37636. }
  37637. // ClearDeletedAt clears the value of the "deleted_at" field.
  37638. func (m *WorkExperienceMutation) ClearDeletedAt() {
  37639. m.deleted_at = nil
  37640. m.clearedFields[workexperience.FieldDeletedAt] = struct{}{}
  37641. }
  37642. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  37643. func (m *WorkExperienceMutation) DeletedAtCleared() bool {
  37644. _, ok := m.clearedFields[workexperience.FieldDeletedAt]
  37645. return ok
  37646. }
  37647. // ResetDeletedAt resets all changes to the "deleted_at" field.
  37648. func (m *WorkExperienceMutation) ResetDeletedAt() {
  37649. m.deleted_at = nil
  37650. delete(m.clearedFields, workexperience.FieldDeletedAt)
  37651. }
  37652. // SetEmployeeID sets the "employee_id" field.
  37653. func (m *WorkExperienceMutation) SetEmployeeID(u uint64) {
  37654. m.employee = &u
  37655. }
  37656. // EmployeeID returns the value of the "employee_id" field in the mutation.
  37657. func (m *WorkExperienceMutation) EmployeeID() (r uint64, exists bool) {
  37658. v := m.employee
  37659. if v == nil {
  37660. return
  37661. }
  37662. return *v, true
  37663. }
  37664. // OldEmployeeID returns the old "employee_id" field's value of the WorkExperience entity.
  37665. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  37666. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37667. func (m *WorkExperienceMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  37668. if !m.op.Is(OpUpdateOne) {
  37669. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  37670. }
  37671. if m.id == nil || m.oldValue == nil {
  37672. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  37673. }
  37674. oldValue, err := m.oldValue(ctx)
  37675. if err != nil {
  37676. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  37677. }
  37678. return oldValue.EmployeeID, nil
  37679. }
  37680. // ResetEmployeeID resets all changes to the "employee_id" field.
  37681. func (m *WorkExperienceMutation) ResetEmployeeID() {
  37682. m.employee = nil
  37683. }
  37684. // SetStartDate sets the "start_date" field.
  37685. func (m *WorkExperienceMutation) SetStartDate(t time.Time) {
  37686. m.start_date = &t
  37687. }
  37688. // StartDate returns the value of the "start_date" field in the mutation.
  37689. func (m *WorkExperienceMutation) StartDate() (r time.Time, exists bool) {
  37690. v := m.start_date
  37691. if v == nil {
  37692. return
  37693. }
  37694. return *v, true
  37695. }
  37696. // OldStartDate returns the old "start_date" field's value of the WorkExperience entity.
  37697. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  37698. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37699. func (m *WorkExperienceMutation) OldStartDate(ctx context.Context) (v time.Time, err error) {
  37700. if !m.op.Is(OpUpdateOne) {
  37701. return v, errors.New("OldStartDate is only allowed on UpdateOne operations")
  37702. }
  37703. if m.id == nil || m.oldValue == nil {
  37704. return v, errors.New("OldStartDate requires an ID field in the mutation")
  37705. }
  37706. oldValue, err := m.oldValue(ctx)
  37707. if err != nil {
  37708. return v, fmt.Errorf("querying old value for OldStartDate: %w", err)
  37709. }
  37710. return oldValue.StartDate, nil
  37711. }
  37712. // ResetStartDate resets all changes to the "start_date" field.
  37713. func (m *WorkExperienceMutation) ResetStartDate() {
  37714. m.start_date = nil
  37715. }
  37716. // SetEndDate sets the "end_date" field.
  37717. func (m *WorkExperienceMutation) SetEndDate(t time.Time) {
  37718. m.end_date = &t
  37719. }
  37720. // EndDate returns the value of the "end_date" field in the mutation.
  37721. func (m *WorkExperienceMutation) EndDate() (r time.Time, exists bool) {
  37722. v := m.end_date
  37723. if v == nil {
  37724. return
  37725. }
  37726. return *v, true
  37727. }
  37728. // OldEndDate returns the old "end_date" field's value of the WorkExperience entity.
  37729. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  37730. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37731. func (m *WorkExperienceMutation) OldEndDate(ctx context.Context) (v time.Time, err error) {
  37732. if !m.op.Is(OpUpdateOne) {
  37733. return v, errors.New("OldEndDate is only allowed on UpdateOne operations")
  37734. }
  37735. if m.id == nil || m.oldValue == nil {
  37736. return v, errors.New("OldEndDate requires an ID field in the mutation")
  37737. }
  37738. oldValue, err := m.oldValue(ctx)
  37739. if err != nil {
  37740. return v, fmt.Errorf("querying old value for OldEndDate: %w", err)
  37741. }
  37742. return oldValue.EndDate, nil
  37743. }
  37744. // ResetEndDate resets all changes to the "end_date" field.
  37745. func (m *WorkExperienceMutation) ResetEndDate() {
  37746. m.end_date = nil
  37747. }
  37748. // SetCompany sets the "company" field.
  37749. func (m *WorkExperienceMutation) SetCompany(s string) {
  37750. m.company = &s
  37751. }
  37752. // Company returns the value of the "company" field in the mutation.
  37753. func (m *WorkExperienceMutation) Company() (r string, exists bool) {
  37754. v := m.company
  37755. if v == nil {
  37756. return
  37757. }
  37758. return *v, true
  37759. }
  37760. // OldCompany returns the old "company" field's value of the WorkExperience entity.
  37761. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  37762. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37763. func (m *WorkExperienceMutation) OldCompany(ctx context.Context) (v string, err error) {
  37764. if !m.op.Is(OpUpdateOne) {
  37765. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  37766. }
  37767. if m.id == nil || m.oldValue == nil {
  37768. return v, errors.New("OldCompany requires an ID field in the mutation")
  37769. }
  37770. oldValue, err := m.oldValue(ctx)
  37771. if err != nil {
  37772. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  37773. }
  37774. return oldValue.Company, nil
  37775. }
  37776. // ResetCompany resets all changes to the "company" field.
  37777. func (m *WorkExperienceMutation) ResetCompany() {
  37778. m.company = nil
  37779. }
  37780. // SetExperience sets the "experience" field.
  37781. func (m *WorkExperienceMutation) SetExperience(s string) {
  37782. m.experience = &s
  37783. }
  37784. // Experience returns the value of the "experience" field in the mutation.
  37785. func (m *WorkExperienceMutation) Experience() (r string, exists bool) {
  37786. v := m.experience
  37787. if v == nil {
  37788. return
  37789. }
  37790. return *v, true
  37791. }
  37792. // OldExperience returns the old "experience" field's value of the WorkExperience entity.
  37793. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  37794. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37795. func (m *WorkExperienceMutation) OldExperience(ctx context.Context) (v string, err error) {
  37796. if !m.op.Is(OpUpdateOne) {
  37797. return v, errors.New("OldExperience is only allowed on UpdateOne operations")
  37798. }
  37799. if m.id == nil || m.oldValue == nil {
  37800. return v, errors.New("OldExperience requires an ID field in the mutation")
  37801. }
  37802. oldValue, err := m.oldValue(ctx)
  37803. if err != nil {
  37804. return v, fmt.Errorf("querying old value for OldExperience: %w", err)
  37805. }
  37806. return oldValue.Experience, nil
  37807. }
  37808. // ResetExperience resets all changes to the "experience" field.
  37809. func (m *WorkExperienceMutation) ResetExperience() {
  37810. m.experience = nil
  37811. }
  37812. // SetOrganizationID sets the "organization_id" field.
  37813. func (m *WorkExperienceMutation) SetOrganizationID(u uint64) {
  37814. m.organization_id = &u
  37815. m.addorganization_id = nil
  37816. }
  37817. // OrganizationID returns the value of the "organization_id" field in the mutation.
  37818. func (m *WorkExperienceMutation) OrganizationID() (r uint64, exists bool) {
  37819. v := m.organization_id
  37820. if v == nil {
  37821. return
  37822. }
  37823. return *v, true
  37824. }
  37825. // OldOrganizationID returns the old "organization_id" field's value of the WorkExperience entity.
  37826. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  37827. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37828. func (m *WorkExperienceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  37829. if !m.op.Is(OpUpdateOne) {
  37830. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  37831. }
  37832. if m.id == nil || m.oldValue == nil {
  37833. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  37834. }
  37835. oldValue, err := m.oldValue(ctx)
  37836. if err != nil {
  37837. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  37838. }
  37839. return oldValue.OrganizationID, nil
  37840. }
  37841. // AddOrganizationID adds u to the "organization_id" field.
  37842. func (m *WorkExperienceMutation) AddOrganizationID(u int64) {
  37843. if m.addorganization_id != nil {
  37844. *m.addorganization_id += u
  37845. } else {
  37846. m.addorganization_id = &u
  37847. }
  37848. }
  37849. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  37850. func (m *WorkExperienceMutation) AddedOrganizationID() (r int64, exists bool) {
  37851. v := m.addorganization_id
  37852. if v == nil {
  37853. return
  37854. }
  37855. return *v, true
  37856. }
  37857. // ResetOrganizationID resets all changes to the "organization_id" field.
  37858. func (m *WorkExperienceMutation) ResetOrganizationID() {
  37859. m.organization_id = nil
  37860. m.addorganization_id = nil
  37861. }
  37862. // ClearEmployee clears the "employee" edge to the Employee entity.
  37863. func (m *WorkExperienceMutation) ClearEmployee() {
  37864. m.clearedemployee = true
  37865. m.clearedFields[workexperience.FieldEmployeeID] = struct{}{}
  37866. }
  37867. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  37868. func (m *WorkExperienceMutation) EmployeeCleared() bool {
  37869. return m.clearedemployee
  37870. }
  37871. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  37872. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  37873. // EmployeeID instead. It exists only for internal usage by the builders.
  37874. func (m *WorkExperienceMutation) EmployeeIDs() (ids []uint64) {
  37875. if id := m.employee; id != nil {
  37876. ids = append(ids, *id)
  37877. }
  37878. return
  37879. }
  37880. // ResetEmployee resets all changes to the "employee" edge.
  37881. func (m *WorkExperienceMutation) ResetEmployee() {
  37882. m.employee = nil
  37883. m.clearedemployee = false
  37884. }
  37885. // Where appends a list predicates to the WorkExperienceMutation builder.
  37886. func (m *WorkExperienceMutation) Where(ps ...predicate.WorkExperience) {
  37887. m.predicates = append(m.predicates, ps...)
  37888. }
  37889. // WhereP appends storage-level predicates to the WorkExperienceMutation builder. Using this method,
  37890. // users can use type-assertion to append predicates that do not depend on any generated package.
  37891. func (m *WorkExperienceMutation) WhereP(ps ...func(*sql.Selector)) {
  37892. p := make([]predicate.WorkExperience, len(ps))
  37893. for i := range ps {
  37894. p[i] = ps[i]
  37895. }
  37896. m.Where(p...)
  37897. }
  37898. // Op returns the operation name.
  37899. func (m *WorkExperienceMutation) Op() Op {
  37900. return m.op
  37901. }
  37902. // SetOp allows setting the mutation operation.
  37903. func (m *WorkExperienceMutation) SetOp(op Op) {
  37904. m.op = op
  37905. }
  37906. // Type returns the node type of this mutation (WorkExperience).
  37907. func (m *WorkExperienceMutation) Type() string {
  37908. return m.typ
  37909. }
  37910. // Fields returns all fields that were changed during this mutation. Note that in
  37911. // order to get all numeric fields that were incremented/decremented, call
  37912. // AddedFields().
  37913. func (m *WorkExperienceMutation) Fields() []string {
  37914. fields := make([]string, 0, 9)
  37915. if m.created_at != nil {
  37916. fields = append(fields, workexperience.FieldCreatedAt)
  37917. }
  37918. if m.updated_at != nil {
  37919. fields = append(fields, workexperience.FieldUpdatedAt)
  37920. }
  37921. if m.deleted_at != nil {
  37922. fields = append(fields, workexperience.FieldDeletedAt)
  37923. }
  37924. if m.employee != nil {
  37925. fields = append(fields, workexperience.FieldEmployeeID)
  37926. }
  37927. if m.start_date != nil {
  37928. fields = append(fields, workexperience.FieldStartDate)
  37929. }
  37930. if m.end_date != nil {
  37931. fields = append(fields, workexperience.FieldEndDate)
  37932. }
  37933. if m.company != nil {
  37934. fields = append(fields, workexperience.FieldCompany)
  37935. }
  37936. if m.experience != nil {
  37937. fields = append(fields, workexperience.FieldExperience)
  37938. }
  37939. if m.organization_id != nil {
  37940. fields = append(fields, workexperience.FieldOrganizationID)
  37941. }
  37942. return fields
  37943. }
  37944. // Field returns the value of a field with the given name. The second boolean
  37945. // return value indicates that this field was not set, or was not defined in the
  37946. // schema.
  37947. func (m *WorkExperienceMutation) Field(name string) (ent.Value, bool) {
  37948. switch name {
  37949. case workexperience.FieldCreatedAt:
  37950. return m.CreatedAt()
  37951. case workexperience.FieldUpdatedAt:
  37952. return m.UpdatedAt()
  37953. case workexperience.FieldDeletedAt:
  37954. return m.DeletedAt()
  37955. case workexperience.FieldEmployeeID:
  37956. return m.EmployeeID()
  37957. case workexperience.FieldStartDate:
  37958. return m.StartDate()
  37959. case workexperience.FieldEndDate:
  37960. return m.EndDate()
  37961. case workexperience.FieldCompany:
  37962. return m.Company()
  37963. case workexperience.FieldExperience:
  37964. return m.Experience()
  37965. case workexperience.FieldOrganizationID:
  37966. return m.OrganizationID()
  37967. }
  37968. return nil, false
  37969. }
  37970. // OldField returns the old value of the field from the database. An error is
  37971. // returned if the mutation operation is not UpdateOne, or the query to the
  37972. // database failed.
  37973. func (m *WorkExperienceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  37974. switch name {
  37975. case workexperience.FieldCreatedAt:
  37976. return m.OldCreatedAt(ctx)
  37977. case workexperience.FieldUpdatedAt:
  37978. return m.OldUpdatedAt(ctx)
  37979. case workexperience.FieldDeletedAt:
  37980. return m.OldDeletedAt(ctx)
  37981. case workexperience.FieldEmployeeID:
  37982. return m.OldEmployeeID(ctx)
  37983. case workexperience.FieldStartDate:
  37984. return m.OldStartDate(ctx)
  37985. case workexperience.FieldEndDate:
  37986. return m.OldEndDate(ctx)
  37987. case workexperience.FieldCompany:
  37988. return m.OldCompany(ctx)
  37989. case workexperience.FieldExperience:
  37990. return m.OldExperience(ctx)
  37991. case workexperience.FieldOrganizationID:
  37992. return m.OldOrganizationID(ctx)
  37993. }
  37994. return nil, fmt.Errorf("unknown WorkExperience field %s", name)
  37995. }
  37996. // SetField sets the value of a field with the given name. It returns an error if
  37997. // the field is not defined in the schema, or if the type mismatched the field
  37998. // type.
  37999. func (m *WorkExperienceMutation) SetField(name string, value ent.Value) error {
  38000. switch name {
  38001. case workexperience.FieldCreatedAt:
  38002. v, ok := value.(time.Time)
  38003. if !ok {
  38004. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38005. }
  38006. m.SetCreatedAt(v)
  38007. return nil
  38008. case workexperience.FieldUpdatedAt:
  38009. v, ok := value.(time.Time)
  38010. if !ok {
  38011. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38012. }
  38013. m.SetUpdatedAt(v)
  38014. return nil
  38015. case workexperience.FieldDeletedAt:
  38016. v, ok := value.(time.Time)
  38017. if !ok {
  38018. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38019. }
  38020. m.SetDeletedAt(v)
  38021. return nil
  38022. case workexperience.FieldEmployeeID:
  38023. v, ok := value.(uint64)
  38024. if !ok {
  38025. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38026. }
  38027. m.SetEmployeeID(v)
  38028. return nil
  38029. case workexperience.FieldStartDate:
  38030. v, ok := value.(time.Time)
  38031. if !ok {
  38032. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38033. }
  38034. m.SetStartDate(v)
  38035. return nil
  38036. case workexperience.FieldEndDate:
  38037. v, ok := value.(time.Time)
  38038. if !ok {
  38039. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38040. }
  38041. m.SetEndDate(v)
  38042. return nil
  38043. case workexperience.FieldCompany:
  38044. v, ok := value.(string)
  38045. if !ok {
  38046. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38047. }
  38048. m.SetCompany(v)
  38049. return nil
  38050. case workexperience.FieldExperience:
  38051. v, ok := value.(string)
  38052. if !ok {
  38053. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38054. }
  38055. m.SetExperience(v)
  38056. return nil
  38057. case workexperience.FieldOrganizationID:
  38058. v, ok := value.(uint64)
  38059. if !ok {
  38060. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38061. }
  38062. m.SetOrganizationID(v)
  38063. return nil
  38064. }
  38065. return fmt.Errorf("unknown WorkExperience field %s", name)
  38066. }
  38067. // AddedFields returns all numeric fields that were incremented/decremented during
  38068. // this mutation.
  38069. func (m *WorkExperienceMutation) AddedFields() []string {
  38070. var fields []string
  38071. if m.addorganization_id != nil {
  38072. fields = append(fields, workexperience.FieldOrganizationID)
  38073. }
  38074. return fields
  38075. }
  38076. // AddedField returns the numeric value that was incremented/decremented on a field
  38077. // with the given name. The second boolean return value indicates that this field
  38078. // was not set, or was not defined in the schema.
  38079. func (m *WorkExperienceMutation) AddedField(name string) (ent.Value, bool) {
  38080. switch name {
  38081. case workexperience.FieldOrganizationID:
  38082. return m.AddedOrganizationID()
  38083. }
  38084. return nil, false
  38085. }
  38086. // AddField adds the value to the field with the given name. It returns an error if
  38087. // the field is not defined in the schema, or if the type mismatched the field
  38088. // type.
  38089. func (m *WorkExperienceMutation) AddField(name string, value ent.Value) error {
  38090. switch name {
  38091. case workexperience.FieldOrganizationID:
  38092. v, ok := value.(int64)
  38093. if !ok {
  38094. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38095. }
  38096. m.AddOrganizationID(v)
  38097. return nil
  38098. }
  38099. return fmt.Errorf("unknown WorkExperience numeric field %s", name)
  38100. }
  38101. // ClearedFields returns all nullable fields that were cleared during this
  38102. // mutation.
  38103. func (m *WorkExperienceMutation) ClearedFields() []string {
  38104. var fields []string
  38105. if m.FieldCleared(workexperience.FieldDeletedAt) {
  38106. fields = append(fields, workexperience.FieldDeletedAt)
  38107. }
  38108. return fields
  38109. }
  38110. // FieldCleared returns a boolean indicating if a field with the given name was
  38111. // cleared in this mutation.
  38112. func (m *WorkExperienceMutation) FieldCleared(name string) bool {
  38113. _, ok := m.clearedFields[name]
  38114. return ok
  38115. }
  38116. // ClearField clears the value of the field with the given name. It returns an
  38117. // error if the field is not defined in the schema.
  38118. func (m *WorkExperienceMutation) ClearField(name string) error {
  38119. switch name {
  38120. case workexperience.FieldDeletedAt:
  38121. m.ClearDeletedAt()
  38122. return nil
  38123. }
  38124. return fmt.Errorf("unknown WorkExperience nullable field %s", name)
  38125. }
  38126. // ResetField resets all changes in the mutation for the field with the given name.
  38127. // It returns an error if the field is not defined in the schema.
  38128. func (m *WorkExperienceMutation) ResetField(name string) error {
  38129. switch name {
  38130. case workexperience.FieldCreatedAt:
  38131. m.ResetCreatedAt()
  38132. return nil
  38133. case workexperience.FieldUpdatedAt:
  38134. m.ResetUpdatedAt()
  38135. return nil
  38136. case workexperience.FieldDeletedAt:
  38137. m.ResetDeletedAt()
  38138. return nil
  38139. case workexperience.FieldEmployeeID:
  38140. m.ResetEmployeeID()
  38141. return nil
  38142. case workexperience.FieldStartDate:
  38143. m.ResetStartDate()
  38144. return nil
  38145. case workexperience.FieldEndDate:
  38146. m.ResetEndDate()
  38147. return nil
  38148. case workexperience.FieldCompany:
  38149. m.ResetCompany()
  38150. return nil
  38151. case workexperience.FieldExperience:
  38152. m.ResetExperience()
  38153. return nil
  38154. case workexperience.FieldOrganizationID:
  38155. m.ResetOrganizationID()
  38156. return nil
  38157. }
  38158. return fmt.Errorf("unknown WorkExperience field %s", name)
  38159. }
  38160. // AddedEdges returns all edge names that were set/added in this mutation.
  38161. func (m *WorkExperienceMutation) AddedEdges() []string {
  38162. edges := make([]string, 0, 1)
  38163. if m.employee != nil {
  38164. edges = append(edges, workexperience.EdgeEmployee)
  38165. }
  38166. return edges
  38167. }
  38168. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  38169. // name in this mutation.
  38170. func (m *WorkExperienceMutation) AddedIDs(name string) []ent.Value {
  38171. switch name {
  38172. case workexperience.EdgeEmployee:
  38173. if id := m.employee; id != nil {
  38174. return []ent.Value{*id}
  38175. }
  38176. }
  38177. return nil
  38178. }
  38179. // RemovedEdges returns all edge names that were removed in this mutation.
  38180. func (m *WorkExperienceMutation) RemovedEdges() []string {
  38181. edges := make([]string, 0, 1)
  38182. return edges
  38183. }
  38184. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  38185. // the given name in this mutation.
  38186. func (m *WorkExperienceMutation) RemovedIDs(name string) []ent.Value {
  38187. return nil
  38188. }
  38189. // ClearedEdges returns all edge names that were cleared in this mutation.
  38190. func (m *WorkExperienceMutation) ClearedEdges() []string {
  38191. edges := make([]string, 0, 1)
  38192. if m.clearedemployee {
  38193. edges = append(edges, workexperience.EdgeEmployee)
  38194. }
  38195. return edges
  38196. }
  38197. // EdgeCleared returns a boolean which indicates if the edge with the given name
  38198. // was cleared in this mutation.
  38199. func (m *WorkExperienceMutation) EdgeCleared(name string) bool {
  38200. switch name {
  38201. case workexperience.EdgeEmployee:
  38202. return m.clearedemployee
  38203. }
  38204. return false
  38205. }
  38206. // ClearEdge clears the value of the edge with the given name. It returns an error
  38207. // if that edge is not defined in the schema.
  38208. func (m *WorkExperienceMutation) ClearEdge(name string) error {
  38209. switch name {
  38210. case workexperience.EdgeEmployee:
  38211. m.ClearEmployee()
  38212. return nil
  38213. }
  38214. return fmt.Errorf("unknown WorkExperience unique edge %s", name)
  38215. }
  38216. // ResetEdge resets all changes to the edge with the given name in this mutation.
  38217. // It returns an error if the edge is not defined in the schema.
  38218. func (m *WorkExperienceMutation) ResetEdge(name string) error {
  38219. switch name {
  38220. case workexperience.EdgeEmployee:
  38221. m.ResetEmployee()
  38222. return nil
  38223. }
  38224. return fmt.Errorf("unknown WorkExperience edge %s", name)
  38225. }
  38226. // WpChatroomMutation represents an operation that mutates the WpChatroom nodes in the graph.
  38227. type WpChatroomMutation struct {
  38228. config
  38229. op Op
  38230. typ string
  38231. id *uint64
  38232. created_at *time.Time
  38233. updated_at *time.Time
  38234. status *uint8
  38235. addstatus *int8
  38236. wx_wxid *string
  38237. chatroom_id *string
  38238. nickname *string
  38239. owner *string
  38240. avatar *string
  38241. member_list *[]string
  38242. appendmember_list []string
  38243. clearedFields map[string]struct{}
  38244. done bool
  38245. oldValue func(context.Context) (*WpChatroom, error)
  38246. predicates []predicate.WpChatroom
  38247. }
  38248. var _ ent.Mutation = (*WpChatroomMutation)(nil)
  38249. // wpchatroomOption allows management of the mutation configuration using functional options.
  38250. type wpchatroomOption func(*WpChatroomMutation)
  38251. // newWpChatroomMutation creates new mutation for the WpChatroom entity.
  38252. func newWpChatroomMutation(c config, op Op, opts ...wpchatroomOption) *WpChatroomMutation {
  38253. m := &WpChatroomMutation{
  38254. config: c,
  38255. op: op,
  38256. typ: TypeWpChatroom,
  38257. clearedFields: make(map[string]struct{}),
  38258. }
  38259. for _, opt := range opts {
  38260. opt(m)
  38261. }
  38262. return m
  38263. }
  38264. // withWpChatroomID sets the ID field of the mutation.
  38265. func withWpChatroomID(id uint64) wpchatroomOption {
  38266. return func(m *WpChatroomMutation) {
  38267. var (
  38268. err error
  38269. once sync.Once
  38270. value *WpChatroom
  38271. )
  38272. m.oldValue = func(ctx context.Context) (*WpChatroom, error) {
  38273. once.Do(func() {
  38274. if m.done {
  38275. err = errors.New("querying old values post mutation is not allowed")
  38276. } else {
  38277. value, err = m.Client().WpChatroom.Get(ctx, id)
  38278. }
  38279. })
  38280. return value, err
  38281. }
  38282. m.id = &id
  38283. }
  38284. }
  38285. // withWpChatroom sets the old WpChatroom of the mutation.
  38286. func withWpChatroom(node *WpChatroom) wpchatroomOption {
  38287. return func(m *WpChatroomMutation) {
  38288. m.oldValue = func(context.Context) (*WpChatroom, error) {
  38289. return node, nil
  38290. }
  38291. m.id = &node.ID
  38292. }
  38293. }
  38294. // Client returns a new `ent.Client` from the mutation. If the mutation was
  38295. // executed in a transaction (ent.Tx), a transactional client is returned.
  38296. func (m WpChatroomMutation) Client() *Client {
  38297. client := &Client{config: m.config}
  38298. client.init()
  38299. return client
  38300. }
  38301. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  38302. // it returns an error otherwise.
  38303. func (m WpChatroomMutation) Tx() (*Tx, error) {
  38304. if _, ok := m.driver.(*txDriver); !ok {
  38305. return nil, errors.New("ent: mutation is not running in a transaction")
  38306. }
  38307. tx := &Tx{config: m.config}
  38308. tx.init()
  38309. return tx, nil
  38310. }
  38311. // SetID sets the value of the id field. Note that this
  38312. // operation is only accepted on creation of WpChatroom entities.
  38313. func (m *WpChatroomMutation) SetID(id uint64) {
  38314. m.id = &id
  38315. }
  38316. // ID returns the ID value in the mutation. Note that the ID is only available
  38317. // if it was provided to the builder or after it was returned from the database.
  38318. func (m *WpChatroomMutation) ID() (id uint64, exists bool) {
  38319. if m.id == nil {
  38320. return
  38321. }
  38322. return *m.id, true
  38323. }
  38324. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  38325. // That means, if the mutation is applied within a transaction with an isolation level such
  38326. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  38327. // or updated by the mutation.
  38328. func (m *WpChatroomMutation) IDs(ctx context.Context) ([]uint64, error) {
  38329. switch {
  38330. case m.op.Is(OpUpdateOne | OpDeleteOne):
  38331. id, exists := m.ID()
  38332. if exists {
  38333. return []uint64{id}, nil
  38334. }
  38335. fallthrough
  38336. case m.op.Is(OpUpdate | OpDelete):
  38337. return m.Client().WpChatroom.Query().Where(m.predicates...).IDs(ctx)
  38338. default:
  38339. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  38340. }
  38341. }
  38342. // SetCreatedAt sets the "created_at" field.
  38343. func (m *WpChatroomMutation) SetCreatedAt(t time.Time) {
  38344. m.created_at = &t
  38345. }
  38346. // CreatedAt returns the value of the "created_at" field in the mutation.
  38347. func (m *WpChatroomMutation) CreatedAt() (r time.Time, exists bool) {
  38348. v := m.created_at
  38349. if v == nil {
  38350. return
  38351. }
  38352. return *v, true
  38353. }
  38354. // OldCreatedAt returns the old "created_at" field's value of the WpChatroom entity.
  38355. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  38356. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38357. func (m *WpChatroomMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  38358. if !m.op.Is(OpUpdateOne) {
  38359. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  38360. }
  38361. if m.id == nil || m.oldValue == nil {
  38362. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  38363. }
  38364. oldValue, err := m.oldValue(ctx)
  38365. if err != nil {
  38366. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  38367. }
  38368. return oldValue.CreatedAt, nil
  38369. }
  38370. // ResetCreatedAt resets all changes to the "created_at" field.
  38371. func (m *WpChatroomMutation) ResetCreatedAt() {
  38372. m.created_at = nil
  38373. }
  38374. // SetUpdatedAt sets the "updated_at" field.
  38375. func (m *WpChatroomMutation) SetUpdatedAt(t time.Time) {
  38376. m.updated_at = &t
  38377. }
  38378. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  38379. func (m *WpChatroomMutation) UpdatedAt() (r time.Time, exists bool) {
  38380. v := m.updated_at
  38381. if v == nil {
  38382. return
  38383. }
  38384. return *v, true
  38385. }
  38386. // OldUpdatedAt returns the old "updated_at" field's value of the WpChatroom entity.
  38387. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  38388. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38389. func (m *WpChatroomMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  38390. if !m.op.Is(OpUpdateOne) {
  38391. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  38392. }
  38393. if m.id == nil || m.oldValue == nil {
  38394. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  38395. }
  38396. oldValue, err := m.oldValue(ctx)
  38397. if err != nil {
  38398. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  38399. }
  38400. return oldValue.UpdatedAt, nil
  38401. }
  38402. // ResetUpdatedAt resets all changes to the "updated_at" field.
  38403. func (m *WpChatroomMutation) ResetUpdatedAt() {
  38404. m.updated_at = nil
  38405. }
  38406. // SetStatus sets the "status" field.
  38407. func (m *WpChatroomMutation) SetStatus(u uint8) {
  38408. m.status = &u
  38409. m.addstatus = nil
  38410. }
  38411. // Status returns the value of the "status" field in the mutation.
  38412. func (m *WpChatroomMutation) Status() (r uint8, exists bool) {
  38413. v := m.status
  38414. if v == nil {
  38415. return
  38416. }
  38417. return *v, true
  38418. }
  38419. // OldStatus returns the old "status" field's value of the WpChatroom entity.
  38420. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  38421. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38422. func (m *WpChatroomMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  38423. if !m.op.Is(OpUpdateOne) {
  38424. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  38425. }
  38426. if m.id == nil || m.oldValue == nil {
  38427. return v, errors.New("OldStatus requires an ID field in the mutation")
  38428. }
  38429. oldValue, err := m.oldValue(ctx)
  38430. if err != nil {
  38431. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  38432. }
  38433. return oldValue.Status, nil
  38434. }
  38435. // AddStatus adds u to the "status" field.
  38436. func (m *WpChatroomMutation) AddStatus(u int8) {
  38437. if m.addstatus != nil {
  38438. *m.addstatus += u
  38439. } else {
  38440. m.addstatus = &u
  38441. }
  38442. }
  38443. // AddedStatus returns the value that was added to the "status" field in this mutation.
  38444. func (m *WpChatroomMutation) AddedStatus() (r int8, exists bool) {
  38445. v := m.addstatus
  38446. if v == nil {
  38447. return
  38448. }
  38449. return *v, true
  38450. }
  38451. // ClearStatus clears the value of the "status" field.
  38452. func (m *WpChatroomMutation) ClearStatus() {
  38453. m.status = nil
  38454. m.addstatus = nil
  38455. m.clearedFields[wpchatroom.FieldStatus] = struct{}{}
  38456. }
  38457. // StatusCleared returns if the "status" field was cleared in this mutation.
  38458. func (m *WpChatroomMutation) StatusCleared() bool {
  38459. _, ok := m.clearedFields[wpchatroom.FieldStatus]
  38460. return ok
  38461. }
  38462. // ResetStatus resets all changes to the "status" field.
  38463. func (m *WpChatroomMutation) ResetStatus() {
  38464. m.status = nil
  38465. m.addstatus = nil
  38466. delete(m.clearedFields, wpchatroom.FieldStatus)
  38467. }
  38468. // SetWxWxid sets the "wx_wxid" field.
  38469. func (m *WpChatroomMutation) SetWxWxid(s string) {
  38470. m.wx_wxid = &s
  38471. }
  38472. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  38473. func (m *WpChatroomMutation) WxWxid() (r string, exists bool) {
  38474. v := m.wx_wxid
  38475. if v == nil {
  38476. return
  38477. }
  38478. return *v, true
  38479. }
  38480. // OldWxWxid returns the old "wx_wxid" field's value of the WpChatroom entity.
  38481. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  38482. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38483. func (m *WpChatroomMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  38484. if !m.op.Is(OpUpdateOne) {
  38485. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  38486. }
  38487. if m.id == nil || m.oldValue == nil {
  38488. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  38489. }
  38490. oldValue, err := m.oldValue(ctx)
  38491. if err != nil {
  38492. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  38493. }
  38494. return oldValue.WxWxid, nil
  38495. }
  38496. // ResetWxWxid resets all changes to the "wx_wxid" field.
  38497. func (m *WpChatroomMutation) ResetWxWxid() {
  38498. m.wx_wxid = nil
  38499. }
  38500. // SetChatroomID sets the "chatroom_id" field.
  38501. func (m *WpChatroomMutation) SetChatroomID(s string) {
  38502. m.chatroom_id = &s
  38503. }
  38504. // ChatroomID returns the value of the "chatroom_id" field in the mutation.
  38505. func (m *WpChatroomMutation) ChatroomID() (r string, exists bool) {
  38506. v := m.chatroom_id
  38507. if v == nil {
  38508. return
  38509. }
  38510. return *v, true
  38511. }
  38512. // OldChatroomID returns the old "chatroom_id" field's value of the WpChatroom entity.
  38513. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  38514. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38515. func (m *WpChatroomMutation) OldChatroomID(ctx context.Context) (v string, err error) {
  38516. if !m.op.Is(OpUpdateOne) {
  38517. return v, errors.New("OldChatroomID is only allowed on UpdateOne operations")
  38518. }
  38519. if m.id == nil || m.oldValue == nil {
  38520. return v, errors.New("OldChatroomID requires an ID field in the mutation")
  38521. }
  38522. oldValue, err := m.oldValue(ctx)
  38523. if err != nil {
  38524. return v, fmt.Errorf("querying old value for OldChatroomID: %w", err)
  38525. }
  38526. return oldValue.ChatroomID, nil
  38527. }
  38528. // ResetChatroomID resets all changes to the "chatroom_id" field.
  38529. func (m *WpChatroomMutation) ResetChatroomID() {
  38530. m.chatroom_id = nil
  38531. }
  38532. // SetNickname sets the "nickname" field.
  38533. func (m *WpChatroomMutation) SetNickname(s string) {
  38534. m.nickname = &s
  38535. }
  38536. // Nickname returns the value of the "nickname" field in the mutation.
  38537. func (m *WpChatroomMutation) Nickname() (r string, exists bool) {
  38538. v := m.nickname
  38539. if v == nil {
  38540. return
  38541. }
  38542. return *v, true
  38543. }
  38544. // OldNickname returns the old "nickname" field's value of the WpChatroom entity.
  38545. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  38546. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38547. func (m *WpChatroomMutation) OldNickname(ctx context.Context) (v string, err error) {
  38548. if !m.op.Is(OpUpdateOne) {
  38549. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  38550. }
  38551. if m.id == nil || m.oldValue == nil {
  38552. return v, errors.New("OldNickname requires an ID field in the mutation")
  38553. }
  38554. oldValue, err := m.oldValue(ctx)
  38555. if err != nil {
  38556. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  38557. }
  38558. return oldValue.Nickname, nil
  38559. }
  38560. // ResetNickname resets all changes to the "nickname" field.
  38561. func (m *WpChatroomMutation) ResetNickname() {
  38562. m.nickname = nil
  38563. }
  38564. // SetOwner sets the "owner" field.
  38565. func (m *WpChatroomMutation) SetOwner(s string) {
  38566. m.owner = &s
  38567. }
  38568. // Owner returns the value of the "owner" field in the mutation.
  38569. func (m *WpChatroomMutation) Owner() (r string, exists bool) {
  38570. v := m.owner
  38571. if v == nil {
  38572. return
  38573. }
  38574. return *v, true
  38575. }
  38576. // OldOwner returns the old "owner" field's value of the WpChatroom entity.
  38577. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  38578. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38579. func (m *WpChatroomMutation) OldOwner(ctx context.Context) (v string, err error) {
  38580. if !m.op.Is(OpUpdateOne) {
  38581. return v, errors.New("OldOwner is only allowed on UpdateOne operations")
  38582. }
  38583. if m.id == nil || m.oldValue == nil {
  38584. return v, errors.New("OldOwner requires an ID field in the mutation")
  38585. }
  38586. oldValue, err := m.oldValue(ctx)
  38587. if err != nil {
  38588. return v, fmt.Errorf("querying old value for OldOwner: %w", err)
  38589. }
  38590. return oldValue.Owner, nil
  38591. }
  38592. // ResetOwner resets all changes to the "owner" field.
  38593. func (m *WpChatroomMutation) ResetOwner() {
  38594. m.owner = nil
  38595. }
  38596. // SetAvatar sets the "avatar" field.
  38597. func (m *WpChatroomMutation) SetAvatar(s string) {
  38598. m.avatar = &s
  38599. }
  38600. // Avatar returns the value of the "avatar" field in the mutation.
  38601. func (m *WpChatroomMutation) Avatar() (r string, exists bool) {
  38602. v := m.avatar
  38603. if v == nil {
  38604. return
  38605. }
  38606. return *v, true
  38607. }
  38608. // OldAvatar returns the old "avatar" field's value of the WpChatroom entity.
  38609. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  38610. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38611. func (m *WpChatroomMutation) OldAvatar(ctx context.Context) (v string, err error) {
  38612. if !m.op.Is(OpUpdateOne) {
  38613. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  38614. }
  38615. if m.id == nil || m.oldValue == nil {
  38616. return v, errors.New("OldAvatar requires an ID field in the mutation")
  38617. }
  38618. oldValue, err := m.oldValue(ctx)
  38619. if err != nil {
  38620. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  38621. }
  38622. return oldValue.Avatar, nil
  38623. }
  38624. // ResetAvatar resets all changes to the "avatar" field.
  38625. func (m *WpChatroomMutation) ResetAvatar() {
  38626. m.avatar = nil
  38627. }
  38628. // SetMemberList sets the "member_list" field.
  38629. func (m *WpChatroomMutation) SetMemberList(s []string) {
  38630. m.member_list = &s
  38631. m.appendmember_list = nil
  38632. }
  38633. // MemberList returns the value of the "member_list" field in the mutation.
  38634. func (m *WpChatroomMutation) MemberList() (r []string, exists bool) {
  38635. v := m.member_list
  38636. if v == nil {
  38637. return
  38638. }
  38639. return *v, true
  38640. }
  38641. // OldMemberList returns the old "member_list" field's value of the WpChatroom entity.
  38642. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  38643. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38644. func (m *WpChatroomMutation) OldMemberList(ctx context.Context) (v []string, err error) {
  38645. if !m.op.Is(OpUpdateOne) {
  38646. return v, errors.New("OldMemberList is only allowed on UpdateOne operations")
  38647. }
  38648. if m.id == nil || m.oldValue == nil {
  38649. return v, errors.New("OldMemberList requires an ID field in the mutation")
  38650. }
  38651. oldValue, err := m.oldValue(ctx)
  38652. if err != nil {
  38653. return v, fmt.Errorf("querying old value for OldMemberList: %w", err)
  38654. }
  38655. return oldValue.MemberList, nil
  38656. }
  38657. // AppendMemberList adds s to the "member_list" field.
  38658. func (m *WpChatroomMutation) AppendMemberList(s []string) {
  38659. m.appendmember_list = append(m.appendmember_list, s...)
  38660. }
  38661. // AppendedMemberList returns the list of values that were appended to the "member_list" field in this mutation.
  38662. func (m *WpChatroomMutation) AppendedMemberList() ([]string, bool) {
  38663. if len(m.appendmember_list) == 0 {
  38664. return nil, false
  38665. }
  38666. return m.appendmember_list, true
  38667. }
  38668. // ResetMemberList resets all changes to the "member_list" field.
  38669. func (m *WpChatroomMutation) ResetMemberList() {
  38670. m.member_list = nil
  38671. m.appendmember_list = nil
  38672. }
  38673. // Where appends a list predicates to the WpChatroomMutation builder.
  38674. func (m *WpChatroomMutation) Where(ps ...predicate.WpChatroom) {
  38675. m.predicates = append(m.predicates, ps...)
  38676. }
  38677. // WhereP appends storage-level predicates to the WpChatroomMutation builder. Using this method,
  38678. // users can use type-assertion to append predicates that do not depend on any generated package.
  38679. func (m *WpChatroomMutation) WhereP(ps ...func(*sql.Selector)) {
  38680. p := make([]predicate.WpChatroom, len(ps))
  38681. for i := range ps {
  38682. p[i] = ps[i]
  38683. }
  38684. m.Where(p...)
  38685. }
  38686. // Op returns the operation name.
  38687. func (m *WpChatroomMutation) Op() Op {
  38688. return m.op
  38689. }
  38690. // SetOp allows setting the mutation operation.
  38691. func (m *WpChatroomMutation) SetOp(op Op) {
  38692. m.op = op
  38693. }
  38694. // Type returns the node type of this mutation (WpChatroom).
  38695. func (m *WpChatroomMutation) Type() string {
  38696. return m.typ
  38697. }
  38698. // Fields returns all fields that were changed during this mutation. Note that in
  38699. // order to get all numeric fields that were incremented/decremented, call
  38700. // AddedFields().
  38701. func (m *WpChatroomMutation) Fields() []string {
  38702. fields := make([]string, 0, 9)
  38703. if m.created_at != nil {
  38704. fields = append(fields, wpchatroom.FieldCreatedAt)
  38705. }
  38706. if m.updated_at != nil {
  38707. fields = append(fields, wpchatroom.FieldUpdatedAt)
  38708. }
  38709. if m.status != nil {
  38710. fields = append(fields, wpchatroom.FieldStatus)
  38711. }
  38712. if m.wx_wxid != nil {
  38713. fields = append(fields, wpchatroom.FieldWxWxid)
  38714. }
  38715. if m.chatroom_id != nil {
  38716. fields = append(fields, wpchatroom.FieldChatroomID)
  38717. }
  38718. if m.nickname != nil {
  38719. fields = append(fields, wpchatroom.FieldNickname)
  38720. }
  38721. if m.owner != nil {
  38722. fields = append(fields, wpchatroom.FieldOwner)
  38723. }
  38724. if m.avatar != nil {
  38725. fields = append(fields, wpchatroom.FieldAvatar)
  38726. }
  38727. if m.member_list != nil {
  38728. fields = append(fields, wpchatroom.FieldMemberList)
  38729. }
  38730. return fields
  38731. }
  38732. // Field returns the value of a field with the given name. The second boolean
  38733. // return value indicates that this field was not set, or was not defined in the
  38734. // schema.
  38735. func (m *WpChatroomMutation) Field(name string) (ent.Value, bool) {
  38736. switch name {
  38737. case wpchatroom.FieldCreatedAt:
  38738. return m.CreatedAt()
  38739. case wpchatroom.FieldUpdatedAt:
  38740. return m.UpdatedAt()
  38741. case wpchatroom.FieldStatus:
  38742. return m.Status()
  38743. case wpchatroom.FieldWxWxid:
  38744. return m.WxWxid()
  38745. case wpchatroom.FieldChatroomID:
  38746. return m.ChatroomID()
  38747. case wpchatroom.FieldNickname:
  38748. return m.Nickname()
  38749. case wpchatroom.FieldOwner:
  38750. return m.Owner()
  38751. case wpchatroom.FieldAvatar:
  38752. return m.Avatar()
  38753. case wpchatroom.FieldMemberList:
  38754. return m.MemberList()
  38755. }
  38756. return nil, false
  38757. }
  38758. // OldField returns the old value of the field from the database. An error is
  38759. // returned if the mutation operation is not UpdateOne, or the query to the
  38760. // database failed.
  38761. func (m *WpChatroomMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  38762. switch name {
  38763. case wpchatroom.FieldCreatedAt:
  38764. return m.OldCreatedAt(ctx)
  38765. case wpchatroom.FieldUpdatedAt:
  38766. return m.OldUpdatedAt(ctx)
  38767. case wpchatroom.FieldStatus:
  38768. return m.OldStatus(ctx)
  38769. case wpchatroom.FieldWxWxid:
  38770. return m.OldWxWxid(ctx)
  38771. case wpchatroom.FieldChatroomID:
  38772. return m.OldChatroomID(ctx)
  38773. case wpchatroom.FieldNickname:
  38774. return m.OldNickname(ctx)
  38775. case wpchatroom.FieldOwner:
  38776. return m.OldOwner(ctx)
  38777. case wpchatroom.FieldAvatar:
  38778. return m.OldAvatar(ctx)
  38779. case wpchatroom.FieldMemberList:
  38780. return m.OldMemberList(ctx)
  38781. }
  38782. return nil, fmt.Errorf("unknown WpChatroom field %s", name)
  38783. }
  38784. // SetField sets the value of a field with the given name. It returns an error if
  38785. // the field is not defined in the schema, or if the type mismatched the field
  38786. // type.
  38787. func (m *WpChatroomMutation) SetField(name string, value ent.Value) error {
  38788. switch name {
  38789. case wpchatroom.FieldCreatedAt:
  38790. v, ok := value.(time.Time)
  38791. if !ok {
  38792. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38793. }
  38794. m.SetCreatedAt(v)
  38795. return nil
  38796. case wpchatroom.FieldUpdatedAt:
  38797. v, ok := value.(time.Time)
  38798. if !ok {
  38799. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38800. }
  38801. m.SetUpdatedAt(v)
  38802. return nil
  38803. case wpchatroom.FieldStatus:
  38804. v, ok := value.(uint8)
  38805. if !ok {
  38806. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38807. }
  38808. m.SetStatus(v)
  38809. return nil
  38810. case wpchatroom.FieldWxWxid:
  38811. v, ok := value.(string)
  38812. if !ok {
  38813. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38814. }
  38815. m.SetWxWxid(v)
  38816. return nil
  38817. case wpchatroom.FieldChatroomID:
  38818. v, ok := value.(string)
  38819. if !ok {
  38820. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38821. }
  38822. m.SetChatroomID(v)
  38823. return nil
  38824. case wpchatroom.FieldNickname:
  38825. v, ok := value.(string)
  38826. if !ok {
  38827. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38828. }
  38829. m.SetNickname(v)
  38830. return nil
  38831. case wpchatroom.FieldOwner:
  38832. v, ok := value.(string)
  38833. if !ok {
  38834. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38835. }
  38836. m.SetOwner(v)
  38837. return nil
  38838. case wpchatroom.FieldAvatar:
  38839. v, ok := value.(string)
  38840. if !ok {
  38841. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38842. }
  38843. m.SetAvatar(v)
  38844. return nil
  38845. case wpchatroom.FieldMemberList:
  38846. v, ok := value.([]string)
  38847. if !ok {
  38848. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38849. }
  38850. m.SetMemberList(v)
  38851. return nil
  38852. }
  38853. return fmt.Errorf("unknown WpChatroom field %s", name)
  38854. }
  38855. // AddedFields returns all numeric fields that were incremented/decremented during
  38856. // this mutation.
  38857. func (m *WpChatroomMutation) AddedFields() []string {
  38858. var fields []string
  38859. if m.addstatus != nil {
  38860. fields = append(fields, wpchatroom.FieldStatus)
  38861. }
  38862. return fields
  38863. }
  38864. // AddedField returns the numeric value that was incremented/decremented on a field
  38865. // with the given name. The second boolean return value indicates that this field
  38866. // was not set, or was not defined in the schema.
  38867. func (m *WpChatroomMutation) AddedField(name string) (ent.Value, bool) {
  38868. switch name {
  38869. case wpchatroom.FieldStatus:
  38870. return m.AddedStatus()
  38871. }
  38872. return nil, false
  38873. }
  38874. // AddField adds the value to the field with the given name. It returns an error if
  38875. // the field is not defined in the schema, or if the type mismatched the field
  38876. // type.
  38877. func (m *WpChatroomMutation) AddField(name string, value ent.Value) error {
  38878. switch name {
  38879. case wpchatroom.FieldStatus:
  38880. v, ok := value.(int8)
  38881. if !ok {
  38882. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38883. }
  38884. m.AddStatus(v)
  38885. return nil
  38886. }
  38887. return fmt.Errorf("unknown WpChatroom numeric field %s", name)
  38888. }
  38889. // ClearedFields returns all nullable fields that were cleared during this
  38890. // mutation.
  38891. func (m *WpChatroomMutation) ClearedFields() []string {
  38892. var fields []string
  38893. if m.FieldCleared(wpchatroom.FieldStatus) {
  38894. fields = append(fields, wpchatroom.FieldStatus)
  38895. }
  38896. return fields
  38897. }
  38898. // FieldCleared returns a boolean indicating if a field with the given name was
  38899. // cleared in this mutation.
  38900. func (m *WpChatroomMutation) FieldCleared(name string) bool {
  38901. _, ok := m.clearedFields[name]
  38902. return ok
  38903. }
  38904. // ClearField clears the value of the field with the given name. It returns an
  38905. // error if the field is not defined in the schema.
  38906. func (m *WpChatroomMutation) ClearField(name string) error {
  38907. switch name {
  38908. case wpchatroom.FieldStatus:
  38909. m.ClearStatus()
  38910. return nil
  38911. }
  38912. return fmt.Errorf("unknown WpChatroom nullable field %s", name)
  38913. }
  38914. // ResetField resets all changes in the mutation for the field with the given name.
  38915. // It returns an error if the field is not defined in the schema.
  38916. func (m *WpChatroomMutation) ResetField(name string) error {
  38917. switch name {
  38918. case wpchatroom.FieldCreatedAt:
  38919. m.ResetCreatedAt()
  38920. return nil
  38921. case wpchatroom.FieldUpdatedAt:
  38922. m.ResetUpdatedAt()
  38923. return nil
  38924. case wpchatroom.FieldStatus:
  38925. m.ResetStatus()
  38926. return nil
  38927. case wpchatroom.FieldWxWxid:
  38928. m.ResetWxWxid()
  38929. return nil
  38930. case wpchatroom.FieldChatroomID:
  38931. m.ResetChatroomID()
  38932. return nil
  38933. case wpchatroom.FieldNickname:
  38934. m.ResetNickname()
  38935. return nil
  38936. case wpchatroom.FieldOwner:
  38937. m.ResetOwner()
  38938. return nil
  38939. case wpchatroom.FieldAvatar:
  38940. m.ResetAvatar()
  38941. return nil
  38942. case wpchatroom.FieldMemberList:
  38943. m.ResetMemberList()
  38944. return nil
  38945. }
  38946. return fmt.Errorf("unknown WpChatroom field %s", name)
  38947. }
  38948. // AddedEdges returns all edge names that were set/added in this mutation.
  38949. func (m *WpChatroomMutation) AddedEdges() []string {
  38950. edges := make([]string, 0, 0)
  38951. return edges
  38952. }
  38953. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  38954. // name in this mutation.
  38955. func (m *WpChatroomMutation) AddedIDs(name string) []ent.Value {
  38956. return nil
  38957. }
  38958. // RemovedEdges returns all edge names that were removed in this mutation.
  38959. func (m *WpChatroomMutation) RemovedEdges() []string {
  38960. edges := make([]string, 0, 0)
  38961. return edges
  38962. }
  38963. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  38964. // the given name in this mutation.
  38965. func (m *WpChatroomMutation) RemovedIDs(name string) []ent.Value {
  38966. return nil
  38967. }
  38968. // ClearedEdges returns all edge names that were cleared in this mutation.
  38969. func (m *WpChatroomMutation) ClearedEdges() []string {
  38970. edges := make([]string, 0, 0)
  38971. return edges
  38972. }
  38973. // EdgeCleared returns a boolean which indicates if the edge with the given name
  38974. // was cleared in this mutation.
  38975. func (m *WpChatroomMutation) EdgeCleared(name string) bool {
  38976. return false
  38977. }
  38978. // ClearEdge clears the value of the edge with the given name. It returns an error
  38979. // if that edge is not defined in the schema.
  38980. func (m *WpChatroomMutation) ClearEdge(name string) error {
  38981. return fmt.Errorf("unknown WpChatroom unique edge %s", name)
  38982. }
  38983. // ResetEdge resets all changes to the edge with the given name in this mutation.
  38984. // It returns an error if the edge is not defined in the schema.
  38985. func (m *WpChatroomMutation) ResetEdge(name string) error {
  38986. return fmt.Errorf("unknown WpChatroom edge %s", name)
  38987. }
  38988. // WpChatroomMemberMutation represents an operation that mutates the WpChatroomMember nodes in the graph.
  38989. type WpChatroomMemberMutation struct {
  38990. config
  38991. op Op
  38992. typ string
  38993. id *uint64
  38994. created_at *time.Time
  38995. updated_at *time.Time
  38996. status *uint8
  38997. addstatus *int8
  38998. wx_wxid *string
  38999. wxid *string
  39000. nickname *string
  39001. avatar *string
  39002. clearedFields map[string]struct{}
  39003. done bool
  39004. oldValue func(context.Context) (*WpChatroomMember, error)
  39005. predicates []predicate.WpChatroomMember
  39006. }
  39007. var _ ent.Mutation = (*WpChatroomMemberMutation)(nil)
  39008. // wpchatroommemberOption allows management of the mutation configuration using functional options.
  39009. type wpchatroommemberOption func(*WpChatroomMemberMutation)
  39010. // newWpChatroomMemberMutation creates new mutation for the WpChatroomMember entity.
  39011. func newWpChatroomMemberMutation(c config, op Op, opts ...wpchatroommemberOption) *WpChatroomMemberMutation {
  39012. m := &WpChatroomMemberMutation{
  39013. config: c,
  39014. op: op,
  39015. typ: TypeWpChatroomMember,
  39016. clearedFields: make(map[string]struct{}),
  39017. }
  39018. for _, opt := range opts {
  39019. opt(m)
  39020. }
  39021. return m
  39022. }
  39023. // withWpChatroomMemberID sets the ID field of the mutation.
  39024. func withWpChatroomMemberID(id uint64) wpchatroommemberOption {
  39025. return func(m *WpChatroomMemberMutation) {
  39026. var (
  39027. err error
  39028. once sync.Once
  39029. value *WpChatroomMember
  39030. )
  39031. m.oldValue = func(ctx context.Context) (*WpChatroomMember, error) {
  39032. once.Do(func() {
  39033. if m.done {
  39034. err = errors.New("querying old values post mutation is not allowed")
  39035. } else {
  39036. value, err = m.Client().WpChatroomMember.Get(ctx, id)
  39037. }
  39038. })
  39039. return value, err
  39040. }
  39041. m.id = &id
  39042. }
  39043. }
  39044. // withWpChatroomMember sets the old WpChatroomMember of the mutation.
  39045. func withWpChatroomMember(node *WpChatroomMember) wpchatroommemberOption {
  39046. return func(m *WpChatroomMemberMutation) {
  39047. m.oldValue = func(context.Context) (*WpChatroomMember, error) {
  39048. return node, nil
  39049. }
  39050. m.id = &node.ID
  39051. }
  39052. }
  39053. // Client returns a new `ent.Client` from the mutation. If the mutation was
  39054. // executed in a transaction (ent.Tx), a transactional client is returned.
  39055. func (m WpChatroomMemberMutation) Client() *Client {
  39056. client := &Client{config: m.config}
  39057. client.init()
  39058. return client
  39059. }
  39060. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  39061. // it returns an error otherwise.
  39062. func (m WpChatroomMemberMutation) Tx() (*Tx, error) {
  39063. if _, ok := m.driver.(*txDriver); !ok {
  39064. return nil, errors.New("ent: mutation is not running in a transaction")
  39065. }
  39066. tx := &Tx{config: m.config}
  39067. tx.init()
  39068. return tx, nil
  39069. }
  39070. // SetID sets the value of the id field. Note that this
  39071. // operation is only accepted on creation of WpChatroomMember entities.
  39072. func (m *WpChatroomMemberMutation) SetID(id uint64) {
  39073. m.id = &id
  39074. }
  39075. // ID returns the ID value in the mutation. Note that the ID is only available
  39076. // if it was provided to the builder or after it was returned from the database.
  39077. func (m *WpChatroomMemberMutation) ID() (id uint64, exists bool) {
  39078. if m.id == nil {
  39079. return
  39080. }
  39081. return *m.id, true
  39082. }
  39083. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  39084. // That means, if the mutation is applied within a transaction with an isolation level such
  39085. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  39086. // or updated by the mutation.
  39087. func (m *WpChatroomMemberMutation) IDs(ctx context.Context) ([]uint64, error) {
  39088. switch {
  39089. case m.op.Is(OpUpdateOne | OpDeleteOne):
  39090. id, exists := m.ID()
  39091. if exists {
  39092. return []uint64{id}, nil
  39093. }
  39094. fallthrough
  39095. case m.op.Is(OpUpdate | OpDelete):
  39096. return m.Client().WpChatroomMember.Query().Where(m.predicates...).IDs(ctx)
  39097. default:
  39098. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  39099. }
  39100. }
  39101. // SetCreatedAt sets the "created_at" field.
  39102. func (m *WpChatroomMemberMutation) SetCreatedAt(t time.Time) {
  39103. m.created_at = &t
  39104. }
  39105. // CreatedAt returns the value of the "created_at" field in the mutation.
  39106. func (m *WpChatroomMemberMutation) CreatedAt() (r time.Time, exists bool) {
  39107. v := m.created_at
  39108. if v == nil {
  39109. return
  39110. }
  39111. return *v, true
  39112. }
  39113. // OldCreatedAt returns the old "created_at" field's value of the WpChatroomMember entity.
  39114. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  39115. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39116. func (m *WpChatroomMemberMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  39117. if !m.op.Is(OpUpdateOne) {
  39118. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  39119. }
  39120. if m.id == nil || m.oldValue == nil {
  39121. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  39122. }
  39123. oldValue, err := m.oldValue(ctx)
  39124. if err != nil {
  39125. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  39126. }
  39127. return oldValue.CreatedAt, nil
  39128. }
  39129. // ResetCreatedAt resets all changes to the "created_at" field.
  39130. func (m *WpChatroomMemberMutation) ResetCreatedAt() {
  39131. m.created_at = nil
  39132. }
  39133. // SetUpdatedAt sets the "updated_at" field.
  39134. func (m *WpChatroomMemberMutation) SetUpdatedAt(t time.Time) {
  39135. m.updated_at = &t
  39136. }
  39137. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  39138. func (m *WpChatroomMemberMutation) UpdatedAt() (r time.Time, exists bool) {
  39139. v := m.updated_at
  39140. if v == nil {
  39141. return
  39142. }
  39143. return *v, true
  39144. }
  39145. // OldUpdatedAt returns the old "updated_at" field's value of the WpChatroomMember entity.
  39146. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  39147. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39148. func (m *WpChatroomMemberMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  39149. if !m.op.Is(OpUpdateOne) {
  39150. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  39151. }
  39152. if m.id == nil || m.oldValue == nil {
  39153. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  39154. }
  39155. oldValue, err := m.oldValue(ctx)
  39156. if err != nil {
  39157. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  39158. }
  39159. return oldValue.UpdatedAt, nil
  39160. }
  39161. // ResetUpdatedAt resets all changes to the "updated_at" field.
  39162. func (m *WpChatroomMemberMutation) ResetUpdatedAt() {
  39163. m.updated_at = nil
  39164. }
  39165. // SetStatus sets the "status" field.
  39166. func (m *WpChatroomMemberMutation) SetStatus(u uint8) {
  39167. m.status = &u
  39168. m.addstatus = nil
  39169. }
  39170. // Status returns the value of the "status" field in the mutation.
  39171. func (m *WpChatroomMemberMutation) Status() (r uint8, exists bool) {
  39172. v := m.status
  39173. if v == nil {
  39174. return
  39175. }
  39176. return *v, true
  39177. }
  39178. // OldStatus returns the old "status" field's value of the WpChatroomMember entity.
  39179. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  39180. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39181. func (m *WpChatroomMemberMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  39182. if !m.op.Is(OpUpdateOne) {
  39183. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  39184. }
  39185. if m.id == nil || m.oldValue == nil {
  39186. return v, errors.New("OldStatus requires an ID field in the mutation")
  39187. }
  39188. oldValue, err := m.oldValue(ctx)
  39189. if err != nil {
  39190. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  39191. }
  39192. return oldValue.Status, nil
  39193. }
  39194. // AddStatus adds u to the "status" field.
  39195. func (m *WpChatroomMemberMutation) AddStatus(u int8) {
  39196. if m.addstatus != nil {
  39197. *m.addstatus += u
  39198. } else {
  39199. m.addstatus = &u
  39200. }
  39201. }
  39202. // AddedStatus returns the value that was added to the "status" field in this mutation.
  39203. func (m *WpChatroomMemberMutation) AddedStatus() (r int8, exists bool) {
  39204. v := m.addstatus
  39205. if v == nil {
  39206. return
  39207. }
  39208. return *v, true
  39209. }
  39210. // ClearStatus clears the value of the "status" field.
  39211. func (m *WpChatroomMemberMutation) ClearStatus() {
  39212. m.status = nil
  39213. m.addstatus = nil
  39214. m.clearedFields[wpchatroommember.FieldStatus] = struct{}{}
  39215. }
  39216. // StatusCleared returns if the "status" field was cleared in this mutation.
  39217. func (m *WpChatroomMemberMutation) StatusCleared() bool {
  39218. _, ok := m.clearedFields[wpchatroommember.FieldStatus]
  39219. return ok
  39220. }
  39221. // ResetStatus resets all changes to the "status" field.
  39222. func (m *WpChatroomMemberMutation) ResetStatus() {
  39223. m.status = nil
  39224. m.addstatus = nil
  39225. delete(m.clearedFields, wpchatroommember.FieldStatus)
  39226. }
  39227. // SetWxWxid sets the "wx_wxid" field.
  39228. func (m *WpChatroomMemberMutation) SetWxWxid(s string) {
  39229. m.wx_wxid = &s
  39230. }
  39231. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  39232. func (m *WpChatroomMemberMutation) WxWxid() (r string, exists bool) {
  39233. v := m.wx_wxid
  39234. if v == nil {
  39235. return
  39236. }
  39237. return *v, true
  39238. }
  39239. // OldWxWxid returns the old "wx_wxid" field's value of the WpChatroomMember entity.
  39240. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  39241. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39242. func (m *WpChatroomMemberMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  39243. if !m.op.Is(OpUpdateOne) {
  39244. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  39245. }
  39246. if m.id == nil || m.oldValue == nil {
  39247. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  39248. }
  39249. oldValue, err := m.oldValue(ctx)
  39250. if err != nil {
  39251. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  39252. }
  39253. return oldValue.WxWxid, nil
  39254. }
  39255. // ResetWxWxid resets all changes to the "wx_wxid" field.
  39256. func (m *WpChatroomMemberMutation) ResetWxWxid() {
  39257. m.wx_wxid = nil
  39258. }
  39259. // SetWxid sets the "wxid" field.
  39260. func (m *WpChatroomMemberMutation) SetWxid(s string) {
  39261. m.wxid = &s
  39262. }
  39263. // Wxid returns the value of the "wxid" field in the mutation.
  39264. func (m *WpChatroomMemberMutation) Wxid() (r string, exists bool) {
  39265. v := m.wxid
  39266. if v == nil {
  39267. return
  39268. }
  39269. return *v, true
  39270. }
  39271. // OldWxid returns the old "wxid" field's value of the WpChatroomMember entity.
  39272. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  39273. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39274. func (m *WpChatroomMemberMutation) OldWxid(ctx context.Context) (v string, err error) {
  39275. if !m.op.Is(OpUpdateOne) {
  39276. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  39277. }
  39278. if m.id == nil || m.oldValue == nil {
  39279. return v, errors.New("OldWxid requires an ID field in the mutation")
  39280. }
  39281. oldValue, err := m.oldValue(ctx)
  39282. if err != nil {
  39283. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  39284. }
  39285. return oldValue.Wxid, nil
  39286. }
  39287. // ResetWxid resets all changes to the "wxid" field.
  39288. func (m *WpChatroomMemberMutation) ResetWxid() {
  39289. m.wxid = nil
  39290. }
  39291. // SetNickname sets the "nickname" field.
  39292. func (m *WpChatroomMemberMutation) SetNickname(s string) {
  39293. m.nickname = &s
  39294. }
  39295. // Nickname returns the value of the "nickname" field in the mutation.
  39296. func (m *WpChatroomMemberMutation) Nickname() (r string, exists bool) {
  39297. v := m.nickname
  39298. if v == nil {
  39299. return
  39300. }
  39301. return *v, true
  39302. }
  39303. // OldNickname returns the old "nickname" field's value of the WpChatroomMember entity.
  39304. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  39305. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39306. func (m *WpChatroomMemberMutation) OldNickname(ctx context.Context) (v string, err error) {
  39307. if !m.op.Is(OpUpdateOne) {
  39308. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  39309. }
  39310. if m.id == nil || m.oldValue == nil {
  39311. return v, errors.New("OldNickname requires an ID field in the mutation")
  39312. }
  39313. oldValue, err := m.oldValue(ctx)
  39314. if err != nil {
  39315. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  39316. }
  39317. return oldValue.Nickname, nil
  39318. }
  39319. // ResetNickname resets all changes to the "nickname" field.
  39320. func (m *WpChatroomMemberMutation) ResetNickname() {
  39321. m.nickname = nil
  39322. }
  39323. // SetAvatar sets the "avatar" field.
  39324. func (m *WpChatroomMemberMutation) SetAvatar(s string) {
  39325. m.avatar = &s
  39326. }
  39327. // Avatar returns the value of the "avatar" field in the mutation.
  39328. func (m *WpChatroomMemberMutation) Avatar() (r string, exists bool) {
  39329. v := m.avatar
  39330. if v == nil {
  39331. return
  39332. }
  39333. return *v, true
  39334. }
  39335. // OldAvatar returns the old "avatar" field's value of the WpChatroomMember entity.
  39336. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  39337. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39338. func (m *WpChatroomMemberMutation) OldAvatar(ctx context.Context) (v string, err error) {
  39339. if !m.op.Is(OpUpdateOne) {
  39340. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  39341. }
  39342. if m.id == nil || m.oldValue == nil {
  39343. return v, errors.New("OldAvatar requires an ID field in the mutation")
  39344. }
  39345. oldValue, err := m.oldValue(ctx)
  39346. if err != nil {
  39347. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  39348. }
  39349. return oldValue.Avatar, nil
  39350. }
  39351. // ResetAvatar resets all changes to the "avatar" field.
  39352. func (m *WpChatroomMemberMutation) ResetAvatar() {
  39353. m.avatar = nil
  39354. }
  39355. // Where appends a list predicates to the WpChatroomMemberMutation builder.
  39356. func (m *WpChatroomMemberMutation) Where(ps ...predicate.WpChatroomMember) {
  39357. m.predicates = append(m.predicates, ps...)
  39358. }
  39359. // WhereP appends storage-level predicates to the WpChatroomMemberMutation builder. Using this method,
  39360. // users can use type-assertion to append predicates that do not depend on any generated package.
  39361. func (m *WpChatroomMemberMutation) WhereP(ps ...func(*sql.Selector)) {
  39362. p := make([]predicate.WpChatroomMember, len(ps))
  39363. for i := range ps {
  39364. p[i] = ps[i]
  39365. }
  39366. m.Where(p...)
  39367. }
  39368. // Op returns the operation name.
  39369. func (m *WpChatroomMemberMutation) Op() Op {
  39370. return m.op
  39371. }
  39372. // SetOp allows setting the mutation operation.
  39373. func (m *WpChatroomMemberMutation) SetOp(op Op) {
  39374. m.op = op
  39375. }
  39376. // Type returns the node type of this mutation (WpChatroomMember).
  39377. func (m *WpChatroomMemberMutation) Type() string {
  39378. return m.typ
  39379. }
  39380. // Fields returns all fields that were changed during this mutation. Note that in
  39381. // order to get all numeric fields that were incremented/decremented, call
  39382. // AddedFields().
  39383. func (m *WpChatroomMemberMutation) Fields() []string {
  39384. fields := make([]string, 0, 7)
  39385. if m.created_at != nil {
  39386. fields = append(fields, wpchatroommember.FieldCreatedAt)
  39387. }
  39388. if m.updated_at != nil {
  39389. fields = append(fields, wpchatroommember.FieldUpdatedAt)
  39390. }
  39391. if m.status != nil {
  39392. fields = append(fields, wpchatroommember.FieldStatus)
  39393. }
  39394. if m.wx_wxid != nil {
  39395. fields = append(fields, wpchatroommember.FieldWxWxid)
  39396. }
  39397. if m.wxid != nil {
  39398. fields = append(fields, wpchatroommember.FieldWxid)
  39399. }
  39400. if m.nickname != nil {
  39401. fields = append(fields, wpchatroommember.FieldNickname)
  39402. }
  39403. if m.avatar != nil {
  39404. fields = append(fields, wpchatroommember.FieldAvatar)
  39405. }
  39406. return fields
  39407. }
  39408. // Field returns the value of a field with the given name. The second boolean
  39409. // return value indicates that this field was not set, or was not defined in the
  39410. // schema.
  39411. func (m *WpChatroomMemberMutation) Field(name string) (ent.Value, bool) {
  39412. switch name {
  39413. case wpchatroommember.FieldCreatedAt:
  39414. return m.CreatedAt()
  39415. case wpchatroommember.FieldUpdatedAt:
  39416. return m.UpdatedAt()
  39417. case wpchatroommember.FieldStatus:
  39418. return m.Status()
  39419. case wpchatroommember.FieldWxWxid:
  39420. return m.WxWxid()
  39421. case wpchatroommember.FieldWxid:
  39422. return m.Wxid()
  39423. case wpchatroommember.FieldNickname:
  39424. return m.Nickname()
  39425. case wpchatroommember.FieldAvatar:
  39426. return m.Avatar()
  39427. }
  39428. return nil, false
  39429. }
  39430. // OldField returns the old value of the field from the database. An error is
  39431. // returned if the mutation operation is not UpdateOne, or the query to the
  39432. // database failed.
  39433. func (m *WpChatroomMemberMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  39434. switch name {
  39435. case wpchatroommember.FieldCreatedAt:
  39436. return m.OldCreatedAt(ctx)
  39437. case wpchatroommember.FieldUpdatedAt:
  39438. return m.OldUpdatedAt(ctx)
  39439. case wpchatroommember.FieldStatus:
  39440. return m.OldStatus(ctx)
  39441. case wpchatroommember.FieldWxWxid:
  39442. return m.OldWxWxid(ctx)
  39443. case wpchatroommember.FieldWxid:
  39444. return m.OldWxid(ctx)
  39445. case wpchatroommember.FieldNickname:
  39446. return m.OldNickname(ctx)
  39447. case wpchatroommember.FieldAvatar:
  39448. return m.OldAvatar(ctx)
  39449. }
  39450. return nil, fmt.Errorf("unknown WpChatroomMember field %s", name)
  39451. }
  39452. // SetField sets the value of a field with the given name. It returns an error if
  39453. // the field is not defined in the schema, or if the type mismatched the field
  39454. // type.
  39455. func (m *WpChatroomMemberMutation) SetField(name string, value ent.Value) error {
  39456. switch name {
  39457. case wpchatroommember.FieldCreatedAt:
  39458. v, ok := value.(time.Time)
  39459. if !ok {
  39460. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39461. }
  39462. m.SetCreatedAt(v)
  39463. return nil
  39464. case wpchatroommember.FieldUpdatedAt:
  39465. v, ok := value.(time.Time)
  39466. if !ok {
  39467. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39468. }
  39469. m.SetUpdatedAt(v)
  39470. return nil
  39471. case wpchatroommember.FieldStatus:
  39472. v, ok := value.(uint8)
  39473. if !ok {
  39474. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39475. }
  39476. m.SetStatus(v)
  39477. return nil
  39478. case wpchatroommember.FieldWxWxid:
  39479. v, ok := value.(string)
  39480. if !ok {
  39481. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39482. }
  39483. m.SetWxWxid(v)
  39484. return nil
  39485. case wpchatroommember.FieldWxid:
  39486. v, ok := value.(string)
  39487. if !ok {
  39488. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39489. }
  39490. m.SetWxid(v)
  39491. return nil
  39492. case wpchatroommember.FieldNickname:
  39493. v, ok := value.(string)
  39494. if !ok {
  39495. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39496. }
  39497. m.SetNickname(v)
  39498. return nil
  39499. case wpchatroommember.FieldAvatar:
  39500. v, ok := value.(string)
  39501. if !ok {
  39502. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39503. }
  39504. m.SetAvatar(v)
  39505. return nil
  39506. }
  39507. return fmt.Errorf("unknown WpChatroomMember field %s", name)
  39508. }
  39509. // AddedFields returns all numeric fields that were incremented/decremented during
  39510. // this mutation.
  39511. func (m *WpChatroomMemberMutation) AddedFields() []string {
  39512. var fields []string
  39513. if m.addstatus != nil {
  39514. fields = append(fields, wpchatroommember.FieldStatus)
  39515. }
  39516. return fields
  39517. }
  39518. // AddedField returns the numeric value that was incremented/decremented on a field
  39519. // with the given name. The second boolean return value indicates that this field
  39520. // was not set, or was not defined in the schema.
  39521. func (m *WpChatroomMemberMutation) AddedField(name string) (ent.Value, bool) {
  39522. switch name {
  39523. case wpchatroommember.FieldStatus:
  39524. return m.AddedStatus()
  39525. }
  39526. return nil, false
  39527. }
  39528. // AddField adds the value to the field with the given name. It returns an error if
  39529. // the field is not defined in the schema, or if the type mismatched the field
  39530. // type.
  39531. func (m *WpChatroomMemberMutation) AddField(name string, value ent.Value) error {
  39532. switch name {
  39533. case wpchatroommember.FieldStatus:
  39534. v, ok := value.(int8)
  39535. if !ok {
  39536. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39537. }
  39538. m.AddStatus(v)
  39539. return nil
  39540. }
  39541. return fmt.Errorf("unknown WpChatroomMember numeric field %s", name)
  39542. }
  39543. // ClearedFields returns all nullable fields that were cleared during this
  39544. // mutation.
  39545. func (m *WpChatroomMemberMutation) ClearedFields() []string {
  39546. var fields []string
  39547. if m.FieldCleared(wpchatroommember.FieldStatus) {
  39548. fields = append(fields, wpchatroommember.FieldStatus)
  39549. }
  39550. return fields
  39551. }
  39552. // FieldCleared returns a boolean indicating if a field with the given name was
  39553. // cleared in this mutation.
  39554. func (m *WpChatroomMemberMutation) FieldCleared(name string) bool {
  39555. _, ok := m.clearedFields[name]
  39556. return ok
  39557. }
  39558. // ClearField clears the value of the field with the given name. It returns an
  39559. // error if the field is not defined in the schema.
  39560. func (m *WpChatroomMemberMutation) ClearField(name string) error {
  39561. switch name {
  39562. case wpchatroommember.FieldStatus:
  39563. m.ClearStatus()
  39564. return nil
  39565. }
  39566. return fmt.Errorf("unknown WpChatroomMember nullable field %s", name)
  39567. }
  39568. // ResetField resets all changes in the mutation for the field with the given name.
  39569. // It returns an error if the field is not defined in the schema.
  39570. func (m *WpChatroomMemberMutation) ResetField(name string) error {
  39571. switch name {
  39572. case wpchatroommember.FieldCreatedAt:
  39573. m.ResetCreatedAt()
  39574. return nil
  39575. case wpchatroommember.FieldUpdatedAt:
  39576. m.ResetUpdatedAt()
  39577. return nil
  39578. case wpchatroommember.FieldStatus:
  39579. m.ResetStatus()
  39580. return nil
  39581. case wpchatroommember.FieldWxWxid:
  39582. m.ResetWxWxid()
  39583. return nil
  39584. case wpchatroommember.FieldWxid:
  39585. m.ResetWxid()
  39586. return nil
  39587. case wpchatroommember.FieldNickname:
  39588. m.ResetNickname()
  39589. return nil
  39590. case wpchatroommember.FieldAvatar:
  39591. m.ResetAvatar()
  39592. return nil
  39593. }
  39594. return fmt.Errorf("unknown WpChatroomMember field %s", name)
  39595. }
  39596. // AddedEdges returns all edge names that were set/added in this mutation.
  39597. func (m *WpChatroomMemberMutation) AddedEdges() []string {
  39598. edges := make([]string, 0, 0)
  39599. return edges
  39600. }
  39601. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  39602. // name in this mutation.
  39603. func (m *WpChatroomMemberMutation) AddedIDs(name string) []ent.Value {
  39604. return nil
  39605. }
  39606. // RemovedEdges returns all edge names that were removed in this mutation.
  39607. func (m *WpChatroomMemberMutation) RemovedEdges() []string {
  39608. edges := make([]string, 0, 0)
  39609. return edges
  39610. }
  39611. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  39612. // the given name in this mutation.
  39613. func (m *WpChatroomMemberMutation) RemovedIDs(name string) []ent.Value {
  39614. return nil
  39615. }
  39616. // ClearedEdges returns all edge names that were cleared in this mutation.
  39617. func (m *WpChatroomMemberMutation) ClearedEdges() []string {
  39618. edges := make([]string, 0, 0)
  39619. return edges
  39620. }
  39621. // EdgeCleared returns a boolean which indicates if the edge with the given name
  39622. // was cleared in this mutation.
  39623. func (m *WpChatroomMemberMutation) EdgeCleared(name string) bool {
  39624. return false
  39625. }
  39626. // ClearEdge clears the value of the edge with the given name. It returns an error
  39627. // if that edge is not defined in the schema.
  39628. func (m *WpChatroomMemberMutation) ClearEdge(name string) error {
  39629. return fmt.Errorf("unknown WpChatroomMember unique edge %s", name)
  39630. }
  39631. // ResetEdge resets all changes to the edge with the given name in this mutation.
  39632. // It returns an error if the edge is not defined in the schema.
  39633. func (m *WpChatroomMemberMutation) ResetEdge(name string) error {
  39634. return fmt.Errorf("unknown WpChatroomMember edge %s", name)
  39635. }
  39636. // WxMutation represents an operation that mutates the Wx nodes in the graph.
  39637. type WxMutation struct {
  39638. config
  39639. op Op
  39640. typ string
  39641. id *uint64
  39642. created_at *time.Time
  39643. updated_at *time.Time
  39644. status *uint8
  39645. addstatus *int8
  39646. deleted_at *time.Time
  39647. port *string
  39648. process_id *string
  39649. callback *string
  39650. wxid *string
  39651. account *string
  39652. nickname *string
  39653. tel *string
  39654. head_big *string
  39655. organization_id *uint64
  39656. addorganization_id *int64
  39657. api_base *string
  39658. api_key *string
  39659. allow_list *[]string
  39660. appendallow_list []string
  39661. group_allow_list *[]string
  39662. appendgroup_allow_list []string
  39663. block_list *[]string
  39664. appendblock_list []string
  39665. group_block_list *[]string
  39666. appendgroup_block_list []string
  39667. clearedFields map[string]struct{}
  39668. server *uint64
  39669. clearedserver bool
  39670. agent *uint64
  39671. clearedagent bool
  39672. done bool
  39673. oldValue func(context.Context) (*Wx, error)
  39674. predicates []predicate.Wx
  39675. }
  39676. var _ ent.Mutation = (*WxMutation)(nil)
  39677. // wxOption allows management of the mutation configuration using functional options.
  39678. type wxOption func(*WxMutation)
  39679. // newWxMutation creates new mutation for the Wx entity.
  39680. func newWxMutation(c config, op Op, opts ...wxOption) *WxMutation {
  39681. m := &WxMutation{
  39682. config: c,
  39683. op: op,
  39684. typ: TypeWx,
  39685. clearedFields: make(map[string]struct{}),
  39686. }
  39687. for _, opt := range opts {
  39688. opt(m)
  39689. }
  39690. return m
  39691. }
  39692. // withWxID sets the ID field of the mutation.
  39693. func withWxID(id uint64) wxOption {
  39694. return func(m *WxMutation) {
  39695. var (
  39696. err error
  39697. once sync.Once
  39698. value *Wx
  39699. )
  39700. m.oldValue = func(ctx context.Context) (*Wx, error) {
  39701. once.Do(func() {
  39702. if m.done {
  39703. err = errors.New("querying old values post mutation is not allowed")
  39704. } else {
  39705. value, err = m.Client().Wx.Get(ctx, id)
  39706. }
  39707. })
  39708. return value, err
  39709. }
  39710. m.id = &id
  39711. }
  39712. }
  39713. // withWx sets the old Wx of the mutation.
  39714. func withWx(node *Wx) wxOption {
  39715. return func(m *WxMutation) {
  39716. m.oldValue = func(context.Context) (*Wx, error) {
  39717. return node, nil
  39718. }
  39719. m.id = &node.ID
  39720. }
  39721. }
  39722. // Client returns a new `ent.Client` from the mutation. If the mutation was
  39723. // executed in a transaction (ent.Tx), a transactional client is returned.
  39724. func (m WxMutation) Client() *Client {
  39725. client := &Client{config: m.config}
  39726. client.init()
  39727. return client
  39728. }
  39729. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  39730. // it returns an error otherwise.
  39731. func (m WxMutation) Tx() (*Tx, error) {
  39732. if _, ok := m.driver.(*txDriver); !ok {
  39733. return nil, errors.New("ent: mutation is not running in a transaction")
  39734. }
  39735. tx := &Tx{config: m.config}
  39736. tx.init()
  39737. return tx, nil
  39738. }
  39739. // SetID sets the value of the id field. Note that this
  39740. // operation is only accepted on creation of Wx entities.
  39741. func (m *WxMutation) SetID(id uint64) {
  39742. m.id = &id
  39743. }
  39744. // ID returns the ID value in the mutation. Note that the ID is only available
  39745. // if it was provided to the builder or after it was returned from the database.
  39746. func (m *WxMutation) ID() (id uint64, exists bool) {
  39747. if m.id == nil {
  39748. return
  39749. }
  39750. return *m.id, true
  39751. }
  39752. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  39753. // That means, if the mutation is applied within a transaction with an isolation level such
  39754. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  39755. // or updated by the mutation.
  39756. func (m *WxMutation) IDs(ctx context.Context) ([]uint64, error) {
  39757. switch {
  39758. case m.op.Is(OpUpdateOne | OpDeleteOne):
  39759. id, exists := m.ID()
  39760. if exists {
  39761. return []uint64{id}, nil
  39762. }
  39763. fallthrough
  39764. case m.op.Is(OpUpdate | OpDelete):
  39765. return m.Client().Wx.Query().Where(m.predicates...).IDs(ctx)
  39766. default:
  39767. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  39768. }
  39769. }
  39770. // SetCreatedAt sets the "created_at" field.
  39771. func (m *WxMutation) SetCreatedAt(t time.Time) {
  39772. m.created_at = &t
  39773. }
  39774. // CreatedAt returns the value of the "created_at" field in the mutation.
  39775. func (m *WxMutation) CreatedAt() (r time.Time, exists bool) {
  39776. v := m.created_at
  39777. if v == nil {
  39778. return
  39779. }
  39780. return *v, true
  39781. }
  39782. // OldCreatedAt returns the old "created_at" field's value of the Wx entity.
  39783. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  39784. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39785. func (m *WxMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  39786. if !m.op.Is(OpUpdateOne) {
  39787. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  39788. }
  39789. if m.id == nil || m.oldValue == nil {
  39790. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  39791. }
  39792. oldValue, err := m.oldValue(ctx)
  39793. if err != nil {
  39794. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  39795. }
  39796. return oldValue.CreatedAt, nil
  39797. }
  39798. // ResetCreatedAt resets all changes to the "created_at" field.
  39799. func (m *WxMutation) ResetCreatedAt() {
  39800. m.created_at = nil
  39801. }
  39802. // SetUpdatedAt sets the "updated_at" field.
  39803. func (m *WxMutation) SetUpdatedAt(t time.Time) {
  39804. m.updated_at = &t
  39805. }
  39806. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  39807. func (m *WxMutation) UpdatedAt() (r time.Time, exists bool) {
  39808. v := m.updated_at
  39809. if v == nil {
  39810. return
  39811. }
  39812. return *v, true
  39813. }
  39814. // OldUpdatedAt returns the old "updated_at" field's value of the Wx entity.
  39815. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  39816. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39817. func (m *WxMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  39818. if !m.op.Is(OpUpdateOne) {
  39819. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  39820. }
  39821. if m.id == nil || m.oldValue == nil {
  39822. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  39823. }
  39824. oldValue, err := m.oldValue(ctx)
  39825. if err != nil {
  39826. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  39827. }
  39828. return oldValue.UpdatedAt, nil
  39829. }
  39830. // ResetUpdatedAt resets all changes to the "updated_at" field.
  39831. func (m *WxMutation) ResetUpdatedAt() {
  39832. m.updated_at = nil
  39833. }
  39834. // SetStatus sets the "status" field.
  39835. func (m *WxMutation) SetStatus(u uint8) {
  39836. m.status = &u
  39837. m.addstatus = nil
  39838. }
  39839. // Status returns the value of the "status" field in the mutation.
  39840. func (m *WxMutation) Status() (r uint8, exists bool) {
  39841. v := m.status
  39842. if v == nil {
  39843. return
  39844. }
  39845. return *v, true
  39846. }
  39847. // OldStatus returns the old "status" field's value of the Wx entity.
  39848. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  39849. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39850. func (m *WxMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  39851. if !m.op.Is(OpUpdateOne) {
  39852. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  39853. }
  39854. if m.id == nil || m.oldValue == nil {
  39855. return v, errors.New("OldStatus requires an ID field in the mutation")
  39856. }
  39857. oldValue, err := m.oldValue(ctx)
  39858. if err != nil {
  39859. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  39860. }
  39861. return oldValue.Status, nil
  39862. }
  39863. // AddStatus adds u to the "status" field.
  39864. func (m *WxMutation) AddStatus(u int8) {
  39865. if m.addstatus != nil {
  39866. *m.addstatus += u
  39867. } else {
  39868. m.addstatus = &u
  39869. }
  39870. }
  39871. // AddedStatus returns the value that was added to the "status" field in this mutation.
  39872. func (m *WxMutation) AddedStatus() (r int8, exists bool) {
  39873. v := m.addstatus
  39874. if v == nil {
  39875. return
  39876. }
  39877. return *v, true
  39878. }
  39879. // ClearStatus clears the value of the "status" field.
  39880. func (m *WxMutation) ClearStatus() {
  39881. m.status = nil
  39882. m.addstatus = nil
  39883. m.clearedFields[wx.FieldStatus] = struct{}{}
  39884. }
  39885. // StatusCleared returns if the "status" field was cleared in this mutation.
  39886. func (m *WxMutation) StatusCleared() bool {
  39887. _, ok := m.clearedFields[wx.FieldStatus]
  39888. return ok
  39889. }
  39890. // ResetStatus resets all changes to the "status" field.
  39891. func (m *WxMutation) ResetStatus() {
  39892. m.status = nil
  39893. m.addstatus = nil
  39894. delete(m.clearedFields, wx.FieldStatus)
  39895. }
  39896. // SetDeletedAt sets the "deleted_at" field.
  39897. func (m *WxMutation) SetDeletedAt(t time.Time) {
  39898. m.deleted_at = &t
  39899. }
  39900. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  39901. func (m *WxMutation) DeletedAt() (r time.Time, exists bool) {
  39902. v := m.deleted_at
  39903. if v == nil {
  39904. return
  39905. }
  39906. return *v, true
  39907. }
  39908. // OldDeletedAt returns the old "deleted_at" field's value of the Wx entity.
  39909. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  39910. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39911. func (m *WxMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  39912. if !m.op.Is(OpUpdateOne) {
  39913. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  39914. }
  39915. if m.id == nil || m.oldValue == nil {
  39916. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  39917. }
  39918. oldValue, err := m.oldValue(ctx)
  39919. if err != nil {
  39920. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  39921. }
  39922. return oldValue.DeletedAt, nil
  39923. }
  39924. // ClearDeletedAt clears the value of the "deleted_at" field.
  39925. func (m *WxMutation) ClearDeletedAt() {
  39926. m.deleted_at = nil
  39927. m.clearedFields[wx.FieldDeletedAt] = struct{}{}
  39928. }
  39929. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  39930. func (m *WxMutation) DeletedAtCleared() bool {
  39931. _, ok := m.clearedFields[wx.FieldDeletedAt]
  39932. return ok
  39933. }
  39934. // ResetDeletedAt resets all changes to the "deleted_at" field.
  39935. func (m *WxMutation) ResetDeletedAt() {
  39936. m.deleted_at = nil
  39937. delete(m.clearedFields, wx.FieldDeletedAt)
  39938. }
  39939. // SetServerID sets the "server_id" field.
  39940. func (m *WxMutation) SetServerID(u uint64) {
  39941. m.server = &u
  39942. }
  39943. // ServerID returns the value of the "server_id" field in the mutation.
  39944. func (m *WxMutation) ServerID() (r uint64, exists bool) {
  39945. v := m.server
  39946. if v == nil {
  39947. return
  39948. }
  39949. return *v, true
  39950. }
  39951. // OldServerID returns the old "server_id" field's value of the Wx entity.
  39952. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  39953. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39954. func (m *WxMutation) OldServerID(ctx context.Context) (v uint64, err error) {
  39955. if !m.op.Is(OpUpdateOne) {
  39956. return v, errors.New("OldServerID is only allowed on UpdateOne operations")
  39957. }
  39958. if m.id == nil || m.oldValue == nil {
  39959. return v, errors.New("OldServerID requires an ID field in the mutation")
  39960. }
  39961. oldValue, err := m.oldValue(ctx)
  39962. if err != nil {
  39963. return v, fmt.Errorf("querying old value for OldServerID: %w", err)
  39964. }
  39965. return oldValue.ServerID, nil
  39966. }
  39967. // ClearServerID clears the value of the "server_id" field.
  39968. func (m *WxMutation) ClearServerID() {
  39969. m.server = nil
  39970. m.clearedFields[wx.FieldServerID] = struct{}{}
  39971. }
  39972. // ServerIDCleared returns if the "server_id" field was cleared in this mutation.
  39973. func (m *WxMutation) ServerIDCleared() bool {
  39974. _, ok := m.clearedFields[wx.FieldServerID]
  39975. return ok
  39976. }
  39977. // ResetServerID resets all changes to the "server_id" field.
  39978. func (m *WxMutation) ResetServerID() {
  39979. m.server = nil
  39980. delete(m.clearedFields, wx.FieldServerID)
  39981. }
  39982. // SetPort sets the "port" field.
  39983. func (m *WxMutation) SetPort(s string) {
  39984. m.port = &s
  39985. }
  39986. // Port returns the value of the "port" field in the mutation.
  39987. func (m *WxMutation) Port() (r string, exists bool) {
  39988. v := m.port
  39989. if v == nil {
  39990. return
  39991. }
  39992. return *v, true
  39993. }
  39994. // OldPort returns the old "port" field's value of the Wx entity.
  39995. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  39996. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39997. func (m *WxMutation) OldPort(ctx context.Context) (v string, err error) {
  39998. if !m.op.Is(OpUpdateOne) {
  39999. return v, errors.New("OldPort is only allowed on UpdateOne operations")
  40000. }
  40001. if m.id == nil || m.oldValue == nil {
  40002. return v, errors.New("OldPort requires an ID field in the mutation")
  40003. }
  40004. oldValue, err := m.oldValue(ctx)
  40005. if err != nil {
  40006. return v, fmt.Errorf("querying old value for OldPort: %w", err)
  40007. }
  40008. return oldValue.Port, nil
  40009. }
  40010. // ResetPort resets all changes to the "port" field.
  40011. func (m *WxMutation) ResetPort() {
  40012. m.port = nil
  40013. }
  40014. // SetProcessID sets the "process_id" field.
  40015. func (m *WxMutation) SetProcessID(s string) {
  40016. m.process_id = &s
  40017. }
  40018. // ProcessID returns the value of the "process_id" field in the mutation.
  40019. func (m *WxMutation) ProcessID() (r string, exists bool) {
  40020. v := m.process_id
  40021. if v == nil {
  40022. return
  40023. }
  40024. return *v, true
  40025. }
  40026. // OldProcessID returns the old "process_id" field's value of the Wx entity.
  40027. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40028. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40029. func (m *WxMutation) OldProcessID(ctx context.Context) (v string, err error) {
  40030. if !m.op.Is(OpUpdateOne) {
  40031. return v, errors.New("OldProcessID is only allowed on UpdateOne operations")
  40032. }
  40033. if m.id == nil || m.oldValue == nil {
  40034. return v, errors.New("OldProcessID requires an ID field in the mutation")
  40035. }
  40036. oldValue, err := m.oldValue(ctx)
  40037. if err != nil {
  40038. return v, fmt.Errorf("querying old value for OldProcessID: %w", err)
  40039. }
  40040. return oldValue.ProcessID, nil
  40041. }
  40042. // ResetProcessID resets all changes to the "process_id" field.
  40043. func (m *WxMutation) ResetProcessID() {
  40044. m.process_id = nil
  40045. }
  40046. // SetCallback sets the "callback" field.
  40047. func (m *WxMutation) SetCallback(s string) {
  40048. m.callback = &s
  40049. }
  40050. // Callback returns the value of the "callback" field in the mutation.
  40051. func (m *WxMutation) Callback() (r string, exists bool) {
  40052. v := m.callback
  40053. if v == nil {
  40054. return
  40055. }
  40056. return *v, true
  40057. }
  40058. // OldCallback returns the old "callback" field's value of the Wx entity.
  40059. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40060. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40061. func (m *WxMutation) OldCallback(ctx context.Context) (v string, err error) {
  40062. if !m.op.Is(OpUpdateOne) {
  40063. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  40064. }
  40065. if m.id == nil || m.oldValue == nil {
  40066. return v, errors.New("OldCallback requires an ID field in the mutation")
  40067. }
  40068. oldValue, err := m.oldValue(ctx)
  40069. if err != nil {
  40070. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  40071. }
  40072. return oldValue.Callback, nil
  40073. }
  40074. // ResetCallback resets all changes to the "callback" field.
  40075. func (m *WxMutation) ResetCallback() {
  40076. m.callback = nil
  40077. }
  40078. // SetWxid sets the "wxid" field.
  40079. func (m *WxMutation) SetWxid(s string) {
  40080. m.wxid = &s
  40081. }
  40082. // Wxid returns the value of the "wxid" field in the mutation.
  40083. func (m *WxMutation) Wxid() (r string, exists bool) {
  40084. v := m.wxid
  40085. if v == nil {
  40086. return
  40087. }
  40088. return *v, true
  40089. }
  40090. // OldWxid returns the old "wxid" 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) OldWxid(ctx context.Context) (v string, err error) {
  40094. if !m.op.Is(OpUpdateOne) {
  40095. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  40096. }
  40097. if m.id == nil || m.oldValue == nil {
  40098. return v, errors.New("OldWxid 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 OldWxid: %w", err)
  40103. }
  40104. return oldValue.Wxid, nil
  40105. }
  40106. // ResetWxid resets all changes to the "wxid" field.
  40107. func (m *WxMutation) ResetWxid() {
  40108. m.wxid = nil
  40109. }
  40110. // SetAccount sets the "account" field.
  40111. func (m *WxMutation) SetAccount(s string) {
  40112. m.account = &s
  40113. }
  40114. // Account returns the value of the "account" field in the mutation.
  40115. func (m *WxMutation) Account() (r string, exists bool) {
  40116. v := m.account
  40117. if v == nil {
  40118. return
  40119. }
  40120. return *v, true
  40121. }
  40122. // OldAccount returns the old "account" field's value of the Wx entity.
  40123. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40124. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40125. func (m *WxMutation) OldAccount(ctx context.Context) (v string, err error) {
  40126. if !m.op.Is(OpUpdateOne) {
  40127. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  40128. }
  40129. if m.id == nil || m.oldValue == nil {
  40130. return v, errors.New("OldAccount requires an ID field in the mutation")
  40131. }
  40132. oldValue, err := m.oldValue(ctx)
  40133. if err != nil {
  40134. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  40135. }
  40136. return oldValue.Account, nil
  40137. }
  40138. // ResetAccount resets all changes to the "account" field.
  40139. func (m *WxMutation) ResetAccount() {
  40140. m.account = nil
  40141. }
  40142. // SetNickname sets the "nickname" field.
  40143. func (m *WxMutation) SetNickname(s string) {
  40144. m.nickname = &s
  40145. }
  40146. // Nickname returns the value of the "nickname" field in the mutation.
  40147. func (m *WxMutation) Nickname() (r string, exists bool) {
  40148. v := m.nickname
  40149. if v == nil {
  40150. return
  40151. }
  40152. return *v, true
  40153. }
  40154. // OldNickname returns the old "nickname" field's value of the Wx entity.
  40155. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40156. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40157. func (m *WxMutation) OldNickname(ctx context.Context) (v string, err error) {
  40158. if !m.op.Is(OpUpdateOne) {
  40159. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  40160. }
  40161. if m.id == nil || m.oldValue == nil {
  40162. return v, errors.New("OldNickname requires an ID field in the mutation")
  40163. }
  40164. oldValue, err := m.oldValue(ctx)
  40165. if err != nil {
  40166. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  40167. }
  40168. return oldValue.Nickname, nil
  40169. }
  40170. // ResetNickname resets all changes to the "nickname" field.
  40171. func (m *WxMutation) ResetNickname() {
  40172. m.nickname = nil
  40173. }
  40174. // SetTel sets the "tel" field.
  40175. func (m *WxMutation) SetTel(s string) {
  40176. m.tel = &s
  40177. }
  40178. // Tel returns the value of the "tel" field in the mutation.
  40179. func (m *WxMutation) Tel() (r string, exists bool) {
  40180. v := m.tel
  40181. if v == nil {
  40182. return
  40183. }
  40184. return *v, true
  40185. }
  40186. // OldTel returns the old "tel" field's value of the Wx entity.
  40187. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40188. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40189. func (m *WxMutation) OldTel(ctx context.Context) (v string, err error) {
  40190. if !m.op.Is(OpUpdateOne) {
  40191. return v, errors.New("OldTel is only allowed on UpdateOne operations")
  40192. }
  40193. if m.id == nil || m.oldValue == nil {
  40194. return v, errors.New("OldTel requires an ID field in the mutation")
  40195. }
  40196. oldValue, err := m.oldValue(ctx)
  40197. if err != nil {
  40198. return v, fmt.Errorf("querying old value for OldTel: %w", err)
  40199. }
  40200. return oldValue.Tel, nil
  40201. }
  40202. // ResetTel resets all changes to the "tel" field.
  40203. func (m *WxMutation) ResetTel() {
  40204. m.tel = nil
  40205. }
  40206. // SetHeadBig sets the "head_big" field.
  40207. func (m *WxMutation) SetHeadBig(s string) {
  40208. m.head_big = &s
  40209. }
  40210. // HeadBig returns the value of the "head_big" field in the mutation.
  40211. func (m *WxMutation) HeadBig() (r string, exists bool) {
  40212. v := m.head_big
  40213. if v == nil {
  40214. return
  40215. }
  40216. return *v, true
  40217. }
  40218. // OldHeadBig returns the old "head_big" field's value of the Wx entity.
  40219. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40220. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40221. func (m *WxMutation) OldHeadBig(ctx context.Context) (v string, err error) {
  40222. if !m.op.Is(OpUpdateOne) {
  40223. return v, errors.New("OldHeadBig is only allowed on UpdateOne operations")
  40224. }
  40225. if m.id == nil || m.oldValue == nil {
  40226. return v, errors.New("OldHeadBig requires an ID field in the mutation")
  40227. }
  40228. oldValue, err := m.oldValue(ctx)
  40229. if err != nil {
  40230. return v, fmt.Errorf("querying old value for OldHeadBig: %w", err)
  40231. }
  40232. return oldValue.HeadBig, nil
  40233. }
  40234. // ResetHeadBig resets all changes to the "head_big" field.
  40235. func (m *WxMutation) ResetHeadBig() {
  40236. m.head_big = nil
  40237. }
  40238. // SetOrganizationID sets the "organization_id" field.
  40239. func (m *WxMutation) SetOrganizationID(u uint64) {
  40240. m.organization_id = &u
  40241. m.addorganization_id = nil
  40242. }
  40243. // OrganizationID returns the value of the "organization_id" field in the mutation.
  40244. func (m *WxMutation) OrganizationID() (r uint64, exists bool) {
  40245. v := m.organization_id
  40246. if v == nil {
  40247. return
  40248. }
  40249. return *v, true
  40250. }
  40251. // OldOrganizationID returns the old "organization_id" field's value of the Wx entity.
  40252. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40253. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40254. func (m *WxMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  40255. if !m.op.Is(OpUpdateOne) {
  40256. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  40257. }
  40258. if m.id == nil || m.oldValue == nil {
  40259. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  40260. }
  40261. oldValue, err := m.oldValue(ctx)
  40262. if err != nil {
  40263. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  40264. }
  40265. return oldValue.OrganizationID, nil
  40266. }
  40267. // AddOrganizationID adds u to the "organization_id" field.
  40268. func (m *WxMutation) AddOrganizationID(u int64) {
  40269. if m.addorganization_id != nil {
  40270. *m.addorganization_id += u
  40271. } else {
  40272. m.addorganization_id = &u
  40273. }
  40274. }
  40275. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  40276. func (m *WxMutation) AddedOrganizationID() (r int64, exists bool) {
  40277. v := m.addorganization_id
  40278. if v == nil {
  40279. return
  40280. }
  40281. return *v, true
  40282. }
  40283. // ClearOrganizationID clears the value of the "organization_id" field.
  40284. func (m *WxMutation) ClearOrganizationID() {
  40285. m.organization_id = nil
  40286. m.addorganization_id = nil
  40287. m.clearedFields[wx.FieldOrganizationID] = struct{}{}
  40288. }
  40289. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  40290. func (m *WxMutation) OrganizationIDCleared() bool {
  40291. _, ok := m.clearedFields[wx.FieldOrganizationID]
  40292. return ok
  40293. }
  40294. // ResetOrganizationID resets all changes to the "organization_id" field.
  40295. func (m *WxMutation) ResetOrganizationID() {
  40296. m.organization_id = nil
  40297. m.addorganization_id = nil
  40298. delete(m.clearedFields, wx.FieldOrganizationID)
  40299. }
  40300. // SetAgentID sets the "agent_id" field.
  40301. func (m *WxMutation) SetAgentID(u uint64) {
  40302. m.agent = &u
  40303. }
  40304. // AgentID returns the value of the "agent_id" field in the mutation.
  40305. func (m *WxMutation) AgentID() (r uint64, exists bool) {
  40306. v := m.agent
  40307. if v == nil {
  40308. return
  40309. }
  40310. return *v, true
  40311. }
  40312. // OldAgentID returns the old "agent_id" field's value of the Wx entity.
  40313. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40314. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40315. func (m *WxMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  40316. if !m.op.Is(OpUpdateOne) {
  40317. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  40318. }
  40319. if m.id == nil || m.oldValue == nil {
  40320. return v, errors.New("OldAgentID requires an ID field in the mutation")
  40321. }
  40322. oldValue, err := m.oldValue(ctx)
  40323. if err != nil {
  40324. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  40325. }
  40326. return oldValue.AgentID, nil
  40327. }
  40328. // ResetAgentID resets all changes to the "agent_id" field.
  40329. func (m *WxMutation) ResetAgentID() {
  40330. m.agent = nil
  40331. }
  40332. // SetAPIBase sets the "api_base" field.
  40333. func (m *WxMutation) SetAPIBase(s string) {
  40334. m.api_base = &s
  40335. }
  40336. // APIBase returns the value of the "api_base" field in the mutation.
  40337. func (m *WxMutation) APIBase() (r string, exists bool) {
  40338. v := m.api_base
  40339. if v == nil {
  40340. return
  40341. }
  40342. return *v, true
  40343. }
  40344. // OldAPIBase returns the old "api_base" field's value of the Wx entity.
  40345. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40346. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40347. func (m *WxMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  40348. if !m.op.Is(OpUpdateOne) {
  40349. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  40350. }
  40351. if m.id == nil || m.oldValue == nil {
  40352. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  40353. }
  40354. oldValue, err := m.oldValue(ctx)
  40355. if err != nil {
  40356. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  40357. }
  40358. return oldValue.APIBase, nil
  40359. }
  40360. // ClearAPIBase clears the value of the "api_base" field.
  40361. func (m *WxMutation) ClearAPIBase() {
  40362. m.api_base = nil
  40363. m.clearedFields[wx.FieldAPIBase] = struct{}{}
  40364. }
  40365. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  40366. func (m *WxMutation) APIBaseCleared() bool {
  40367. _, ok := m.clearedFields[wx.FieldAPIBase]
  40368. return ok
  40369. }
  40370. // ResetAPIBase resets all changes to the "api_base" field.
  40371. func (m *WxMutation) ResetAPIBase() {
  40372. m.api_base = nil
  40373. delete(m.clearedFields, wx.FieldAPIBase)
  40374. }
  40375. // SetAPIKey sets the "api_key" field.
  40376. func (m *WxMutation) SetAPIKey(s string) {
  40377. m.api_key = &s
  40378. }
  40379. // APIKey returns the value of the "api_key" field in the mutation.
  40380. func (m *WxMutation) APIKey() (r string, exists bool) {
  40381. v := m.api_key
  40382. if v == nil {
  40383. return
  40384. }
  40385. return *v, true
  40386. }
  40387. // OldAPIKey returns the old "api_key" field's value of the Wx entity.
  40388. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40389. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40390. func (m *WxMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  40391. if !m.op.Is(OpUpdateOne) {
  40392. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  40393. }
  40394. if m.id == nil || m.oldValue == nil {
  40395. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  40396. }
  40397. oldValue, err := m.oldValue(ctx)
  40398. if err != nil {
  40399. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  40400. }
  40401. return oldValue.APIKey, nil
  40402. }
  40403. // ClearAPIKey clears the value of the "api_key" field.
  40404. func (m *WxMutation) ClearAPIKey() {
  40405. m.api_key = nil
  40406. m.clearedFields[wx.FieldAPIKey] = struct{}{}
  40407. }
  40408. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  40409. func (m *WxMutation) APIKeyCleared() bool {
  40410. _, ok := m.clearedFields[wx.FieldAPIKey]
  40411. return ok
  40412. }
  40413. // ResetAPIKey resets all changes to the "api_key" field.
  40414. func (m *WxMutation) ResetAPIKey() {
  40415. m.api_key = nil
  40416. delete(m.clearedFields, wx.FieldAPIKey)
  40417. }
  40418. // SetAllowList sets the "allow_list" field.
  40419. func (m *WxMutation) SetAllowList(s []string) {
  40420. m.allow_list = &s
  40421. m.appendallow_list = nil
  40422. }
  40423. // AllowList returns the value of the "allow_list" field in the mutation.
  40424. func (m *WxMutation) AllowList() (r []string, exists bool) {
  40425. v := m.allow_list
  40426. if v == nil {
  40427. return
  40428. }
  40429. return *v, true
  40430. }
  40431. // OldAllowList returns the old "allow_list" field's value of the Wx entity.
  40432. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40433. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40434. func (m *WxMutation) OldAllowList(ctx context.Context) (v []string, err error) {
  40435. if !m.op.Is(OpUpdateOne) {
  40436. return v, errors.New("OldAllowList is only allowed on UpdateOne operations")
  40437. }
  40438. if m.id == nil || m.oldValue == nil {
  40439. return v, errors.New("OldAllowList requires an ID field in the mutation")
  40440. }
  40441. oldValue, err := m.oldValue(ctx)
  40442. if err != nil {
  40443. return v, fmt.Errorf("querying old value for OldAllowList: %w", err)
  40444. }
  40445. return oldValue.AllowList, nil
  40446. }
  40447. // AppendAllowList adds s to the "allow_list" field.
  40448. func (m *WxMutation) AppendAllowList(s []string) {
  40449. m.appendallow_list = append(m.appendallow_list, s...)
  40450. }
  40451. // AppendedAllowList returns the list of values that were appended to the "allow_list" field in this mutation.
  40452. func (m *WxMutation) AppendedAllowList() ([]string, bool) {
  40453. if len(m.appendallow_list) == 0 {
  40454. return nil, false
  40455. }
  40456. return m.appendallow_list, true
  40457. }
  40458. // ResetAllowList resets all changes to the "allow_list" field.
  40459. func (m *WxMutation) ResetAllowList() {
  40460. m.allow_list = nil
  40461. m.appendallow_list = nil
  40462. }
  40463. // SetGroupAllowList sets the "group_allow_list" field.
  40464. func (m *WxMutation) SetGroupAllowList(s []string) {
  40465. m.group_allow_list = &s
  40466. m.appendgroup_allow_list = nil
  40467. }
  40468. // GroupAllowList returns the value of the "group_allow_list" field in the mutation.
  40469. func (m *WxMutation) GroupAllowList() (r []string, exists bool) {
  40470. v := m.group_allow_list
  40471. if v == nil {
  40472. return
  40473. }
  40474. return *v, true
  40475. }
  40476. // OldGroupAllowList returns the old "group_allow_list" field's value of the Wx entity.
  40477. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40478. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40479. func (m *WxMutation) OldGroupAllowList(ctx context.Context) (v []string, err error) {
  40480. if !m.op.Is(OpUpdateOne) {
  40481. return v, errors.New("OldGroupAllowList is only allowed on UpdateOne operations")
  40482. }
  40483. if m.id == nil || m.oldValue == nil {
  40484. return v, errors.New("OldGroupAllowList requires an ID field in the mutation")
  40485. }
  40486. oldValue, err := m.oldValue(ctx)
  40487. if err != nil {
  40488. return v, fmt.Errorf("querying old value for OldGroupAllowList: %w", err)
  40489. }
  40490. return oldValue.GroupAllowList, nil
  40491. }
  40492. // AppendGroupAllowList adds s to the "group_allow_list" field.
  40493. func (m *WxMutation) AppendGroupAllowList(s []string) {
  40494. m.appendgroup_allow_list = append(m.appendgroup_allow_list, s...)
  40495. }
  40496. // AppendedGroupAllowList returns the list of values that were appended to the "group_allow_list" field in this mutation.
  40497. func (m *WxMutation) AppendedGroupAllowList() ([]string, bool) {
  40498. if len(m.appendgroup_allow_list) == 0 {
  40499. return nil, false
  40500. }
  40501. return m.appendgroup_allow_list, true
  40502. }
  40503. // ResetGroupAllowList resets all changes to the "group_allow_list" field.
  40504. func (m *WxMutation) ResetGroupAllowList() {
  40505. m.group_allow_list = nil
  40506. m.appendgroup_allow_list = nil
  40507. }
  40508. // SetBlockList sets the "block_list" field.
  40509. func (m *WxMutation) SetBlockList(s []string) {
  40510. m.block_list = &s
  40511. m.appendblock_list = nil
  40512. }
  40513. // BlockList returns the value of the "block_list" field in the mutation.
  40514. func (m *WxMutation) BlockList() (r []string, exists bool) {
  40515. v := m.block_list
  40516. if v == nil {
  40517. return
  40518. }
  40519. return *v, true
  40520. }
  40521. // OldBlockList returns the old "block_list" field's value of the Wx entity.
  40522. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40523. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40524. func (m *WxMutation) OldBlockList(ctx context.Context) (v []string, err error) {
  40525. if !m.op.Is(OpUpdateOne) {
  40526. return v, errors.New("OldBlockList is only allowed on UpdateOne operations")
  40527. }
  40528. if m.id == nil || m.oldValue == nil {
  40529. return v, errors.New("OldBlockList requires an ID field in the mutation")
  40530. }
  40531. oldValue, err := m.oldValue(ctx)
  40532. if err != nil {
  40533. return v, fmt.Errorf("querying old value for OldBlockList: %w", err)
  40534. }
  40535. return oldValue.BlockList, nil
  40536. }
  40537. // AppendBlockList adds s to the "block_list" field.
  40538. func (m *WxMutation) AppendBlockList(s []string) {
  40539. m.appendblock_list = append(m.appendblock_list, s...)
  40540. }
  40541. // AppendedBlockList returns the list of values that were appended to the "block_list" field in this mutation.
  40542. func (m *WxMutation) AppendedBlockList() ([]string, bool) {
  40543. if len(m.appendblock_list) == 0 {
  40544. return nil, false
  40545. }
  40546. return m.appendblock_list, true
  40547. }
  40548. // ResetBlockList resets all changes to the "block_list" field.
  40549. func (m *WxMutation) ResetBlockList() {
  40550. m.block_list = nil
  40551. m.appendblock_list = nil
  40552. }
  40553. // SetGroupBlockList sets the "group_block_list" field.
  40554. func (m *WxMutation) SetGroupBlockList(s []string) {
  40555. m.group_block_list = &s
  40556. m.appendgroup_block_list = nil
  40557. }
  40558. // GroupBlockList returns the value of the "group_block_list" field in the mutation.
  40559. func (m *WxMutation) GroupBlockList() (r []string, exists bool) {
  40560. v := m.group_block_list
  40561. if v == nil {
  40562. return
  40563. }
  40564. return *v, true
  40565. }
  40566. // OldGroupBlockList returns the old "group_block_list" field's value of the Wx entity.
  40567. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40568. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40569. func (m *WxMutation) OldGroupBlockList(ctx context.Context) (v []string, err error) {
  40570. if !m.op.Is(OpUpdateOne) {
  40571. return v, errors.New("OldGroupBlockList is only allowed on UpdateOne operations")
  40572. }
  40573. if m.id == nil || m.oldValue == nil {
  40574. return v, errors.New("OldGroupBlockList requires an ID field in the mutation")
  40575. }
  40576. oldValue, err := m.oldValue(ctx)
  40577. if err != nil {
  40578. return v, fmt.Errorf("querying old value for OldGroupBlockList: %w", err)
  40579. }
  40580. return oldValue.GroupBlockList, nil
  40581. }
  40582. // AppendGroupBlockList adds s to the "group_block_list" field.
  40583. func (m *WxMutation) AppendGroupBlockList(s []string) {
  40584. m.appendgroup_block_list = append(m.appendgroup_block_list, s...)
  40585. }
  40586. // AppendedGroupBlockList returns the list of values that were appended to the "group_block_list" field in this mutation.
  40587. func (m *WxMutation) AppendedGroupBlockList() ([]string, bool) {
  40588. if len(m.appendgroup_block_list) == 0 {
  40589. return nil, false
  40590. }
  40591. return m.appendgroup_block_list, true
  40592. }
  40593. // ResetGroupBlockList resets all changes to the "group_block_list" field.
  40594. func (m *WxMutation) ResetGroupBlockList() {
  40595. m.group_block_list = nil
  40596. m.appendgroup_block_list = nil
  40597. }
  40598. // ClearServer clears the "server" edge to the Server entity.
  40599. func (m *WxMutation) ClearServer() {
  40600. m.clearedserver = true
  40601. m.clearedFields[wx.FieldServerID] = struct{}{}
  40602. }
  40603. // ServerCleared reports if the "server" edge to the Server entity was cleared.
  40604. func (m *WxMutation) ServerCleared() bool {
  40605. return m.ServerIDCleared() || m.clearedserver
  40606. }
  40607. // ServerIDs returns the "server" edge IDs in the mutation.
  40608. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  40609. // ServerID instead. It exists only for internal usage by the builders.
  40610. func (m *WxMutation) ServerIDs() (ids []uint64) {
  40611. if id := m.server; id != nil {
  40612. ids = append(ids, *id)
  40613. }
  40614. return
  40615. }
  40616. // ResetServer resets all changes to the "server" edge.
  40617. func (m *WxMutation) ResetServer() {
  40618. m.server = nil
  40619. m.clearedserver = false
  40620. }
  40621. // ClearAgent clears the "agent" edge to the Agent entity.
  40622. func (m *WxMutation) ClearAgent() {
  40623. m.clearedagent = true
  40624. m.clearedFields[wx.FieldAgentID] = struct{}{}
  40625. }
  40626. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  40627. func (m *WxMutation) AgentCleared() bool {
  40628. return m.clearedagent
  40629. }
  40630. // AgentIDs returns the "agent" edge IDs in the mutation.
  40631. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  40632. // AgentID instead. It exists only for internal usage by the builders.
  40633. func (m *WxMutation) AgentIDs() (ids []uint64) {
  40634. if id := m.agent; id != nil {
  40635. ids = append(ids, *id)
  40636. }
  40637. return
  40638. }
  40639. // ResetAgent resets all changes to the "agent" edge.
  40640. func (m *WxMutation) ResetAgent() {
  40641. m.agent = nil
  40642. m.clearedagent = false
  40643. }
  40644. // Where appends a list predicates to the WxMutation builder.
  40645. func (m *WxMutation) Where(ps ...predicate.Wx) {
  40646. m.predicates = append(m.predicates, ps...)
  40647. }
  40648. // WhereP appends storage-level predicates to the WxMutation builder. Using this method,
  40649. // users can use type-assertion to append predicates that do not depend on any generated package.
  40650. func (m *WxMutation) WhereP(ps ...func(*sql.Selector)) {
  40651. p := make([]predicate.Wx, len(ps))
  40652. for i := range ps {
  40653. p[i] = ps[i]
  40654. }
  40655. m.Where(p...)
  40656. }
  40657. // Op returns the operation name.
  40658. func (m *WxMutation) Op() Op {
  40659. return m.op
  40660. }
  40661. // SetOp allows setting the mutation operation.
  40662. func (m *WxMutation) SetOp(op Op) {
  40663. m.op = op
  40664. }
  40665. // Type returns the node type of this mutation (Wx).
  40666. func (m *WxMutation) Type() string {
  40667. return m.typ
  40668. }
  40669. // Fields returns all fields that were changed during this mutation. Note that in
  40670. // order to get all numeric fields that were incremented/decremented, call
  40671. // AddedFields().
  40672. func (m *WxMutation) Fields() []string {
  40673. fields := make([]string, 0, 21)
  40674. if m.created_at != nil {
  40675. fields = append(fields, wx.FieldCreatedAt)
  40676. }
  40677. if m.updated_at != nil {
  40678. fields = append(fields, wx.FieldUpdatedAt)
  40679. }
  40680. if m.status != nil {
  40681. fields = append(fields, wx.FieldStatus)
  40682. }
  40683. if m.deleted_at != nil {
  40684. fields = append(fields, wx.FieldDeletedAt)
  40685. }
  40686. if m.server != nil {
  40687. fields = append(fields, wx.FieldServerID)
  40688. }
  40689. if m.port != nil {
  40690. fields = append(fields, wx.FieldPort)
  40691. }
  40692. if m.process_id != nil {
  40693. fields = append(fields, wx.FieldProcessID)
  40694. }
  40695. if m.callback != nil {
  40696. fields = append(fields, wx.FieldCallback)
  40697. }
  40698. if m.wxid != nil {
  40699. fields = append(fields, wx.FieldWxid)
  40700. }
  40701. if m.account != nil {
  40702. fields = append(fields, wx.FieldAccount)
  40703. }
  40704. if m.nickname != nil {
  40705. fields = append(fields, wx.FieldNickname)
  40706. }
  40707. if m.tel != nil {
  40708. fields = append(fields, wx.FieldTel)
  40709. }
  40710. if m.head_big != nil {
  40711. fields = append(fields, wx.FieldHeadBig)
  40712. }
  40713. if m.organization_id != nil {
  40714. fields = append(fields, wx.FieldOrganizationID)
  40715. }
  40716. if m.agent != nil {
  40717. fields = append(fields, wx.FieldAgentID)
  40718. }
  40719. if m.api_base != nil {
  40720. fields = append(fields, wx.FieldAPIBase)
  40721. }
  40722. if m.api_key != nil {
  40723. fields = append(fields, wx.FieldAPIKey)
  40724. }
  40725. if m.allow_list != nil {
  40726. fields = append(fields, wx.FieldAllowList)
  40727. }
  40728. if m.group_allow_list != nil {
  40729. fields = append(fields, wx.FieldGroupAllowList)
  40730. }
  40731. if m.block_list != nil {
  40732. fields = append(fields, wx.FieldBlockList)
  40733. }
  40734. if m.group_block_list != nil {
  40735. fields = append(fields, wx.FieldGroupBlockList)
  40736. }
  40737. return fields
  40738. }
  40739. // Field returns the value of a field with the given name. The second boolean
  40740. // return value indicates that this field was not set, or was not defined in the
  40741. // schema.
  40742. func (m *WxMutation) Field(name string) (ent.Value, bool) {
  40743. switch name {
  40744. case wx.FieldCreatedAt:
  40745. return m.CreatedAt()
  40746. case wx.FieldUpdatedAt:
  40747. return m.UpdatedAt()
  40748. case wx.FieldStatus:
  40749. return m.Status()
  40750. case wx.FieldDeletedAt:
  40751. return m.DeletedAt()
  40752. case wx.FieldServerID:
  40753. return m.ServerID()
  40754. case wx.FieldPort:
  40755. return m.Port()
  40756. case wx.FieldProcessID:
  40757. return m.ProcessID()
  40758. case wx.FieldCallback:
  40759. return m.Callback()
  40760. case wx.FieldWxid:
  40761. return m.Wxid()
  40762. case wx.FieldAccount:
  40763. return m.Account()
  40764. case wx.FieldNickname:
  40765. return m.Nickname()
  40766. case wx.FieldTel:
  40767. return m.Tel()
  40768. case wx.FieldHeadBig:
  40769. return m.HeadBig()
  40770. case wx.FieldOrganizationID:
  40771. return m.OrganizationID()
  40772. case wx.FieldAgentID:
  40773. return m.AgentID()
  40774. case wx.FieldAPIBase:
  40775. return m.APIBase()
  40776. case wx.FieldAPIKey:
  40777. return m.APIKey()
  40778. case wx.FieldAllowList:
  40779. return m.AllowList()
  40780. case wx.FieldGroupAllowList:
  40781. return m.GroupAllowList()
  40782. case wx.FieldBlockList:
  40783. return m.BlockList()
  40784. case wx.FieldGroupBlockList:
  40785. return m.GroupBlockList()
  40786. }
  40787. return nil, false
  40788. }
  40789. // OldField returns the old value of the field from the database. An error is
  40790. // returned if the mutation operation is not UpdateOne, or the query to the
  40791. // database failed.
  40792. func (m *WxMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  40793. switch name {
  40794. case wx.FieldCreatedAt:
  40795. return m.OldCreatedAt(ctx)
  40796. case wx.FieldUpdatedAt:
  40797. return m.OldUpdatedAt(ctx)
  40798. case wx.FieldStatus:
  40799. return m.OldStatus(ctx)
  40800. case wx.FieldDeletedAt:
  40801. return m.OldDeletedAt(ctx)
  40802. case wx.FieldServerID:
  40803. return m.OldServerID(ctx)
  40804. case wx.FieldPort:
  40805. return m.OldPort(ctx)
  40806. case wx.FieldProcessID:
  40807. return m.OldProcessID(ctx)
  40808. case wx.FieldCallback:
  40809. return m.OldCallback(ctx)
  40810. case wx.FieldWxid:
  40811. return m.OldWxid(ctx)
  40812. case wx.FieldAccount:
  40813. return m.OldAccount(ctx)
  40814. case wx.FieldNickname:
  40815. return m.OldNickname(ctx)
  40816. case wx.FieldTel:
  40817. return m.OldTel(ctx)
  40818. case wx.FieldHeadBig:
  40819. return m.OldHeadBig(ctx)
  40820. case wx.FieldOrganizationID:
  40821. return m.OldOrganizationID(ctx)
  40822. case wx.FieldAgentID:
  40823. return m.OldAgentID(ctx)
  40824. case wx.FieldAPIBase:
  40825. return m.OldAPIBase(ctx)
  40826. case wx.FieldAPIKey:
  40827. return m.OldAPIKey(ctx)
  40828. case wx.FieldAllowList:
  40829. return m.OldAllowList(ctx)
  40830. case wx.FieldGroupAllowList:
  40831. return m.OldGroupAllowList(ctx)
  40832. case wx.FieldBlockList:
  40833. return m.OldBlockList(ctx)
  40834. case wx.FieldGroupBlockList:
  40835. return m.OldGroupBlockList(ctx)
  40836. }
  40837. return nil, fmt.Errorf("unknown Wx field %s", name)
  40838. }
  40839. // SetField sets the value of a field with the given name. It returns an error if
  40840. // the field is not defined in the schema, or if the type mismatched the field
  40841. // type.
  40842. func (m *WxMutation) SetField(name string, value ent.Value) error {
  40843. switch name {
  40844. case wx.FieldCreatedAt:
  40845. v, ok := value.(time.Time)
  40846. if !ok {
  40847. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40848. }
  40849. m.SetCreatedAt(v)
  40850. return nil
  40851. case wx.FieldUpdatedAt:
  40852. v, ok := value.(time.Time)
  40853. if !ok {
  40854. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40855. }
  40856. m.SetUpdatedAt(v)
  40857. return nil
  40858. case wx.FieldStatus:
  40859. v, ok := value.(uint8)
  40860. if !ok {
  40861. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40862. }
  40863. m.SetStatus(v)
  40864. return nil
  40865. case wx.FieldDeletedAt:
  40866. v, ok := value.(time.Time)
  40867. if !ok {
  40868. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40869. }
  40870. m.SetDeletedAt(v)
  40871. return nil
  40872. case wx.FieldServerID:
  40873. v, ok := value.(uint64)
  40874. if !ok {
  40875. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40876. }
  40877. m.SetServerID(v)
  40878. return nil
  40879. case wx.FieldPort:
  40880. v, ok := value.(string)
  40881. if !ok {
  40882. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40883. }
  40884. m.SetPort(v)
  40885. return nil
  40886. case wx.FieldProcessID:
  40887. v, ok := value.(string)
  40888. if !ok {
  40889. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40890. }
  40891. m.SetProcessID(v)
  40892. return nil
  40893. case wx.FieldCallback:
  40894. v, ok := value.(string)
  40895. if !ok {
  40896. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40897. }
  40898. m.SetCallback(v)
  40899. return nil
  40900. case wx.FieldWxid:
  40901. v, ok := value.(string)
  40902. if !ok {
  40903. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40904. }
  40905. m.SetWxid(v)
  40906. return nil
  40907. case wx.FieldAccount:
  40908. v, ok := value.(string)
  40909. if !ok {
  40910. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40911. }
  40912. m.SetAccount(v)
  40913. return nil
  40914. case wx.FieldNickname:
  40915. v, ok := value.(string)
  40916. if !ok {
  40917. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40918. }
  40919. m.SetNickname(v)
  40920. return nil
  40921. case wx.FieldTel:
  40922. v, ok := value.(string)
  40923. if !ok {
  40924. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40925. }
  40926. m.SetTel(v)
  40927. return nil
  40928. case wx.FieldHeadBig:
  40929. v, ok := value.(string)
  40930. if !ok {
  40931. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40932. }
  40933. m.SetHeadBig(v)
  40934. return nil
  40935. case wx.FieldOrganizationID:
  40936. v, ok := value.(uint64)
  40937. if !ok {
  40938. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40939. }
  40940. m.SetOrganizationID(v)
  40941. return nil
  40942. case wx.FieldAgentID:
  40943. v, ok := value.(uint64)
  40944. if !ok {
  40945. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40946. }
  40947. m.SetAgentID(v)
  40948. return nil
  40949. case wx.FieldAPIBase:
  40950. v, ok := value.(string)
  40951. if !ok {
  40952. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40953. }
  40954. m.SetAPIBase(v)
  40955. return nil
  40956. case wx.FieldAPIKey:
  40957. v, ok := value.(string)
  40958. if !ok {
  40959. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40960. }
  40961. m.SetAPIKey(v)
  40962. return nil
  40963. case wx.FieldAllowList:
  40964. v, ok := value.([]string)
  40965. if !ok {
  40966. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40967. }
  40968. m.SetAllowList(v)
  40969. return nil
  40970. case wx.FieldGroupAllowList:
  40971. v, ok := value.([]string)
  40972. if !ok {
  40973. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40974. }
  40975. m.SetGroupAllowList(v)
  40976. return nil
  40977. case wx.FieldBlockList:
  40978. v, ok := value.([]string)
  40979. if !ok {
  40980. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40981. }
  40982. m.SetBlockList(v)
  40983. return nil
  40984. case wx.FieldGroupBlockList:
  40985. v, ok := value.([]string)
  40986. if !ok {
  40987. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40988. }
  40989. m.SetGroupBlockList(v)
  40990. return nil
  40991. }
  40992. return fmt.Errorf("unknown Wx field %s", name)
  40993. }
  40994. // AddedFields returns all numeric fields that were incremented/decremented during
  40995. // this mutation.
  40996. func (m *WxMutation) AddedFields() []string {
  40997. var fields []string
  40998. if m.addstatus != nil {
  40999. fields = append(fields, wx.FieldStatus)
  41000. }
  41001. if m.addorganization_id != nil {
  41002. fields = append(fields, wx.FieldOrganizationID)
  41003. }
  41004. return fields
  41005. }
  41006. // AddedField returns the numeric value that was incremented/decremented on a field
  41007. // with the given name. The second boolean return value indicates that this field
  41008. // was not set, or was not defined in the schema.
  41009. func (m *WxMutation) AddedField(name string) (ent.Value, bool) {
  41010. switch name {
  41011. case wx.FieldStatus:
  41012. return m.AddedStatus()
  41013. case wx.FieldOrganizationID:
  41014. return m.AddedOrganizationID()
  41015. }
  41016. return nil, false
  41017. }
  41018. // AddField adds the value to the field with the given name. It returns an error if
  41019. // the field is not defined in the schema, or if the type mismatched the field
  41020. // type.
  41021. func (m *WxMutation) AddField(name string, value ent.Value) error {
  41022. switch name {
  41023. case wx.FieldStatus:
  41024. v, ok := value.(int8)
  41025. if !ok {
  41026. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41027. }
  41028. m.AddStatus(v)
  41029. return nil
  41030. case wx.FieldOrganizationID:
  41031. v, ok := value.(int64)
  41032. if !ok {
  41033. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41034. }
  41035. m.AddOrganizationID(v)
  41036. return nil
  41037. }
  41038. return fmt.Errorf("unknown Wx numeric field %s", name)
  41039. }
  41040. // ClearedFields returns all nullable fields that were cleared during this
  41041. // mutation.
  41042. func (m *WxMutation) ClearedFields() []string {
  41043. var fields []string
  41044. if m.FieldCleared(wx.FieldStatus) {
  41045. fields = append(fields, wx.FieldStatus)
  41046. }
  41047. if m.FieldCleared(wx.FieldDeletedAt) {
  41048. fields = append(fields, wx.FieldDeletedAt)
  41049. }
  41050. if m.FieldCleared(wx.FieldServerID) {
  41051. fields = append(fields, wx.FieldServerID)
  41052. }
  41053. if m.FieldCleared(wx.FieldOrganizationID) {
  41054. fields = append(fields, wx.FieldOrganizationID)
  41055. }
  41056. if m.FieldCleared(wx.FieldAPIBase) {
  41057. fields = append(fields, wx.FieldAPIBase)
  41058. }
  41059. if m.FieldCleared(wx.FieldAPIKey) {
  41060. fields = append(fields, wx.FieldAPIKey)
  41061. }
  41062. return fields
  41063. }
  41064. // FieldCleared returns a boolean indicating if a field with the given name was
  41065. // cleared in this mutation.
  41066. func (m *WxMutation) FieldCleared(name string) bool {
  41067. _, ok := m.clearedFields[name]
  41068. return ok
  41069. }
  41070. // ClearField clears the value of the field with the given name. It returns an
  41071. // error if the field is not defined in the schema.
  41072. func (m *WxMutation) ClearField(name string) error {
  41073. switch name {
  41074. case wx.FieldStatus:
  41075. m.ClearStatus()
  41076. return nil
  41077. case wx.FieldDeletedAt:
  41078. m.ClearDeletedAt()
  41079. return nil
  41080. case wx.FieldServerID:
  41081. m.ClearServerID()
  41082. return nil
  41083. case wx.FieldOrganizationID:
  41084. m.ClearOrganizationID()
  41085. return nil
  41086. case wx.FieldAPIBase:
  41087. m.ClearAPIBase()
  41088. return nil
  41089. case wx.FieldAPIKey:
  41090. m.ClearAPIKey()
  41091. return nil
  41092. }
  41093. return fmt.Errorf("unknown Wx nullable field %s", name)
  41094. }
  41095. // ResetField resets all changes in the mutation for the field with the given name.
  41096. // It returns an error if the field is not defined in the schema.
  41097. func (m *WxMutation) ResetField(name string) error {
  41098. switch name {
  41099. case wx.FieldCreatedAt:
  41100. m.ResetCreatedAt()
  41101. return nil
  41102. case wx.FieldUpdatedAt:
  41103. m.ResetUpdatedAt()
  41104. return nil
  41105. case wx.FieldStatus:
  41106. m.ResetStatus()
  41107. return nil
  41108. case wx.FieldDeletedAt:
  41109. m.ResetDeletedAt()
  41110. return nil
  41111. case wx.FieldServerID:
  41112. m.ResetServerID()
  41113. return nil
  41114. case wx.FieldPort:
  41115. m.ResetPort()
  41116. return nil
  41117. case wx.FieldProcessID:
  41118. m.ResetProcessID()
  41119. return nil
  41120. case wx.FieldCallback:
  41121. m.ResetCallback()
  41122. return nil
  41123. case wx.FieldWxid:
  41124. m.ResetWxid()
  41125. return nil
  41126. case wx.FieldAccount:
  41127. m.ResetAccount()
  41128. return nil
  41129. case wx.FieldNickname:
  41130. m.ResetNickname()
  41131. return nil
  41132. case wx.FieldTel:
  41133. m.ResetTel()
  41134. return nil
  41135. case wx.FieldHeadBig:
  41136. m.ResetHeadBig()
  41137. return nil
  41138. case wx.FieldOrganizationID:
  41139. m.ResetOrganizationID()
  41140. return nil
  41141. case wx.FieldAgentID:
  41142. m.ResetAgentID()
  41143. return nil
  41144. case wx.FieldAPIBase:
  41145. m.ResetAPIBase()
  41146. return nil
  41147. case wx.FieldAPIKey:
  41148. m.ResetAPIKey()
  41149. return nil
  41150. case wx.FieldAllowList:
  41151. m.ResetAllowList()
  41152. return nil
  41153. case wx.FieldGroupAllowList:
  41154. m.ResetGroupAllowList()
  41155. return nil
  41156. case wx.FieldBlockList:
  41157. m.ResetBlockList()
  41158. return nil
  41159. case wx.FieldGroupBlockList:
  41160. m.ResetGroupBlockList()
  41161. return nil
  41162. }
  41163. return fmt.Errorf("unknown Wx field %s", name)
  41164. }
  41165. // AddedEdges returns all edge names that were set/added in this mutation.
  41166. func (m *WxMutation) AddedEdges() []string {
  41167. edges := make([]string, 0, 2)
  41168. if m.server != nil {
  41169. edges = append(edges, wx.EdgeServer)
  41170. }
  41171. if m.agent != nil {
  41172. edges = append(edges, wx.EdgeAgent)
  41173. }
  41174. return edges
  41175. }
  41176. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  41177. // name in this mutation.
  41178. func (m *WxMutation) AddedIDs(name string) []ent.Value {
  41179. switch name {
  41180. case wx.EdgeServer:
  41181. if id := m.server; id != nil {
  41182. return []ent.Value{*id}
  41183. }
  41184. case wx.EdgeAgent:
  41185. if id := m.agent; id != nil {
  41186. return []ent.Value{*id}
  41187. }
  41188. }
  41189. return nil
  41190. }
  41191. // RemovedEdges returns all edge names that were removed in this mutation.
  41192. func (m *WxMutation) RemovedEdges() []string {
  41193. edges := make([]string, 0, 2)
  41194. return edges
  41195. }
  41196. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  41197. // the given name in this mutation.
  41198. func (m *WxMutation) RemovedIDs(name string) []ent.Value {
  41199. return nil
  41200. }
  41201. // ClearedEdges returns all edge names that were cleared in this mutation.
  41202. func (m *WxMutation) ClearedEdges() []string {
  41203. edges := make([]string, 0, 2)
  41204. if m.clearedserver {
  41205. edges = append(edges, wx.EdgeServer)
  41206. }
  41207. if m.clearedagent {
  41208. edges = append(edges, wx.EdgeAgent)
  41209. }
  41210. return edges
  41211. }
  41212. // EdgeCleared returns a boolean which indicates if the edge with the given name
  41213. // was cleared in this mutation.
  41214. func (m *WxMutation) EdgeCleared(name string) bool {
  41215. switch name {
  41216. case wx.EdgeServer:
  41217. return m.clearedserver
  41218. case wx.EdgeAgent:
  41219. return m.clearedagent
  41220. }
  41221. return false
  41222. }
  41223. // ClearEdge clears the value of the edge with the given name. It returns an error
  41224. // if that edge is not defined in the schema.
  41225. func (m *WxMutation) ClearEdge(name string) error {
  41226. switch name {
  41227. case wx.EdgeServer:
  41228. m.ClearServer()
  41229. return nil
  41230. case wx.EdgeAgent:
  41231. m.ClearAgent()
  41232. return nil
  41233. }
  41234. return fmt.Errorf("unknown Wx unique edge %s", name)
  41235. }
  41236. // ResetEdge resets all changes to the edge with the given name in this mutation.
  41237. // It returns an error if the edge is not defined in the schema.
  41238. func (m *WxMutation) ResetEdge(name string) error {
  41239. switch name {
  41240. case wx.EdgeServer:
  41241. m.ResetServer()
  41242. return nil
  41243. case wx.EdgeAgent:
  41244. m.ResetAgent()
  41245. return nil
  41246. }
  41247. return fmt.Errorf("unknown Wx edge %s", name)
  41248. }
  41249. // WxCardMutation represents an operation that mutates the WxCard nodes in the graph.
  41250. type WxCardMutation struct {
  41251. config
  41252. op Op
  41253. typ string
  41254. id *uint64
  41255. created_at *time.Time
  41256. updated_at *time.Time
  41257. deleted_at *time.Time
  41258. user_id *uint64
  41259. adduser_id *int64
  41260. wx_user_id *uint64
  41261. addwx_user_id *int64
  41262. avatar *string
  41263. logo *string
  41264. name *string
  41265. company *string
  41266. address *string
  41267. phone *string
  41268. official_account *string
  41269. wechat_account *string
  41270. email *string
  41271. api_base *string
  41272. api_key *string
  41273. ai_info *string
  41274. intro *string
  41275. clearedFields map[string]struct{}
  41276. done bool
  41277. oldValue func(context.Context) (*WxCard, error)
  41278. predicates []predicate.WxCard
  41279. }
  41280. var _ ent.Mutation = (*WxCardMutation)(nil)
  41281. // wxcardOption allows management of the mutation configuration using functional options.
  41282. type wxcardOption func(*WxCardMutation)
  41283. // newWxCardMutation creates new mutation for the WxCard entity.
  41284. func newWxCardMutation(c config, op Op, opts ...wxcardOption) *WxCardMutation {
  41285. m := &WxCardMutation{
  41286. config: c,
  41287. op: op,
  41288. typ: TypeWxCard,
  41289. clearedFields: make(map[string]struct{}),
  41290. }
  41291. for _, opt := range opts {
  41292. opt(m)
  41293. }
  41294. return m
  41295. }
  41296. // withWxCardID sets the ID field of the mutation.
  41297. func withWxCardID(id uint64) wxcardOption {
  41298. return func(m *WxCardMutation) {
  41299. var (
  41300. err error
  41301. once sync.Once
  41302. value *WxCard
  41303. )
  41304. m.oldValue = func(ctx context.Context) (*WxCard, error) {
  41305. once.Do(func() {
  41306. if m.done {
  41307. err = errors.New("querying old values post mutation is not allowed")
  41308. } else {
  41309. value, err = m.Client().WxCard.Get(ctx, id)
  41310. }
  41311. })
  41312. return value, err
  41313. }
  41314. m.id = &id
  41315. }
  41316. }
  41317. // withWxCard sets the old WxCard of the mutation.
  41318. func withWxCard(node *WxCard) wxcardOption {
  41319. return func(m *WxCardMutation) {
  41320. m.oldValue = func(context.Context) (*WxCard, error) {
  41321. return node, nil
  41322. }
  41323. m.id = &node.ID
  41324. }
  41325. }
  41326. // Client returns a new `ent.Client` from the mutation. If the mutation was
  41327. // executed in a transaction (ent.Tx), a transactional client is returned.
  41328. func (m WxCardMutation) Client() *Client {
  41329. client := &Client{config: m.config}
  41330. client.init()
  41331. return client
  41332. }
  41333. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  41334. // it returns an error otherwise.
  41335. func (m WxCardMutation) Tx() (*Tx, error) {
  41336. if _, ok := m.driver.(*txDriver); !ok {
  41337. return nil, errors.New("ent: mutation is not running in a transaction")
  41338. }
  41339. tx := &Tx{config: m.config}
  41340. tx.init()
  41341. return tx, nil
  41342. }
  41343. // SetID sets the value of the id field. Note that this
  41344. // operation is only accepted on creation of WxCard entities.
  41345. func (m *WxCardMutation) SetID(id uint64) {
  41346. m.id = &id
  41347. }
  41348. // ID returns the ID value in the mutation. Note that the ID is only available
  41349. // if it was provided to the builder or after it was returned from the database.
  41350. func (m *WxCardMutation) ID() (id uint64, exists bool) {
  41351. if m.id == nil {
  41352. return
  41353. }
  41354. return *m.id, true
  41355. }
  41356. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  41357. // That means, if the mutation is applied within a transaction with an isolation level such
  41358. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  41359. // or updated by the mutation.
  41360. func (m *WxCardMutation) IDs(ctx context.Context) ([]uint64, error) {
  41361. switch {
  41362. case m.op.Is(OpUpdateOne | OpDeleteOne):
  41363. id, exists := m.ID()
  41364. if exists {
  41365. return []uint64{id}, nil
  41366. }
  41367. fallthrough
  41368. case m.op.Is(OpUpdate | OpDelete):
  41369. return m.Client().WxCard.Query().Where(m.predicates...).IDs(ctx)
  41370. default:
  41371. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  41372. }
  41373. }
  41374. // SetCreatedAt sets the "created_at" field.
  41375. func (m *WxCardMutation) SetCreatedAt(t time.Time) {
  41376. m.created_at = &t
  41377. }
  41378. // CreatedAt returns the value of the "created_at" field in the mutation.
  41379. func (m *WxCardMutation) CreatedAt() (r time.Time, exists bool) {
  41380. v := m.created_at
  41381. if v == nil {
  41382. return
  41383. }
  41384. return *v, true
  41385. }
  41386. // OldCreatedAt returns the old "created_at" field's value of the WxCard entity.
  41387. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  41388. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41389. func (m *WxCardMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  41390. if !m.op.Is(OpUpdateOne) {
  41391. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  41392. }
  41393. if m.id == nil || m.oldValue == nil {
  41394. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  41395. }
  41396. oldValue, err := m.oldValue(ctx)
  41397. if err != nil {
  41398. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  41399. }
  41400. return oldValue.CreatedAt, nil
  41401. }
  41402. // ResetCreatedAt resets all changes to the "created_at" field.
  41403. func (m *WxCardMutation) ResetCreatedAt() {
  41404. m.created_at = nil
  41405. }
  41406. // SetUpdatedAt sets the "updated_at" field.
  41407. func (m *WxCardMutation) SetUpdatedAt(t time.Time) {
  41408. m.updated_at = &t
  41409. }
  41410. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  41411. func (m *WxCardMutation) UpdatedAt() (r time.Time, exists bool) {
  41412. v := m.updated_at
  41413. if v == nil {
  41414. return
  41415. }
  41416. return *v, true
  41417. }
  41418. // OldUpdatedAt returns the old "updated_at" field's value of the WxCard entity.
  41419. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  41420. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41421. func (m *WxCardMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  41422. if !m.op.Is(OpUpdateOne) {
  41423. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  41424. }
  41425. if m.id == nil || m.oldValue == nil {
  41426. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  41427. }
  41428. oldValue, err := m.oldValue(ctx)
  41429. if err != nil {
  41430. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  41431. }
  41432. return oldValue.UpdatedAt, nil
  41433. }
  41434. // ResetUpdatedAt resets all changes to the "updated_at" field.
  41435. func (m *WxCardMutation) ResetUpdatedAt() {
  41436. m.updated_at = nil
  41437. }
  41438. // SetDeletedAt sets the "deleted_at" field.
  41439. func (m *WxCardMutation) SetDeletedAt(t time.Time) {
  41440. m.deleted_at = &t
  41441. }
  41442. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  41443. func (m *WxCardMutation) DeletedAt() (r time.Time, exists bool) {
  41444. v := m.deleted_at
  41445. if v == nil {
  41446. return
  41447. }
  41448. return *v, true
  41449. }
  41450. // OldDeletedAt returns the old "deleted_at" field's value of the WxCard entity.
  41451. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  41452. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41453. func (m *WxCardMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  41454. if !m.op.Is(OpUpdateOne) {
  41455. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  41456. }
  41457. if m.id == nil || m.oldValue == nil {
  41458. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  41459. }
  41460. oldValue, err := m.oldValue(ctx)
  41461. if err != nil {
  41462. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  41463. }
  41464. return oldValue.DeletedAt, nil
  41465. }
  41466. // ClearDeletedAt clears the value of the "deleted_at" field.
  41467. func (m *WxCardMutation) ClearDeletedAt() {
  41468. m.deleted_at = nil
  41469. m.clearedFields[wxcard.FieldDeletedAt] = struct{}{}
  41470. }
  41471. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  41472. func (m *WxCardMutation) DeletedAtCleared() bool {
  41473. _, ok := m.clearedFields[wxcard.FieldDeletedAt]
  41474. return ok
  41475. }
  41476. // ResetDeletedAt resets all changes to the "deleted_at" field.
  41477. func (m *WxCardMutation) ResetDeletedAt() {
  41478. m.deleted_at = nil
  41479. delete(m.clearedFields, wxcard.FieldDeletedAt)
  41480. }
  41481. // SetUserID sets the "user_id" field.
  41482. func (m *WxCardMutation) SetUserID(u uint64) {
  41483. m.user_id = &u
  41484. m.adduser_id = nil
  41485. }
  41486. // UserID returns the value of the "user_id" field in the mutation.
  41487. func (m *WxCardMutation) UserID() (r uint64, exists bool) {
  41488. v := m.user_id
  41489. if v == nil {
  41490. return
  41491. }
  41492. return *v, true
  41493. }
  41494. // OldUserID returns the old "user_id" field's value of the WxCard entity.
  41495. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  41496. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41497. func (m *WxCardMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  41498. if !m.op.Is(OpUpdateOne) {
  41499. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  41500. }
  41501. if m.id == nil || m.oldValue == nil {
  41502. return v, errors.New("OldUserID requires an ID field in the mutation")
  41503. }
  41504. oldValue, err := m.oldValue(ctx)
  41505. if err != nil {
  41506. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  41507. }
  41508. return oldValue.UserID, nil
  41509. }
  41510. // AddUserID adds u to the "user_id" field.
  41511. func (m *WxCardMutation) AddUserID(u int64) {
  41512. if m.adduser_id != nil {
  41513. *m.adduser_id += u
  41514. } else {
  41515. m.adduser_id = &u
  41516. }
  41517. }
  41518. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  41519. func (m *WxCardMutation) AddedUserID() (r int64, exists bool) {
  41520. v := m.adduser_id
  41521. if v == nil {
  41522. return
  41523. }
  41524. return *v, true
  41525. }
  41526. // ClearUserID clears the value of the "user_id" field.
  41527. func (m *WxCardMutation) ClearUserID() {
  41528. m.user_id = nil
  41529. m.adduser_id = nil
  41530. m.clearedFields[wxcard.FieldUserID] = struct{}{}
  41531. }
  41532. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  41533. func (m *WxCardMutation) UserIDCleared() bool {
  41534. _, ok := m.clearedFields[wxcard.FieldUserID]
  41535. return ok
  41536. }
  41537. // ResetUserID resets all changes to the "user_id" field.
  41538. func (m *WxCardMutation) ResetUserID() {
  41539. m.user_id = nil
  41540. m.adduser_id = nil
  41541. delete(m.clearedFields, wxcard.FieldUserID)
  41542. }
  41543. // SetWxUserID sets the "wx_user_id" field.
  41544. func (m *WxCardMutation) SetWxUserID(u uint64) {
  41545. m.wx_user_id = &u
  41546. m.addwx_user_id = nil
  41547. }
  41548. // WxUserID returns the value of the "wx_user_id" field in the mutation.
  41549. func (m *WxCardMutation) WxUserID() (r uint64, exists bool) {
  41550. v := m.wx_user_id
  41551. if v == nil {
  41552. return
  41553. }
  41554. return *v, true
  41555. }
  41556. // OldWxUserID returns the old "wx_user_id" field's value of the WxCard entity.
  41557. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  41558. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41559. func (m *WxCardMutation) OldWxUserID(ctx context.Context) (v uint64, err error) {
  41560. if !m.op.Is(OpUpdateOne) {
  41561. return v, errors.New("OldWxUserID is only allowed on UpdateOne operations")
  41562. }
  41563. if m.id == nil || m.oldValue == nil {
  41564. return v, errors.New("OldWxUserID requires an ID field in the mutation")
  41565. }
  41566. oldValue, err := m.oldValue(ctx)
  41567. if err != nil {
  41568. return v, fmt.Errorf("querying old value for OldWxUserID: %w", err)
  41569. }
  41570. return oldValue.WxUserID, nil
  41571. }
  41572. // AddWxUserID adds u to the "wx_user_id" field.
  41573. func (m *WxCardMutation) AddWxUserID(u int64) {
  41574. if m.addwx_user_id != nil {
  41575. *m.addwx_user_id += u
  41576. } else {
  41577. m.addwx_user_id = &u
  41578. }
  41579. }
  41580. // AddedWxUserID returns the value that was added to the "wx_user_id" field in this mutation.
  41581. func (m *WxCardMutation) AddedWxUserID() (r int64, exists bool) {
  41582. v := m.addwx_user_id
  41583. if v == nil {
  41584. return
  41585. }
  41586. return *v, true
  41587. }
  41588. // ClearWxUserID clears the value of the "wx_user_id" field.
  41589. func (m *WxCardMutation) ClearWxUserID() {
  41590. m.wx_user_id = nil
  41591. m.addwx_user_id = nil
  41592. m.clearedFields[wxcard.FieldWxUserID] = struct{}{}
  41593. }
  41594. // WxUserIDCleared returns if the "wx_user_id" field was cleared in this mutation.
  41595. func (m *WxCardMutation) WxUserIDCleared() bool {
  41596. _, ok := m.clearedFields[wxcard.FieldWxUserID]
  41597. return ok
  41598. }
  41599. // ResetWxUserID resets all changes to the "wx_user_id" field.
  41600. func (m *WxCardMutation) ResetWxUserID() {
  41601. m.wx_user_id = nil
  41602. m.addwx_user_id = nil
  41603. delete(m.clearedFields, wxcard.FieldWxUserID)
  41604. }
  41605. // SetAvatar sets the "avatar" field.
  41606. func (m *WxCardMutation) SetAvatar(s string) {
  41607. m.avatar = &s
  41608. }
  41609. // Avatar returns the value of the "avatar" field in the mutation.
  41610. func (m *WxCardMutation) Avatar() (r string, exists bool) {
  41611. v := m.avatar
  41612. if v == nil {
  41613. return
  41614. }
  41615. return *v, true
  41616. }
  41617. // OldAvatar returns the old "avatar" field's value of the WxCard entity.
  41618. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  41619. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41620. func (m *WxCardMutation) OldAvatar(ctx context.Context) (v string, err error) {
  41621. if !m.op.Is(OpUpdateOne) {
  41622. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  41623. }
  41624. if m.id == nil || m.oldValue == nil {
  41625. return v, errors.New("OldAvatar requires an ID field in the mutation")
  41626. }
  41627. oldValue, err := m.oldValue(ctx)
  41628. if err != nil {
  41629. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  41630. }
  41631. return oldValue.Avatar, nil
  41632. }
  41633. // ResetAvatar resets all changes to the "avatar" field.
  41634. func (m *WxCardMutation) ResetAvatar() {
  41635. m.avatar = nil
  41636. }
  41637. // SetLogo sets the "logo" field.
  41638. func (m *WxCardMutation) SetLogo(s string) {
  41639. m.logo = &s
  41640. }
  41641. // Logo returns the value of the "logo" field in the mutation.
  41642. func (m *WxCardMutation) Logo() (r string, exists bool) {
  41643. v := m.logo
  41644. if v == nil {
  41645. return
  41646. }
  41647. return *v, true
  41648. }
  41649. // OldLogo returns the old "logo" field's value of the WxCard entity.
  41650. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  41651. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41652. func (m *WxCardMutation) OldLogo(ctx context.Context) (v string, err error) {
  41653. if !m.op.Is(OpUpdateOne) {
  41654. return v, errors.New("OldLogo is only allowed on UpdateOne operations")
  41655. }
  41656. if m.id == nil || m.oldValue == nil {
  41657. return v, errors.New("OldLogo requires an ID field in the mutation")
  41658. }
  41659. oldValue, err := m.oldValue(ctx)
  41660. if err != nil {
  41661. return v, fmt.Errorf("querying old value for OldLogo: %w", err)
  41662. }
  41663. return oldValue.Logo, nil
  41664. }
  41665. // ResetLogo resets all changes to the "logo" field.
  41666. func (m *WxCardMutation) ResetLogo() {
  41667. m.logo = nil
  41668. }
  41669. // SetName sets the "name" field.
  41670. func (m *WxCardMutation) SetName(s string) {
  41671. m.name = &s
  41672. }
  41673. // Name returns the value of the "name" field in the mutation.
  41674. func (m *WxCardMutation) Name() (r string, exists bool) {
  41675. v := m.name
  41676. if v == nil {
  41677. return
  41678. }
  41679. return *v, true
  41680. }
  41681. // OldName returns the old "name" field's value of the WxCard entity.
  41682. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  41683. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41684. func (m *WxCardMutation) OldName(ctx context.Context) (v string, err error) {
  41685. if !m.op.Is(OpUpdateOne) {
  41686. return v, errors.New("OldName is only allowed on UpdateOne operations")
  41687. }
  41688. if m.id == nil || m.oldValue == nil {
  41689. return v, errors.New("OldName requires an ID field in the mutation")
  41690. }
  41691. oldValue, err := m.oldValue(ctx)
  41692. if err != nil {
  41693. return v, fmt.Errorf("querying old value for OldName: %w", err)
  41694. }
  41695. return oldValue.Name, nil
  41696. }
  41697. // ResetName resets all changes to the "name" field.
  41698. func (m *WxCardMutation) ResetName() {
  41699. m.name = nil
  41700. }
  41701. // SetCompany sets the "company" field.
  41702. func (m *WxCardMutation) SetCompany(s string) {
  41703. m.company = &s
  41704. }
  41705. // Company returns the value of the "company" field in the mutation.
  41706. func (m *WxCardMutation) Company() (r string, exists bool) {
  41707. v := m.company
  41708. if v == nil {
  41709. return
  41710. }
  41711. return *v, true
  41712. }
  41713. // OldCompany returns the old "company" field's value of the WxCard entity.
  41714. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  41715. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41716. func (m *WxCardMutation) OldCompany(ctx context.Context) (v string, err error) {
  41717. if !m.op.Is(OpUpdateOne) {
  41718. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  41719. }
  41720. if m.id == nil || m.oldValue == nil {
  41721. return v, errors.New("OldCompany requires an ID field in the mutation")
  41722. }
  41723. oldValue, err := m.oldValue(ctx)
  41724. if err != nil {
  41725. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  41726. }
  41727. return oldValue.Company, nil
  41728. }
  41729. // ResetCompany resets all changes to the "company" field.
  41730. func (m *WxCardMutation) ResetCompany() {
  41731. m.company = nil
  41732. }
  41733. // SetAddress sets the "address" field.
  41734. func (m *WxCardMutation) SetAddress(s string) {
  41735. m.address = &s
  41736. }
  41737. // Address returns the value of the "address" field in the mutation.
  41738. func (m *WxCardMutation) Address() (r string, exists bool) {
  41739. v := m.address
  41740. if v == nil {
  41741. return
  41742. }
  41743. return *v, true
  41744. }
  41745. // OldAddress returns the old "address" field's value of the WxCard entity.
  41746. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  41747. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41748. func (m *WxCardMutation) OldAddress(ctx context.Context) (v string, err error) {
  41749. if !m.op.Is(OpUpdateOne) {
  41750. return v, errors.New("OldAddress is only allowed on UpdateOne operations")
  41751. }
  41752. if m.id == nil || m.oldValue == nil {
  41753. return v, errors.New("OldAddress requires an ID field in the mutation")
  41754. }
  41755. oldValue, err := m.oldValue(ctx)
  41756. if err != nil {
  41757. return v, fmt.Errorf("querying old value for OldAddress: %w", err)
  41758. }
  41759. return oldValue.Address, nil
  41760. }
  41761. // ResetAddress resets all changes to the "address" field.
  41762. func (m *WxCardMutation) ResetAddress() {
  41763. m.address = nil
  41764. }
  41765. // SetPhone sets the "phone" field.
  41766. func (m *WxCardMutation) SetPhone(s string) {
  41767. m.phone = &s
  41768. }
  41769. // Phone returns the value of the "phone" field in the mutation.
  41770. func (m *WxCardMutation) Phone() (r string, exists bool) {
  41771. v := m.phone
  41772. if v == nil {
  41773. return
  41774. }
  41775. return *v, true
  41776. }
  41777. // OldPhone returns the old "phone" field's value of the WxCard entity.
  41778. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  41779. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41780. func (m *WxCardMutation) OldPhone(ctx context.Context) (v string, err error) {
  41781. if !m.op.Is(OpUpdateOne) {
  41782. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  41783. }
  41784. if m.id == nil || m.oldValue == nil {
  41785. return v, errors.New("OldPhone requires an ID field in the mutation")
  41786. }
  41787. oldValue, err := m.oldValue(ctx)
  41788. if err != nil {
  41789. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  41790. }
  41791. return oldValue.Phone, nil
  41792. }
  41793. // ResetPhone resets all changes to the "phone" field.
  41794. func (m *WxCardMutation) ResetPhone() {
  41795. m.phone = nil
  41796. }
  41797. // SetOfficialAccount sets the "official_account" field.
  41798. func (m *WxCardMutation) SetOfficialAccount(s string) {
  41799. m.official_account = &s
  41800. }
  41801. // OfficialAccount returns the value of the "official_account" field in the mutation.
  41802. func (m *WxCardMutation) OfficialAccount() (r string, exists bool) {
  41803. v := m.official_account
  41804. if v == nil {
  41805. return
  41806. }
  41807. return *v, true
  41808. }
  41809. // OldOfficialAccount returns the old "official_account" field's value of the WxCard entity.
  41810. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  41811. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41812. func (m *WxCardMutation) OldOfficialAccount(ctx context.Context) (v string, err error) {
  41813. if !m.op.Is(OpUpdateOne) {
  41814. return v, errors.New("OldOfficialAccount is only allowed on UpdateOne operations")
  41815. }
  41816. if m.id == nil || m.oldValue == nil {
  41817. return v, errors.New("OldOfficialAccount requires an ID field in the mutation")
  41818. }
  41819. oldValue, err := m.oldValue(ctx)
  41820. if err != nil {
  41821. return v, fmt.Errorf("querying old value for OldOfficialAccount: %w", err)
  41822. }
  41823. return oldValue.OfficialAccount, nil
  41824. }
  41825. // ResetOfficialAccount resets all changes to the "official_account" field.
  41826. func (m *WxCardMutation) ResetOfficialAccount() {
  41827. m.official_account = nil
  41828. }
  41829. // SetWechatAccount sets the "wechat_account" field.
  41830. func (m *WxCardMutation) SetWechatAccount(s string) {
  41831. m.wechat_account = &s
  41832. }
  41833. // WechatAccount returns the value of the "wechat_account" field in the mutation.
  41834. func (m *WxCardMutation) WechatAccount() (r string, exists bool) {
  41835. v := m.wechat_account
  41836. if v == nil {
  41837. return
  41838. }
  41839. return *v, true
  41840. }
  41841. // OldWechatAccount returns the old "wechat_account" field's value of the WxCard entity.
  41842. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  41843. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41844. func (m *WxCardMutation) OldWechatAccount(ctx context.Context) (v string, err error) {
  41845. if !m.op.Is(OpUpdateOne) {
  41846. return v, errors.New("OldWechatAccount is only allowed on UpdateOne operations")
  41847. }
  41848. if m.id == nil || m.oldValue == nil {
  41849. return v, errors.New("OldWechatAccount requires an ID field in the mutation")
  41850. }
  41851. oldValue, err := m.oldValue(ctx)
  41852. if err != nil {
  41853. return v, fmt.Errorf("querying old value for OldWechatAccount: %w", err)
  41854. }
  41855. return oldValue.WechatAccount, nil
  41856. }
  41857. // ResetWechatAccount resets all changes to the "wechat_account" field.
  41858. func (m *WxCardMutation) ResetWechatAccount() {
  41859. m.wechat_account = nil
  41860. }
  41861. // SetEmail sets the "email" field.
  41862. func (m *WxCardMutation) SetEmail(s string) {
  41863. m.email = &s
  41864. }
  41865. // Email returns the value of the "email" field in the mutation.
  41866. func (m *WxCardMutation) Email() (r string, exists bool) {
  41867. v := m.email
  41868. if v == nil {
  41869. return
  41870. }
  41871. return *v, true
  41872. }
  41873. // OldEmail returns the old "email" field's value of the WxCard entity.
  41874. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  41875. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41876. func (m *WxCardMutation) OldEmail(ctx context.Context) (v string, err error) {
  41877. if !m.op.Is(OpUpdateOne) {
  41878. return v, errors.New("OldEmail is only allowed on UpdateOne operations")
  41879. }
  41880. if m.id == nil || m.oldValue == nil {
  41881. return v, errors.New("OldEmail requires an ID field in the mutation")
  41882. }
  41883. oldValue, err := m.oldValue(ctx)
  41884. if err != nil {
  41885. return v, fmt.Errorf("querying old value for OldEmail: %w", err)
  41886. }
  41887. return oldValue.Email, nil
  41888. }
  41889. // ClearEmail clears the value of the "email" field.
  41890. func (m *WxCardMutation) ClearEmail() {
  41891. m.email = nil
  41892. m.clearedFields[wxcard.FieldEmail] = struct{}{}
  41893. }
  41894. // EmailCleared returns if the "email" field was cleared in this mutation.
  41895. func (m *WxCardMutation) EmailCleared() bool {
  41896. _, ok := m.clearedFields[wxcard.FieldEmail]
  41897. return ok
  41898. }
  41899. // ResetEmail resets all changes to the "email" field.
  41900. func (m *WxCardMutation) ResetEmail() {
  41901. m.email = nil
  41902. delete(m.clearedFields, wxcard.FieldEmail)
  41903. }
  41904. // SetAPIBase sets the "api_base" field.
  41905. func (m *WxCardMutation) SetAPIBase(s string) {
  41906. m.api_base = &s
  41907. }
  41908. // APIBase returns the value of the "api_base" field in the mutation.
  41909. func (m *WxCardMutation) APIBase() (r string, exists bool) {
  41910. v := m.api_base
  41911. if v == nil {
  41912. return
  41913. }
  41914. return *v, true
  41915. }
  41916. // OldAPIBase returns the old "api_base" field's value of the WxCard entity.
  41917. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  41918. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41919. func (m *WxCardMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  41920. if !m.op.Is(OpUpdateOne) {
  41921. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  41922. }
  41923. if m.id == nil || m.oldValue == nil {
  41924. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  41925. }
  41926. oldValue, err := m.oldValue(ctx)
  41927. if err != nil {
  41928. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  41929. }
  41930. return oldValue.APIBase, nil
  41931. }
  41932. // ClearAPIBase clears the value of the "api_base" field.
  41933. func (m *WxCardMutation) ClearAPIBase() {
  41934. m.api_base = nil
  41935. m.clearedFields[wxcard.FieldAPIBase] = struct{}{}
  41936. }
  41937. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  41938. func (m *WxCardMutation) APIBaseCleared() bool {
  41939. _, ok := m.clearedFields[wxcard.FieldAPIBase]
  41940. return ok
  41941. }
  41942. // ResetAPIBase resets all changes to the "api_base" field.
  41943. func (m *WxCardMutation) ResetAPIBase() {
  41944. m.api_base = nil
  41945. delete(m.clearedFields, wxcard.FieldAPIBase)
  41946. }
  41947. // SetAPIKey sets the "api_key" field.
  41948. func (m *WxCardMutation) SetAPIKey(s string) {
  41949. m.api_key = &s
  41950. }
  41951. // APIKey returns the value of the "api_key" field in the mutation.
  41952. func (m *WxCardMutation) APIKey() (r string, exists bool) {
  41953. v := m.api_key
  41954. if v == nil {
  41955. return
  41956. }
  41957. return *v, true
  41958. }
  41959. // OldAPIKey returns the old "api_key" field's value of the WxCard entity.
  41960. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  41961. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41962. func (m *WxCardMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  41963. if !m.op.Is(OpUpdateOne) {
  41964. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  41965. }
  41966. if m.id == nil || m.oldValue == nil {
  41967. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  41968. }
  41969. oldValue, err := m.oldValue(ctx)
  41970. if err != nil {
  41971. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  41972. }
  41973. return oldValue.APIKey, nil
  41974. }
  41975. // ClearAPIKey clears the value of the "api_key" field.
  41976. func (m *WxCardMutation) ClearAPIKey() {
  41977. m.api_key = nil
  41978. m.clearedFields[wxcard.FieldAPIKey] = struct{}{}
  41979. }
  41980. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  41981. func (m *WxCardMutation) APIKeyCleared() bool {
  41982. _, ok := m.clearedFields[wxcard.FieldAPIKey]
  41983. return ok
  41984. }
  41985. // ResetAPIKey resets all changes to the "api_key" field.
  41986. func (m *WxCardMutation) ResetAPIKey() {
  41987. m.api_key = nil
  41988. delete(m.clearedFields, wxcard.FieldAPIKey)
  41989. }
  41990. // SetAiInfo sets the "ai_info" field.
  41991. func (m *WxCardMutation) SetAiInfo(s string) {
  41992. m.ai_info = &s
  41993. }
  41994. // AiInfo returns the value of the "ai_info" field in the mutation.
  41995. func (m *WxCardMutation) AiInfo() (r string, exists bool) {
  41996. v := m.ai_info
  41997. if v == nil {
  41998. return
  41999. }
  42000. return *v, true
  42001. }
  42002. // OldAiInfo returns the old "ai_info" field's value of the WxCard entity.
  42003. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  42004. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42005. func (m *WxCardMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  42006. if !m.op.Is(OpUpdateOne) {
  42007. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  42008. }
  42009. if m.id == nil || m.oldValue == nil {
  42010. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  42011. }
  42012. oldValue, err := m.oldValue(ctx)
  42013. if err != nil {
  42014. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  42015. }
  42016. return oldValue.AiInfo, nil
  42017. }
  42018. // ClearAiInfo clears the value of the "ai_info" field.
  42019. func (m *WxCardMutation) ClearAiInfo() {
  42020. m.ai_info = nil
  42021. m.clearedFields[wxcard.FieldAiInfo] = struct{}{}
  42022. }
  42023. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  42024. func (m *WxCardMutation) AiInfoCleared() bool {
  42025. _, ok := m.clearedFields[wxcard.FieldAiInfo]
  42026. return ok
  42027. }
  42028. // ResetAiInfo resets all changes to the "ai_info" field.
  42029. func (m *WxCardMutation) ResetAiInfo() {
  42030. m.ai_info = nil
  42031. delete(m.clearedFields, wxcard.FieldAiInfo)
  42032. }
  42033. // SetIntro sets the "intro" field.
  42034. func (m *WxCardMutation) SetIntro(s string) {
  42035. m.intro = &s
  42036. }
  42037. // Intro returns the value of the "intro" field in the mutation.
  42038. func (m *WxCardMutation) Intro() (r string, exists bool) {
  42039. v := m.intro
  42040. if v == nil {
  42041. return
  42042. }
  42043. return *v, true
  42044. }
  42045. // OldIntro returns the old "intro" field's value of the WxCard entity.
  42046. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  42047. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42048. func (m *WxCardMutation) OldIntro(ctx context.Context) (v string, err error) {
  42049. if !m.op.Is(OpUpdateOne) {
  42050. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  42051. }
  42052. if m.id == nil || m.oldValue == nil {
  42053. return v, errors.New("OldIntro requires an ID field in the mutation")
  42054. }
  42055. oldValue, err := m.oldValue(ctx)
  42056. if err != nil {
  42057. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  42058. }
  42059. return oldValue.Intro, nil
  42060. }
  42061. // ClearIntro clears the value of the "intro" field.
  42062. func (m *WxCardMutation) ClearIntro() {
  42063. m.intro = nil
  42064. m.clearedFields[wxcard.FieldIntro] = struct{}{}
  42065. }
  42066. // IntroCleared returns if the "intro" field was cleared in this mutation.
  42067. func (m *WxCardMutation) IntroCleared() bool {
  42068. _, ok := m.clearedFields[wxcard.FieldIntro]
  42069. return ok
  42070. }
  42071. // ResetIntro resets all changes to the "intro" field.
  42072. func (m *WxCardMutation) ResetIntro() {
  42073. m.intro = nil
  42074. delete(m.clearedFields, wxcard.FieldIntro)
  42075. }
  42076. // Where appends a list predicates to the WxCardMutation builder.
  42077. func (m *WxCardMutation) Where(ps ...predicate.WxCard) {
  42078. m.predicates = append(m.predicates, ps...)
  42079. }
  42080. // WhereP appends storage-level predicates to the WxCardMutation builder. Using this method,
  42081. // users can use type-assertion to append predicates that do not depend on any generated package.
  42082. func (m *WxCardMutation) WhereP(ps ...func(*sql.Selector)) {
  42083. p := make([]predicate.WxCard, len(ps))
  42084. for i := range ps {
  42085. p[i] = ps[i]
  42086. }
  42087. m.Where(p...)
  42088. }
  42089. // Op returns the operation name.
  42090. func (m *WxCardMutation) Op() Op {
  42091. return m.op
  42092. }
  42093. // SetOp allows setting the mutation operation.
  42094. func (m *WxCardMutation) SetOp(op Op) {
  42095. m.op = op
  42096. }
  42097. // Type returns the node type of this mutation (WxCard).
  42098. func (m *WxCardMutation) Type() string {
  42099. return m.typ
  42100. }
  42101. // Fields returns all fields that were changed during this mutation. Note that in
  42102. // order to get all numeric fields that were incremented/decremented, call
  42103. // AddedFields().
  42104. func (m *WxCardMutation) Fields() []string {
  42105. fields := make([]string, 0, 18)
  42106. if m.created_at != nil {
  42107. fields = append(fields, wxcard.FieldCreatedAt)
  42108. }
  42109. if m.updated_at != nil {
  42110. fields = append(fields, wxcard.FieldUpdatedAt)
  42111. }
  42112. if m.deleted_at != nil {
  42113. fields = append(fields, wxcard.FieldDeletedAt)
  42114. }
  42115. if m.user_id != nil {
  42116. fields = append(fields, wxcard.FieldUserID)
  42117. }
  42118. if m.wx_user_id != nil {
  42119. fields = append(fields, wxcard.FieldWxUserID)
  42120. }
  42121. if m.avatar != nil {
  42122. fields = append(fields, wxcard.FieldAvatar)
  42123. }
  42124. if m.logo != nil {
  42125. fields = append(fields, wxcard.FieldLogo)
  42126. }
  42127. if m.name != nil {
  42128. fields = append(fields, wxcard.FieldName)
  42129. }
  42130. if m.company != nil {
  42131. fields = append(fields, wxcard.FieldCompany)
  42132. }
  42133. if m.address != nil {
  42134. fields = append(fields, wxcard.FieldAddress)
  42135. }
  42136. if m.phone != nil {
  42137. fields = append(fields, wxcard.FieldPhone)
  42138. }
  42139. if m.official_account != nil {
  42140. fields = append(fields, wxcard.FieldOfficialAccount)
  42141. }
  42142. if m.wechat_account != nil {
  42143. fields = append(fields, wxcard.FieldWechatAccount)
  42144. }
  42145. if m.email != nil {
  42146. fields = append(fields, wxcard.FieldEmail)
  42147. }
  42148. if m.api_base != nil {
  42149. fields = append(fields, wxcard.FieldAPIBase)
  42150. }
  42151. if m.api_key != nil {
  42152. fields = append(fields, wxcard.FieldAPIKey)
  42153. }
  42154. if m.ai_info != nil {
  42155. fields = append(fields, wxcard.FieldAiInfo)
  42156. }
  42157. if m.intro != nil {
  42158. fields = append(fields, wxcard.FieldIntro)
  42159. }
  42160. return fields
  42161. }
  42162. // Field returns the value of a field with the given name. The second boolean
  42163. // return value indicates that this field was not set, or was not defined in the
  42164. // schema.
  42165. func (m *WxCardMutation) Field(name string) (ent.Value, bool) {
  42166. switch name {
  42167. case wxcard.FieldCreatedAt:
  42168. return m.CreatedAt()
  42169. case wxcard.FieldUpdatedAt:
  42170. return m.UpdatedAt()
  42171. case wxcard.FieldDeletedAt:
  42172. return m.DeletedAt()
  42173. case wxcard.FieldUserID:
  42174. return m.UserID()
  42175. case wxcard.FieldWxUserID:
  42176. return m.WxUserID()
  42177. case wxcard.FieldAvatar:
  42178. return m.Avatar()
  42179. case wxcard.FieldLogo:
  42180. return m.Logo()
  42181. case wxcard.FieldName:
  42182. return m.Name()
  42183. case wxcard.FieldCompany:
  42184. return m.Company()
  42185. case wxcard.FieldAddress:
  42186. return m.Address()
  42187. case wxcard.FieldPhone:
  42188. return m.Phone()
  42189. case wxcard.FieldOfficialAccount:
  42190. return m.OfficialAccount()
  42191. case wxcard.FieldWechatAccount:
  42192. return m.WechatAccount()
  42193. case wxcard.FieldEmail:
  42194. return m.Email()
  42195. case wxcard.FieldAPIBase:
  42196. return m.APIBase()
  42197. case wxcard.FieldAPIKey:
  42198. return m.APIKey()
  42199. case wxcard.FieldAiInfo:
  42200. return m.AiInfo()
  42201. case wxcard.FieldIntro:
  42202. return m.Intro()
  42203. }
  42204. return nil, false
  42205. }
  42206. // OldField returns the old value of the field from the database. An error is
  42207. // returned if the mutation operation is not UpdateOne, or the query to the
  42208. // database failed.
  42209. func (m *WxCardMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  42210. switch name {
  42211. case wxcard.FieldCreatedAt:
  42212. return m.OldCreatedAt(ctx)
  42213. case wxcard.FieldUpdatedAt:
  42214. return m.OldUpdatedAt(ctx)
  42215. case wxcard.FieldDeletedAt:
  42216. return m.OldDeletedAt(ctx)
  42217. case wxcard.FieldUserID:
  42218. return m.OldUserID(ctx)
  42219. case wxcard.FieldWxUserID:
  42220. return m.OldWxUserID(ctx)
  42221. case wxcard.FieldAvatar:
  42222. return m.OldAvatar(ctx)
  42223. case wxcard.FieldLogo:
  42224. return m.OldLogo(ctx)
  42225. case wxcard.FieldName:
  42226. return m.OldName(ctx)
  42227. case wxcard.FieldCompany:
  42228. return m.OldCompany(ctx)
  42229. case wxcard.FieldAddress:
  42230. return m.OldAddress(ctx)
  42231. case wxcard.FieldPhone:
  42232. return m.OldPhone(ctx)
  42233. case wxcard.FieldOfficialAccount:
  42234. return m.OldOfficialAccount(ctx)
  42235. case wxcard.FieldWechatAccount:
  42236. return m.OldWechatAccount(ctx)
  42237. case wxcard.FieldEmail:
  42238. return m.OldEmail(ctx)
  42239. case wxcard.FieldAPIBase:
  42240. return m.OldAPIBase(ctx)
  42241. case wxcard.FieldAPIKey:
  42242. return m.OldAPIKey(ctx)
  42243. case wxcard.FieldAiInfo:
  42244. return m.OldAiInfo(ctx)
  42245. case wxcard.FieldIntro:
  42246. return m.OldIntro(ctx)
  42247. }
  42248. return nil, fmt.Errorf("unknown WxCard field %s", name)
  42249. }
  42250. // SetField sets the value of a field with the given name. It returns an error if
  42251. // the field is not defined in the schema, or if the type mismatched the field
  42252. // type.
  42253. func (m *WxCardMutation) SetField(name string, value ent.Value) error {
  42254. switch name {
  42255. case wxcard.FieldCreatedAt:
  42256. v, ok := value.(time.Time)
  42257. if !ok {
  42258. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42259. }
  42260. m.SetCreatedAt(v)
  42261. return nil
  42262. case wxcard.FieldUpdatedAt:
  42263. v, ok := value.(time.Time)
  42264. if !ok {
  42265. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42266. }
  42267. m.SetUpdatedAt(v)
  42268. return nil
  42269. case wxcard.FieldDeletedAt:
  42270. v, ok := value.(time.Time)
  42271. if !ok {
  42272. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42273. }
  42274. m.SetDeletedAt(v)
  42275. return nil
  42276. case wxcard.FieldUserID:
  42277. v, ok := value.(uint64)
  42278. if !ok {
  42279. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42280. }
  42281. m.SetUserID(v)
  42282. return nil
  42283. case wxcard.FieldWxUserID:
  42284. v, ok := value.(uint64)
  42285. if !ok {
  42286. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42287. }
  42288. m.SetWxUserID(v)
  42289. return nil
  42290. case wxcard.FieldAvatar:
  42291. v, ok := value.(string)
  42292. if !ok {
  42293. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42294. }
  42295. m.SetAvatar(v)
  42296. return nil
  42297. case wxcard.FieldLogo:
  42298. v, ok := value.(string)
  42299. if !ok {
  42300. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42301. }
  42302. m.SetLogo(v)
  42303. return nil
  42304. case wxcard.FieldName:
  42305. v, ok := value.(string)
  42306. if !ok {
  42307. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42308. }
  42309. m.SetName(v)
  42310. return nil
  42311. case wxcard.FieldCompany:
  42312. v, ok := value.(string)
  42313. if !ok {
  42314. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42315. }
  42316. m.SetCompany(v)
  42317. return nil
  42318. case wxcard.FieldAddress:
  42319. v, ok := value.(string)
  42320. if !ok {
  42321. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42322. }
  42323. m.SetAddress(v)
  42324. return nil
  42325. case wxcard.FieldPhone:
  42326. v, ok := value.(string)
  42327. if !ok {
  42328. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42329. }
  42330. m.SetPhone(v)
  42331. return nil
  42332. case wxcard.FieldOfficialAccount:
  42333. v, ok := value.(string)
  42334. if !ok {
  42335. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42336. }
  42337. m.SetOfficialAccount(v)
  42338. return nil
  42339. case wxcard.FieldWechatAccount:
  42340. v, ok := value.(string)
  42341. if !ok {
  42342. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42343. }
  42344. m.SetWechatAccount(v)
  42345. return nil
  42346. case wxcard.FieldEmail:
  42347. v, ok := value.(string)
  42348. if !ok {
  42349. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42350. }
  42351. m.SetEmail(v)
  42352. return nil
  42353. case wxcard.FieldAPIBase:
  42354. v, ok := value.(string)
  42355. if !ok {
  42356. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42357. }
  42358. m.SetAPIBase(v)
  42359. return nil
  42360. case wxcard.FieldAPIKey:
  42361. v, ok := value.(string)
  42362. if !ok {
  42363. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42364. }
  42365. m.SetAPIKey(v)
  42366. return nil
  42367. case wxcard.FieldAiInfo:
  42368. v, ok := value.(string)
  42369. if !ok {
  42370. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42371. }
  42372. m.SetAiInfo(v)
  42373. return nil
  42374. case wxcard.FieldIntro:
  42375. v, ok := value.(string)
  42376. if !ok {
  42377. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42378. }
  42379. m.SetIntro(v)
  42380. return nil
  42381. }
  42382. return fmt.Errorf("unknown WxCard field %s", name)
  42383. }
  42384. // AddedFields returns all numeric fields that were incremented/decremented during
  42385. // this mutation.
  42386. func (m *WxCardMutation) AddedFields() []string {
  42387. var fields []string
  42388. if m.adduser_id != nil {
  42389. fields = append(fields, wxcard.FieldUserID)
  42390. }
  42391. if m.addwx_user_id != nil {
  42392. fields = append(fields, wxcard.FieldWxUserID)
  42393. }
  42394. return fields
  42395. }
  42396. // AddedField returns the numeric value that was incremented/decremented on a field
  42397. // with the given name. The second boolean return value indicates that this field
  42398. // was not set, or was not defined in the schema.
  42399. func (m *WxCardMutation) AddedField(name string) (ent.Value, bool) {
  42400. switch name {
  42401. case wxcard.FieldUserID:
  42402. return m.AddedUserID()
  42403. case wxcard.FieldWxUserID:
  42404. return m.AddedWxUserID()
  42405. }
  42406. return nil, false
  42407. }
  42408. // AddField adds the value to the field with the given name. It returns an error if
  42409. // the field is not defined in the schema, or if the type mismatched the field
  42410. // type.
  42411. func (m *WxCardMutation) AddField(name string, value ent.Value) error {
  42412. switch name {
  42413. case wxcard.FieldUserID:
  42414. v, ok := value.(int64)
  42415. if !ok {
  42416. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42417. }
  42418. m.AddUserID(v)
  42419. return nil
  42420. case wxcard.FieldWxUserID:
  42421. v, ok := value.(int64)
  42422. if !ok {
  42423. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42424. }
  42425. m.AddWxUserID(v)
  42426. return nil
  42427. }
  42428. return fmt.Errorf("unknown WxCard numeric field %s", name)
  42429. }
  42430. // ClearedFields returns all nullable fields that were cleared during this
  42431. // mutation.
  42432. func (m *WxCardMutation) ClearedFields() []string {
  42433. var fields []string
  42434. if m.FieldCleared(wxcard.FieldDeletedAt) {
  42435. fields = append(fields, wxcard.FieldDeletedAt)
  42436. }
  42437. if m.FieldCleared(wxcard.FieldUserID) {
  42438. fields = append(fields, wxcard.FieldUserID)
  42439. }
  42440. if m.FieldCleared(wxcard.FieldWxUserID) {
  42441. fields = append(fields, wxcard.FieldWxUserID)
  42442. }
  42443. if m.FieldCleared(wxcard.FieldEmail) {
  42444. fields = append(fields, wxcard.FieldEmail)
  42445. }
  42446. if m.FieldCleared(wxcard.FieldAPIBase) {
  42447. fields = append(fields, wxcard.FieldAPIBase)
  42448. }
  42449. if m.FieldCleared(wxcard.FieldAPIKey) {
  42450. fields = append(fields, wxcard.FieldAPIKey)
  42451. }
  42452. if m.FieldCleared(wxcard.FieldAiInfo) {
  42453. fields = append(fields, wxcard.FieldAiInfo)
  42454. }
  42455. if m.FieldCleared(wxcard.FieldIntro) {
  42456. fields = append(fields, wxcard.FieldIntro)
  42457. }
  42458. return fields
  42459. }
  42460. // FieldCleared returns a boolean indicating if a field with the given name was
  42461. // cleared in this mutation.
  42462. func (m *WxCardMutation) FieldCleared(name string) bool {
  42463. _, ok := m.clearedFields[name]
  42464. return ok
  42465. }
  42466. // ClearField clears the value of the field with the given name. It returns an
  42467. // error if the field is not defined in the schema.
  42468. func (m *WxCardMutation) ClearField(name string) error {
  42469. switch name {
  42470. case wxcard.FieldDeletedAt:
  42471. m.ClearDeletedAt()
  42472. return nil
  42473. case wxcard.FieldUserID:
  42474. m.ClearUserID()
  42475. return nil
  42476. case wxcard.FieldWxUserID:
  42477. m.ClearWxUserID()
  42478. return nil
  42479. case wxcard.FieldEmail:
  42480. m.ClearEmail()
  42481. return nil
  42482. case wxcard.FieldAPIBase:
  42483. m.ClearAPIBase()
  42484. return nil
  42485. case wxcard.FieldAPIKey:
  42486. m.ClearAPIKey()
  42487. return nil
  42488. case wxcard.FieldAiInfo:
  42489. m.ClearAiInfo()
  42490. return nil
  42491. case wxcard.FieldIntro:
  42492. m.ClearIntro()
  42493. return nil
  42494. }
  42495. return fmt.Errorf("unknown WxCard nullable field %s", name)
  42496. }
  42497. // ResetField resets all changes in the mutation for the field with the given name.
  42498. // It returns an error if the field is not defined in the schema.
  42499. func (m *WxCardMutation) ResetField(name string) error {
  42500. switch name {
  42501. case wxcard.FieldCreatedAt:
  42502. m.ResetCreatedAt()
  42503. return nil
  42504. case wxcard.FieldUpdatedAt:
  42505. m.ResetUpdatedAt()
  42506. return nil
  42507. case wxcard.FieldDeletedAt:
  42508. m.ResetDeletedAt()
  42509. return nil
  42510. case wxcard.FieldUserID:
  42511. m.ResetUserID()
  42512. return nil
  42513. case wxcard.FieldWxUserID:
  42514. m.ResetWxUserID()
  42515. return nil
  42516. case wxcard.FieldAvatar:
  42517. m.ResetAvatar()
  42518. return nil
  42519. case wxcard.FieldLogo:
  42520. m.ResetLogo()
  42521. return nil
  42522. case wxcard.FieldName:
  42523. m.ResetName()
  42524. return nil
  42525. case wxcard.FieldCompany:
  42526. m.ResetCompany()
  42527. return nil
  42528. case wxcard.FieldAddress:
  42529. m.ResetAddress()
  42530. return nil
  42531. case wxcard.FieldPhone:
  42532. m.ResetPhone()
  42533. return nil
  42534. case wxcard.FieldOfficialAccount:
  42535. m.ResetOfficialAccount()
  42536. return nil
  42537. case wxcard.FieldWechatAccount:
  42538. m.ResetWechatAccount()
  42539. return nil
  42540. case wxcard.FieldEmail:
  42541. m.ResetEmail()
  42542. return nil
  42543. case wxcard.FieldAPIBase:
  42544. m.ResetAPIBase()
  42545. return nil
  42546. case wxcard.FieldAPIKey:
  42547. m.ResetAPIKey()
  42548. return nil
  42549. case wxcard.FieldAiInfo:
  42550. m.ResetAiInfo()
  42551. return nil
  42552. case wxcard.FieldIntro:
  42553. m.ResetIntro()
  42554. return nil
  42555. }
  42556. return fmt.Errorf("unknown WxCard field %s", name)
  42557. }
  42558. // AddedEdges returns all edge names that were set/added in this mutation.
  42559. func (m *WxCardMutation) AddedEdges() []string {
  42560. edges := make([]string, 0, 0)
  42561. return edges
  42562. }
  42563. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  42564. // name in this mutation.
  42565. func (m *WxCardMutation) AddedIDs(name string) []ent.Value {
  42566. return nil
  42567. }
  42568. // RemovedEdges returns all edge names that were removed in this mutation.
  42569. func (m *WxCardMutation) RemovedEdges() []string {
  42570. edges := make([]string, 0, 0)
  42571. return edges
  42572. }
  42573. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  42574. // the given name in this mutation.
  42575. func (m *WxCardMutation) RemovedIDs(name string) []ent.Value {
  42576. return nil
  42577. }
  42578. // ClearedEdges returns all edge names that were cleared in this mutation.
  42579. func (m *WxCardMutation) ClearedEdges() []string {
  42580. edges := make([]string, 0, 0)
  42581. return edges
  42582. }
  42583. // EdgeCleared returns a boolean which indicates if the edge with the given name
  42584. // was cleared in this mutation.
  42585. func (m *WxCardMutation) EdgeCleared(name string) bool {
  42586. return false
  42587. }
  42588. // ClearEdge clears the value of the edge with the given name. It returns an error
  42589. // if that edge is not defined in the schema.
  42590. func (m *WxCardMutation) ClearEdge(name string) error {
  42591. return fmt.Errorf("unknown WxCard unique edge %s", name)
  42592. }
  42593. // ResetEdge resets all changes to the edge with the given name in this mutation.
  42594. // It returns an error if the edge is not defined in the schema.
  42595. func (m *WxCardMutation) ResetEdge(name string) error {
  42596. return fmt.Errorf("unknown WxCard edge %s", name)
  42597. }
  42598. // WxCardUserMutation represents an operation that mutates the WxCardUser nodes in the graph.
  42599. type WxCardUserMutation struct {
  42600. config
  42601. op Op
  42602. typ string
  42603. id *uint64
  42604. created_at *time.Time
  42605. updated_at *time.Time
  42606. deleted_at *time.Time
  42607. wxid *string
  42608. account *string
  42609. avatar *string
  42610. nickname *string
  42611. remark *string
  42612. phone *string
  42613. open_id *string
  42614. union_id *string
  42615. session_key *string
  42616. is_vip *int
  42617. addis_vip *int
  42618. clearedFields map[string]struct{}
  42619. done bool
  42620. oldValue func(context.Context) (*WxCardUser, error)
  42621. predicates []predicate.WxCardUser
  42622. }
  42623. var _ ent.Mutation = (*WxCardUserMutation)(nil)
  42624. // wxcarduserOption allows management of the mutation configuration using functional options.
  42625. type wxcarduserOption func(*WxCardUserMutation)
  42626. // newWxCardUserMutation creates new mutation for the WxCardUser entity.
  42627. func newWxCardUserMutation(c config, op Op, opts ...wxcarduserOption) *WxCardUserMutation {
  42628. m := &WxCardUserMutation{
  42629. config: c,
  42630. op: op,
  42631. typ: TypeWxCardUser,
  42632. clearedFields: make(map[string]struct{}),
  42633. }
  42634. for _, opt := range opts {
  42635. opt(m)
  42636. }
  42637. return m
  42638. }
  42639. // withWxCardUserID sets the ID field of the mutation.
  42640. func withWxCardUserID(id uint64) wxcarduserOption {
  42641. return func(m *WxCardUserMutation) {
  42642. var (
  42643. err error
  42644. once sync.Once
  42645. value *WxCardUser
  42646. )
  42647. m.oldValue = func(ctx context.Context) (*WxCardUser, error) {
  42648. once.Do(func() {
  42649. if m.done {
  42650. err = errors.New("querying old values post mutation is not allowed")
  42651. } else {
  42652. value, err = m.Client().WxCardUser.Get(ctx, id)
  42653. }
  42654. })
  42655. return value, err
  42656. }
  42657. m.id = &id
  42658. }
  42659. }
  42660. // withWxCardUser sets the old WxCardUser of the mutation.
  42661. func withWxCardUser(node *WxCardUser) wxcarduserOption {
  42662. return func(m *WxCardUserMutation) {
  42663. m.oldValue = func(context.Context) (*WxCardUser, error) {
  42664. return node, nil
  42665. }
  42666. m.id = &node.ID
  42667. }
  42668. }
  42669. // Client returns a new `ent.Client` from the mutation. If the mutation was
  42670. // executed in a transaction (ent.Tx), a transactional client is returned.
  42671. func (m WxCardUserMutation) Client() *Client {
  42672. client := &Client{config: m.config}
  42673. client.init()
  42674. return client
  42675. }
  42676. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  42677. // it returns an error otherwise.
  42678. func (m WxCardUserMutation) Tx() (*Tx, error) {
  42679. if _, ok := m.driver.(*txDriver); !ok {
  42680. return nil, errors.New("ent: mutation is not running in a transaction")
  42681. }
  42682. tx := &Tx{config: m.config}
  42683. tx.init()
  42684. return tx, nil
  42685. }
  42686. // SetID sets the value of the id field. Note that this
  42687. // operation is only accepted on creation of WxCardUser entities.
  42688. func (m *WxCardUserMutation) SetID(id uint64) {
  42689. m.id = &id
  42690. }
  42691. // ID returns the ID value in the mutation. Note that the ID is only available
  42692. // if it was provided to the builder or after it was returned from the database.
  42693. func (m *WxCardUserMutation) ID() (id uint64, exists bool) {
  42694. if m.id == nil {
  42695. return
  42696. }
  42697. return *m.id, true
  42698. }
  42699. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  42700. // That means, if the mutation is applied within a transaction with an isolation level such
  42701. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  42702. // or updated by the mutation.
  42703. func (m *WxCardUserMutation) IDs(ctx context.Context) ([]uint64, error) {
  42704. switch {
  42705. case m.op.Is(OpUpdateOne | OpDeleteOne):
  42706. id, exists := m.ID()
  42707. if exists {
  42708. return []uint64{id}, nil
  42709. }
  42710. fallthrough
  42711. case m.op.Is(OpUpdate | OpDelete):
  42712. return m.Client().WxCardUser.Query().Where(m.predicates...).IDs(ctx)
  42713. default:
  42714. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  42715. }
  42716. }
  42717. // SetCreatedAt sets the "created_at" field.
  42718. func (m *WxCardUserMutation) SetCreatedAt(t time.Time) {
  42719. m.created_at = &t
  42720. }
  42721. // CreatedAt returns the value of the "created_at" field in the mutation.
  42722. func (m *WxCardUserMutation) CreatedAt() (r time.Time, exists bool) {
  42723. v := m.created_at
  42724. if v == nil {
  42725. return
  42726. }
  42727. return *v, true
  42728. }
  42729. // OldCreatedAt returns the old "created_at" field's value of the WxCardUser entity.
  42730. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  42731. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42732. func (m *WxCardUserMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  42733. if !m.op.Is(OpUpdateOne) {
  42734. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  42735. }
  42736. if m.id == nil || m.oldValue == nil {
  42737. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  42738. }
  42739. oldValue, err := m.oldValue(ctx)
  42740. if err != nil {
  42741. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  42742. }
  42743. return oldValue.CreatedAt, nil
  42744. }
  42745. // ResetCreatedAt resets all changes to the "created_at" field.
  42746. func (m *WxCardUserMutation) ResetCreatedAt() {
  42747. m.created_at = nil
  42748. }
  42749. // SetUpdatedAt sets the "updated_at" field.
  42750. func (m *WxCardUserMutation) SetUpdatedAt(t time.Time) {
  42751. m.updated_at = &t
  42752. }
  42753. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  42754. func (m *WxCardUserMutation) UpdatedAt() (r time.Time, exists bool) {
  42755. v := m.updated_at
  42756. if v == nil {
  42757. return
  42758. }
  42759. return *v, true
  42760. }
  42761. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardUser entity.
  42762. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  42763. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42764. func (m *WxCardUserMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  42765. if !m.op.Is(OpUpdateOne) {
  42766. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  42767. }
  42768. if m.id == nil || m.oldValue == nil {
  42769. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  42770. }
  42771. oldValue, err := m.oldValue(ctx)
  42772. if err != nil {
  42773. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  42774. }
  42775. return oldValue.UpdatedAt, nil
  42776. }
  42777. // ResetUpdatedAt resets all changes to the "updated_at" field.
  42778. func (m *WxCardUserMutation) ResetUpdatedAt() {
  42779. m.updated_at = nil
  42780. }
  42781. // SetDeletedAt sets the "deleted_at" field.
  42782. func (m *WxCardUserMutation) SetDeletedAt(t time.Time) {
  42783. m.deleted_at = &t
  42784. }
  42785. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  42786. func (m *WxCardUserMutation) DeletedAt() (r time.Time, exists bool) {
  42787. v := m.deleted_at
  42788. if v == nil {
  42789. return
  42790. }
  42791. return *v, true
  42792. }
  42793. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardUser entity.
  42794. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  42795. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42796. func (m *WxCardUserMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  42797. if !m.op.Is(OpUpdateOne) {
  42798. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  42799. }
  42800. if m.id == nil || m.oldValue == nil {
  42801. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  42802. }
  42803. oldValue, err := m.oldValue(ctx)
  42804. if err != nil {
  42805. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  42806. }
  42807. return oldValue.DeletedAt, nil
  42808. }
  42809. // ClearDeletedAt clears the value of the "deleted_at" field.
  42810. func (m *WxCardUserMutation) ClearDeletedAt() {
  42811. m.deleted_at = nil
  42812. m.clearedFields[wxcarduser.FieldDeletedAt] = struct{}{}
  42813. }
  42814. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  42815. func (m *WxCardUserMutation) DeletedAtCleared() bool {
  42816. _, ok := m.clearedFields[wxcarduser.FieldDeletedAt]
  42817. return ok
  42818. }
  42819. // ResetDeletedAt resets all changes to the "deleted_at" field.
  42820. func (m *WxCardUserMutation) ResetDeletedAt() {
  42821. m.deleted_at = nil
  42822. delete(m.clearedFields, wxcarduser.FieldDeletedAt)
  42823. }
  42824. // SetWxid sets the "wxid" field.
  42825. func (m *WxCardUserMutation) SetWxid(s string) {
  42826. m.wxid = &s
  42827. }
  42828. // Wxid returns the value of the "wxid" field in the mutation.
  42829. func (m *WxCardUserMutation) Wxid() (r string, exists bool) {
  42830. v := m.wxid
  42831. if v == nil {
  42832. return
  42833. }
  42834. return *v, true
  42835. }
  42836. // OldWxid returns the old "wxid" field's value of the WxCardUser entity.
  42837. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  42838. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42839. func (m *WxCardUserMutation) OldWxid(ctx context.Context) (v string, err error) {
  42840. if !m.op.Is(OpUpdateOne) {
  42841. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  42842. }
  42843. if m.id == nil || m.oldValue == nil {
  42844. return v, errors.New("OldWxid requires an ID field in the mutation")
  42845. }
  42846. oldValue, err := m.oldValue(ctx)
  42847. if err != nil {
  42848. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  42849. }
  42850. return oldValue.Wxid, nil
  42851. }
  42852. // ResetWxid resets all changes to the "wxid" field.
  42853. func (m *WxCardUserMutation) ResetWxid() {
  42854. m.wxid = nil
  42855. }
  42856. // SetAccount sets the "account" field.
  42857. func (m *WxCardUserMutation) SetAccount(s string) {
  42858. m.account = &s
  42859. }
  42860. // Account returns the value of the "account" field in the mutation.
  42861. func (m *WxCardUserMutation) Account() (r string, exists bool) {
  42862. v := m.account
  42863. if v == nil {
  42864. return
  42865. }
  42866. return *v, true
  42867. }
  42868. // OldAccount returns the old "account" field's value of the WxCardUser entity.
  42869. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  42870. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42871. func (m *WxCardUserMutation) OldAccount(ctx context.Context) (v string, err error) {
  42872. if !m.op.Is(OpUpdateOne) {
  42873. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  42874. }
  42875. if m.id == nil || m.oldValue == nil {
  42876. return v, errors.New("OldAccount requires an ID field in the mutation")
  42877. }
  42878. oldValue, err := m.oldValue(ctx)
  42879. if err != nil {
  42880. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  42881. }
  42882. return oldValue.Account, nil
  42883. }
  42884. // ResetAccount resets all changes to the "account" field.
  42885. func (m *WxCardUserMutation) ResetAccount() {
  42886. m.account = nil
  42887. }
  42888. // SetAvatar sets the "avatar" field.
  42889. func (m *WxCardUserMutation) SetAvatar(s string) {
  42890. m.avatar = &s
  42891. }
  42892. // Avatar returns the value of the "avatar" field in the mutation.
  42893. func (m *WxCardUserMutation) Avatar() (r string, exists bool) {
  42894. v := m.avatar
  42895. if v == nil {
  42896. return
  42897. }
  42898. return *v, true
  42899. }
  42900. // OldAvatar returns the old "avatar" field's value of the WxCardUser entity.
  42901. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  42902. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42903. func (m *WxCardUserMutation) OldAvatar(ctx context.Context) (v string, err error) {
  42904. if !m.op.Is(OpUpdateOne) {
  42905. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  42906. }
  42907. if m.id == nil || m.oldValue == nil {
  42908. return v, errors.New("OldAvatar requires an ID field in the mutation")
  42909. }
  42910. oldValue, err := m.oldValue(ctx)
  42911. if err != nil {
  42912. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  42913. }
  42914. return oldValue.Avatar, nil
  42915. }
  42916. // ResetAvatar resets all changes to the "avatar" field.
  42917. func (m *WxCardUserMutation) ResetAvatar() {
  42918. m.avatar = nil
  42919. }
  42920. // SetNickname sets the "nickname" field.
  42921. func (m *WxCardUserMutation) SetNickname(s string) {
  42922. m.nickname = &s
  42923. }
  42924. // Nickname returns the value of the "nickname" field in the mutation.
  42925. func (m *WxCardUserMutation) Nickname() (r string, exists bool) {
  42926. v := m.nickname
  42927. if v == nil {
  42928. return
  42929. }
  42930. return *v, true
  42931. }
  42932. // OldNickname returns the old "nickname" field's value of the WxCardUser entity.
  42933. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  42934. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42935. func (m *WxCardUserMutation) OldNickname(ctx context.Context) (v string, err error) {
  42936. if !m.op.Is(OpUpdateOne) {
  42937. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  42938. }
  42939. if m.id == nil || m.oldValue == nil {
  42940. return v, errors.New("OldNickname requires an ID field in the mutation")
  42941. }
  42942. oldValue, err := m.oldValue(ctx)
  42943. if err != nil {
  42944. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  42945. }
  42946. return oldValue.Nickname, nil
  42947. }
  42948. // ResetNickname resets all changes to the "nickname" field.
  42949. func (m *WxCardUserMutation) ResetNickname() {
  42950. m.nickname = nil
  42951. }
  42952. // SetRemark sets the "remark" field.
  42953. func (m *WxCardUserMutation) SetRemark(s string) {
  42954. m.remark = &s
  42955. }
  42956. // Remark returns the value of the "remark" field in the mutation.
  42957. func (m *WxCardUserMutation) Remark() (r string, exists bool) {
  42958. v := m.remark
  42959. if v == nil {
  42960. return
  42961. }
  42962. return *v, true
  42963. }
  42964. // OldRemark returns the old "remark" field's value of the WxCardUser entity.
  42965. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  42966. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42967. func (m *WxCardUserMutation) OldRemark(ctx context.Context) (v string, err error) {
  42968. if !m.op.Is(OpUpdateOne) {
  42969. return v, errors.New("OldRemark is only allowed on UpdateOne operations")
  42970. }
  42971. if m.id == nil || m.oldValue == nil {
  42972. return v, errors.New("OldRemark requires an ID field in the mutation")
  42973. }
  42974. oldValue, err := m.oldValue(ctx)
  42975. if err != nil {
  42976. return v, fmt.Errorf("querying old value for OldRemark: %w", err)
  42977. }
  42978. return oldValue.Remark, nil
  42979. }
  42980. // ResetRemark resets all changes to the "remark" field.
  42981. func (m *WxCardUserMutation) ResetRemark() {
  42982. m.remark = nil
  42983. }
  42984. // SetPhone sets the "phone" field.
  42985. func (m *WxCardUserMutation) SetPhone(s string) {
  42986. m.phone = &s
  42987. }
  42988. // Phone returns the value of the "phone" field in the mutation.
  42989. func (m *WxCardUserMutation) Phone() (r string, exists bool) {
  42990. v := m.phone
  42991. if v == nil {
  42992. return
  42993. }
  42994. return *v, true
  42995. }
  42996. // OldPhone returns the old "phone" field's value of the WxCardUser entity.
  42997. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  42998. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42999. func (m *WxCardUserMutation) OldPhone(ctx context.Context) (v string, err error) {
  43000. if !m.op.Is(OpUpdateOne) {
  43001. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  43002. }
  43003. if m.id == nil || m.oldValue == nil {
  43004. return v, errors.New("OldPhone requires an ID field in the mutation")
  43005. }
  43006. oldValue, err := m.oldValue(ctx)
  43007. if err != nil {
  43008. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  43009. }
  43010. return oldValue.Phone, nil
  43011. }
  43012. // ResetPhone resets all changes to the "phone" field.
  43013. func (m *WxCardUserMutation) ResetPhone() {
  43014. m.phone = nil
  43015. }
  43016. // SetOpenID sets the "open_id" field.
  43017. func (m *WxCardUserMutation) SetOpenID(s string) {
  43018. m.open_id = &s
  43019. }
  43020. // OpenID returns the value of the "open_id" field in the mutation.
  43021. func (m *WxCardUserMutation) OpenID() (r string, exists bool) {
  43022. v := m.open_id
  43023. if v == nil {
  43024. return
  43025. }
  43026. return *v, true
  43027. }
  43028. // OldOpenID returns the old "open_id" field's value of the WxCardUser entity.
  43029. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  43030. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43031. func (m *WxCardUserMutation) OldOpenID(ctx context.Context) (v string, err error) {
  43032. if !m.op.Is(OpUpdateOne) {
  43033. return v, errors.New("OldOpenID is only allowed on UpdateOne operations")
  43034. }
  43035. if m.id == nil || m.oldValue == nil {
  43036. return v, errors.New("OldOpenID requires an ID field in the mutation")
  43037. }
  43038. oldValue, err := m.oldValue(ctx)
  43039. if err != nil {
  43040. return v, fmt.Errorf("querying old value for OldOpenID: %w", err)
  43041. }
  43042. return oldValue.OpenID, nil
  43043. }
  43044. // ResetOpenID resets all changes to the "open_id" field.
  43045. func (m *WxCardUserMutation) ResetOpenID() {
  43046. m.open_id = nil
  43047. }
  43048. // SetUnionID sets the "union_id" field.
  43049. func (m *WxCardUserMutation) SetUnionID(s string) {
  43050. m.union_id = &s
  43051. }
  43052. // UnionID returns the value of the "union_id" field in the mutation.
  43053. func (m *WxCardUserMutation) UnionID() (r string, exists bool) {
  43054. v := m.union_id
  43055. if v == nil {
  43056. return
  43057. }
  43058. return *v, true
  43059. }
  43060. // OldUnionID returns the old "union_id" field's value of the WxCardUser entity.
  43061. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  43062. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43063. func (m *WxCardUserMutation) OldUnionID(ctx context.Context) (v string, err error) {
  43064. if !m.op.Is(OpUpdateOne) {
  43065. return v, errors.New("OldUnionID is only allowed on UpdateOne operations")
  43066. }
  43067. if m.id == nil || m.oldValue == nil {
  43068. return v, errors.New("OldUnionID requires an ID field in the mutation")
  43069. }
  43070. oldValue, err := m.oldValue(ctx)
  43071. if err != nil {
  43072. return v, fmt.Errorf("querying old value for OldUnionID: %w", err)
  43073. }
  43074. return oldValue.UnionID, nil
  43075. }
  43076. // ResetUnionID resets all changes to the "union_id" field.
  43077. func (m *WxCardUserMutation) ResetUnionID() {
  43078. m.union_id = nil
  43079. }
  43080. // SetSessionKey sets the "session_key" field.
  43081. func (m *WxCardUserMutation) SetSessionKey(s string) {
  43082. m.session_key = &s
  43083. }
  43084. // SessionKey returns the value of the "session_key" field in the mutation.
  43085. func (m *WxCardUserMutation) SessionKey() (r string, exists bool) {
  43086. v := m.session_key
  43087. if v == nil {
  43088. return
  43089. }
  43090. return *v, true
  43091. }
  43092. // OldSessionKey returns the old "session_key" field's value of the WxCardUser entity.
  43093. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  43094. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43095. func (m *WxCardUserMutation) OldSessionKey(ctx context.Context) (v string, err error) {
  43096. if !m.op.Is(OpUpdateOne) {
  43097. return v, errors.New("OldSessionKey is only allowed on UpdateOne operations")
  43098. }
  43099. if m.id == nil || m.oldValue == nil {
  43100. return v, errors.New("OldSessionKey requires an ID field in the mutation")
  43101. }
  43102. oldValue, err := m.oldValue(ctx)
  43103. if err != nil {
  43104. return v, fmt.Errorf("querying old value for OldSessionKey: %w", err)
  43105. }
  43106. return oldValue.SessionKey, nil
  43107. }
  43108. // ResetSessionKey resets all changes to the "session_key" field.
  43109. func (m *WxCardUserMutation) ResetSessionKey() {
  43110. m.session_key = nil
  43111. }
  43112. // SetIsVip sets the "is_vip" field.
  43113. func (m *WxCardUserMutation) SetIsVip(i int) {
  43114. m.is_vip = &i
  43115. m.addis_vip = nil
  43116. }
  43117. // IsVip returns the value of the "is_vip" field in the mutation.
  43118. func (m *WxCardUserMutation) IsVip() (r int, exists bool) {
  43119. v := m.is_vip
  43120. if v == nil {
  43121. return
  43122. }
  43123. return *v, true
  43124. }
  43125. // OldIsVip returns the old "is_vip" field's value of the WxCardUser entity.
  43126. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  43127. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43128. func (m *WxCardUserMutation) OldIsVip(ctx context.Context) (v int, err error) {
  43129. if !m.op.Is(OpUpdateOne) {
  43130. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  43131. }
  43132. if m.id == nil || m.oldValue == nil {
  43133. return v, errors.New("OldIsVip requires an ID field in the mutation")
  43134. }
  43135. oldValue, err := m.oldValue(ctx)
  43136. if err != nil {
  43137. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  43138. }
  43139. return oldValue.IsVip, nil
  43140. }
  43141. // AddIsVip adds i to the "is_vip" field.
  43142. func (m *WxCardUserMutation) AddIsVip(i int) {
  43143. if m.addis_vip != nil {
  43144. *m.addis_vip += i
  43145. } else {
  43146. m.addis_vip = &i
  43147. }
  43148. }
  43149. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  43150. func (m *WxCardUserMutation) AddedIsVip() (r int, exists bool) {
  43151. v := m.addis_vip
  43152. if v == nil {
  43153. return
  43154. }
  43155. return *v, true
  43156. }
  43157. // ResetIsVip resets all changes to the "is_vip" field.
  43158. func (m *WxCardUserMutation) ResetIsVip() {
  43159. m.is_vip = nil
  43160. m.addis_vip = nil
  43161. }
  43162. // Where appends a list predicates to the WxCardUserMutation builder.
  43163. func (m *WxCardUserMutation) Where(ps ...predicate.WxCardUser) {
  43164. m.predicates = append(m.predicates, ps...)
  43165. }
  43166. // WhereP appends storage-level predicates to the WxCardUserMutation builder. Using this method,
  43167. // users can use type-assertion to append predicates that do not depend on any generated package.
  43168. func (m *WxCardUserMutation) WhereP(ps ...func(*sql.Selector)) {
  43169. p := make([]predicate.WxCardUser, len(ps))
  43170. for i := range ps {
  43171. p[i] = ps[i]
  43172. }
  43173. m.Where(p...)
  43174. }
  43175. // Op returns the operation name.
  43176. func (m *WxCardUserMutation) Op() Op {
  43177. return m.op
  43178. }
  43179. // SetOp allows setting the mutation operation.
  43180. func (m *WxCardUserMutation) SetOp(op Op) {
  43181. m.op = op
  43182. }
  43183. // Type returns the node type of this mutation (WxCardUser).
  43184. func (m *WxCardUserMutation) Type() string {
  43185. return m.typ
  43186. }
  43187. // Fields returns all fields that were changed during this mutation. Note that in
  43188. // order to get all numeric fields that were incremented/decremented, call
  43189. // AddedFields().
  43190. func (m *WxCardUserMutation) Fields() []string {
  43191. fields := make([]string, 0, 13)
  43192. if m.created_at != nil {
  43193. fields = append(fields, wxcarduser.FieldCreatedAt)
  43194. }
  43195. if m.updated_at != nil {
  43196. fields = append(fields, wxcarduser.FieldUpdatedAt)
  43197. }
  43198. if m.deleted_at != nil {
  43199. fields = append(fields, wxcarduser.FieldDeletedAt)
  43200. }
  43201. if m.wxid != nil {
  43202. fields = append(fields, wxcarduser.FieldWxid)
  43203. }
  43204. if m.account != nil {
  43205. fields = append(fields, wxcarduser.FieldAccount)
  43206. }
  43207. if m.avatar != nil {
  43208. fields = append(fields, wxcarduser.FieldAvatar)
  43209. }
  43210. if m.nickname != nil {
  43211. fields = append(fields, wxcarduser.FieldNickname)
  43212. }
  43213. if m.remark != nil {
  43214. fields = append(fields, wxcarduser.FieldRemark)
  43215. }
  43216. if m.phone != nil {
  43217. fields = append(fields, wxcarduser.FieldPhone)
  43218. }
  43219. if m.open_id != nil {
  43220. fields = append(fields, wxcarduser.FieldOpenID)
  43221. }
  43222. if m.union_id != nil {
  43223. fields = append(fields, wxcarduser.FieldUnionID)
  43224. }
  43225. if m.session_key != nil {
  43226. fields = append(fields, wxcarduser.FieldSessionKey)
  43227. }
  43228. if m.is_vip != nil {
  43229. fields = append(fields, wxcarduser.FieldIsVip)
  43230. }
  43231. return fields
  43232. }
  43233. // Field returns the value of a field with the given name. The second boolean
  43234. // return value indicates that this field was not set, or was not defined in the
  43235. // schema.
  43236. func (m *WxCardUserMutation) Field(name string) (ent.Value, bool) {
  43237. switch name {
  43238. case wxcarduser.FieldCreatedAt:
  43239. return m.CreatedAt()
  43240. case wxcarduser.FieldUpdatedAt:
  43241. return m.UpdatedAt()
  43242. case wxcarduser.FieldDeletedAt:
  43243. return m.DeletedAt()
  43244. case wxcarduser.FieldWxid:
  43245. return m.Wxid()
  43246. case wxcarduser.FieldAccount:
  43247. return m.Account()
  43248. case wxcarduser.FieldAvatar:
  43249. return m.Avatar()
  43250. case wxcarduser.FieldNickname:
  43251. return m.Nickname()
  43252. case wxcarduser.FieldRemark:
  43253. return m.Remark()
  43254. case wxcarduser.FieldPhone:
  43255. return m.Phone()
  43256. case wxcarduser.FieldOpenID:
  43257. return m.OpenID()
  43258. case wxcarduser.FieldUnionID:
  43259. return m.UnionID()
  43260. case wxcarduser.FieldSessionKey:
  43261. return m.SessionKey()
  43262. case wxcarduser.FieldIsVip:
  43263. return m.IsVip()
  43264. }
  43265. return nil, false
  43266. }
  43267. // OldField returns the old value of the field from the database. An error is
  43268. // returned if the mutation operation is not UpdateOne, or the query to the
  43269. // database failed.
  43270. func (m *WxCardUserMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  43271. switch name {
  43272. case wxcarduser.FieldCreatedAt:
  43273. return m.OldCreatedAt(ctx)
  43274. case wxcarduser.FieldUpdatedAt:
  43275. return m.OldUpdatedAt(ctx)
  43276. case wxcarduser.FieldDeletedAt:
  43277. return m.OldDeletedAt(ctx)
  43278. case wxcarduser.FieldWxid:
  43279. return m.OldWxid(ctx)
  43280. case wxcarduser.FieldAccount:
  43281. return m.OldAccount(ctx)
  43282. case wxcarduser.FieldAvatar:
  43283. return m.OldAvatar(ctx)
  43284. case wxcarduser.FieldNickname:
  43285. return m.OldNickname(ctx)
  43286. case wxcarduser.FieldRemark:
  43287. return m.OldRemark(ctx)
  43288. case wxcarduser.FieldPhone:
  43289. return m.OldPhone(ctx)
  43290. case wxcarduser.FieldOpenID:
  43291. return m.OldOpenID(ctx)
  43292. case wxcarduser.FieldUnionID:
  43293. return m.OldUnionID(ctx)
  43294. case wxcarduser.FieldSessionKey:
  43295. return m.OldSessionKey(ctx)
  43296. case wxcarduser.FieldIsVip:
  43297. return m.OldIsVip(ctx)
  43298. }
  43299. return nil, fmt.Errorf("unknown WxCardUser field %s", name)
  43300. }
  43301. // SetField sets the value of a field with the given name. It returns an error if
  43302. // the field is not defined in the schema, or if the type mismatched the field
  43303. // type.
  43304. func (m *WxCardUserMutation) SetField(name string, value ent.Value) error {
  43305. switch name {
  43306. case wxcarduser.FieldCreatedAt:
  43307. v, ok := value.(time.Time)
  43308. if !ok {
  43309. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43310. }
  43311. m.SetCreatedAt(v)
  43312. return nil
  43313. case wxcarduser.FieldUpdatedAt:
  43314. v, ok := value.(time.Time)
  43315. if !ok {
  43316. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43317. }
  43318. m.SetUpdatedAt(v)
  43319. return nil
  43320. case wxcarduser.FieldDeletedAt:
  43321. v, ok := value.(time.Time)
  43322. if !ok {
  43323. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43324. }
  43325. m.SetDeletedAt(v)
  43326. return nil
  43327. case wxcarduser.FieldWxid:
  43328. v, ok := value.(string)
  43329. if !ok {
  43330. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43331. }
  43332. m.SetWxid(v)
  43333. return nil
  43334. case wxcarduser.FieldAccount:
  43335. v, ok := value.(string)
  43336. if !ok {
  43337. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43338. }
  43339. m.SetAccount(v)
  43340. return nil
  43341. case wxcarduser.FieldAvatar:
  43342. v, ok := value.(string)
  43343. if !ok {
  43344. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43345. }
  43346. m.SetAvatar(v)
  43347. return nil
  43348. case wxcarduser.FieldNickname:
  43349. v, ok := value.(string)
  43350. if !ok {
  43351. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43352. }
  43353. m.SetNickname(v)
  43354. return nil
  43355. case wxcarduser.FieldRemark:
  43356. v, ok := value.(string)
  43357. if !ok {
  43358. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43359. }
  43360. m.SetRemark(v)
  43361. return nil
  43362. case wxcarduser.FieldPhone:
  43363. v, ok := value.(string)
  43364. if !ok {
  43365. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43366. }
  43367. m.SetPhone(v)
  43368. return nil
  43369. case wxcarduser.FieldOpenID:
  43370. v, ok := value.(string)
  43371. if !ok {
  43372. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43373. }
  43374. m.SetOpenID(v)
  43375. return nil
  43376. case wxcarduser.FieldUnionID:
  43377. v, ok := value.(string)
  43378. if !ok {
  43379. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43380. }
  43381. m.SetUnionID(v)
  43382. return nil
  43383. case wxcarduser.FieldSessionKey:
  43384. v, ok := value.(string)
  43385. if !ok {
  43386. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43387. }
  43388. m.SetSessionKey(v)
  43389. return nil
  43390. case wxcarduser.FieldIsVip:
  43391. v, ok := value.(int)
  43392. if !ok {
  43393. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43394. }
  43395. m.SetIsVip(v)
  43396. return nil
  43397. }
  43398. return fmt.Errorf("unknown WxCardUser field %s", name)
  43399. }
  43400. // AddedFields returns all numeric fields that were incremented/decremented during
  43401. // this mutation.
  43402. func (m *WxCardUserMutation) AddedFields() []string {
  43403. var fields []string
  43404. if m.addis_vip != nil {
  43405. fields = append(fields, wxcarduser.FieldIsVip)
  43406. }
  43407. return fields
  43408. }
  43409. // AddedField returns the numeric value that was incremented/decremented on a field
  43410. // with the given name. The second boolean return value indicates that this field
  43411. // was not set, or was not defined in the schema.
  43412. func (m *WxCardUserMutation) AddedField(name string) (ent.Value, bool) {
  43413. switch name {
  43414. case wxcarduser.FieldIsVip:
  43415. return m.AddedIsVip()
  43416. }
  43417. return nil, false
  43418. }
  43419. // AddField adds the value to the field with the given name. It returns an error if
  43420. // the field is not defined in the schema, or if the type mismatched the field
  43421. // type.
  43422. func (m *WxCardUserMutation) AddField(name string, value ent.Value) error {
  43423. switch name {
  43424. case wxcarduser.FieldIsVip:
  43425. v, ok := value.(int)
  43426. if !ok {
  43427. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43428. }
  43429. m.AddIsVip(v)
  43430. return nil
  43431. }
  43432. return fmt.Errorf("unknown WxCardUser numeric field %s", name)
  43433. }
  43434. // ClearedFields returns all nullable fields that were cleared during this
  43435. // mutation.
  43436. func (m *WxCardUserMutation) ClearedFields() []string {
  43437. var fields []string
  43438. if m.FieldCleared(wxcarduser.FieldDeletedAt) {
  43439. fields = append(fields, wxcarduser.FieldDeletedAt)
  43440. }
  43441. return fields
  43442. }
  43443. // FieldCleared returns a boolean indicating if a field with the given name was
  43444. // cleared in this mutation.
  43445. func (m *WxCardUserMutation) FieldCleared(name string) bool {
  43446. _, ok := m.clearedFields[name]
  43447. return ok
  43448. }
  43449. // ClearField clears the value of the field with the given name. It returns an
  43450. // error if the field is not defined in the schema.
  43451. func (m *WxCardUserMutation) ClearField(name string) error {
  43452. switch name {
  43453. case wxcarduser.FieldDeletedAt:
  43454. m.ClearDeletedAt()
  43455. return nil
  43456. }
  43457. return fmt.Errorf("unknown WxCardUser nullable field %s", name)
  43458. }
  43459. // ResetField resets all changes in the mutation for the field with the given name.
  43460. // It returns an error if the field is not defined in the schema.
  43461. func (m *WxCardUserMutation) ResetField(name string) error {
  43462. switch name {
  43463. case wxcarduser.FieldCreatedAt:
  43464. m.ResetCreatedAt()
  43465. return nil
  43466. case wxcarduser.FieldUpdatedAt:
  43467. m.ResetUpdatedAt()
  43468. return nil
  43469. case wxcarduser.FieldDeletedAt:
  43470. m.ResetDeletedAt()
  43471. return nil
  43472. case wxcarduser.FieldWxid:
  43473. m.ResetWxid()
  43474. return nil
  43475. case wxcarduser.FieldAccount:
  43476. m.ResetAccount()
  43477. return nil
  43478. case wxcarduser.FieldAvatar:
  43479. m.ResetAvatar()
  43480. return nil
  43481. case wxcarduser.FieldNickname:
  43482. m.ResetNickname()
  43483. return nil
  43484. case wxcarduser.FieldRemark:
  43485. m.ResetRemark()
  43486. return nil
  43487. case wxcarduser.FieldPhone:
  43488. m.ResetPhone()
  43489. return nil
  43490. case wxcarduser.FieldOpenID:
  43491. m.ResetOpenID()
  43492. return nil
  43493. case wxcarduser.FieldUnionID:
  43494. m.ResetUnionID()
  43495. return nil
  43496. case wxcarduser.FieldSessionKey:
  43497. m.ResetSessionKey()
  43498. return nil
  43499. case wxcarduser.FieldIsVip:
  43500. m.ResetIsVip()
  43501. return nil
  43502. }
  43503. return fmt.Errorf("unknown WxCardUser field %s", name)
  43504. }
  43505. // AddedEdges returns all edge names that were set/added in this mutation.
  43506. func (m *WxCardUserMutation) AddedEdges() []string {
  43507. edges := make([]string, 0, 0)
  43508. return edges
  43509. }
  43510. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  43511. // name in this mutation.
  43512. func (m *WxCardUserMutation) AddedIDs(name string) []ent.Value {
  43513. return nil
  43514. }
  43515. // RemovedEdges returns all edge names that were removed in this mutation.
  43516. func (m *WxCardUserMutation) RemovedEdges() []string {
  43517. edges := make([]string, 0, 0)
  43518. return edges
  43519. }
  43520. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  43521. // the given name in this mutation.
  43522. func (m *WxCardUserMutation) RemovedIDs(name string) []ent.Value {
  43523. return nil
  43524. }
  43525. // ClearedEdges returns all edge names that were cleared in this mutation.
  43526. func (m *WxCardUserMutation) ClearedEdges() []string {
  43527. edges := make([]string, 0, 0)
  43528. return edges
  43529. }
  43530. // EdgeCleared returns a boolean which indicates if the edge with the given name
  43531. // was cleared in this mutation.
  43532. func (m *WxCardUserMutation) EdgeCleared(name string) bool {
  43533. return false
  43534. }
  43535. // ClearEdge clears the value of the edge with the given name. It returns an error
  43536. // if that edge is not defined in the schema.
  43537. func (m *WxCardUserMutation) ClearEdge(name string) error {
  43538. return fmt.Errorf("unknown WxCardUser unique edge %s", name)
  43539. }
  43540. // ResetEdge resets all changes to the edge with the given name in this mutation.
  43541. // It returns an error if the edge is not defined in the schema.
  43542. func (m *WxCardUserMutation) ResetEdge(name string) error {
  43543. return fmt.Errorf("unknown WxCardUser edge %s", name)
  43544. }
  43545. // WxCardVisitMutation represents an operation that mutates the WxCardVisit nodes in the graph.
  43546. type WxCardVisitMutation struct {
  43547. config
  43548. op Op
  43549. typ string
  43550. id *uint64
  43551. created_at *time.Time
  43552. updated_at *time.Time
  43553. deleted_at *time.Time
  43554. user_id *uint64
  43555. adduser_id *int64
  43556. bot_id *uint64
  43557. addbot_id *int64
  43558. bot_type *uint8
  43559. addbot_type *int8
  43560. clearedFields map[string]struct{}
  43561. done bool
  43562. oldValue func(context.Context) (*WxCardVisit, error)
  43563. predicates []predicate.WxCardVisit
  43564. }
  43565. var _ ent.Mutation = (*WxCardVisitMutation)(nil)
  43566. // wxcardvisitOption allows management of the mutation configuration using functional options.
  43567. type wxcardvisitOption func(*WxCardVisitMutation)
  43568. // newWxCardVisitMutation creates new mutation for the WxCardVisit entity.
  43569. func newWxCardVisitMutation(c config, op Op, opts ...wxcardvisitOption) *WxCardVisitMutation {
  43570. m := &WxCardVisitMutation{
  43571. config: c,
  43572. op: op,
  43573. typ: TypeWxCardVisit,
  43574. clearedFields: make(map[string]struct{}),
  43575. }
  43576. for _, opt := range opts {
  43577. opt(m)
  43578. }
  43579. return m
  43580. }
  43581. // withWxCardVisitID sets the ID field of the mutation.
  43582. func withWxCardVisitID(id uint64) wxcardvisitOption {
  43583. return func(m *WxCardVisitMutation) {
  43584. var (
  43585. err error
  43586. once sync.Once
  43587. value *WxCardVisit
  43588. )
  43589. m.oldValue = func(ctx context.Context) (*WxCardVisit, error) {
  43590. once.Do(func() {
  43591. if m.done {
  43592. err = errors.New("querying old values post mutation is not allowed")
  43593. } else {
  43594. value, err = m.Client().WxCardVisit.Get(ctx, id)
  43595. }
  43596. })
  43597. return value, err
  43598. }
  43599. m.id = &id
  43600. }
  43601. }
  43602. // withWxCardVisit sets the old WxCardVisit of the mutation.
  43603. func withWxCardVisit(node *WxCardVisit) wxcardvisitOption {
  43604. return func(m *WxCardVisitMutation) {
  43605. m.oldValue = func(context.Context) (*WxCardVisit, error) {
  43606. return node, nil
  43607. }
  43608. m.id = &node.ID
  43609. }
  43610. }
  43611. // Client returns a new `ent.Client` from the mutation. If the mutation was
  43612. // executed in a transaction (ent.Tx), a transactional client is returned.
  43613. func (m WxCardVisitMutation) Client() *Client {
  43614. client := &Client{config: m.config}
  43615. client.init()
  43616. return client
  43617. }
  43618. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  43619. // it returns an error otherwise.
  43620. func (m WxCardVisitMutation) Tx() (*Tx, error) {
  43621. if _, ok := m.driver.(*txDriver); !ok {
  43622. return nil, errors.New("ent: mutation is not running in a transaction")
  43623. }
  43624. tx := &Tx{config: m.config}
  43625. tx.init()
  43626. return tx, nil
  43627. }
  43628. // SetID sets the value of the id field. Note that this
  43629. // operation is only accepted on creation of WxCardVisit entities.
  43630. func (m *WxCardVisitMutation) SetID(id uint64) {
  43631. m.id = &id
  43632. }
  43633. // ID returns the ID value in the mutation. Note that the ID is only available
  43634. // if it was provided to the builder or after it was returned from the database.
  43635. func (m *WxCardVisitMutation) ID() (id uint64, exists bool) {
  43636. if m.id == nil {
  43637. return
  43638. }
  43639. return *m.id, true
  43640. }
  43641. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  43642. // That means, if the mutation is applied within a transaction with an isolation level such
  43643. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  43644. // or updated by the mutation.
  43645. func (m *WxCardVisitMutation) IDs(ctx context.Context) ([]uint64, error) {
  43646. switch {
  43647. case m.op.Is(OpUpdateOne | OpDeleteOne):
  43648. id, exists := m.ID()
  43649. if exists {
  43650. return []uint64{id}, nil
  43651. }
  43652. fallthrough
  43653. case m.op.Is(OpUpdate | OpDelete):
  43654. return m.Client().WxCardVisit.Query().Where(m.predicates...).IDs(ctx)
  43655. default:
  43656. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  43657. }
  43658. }
  43659. // SetCreatedAt sets the "created_at" field.
  43660. func (m *WxCardVisitMutation) SetCreatedAt(t time.Time) {
  43661. m.created_at = &t
  43662. }
  43663. // CreatedAt returns the value of the "created_at" field in the mutation.
  43664. func (m *WxCardVisitMutation) CreatedAt() (r time.Time, exists bool) {
  43665. v := m.created_at
  43666. if v == nil {
  43667. return
  43668. }
  43669. return *v, true
  43670. }
  43671. // OldCreatedAt returns the old "created_at" field's value of the WxCardVisit entity.
  43672. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  43673. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43674. func (m *WxCardVisitMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  43675. if !m.op.Is(OpUpdateOne) {
  43676. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  43677. }
  43678. if m.id == nil || m.oldValue == nil {
  43679. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  43680. }
  43681. oldValue, err := m.oldValue(ctx)
  43682. if err != nil {
  43683. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  43684. }
  43685. return oldValue.CreatedAt, nil
  43686. }
  43687. // ResetCreatedAt resets all changes to the "created_at" field.
  43688. func (m *WxCardVisitMutation) ResetCreatedAt() {
  43689. m.created_at = nil
  43690. }
  43691. // SetUpdatedAt sets the "updated_at" field.
  43692. func (m *WxCardVisitMutation) SetUpdatedAt(t time.Time) {
  43693. m.updated_at = &t
  43694. }
  43695. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  43696. func (m *WxCardVisitMutation) UpdatedAt() (r time.Time, exists bool) {
  43697. v := m.updated_at
  43698. if v == nil {
  43699. return
  43700. }
  43701. return *v, true
  43702. }
  43703. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardVisit entity.
  43704. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  43705. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43706. func (m *WxCardVisitMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  43707. if !m.op.Is(OpUpdateOne) {
  43708. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  43709. }
  43710. if m.id == nil || m.oldValue == nil {
  43711. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  43712. }
  43713. oldValue, err := m.oldValue(ctx)
  43714. if err != nil {
  43715. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  43716. }
  43717. return oldValue.UpdatedAt, nil
  43718. }
  43719. // ResetUpdatedAt resets all changes to the "updated_at" field.
  43720. func (m *WxCardVisitMutation) ResetUpdatedAt() {
  43721. m.updated_at = nil
  43722. }
  43723. // SetDeletedAt sets the "deleted_at" field.
  43724. func (m *WxCardVisitMutation) SetDeletedAt(t time.Time) {
  43725. m.deleted_at = &t
  43726. }
  43727. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  43728. func (m *WxCardVisitMutation) DeletedAt() (r time.Time, exists bool) {
  43729. v := m.deleted_at
  43730. if v == nil {
  43731. return
  43732. }
  43733. return *v, true
  43734. }
  43735. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardVisit entity.
  43736. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  43737. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43738. func (m *WxCardVisitMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  43739. if !m.op.Is(OpUpdateOne) {
  43740. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  43741. }
  43742. if m.id == nil || m.oldValue == nil {
  43743. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  43744. }
  43745. oldValue, err := m.oldValue(ctx)
  43746. if err != nil {
  43747. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  43748. }
  43749. return oldValue.DeletedAt, nil
  43750. }
  43751. // ClearDeletedAt clears the value of the "deleted_at" field.
  43752. func (m *WxCardVisitMutation) ClearDeletedAt() {
  43753. m.deleted_at = nil
  43754. m.clearedFields[wxcardvisit.FieldDeletedAt] = struct{}{}
  43755. }
  43756. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  43757. func (m *WxCardVisitMutation) DeletedAtCleared() bool {
  43758. _, ok := m.clearedFields[wxcardvisit.FieldDeletedAt]
  43759. return ok
  43760. }
  43761. // ResetDeletedAt resets all changes to the "deleted_at" field.
  43762. func (m *WxCardVisitMutation) ResetDeletedAt() {
  43763. m.deleted_at = nil
  43764. delete(m.clearedFields, wxcardvisit.FieldDeletedAt)
  43765. }
  43766. // SetUserID sets the "user_id" field.
  43767. func (m *WxCardVisitMutation) SetUserID(u uint64) {
  43768. m.user_id = &u
  43769. m.adduser_id = nil
  43770. }
  43771. // UserID returns the value of the "user_id" field in the mutation.
  43772. func (m *WxCardVisitMutation) UserID() (r uint64, exists bool) {
  43773. v := m.user_id
  43774. if v == nil {
  43775. return
  43776. }
  43777. return *v, true
  43778. }
  43779. // OldUserID returns the old "user_id" field's value of the WxCardVisit entity.
  43780. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  43781. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43782. func (m *WxCardVisitMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  43783. if !m.op.Is(OpUpdateOne) {
  43784. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  43785. }
  43786. if m.id == nil || m.oldValue == nil {
  43787. return v, errors.New("OldUserID requires an ID field in the mutation")
  43788. }
  43789. oldValue, err := m.oldValue(ctx)
  43790. if err != nil {
  43791. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  43792. }
  43793. return oldValue.UserID, nil
  43794. }
  43795. // AddUserID adds u to the "user_id" field.
  43796. func (m *WxCardVisitMutation) AddUserID(u int64) {
  43797. if m.adduser_id != nil {
  43798. *m.adduser_id += u
  43799. } else {
  43800. m.adduser_id = &u
  43801. }
  43802. }
  43803. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  43804. func (m *WxCardVisitMutation) AddedUserID() (r int64, exists bool) {
  43805. v := m.adduser_id
  43806. if v == nil {
  43807. return
  43808. }
  43809. return *v, true
  43810. }
  43811. // ClearUserID clears the value of the "user_id" field.
  43812. func (m *WxCardVisitMutation) ClearUserID() {
  43813. m.user_id = nil
  43814. m.adduser_id = nil
  43815. m.clearedFields[wxcardvisit.FieldUserID] = struct{}{}
  43816. }
  43817. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  43818. func (m *WxCardVisitMutation) UserIDCleared() bool {
  43819. _, ok := m.clearedFields[wxcardvisit.FieldUserID]
  43820. return ok
  43821. }
  43822. // ResetUserID resets all changes to the "user_id" field.
  43823. func (m *WxCardVisitMutation) ResetUserID() {
  43824. m.user_id = nil
  43825. m.adduser_id = nil
  43826. delete(m.clearedFields, wxcardvisit.FieldUserID)
  43827. }
  43828. // SetBotID sets the "bot_id" field.
  43829. func (m *WxCardVisitMutation) SetBotID(u uint64) {
  43830. m.bot_id = &u
  43831. m.addbot_id = nil
  43832. }
  43833. // BotID returns the value of the "bot_id" field in the mutation.
  43834. func (m *WxCardVisitMutation) BotID() (r uint64, exists bool) {
  43835. v := m.bot_id
  43836. if v == nil {
  43837. return
  43838. }
  43839. return *v, true
  43840. }
  43841. // OldBotID returns the old "bot_id" field's value of the WxCardVisit entity.
  43842. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  43843. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43844. func (m *WxCardVisitMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  43845. if !m.op.Is(OpUpdateOne) {
  43846. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  43847. }
  43848. if m.id == nil || m.oldValue == nil {
  43849. return v, errors.New("OldBotID requires an ID field in the mutation")
  43850. }
  43851. oldValue, err := m.oldValue(ctx)
  43852. if err != nil {
  43853. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  43854. }
  43855. return oldValue.BotID, nil
  43856. }
  43857. // AddBotID adds u to the "bot_id" field.
  43858. func (m *WxCardVisitMutation) AddBotID(u int64) {
  43859. if m.addbot_id != nil {
  43860. *m.addbot_id += u
  43861. } else {
  43862. m.addbot_id = &u
  43863. }
  43864. }
  43865. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  43866. func (m *WxCardVisitMutation) AddedBotID() (r int64, exists bool) {
  43867. v := m.addbot_id
  43868. if v == nil {
  43869. return
  43870. }
  43871. return *v, true
  43872. }
  43873. // ResetBotID resets all changes to the "bot_id" field.
  43874. func (m *WxCardVisitMutation) ResetBotID() {
  43875. m.bot_id = nil
  43876. m.addbot_id = nil
  43877. }
  43878. // SetBotType sets the "bot_type" field.
  43879. func (m *WxCardVisitMutation) SetBotType(u uint8) {
  43880. m.bot_type = &u
  43881. m.addbot_type = nil
  43882. }
  43883. // BotType returns the value of the "bot_type" field in the mutation.
  43884. func (m *WxCardVisitMutation) BotType() (r uint8, exists bool) {
  43885. v := m.bot_type
  43886. if v == nil {
  43887. return
  43888. }
  43889. return *v, true
  43890. }
  43891. // OldBotType returns the old "bot_type" field's value of the WxCardVisit entity.
  43892. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  43893. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43894. func (m *WxCardVisitMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  43895. if !m.op.Is(OpUpdateOne) {
  43896. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  43897. }
  43898. if m.id == nil || m.oldValue == nil {
  43899. return v, errors.New("OldBotType requires an ID field in the mutation")
  43900. }
  43901. oldValue, err := m.oldValue(ctx)
  43902. if err != nil {
  43903. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  43904. }
  43905. return oldValue.BotType, nil
  43906. }
  43907. // AddBotType adds u to the "bot_type" field.
  43908. func (m *WxCardVisitMutation) AddBotType(u int8) {
  43909. if m.addbot_type != nil {
  43910. *m.addbot_type += u
  43911. } else {
  43912. m.addbot_type = &u
  43913. }
  43914. }
  43915. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  43916. func (m *WxCardVisitMutation) AddedBotType() (r int8, exists bool) {
  43917. v := m.addbot_type
  43918. if v == nil {
  43919. return
  43920. }
  43921. return *v, true
  43922. }
  43923. // ResetBotType resets all changes to the "bot_type" field.
  43924. func (m *WxCardVisitMutation) ResetBotType() {
  43925. m.bot_type = nil
  43926. m.addbot_type = nil
  43927. }
  43928. // Where appends a list predicates to the WxCardVisitMutation builder.
  43929. func (m *WxCardVisitMutation) Where(ps ...predicate.WxCardVisit) {
  43930. m.predicates = append(m.predicates, ps...)
  43931. }
  43932. // WhereP appends storage-level predicates to the WxCardVisitMutation builder. Using this method,
  43933. // users can use type-assertion to append predicates that do not depend on any generated package.
  43934. func (m *WxCardVisitMutation) WhereP(ps ...func(*sql.Selector)) {
  43935. p := make([]predicate.WxCardVisit, len(ps))
  43936. for i := range ps {
  43937. p[i] = ps[i]
  43938. }
  43939. m.Where(p...)
  43940. }
  43941. // Op returns the operation name.
  43942. func (m *WxCardVisitMutation) Op() Op {
  43943. return m.op
  43944. }
  43945. // SetOp allows setting the mutation operation.
  43946. func (m *WxCardVisitMutation) SetOp(op Op) {
  43947. m.op = op
  43948. }
  43949. // Type returns the node type of this mutation (WxCardVisit).
  43950. func (m *WxCardVisitMutation) Type() string {
  43951. return m.typ
  43952. }
  43953. // Fields returns all fields that were changed during this mutation. Note that in
  43954. // order to get all numeric fields that were incremented/decremented, call
  43955. // AddedFields().
  43956. func (m *WxCardVisitMutation) Fields() []string {
  43957. fields := make([]string, 0, 6)
  43958. if m.created_at != nil {
  43959. fields = append(fields, wxcardvisit.FieldCreatedAt)
  43960. }
  43961. if m.updated_at != nil {
  43962. fields = append(fields, wxcardvisit.FieldUpdatedAt)
  43963. }
  43964. if m.deleted_at != nil {
  43965. fields = append(fields, wxcardvisit.FieldDeletedAt)
  43966. }
  43967. if m.user_id != nil {
  43968. fields = append(fields, wxcardvisit.FieldUserID)
  43969. }
  43970. if m.bot_id != nil {
  43971. fields = append(fields, wxcardvisit.FieldBotID)
  43972. }
  43973. if m.bot_type != nil {
  43974. fields = append(fields, wxcardvisit.FieldBotType)
  43975. }
  43976. return fields
  43977. }
  43978. // Field returns the value of a field with the given name. The second boolean
  43979. // return value indicates that this field was not set, or was not defined in the
  43980. // schema.
  43981. func (m *WxCardVisitMutation) Field(name string) (ent.Value, bool) {
  43982. switch name {
  43983. case wxcardvisit.FieldCreatedAt:
  43984. return m.CreatedAt()
  43985. case wxcardvisit.FieldUpdatedAt:
  43986. return m.UpdatedAt()
  43987. case wxcardvisit.FieldDeletedAt:
  43988. return m.DeletedAt()
  43989. case wxcardvisit.FieldUserID:
  43990. return m.UserID()
  43991. case wxcardvisit.FieldBotID:
  43992. return m.BotID()
  43993. case wxcardvisit.FieldBotType:
  43994. return m.BotType()
  43995. }
  43996. return nil, false
  43997. }
  43998. // OldField returns the old value of the field from the database. An error is
  43999. // returned if the mutation operation is not UpdateOne, or the query to the
  44000. // database failed.
  44001. func (m *WxCardVisitMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  44002. switch name {
  44003. case wxcardvisit.FieldCreatedAt:
  44004. return m.OldCreatedAt(ctx)
  44005. case wxcardvisit.FieldUpdatedAt:
  44006. return m.OldUpdatedAt(ctx)
  44007. case wxcardvisit.FieldDeletedAt:
  44008. return m.OldDeletedAt(ctx)
  44009. case wxcardvisit.FieldUserID:
  44010. return m.OldUserID(ctx)
  44011. case wxcardvisit.FieldBotID:
  44012. return m.OldBotID(ctx)
  44013. case wxcardvisit.FieldBotType:
  44014. return m.OldBotType(ctx)
  44015. }
  44016. return nil, fmt.Errorf("unknown WxCardVisit field %s", name)
  44017. }
  44018. // SetField sets the value of a field with the given name. It returns an error if
  44019. // the field is not defined in the schema, or if the type mismatched the field
  44020. // type.
  44021. func (m *WxCardVisitMutation) SetField(name string, value ent.Value) error {
  44022. switch name {
  44023. case wxcardvisit.FieldCreatedAt:
  44024. v, ok := value.(time.Time)
  44025. if !ok {
  44026. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44027. }
  44028. m.SetCreatedAt(v)
  44029. return nil
  44030. case wxcardvisit.FieldUpdatedAt:
  44031. v, ok := value.(time.Time)
  44032. if !ok {
  44033. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44034. }
  44035. m.SetUpdatedAt(v)
  44036. return nil
  44037. case wxcardvisit.FieldDeletedAt:
  44038. v, ok := value.(time.Time)
  44039. if !ok {
  44040. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44041. }
  44042. m.SetDeletedAt(v)
  44043. return nil
  44044. case wxcardvisit.FieldUserID:
  44045. v, ok := value.(uint64)
  44046. if !ok {
  44047. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44048. }
  44049. m.SetUserID(v)
  44050. return nil
  44051. case wxcardvisit.FieldBotID:
  44052. v, ok := value.(uint64)
  44053. if !ok {
  44054. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44055. }
  44056. m.SetBotID(v)
  44057. return nil
  44058. case wxcardvisit.FieldBotType:
  44059. v, ok := value.(uint8)
  44060. if !ok {
  44061. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44062. }
  44063. m.SetBotType(v)
  44064. return nil
  44065. }
  44066. return fmt.Errorf("unknown WxCardVisit field %s", name)
  44067. }
  44068. // AddedFields returns all numeric fields that were incremented/decremented during
  44069. // this mutation.
  44070. func (m *WxCardVisitMutation) AddedFields() []string {
  44071. var fields []string
  44072. if m.adduser_id != nil {
  44073. fields = append(fields, wxcardvisit.FieldUserID)
  44074. }
  44075. if m.addbot_id != nil {
  44076. fields = append(fields, wxcardvisit.FieldBotID)
  44077. }
  44078. if m.addbot_type != nil {
  44079. fields = append(fields, wxcardvisit.FieldBotType)
  44080. }
  44081. return fields
  44082. }
  44083. // AddedField returns the numeric value that was incremented/decremented on a field
  44084. // with the given name. The second boolean return value indicates that this field
  44085. // was not set, or was not defined in the schema.
  44086. func (m *WxCardVisitMutation) AddedField(name string) (ent.Value, bool) {
  44087. switch name {
  44088. case wxcardvisit.FieldUserID:
  44089. return m.AddedUserID()
  44090. case wxcardvisit.FieldBotID:
  44091. return m.AddedBotID()
  44092. case wxcardvisit.FieldBotType:
  44093. return m.AddedBotType()
  44094. }
  44095. return nil, false
  44096. }
  44097. // AddField adds the value to the field with the given name. It returns an error if
  44098. // the field is not defined in the schema, or if the type mismatched the field
  44099. // type.
  44100. func (m *WxCardVisitMutation) AddField(name string, value ent.Value) error {
  44101. switch name {
  44102. case wxcardvisit.FieldUserID:
  44103. v, ok := value.(int64)
  44104. if !ok {
  44105. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44106. }
  44107. m.AddUserID(v)
  44108. return nil
  44109. case wxcardvisit.FieldBotID:
  44110. v, ok := value.(int64)
  44111. if !ok {
  44112. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44113. }
  44114. m.AddBotID(v)
  44115. return nil
  44116. case wxcardvisit.FieldBotType:
  44117. v, ok := value.(int8)
  44118. if !ok {
  44119. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44120. }
  44121. m.AddBotType(v)
  44122. return nil
  44123. }
  44124. return fmt.Errorf("unknown WxCardVisit numeric field %s", name)
  44125. }
  44126. // ClearedFields returns all nullable fields that were cleared during this
  44127. // mutation.
  44128. func (m *WxCardVisitMutation) ClearedFields() []string {
  44129. var fields []string
  44130. if m.FieldCleared(wxcardvisit.FieldDeletedAt) {
  44131. fields = append(fields, wxcardvisit.FieldDeletedAt)
  44132. }
  44133. if m.FieldCleared(wxcardvisit.FieldUserID) {
  44134. fields = append(fields, wxcardvisit.FieldUserID)
  44135. }
  44136. return fields
  44137. }
  44138. // FieldCleared returns a boolean indicating if a field with the given name was
  44139. // cleared in this mutation.
  44140. func (m *WxCardVisitMutation) FieldCleared(name string) bool {
  44141. _, ok := m.clearedFields[name]
  44142. return ok
  44143. }
  44144. // ClearField clears the value of the field with the given name. It returns an
  44145. // error if the field is not defined in the schema.
  44146. func (m *WxCardVisitMutation) ClearField(name string) error {
  44147. switch name {
  44148. case wxcardvisit.FieldDeletedAt:
  44149. m.ClearDeletedAt()
  44150. return nil
  44151. case wxcardvisit.FieldUserID:
  44152. m.ClearUserID()
  44153. return nil
  44154. }
  44155. return fmt.Errorf("unknown WxCardVisit nullable field %s", name)
  44156. }
  44157. // ResetField resets all changes in the mutation for the field with the given name.
  44158. // It returns an error if the field is not defined in the schema.
  44159. func (m *WxCardVisitMutation) ResetField(name string) error {
  44160. switch name {
  44161. case wxcardvisit.FieldCreatedAt:
  44162. m.ResetCreatedAt()
  44163. return nil
  44164. case wxcardvisit.FieldUpdatedAt:
  44165. m.ResetUpdatedAt()
  44166. return nil
  44167. case wxcardvisit.FieldDeletedAt:
  44168. m.ResetDeletedAt()
  44169. return nil
  44170. case wxcardvisit.FieldUserID:
  44171. m.ResetUserID()
  44172. return nil
  44173. case wxcardvisit.FieldBotID:
  44174. m.ResetBotID()
  44175. return nil
  44176. case wxcardvisit.FieldBotType:
  44177. m.ResetBotType()
  44178. return nil
  44179. }
  44180. return fmt.Errorf("unknown WxCardVisit field %s", name)
  44181. }
  44182. // AddedEdges returns all edge names that were set/added in this mutation.
  44183. func (m *WxCardVisitMutation) AddedEdges() []string {
  44184. edges := make([]string, 0, 0)
  44185. return edges
  44186. }
  44187. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  44188. // name in this mutation.
  44189. func (m *WxCardVisitMutation) AddedIDs(name string) []ent.Value {
  44190. return nil
  44191. }
  44192. // RemovedEdges returns all edge names that were removed in this mutation.
  44193. func (m *WxCardVisitMutation) RemovedEdges() []string {
  44194. edges := make([]string, 0, 0)
  44195. return edges
  44196. }
  44197. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  44198. // the given name in this mutation.
  44199. func (m *WxCardVisitMutation) RemovedIDs(name string) []ent.Value {
  44200. return nil
  44201. }
  44202. // ClearedEdges returns all edge names that were cleared in this mutation.
  44203. func (m *WxCardVisitMutation) ClearedEdges() []string {
  44204. edges := make([]string, 0, 0)
  44205. return edges
  44206. }
  44207. // EdgeCleared returns a boolean which indicates if the edge with the given name
  44208. // was cleared in this mutation.
  44209. func (m *WxCardVisitMutation) EdgeCleared(name string) bool {
  44210. return false
  44211. }
  44212. // ClearEdge clears the value of the edge with the given name. It returns an error
  44213. // if that edge is not defined in the schema.
  44214. func (m *WxCardVisitMutation) ClearEdge(name string) error {
  44215. return fmt.Errorf("unknown WxCardVisit unique edge %s", name)
  44216. }
  44217. // ResetEdge resets all changes to the edge with the given name in this mutation.
  44218. // It returns an error if the edge is not defined in the schema.
  44219. func (m *WxCardVisitMutation) ResetEdge(name string) error {
  44220. return fmt.Errorf("unknown WxCardVisit edge %s", name)
  44221. }