mutation.go 1.4 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656
  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. template_name *string
  3993. template_code *string
  3994. lang *string
  3995. clearedFields map[string]struct{}
  3996. done bool
  3997. oldValue func(context.Context) (*BatchMsg, error)
  3998. predicates []predicate.BatchMsg
  3999. }
  4000. var _ ent.Mutation = (*BatchMsgMutation)(nil)
  4001. // batchmsgOption allows management of the mutation configuration using functional options.
  4002. type batchmsgOption func(*BatchMsgMutation)
  4003. // newBatchMsgMutation creates new mutation for the BatchMsg entity.
  4004. func newBatchMsgMutation(c config, op Op, opts ...batchmsgOption) *BatchMsgMutation {
  4005. m := &BatchMsgMutation{
  4006. config: c,
  4007. op: op,
  4008. typ: TypeBatchMsg,
  4009. clearedFields: make(map[string]struct{}),
  4010. }
  4011. for _, opt := range opts {
  4012. opt(m)
  4013. }
  4014. return m
  4015. }
  4016. // withBatchMsgID sets the ID field of the mutation.
  4017. func withBatchMsgID(id uint64) batchmsgOption {
  4018. return func(m *BatchMsgMutation) {
  4019. var (
  4020. err error
  4021. once sync.Once
  4022. value *BatchMsg
  4023. )
  4024. m.oldValue = func(ctx context.Context) (*BatchMsg, error) {
  4025. once.Do(func() {
  4026. if m.done {
  4027. err = errors.New("querying old values post mutation is not allowed")
  4028. } else {
  4029. value, err = m.Client().BatchMsg.Get(ctx, id)
  4030. }
  4031. })
  4032. return value, err
  4033. }
  4034. m.id = &id
  4035. }
  4036. }
  4037. // withBatchMsg sets the old BatchMsg of the mutation.
  4038. func withBatchMsg(node *BatchMsg) batchmsgOption {
  4039. return func(m *BatchMsgMutation) {
  4040. m.oldValue = func(context.Context) (*BatchMsg, error) {
  4041. return node, nil
  4042. }
  4043. m.id = &node.ID
  4044. }
  4045. }
  4046. // Client returns a new `ent.Client` from the mutation. If the mutation was
  4047. // executed in a transaction (ent.Tx), a transactional client is returned.
  4048. func (m BatchMsgMutation) Client() *Client {
  4049. client := &Client{config: m.config}
  4050. client.init()
  4051. return client
  4052. }
  4053. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  4054. // it returns an error otherwise.
  4055. func (m BatchMsgMutation) Tx() (*Tx, error) {
  4056. if _, ok := m.driver.(*txDriver); !ok {
  4057. return nil, errors.New("ent: mutation is not running in a transaction")
  4058. }
  4059. tx := &Tx{config: m.config}
  4060. tx.init()
  4061. return tx, nil
  4062. }
  4063. // SetID sets the value of the id field. Note that this
  4064. // operation is only accepted on creation of BatchMsg entities.
  4065. func (m *BatchMsgMutation) SetID(id uint64) {
  4066. m.id = &id
  4067. }
  4068. // ID returns the ID value in the mutation. Note that the ID is only available
  4069. // if it was provided to the builder or after it was returned from the database.
  4070. func (m *BatchMsgMutation) ID() (id uint64, exists bool) {
  4071. if m.id == nil {
  4072. return
  4073. }
  4074. return *m.id, true
  4075. }
  4076. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  4077. // That means, if the mutation is applied within a transaction with an isolation level such
  4078. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  4079. // or updated by the mutation.
  4080. func (m *BatchMsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  4081. switch {
  4082. case m.op.Is(OpUpdateOne | OpDeleteOne):
  4083. id, exists := m.ID()
  4084. if exists {
  4085. return []uint64{id}, nil
  4086. }
  4087. fallthrough
  4088. case m.op.Is(OpUpdate | OpDelete):
  4089. return m.Client().BatchMsg.Query().Where(m.predicates...).IDs(ctx)
  4090. default:
  4091. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  4092. }
  4093. }
  4094. // SetCreatedAt sets the "created_at" field.
  4095. func (m *BatchMsgMutation) SetCreatedAt(t time.Time) {
  4096. m.created_at = &t
  4097. }
  4098. // CreatedAt returns the value of the "created_at" field in the mutation.
  4099. func (m *BatchMsgMutation) CreatedAt() (r time.Time, exists bool) {
  4100. v := m.created_at
  4101. if v == nil {
  4102. return
  4103. }
  4104. return *v, true
  4105. }
  4106. // OldCreatedAt returns the old "created_at" field's value of the BatchMsg entity.
  4107. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4108. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4109. func (m *BatchMsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  4110. if !m.op.Is(OpUpdateOne) {
  4111. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  4112. }
  4113. if m.id == nil || m.oldValue == nil {
  4114. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  4115. }
  4116. oldValue, err := m.oldValue(ctx)
  4117. if err != nil {
  4118. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  4119. }
  4120. return oldValue.CreatedAt, nil
  4121. }
  4122. // ResetCreatedAt resets all changes to the "created_at" field.
  4123. func (m *BatchMsgMutation) ResetCreatedAt() {
  4124. m.created_at = nil
  4125. }
  4126. // SetUpdatedAt sets the "updated_at" field.
  4127. func (m *BatchMsgMutation) SetUpdatedAt(t time.Time) {
  4128. m.updated_at = &t
  4129. }
  4130. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  4131. func (m *BatchMsgMutation) UpdatedAt() (r time.Time, exists bool) {
  4132. v := m.updated_at
  4133. if v == nil {
  4134. return
  4135. }
  4136. return *v, true
  4137. }
  4138. // OldUpdatedAt returns the old "updated_at" field's value of the BatchMsg entity.
  4139. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4140. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4141. func (m *BatchMsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  4142. if !m.op.Is(OpUpdateOne) {
  4143. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  4144. }
  4145. if m.id == nil || m.oldValue == nil {
  4146. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  4147. }
  4148. oldValue, err := m.oldValue(ctx)
  4149. if err != nil {
  4150. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  4151. }
  4152. return oldValue.UpdatedAt, nil
  4153. }
  4154. // ResetUpdatedAt resets all changes to the "updated_at" field.
  4155. func (m *BatchMsgMutation) ResetUpdatedAt() {
  4156. m.updated_at = nil
  4157. }
  4158. // SetDeletedAt sets the "deleted_at" field.
  4159. func (m *BatchMsgMutation) SetDeletedAt(t time.Time) {
  4160. m.deleted_at = &t
  4161. }
  4162. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  4163. func (m *BatchMsgMutation) DeletedAt() (r time.Time, exists bool) {
  4164. v := m.deleted_at
  4165. if v == nil {
  4166. return
  4167. }
  4168. return *v, true
  4169. }
  4170. // OldDeletedAt returns the old "deleted_at" field's value of the BatchMsg entity.
  4171. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4172. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4173. func (m *BatchMsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  4174. if !m.op.Is(OpUpdateOne) {
  4175. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  4176. }
  4177. if m.id == nil || m.oldValue == nil {
  4178. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  4179. }
  4180. oldValue, err := m.oldValue(ctx)
  4181. if err != nil {
  4182. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  4183. }
  4184. return oldValue.DeletedAt, nil
  4185. }
  4186. // ClearDeletedAt clears the value of the "deleted_at" field.
  4187. func (m *BatchMsgMutation) ClearDeletedAt() {
  4188. m.deleted_at = nil
  4189. m.clearedFields[batchmsg.FieldDeletedAt] = struct{}{}
  4190. }
  4191. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  4192. func (m *BatchMsgMutation) DeletedAtCleared() bool {
  4193. _, ok := m.clearedFields[batchmsg.FieldDeletedAt]
  4194. return ok
  4195. }
  4196. // ResetDeletedAt resets all changes to the "deleted_at" field.
  4197. func (m *BatchMsgMutation) ResetDeletedAt() {
  4198. m.deleted_at = nil
  4199. delete(m.clearedFields, batchmsg.FieldDeletedAt)
  4200. }
  4201. // SetStatus sets the "status" field.
  4202. func (m *BatchMsgMutation) SetStatus(u uint8) {
  4203. m.status = &u
  4204. m.addstatus = nil
  4205. }
  4206. // Status returns the value of the "status" field in the mutation.
  4207. func (m *BatchMsgMutation) Status() (r uint8, exists bool) {
  4208. v := m.status
  4209. if v == nil {
  4210. return
  4211. }
  4212. return *v, true
  4213. }
  4214. // OldStatus returns the old "status" field's value of the BatchMsg entity.
  4215. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4216. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4217. func (m *BatchMsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  4218. if !m.op.Is(OpUpdateOne) {
  4219. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  4220. }
  4221. if m.id == nil || m.oldValue == nil {
  4222. return v, errors.New("OldStatus requires an ID field in the mutation")
  4223. }
  4224. oldValue, err := m.oldValue(ctx)
  4225. if err != nil {
  4226. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  4227. }
  4228. return oldValue.Status, nil
  4229. }
  4230. // AddStatus adds u to the "status" field.
  4231. func (m *BatchMsgMutation) AddStatus(u int8) {
  4232. if m.addstatus != nil {
  4233. *m.addstatus += u
  4234. } else {
  4235. m.addstatus = &u
  4236. }
  4237. }
  4238. // AddedStatus returns the value that was added to the "status" field in this mutation.
  4239. func (m *BatchMsgMutation) AddedStatus() (r int8, exists bool) {
  4240. v := m.addstatus
  4241. if v == nil {
  4242. return
  4243. }
  4244. return *v, true
  4245. }
  4246. // ClearStatus clears the value of the "status" field.
  4247. func (m *BatchMsgMutation) ClearStatus() {
  4248. m.status = nil
  4249. m.addstatus = nil
  4250. m.clearedFields[batchmsg.FieldStatus] = struct{}{}
  4251. }
  4252. // StatusCleared returns if the "status" field was cleared in this mutation.
  4253. func (m *BatchMsgMutation) StatusCleared() bool {
  4254. _, ok := m.clearedFields[batchmsg.FieldStatus]
  4255. return ok
  4256. }
  4257. // ResetStatus resets all changes to the "status" field.
  4258. func (m *BatchMsgMutation) ResetStatus() {
  4259. m.status = nil
  4260. m.addstatus = nil
  4261. delete(m.clearedFields, batchmsg.FieldStatus)
  4262. }
  4263. // SetBatchNo sets the "batch_no" field.
  4264. func (m *BatchMsgMutation) SetBatchNo(s string) {
  4265. m.batch_no = &s
  4266. }
  4267. // BatchNo returns the value of the "batch_no" field in the mutation.
  4268. func (m *BatchMsgMutation) BatchNo() (r string, exists bool) {
  4269. v := m.batch_no
  4270. if v == nil {
  4271. return
  4272. }
  4273. return *v, true
  4274. }
  4275. // OldBatchNo returns the old "batch_no" field's value of the BatchMsg entity.
  4276. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4277. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4278. func (m *BatchMsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  4279. if !m.op.Is(OpUpdateOne) {
  4280. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  4281. }
  4282. if m.id == nil || m.oldValue == nil {
  4283. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  4284. }
  4285. oldValue, err := m.oldValue(ctx)
  4286. if err != nil {
  4287. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  4288. }
  4289. return oldValue.BatchNo, nil
  4290. }
  4291. // ClearBatchNo clears the value of the "batch_no" field.
  4292. func (m *BatchMsgMutation) ClearBatchNo() {
  4293. m.batch_no = nil
  4294. m.clearedFields[batchmsg.FieldBatchNo] = struct{}{}
  4295. }
  4296. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  4297. func (m *BatchMsgMutation) BatchNoCleared() bool {
  4298. _, ok := m.clearedFields[batchmsg.FieldBatchNo]
  4299. return ok
  4300. }
  4301. // ResetBatchNo resets all changes to the "batch_no" field.
  4302. func (m *BatchMsgMutation) ResetBatchNo() {
  4303. m.batch_no = nil
  4304. delete(m.clearedFields, batchmsg.FieldBatchNo)
  4305. }
  4306. // SetTaskName sets the "task_name" field.
  4307. func (m *BatchMsgMutation) SetTaskName(s string) {
  4308. m.task_name = &s
  4309. }
  4310. // TaskName returns the value of the "task_name" field in the mutation.
  4311. func (m *BatchMsgMutation) TaskName() (r string, exists bool) {
  4312. v := m.task_name
  4313. if v == nil {
  4314. return
  4315. }
  4316. return *v, true
  4317. }
  4318. // OldTaskName returns the old "task_name" field's value of the BatchMsg entity.
  4319. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4320. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4321. func (m *BatchMsgMutation) OldTaskName(ctx context.Context) (v string, err error) {
  4322. if !m.op.Is(OpUpdateOne) {
  4323. return v, errors.New("OldTaskName is only allowed on UpdateOne operations")
  4324. }
  4325. if m.id == nil || m.oldValue == nil {
  4326. return v, errors.New("OldTaskName requires an ID field in the mutation")
  4327. }
  4328. oldValue, err := m.oldValue(ctx)
  4329. if err != nil {
  4330. return v, fmt.Errorf("querying old value for OldTaskName: %w", err)
  4331. }
  4332. return oldValue.TaskName, nil
  4333. }
  4334. // ClearTaskName clears the value of the "task_name" field.
  4335. func (m *BatchMsgMutation) ClearTaskName() {
  4336. m.task_name = nil
  4337. m.clearedFields[batchmsg.FieldTaskName] = struct{}{}
  4338. }
  4339. // TaskNameCleared returns if the "task_name" field was cleared in this mutation.
  4340. func (m *BatchMsgMutation) TaskNameCleared() bool {
  4341. _, ok := m.clearedFields[batchmsg.FieldTaskName]
  4342. return ok
  4343. }
  4344. // ResetTaskName resets all changes to the "task_name" field.
  4345. func (m *BatchMsgMutation) ResetTaskName() {
  4346. m.task_name = nil
  4347. delete(m.clearedFields, batchmsg.FieldTaskName)
  4348. }
  4349. // SetFromwxid sets the "fromwxid" field.
  4350. func (m *BatchMsgMutation) SetFromwxid(s string) {
  4351. m.fromwxid = &s
  4352. }
  4353. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  4354. func (m *BatchMsgMutation) Fromwxid() (r string, exists bool) {
  4355. v := m.fromwxid
  4356. if v == nil {
  4357. return
  4358. }
  4359. return *v, true
  4360. }
  4361. // OldFromwxid returns the old "fromwxid" field's value of the BatchMsg entity.
  4362. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4363. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4364. func (m *BatchMsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  4365. if !m.op.Is(OpUpdateOne) {
  4366. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  4367. }
  4368. if m.id == nil || m.oldValue == nil {
  4369. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  4370. }
  4371. oldValue, err := m.oldValue(ctx)
  4372. if err != nil {
  4373. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  4374. }
  4375. return oldValue.Fromwxid, nil
  4376. }
  4377. // ClearFromwxid clears the value of the "fromwxid" field.
  4378. func (m *BatchMsgMutation) ClearFromwxid() {
  4379. m.fromwxid = nil
  4380. m.clearedFields[batchmsg.FieldFromwxid] = struct{}{}
  4381. }
  4382. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  4383. func (m *BatchMsgMutation) FromwxidCleared() bool {
  4384. _, ok := m.clearedFields[batchmsg.FieldFromwxid]
  4385. return ok
  4386. }
  4387. // ResetFromwxid resets all changes to the "fromwxid" field.
  4388. func (m *BatchMsgMutation) ResetFromwxid() {
  4389. m.fromwxid = nil
  4390. delete(m.clearedFields, batchmsg.FieldFromwxid)
  4391. }
  4392. // SetMsg sets the "msg" field.
  4393. func (m *BatchMsgMutation) SetMsg(s string) {
  4394. m.msg = &s
  4395. }
  4396. // Msg returns the value of the "msg" field in the mutation.
  4397. func (m *BatchMsgMutation) Msg() (r string, exists bool) {
  4398. v := m.msg
  4399. if v == nil {
  4400. return
  4401. }
  4402. return *v, true
  4403. }
  4404. // OldMsg returns the old "msg" field's value of the BatchMsg entity.
  4405. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4406. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4407. func (m *BatchMsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  4408. if !m.op.Is(OpUpdateOne) {
  4409. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  4410. }
  4411. if m.id == nil || m.oldValue == nil {
  4412. return v, errors.New("OldMsg requires an ID field in the mutation")
  4413. }
  4414. oldValue, err := m.oldValue(ctx)
  4415. if err != nil {
  4416. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  4417. }
  4418. return oldValue.Msg, nil
  4419. }
  4420. // ClearMsg clears the value of the "msg" field.
  4421. func (m *BatchMsgMutation) ClearMsg() {
  4422. m.msg = nil
  4423. m.clearedFields[batchmsg.FieldMsg] = struct{}{}
  4424. }
  4425. // MsgCleared returns if the "msg" field was cleared in this mutation.
  4426. func (m *BatchMsgMutation) MsgCleared() bool {
  4427. _, ok := m.clearedFields[batchmsg.FieldMsg]
  4428. return ok
  4429. }
  4430. // ResetMsg resets all changes to the "msg" field.
  4431. func (m *BatchMsgMutation) ResetMsg() {
  4432. m.msg = nil
  4433. delete(m.clearedFields, batchmsg.FieldMsg)
  4434. }
  4435. // SetTag sets the "tag" field.
  4436. func (m *BatchMsgMutation) SetTag(s string) {
  4437. m.tag = &s
  4438. }
  4439. // Tag returns the value of the "tag" field in the mutation.
  4440. func (m *BatchMsgMutation) Tag() (r string, exists bool) {
  4441. v := m.tag
  4442. if v == nil {
  4443. return
  4444. }
  4445. return *v, true
  4446. }
  4447. // OldTag returns the old "tag" field's value of the BatchMsg entity.
  4448. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4449. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4450. func (m *BatchMsgMutation) OldTag(ctx context.Context) (v string, err error) {
  4451. if !m.op.Is(OpUpdateOne) {
  4452. return v, errors.New("OldTag is only allowed on UpdateOne operations")
  4453. }
  4454. if m.id == nil || m.oldValue == nil {
  4455. return v, errors.New("OldTag requires an ID field in the mutation")
  4456. }
  4457. oldValue, err := m.oldValue(ctx)
  4458. if err != nil {
  4459. return v, fmt.Errorf("querying old value for OldTag: %w", err)
  4460. }
  4461. return oldValue.Tag, nil
  4462. }
  4463. // ClearTag clears the value of the "tag" field.
  4464. func (m *BatchMsgMutation) ClearTag() {
  4465. m.tag = nil
  4466. m.clearedFields[batchmsg.FieldTag] = struct{}{}
  4467. }
  4468. // TagCleared returns if the "tag" field was cleared in this mutation.
  4469. func (m *BatchMsgMutation) TagCleared() bool {
  4470. _, ok := m.clearedFields[batchmsg.FieldTag]
  4471. return ok
  4472. }
  4473. // ResetTag resets all changes to the "tag" field.
  4474. func (m *BatchMsgMutation) ResetTag() {
  4475. m.tag = nil
  4476. delete(m.clearedFields, batchmsg.FieldTag)
  4477. }
  4478. // SetTagids sets the "tagids" field.
  4479. func (m *BatchMsgMutation) SetTagids(s string) {
  4480. m.tagids = &s
  4481. }
  4482. // Tagids returns the value of the "tagids" field in the mutation.
  4483. func (m *BatchMsgMutation) Tagids() (r string, exists bool) {
  4484. v := m.tagids
  4485. if v == nil {
  4486. return
  4487. }
  4488. return *v, true
  4489. }
  4490. // OldTagids returns the old "tagids" field's value of the BatchMsg entity.
  4491. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4492. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4493. func (m *BatchMsgMutation) OldTagids(ctx context.Context) (v string, err error) {
  4494. if !m.op.Is(OpUpdateOne) {
  4495. return v, errors.New("OldTagids is only allowed on UpdateOne operations")
  4496. }
  4497. if m.id == nil || m.oldValue == nil {
  4498. return v, errors.New("OldTagids requires an ID field in the mutation")
  4499. }
  4500. oldValue, err := m.oldValue(ctx)
  4501. if err != nil {
  4502. return v, fmt.Errorf("querying old value for OldTagids: %w", err)
  4503. }
  4504. return oldValue.Tagids, nil
  4505. }
  4506. // ClearTagids clears the value of the "tagids" field.
  4507. func (m *BatchMsgMutation) ClearTagids() {
  4508. m.tagids = nil
  4509. m.clearedFields[batchmsg.FieldTagids] = struct{}{}
  4510. }
  4511. // TagidsCleared returns if the "tagids" field was cleared in this mutation.
  4512. func (m *BatchMsgMutation) TagidsCleared() bool {
  4513. _, ok := m.clearedFields[batchmsg.FieldTagids]
  4514. return ok
  4515. }
  4516. // ResetTagids resets all changes to the "tagids" field.
  4517. func (m *BatchMsgMutation) ResetTagids() {
  4518. m.tagids = nil
  4519. delete(m.clearedFields, batchmsg.FieldTagids)
  4520. }
  4521. // SetTotal sets the "total" field.
  4522. func (m *BatchMsgMutation) SetTotal(i int32) {
  4523. m.total = &i
  4524. m.addtotal = nil
  4525. }
  4526. // Total returns the value of the "total" field in the mutation.
  4527. func (m *BatchMsgMutation) Total() (r int32, exists bool) {
  4528. v := m.total
  4529. if v == nil {
  4530. return
  4531. }
  4532. return *v, true
  4533. }
  4534. // OldTotal returns the old "total" field's value of the BatchMsg entity.
  4535. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4536. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4537. func (m *BatchMsgMutation) OldTotal(ctx context.Context) (v int32, err error) {
  4538. if !m.op.Is(OpUpdateOne) {
  4539. return v, errors.New("OldTotal is only allowed on UpdateOne operations")
  4540. }
  4541. if m.id == nil || m.oldValue == nil {
  4542. return v, errors.New("OldTotal requires an ID field in the mutation")
  4543. }
  4544. oldValue, err := m.oldValue(ctx)
  4545. if err != nil {
  4546. return v, fmt.Errorf("querying old value for OldTotal: %w", err)
  4547. }
  4548. return oldValue.Total, nil
  4549. }
  4550. // AddTotal adds i to the "total" field.
  4551. func (m *BatchMsgMutation) AddTotal(i int32) {
  4552. if m.addtotal != nil {
  4553. *m.addtotal += i
  4554. } else {
  4555. m.addtotal = &i
  4556. }
  4557. }
  4558. // AddedTotal returns the value that was added to the "total" field in this mutation.
  4559. func (m *BatchMsgMutation) AddedTotal() (r int32, exists bool) {
  4560. v := m.addtotal
  4561. if v == nil {
  4562. return
  4563. }
  4564. return *v, true
  4565. }
  4566. // ClearTotal clears the value of the "total" field.
  4567. func (m *BatchMsgMutation) ClearTotal() {
  4568. m.total = nil
  4569. m.addtotal = nil
  4570. m.clearedFields[batchmsg.FieldTotal] = struct{}{}
  4571. }
  4572. // TotalCleared returns if the "total" field was cleared in this mutation.
  4573. func (m *BatchMsgMutation) TotalCleared() bool {
  4574. _, ok := m.clearedFields[batchmsg.FieldTotal]
  4575. return ok
  4576. }
  4577. // ResetTotal resets all changes to the "total" field.
  4578. func (m *BatchMsgMutation) ResetTotal() {
  4579. m.total = nil
  4580. m.addtotal = nil
  4581. delete(m.clearedFields, batchmsg.FieldTotal)
  4582. }
  4583. // SetSuccess sets the "success" field.
  4584. func (m *BatchMsgMutation) SetSuccess(i int32) {
  4585. m.success = &i
  4586. m.addsuccess = nil
  4587. }
  4588. // Success returns the value of the "success" field in the mutation.
  4589. func (m *BatchMsgMutation) Success() (r int32, exists bool) {
  4590. v := m.success
  4591. if v == nil {
  4592. return
  4593. }
  4594. return *v, true
  4595. }
  4596. // OldSuccess returns the old "success" field's value of the BatchMsg entity.
  4597. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4598. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4599. func (m *BatchMsgMutation) OldSuccess(ctx context.Context) (v int32, err error) {
  4600. if !m.op.Is(OpUpdateOne) {
  4601. return v, errors.New("OldSuccess is only allowed on UpdateOne operations")
  4602. }
  4603. if m.id == nil || m.oldValue == nil {
  4604. return v, errors.New("OldSuccess requires an ID field in the mutation")
  4605. }
  4606. oldValue, err := m.oldValue(ctx)
  4607. if err != nil {
  4608. return v, fmt.Errorf("querying old value for OldSuccess: %w", err)
  4609. }
  4610. return oldValue.Success, nil
  4611. }
  4612. // AddSuccess adds i to the "success" field.
  4613. func (m *BatchMsgMutation) AddSuccess(i int32) {
  4614. if m.addsuccess != nil {
  4615. *m.addsuccess += i
  4616. } else {
  4617. m.addsuccess = &i
  4618. }
  4619. }
  4620. // AddedSuccess returns the value that was added to the "success" field in this mutation.
  4621. func (m *BatchMsgMutation) AddedSuccess() (r int32, exists bool) {
  4622. v := m.addsuccess
  4623. if v == nil {
  4624. return
  4625. }
  4626. return *v, true
  4627. }
  4628. // ClearSuccess clears the value of the "success" field.
  4629. func (m *BatchMsgMutation) ClearSuccess() {
  4630. m.success = nil
  4631. m.addsuccess = nil
  4632. m.clearedFields[batchmsg.FieldSuccess] = struct{}{}
  4633. }
  4634. // SuccessCleared returns if the "success" field was cleared in this mutation.
  4635. func (m *BatchMsgMutation) SuccessCleared() bool {
  4636. _, ok := m.clearedFields[batchmsg.FieldSuccess]
  4637. return ok
  4638. }
  4639. // ResetSuccess resets all changes to the "success" field.
  4640. func (m *BatchMsgMutation) ResetSuccess() {
  4641. m.success = nil
  4642. m.addsuccess = nil
  4643. delete(m.clearedFields, batchmsg.FieldSuccess)
  4644. }
  4645. // SetFail sets the "fail" field.
  4646. func (m *BatchMsgMutation) SetFail(i int32) {
  4647. m.fail = &i
  4648. m.addfail = nil
  4649. }
  4650. // Fail returns the value of the "fail" field in the mutation.
  4651. func (m *BatchMsgMutation) Fail() (r int32, exists bool) {
  4652. v := m.fail
  4653. if v == nil {
  4654. return
  4655. }
  4656. return *v, true
  4657. }
  4658. // OldFail returns the old "fail" field's value of the BatchMsg entity.
  4659. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4660. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4661. func (m *BatchMsgMutation) OldFail(ctx context.Context) (v int32, err error) {
  4662. if !m.op.Is(OpUpdateOne) {
  4663. return v, errors.New("OldFail is only allowed on UpdateOne operations")
  4664. }
  4665. if m.id == nil || m.oldValue == nil {
  4666. return v, errors.New("OldFail requires an ID field in the mutation")
  4667. }
  4668. oldValue, err := m.oldValue(ctx)
  4669. if err != nil {
  4670. return v, fmt.Errorf("querying old value for OldFail: %w", err)
  4671. }
  4672. return oldValue.Fail, nil
  4673. }
  4674. // AddFail adds i to the "fail" field.
  4675. func (m *BatchMsgMutation) AddFail(i int32) {
  4676. if m.addfail != nil {
  4677. *m.addfail += i
  4678. } else {
  4679. m.addfail = &i
  4680. }
  4681. }
  4682. // AddedFail returns the value that was added to the "fail" field in this mutation.
  4683. func (m *BatchMsgMutation) AddedFail() (r int32, exists bool) {
  4684. v := m.addfail
  4685. if v == nil {
  4686. return
  4687. }
  4688. return *v, true
  4689. }
  4690. // ClearFail clears the value of the "fail" field.
  4691. func (m *BatchMsgMutation) ClearFail() {
  4692. m.fail = nil
  4693. m.addfail = nil
  4694. m.clearedFields[batchmsg.FieldFail] = struct{}{}
  4695. }
  4696. // FailCleared returns if the "fail" field was cleared in this mutation.
  4697. func (m *BatchMsgMutation) FailCleared() bool {
  4698. _, ok := m.clearedFields[batchmsg.FieldFail]
  4699. return ok
  4700. }
  4701. // ResetFail resets all changes to the "fail" field.
  4702. func (m *BatchMsgMutation) ResetFail() {
  4703. m.fail = nil
  4704. m.addfail = nil
  4705. delete(m.clearedFields, batchmsg.FieldFail)
  4706. }
  4707. // SetStartTime sets the "start_time" field.
  4708. func (m *BatchMsgMutation) SetStartTime(t time.Time) {
  4709. m.start_time = &t
  4710. }
  4711. // StartTime returns the value of the "start_time" field in the mutation.
  4712. func (m *BatchMsgMutation) StartTime() (r time.Time, exists bool) {
  4713. v := m.start_time
  4714. if v == nil {
  4715. return
  4716. }
  4717. return *v, true
  4718. }
  4719. // OldStartTime returns the old "start_time" field's value of the BatchMsg entity.
  4720. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4721. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4722. func (m *BatchMsgMutation) OldStartTime(ctx context.Context) (v time.Time, err error) {
  4723. if !m.op.Is(OpUpdateOne) {
  4724. return v, errors.New("OldStartTime is only allowed on UpdateOne operations")
  4725. }
  4726. if m.id == nil || m.oldValue == nil {
  4727. return v, errors.New("OldStartTime requires an ID field in the mutation")
  4728. }
  4729. oldValue, err := m.oldValue(ctx)
  4730. if err != nil {
  4731. return v, fmt.Errorf("querying old value for OldStartTime: %w", err)
  4732. }
  4733. return oldValue.StartTime, nil
  4734. }
  4735. // ClearStartTime clears the value of the "start_time" field.
  4736. func (m *BatchMsgMutation) ClearStartTime() {
  4737. m.start_time = nil
  4738. m.clearedFields[batchmsg.FieldStartTime] = struct{}{}
  4739. }
  4740. // StartTimeCleared returns if the "start_time" field was cleared in this mutation.
  4741. func (m *BatchMsgMutation) StartTimeCleared() bool {
  4742. _, ok := m.clearedFields[batchmsg.FieldStartTime]
  4743. return ok
  4744. }
  4745. // ResetStartTime resets all changes to the "start_time" field.
  4746. func (m *BatchMsgMutation) ResetStartTime() {
  4747. m.start_time = nil
  4748. delete(m.clearedFields, batchmsg.FieldStartTime)
  4749. }
  4750. // SetStopTime sets the "stop_time" field.
  4751. func (m *BatchMsgMutation) SetStopTime(t time.Time) {
  4752. m.stop_time = &t
  4753. }
  4754. // StopTime returns the value of the "stop_time" field in the mutation.
  4755. func (m *BatchMsgMutation) StopTime() (r time.Time, exists bool) {
  4756. v := m.stop_time
  4757. if v == nil {
  4758. return
  4759. }
  4760. return *v, true
  4761. }
  4762. // OldStopTime returns the old "stop_time" field's value of the BatchMsg entity.
  4763. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4764. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4765. func (m *BatchMsgMutation) OldStopTime(ctx context.Context) (v time.Time, err error) {
  4766. if !m.op.Is(OpUpdateOne) {
  4767. return v, errors.New("OldStopTime is only allowed on UpdateOne operations")
  4768. }
  4769. if m.id == nil || m.oldValue == nil {
  4770. return v, errors.New("OldStopTime requires an ID field in the mutation")
  4771. }
  4772. oldValue, err := m.oldValue(ctx)
  4773. if err != nil {
  4774. return v, fmt.Errorf("querying old value for OldStopTime: %w", err)
  4775. }
  4776. return oldValue.StopTime, nil
  4777. }
  4778. // ClearStopTime clears the value of the "stop_time" field.
  4779. func (m *BatchMsgMutation) ClearStopTime() {
  4780. m.stop_time = nil
  4781. m.clearedFields[batchmsg.FieldStopTime] = struct{}{}
  4782. }
  4783. // StopTimeCleared returns if the "stop_time" field was cleared in this mutation.
  4784. func (m *BatchMsgMutation) StopTimeCleared() bool {
  4785. _, ok := m.clearedFields[batchmsg.FieldStopTime]
  4786. return ok
  4787. }
  4788. // ResetStopTime resets all changes to the "stop_time" field.
  4789. func (m *BatchMsgMutation) ResetStopTime() {
  4790. m.stop_time = nil
  4791. delete(m.clearedFields, batchmsg.FieldStopTime)
  4792. }
  4793. // SetSendTime sets the "send_time" field.
  4794. func (m *BatchMsgMutation) SetSendTime(t time.Time) {
  4795. m.send_time = &t
  4796. }
  4797. // SendTime returns the value of the "send_time" field in the mutation.
  4798. func (m *BatchMsgMutation) SendTime() (r time.Time, exists bool) {
  4799. v := m.send_time
  4800. if v == nil {
  4801. return
  4802. }
  4803. return *v, true
  4804. }
  4805. // OldSendTime returns the old "send_time" field's value of the BatchMsg entity.
  4806. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4807. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4808. func (m *BatchMsgMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  4809. if !m.op.Is(OpUpdateOne) {
  4810. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  4811. }
  4812. if m.id == nil || m.oldValue == nil {
  4813. return v, errors.New("OldSendTime requires an ID field in the mutation")
  4814. }
  4815. oldValue, err := m.oldValue(ctx)
  4816. if err != nil {
  4817. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  4818. }
  4819. return oldValue.SendTime, nil
  4820. }
  4821. // ClearSendTime clears the value of the "send_time" field.
  4822. func (m *BatchMsgMutation) ClearSendTime() {
  4823. m.send_time = nil
  4824. m.clearedFields[batchmsg.FieldSendTime] = struct{}{}
  4825. }
  4826. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  4827. func (m *BatchMsgMutation) SendTimeCleared() bool {
  4828. _, ok := m.clearedFields[batchmsg.FieldSendTime]
  4829. return ok
  4830. }
  4831. // ResetSendTime resets all changes to the "send_time" field.
  4832. func (m *BatchMsgMutation) ResetSendTime() {
  4833. m.send_time = nil
  4834. delete(m.clearedFields, batchmsg.FieldSendTime)
  4835. }
  4836. // SetType sets the "type" field.
  4837. func (m *BatchMsgMutation) SetType(i int32) {
  4838. m._type = &i
  4839. m.add_type = nil
  4840. }
  4841. // GetType returns the value of the "type" field in the mutation.
  4842. func (m *BatchMsgMutation) GetType() (r int32, exists bool) {
  4843. v := m._type
  4844. if v == nil {
  4845. return
  4846. }
  4847. return *v, true
  4848. }
  4849. // OldType returns the old "type" field's value of the BatchMsg entity.
  4850. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4851. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4852. func (m *BatchMsgMutation) OldType(ctx context.Context) (v int32, err error) {
  4853. if !m.op.Is(OpUpdateOne) {
  4854. return v, errors.New("OldType is only allowed on UpdateOne operations")
  4855. }
  4856. if m.id == nil || m.oldValue == nil {
  4857. return v, errors.New("OldType requires an ID field in the mutation")
  4858. }
  4859. oldValue, err := m.oldValue(ctx)
  4860. if err != nil {
  4861. return v, fmt.Errorf("querying old value for OldType: %w", err)
  4862. }
  4863. return oldValue.Type, nil
  4864. }
  4865. // AddType adds i to the "type" field.
  4866. func (m *BatchMsgMutation) AddType(i int32) {
  4867. if m.add_type != nil {
  4868. *m.add_type += i
  4869. } else {
  4870. m.add_type = &i
  4871. }
  4872. }
  4873. // AddedType returns the value that was added to the "type" field in this mutation.
  4874. func (m *BatchMsgMutation) AddedType() (r int32, exists bool) {
  4875. v := m.add_type
  4876. if v == nil {
  4877. return
  4878. }
  4879. return *v, true
  4880. }
  4881. // ClearType clears the value of the "type" field.
  4882. func (m *BatchMsgMutation) ClearType() {
  4883. m._type = nil
  4884. m.add_type = nil
  4885. m.clearedFields[batchmsg.FieldType] = struct{}{}
  4886. }
  4887. // TypeCleared returns if the "type" field was cleared in this mutation.
  4888. func (m *BatchMsgMutation) TypeCleared() bool {
  4889. _, ok := m.clearedFields[batchmsg.FieldType]
  4890. return ok
  4891. }
  4892. // ResetType resets all changes to the "type" field.
  4893. func (m *BatchMsgMutation) ResetType() {
  4894. m._type = nil
  4895. m.add_type = nil
  4896. delete(m.clearedFields, batchmsg.FieldType)
  4897. }
  4898. // SetOrganizationID sets the "organization_id" field.
  4899. func (m *BatchMsgMutation) SetOrganizationID(u uint64) {
  4900. m.organization_id = &u
  4901. m.addorganization_id = nil
  4902. }
  4903. // OrganizationID returns the value of the "organization_id" field in the mutation.
  4904. func (m *BatchMsgMutation) OrganizationID() (r uint64, exists bool) {
  4905. v := m.organization_id
  4906. if v == nil {
  4907. return
  4908. }
  4909. return *v, true
  4910. }
  4911. // OldOrganizationID returns the old "organization_id" field's value of the BatchMsg entity.
  4912. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4913. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4914. func (m *BatchMsgMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  4915. if !m.op.Is(OpUpdateOne) {
  4916. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  4917. }
  4918. if m.id == nil || m.oldValue == nil {
  4919. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  4920. }
  4921. oldValue, err := m.oldValue(ctx)
  4922. if err != nil {
  4923. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  4924. }
  4925. return oldValue.OrganizationID, nil
  4926. }
  4927. // AddOrganizationID adds u to the "organization_id" field.
  4928. func (m *BatchMsgMutation) AddOrganizationID(u int64) {
  4929. if m.addorganization_id != nil {
  4930. *m.addorganization_id += u
  4931. } else {
  4932. m.addorganization_id = &u
  4933. }
  4934. }
  4935. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  4936. func (m *BatchMsgMutation) AddedOrganizationID() (r int64, exists bool) {
  4937. v := m.addorganization_id
  4938. if v == nil {
  4939. return
  4940. }
  4941. return *v, true
  4942. }
  4943. // ResetOrganizationID resets all changes to the "organization_id" field.
  4944. func (m *BatchMsgMutation) ResetOrganizationID() {
  4945. m.organization_id = nil
  4946. m.addorganization_id = nil
  4947. }
  4948. // SetCtype sets the "ctype" field.
  4949. func (m *BatchMsgMutation) SetCtype(u uint64) {
  4950. m.ctype = &u
  4951. m.addctype = nil
  4952. }
  4953. // Ctype returns the value of the "ctype" field in the mutation.
  4954. func (m *BatchMsgMutation) Ctype() (r uint64, exists bool) {
  4955. v := m.ctype
  4956. if v == nil {
  4957. return
  4958. }
  4959. return *v, true
  4960. }
  4961. // OldCtype returns the old "ctype" field's value of the BatchMsg entity.
  4962. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4963. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4964. func (m *BatchMsgMutation) OldCtype(ctx context.Context) (v uint64, err error) {
  4965. if !m.op.Is(OpUpdateOne) {
  4966. return v, errors.New("OldCtype is only allowed on UpdateOne operations")
  4967. }
  4968. if m.id == nil || m.oldValue == nil {
  4969. return v, errors.New("OldCtype requires an ID field in the mutation")
  4970. }
  4971. oldValue, err := m.oldValue(ctx)
  4972. if err != nil {
  4973. return v, fmt.Errorf("querying old value for OldCtype: %w", err)
  4974. }
  4975. return oldValue.Ctype, nil
  4976. }
  4977. // AddCtype adds u to the "ctype" field.
  4978. func (m *BatchMsgMutation) AddCtype(u int64) {
  4979. if m.addctype != nil {
  4980. *m.addctype += u
  4981. } else {
  4982. m.addctype = &u
  4983. }
  4984. }
  4985. // AddedCtype returns the value that was added to the "ctype" field in this mutation.
  4986. func (m *BatchMsgMutation) AddedCtype() (r int64, exists bool) {
  4987. v := m.addctype
  4988. if v == nil {
  4989. return
  4990. }
  4991. return *v, true
  4992. }
  4993. // ResetCtype resets all changes to the "ctype" field.
  4994. func (m *BatchMsgMutation) ResetCtype() {
  4995. m.ctype = nil
  4996. m.addctype = nil
  4997. }
  4998. // SetCc sets the "cc" field.
  4999. func (m *BatchMsgMutation) SetCc(s string) {
  5000. m.cc = &s
  5001. }
  5002. // Cc returns the value of the "cc" field in the mutation.
  5003. func (m *BatchMsgMutation) Cc() (r string, exists bool) {
  5004. v := m.cc
  5005. if v == nil {
  5006. return
  5007. }
  5008. return *v, true
  5009. }
  5010. // OldCc returns the old "cc" field's value of the BatchMsg entity.
  5011. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5012. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5013. func (m *BatchMsgMutation) OldCc(ctx context.Context) (v string, err error) {
  5014. if !m.op.Is(OpUpdateOne) {
  5015. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  5016. }
  5017. if m.id == nil || m.oldValue == nil {
  5018. return v, errors.New("OldCc requires an ID field in the mutation")
  5019. }
  5020. oldValue, err := m.oldValue(ctx)
  5021. if err != nil {
  5022. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  5023. }
  5024. return oldValue.Cc, nil
  5025. }
  5026. // ClearCc clears the value of the "cc" field.
  5027. func (m *BatchMsgMutation) ClearCc() {
  5028. m.cc = nil
  5029. m.clearedFields[batchmsg.FieldCc] = struct{}{}
  5030. }
  5031. // CcCleared returns if the "cc" field was cleared in this mutation.
  5032. func (m *BatchMsgMutation) CcCleared() bool {
  5033. _, ok := m.clearedFields[batchmsg.FieldCc]
  5034. return ok
  5035. }
  5036. // ResetCc resets all changes to the "cc" field.
  5037. func (m *BatchMsgMutation) ResetCc() {
  5038. m.cc = nil
  5039. delete(m.clearedFields, batchmsg.FieldCc)
  5040. }
  5041. // SetPhone sets the "phone" field.
  5042. func (m *BatchMsgMutation) SetPhone(s string) {
  5043. m.phone = &s
  5044. }
  5045. // Phone returns the value of the "phone" field in the mutation.
  5046. func (m *BatchMsgMutation) Phone() (r string, exists bool) {
  5047. v := m.phone
  5048. if v == nil {
  5049. return
  5050. }
  5051. return *v, true
  5052. }
  5053. // OldPhone returns the old "phone" field's value of the BatchMsg entity.
  5054. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5055. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5056. func (m *BatchMsgMutation) OldPhone(ctx context.Context) (v string, err error) {
  5057. if !m.op.Is(OpUpdateOne) {
  5058. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  5059. }
  5060. if m.id == nil || m.oldValue == nil {
  5061. return v, errors.New("OldPhone requires an ID field in the mutation")
  5062. }
  5063. oldValue, err := m.oldValue(ctx)
  5064. if err != nil {
  5065. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  5066. }
  5067. return oldValue.Phone, nil
  5068. }
  5069. // ClearPhone clears the value of the "phone" field.
  5070. func (m *BatchMsgMutation) ClearPhone() {
  5071. m.phone = nil
  5072. m.clearedFields[batchmsg.FieldPhone] = struct{}{}
  5073. }
  5074. // PhoneCleared returns if the "phone" field was cleared in this mutation.
  5075. func (m *BatchMsgMutation) PhoneCleared() bool {
  5076. _, ok := m.clearedFields[batchmsg.FieldPhone]
  5077. return ok
  5078. }
  5079. // ResetPhone resets all changes to the "phone" field.
  5080. func (m *BatchMsgMutation) ResetPhone() {
  5081. m.phone = nil
  5082. delete(m.clearedFields, batchmsg.FieldPhone)
  5083. }
  5084. // SetTemplateName sets the "template_name" field.
  5085. func (m *BatchMsgMutation) SetTemplateName(s string) {
  5086. m.template_name = &s
  5087. }
  5088. // TemplateName returns the value of the "template_name" field in the mutation.
  5089. func (m *BatchMsgMutation) TemplateName() (r string, exists bool) {
  5090. v := m.template_name
  5091. if v == nil {
  5092. return
  5093. }
  5094. return *v, true
  5095. }
  5096. // OldTemplateName returns the old "template_name" field's value of the BatchMsg entity.
  5097. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5098. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5099. func (m *BatchMsgMutation) OldTemplateName(ctx context.Context) (v string, err error) {
  5100. if !m.op.Is(OpUpdateOne) {
  5101. return v, errors.New("OldTemplateName is only allowed on UpdateOne operations")
  5102. }
  5103. if m.id == nil || m.oldValue == nil {
  5104. return v, errors.New("OldTemplateName requires an ID field in the mutation")
  5105. }
  5106. oldValue, err := m.oldValue(ctx)
  5107. if err != nil {
  5108. return v, fmt.Errorf("querying old value for OldTemplateName: %w", err)
  5109. }
  5110. return oldValue.TemplateName, nil
  5111. }
  5112. // ClearTemplateName clears the value of the "template_name" field.
  5113. func (m *BatchMsgMutation) ClearTemplateName() {
  5114. m.template_name = nil
  5115. m.clearedFields[batchmsg.FieldTemplateName] = struct{}{}
  5116. }
  5117. // TemplateNameCleared returns if the "template_name" field was cleared in this mutation.
  5118. func (m *BatchMsgMutation) TemplateNameCleared() bool {
  5119. _, ok := m.clearedFields[batchmsg.FieldTemplateName]
  5120. return ok
  5121. }
  5122. // ResetTemplateName resets all changes to the "template_name" field.
  5123. func (m *BatchMsgMutation) ResetTemplateName() {
  5124. m.template_name = nil
  5125. delete(m.clearedFields, batchmsg.FieldTemplateName)
  5126. }
  5127. // SetTemplateCode sets the "template_code" field.
  5128. func (m *BatchMsgMutation) SetTemplateCode(s string) {
  5129. m.template_code = &s
  5130. }
  5131. // TemplateCode returns the value of the "template_code" field in the mutation.
  5132. func (m *BatchMsgMutation) TemplateCode() (r string, exists bool) {
  5133. v := m.template_code
  5134. if v == nil {
  5135. return
  5136. }
  5137. return *v, true
  5138. }
  5139. // OldTemplateCode returns the old "template_code" field's value of the BatchMsg entity.
  5140. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5141. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5142. func (m *BatchMsgMutation) OldTemplateCode(ctx context.Context) (v string, err error) {
  5143. if !m.op.Is(OpUpdateOne) {
  5144. return v, errors.New("OldTemplateCode is only allowed on UpdateOne operations")
  5145. }
  5146. if m.id == nil || m.oldValue == nil {
  5147. return v, errors.New("OldTemplateCode requires an ID field in the mutation")
  5148. }
  5149. oldValue, err := m.oldValue(ctx)
  5150. if err != nil {
  5151. return v, fmt.Errorf("querying old value for OldTemplateCode: %w", err)
  5152. }
  5153. return oldValue.TemplateCode, nil
  5154. }
  5155. // ClearTemplateCode clears the value of the "template_code" field.
  5156. func (m *BatchMsgMutation) ClearTemplateCode() {
  5157. m.template_code = nil
  5158. m.clearedFields[batchmsg.FieldTemplateCode] = struct{}{}
  5159. }
  5160. // TemplateCodeCleared returns if the "template_code" field was cleared in this mutation.
  5161. func (m *BatchMsgMutation) TemplateCodeCleared() bool {
  5162. _, ok := m.clearedFields[batchmsg.FieldTemplateCode]
  5163. return ok
  5164. }
  5165. // ResetTemplateCode resets all changes to the "template_code" field.
  5166. func (m *BatchMsgMutation) ResetTemplateCode() {
  5167. m.template_code = nil
  5168. delete(m.clearedFields, batchmsg.FieldTemplateCode)
  5169. }
  5170. // SetLang sets the "lang" field.
  5171. func (m *BatchMsgMutation) SetLang(s string) {
  5172. m.lang = &s
  5173. }
  5174. // Lang returns the value of the "lang" field in the mutation.
  5175. func (m *BatchMsgMutation) Lang() (r string, exists bool) {
  5176. v := m.lang
  5177. if v == nil {
  5178. return
  5179. }
  5180. return *v, true
  5181. }
  5182. // OldLang returns the old "lang" field's value of the BatchMsg entity.
  5183. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5184. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5185. func (m *BatchMsgMutation) OldLang(ctx context.Context) (v string, err error) {
  5186. if !m.op.Is(OpUpdateOne) {
  5187. return v, errors.New("OldLang is only allowed on UpdateOne operations")
  5188. }
  5189. if m.id == nil || m.oldValue == nil {
  5190. return v, errors.New("OldLang requires an ID field in the mutation")
  5191. }
  5192. oldValue, err := m.oldValue(ctx)
  5193. if err != nil {
  5194. return v, fmt.Errorf("querying old value for OldLang: %w", err)
  5195. }
  5196. return oldValue.Lang, nil
  5197. }
  5198. // ClearLang clears the value of the "lang" field.
  5199. func (m *BatchMsgMutation) ClearLang() {
  5200. m.lang = nil
  5201. m.clearedFields[batchmsg.FieldLang] = struct{}{}
  5202. }
  5203. // LangCleared returns if the "lang" field was cleared in this mutation.
  5204. func (m *BatchMsgMutation) LangCleared() bool {
  5205. _, ok := m.clearedFields[batchmsg.FieldLang]
  5206. return ok
  5207. }
  5208. // ResetLang resets all changes to the "lang" field.
  5209. func (m *BatchMsgMutation) ResetLang() {
  5210. m.lang = nil
  5211. delete(m.clearedFields, batchmsg.FieldLang)
  5212. }
  5213. // Where appends a list predicates to the BatchMsgMutation builder.
  5214. func (m *BatchMsgMutation) Where(ps ...predicate.BatchMsg) {
  5215. m.predicates = append(m.predicates, ps...)
  5216. }
  5217. // WhereP appends storage-level predicates to the BatchMsgMutation builder. Using this method,
  5218. // users can use type-assertion to append predicates that do not depend on any generated package.
  5219. func (m *BatchMsgMutation) WhereP(ps ...func(*sql.Selector)) {
  5220. p := make([]predicate.BatchMsg, len(ps))
  5221. for i := range ps {
  5222. p[i] = ps[i]
  5223. }
  5224. m.Where(p...)
  5225. }
  5226. // Op returns the operation name.
  5227. func (m *BatchMsgMutation) Op() Op {
  5228. return m.op
  5229. }
  5230. // SetOp allows setting the mutation operation.
  5231. func (m *BatchMsgMutation) SetOp(op Op) {
  5232. m.op = op
  5233. }
  5234. // Type returns the node type of this mutation (BatchMsg).
  5235. func (m *BatchMsgMutation) Type() string {
  5236. return m.typ
  5237. }
  5238. // Fields returns all fields that were changed during this mutation. Note that in
  5239. // order to get all numeric fields that were incremented/decremented, call
  5240. // AddedFields().
  5241. func (m *BatchMsgMutation) Fields() []string {
  5242. fields := make([]string, 0, 24)
  5243. if m.created_at != nil {
  5244. fields = append(fields, batchmsg.FieldCreatedAt)
  5245. }
  5246. if m.updated_at != nil {
  5247. fields = append(fields, batchmsg.FieldUpdatedAt)
  5248. }
  5249. if m.deleted_at != nil {
  5250. fields = append(fields, batchmsg.FieldDeletedAt)
  5251. }
  5252. if m.status != nil {
  5253. fields = append(fields, batchmsg.FieldStatus)
  5254. }
  5255. if m.batch_no != nil {
  5256. fields = append(fields, batchmsg.FieldBatchNo)
  5257. }
  5258. if m.task_name != nil {
  5259. fields = append(fields, batchmsg.FieldTaskName)
  5260. }
  5261. if m.fromwxid != nil {
  5262. fields = append(fields, batchmsg.FieldFromwxid)
  5263. }
  5264. if m.msg != nil {
  5265. fields = append(fields, batchmsg.FieldMsg)
  5266. }
  5267. if m.tag != nil {
  5268. fields = append(fields, batchmsg.FieldTag)
  5269. }
  5270. if m.tagids != nil {
  5271. fields = append(fields, batchmsg.FieldTagids)
  5272. }
  5273. if m.total != nil {
  5274. fields = append(fields, batchmsg.FieldTotal)
  5275. }
  5276. if m.success != nil {
  5277. fields = append(fields, batchmsg.FieldSuccess)
  5278. }
  5279. if m.fail != nil {
  5280. fields = append(fields, batchmsg.FieldFail)
  5281. }
  5282. if m.start_time != nil {
  5283. fields = append(fields, batchmsg.FieldStartTime)
  5284. }
  5285. if m.stop_time != nil {
  5286. fields = append(fields, batchmsg.FieldStopTime)
  5287. }
  5288. if m.send_time != nil {
  5289. fields = append(fields, batchmsg.FieldSendTime)
  5290. }
  5291. if m._type != nil {
  5292. fields = append(fields, batchmsg.FieldType)
  5293. }
  5294. if m.organization_id != nil {
  5295. fields = append(fields, batchmsg.FieldOrganizationID)
  5296. }
  5297. if m.ctype != nil {
  5298. fields = append(fields, batchmsg.FieldCtype)
  5299. }
  5300. if m.cc != nil {
  5301. fields = append(fields, batchmsg.FieldCc)
  5302. }
  5303. if m.phone != nil {
  5304. fields = append(fields, batchmsg.FieldPhone)
  5305. }
  5306. if m.template_name != nil {
  5307. fields = append(fields, batchmsg.FieldTemplateName)
  5308. }
  5309. if m.template_code != nil {
  5310. fields = append(fields, batchmsg.FieldTemplateCode)
  5311. }
  5312. if m.lang != nil {
  5313. fields = append(fields, batchmsg.FieldLang)
  5314. }
  5315. return fields
  5316. }
  5317. // Field returns the value of a field with the given name. The second boolean
  5318. // return value indicates that this field was not set, or was not defined in the
  5319. // schema.
  5320. func (m *BatchMsgMutation) Field(name string) (ent.Value, bool) {
  5321. switch name {
  5322. case batchmsg.FieldCreatedAt:
  5323. return m.CreatedAt()
  5324. case batchmsg.FieldUpdatedAt:
  5325. return m.UpdatedAt()
  5326. case batchmsg.FieldDeletedAt:
  5327. return m.DeletedAt()
  5328. case batchmsg.FieldStatus:
  5329. return m.Status()
  5330. case batchmsg.FieldBatchNo:
  5331. return m.BatchNo()
  5332. case batchmsg.FieldTaskName:
  5333. return m.TaskName()
  5334. case batchmsg.FieldFromwxid:
  5335. return m.Fromwxid()
  5336. case batchmsg.FieldMsg:
  5337. return m.Msg()
  5338. case batchmsg.FieldTag:
  5339. return m.Tag()
  5340. case batchmsg.FieldTagids:
  5341. return m.Tagids()
  5342. case batchmsg.FieldTotal:
  5343. return m.Total()
  5344. case batchmsg.FieldSuccess:
  5345. return m.Success()
  5346. case batchmsg.FieldFail:
  5347. return m.Fail()
  5348. case batchmsg.FieldStartTime:
  5349. return m.StartTime()
  5350. case batchmsg.FieldStopTime:
  5351. return m.StopTime()
  5352. case batchmsg.FieldSendTime:
  5353. return m.SendTime()
  5354. case batchmsg.FieldType:
  5355. return m.GetType()
  5356. case batchmsg.FieldOrganizationID:
  5357. return m.OrganizationID()
  5358. case batchmsg.FieldCtype:
  5359. return m.Ctype()
  5360. case batchmsg.FieldCc:
  5361. return m.Cc()
  5362. case batchmsg.FieldPhone:
  5363. return m.Phone()
  5364. case batchmsg.FieldTemplateName:
  5365. return m.TemplateName()
  5366. case batchmsg.FieldTemplateCode:
  5367. return m.TemplateCode()
  5368. case batchmsg.FieldLang:
  5369. return m.Lang()
  5370. }
  5371. return nil, false
  5372. }
  5373. // OldField returns the old value of the field from the database. An error is
  5374. // returned if the mutation operation is not UpdateOne, or the query to the
  5375. // database failed.
  5376. func (m *BatchMsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  5377. switch name {
  5378. case batchmsg.FieldCreatedAt:
  5379. return m.OldCreatedAt(ctx)
  5380. case batchmsg.FieldUpdatedAt:
  5381. return m.OldUpdatedAt(ctx)
  5382. case batchmsg.FieldDeletedAt:
  5383. return m.OldDeletedAt(ctx)
  5384. case batchmsg.FieldStatus:
  5385. return m.OldStatus(ctx)
  5386. case batchmsg.FieldBatchNo:
  5387. return m.OldBatchNo(ctx)
  5388. case batchmsg.FieldTaskName:
  5389. return m.OldTaskName(ctx)
  5390. case batchmsg.FieldFromwxid:
  5391. return m.OldFromwxid(ctx)
  5392. case batchmsg.FieldMsg:
  5393. return m.OldMsg(ctx)
  5394. case batchmsg.FieldTag:
  5395. return m.OldTag(ctx)
  5396. case batchmsg.FieldTagids:
  5397. return m.OldTagids(ctx)
  5398. case batchmsg.FieldTotal:
  5399. return m.OldTotal(ctx)
  5400. case batchmsg.FieldSuccess:
  5401. return m.OldSuccess(ctx)
  5402. case batchmsg.FieldFail:
  5403. return m.OldFail(ctx)
  5404. case batchmsg.FieldStartTime:
  5405. return m.OldStartTime(ctx)
  5406. case batchmsg.FieldStopTime:
  5407. return m.OldStopTime(ctx)
  5408. case batchmsg.FieldSendTime:
  5409. return m.OldSendTime(ctx)
  5410. case batchmsg.FieldType:
  5411. return m.OldType(ctx)
  5412. case batchmsg.FieldOrganizationID:
  5413. return m.OldOrganizationID(ctx)
  5414. case batchmsg.FieldCtype:
  5415. return m.OldCtype(ctx)
  5416. case batchmsg.FieldCc:
  5417. return m.OldCc(ctx)
  5418. case batchmsg.FieldPhone:
  5419. return m.OldPhone(ctx)
  5420. case batchmsg.FieldTemplateName:
  5421. return m.OldTemplateName(ctx)
  5422. case batchmsg.FieldTemplateCode:
  5423. return m.OldTemplateCode(ctx)
  5424. case batchmsg.FieldLang:
  5425. return m.OldLang(ctx)
  5426. }
  5427. return nil, fmt.Errorf("unknown BatchMsg field %s", name)
  5428. }
  5429. // SetField sets the value of a field with the given name. It returns an error if
  5430. // the field is not defined in the schema, or if the type mismatched the field
  5431. // type.
  5432. func (m *BatchMsgMutation) SetField(name string, value ent.Value) error {
  5433. switch name {
  5434. case batchmsg.FieldCreatedAt:
  5435. v, ok := value.(time.Time)
  5436. if !ok {
  5437. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5438. }
  5439. m.SetCreatedAt(v)
  5440. return nil
  5441. case batchmsg.FieldUpdatedAt:
  5442. v, ok := value.(time.Time)
  5443. if !ok {
  5444. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5445. }
  5446. m.SetUpdatedAt(v)
  5447. return nil
  5448. case batchmsg.FieldDeletedAt:
  5449. v, ok := value.(time.Time)
  5450. if !ok {
  5451. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5452. }
  5453. m.SetDeletedAt(v)
  5454. return nil
  5455. case batchmsg.FieldStatus:
  5456. v, ok := value.(uint8)
  5457. if !ok {
  5458. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5459. }
  5460. m.SetStatus(v)
  5461. return nil
  5462. case batchmsg.FieldBatchNo:
  5463. v, ok := value.(string)
  5464. if !ok {
  5465. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5466. }
  5467. m.SetBatchNo(v)
  5468. return nil
  5469. case batchmsg.FieldTaskName:
  5470. v, ok := value.(string)
  5471. if !ok {
  5472. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5473. }
  5474. m.SetTaskName(v)
  5475. return nil
  5476. case batchmsg.FieldFromwxid:
  5477. v, ok := value.(string)
  5478. if !ok {
  5479. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5480. }
  5481. m.SetFromwxid(v)
  5482. return nil
  5483. case batchmsg.FieldMsg:
  5484. v, ok := value.(string)
  5485. if !ok {
  5486. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5487. }
  5488. m.SetMsg(v)
  5489. return nil
  5490. case batchmsg.FieldTag:
  5491. v, ok := value.(string)
  5492. if !ok {
  5493. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5494. }
  5495. m.SetTag(v)
  5496. return nil
  5497. case batchmsg.FieldTagids:
  5498. v, ok := value.(string)
  5499. if !ok {
  5500. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5501. }
  5502. m.SetTagids(v)
  5503. return nil
  5504. case batchmsg.FieldTotal:
  5505. v, ok := value.(int32)
  5506. if !ok {
  5507. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5508. }
  5509. m.SetTotal(v)
  5510. return nil
  5511. case batchmsg.FieldSuccess:
  5512. v, ok := value.(int32)
  5513. if !ok {
  5514. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5515. }
  5516. m.SetSuccess(v)
  5517. return nil
  5518. case batchmsg.FieldFail:
  5519. v, ok := value.(int32)
  5520. if !ok {
  5521. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5522. }
  5523. m.SetFail(v)
  5524. return nil
  5525. case batchmsg.FieldStartTime:
  5526. v, ok := value.(time.Time)
  5527. if !ok {
  5528. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5529. }
  5530. m.SetStartTime(v)
  5531. return nil
  5532. case batchmsg.FieldStopTime:
  5533. v, ok := value.(time.Time)
  5534. if !ok {
  5535. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5536. }
  5537. m.SetStopTime(v)
  5538. return nil
  5539. case batchmsg.FieldSendTime:
  5540. v, ok := value.(time.Time)
  5541. if !ok {
  5542. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5543. }
  5544. m.SetSendTime(v)
  5545. return nil
  5546. case batchmsg.FieldType:
  5547. v, ok := value.(int32)
  5548. if !ok {
  5549. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5550. }
  5551. m.SetType(v)
  5552. return nil
  5553. case batchmsg.FieldOrganizationID:
  5554. v, ok := value.(uint64)
  5555. if !ok {
  5556. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5557. }
  5558. m.SetOrganizationID(v)
  5559. return nil
  5560. case batchmsg.FieldCtype:
  5561. v, ok := value.(uint64)
  5562. if !ok {
  5563. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5564. }
  5565. m.SetCtype(v)
  5566. return nil
  5567. case batchmsg.FieldCc:
  5568. v, ok := value.(string)
  5569. if !ok {
  5570. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5571. }
  5572. m.SetCc(v)
  5573. return nil
  5574. case batchmsg.FieldPhone:
  5575. v, ok := value.(string)
  5576. if !ok {
  5577. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5578. }
  5579. m.SetPhone(v)
  5580. return nil
  5581. case batchmsg.FieldTemplateName:
  5582. v, ok := value.(string)
  5583. if !ok {
  5584. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5585. }
  5586. m.SetTemplateName(v)
  5587. return nil
  5588. case batchmsg.FieldTemplateCode:
  5589. v, ok := value.(string)
  5590. if !ok {
  5591. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5592. }
  5593. m.SetTemplateCode(v)
  5594. return nil
  5595. case batchmsg.FieldLang:
  5596. v, ok := value.(string)
  5597. if !ok {
  5598. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5599. }
  5600. m.SetLang(v)
  5601. return nil
  5602. }
  5603. return fmt.Errorf("unknown BatchMsg field %s", name)
  5604. }
  5605. // AddedFields returns all numeric fields that were incremented/decremented during
  5606. // this mutation.
  5607. func (m *BatchMsgMutation) AddedFields() []string {
  5608. var fields []string
  5609. if m.addstatus != nil {
  5610. fields = append(fields, batchmsg.FieldStatus)
  5611. }
  5612. if m.addtotal != nil {
  5613. fields = append(fields, batchmsg.FieldTotal)
  5614. }
  5615. if m.addsuccess != nil {
  5616. fields = append(fields, batchmsg.FieldSuccess)
  5617. }
  5618. if m.addfail != nil {
  5619. fields = append(fields, batchmsg.FieldFail)
  5620. }
  5621. if m.add_type != nil {
  5622. fields = append(fields, batchmsg.FieldType)
  5623. }
  5624. if m.addorganization_id != nil {
  5625. fields = append(fields, batchmsg.FieldOrganizationID)
  5626. }
  5627. if m.addctype != nil {
  5628. fields = append(fields, batchmsg.FieldCtype)
  5629. }
  5630. return fields
  5631. }
  5632. // AddedField returns the numeric value that was incremented/decremented on a field
  5633. // with the given name. The second boolean return value indicates that this field
  5634. // was not set, or was not defined in the schema.
  5635. func (m *BatchMsgMutation) AddedField(name string) (ent.Value, bool) {
  5636. switch name {
  5637. case batchmsg.FieldStatus:
  5638. return m.AddedStatus()
  5639. case batchmsg.FieldTotal:
  5640. return m.AddedTotal()
  5641. case batchmsg.FieldSuccess:
  5642. return m.AddedSuccess()
  5643. case batchmsg.FieldFail:
  5644. return m.AddedFail()
  5645. case batchmsg.FieldType:
  5646. return m.AddedType()
  5647. case batchmsg.FieldOrganizationID:
  5648. return m.AddedOrganizationID()
  5649. case batchmsg.FieldCtype:
  5650. return m.AddedCtype()
  5651. }
  5652. return nil, false
  5653. }
  5654. // AddField adds the value to the field with the given name. It returns an error if
  5655. // the field is not defined in the schema, or if the type mismatched the field
  5656. // type.
  5657. func (m *BatchMsgMutation) AddField(name string, value ent.Value) error {
  5658. switch name {
  5659. case batchmsg.FieldStatus:
  5660. v, ok := value.(int8)
  5661. if !ok {
  5662. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5663. }
  5664. m.AddStatus(v)
  5665. return nil
  5666. case batchmsg.FieldTotal:
  5667. v, ok := value.(int32)
  5668. if !ok {
  5669. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5670. }
  5671. m.AddTotal(v)
  5672. return nil
  5673. case batchmsg.FieldSuccess:
  5674. v, ok := value.(int32)
  5675. if !ok {
  5676. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5677. }
  5678. m.AddSuccess(v)
  5679. return nil
  5680. case batchmsg.FieldFail:
  5681. v, ok := value.(int32)
  5682. if !ok {
  5683. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5684. }
  5685. m.AddFail(v)
  5686. return nil
  5687. case batchmsg.FieldType:
  5688. v, ok := value.(int32)
  5689. if !ok {
  5690. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5691. }
  5692. m.AddType(v)
  5693. return nil
  5694. case batchmsg.FieldOrganizationID:
  5695. v, ok := value.(int64)
  5696. if !ok {
  5697. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5698. }
  5699. m.AddOrganizationID(v)
  5700. return nil
  5701. case batchmsg.FieldCtype:
  5702. v, ok := value.(int64)
  5703. if !ok {
  5704. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5705. }
  5706. m.AddCtype(v)
  5707. return nil
  5708. }
  5709. return fmt.Errorf("unknown BatchMsg numeric field %s", name)
  5710. }
  5711. // ClearedFields returns all nullable fields that were cleared during this
  5712. // mutation.
  5713. func (m *BatchMsgMutation) ClearedFields() []string {
  5714. var fields []string
  5715. if m.FieldCleared(batchmsg.FieldDeletedAt) {
  5716. fields = append(fields, batchmsg.FieldDeletedAt)
  5717. }
  5718. if m.FieldCleared(batchmsg.FieldStatus) {
  5719. fields = append(fields, batchmsg.FieldStatus)
  5720. }
  5721. if m.FieldCleared(batchmsg.FieldBatchNo) {
  5722. fields = append(fields, batchmsg.FieldBatchNo)
  5723. }
  5724. if m.FieldCleared(batchmsg.FieldTaskName) {
  5725. fields = append(fields, batchmsg.FieldTaskName)
  5726. }
  5727. if m.FieldCleared(batchmsg.FieldFromwxid) {
  5728. fields = append(fields, batchmsg.FieldFromwxid)
  5729. }
  5730. if m.FieldCleared(batchmsg.FieldMsg) {
  5731. fields = append(fields, batchmsg.FieldMsg)
  5732. }
  5733. if m.FieldCleared(batchmsg.FieldTag) {
  5734. fields = append(fields, batchmsg.FieldTag)
  5735. }
  5736. if m.FieldCleared(batchmsg.FieldTagids) {
  5737. fields = append(fields, batchmsg.FieldTagids)
  5738. }
  5739. if m.FieldCleared(batchmsg.FieldTotal) {
  5740. fields = append(fields, batchmsg.FieldTotal)
  5741. }
  5742. if m.FieldCleared(batchmsg.FieldSuccess) {
  5743. fields = append(fields, batchmsg.FieldSuccess)
  5744. }
  5745. if m.FieldCleared(batchmsg.FieldFail) {
  5746. fields = append(fields, batchmsg.FieldFail)
  5747. }
  5748. if m.FieldCleared(batchmsg.FieldStartTime) {
  5749. fields = append(fields, batchmsg.FieldStartTime)
  5750. }
  5751. if m.FieldCleared(batchmsg.FieldStopTime) {
  5752. fields = append(fields, batchmsg.FieldStopTime)
  5753. }
  5754. if m.FieldCleared(batchmsg.FieldSendTime) {
  5755. fields = append(fields, batchmsg.FieldSendTime)
  5756. }
  5757. if m.FieldCleared(batchmsg.FieldType) {
  5758. fields = append(fields, batchmsg.FieldType)
  5759. }
  5760. if m.FieldCleared(batchmsg.FieldCc) {
  5761. fields = append(fields, batchmsg.FieldCc)
  5762. }
  5763. if m.FieldCleared(batchmsg.FieldPhone) {
  5764. fields = append(fields, batchmsg.FieldPhone)
  5765. }
  5766. if m.FieldCleared(batchmsg.FieldTemplateName) {
  5767. fields = append(fields, batchmsg.FieldTemplateName)
  5768. }
  5769. if m.FieldCleared(batchmsg.FieldTemplateCode) {
  5770. fields = append(fields, batchmsg.FieldTemplateCode)
  5771. }
  5772. if m.FieldCleared(batchmsg.FieldLang) {
  5773. fields = append(fields, batchmsg.FieldLang)
  5774. }
  5775. return fields
  5776. }
  5777. // FieldCleared returns a boolean indicating if a field with the given name was
  5778. // cleared in this mutation.
  5779. func (m *BatchMsgMutation) FieldCleared(name string) bool {
  5780. _, ok := m.clearedFields[name]
  5781. return ok
  5782. }
  5783. // ClearField clears the value of the field with the given name. It returns an
  5784. // error if the field is not defined in the schema.
  5785. func (m *BatchMsgMutation) ClearField(name string) error {
  5786. switch name {
  5787. case batchmsg.FieldDeletedAt:
  5788. m.ClearDeletedAt()
  5789. return nil
  5790. case batchmsg.FieldStatus:
  5791. m.ClearStatus()
  5792. return nil
  5793. case batchmsg.FieldBatchNo:
  5794. m.ClearBatchNo()
  5795. return nil
  5796. case batchmsg.FieldTaskName:
  5797. m.ClearTaskName()
  5798. return nil
  5799. case batchmsg.FieldFromwxid:
  5800. m.ClearFromwxid()
  5801. return nil
  5802. case batchmsg.FieldMsg:
  5803. m.ClearMsg()
  5804. return nil
  5805. case batchmsg.FieldTag:
  5806. m.ClearTag()
  5807. return nil
  5808. case batchmsg.FieldTagids:
  5809. m.ClearTagids()
  5810. return nil
  5811. case batchmsg.FieldTotal:
  5812. m.ClearTotal()
  5813. return nil
  5814. case batchmsg.FieldSuccess:
  5815. m.ClearSuccess()
  5816. return nil
  5817. case batchmsg.FieldFail:
  5818. m.ClearFail()
  5819. return nil
  5820. case batchmsg.FieldStartTime:
  5821. m.ClearStartTime()
  5822. return nil
  5823. case batchmsg.FieldStopTime:
  5824. m.ClearStopTime()
  5825. return nil
  5826. case batchmsg.FieldSendTime:
  5827. m.ClearSendTime()
  5828. return nil
  5829. case batchmsg.FieldType:
  5830. m.ClearType()
  5831. return nil
  5832. case batchmsg.FieldCc:
  5833. m.ClearCc()
  5834. return nil
  5835. case batchmsg.FieldPhone:
  5836. m.ClearPhone()
  5837. return nil
  5838. case batchmsg.FieldTemplateName:
  5839. m.ClearTemplateName()
  5840. return nil
  5841. case batchmsg.FieldTemplateCode:
  5842. m.ClearTemplateCode()
  5843. return nil
  5844. case batchmsg.FieldLang:
  5845. m.ClearLang()
  5846. return nil
  5847. }
  5848. return fmt.Errorf("unknown BatchMsg nullable field %s", name)
  5849. }
  5850. // ResetField resets all changes in the mutation for the field with the given name.
  5851. // It returns an error if the field is not defined in the schema.
  5852. func (m *BatchMsgMutation) ResetField(name string) error {
  5853. switch name {
  5854. case batchmsg.FieldCreatedAt:
  5855. m.ResetCreatedAt()
  5856. return nil
  5857. case batchmsg.FieldUpdatedAt:
  5858. m.ResetUpdatedAt()
  5859. return nil
  5860. case batchmsg.FieldDeletedAt:
  5861. m.ResetDeletedAt()
  5862. return nil
  5863. case batchmsg.FieldStatus:
  5864. m.ResetStatus()
  5865. return nil
  5866. case batchmsg.FieldBatchNo:
  5867. m.ResetBatchNo()
  5868. return nil
  5869. case batchmsg.FieldTaskName:
  5870. m.ResetTaskName()
  5871. return nil
  5872. case batchmsg.FieldFromwxid:
  5873. m.ResetFromwxid()
  5874. return nil
  5875. case batchmsg.FieldMsg:
  5876. m.ResetMsg()
  5877. return nil
  5878. case batchmsg.FieldTag:
  5879. m.ResetTag()
  5880. return nil
  5881. case batchmsg.FieldTagids:
  5882. m.ResetTagids()
  5883. return nil
  5884. case batchmsg.FieldTotal:
  5885. m.ResetTotal()
  5886. return nil
  5887. case batchmsg.FieldSuccess:
  5888. m.ResetSuccess()
  5889. return nil
  5890. case batchmsg.FieldFail:
  5891. m.ResetFail()
  5892. return nil
  5893. case batchmsg.FieldStartTime:
  5894. m.ResetStartTime()
  5895. return nil
  5896. case batchmsg.FieldStopTime:
  5897. m.ResetStopTime()
  5898. return nil
  5899. case batchmsg.FieldSendTime:
  5900. m.ResetSendTime()
  5901. return nil
  5902. case batchmsg.FieldType:
  5903. m.ResetType()
  5904. return nil
  5905. case batchmsg.FieldOrganizationID:
  5906. m.ResetOrganizationID()
  5907. return nil
  5908. case batchmsg.FieldCtype:
  5909. m.ResetCtype()
  5910. return nil
  5911. case batchmsg.FieldCc:
  5912. m.ResetCc()
  5913. return nil
  5914. case batchmsg.FieldPhone:
  5915. m.ResetPhone()
  5916. return nil
  5917. case batchmsg.FieldTemplateName:
  5918. m.ResetTemplateName()
  5919. return nil
  5920. case batchmsg.FieldTemplateCode:
  5921. m.ResetTemplateCode()
  5922. return nil
  5923. case batchmsg.FieldLang:
  5924. m.ResetLang()
  5925. return nil
  5926. }
  5927. return fmt.Errorf("unknown BatchMsg field %s", name)
  5928. }
  5929. // AddedEdges returns all edge names that were set/added in this mutation.
  5930. func (m *BatchMsgMutation) AddedEdges() []string {
  5931. edges := make([]string, 0, 0)
  5932. return edges
  5933. }
  5934. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  5935. // name in this mutation.
  5936. func (m *BatchMsgMutation) AddedIDs(name string) []ent.Value {
  5937. return nil
  5938. }
  5939. // RemovedEdges returns all edge names that were removed in this mutation.
  5940. func (m *BatchMsgMutation) RemovedEdges() []string {
  5941. edges := make([]string, 0, 0)
  5942. return edges
  5943. }
  5944. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  5945. // the given name in this mutation.
  5946. func (m *BatchMsgMutation) RemovedIDs(name string) []ent.Value {
  5947. return nil
  5948. }
  5949. // ClearedEdges returns all edge names that were cleared in this mutation.
  5950. func (m *BatchMsgMutation) ClearedEdges() []string {
  5951. edges := make([]string, 0, 0)
  5952. return edges
  5953. }
  5954. // EdgeCleared returns a boolean which indicates if the edge with the given name
  5955. // was cleared in this mutation.
  5956. func (m *BatchMsgMutation) EdgeCleared(name string) bool {
  5957. return false
  5958. }
  5959. // ClearEdge clears the value of the edge with the given name. It returns an error
  5960. // if that edge is not defined in the schema.
  5961. func (m *BatchMsgMutation) ClearEdge(name string) error {
  5962. return fmt.Errorf("unknown BatchMsg unique edge %s", name)
  5963. }
  5964. // ResetEdge resets all changes to the edge with the given name in this mutation.
  5965. // It returns an error if the edge is not defined in the schema.
  5966. func (m *BatchMsgMutation) ResetEdge(name string) error {
  5967. return fmt.Errorf("unknown BatchMsg edge %s", name)
  5968. }
  5969. // CategoryMutation represents an operation that mutates the Category nodes in the graph.
  5970. type CategoryMutation struct {
  5971. config
  5972. op Op
  5973. typ string
  5974. id *uint64
  5975. created_at *time.Time
  5976. updated_at *time.Time
  5977. deleted_at *time.Time
  5978. name *string
  5979. organization_id *uint64
  5980. addorganization_id *int64
  5981. clearedFields map[string]struct{}
  5982. done bool
  5983. oldValue func(context.Context) (*Category, error)
  5984. predicates []predicate.Category
  5985. }
  5986. var _ ent.Mutation = (*CategoryMutation)(nil)
  5987. // categoryOption allows management of the mutation configuration using functional options.
  5988. type categoryOption func(*CategoryMutation)
  5989. // newCategoryMutation creates new mutation for the Category entity.
  5990. func newCategoryMutation(c config, op Op, opts ...categoryOption) *CategoryMutation {
  5991. m := &CategoryMutation{
  5992. config: c,
  5993. op: op,
  5994. typ: TypeCategory,
  5995. clearedFields: make(map[string]struct{}),
  5996. }
  5997. for _, opt := range opts {
  5998. opt(m)
  5999. }
  6000. return m
  6001. }
  6002. // withCategoryID sets the ID field of the mutation.
  6003. func withCategoryID(id uint64) categoryOption {
  6004. return func(m *CategoryMutation) {
  6005. var (
  6006. err error
  6007. once sync.Once
  6008. value *Category
  6009. )
  6010. m.oldValue = func(ctx context.Context) (*Category, error) {
  6011. once.Do(func() {
  6012. if m.done {
  6013. err = errors.New("querying old values post mutation is not allowed")
  6014. } else {
  6015. value, err = m.Client().Category.Get(ctx, id)
  6016. }
  6017. })
  6018. return value, err
  6019. }
  6020. m.id = &id
  6021. }
  6022. }
  6023. // withCategory sets the old Category of the mutation.
  6024. func withCategory(node *Category) categoryOption {
  6025. return func(m *CategoryMutation) {
  6026. m.oldValue = func(context.Context) (*Category, error) {
  6027. return node, nil
  6028. }
  6029. m.id = &node.ID
  6030. }
  6031. }
  6032. // Client returns a new `ent.Client` from the mutation. If the mutation was
  6033. // executed in a transaction (ent.Tx), a transactional client is returned.
  6034. func (m CategoryMutation) Client() *Client {
  6035. client := &Client{config: m.config}
  6036. client.init()
  6037. return client
  6038. }
  6039. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  6040. // it returns an error otherwise.
  6041. func (m CategoryMutation) Tx() (*Tx, error) {
  6042. if _, ok := m.driver.(*txDriver); !ok {
  6043. return nil, errors.New("ent: mutation is not running in a transaction")
  6044. }
  6045. tx := &Tx{config: m.config}
  6046. tx.init()
  6047. return tx, nil
  6048. }
  6049. // SetID sets the value of the id field. Note that this
  6050. // operation is only accepted on creation of Category entities.
  6051. func (m *CategoryMutation) SetID(id uint64) {
  6052. m.id = &id
  6053. }
  6054. // ID returns the ID value in the mutation. Note that the ID is only available
  6055. // if it was provided to the builder or after it was returned from the database.
  6056. func (m *CategoryMutation) ID() (id uint64, exists bool) {
  6057. if m.id == nil {
  6058. return
  6059. }
  6060. return *m.id, true
  6061. }
  6062. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  6063. // That means, if the mutation is applied within a transaction with an isolation level such
  6064. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  6065. // or updated by the mutation.
  6066. func (m *CategoryMutation) IDs(ctx context.Context) ([]uint64, error) {
  6067. switch {
  6068. case m.op.Is(OpUpdateOne | OpDeleteOne):
  6069. id, exists := m.ID()
  6070. if exists {
  6071. return []uint64{id}, nil
  6072. }
  6073. fallthrough
  6074. case m.op.Is(OpUpdate | OpDelete):
  6075. return m.Client().Category.Query().Where(m.predicates...).IDs(ctx)
  6076. default:
  6077. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  6078. }
  6079. }
  6080. // SetCreatedAt sets the "created_at" field.
  6081. func (m *CategoryMutation) SetCreatedAt(t time.Time) {
  6082. m.created_at = &t
  6083. }
  6084. // CreatedAt returns the value of the "created_at" field in the mutation.
  6085. func (m *CategoryMutation) CreatedAt() (r time.Time, exists bool) {
  6086. v := m.created_at
  6087. if v == nil {
  6088. return
  6089. }
  6090. return *v, true
  6091. }
  6092. // OldCreatedAt returns the old "created_at" field's value of the Category entity.
  6093. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  6094. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6095. func (m *CategoryMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  6096. if !m.op.Is(OpUpdateOne) {
  6097. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  6098. }
  6099. if m.id == nil || m.oldValue == nil {
  6100. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  6101. }
  6102. oldValue, err := m.oldValue(ctx)
  6103. if err != nil {
  6104. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  6105. }
  6106. return oldValue.CreatedAt, nil
  6107. }
  6108. // ResetCreatedAt resets all changes to the "created_at" field.
  6109. func (m *CategoryMutation) ResetCreatedAt() {
  6110. m.created_at = nil
  6111. }
  6112. // SetUpdatedAt sets the "updated_at" field.
  6113. func (m *CategoryMutation) SetUpdatedAt(t time.Time) {
  6114. m.updated_at = &t
  6115. }
  6116. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  6117. func (m *CategoryMutation) UpdatedAt() (r time.Time, exists bool) {
  6118. v := m.updated_at
  6119. if v == nil {
  6120. return
  6121. }
  6122. return *v, true
  6123. }
  6124. // OldUpdatedAt returns the old "updated_at" field's value of the Category entity.
  6125. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  6126. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6127. func (m *CategoryMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  6128. if !m.op.Is(OpUpdateOne) {
  6129. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  6130. }
  6131. if m.id == nil || m.oldValue == nil {
  6132. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  6133. }
  6134. oldValue, err := m.oldValue(ctx)
  6135. if err != nil {
  6136. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  6137. }
  6138. return oldValue.UpdatedAt, nil
  6139. }
  6140. // ResetUpdatedAt resets all changes to the "updated_at" field.
  6141. func (m *CategoryMutation) ResetUpdatedAt() {
  6142. m.updated_at = nil
  6143. }
  6144. // SetDeletedAt sets the "deleted_at" field.
  6145. func (m *CategoryMutation) SetDeletedAt(t time.Time) {
  6146. m.deleted_at = &t
  6147. }
  6148. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  6149. func (m *CategoryMutation) DeletedAt() (r time.Time, exists bool) {
  6150. v := m.deleted_at
  6151. if v == nil {
  6152. return
  6153. }
  6154. return *v, true
  6155. }
  6156. // OldDeletedAt returns the old "deleted_at" field's value of the Category entity.
  6157. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  6158. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6159. func (m *CategoryMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  6160. if !m.op.Is(OpUpdateOne) {
  6161. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  6162. }
  6163. if m.id == nil || m.oldValue == nil {
  6164. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  6165. }
  6166. oldValue, err := m.oldValue(ctx)
  6167. if err != nil {
  6168. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  6169. }
  6170. return oldValue.DeletedAt, nil
  6171. }
  6172. // ClearDeletedAt clears the value of the "deleted_at" field.
  6173. func (m *CategoryMutation) ClearDeletedAt() {
  6174. m.deleted_at = nil
  6175. m.clearedFields[category.FieldDeletedAt] = struct{}{}
  6176. }
  6177. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  6178. func (m *CategoryMutation) DeletedAtCleared() bool {
  6179. _, ok := m.clearedFields[category.FieldDeletedAt]
  6180. return ok
  6181. }
  6182. // ResetDeletedAt resets all changes to the "deleted_at" field.
  6183. func (m *CategoryMutation) ResetDeletedAt() {
  6184. m.deleted_at = nil
  6185. delete(m.clearedFields, category.FieldDeletedAt)
  6186. }
  6187. // SetName sets the "name" field.
  6188. func (m *CategoryMutation) SetName(s string) {
  6189. m.name = &s
  6190. }
  6191. // Name returns the value of the "name" field in the mutation.
  6192. func (m *CategoryMutation) Name() (r string, exists bool) {
  6193. v := m.name
  6194. if v == nil {
  6195. return
  6196. }
  6197. return *v, true
  6198. }
  6199. // OldName returns the old "name" field's value of the Category entity.
  6200. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  6201. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6202. func (m *CategoryMutation) OldName(ctx context.Context) (v string, err error) {
  6203. if !m.op.Is(OpUpdateOne) {
  6204. return v, errors.New("OldName is only allowed on UpdateOne operations")
  6205. }
  6206. if m.id == nil || m.oldValue == nil {
  6207. return v, errors.New("OldName requires an ID field in the mutation")
  6208. }
  6209. oldValue, err := m.oldValue(ctx)
  6210. if err != nil {
  6211. return v, fmt.Errorf("querying old value for OldName: %w", err)
  6212. }
  6213. return oldValue.Name, nil
  6214. }
  6215. // ResetName resets all changes to the "name" field.
  6216. func (m *CategoryMutation) ResetName() {
  6217. m.name = nil
  6218. }
  6219. // SetOrganizationID sets the "organization_id" field.
  6220. func (m *CategoryMutation) SetOrganizationID(u uint64) {
  6221. m.organization_id = &u
  6222. m.addorganization_id = nil
  6223. }
  6224. // OrganizationID returns the value of the "organization_id" field in the mutation.
  6225. func (m *CategoryMutation) OrganizationID() (r uint64, exists bool) {
  6226. v := m.organization_id
  6227. if v == nil {
  6228. return
  6229. }
  6230. return *v, true
  6231. }
  6232. // OldOrganizationID returns the old "organization_id" field's value of the Category entity.
  6233. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  6234. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6235. func (m *CategoryMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  6236. if !m.op.Is(OpUpdateOne) {
  6237. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  6238. }
  6239. if m.id == nil || m.oldValue == nil {
  6240. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  6241. }
  6242. oldValue, err := m.oldValue(ctx)
  6243. if err != nil {
  6244. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  6245. }
  6246. return oldValue.OrganizationID, nil
  6247. }
  6248. // AddOrganizationID adds u to the "organization_id" field.
  6249. func (m *CategoryMutation) AddOrganizationID(u int64) {
  6250. if m.addorganization_id != nil {
  6251. *m.addorganization_id += u
  6252. } else {
  6253. m.addorganization_id = &u
  6254. }
  6255. }
  6256. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  6257. func (m *CategoryMutation) AddedOrganizationID() (r int64, exists bool) {
  6258. v := m.addorganization_id
  6259. if v == nil {
  6260. return
  6261. }
  6262. return *v, true
  6263. }
  6264. // ResetOrganizationID resets all changes to the "organization_id" field.
  6265. func (m *CategoryMutation) ResetOrganizationID() {
  6266. m.organization_id = nil
  6267. m.addorganization_id = nil
  6268. }
  6269. // Where appends a list predicates to the CategoryMutation builder.
  6270. func (m *CategoryMutation) Where(ps ...predicate.Category) {
  6271. m.predicates = append(m.predicates, ps...)
  6272. }
  6273. // WhereP appends storage-level predicates to the CategoryMutation builder. Using this method,
  6274. // users can use type-assertion to append predicates that do not depend on any generated package.
  6275. func (m *CategoryMutation) WhereP(ps ...func(*sql.Selector)) {
  6276. p := make([]predicate.Category, len(ps))
  6277. for i := range ps {
  6278. p[i] = ps[i]
  6279. }
  6280. m.Where(p...)
  6281. }
  6282. // Op returns the operation name.
  6283. func (m *CategoryMutation) Op() Op {
  6284. return m.op
  6285. }
  6286. // SetOp allows setting the mutation operation.
  6287. func (m *CategoryMutation) SetOp(op Op) {
  6288. m.op = op
  6289. }
  6290. // Type returns the node type of this mutation (Category).
  6291. func (m *CategoryMutation) Type() string {
  6292. return m.typ
  6293. }
  6294. // Fields returns all fields that were changed during this mutation. Note that in
  6295. // order to get all numeric fields that were incremented/decremented, call
  6296. // AddedFields().
  6297. func (m *CategoryMutation) Fields() []string {
  6298. fields := make([]string, 0, 5)
  6299. if m.created_at != nil {
  6300. fields = append(fields, category.FieldCreatedAt)
  6301. }
  6302. if m.updated_at != nil {
  6303. fields = append(fields, category.FieldUpdatedAt)
  6304. }
  6305. if m.deleted_at != nil {
  6306. fields = append(fields, category.FieldDeletedAt)
  6307. }
  6308. if m.name != nil {
  6309. fields = append(fields, category.FieldName)
  6310. }
  6311. if m.organization_id != nil {
  6312. fields = append(fields, category.FieldOrganizationID)
  6313. }
  6314. return fields
  6315. }
  6316. // Field returns the value of a field with the given name. The second boolean
  6317. // return value indicates that this field was not set, or was not defined in the
  6318. // schema.
  6319. func (m *CategoryMutation) Field(name string) (ent.Value, bool) {
  6320. switch name {
  6321. case category.FieldCreatedAt:
  6322. return m.CreatedAt()
  6323. case category.FieldUpdatedAt:
  6324. return m.UpdatedAt()
  6325. case category.FieldDeletedAt:
  6326. return m.DeletedAt()
  6327. case category.FieldName:
  6328. return m.Name()
  6329. case category.FieldOrganizationID:
  6330. return m.OrganizationID()
  6331. }
  6332. return nil, false
  6333. }
  6334. // OldField returns the old value of the field from the database. An error is
  6335. // returned if the mutation operation is not UpdateOne, or the query to the
  6336. // database failed.
  6337. func (m *CategoryMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  6338. switch name {
  6339. case category.FieldCreatedAt:
  6340. return m.OldCreatedAt(ctx)
  6341. case category.FieldUpdatedAt:
  6342. return m.OldUpdatedAt(ctx)
  6343. case category.FieldDeletedAt:
  6344. return m.OldDeletedAt(ctx)
  6345. case category.FieldName:
  6346. return m.OldName(ctx)
  6347. case category.FieldOrganizationID:
  6348. return m.OldOrganizationID(ctx)
  6349. }
  6350. return nil, fmt.Errorf("unknown Category field %s", name)
  6351. }
  6352. // SetField sets the value of a field with the given name. It returns an error if
  6353. // the field is not defined in the schema, or if the type mismatched the field
  6354. // type.
  6355. func (m *CategoryMutation) SetField(name string, value ent.Value) error {
  6356. switch name {
  6357. case category.FieldCreatedAt:
  6358. v, ok := value.(time.Time)
  6359. if !ok {
  6360. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6361. }
  6362. m.SetCreatedAt(v)
  6363. return nil
  6364. case category.FieldUpdatedAt:
  6365. v, ok := value.(time.Time)
  6366. if !ok {
  6367. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6368. }
  6369. m.SetUpdatedAt(v)
  6370. return nil
  6371. case category.FieldDeletedAt:
  6372. v, ok := value.(time.Time)
  6373. if !ok {
  6374. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6375. }
  6376. m.SetDeletedAt(v)
  6377. return nil
  6378. case category.FieldName:
  6379. v, ok := value.(string)
  6380. if !ok {
  6381. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6382. }
  6383. m.SetName(v)
  6384. return nil
  6385. case category.FieldOrganizationID:
  6386. v, ok := value.(uint64)
  6387. if !ok {
  6388. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6389. }
  6390. m.SetOrganizationID(v)
  6391. return nil
  6392. }
  6393. return fmt.Errorf("unknown Category field %s", name)
  6394. }
  6395. // AddedFields returns all numeric fields that were incremented/decremented during
  6396. // this mutation.
  6397. func (m *CategoryMutation) AddedFields() []string {
  6398. var fields []string
  6399. if m.addorganization_id != nil {
  6400. fields = append(fields, category.FieldOrganizationID)
  6401. }
  6402. return fields
  6403. }
  6404. // AddedField returns the numeric value that was incremented/decremented on a field
  6405. // with the given name. The second boolean return value indicates that this field
  6406. // was not set, or was not defined in the schema.
  6407. func (m *CategoryMutation) AddedField(name string) (ent.Value, bool) {
  6408. switch name {
  6409. case category.FieldOrganizationID:
  6410. return m.AddedOrganizationID()
  6411. }
  6412. return nil, false
  6413. }
  6414. // AddField adds the value to the field with the given name. It returns an error if
  6415. // the field is not defined in the schema, or if the type mismatched the field
  6416. // type.
  6417. func (m *CategoryMutation) AddField(name string, value ent.Value) error {
  6418. switch name {
  6419. case category.FieldOrganizationID:
  6420. v, ok := value.(int64)
  6421. if !ok {
  6422. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6423. }
  6424. m.AddOrganizationID(v)
  6425. return nil
  6426. }
  6427. return fmt.Errorf("unknown Category numeric field %s", name)
  6428. }
  6429. // ClearedFields returns all nullable fields that were cleared during this
  6430. // mutation.
  6431. func (m *CategoryMutation) ClearedFields() []string {
  6432. var fields []string
  6433. if m.FieldCleared(category.FieldDeletedAt) {
  6434. fields = append(fields, category.FieldDeletedAt)
  6435. }
  6436. return fields
  6437. }
  6438. // FieldCleared returns a boolean indicating if a field with the given name was
  6439. // cleared in this mutation.
  6440. func (m *CategoryMutation) FieldCleared(name string) bool {
  6441. _, ok := m.clearedFields[name]
  6442. return ok
  6443. }
  6444. // ClearField clears the value of the field with the given name. It returns an
  6445. // error if the field is not defined in the schema.
  6446. func (m *CategoryMutation) ClearField(name string) error {
  6447. switch name {
  6448. case category.FieldDeletedAt:
  6449. m.ClearDeletedAt()
  6450. return nil
  6451. }
  6452. return fmt.Errorf("unknown Category nullable field %s", name)
  6453. }
  6454. // ResetField resets all changes in the mutation for the field with the given name.
  6455. // It returns an error if the field is not defined in the schema.
  6456. func (m *CategoryMutation) ResetField(name string) error {
  6457. switch name {
  6458. case category.FieldCreatedAt:
  6459. m.ResetCreatedAt()
  6460. return nil
  6461. case category.FieldUpdatedAt:
  6462. m.ResetUpdatedAt()
  6463. return nil
  6464. case category.FieldDeletedAt:
  6465. m.ResetDeletedAt()
  6466. return nil
  6467. case category.FieldName:
  6468. m.ResetName()
  6469. return nil
  6470. case category.FieldOrganizationID:
  6471. m.ResetOrganizationID()
  6472. return nil
  6473. }
  6474. return fmt.Errorf("unknown Category field %s", name)
  6475. }
  6476. // AddedEdges returns all edge names that were set/added in this mutation.
  6477. func (m *CategoryMutation) AddedEdges() []string {
  6478. edges := make([]string, 0, 0)
  6479. return edges
  6480. }
  6481. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  6482. // name in this mutation.
  6483. func (m *CategoryMutation) AddedIDs(name string) []ent.Value {
  6484. return nil
  6485. }
  6486. // RemovedEdges returns all edge names that were removed in this mutation.
  6487. func (m *CategoryMutation) RemovedEdges() []string {
  6488. edges := make([]string, 0, 0)
  6489. return edges
  6490. }
  6491. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  6492. // the given name in this mutation.
  6493. func (m *CategoryMutation) RemovedIDs(name string) []ent.Value {
  6494. return nil
  6495. }
  6496. // ClearedEdges returns all edge names that were cleared in this mutation.
  6497. func (m *CategoryMutation) ClearedEdges() []string {
  6498. edges := make([]string, 0, 0)
  6499. return edges
  6500. }
  6501. // EdgeCleared returns a boolean which indicates if the edge with the given name
  6502. // was cleared in this mutation.
  6503. func (m *CategoryMutation) EdgeCleared(name string) bool {
  6504. return false
  6505. }
  6506. // ClearEdge clears the value of the edge with the given name. It returns an error
  6507. // if that edge is not defined in the schema.
  6508. func (m *CategoryMutation) ClearEdge(name string) error {
  6509. return fmt.Errorf("unknown Category unique edge %s", name)
  6510. }
  6511. // ResetEdge resets all changes to the edge with the given name in this mutation.
  6512. // It returns an error if the edge is not defined in the schema.
  6513. func (m *CategoryMutation) ResetEdge(name string) error {
  6514. return fmt.Errorf("unknown Category edge %s", name)
  6515. }
  6516. // ChatRecordsMutation represents an operation that mutates the ChatRecords nodes in the graph.
  6517. type ChatRecordsMutation struct {
  6518. config
  6519. op Op
  6520. typ string
  6521. id *uint64
  6522. created_at *time.Time
  6523. updated_at *time.Time
  6524. deleted_at *time.Time
  6525. content *string
  6526. content_type *uint8
  6527. addcontent_type *int8
  6528. session_id *uint64
  6529. addsession_id *int64
  6530. user_id *uint64
  6531. adduser_id *int64
  6532. bot_id *uint64
  6533. addbot_id *int64
  6534. bot_type *uint8
  6535. addbot_type *int8
  6536. clearedFields map[string]struct{}
  6537. done bool
  6538. oldValue func(context.Context) (*ChatRecords, error)
  6539. predicates []predicate.ChatRecords
  6540. }
  6541. var _ ent.Mutation = (*ChatRecordsMutation)(nil)
  6542. // chatrecordsOption allows management of the mutation configuration using functional options.
  6543. type chatrecordsOption func(*ChatRecordsMutation)
  6544. // newChatRecordsMutation creates new mutation for the ChatRecords entity.
  6545. func newChatRecordsMutation(c config, op Op, opts ...chatrecordsOption) *ChatRecordsMutation {
  6546. m := &ChatRecordsMutation{
  6547. config: c,
  6548. op: op,
  6549. typ: TypeChatRecords,
  6550. clearedFields: make(map[string]struct{}),
  6551. }
  6552. for _, opt := range opts {
  6553. opt(m)
  6554. }
  6555. return m
  6556. }
  6557. // withChatRecordsID sets the ID field of the mutation.
  6558. func withChatRecordsID(id uint64) chatrecordsOption {
  6559. return func(m *ChatRecordsMutation) {
  6560. var (
  6561. err error
  6562. once sync.Once
  6563. value *ChatRecords
  6564. )
  6565. m.oldValue = func(ctx context.Context) (*ChatRecords, error) {
  6566. once.Do(func() {
  6567. if m.done {
  6568. err = errors.New("querying old values post mutation is not allowed")
  6569. } else {
  6570. value, err = m.Client().ChatRecords.Get(ctx, id)
  6571. }
  6572. })
  6573. return value, err
  6574. }
  6575. m.id = &id
  6576. }
  6577. }
  6578. // withChatRecords sets the old ChatRecords of the mutation.
  6579. func withChatRecords(node *ChatRecords) chatrecordsOption {
  6580. return func(m *ChatRecordsMutation) {
  6581. m.oldValue = func(context.Context) (*ChatRecords, error) {
  6582. return node, nil
  6583. }
  6584. m.id = &node.ID
  6585. }
  6586. }
  6587. // Client returns a new `ent.Client` from the mutation. If the mutation was
  6588. // executed in a transaction (ent.Tx), a transactional client is returned.
  6589. func (m ChatRecordsMutation) Client() *Client {
  6590. client := &Client{config: m.config}
  6591. client.init()
  6592. return client
  6593. }
  6594. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  6595. // it returns an error otherwise.
  6596. func (m ChatRecordsMutation) Tx() (*Tx, error) {
  6597. if _, ok := m.driver.(*txDriver); !ok {
  6598. return nil, errors.New("ent: mutation is not running in a transaction")
  6599. }
  6600. tx := &Tx{config: m.config}
  6601. tx.init()
  6602. return tx, nil
  6603. }
  6604. // SetID sets the value of the id field. Note that this
  6605. // operation is only accepted on creation of ChatRecords entities.
  6606. func (m *ChatRecordsMutation) SetID(id uint64) {
  6607. m.id = &id
  6608. }
  6609. // ID returns the ID value in the mutation. Note that the ID is only available
  6610. // if it was provided to the builder or after it was returned from the database.
  6611. func (m *ChatRecordsMutation) ID() (id uint64, exists bool) {
  6612. if m.id == nil {
  6613. return
  6614. }
  6615. return *m.id, true
  6616. }
  6617. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  6618. // That means, if the mutation is applied within a transaction with an isolation level such
  6619. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  6620. // or updated by the mutation.
  6621. func (m *ChatRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  6622. switch {
  6623. case m.op.Is(OpUpdateOne | OpDeleteOne):
  6624. id, exists := m.ID()
  6625. if exists {
  6626. return []uint64{id}, nil
  6627. }
  6628. fallthrough
  6629. case m.op.Is(OpUpdate | OpDelete):
  6630. return m.Client().ChatRecords.Query().Where(m.predicates...).IDs(ctx)
  6631. default:
  6632. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  6633. }
  6634. }
  6635. // SetCreatedAt sets the "created_at" field.
  6636. func (m *ChatRecordsMutation) SetCreatedAt(t time.Time) {
  6637. m.created_at = &t
  6638. }
  6639. // CreatedAt returns the value of the "created_at" field in the mutation.
  6640. func (m *ChatRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  6641. v := m.created_at
  6642. if v == nil {
  6643. return
  6644. }
  6645. return *v, true
  6646. }
  6647. // OldCreatedAt returns the old "created_at" field's value of the ChatRecords entity.
  6648. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6649. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6650. func (m *ChatRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  6651. if !m.op.Is(OpUpdateOne) {
  6652. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  6653. }
  6654. if m.id == nil || m.oldValue == nil {
  6655. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  6656. }
  6657. oldValue, err := m.oldValue(ctx)
  6658. if err != nil {
  6659. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  6660. }
  6661. return oldValue.CreatedAt, nil
  6662. }
  6663. // ResetCreatedAt resets all changes to the "created_at" field.
  6664. func (m *ChatRecordsMutation) ResetCreatedAt() {
  6665. m.created_at = nil
  6666. }
  6667. // SetUpdatedAt sets the "updated_at" field.
  6668. func (m *ChatRecordsMutation) SetUpdatedAt(t time.Time) {
  6669. m.updated_at = &t
  6670. }
  6671. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  6672. func (m *ChatRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  6673. v := m.updated_at
  6674. if v == nil {
  6675. return
  6676. }
  6677. return *v, true
  6678. }
  6679. // OldUpdatedAt returns the old "updated_at" field's value of the ChatRecords entity.
  6680. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6681. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6682. func (m *ChatRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  6683. if !m.op.Is(OpUpdateOne) {
  6684. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  6685. }
  6686. if m.id == nil || m.oldValue == nil {
  6687. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  6688. }
  6689. oldValue, err := m.oldValue(ctx)
  6690. if err != nil {
  6691. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  6692. }
  6693. return oldValue.UpdatedAt, nil
  6694. }
  6695. // ResetUpdatedAt resets all changes to the "updated_at" field.
  6696. func (m *ChatRecordsMutation) ResetUpdatedAt() {
  6697. m.updated_at = nil
  6698. }
  6699. // SetDeletedAt sets the "deleted_at" field.
  6700. func (m *ChatRecordsMutation) SetDeletedAt(t time.Time) {
  6701. m.deleted_at = &t
  6702. }
  6703. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  6704. func (m *ChatRecordsMutation) DeletedAt() (r time.Time, exists bool) {
  6705. v := m.deleted_at
  6706. if v == nil {
  6707. return
  6708. }
  6709. return *v, true
  6710. }
  6711. // OldDeletedAt returns the old "deleted_at" field's value of the ChatRecords entity.
  6712. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6713. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6714. func (m *ChatRecordsMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  6715. if !m.op.Is(OpUpdateOne) {
  6716. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  6717. }
  6718. if m.id == nil || m.oldValue == nil {
  6719. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  6720. }
  6721. oldValue, err := m.oldValue(ctx)
  6722. if err != nil {
  6723. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  6724. }
  6725. return oldValue.DeletedAt, nil
  6726. }
  6727. // ClearDeletedAt clears the value of the "deleted_at" field.
  6728. func (m *ChatRecordsMutation) ClearDeletedAt() {
  6729. m.deleted_at = nil
  6730. m.clearedFields[chatrecords.FieldDeletedAt] = struct{}{}
  6731. }
  6732. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  6733. func (m *ChatRecordsMutation) DeletedAtCleared() bool {
  6734. _, ok := m.clearedFields[chatrecords.FieldDeletedAt]
  6735. return ok
  6736. }
  6737. // ResetDeletedAt resets all changes to the "deleted_at" field.
  6738. func (m *ChatRecordsMutation) ResetDeletedAt() {
  6739. m.deleted_at = nil
  6740. delete(m.clearedFields, chatrecords.FieldDeletedAt)
  6741. }
  6742. // SetContent sets the "content" field.
  6743. func (m *ChatRecordsMutation) SetContent(s string) {
  6744. m.content = &s
  6745. }
  6746. // Content returns the value of the "content" field in the mutation.
  6747. func (m *ChatRecordsMutation) Content() (r string, exists bool) {
  6748. v := m.content
  6749. if v == nil {
  6750. return
  6751. }
  6752. return *v, true
  6753. }
  6754. // OldContent returns the old "content" field's value of the ChatRecords entity.
  6755. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6756. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6757. func (m *ChatRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  6758. if !m.op.Is(OpUpdateOne) {
  6759. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  6760. }
  6761. if m.id == nil || m.oldValue == nil {
  6762. return v, errors.New("OldContent requires an ID field in the mutation")
  6763. }
  6764. oldValue, err := m.oldValue(ctx)
  6765. if err != nil {
  6766. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  6767. }
  6768. return oldValue.Content, nil
  6769. }
  6770. // ResetContent resets all changes to the "content" field.
  6771. func (m *ChatRecordsMutation) ResetContent() {
  6772. m.content = nil
  6773. }
  6774. // SetContentType sets the "content_type" field.
  6775. func (m *ChatRecordsMutation) SetContentType(u uint8) {
  6776. m.content_type = &u
  6777. m.addcontent_type = nil
  6778. }
  6779. // ContentType returns the value of the "content_type" field in the mutation.
  6780. func (m *ChatRecordsMutation) ContentType() (r uint8, exists bool) {
  6781. v := m.content_type
  6782. if v == nil {
  6783. return
  6784. }
  6785. return *v, true
  6786. }
  6787. // OldContentType returns the old "content_type" field's value of the ChatRecords entity.
  6788. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6789. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6790. func (m *ChatRecordsMutation) OldContentType(ctx context.Context) (v uint8, err error) {
  6791. if !m.op.Is(OpUpdateOne) {
  6792. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  6793. }
  6794. if m.id == nil || m.oldValue == nil {
  6795. return v, errors.New("OldContentType requires an ID field in the mutation")
  6796. }
  6797. oldValue, err := m.oldValue(ctx)
  6798. if err != nil {
  6799. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  6800. }
  6801. return oldValue.ContentType, nil
  6802. }
  6803. // AddContentType adds u to the "content_type" field.
  6804. func (m *ChatRecordsMutation) AddContentType(u int8) {
  6805. if m.addcontent_type != nil {
  6806. *m.addcontent_type += u
  6807. } else {
  6808. m.addcontent_type = &u
  6809. }
  6810. }
  6811. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  6812. func (m *ChatRecordsMutation) AddedContentType() (r int8, exists bool) {
  6813. v := m.addcontent_type
  6814. if v == nil {
  6815. return
  6816. }
  6817. return *v, true
  6818. }
  6819. // ResetContentType resets all changes to the "content_type" field.
  6820. func (m *ChatRecordsMutation) ResetContentType() {
  6821. m.content_type = nil
  6822. m.addcontent_type = nil
  6823. }
  6824. // SetSessionID sets the "session_id" field.
  6825. func (m *ChatRecordsMutation) SetSessionID(u uint64) {
  6826. m.session_id = &u
  6827. m.addsession_id = nil
  6828. }
  6829. // SessionID returns the value of the "session_id" field in the mutation.
  6830. func (m *ChatRecordsMutation) SessionID() (r uint64, exists bool) {
  6831. v := m.session_id
  6832. if v == nil {
  6833. return
  6834. }
  6835. return *v, true
  6836. }
  6837. // OldSessionID returns the old "session_id" field's value of the ChatRecords entity.
  6838. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6839. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6840. func (m *ChatRecordsMutation) OldSessionID(ctx context.Context) (v uint64, err error) {
  6841. if !m.op.Is(OpUpdateOne) {
  6842. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  6843. }
  6844. if m.id == nil || m.oldValue == nil {
  6845. return v, errors.New("OldSessionID requires an ID field in the mutation")
  6846. }
  6847. oldValue, err := m.oldValue(ctx)
  6848. if err != nil {
  6849. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  6850. }
  6851. return oldValue.SessionID, nil
  6852. }
  6853. // AddSessionID adds u to the "session_id" field.
  6854. func (m *ChatRecordsMutation) AddSessionID(u int64) {
  6855. if m.addsession_id != nil {
  6856. *m.addsession_id += u
  6857. } else {
  6858. m.addsession_id = &u
  6859. }
  6860. }
  6861. // AddedSessionID returns the value that was added to the "session_id" field in this mutation.
  6862. func (m *ChatRecordsMutation) AddedSessionID() (r int64, exists bool) {
  6863. v := m.addsession_id
  6864. if v == nil {
  6865. return
  6866. }
  6867. return *v, true
  6868. }
  6869. // ResetSessionID resets all changes to the "session_id" field.
  6870. func (m *ChatRecordsMutation) ResetSessionID() {
  6871. m.session_id = nil
  6872. m.addsession_id = nil
  6873. }
  6874. // SetUserID sets the "user_id" field.
  6875. func (m *ChatRecordsMutation) SetUserID(u uint64) {
  6876. m.user_id = &u
  6877. m.adduser_id = nil
  6878. }
  6879. // UserID returns the value of the "user_id" field in the mutation.
  6880. func (m *ChatRecordsMutation) UserID() (r uint64, exists bool) {
  6881. v := m.user_id
  6882. if v == nil {
  6883. return
  6884. }
  6885. return *v, true
  6886. }
  6887. // OldUserID returns the old "user_id" field's value of the ChatRecords entity.
  6888. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6889. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6890. func (m *ChatRecordsMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  6891. if !m.op.Is(OpUpdateOne) {
  6892. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  6893. }
  6894. if m.id == nil || m.oldValue == nil {
  6895. return v, errors.New("OldUserID requires an ID field in the mutation")
  6896. }
  6897. oldValue, err := m.oldValue(ctx)
  6898. if err != nil {
  6899. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  6900. }
  6901. return oldValue.UserID, nil
  6902. }
  6903. // AddUserID adds u to the "user_id" field.
  6904. func (m *ChatRecordsMutation) AddUserID(u int64) {
  6905. if m.adduser_id != nil {
  6906. *m.adduser_id += u
  6907. } else {
  6908. m.adduser_id = &u
  6909. }
  6910. }
  6911. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  6912. func (m *ChatRecordsMutation) AddedUserID() (r int64, exists bool) {
  6913. v := m.adduser_id
  6914. if v == nil {
  6915. return
  6916. }
  6917. return *v, true
  6918. }
  6919. // ResetUserID resets all changes to the "user_id" field.
  6920. func (m *ChatRecordsMutation) ResetUserID() {
  6921. m.user_id = nil
  6922. m.adduser_id = nil
  6923. }
  6924. // SetBotID sets the "bot_id" field.
  6925. func (m *ChatRecordsMutation) SetBotID(u uint64) {
  6926. m.bot_id = &u
  6927. m.addbot_id = nil
  6928. }
  6929. // BotID returns the value of the "bot_id" field in the mutation.
  6930. func (m *ChatRecordsMutation) BotID() (r uint64, exists bool) {
  6931. v := m.bot_id
  6932. if v == nil {
  6933. return
  6934. }
  6935. return *v, true
  6936. }
  6937. // OldBotID returns the old "bot_id" field's value of the ChatRecords entity.
  6938. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6939. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6940. func (m *ChatRecordsMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  6941. if !m.op.Is(OpUpdateOne) {
  6942. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  6943. }
  6944. if m.id == nil || m.oldValue == nil {
  6945. return v, errors.New("OldBotID requires an ID field in the mutation")
  6946. }
  6947. oldValue, err := m.oldValue(ctx)
  6948. if err != nil {
  6949. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  6950. }
  6951. return oldValue.BotID, nil
  6952. }
  6953. // AddBotID adds u to the "bot_id" field.
  6954. func (m *ChatRecordsMutation) AddBotID(u int64) {
  6955. if m.addbot_id != nil {
  6956. *m.addbot_id += u
  6957. } else {
  6958. m.addbot_id = &u
  6959. }
  6960. }
  6961. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  6962. func (m *ChatRecordsMutation) AddedBotID() (r int64, exists bool) {
  6963. v := m.addbot_id
  6964. if v == nil {
  6965. return
  6966. }
  6967. return *v, true
  6968. }
  6969. // ResetBotID resets all changes to the "bot_id" field.
  6970. func (m *ChatRecordsMutation) ResetBotID() {
  6971. m.bot_id = nil
  6972. m.addbot_id = nil
  6973. }
  6974. // SetBotType sets the "bot_type" field.
  6975. func (m *ChatRecordsMutation) SetBotType(u uint8) {
  6976. m.bot_type = &u
  6977. m.addbot_type = nil
  6978. }
  6979. // BotType returns the value of the "bot_type" field in the mutation.
  6980. func (m *ChatRecordsMutation) BotType() (r uint8, exists bool) {
  6981. v := m.bot_type
  6982. if v == nil {
  6983. return
  6984. }
  6985. return *v, true
  6986. }
  6987. // OldBotType returns the old "bot_type" field's value of the ChatRecords entity.
  6988. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6989. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6990. func (m *ChatRecordsMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  6991. if !m.op.Is(OpUpdateOne) {
  6992. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  6993. }
  6994. if m.id == nil || m.oldValue == nil {
  6995. return v, errors.New("OldBotType requires an ID field in the mutation")
  6996. }
  6997. oldValue, err := m.oldValue(ctx)
  6998. if err != nil {
  6999. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  7000. }
  7001. return oldValue.BotType, nil
  7002. }
  7003. // AddBotType adds u to the "bot_type" field.
  7004. func (m *ChatRecordsMutation) AddBotType(u int8) {
  7005. if m.addbot_type != nil {
  7006. *m.addbot_type += u
  7007. } else {
  7008. m.addbot_type = &u
  7009. }
  7010. }
  7011. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  7012. func (m *ChatRecordsMutation) AddedBotType() (r int8, exists bool) {
  7013. v := m.addbot_type
  7014. if v == nil {
  7015. return
  7016. }
  7017. return *v, true
  7018. }
  7019. // ResetBotType resets all changes to the "bot_type" field.
  7020. func (m *ChatRecordsMutation) ResetBotType() {
  7021. m.bot_type = nil
  7022. m.addbot_type = nil
  7023. }
  7024. // Where appends a list predicates to the ChatRecordsMutation builder.
  7025. func (m *ChatRecordsMutation) Where(ps ...predicate.ChatRecords) {
  7026. m.predicates = append(m.predicates, ps...)
  7027. }
  7028. // WhereP appends storage-level predicates to the ChatRecordsMutation builder. Using this method,
  7029. // users can use type-assertion to append predicates that do not depend on any generated package.
  7030. func (m *ChatRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  7031. p := make([]predicate.ChatRecords, len(ps))
  7032. for i := range ps {
  7033. p[i] = ps[i]
  7034. }
  7035. m.Where(p...)
  7036. }
  7037. // Op returns the operation name.
  7038. func (m *ChatRecordsMutation) Op() Op {
  7039. return m.op
  7040. }
  7041. // SetOp allows setting the mutation operation.
  7042. func (m *ChatRecordsMutation) SetOp(op Op) {
  7043. m.op = op
  7044. }
  7045. // Type returns the node type of this mutation (ChatRecords).
  7046. func (m *ChatRecordsMutation) Type() string {
  7047. return m.typ
  7048. }
  7049. // Fields returns all fields that were changed during this mutation. Note that in
  7050. // order to get all numeric fields that were incremented/decremented, call
  7051. // AddedFields().
  7052. func (m *ChatRecordsMutation) Fields() []string {
  7053. fields := make([]string, 0, 9)
  7054. if m.created_at != nil {
  7055. fields = append(fields, chatrecords.FieldCreatedAt)
  7056. }
  7057. if m.updated_at != nil {
  7058. fields = append(fields, chatrecords.FieldUpdatedAt)
  7059. }
  7060. if m.deleted_at != nil {
  7061. fields = append(fields, chatrecords.FieldDeletedAt)
  7062. }
  7063. if m.content != nil {
  7064. fields = append(fields, chatrecords.FieldContent)
  7065. }
  7066. if m.content_type != nil {
  7067. fields = append(fields, chatrecords.FieldContentType)
  7068. }
  7069. if m.session_id != nil {
  7070. fields = append(fields, chatrecords.FieldSessionID)
  7071. }
  7072. if m.user_id != nil {
  7073. fields = append(fields, chatrecords.FieldUserID)
  7074. }
  7075. if m.bot_id != nil {
  7076. fields = append(fields, chatrecords.FieldBotID)
  7077. }
  7078. if m.bot_type != nil {
  7079. fields = append(fields, chatrecords.FieldBotType)
  7080. }
  7081. return fields
  7082. }
  7083. // Field returns the value of a field with the given name. The second boolean
  7084. // return value indicates that this field was not set, or was not defined in the
  7085. // schema.
  7086. func (m *ChatRecordsMutation) Field(name string) (ent.Value, bool) {
  7087. switch name {
  7088. case chatrecords.FieldCreatedAt:
  7089. return m.CreatedAt()
  7090. case chatrecords.FieldUpdatedAt:
  7091. return m.UpdatedAt()
  7092. case chatrecords.FieldDeletedAt:
  7093. return m.DeletedAt()
  7094. case chatrecords.FieldContent:
  7095. return m.Content()
  7096. case chatrecords.FieldContentType:
  7097. return m.ContentType()
  7098. case chatrecords.FieldSessionID:
  7099. return m.SessionID()
  7100. case chatrecords.FieldUserID:
  7101. return m.UserID()
  7102. case chatrecords.FieldBotID:
  7103. return m.BotID()
  7104. case chatrecords.FieldBotType:
  7105. return m.BotType()
  7106. }
  7107. return nil, false
  7108. }
  7109. // OldField returns the old value of the field from the database. An error is
  7110. // returned if the mutation operation is not UpdateOne, or the query to the
  7111. // database failed.
  7112. func (m *ChatRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  7113. switch name {
  7114. case chatrecords.FieldCreatedAt:
  7115. return m.OldCreatedAt(ctx)
  7116. case chatrecords.FieldUpdatedAt:
  7117. return m.OldUpdatedAt(ctx)
  7118. case chatrecords.FieldDeletedAt:
  7119. return m.OldDeletedAt(ctx)
  7120. case chatrecords.FieldContent:
  7121. return m.OldContent(ctx)
  7122. case chatrecords.FieldContentType:
  7123. return m.OldContentType(ctx)
  7124. case chatrecords.FieldSessionID:
  7125. return m.OldSessionID(ctx)
  7126. case chatrecords.FieldUserID:
  7127. return m.OldUserID(ctx)
  7128. case chatrecords.FieldBotID:
  7129. return m.OldBotID(ctx)
  7130. case chatrecords.FieldBotType:
  7131. return m.OldBotType(ctx)
  7132. }
  7133. return nil, fmt.Errorf("unknown ChatRecords field %s", name)
  7134. }
  7135. // SetField sets the value of a field with the given name. It returns an error if
  7136. // the field is not defined in the schema, or if the type mismatched the field
  7137. // type.
  7138. func (m *ChatRecordsMutation) SetField(name string, value ent.Value) error {
  7139. switch name {
  7140. case chatrecords.FieldCreatedAt:
  7141. v, ok := value.(time.Time)
  7142. if !ok {
  7143. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7144. }
  7145. m.SetCreatedAt(v)
  7146. return nil
  7147. case chatrecords.FieldUpdatedAt:
  7148. v, ok := value.(time.Time)
  7149. if !ok {
  7150. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7151. }
  7152. m.SetUpdatedAt(v)
  7153. return nil
  7154. case chatrecords.FieldDeletedAt:
  7155. v, ok := value.(time.Time)
  7156. if !ok {
  7157. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7158. }
  7159. m.SetDeletedAt(v)
  7160. return nil
  7161. case chatrecords.FieldContent:
  7162. v, ok := value.(string)
  7163. if !ok {
  7164. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7165. }
  7166. m.SetContent(v)
  7167. return nil
  7168. case chatrecords.FieldContentType:
  7169. v, ok := value.(uint8)
  7170. if !ok {
  7171. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7172. }
  7173. m.SetContentType(v)
  7174. return nil
  7175. case chatrecords.FieldSessionID:
  7176. v, ok := value.(uint64)
  7177. if !ok {
  7178. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7179. }
  7180. m.SetSessionID(v)
  7181. return nil
  7182. case chatrecords.FieldUserID:
  7183. v, ok := value.(uint64)
  7184. if !ok {
  7185. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7186. }
  7187. m.SetUserID(v)
  7188. return nil
  7189. case chatrecords.FieldBotID:
  7190. v, ok := value.(uint64)
  7191. if !ok {
  7192. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7193. }
  7194. m.SetBotID(v)
  7195. return nil
  7196. case chatrecords.FieldBotType:
  7197. v, ok := value.(uint8)
  7198. if !ok {
  7199. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7200. }
  7201. m.SetBotType(v)
  7202. return nil
  7203. }
  7204. return fmt.Errorf("unknown ChatRecords field %s", name)
  7205. }
  7206. // AddedFields returns all numeric fields that were incremented/decremented during
  7207. // this mutation.
  7208. func (m *ChatRecordsMutation) AddedFields() []string {
  7209. var fields []string
  7210. if m.addcontent_type != nil {
  7211. fields = append(fields, chatrecords.FieldContentType)
  7212. }
  7213. if m.addsession_id != nil {
  7214. fields = append(fields, chatrecords.FieldSessionID)
  7215. }
  7216. if m.adduser_id != nil {
  7217. fields = append(fields, chatrecords.FieldUserID)
  7218. }
  7219. if m.addbot_id != nil {
  7220. fields = append(fields, chatrecords.FieldBotID)
  7221. }
  7222. if m.addbot_type != nil {
  7223. fields = append(fields, chatrecords.FieldBotType)
  7224. }
  7225. return fields
  7226. }
  7227. // AddedField returns the numeric value that was incremented/decremented on a field
  7228. // with the given name. The second boolean return value indicates that this field
  7229. // was not set, or was not defined in the schema.
  7230. func (m *ChatRecordsMutation) AddedField(name string) (ent.Value, bool) {
  7231. switch name {
  7232. case chatrecords.FieldContentType:
  7233. return m.AddedContentType()
  7234. case chatrecords.FieldSessionID:
  7235. return m.AddedSessionID()
  7236. case chatrecords.FieldUserID:
  7237. return m.AddedUserID()
  7238. case chatrecords.FieldBotID:
  7239. return m.AddedBotID()
  7240. case chatrecords.FieldBotType:
  7241. return m.AddedBotType()
  7242. }
  7243. return nil, false
  7244. }
  7245. // AddField adds the value to the field with the given name. It returns an error if
  7246. // the field is not defined in the schema, or if the type mismatched the field
  7247. // type.
  7248. func (m *ChatRecordsMutation) AddField(name string, value ent.Value) error {
  7249. switch name {
  7250. case chatrecords.FieldContentType:
  7251. v, ok := value.(int8)
  7252. if !ok {
  7253. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7254. }
  7255. m.AddContentType(v)
  7256. return nil
  7257. case chatrecords.FieldSessionID:
  7258. v, ok := value.(int64)
  7259. if !ok {
  7260. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7261. }
  7262. m.AddSessionID(v)
  7263. return nil
  7264. case chatrecords.FieldUserID:
  7265. v, ok := value.(int64)
  7266. if !ok {
  7267. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7268. }
  7269. m.AddUserID(v)
  7270. return nil
  7271. case chatrecords.FieldBotID:
  7272. v, ok := value.(int64)
  7273. if !ok {
  7274. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7275. }
  7276. m.AddBotID(v)
  7277. return nil
  7278. case chatrecords.FieldBotType:
  7279. v, ok := value.(int8)
  7280. if !ok {
  7281. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7282. }
  7283. m.AddBotType(v)
  7284. return nil
  7285. }
  7286. return fmt.Errorf("unknown ChatRecords numeric field %s", name)
  7287. }
  7288. // ClearedFields returns all nullable fields that were cleared during this
  7289. // mutation.
  7290. func (m *ChatRecordsMutation) ClearedFields() []string {
  7291. var fields []string
  7292. if m.FieldCleared(chatrecords.FieldDeletedAt) {
  7293. fields = append(fields, chatrecords.FieldDeletedAt)
  7294. }
  7295. return fields
  7296. }
  7297. // FieldCleared returns a boolean indicating if a field with the given name was
  7298. // cleared in this mutation.
  7299. func (m *ChatRecordsMutation) FieldCleared(name string) bool {
  7300. _, ok := m.clearedFields[name]
  7301. return ok
  7302. }
  7303. // ClearField clears the value of the field with the given name. It returns an
  7304. // error if the field is not defined in the schema.
  7305. func (m *ChatRecordsMutation) ClearField(name string) error {
  7306. switch name {
  7307. case chatrecords.FieldDeletedAt:
  7308. m.ClearDeletedAt()
  7309. return nil
  7310. }
  7311. return fmt.Errorf("unknown ChatRecords nullable field %s", name)
  7312. }
  7313. // ResetField resets all changes in the mutation for the field with the given name.
  7314. // It returns an error if the field is not defined in the schema.
  7315. func (m *ChatRecordsMutation) ResetField(name string) error {
  7316. switch name {
  7317. case chatrecords.FieldCreatedAt:
  7318. m.ResetCreatedAt()
  7319. return nil
  7320. case chatrecords.FieldUpdatedAt:
  7321. m.ResetUpdatedAt()
  7322. return nil
  7323. case chatrecords.FieldDeletedAt:
  7324. m.ResetDeletedAt()
  7325. return nil
  7326. case chatrecords.FieldContent:
  7327. m.ResetContent()
  7328. return nil
  7329. case chatrecords.FieldContentType:
  7330. m.ResetContentType()
  7331. return nil
  7332. case chatrecords.FieldSessionID:
  7333. m.ResetSessionID()
  7334. return nil
  7335. case chatrecords.FieldUserID:
  7336. m.ResetUserID()
  7337. return nil
  7338. case chatrecords.FieldBotID:
  7339. m.ResetBotID()
  7340. return nil
  7341. case chatrecords.FieldBotType:
  7342. m.ResetBotType()
  7343. return nil
  7344. }
  7345. return fmt.Errorf("unknown ChatRecords field %s", name)
  7346. }
  7347. // AddedEdges returns all edge names that were set/added in this mutation.
  7348. func (m *ChatRecordsMutation) AddedEdges() []string {
  7349. edges := make([]string, 0, 0)
  7350. return edges
  7351. }
  7352. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  7353. // name in this mutation.
  7354. func (m *ChatRecordsMutation) AddedIDs(name string) []ent.Value {
  7355. return nil
  7356. }
  7357. // RemovedEdges returns all edge names that were removed in this mutation.
  7358. func (m *ChatRecordsMutation) RemovedEdges() []string {
  7359. edges := make([]string, 0, 0)
  7360. return edges
  7361. }
  7362. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  7363. // the given name in this mutation.
  7364. func (m *ChatRecordsMutation) RemovedIDs(name string) []ent.Value {
  7365. return nil
  7366. }
  7367. // ClearedEdges returns all edge names that were cleared in this mutation.
  7368. func (m *ChatRecordsMutation) ClearedEdges() []string {
  7369. edges := make([]string, 0, 0)
  7370. return edges
  7371. }
  7372. // EdgeCleared returns a boolean which indicates if the edge with the given name
  7373. // was cleared in this mutation.
  7374. func (m *ChatRecordsMutation) EdgeCleared(name string) bool {
  7375. return false
  7376. }
  7377. // ClearEdge clears the value of the edge with the given name. It returns an error
  7378. // if that edge is not defined in the schema.
  7379. func (m *ChatRecordsMutation) ClearEdge(name string) error {
  7380. return fmt.Errorf("unknown ChatRecords unique edge %s", name)
  7381. }
  7382. // ResetEdge resets all changes to the edge with the given name in this mutation.
  7383. // It returns an error if the edge is not defined in the schema.
  7384. func (m *ChatRecordsMutation) ResetEdge(name string) error {
  7385. return fmt.Errorf("unknown ChatRecords edge %s", name)
  7386. }
  7387. // ChatSessionMutation represents an operation that mutates the ChatSession nodes in the graph.
  7388. type ChatSessionMutation struct {
  7389. config
  7390. op Op
  7391. typ string
  7392. id *uint64
  7393. created_at *time.Time
  7394. updated_at *time.Time
  7395. deleted_at *time.Time
  7396. name *string
  7397. user_id *uint64
  7398. adduser_id *int64
  7399. bot_id *uint64
  7400. addbot_id *int64
  7401. bot_type *uint8
  7402. addbot_type *int8
  7403. clearedFields map[string]struct{}
  7404. done bool
  7405. oldValue func(context.Context) (*ChatSession, error)
  7406. predicates []predicate.ChatSession
  7407. }
  7408. var _ ent.Mutation = (*ChatSessionMutation)(nil)
  7409. // chatsessionOption allows management of the mutation configuration using functional options.
  7410. type chatsessionOption func(*ChatSessionMutation)
  7411. // newChatSessionMutation creates new mutation for the ChatSession entity.
  7412. func newChatSessionMutation(c config, op Op, opts ...chatsessionOption) *ChatSessionMutation {
  7413. m := &ChatSessionMutation{
  7414. config: c,
  7415. op: op,
  7416. typ: TypeChatSession,
  7417. clearedFields: make(map[string]struct{}),
  7418. }
  7419. for _, opt := range opts {
  7420. opt(m)
  7421. }
  7422. return m
  7423. }
  7424. // withChatSessionID sets the ID field of the mutation.
  7425. func withChatSessionID(id uint64) chatsessionOption {
  7426. return func(m *ChatSessionMutation) {
  7427. var (
  7428. err error
  7429. once sync.Once
  7430. value *ChatSession
  7431. )
  7432. m.oldValue = func(ctx context.Context) (*ChatSession, error) {
  7433. once.Do(func() {
  7434. if m.done {
  7435. err = errors.New("querying old values post mutation is not allowed")
  7436. } else {
  7437. value, err = m.Client().ChatSession.Get(ctx, id)
  7438. }
  7439. })
  7440. return value, err
  7441. }
  7442. m.id = &id
  7443. }
  7444. }
  7445. // withChatSession sets the old ChatSession of the mutation.
  7446. func withChatSession(node *ChatSession) chatsessionOption {
  7447. return func(m *ChatSessionMutation) {
  7448. m.oldValue = func(context.Context) (*ChatSession, error) {
  7449. return node, nil
  7450. }
  7451. m.id = &node.ID
  7452. }
  7453. }
  7454. // Client returns a new `ent.Client` from the mutation. If the mutation was
  7455. // executed in a transaction (ent.Tx), a transactional client is returned.
  7456. func (m ChatSessionMutation) Client() *Client {
  7457. client := &Client{config: m.config}
  7458. client.init()
  7459. return client
  7460. }
  7461. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  7462. // it returns an error otherwise.
  7463. func (m ChatSessionMutation) Tx() (*Tx, error) {
  7464. if _, ok := m.driver.(*txDriver); !ok {
  7465. return nil, errors.New("ent: mutation is not running in a transaction")
  7466. }
  7467. tx := &Tx{config: m.config}
  7468. tx.init()
  7469. return tx, nil
  7470. }
  7471. // SetID sets the value of the id field. Note that this
  7472. // operation is only accepted on creation of ChatSession entities.
  7473. func (m *ChatSessionMutation) SetID(id uint64) {
  7474. m.id = &id
  7475. }
  7476. // ID returns the ID value in the mutation. Note that the ID is only available
  7477. // if it was provided to the builder or after it was returned from the database.
  7478. func (m *ChatSessionMutation) ID() (id uint64, exists bool) {
  7479. if m.id == nil {
  7480. return
  7481. }
  7482. return *m.id, true
  7483. }
  7484. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  7485. // That means, if the mutation is applied within a transaction with an isolation level such
  7486. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  7487. // or updated by the mutation.
  7488. func (m *ChatSessionMutation) IDs(ctx context.Context) ([]uint64, error) {
  7489. switch {
  7490. case m.op.Is(OpUpdateOne | OpDeleteOne):
  7491. id, exists := m.ID()
  7492. if exists {
  7493. return []uint64{id}, nil
  7494. }
  7495. fallthrough
  7496. case m.op.Is(OpUpdate | OpDelete):
  7497. return m.Client().ChatSession.Query().Where(m.predicates...).IDs(ctx)
  7498. default:
  7499. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  7500. }
  7501. }
  7502. // SetCreatedAt sets the "created_at" field.
  7503. func (m *ChatSessionMutation) SetCreatedAt(t time.Time) {
  7504. m.created_at = &t
  7505. }
  7506. // CreatedAt returns the value of the "created_at" field in the mutation.
  7507. func (m *ChatSessionMutation) CreatedAt() (r time.Time, exists bool) {
  7508. v := m.created_at
  7509. if v == nil {
  7510. return
  7511. }
  7512. return *v, true
  7513. }
  7514. // OldCreatedAt returns the old "created_at" field's value of the ChatSession entity.
  7515. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7516. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7517. func (m *ChatSessionMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  7518. if !m.op.Is(OpUpdateOne) {
  7519. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  7520. }
  7521. if m.id == nil || m.oldValue == nil {
  7522. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  7523. }
  7524. oldValue, err := m.oldValue(ctx)
  7525. if err != nil {
  7526. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  7527. }
  7528. return oldValue.CreatedAt, nil
  7529. }
  7530. // ResetCreatedAt resets all changes to the "created_at" field.
  7531. func (m *ChatSessionMutation) ResetCreatedAt() {
  7532. m.created_at = nil
  7533. }
  7534. // SetUpdatedAt sets the "updated_at" field.
  7535. func (m *ChatSessionMutation) SetUpdatedAt(t time.Time) {
  7536. m.updated_at = &t
  7537. }
  7538. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  7539. func (m *ChatSessionMutation) UpdatedAt() (r time.Time, exists bool) {
  7540. v := m.updated_at
  7541. if v == nil {
  7542. return
  7543. }
  7544. return *v, true
  7545. }
  7546. // OldUpdatedAt returns the old "updated_at" field's value of the ChatSession entity.
  7547. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7548. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7549. func (m *ChatSessionMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  7550. if !m.op.Is(OpUpdateOne) {
  7551. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  7552. }
  7553. if m.id == nil || m.oldValue == nil {
  7554. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  7555. }
  7556. oldValue, err := m.oldValue(ctx)
  7557. if err != nil {
  7558. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  7559. }
  7560. return oldValue.UpdatedAt, nil
  7561. }
  7562. // ResetUpdatedAt resets all changes to the "updated_at" field.
  7563. func (m *ChatSessionMutation) ResetUpdatedAt() {
  7564. m.updated_at = nil
  7565. }
  7566. // SetDeletedAt sets the "deleted_at" field.
  7567. func (m *ChatSessionMutation) SetDeletedAt(t time.Time) {
  7568. m.deleted_at = &t
  7569. }
  7570. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  7571. func (m *ChatSessionMutation) DeletedAt() (r time.Time, exists bool) {
  7572. v := m.deleted_at
  7573. if v == nil {
  7574. return
  7575. }
  7576. return *v, true
  7577. }
  7578. // OldDeletedAt returns the old "deleted_at" field's value of the ChatSession entity.
  7579. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7580. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7581. func (m *ChatSessionMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  7582. if !m.op.Is(OpUpdateOne) {
  7583. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  7584. }
  7585. if m.id == nil || m.oldValue == nil {
  7586. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  7587. }
  7588. oldValue, err := m.oldValue(ctx)
  7589. if err != nil {
  7590. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  7591. }
  7592. return oldValue.DeletedAt, nil
  7593. }
  7594. // ClearDeletedAt clears the value of the "deleted_at" field.
  7595. func (m *ChatSessionMutation) ClearDeletedAt() {
  7596. m.deleted_at = nil
  7597. m.clearedFields[chatsession.FieldDeletedAt] = struct{}{}
  7598. }
  7599. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  7600. func (m *ChatSessionMutation) DeletedAtCleared() bool {
  7601. _, ok := m.clearedFields[chatsession.FieldDeletedAt]
  7602. return ok
  7603. }
  7604. // ResetDeletedAt resets all changes to the "deleted_at" field.
  7605. func (m *ChatSessionMutation) ResetDeletedAt() {
  7606. m.deleted_at = nil
  7607. delete(m.clearedFields, chatsession.FieldDeletedAt)
  7608. }
  7609. // SetName sets the "name" field.
  7610. func (m *ChatSessionMutation) SetName(s string) {
  7611. m.name = &s
  7612. }
  7613. // Name returns the value of the "name" field in the mutation.
  7614. func (m *ChatSessionMutation) Name() (r string, exists bool) {
  7615. v := m.name
  7616. if v == nil {
  7617. return
  7618. }
  7619. return *v, true
  7620. }
  7621. // OldName returns the old "name" field's value of the ChatSession entity.
  7622. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7623. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7624. func (m *ChatSessionMutation) OldName(ctx context.Context) (v string, err error) {
  7625. if !m.op.Is(OpUpdateOne) {
  7626. return v, errors.New("OldName is only allowed on UpdateOne operations")
  7627. }
  7628. if m.id == nil || m.oldValue == nil {
  7629. return v, errors.New("OldName requires an ID field in the mutation")
  7630. }
  7631. oldValue, err := m.oldValue(ctx)
  7632. if err != nil {
  7633. return v, fmt.Errorf("querying old value for OldName: %w", err)
  7634. }
  7635. return oldValue.Name, nil
  7636. }
  7637. // ResetName resets all changes to the "name" field.
  7638. func (m *ChatSessionMutation) ResetName() {
  7639. m.name = nil
  7640. }
  7641. // SetUserID sets the "user_id" field.
  7642. func (m *ChatSessionMutation) SetUserID(u uint64) {
  7643. m.user_id = &u
  7644. m.adduser_id = nil
  7645. }
  7646. // UserID returns the value of the "user_id" field in the mutation.
  7647. func (m *ChatSessionMutation) UserID() (r uint64, exists bool) {
  7648. v := m.user_id
  7649. if v == nil {
  7650. return
  7651. }
  7652. return *v, true
  7653. }
  7654. // OldUserID returns the old "user_id" field's value of the ChatSession entity.
  7655. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7656. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7657. func (m *ChatSessionMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  7658. if !m.op.Is(OpUpdateOne) {
  7659. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  7660. }
  7661. if m.id == nil || m.oldValue == nil {
  7662. return v, errors.New("OldUserID requires an ID field in the mutation")
  7663. }
  7664. oldValue, err := m.oldValue(ctx)
  7665. if err != nil {
  7666. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  7667. }
  7668. return oldValue.UserID, nil
  7669. }
  7670. // AddUserID adds u to the "user_id" field.
  7671. func (m *ChatSessionMutation) AddUserID(u int64) {
  7672. if m.adduser_id != nil {
  7673. *m.adduser_id += u
  7674. } else {
  7675. m.adduser_id = &u
  7676. }
  7677. }
  7678. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  7679. func (m *ChatSessionMutation) AddedUserID() (r int64, exists bool) {
  7680. v := m.adduser_id
  7681. if v == nil {
  7682. return
  7683. }
  7684. return *v, true
  7685. }
  7686. // ResetUserID resets all changes to the "user_id" field.
  7687. func (m *ChatSessionMutation) ResetUserID() {
  7688. m.user_id = nil
  7689. m.adduser_id = nil
  7690. }
  7691. // SetBotID sets the "bot_id" field.
  7692. func (m *ChatSessionMutation) SetBotID(u uint64) {
  7693. m.bot_id = &u
  7694. m.addbot_id = nil
  7695. }
  7696. // BotID returns the value of the "bot_id" field in the mutation.
  7697. func (m *ChatSessionMutation) BotID() (r uint64, exists bool) {
  7698. v := m.bot_id
  7699. if v == nil {
  7700. return
  7701. }
  7702. return *v, true
  7703. }
  7704. // OldBotID returns the old "bot_id" field's value of the ChatSession entity.
  7705. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7706. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7707. func (m *ChatSessionMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  7708. if !m.op.Is(OpUpdateOne) {
  7709. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  7710. }
  7711. if m.id == nil || m.oldValue == nil {
  7712. return v, errors.New("OldBotID requires an ID field in the mutation")
  7713. }
  7714. oldValue, err := m.oldValue(ctx)
  7715. if err != nil {
  7716. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  7717. }
  7718. return oldValue.BotID, nil
  7719. }
  7720. // AddBotID adds u to the "bot_id" field.
  7721. func (m *ChatSessionMutation) AddBotID(u int64) {
  7722. if m.addbot_id != nil {
  7723. *m.addbot_id += u
  7724. } else {
  7725. m.addbot_id = &u
  7726. }
  7727. }
  7728. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  7729. func (m *ChatSessionMutation) AddedBotID() (r int64, exists bool) {
  7730. v := m.addbot_id
  7731. if v == nil {
  7732. return
  7733. }
  7734. return *v, true
  7735. }
  7736. // ResetBotID resets all changes to the "bot_id" field.
  7737. func (m *ChatSessionMutation) ResetBotID() {
  7738. m.bot_id = nil
  7739. m.addbot_id = nil
  7740. }
  7741. // SetBotType sets the "bot_type" field.
  7742. func (m *ChatSessionMutation) SetBotType(u uint8) {
  7743. m.bot_type = &u
  7744. m.addbot_type = nil
  7745. }
  7746. // BotType returns the value of the "bot_type" field in the mutation.
  7747. func (m *ChatSessionMutation) BotType() (r uint8, exists bool) {
  7748. v := m.bot_type
  7749. if v == nil {
  7750. return
  7751. }
  7752. return *v, true
  7753. }
  7754. // OldBotType returns the old "bot_type" field's value of the ChatSession entity.
  7755. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7756. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7757. func (m *ChatSessionMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  7758. if !m.op.Is(OpUpdateOne) {
  7759. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  7760. }
  7761. if m.id == nil || m.oldValue == nil {
  7762. return v, errors.New("OldBotType requires an ID field in the mutation")
  7763. }
  7764. oldValue, err := m.oldValue(ctx)
  7765. if err != nil {
  7766. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  7767. }
  7768. return oldValue.BotType, nil
  7769. }
  7770. // AddBotType adds u to the "bot_type" field.
  7771. func (m *ChatSessionMutation) AddBotType(u int8) {
  7772. if m.addbot_type != nil {
  7773. *m.addbot_type += u
  7774. } else {
  7775. m.addbot_type = &u
  7776. }
  7777. }
  7778. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  7779. func (m *ChatSessionMutation) AddedBotType() (r int8, exists bool) {
  7780. v := m.addbot_type
  7781. if v == nil {
  7782. return
  7783. }
  7784. return *v, true
  7785. }
  7786. // ResetBotType resets all changes to the "bot_type" field.
  7787. func (m *ChatSessionMutation) ResetBotType() {
  7788. m.bot_type = nil
  7789. m.addbot_type = nil
  7790. }
  7791. // Where appends a list predicates to the ChatSessionMutation builder.
  7792. func (m *ChatSessionMutation) Where(ps ...predicate.ChatSession) {
  7793. m.predicates = append(m.predicates, ps...)
  7794. }
  7795. // WhereP appends storage-level predicates to the ChatSessionMutation builder. Using this method,
  7796. // users can use type-assertion to append predicates that do not depend on any generated package.
  7797. func (m *ChatSessionMutation) WhereP(ps ...func(*sql.Selector)) {
  7798. p := make([]predicate.ChatSession, len(ps))
  7799. for i := range ps {
  7800. p[i] = ps[i]
  7801. }
  7802. m.Where(p...)
  7803. }
  7804. // Op returns the operation name.
  7805. func (m *ChatSessionMutation) Op() Op {
  7806. return m.op
  7807. }
  7808. // SetOp allows setting the mutation operation.
  7809. func (m *ChatSessionMutation) SetOp(op Op) {
  7810. m.op = op
  7811. }
  7812. // Type returns the node type of this mutation (ChatSession).
  7813. func (m *ChatSessionMutation) Type() string {
  7814. return m.typ
  7815. }
  7816. // Fields returns all fields that were changed during this mutation. Note that in
  7817. // order to get all numeric fields that were incremented/decremented, call
  7818. // AddedFields().
  7819. func (m *ChatSessionMutation) Fields() []string {
  7820. fields := make([]string, 0, 7)
  7821. if m.created_at != nil {
  7822. fields = append(fields, chatsession.FieldCreatedAt)
  7823. }
  7824. if m.updated_at != nil {
  7825. fields = append(fields, chatsession.FieldUpdatedAt)
  7826. }
  7827. if m.deleted_at != nil {
  7828. fields = append(fields, chatsession.FieldDeletedAt)
  7829. }
  7830. if m.name != nil {
  7831. fields = append(fields, chatsession.FieldName)
  7832. }
  7833. if m.user_id != nil {
  7834. fields = append(fields, chatsession.FieldUserID)
  7835. }
  7836. if m.bot_id != nil {
  7837. fields = append(fields, chatsession.FieldBotID)
  7838. }
  7839. if m.bot_type != nil {
  7840. fields = append(fields, chatsession.FieldBotType)
  7841. }
  7842. return fields
  7843. }
  7844. // Field returns the value of a field with the given name. The second boolean
  7845. // return value indicates that this field was not set, or was not defined in the
  7846. // schema.
  7847. func (m *ChatSessionMutation) Field(name string) (ent.Value, bool) {
  7848. switch name {
  7849. case chatsession.FieldCreatedAt:
  7850. return m.CreatedAt()
  7851. case chatsession.FieldUpdatedAt:
  7852. return m.UpdatedAt()
  7853. case chatsession.FieldDeletedAt:
  7854. return m.DeletedAt()
  7855. case chatsession.FieldName:
  7856. return m.Name()
  7857. case chatsession.FieldUserID:
  7858. return m.UserID()
  7859. case chatsession.FieldBotID:
  7860. return m.BotID()
  7861. case chatsession.FieldBotType:
  7862. return m.BotType()
  7863. }
  7864. return nil, false
  7865. }
  7866. // OldField returns the old value of the field from the database. An error is
  7867. // returned if the mutation operation is not UpdateOne, or the query to the
  7868. // database failed.
  7869. func (m *ChatSessionMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  7870. switch name {
  7871. case chatsession.FieldCreatedAt:
  7872. return m.OldCreatedAt(ctx)
  7873. case chatsession.FieldUpdatedAt:
  7874. return m.OldUpdatedAt(ctx)
  7875. case chatsession.FieldDeletedAt:
  7876. return m.OldDeletedAt(ctx)
  7877. case chatsession.FieldName:
  7878. return m.OldName(ctx)
  7879. case chatsession.FieldUserID:
  7880. return m.OldUserID(ctx)
  7881. case chatsession.FieldBotID:
  7882. return m.OldBotID(ctx)
  7883. case chatsession.FieldBotType:
  7884. return m.OldBotType(ctx)
  7885. }
  7886. return nil, fmt.Errorf("unknown ChatSession field %s", name)
  7887. }
  7888. // SetField sets the value of a field with the given name. It returns an error if
  7889. // the field is not defined in the schema, or if the type mismatched the field
  7890. // type.
  7891. func (m *ChatSessionMutation) SetField(name string, value ent.Value) error {
  7892. switch name {
  7893. case chatsession.FieldCreatedAt:
  7894. v, ok := value.(time.Time)
  7895. if !ok {
  7896. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7897. }
  7898. m.SetCreatedAt(v)
  7899. return nil
  7900. case chatsession.FieldUpdatedAt:
  7901. v, ok := value.(time.Time)
  7902. if !ok {
  7903. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7904. }
  7905. m.SetUpdatedAt(v)
  7906. return nil
  7907. case chatsession.FieldDeletedAt:
  7908. v, ok := value.(time.Time)
  7909. if !ok {
  7910. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7911. }
  7912. m.SetDeletedAt(v)
  7913. return nil
  7914. case chatsession.FieldName:
  7915. v, ok := value.(string)
  7916. if !ok {
  7917. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7918. }
  7919. m.SetName(v)
  7920. return nil
  7921. case chatsession.FieldUserID:
  7922. v, ok := value.(uint64)
  7923. if !ok {
  7924. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7925. }
  7926. m.SetUserID(v)
  7927. return nil
  7928. case chatsession.FieldBotID:
  7929. v, ok := value.(uint64)
  7930. if !ok {
  7931. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7932. }
  7933. m.SetBotID(v)
  7934. return nil
  7935. case chatsession.FieldBotType:
  7936. v, ok := value.(uint8)
  7937. if !ok {
  7938. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7939. }
  7940. m.SetBotType(v)
  7941. return nil
  7942. }
  7943. return fmt.Errorf("unknown ChatSession field %s", name)
  7944. }
  7945. // AddedFields returns all numeric fields that were incremented/decremented during
  7946. // this mutation.
  7947. func (m *ChatSessionMutation) AddedFields() []string {
  7948. var fields []string
  7949. if m.adduser_id != nil {
  7950. fields = append(fields, chatsession.FieldUserID)
  7951. }
  7952. if m.addbot_id != nil {
  7953. fields = append(fields, chatsession.FieldBotID)
  7954. }
  7955. if m.addbot_type != nil {
  7956. fields = append(fields, chatsession.FieldBotType)
  7957. }
  7958. return fields
  7959. }
  7960. // AddedField returns the numeric value that was incremented/decremented on a field
  7961. // with the given name. The second boolean return value indicates that this field
  7962. // was not set, or was not defined in the schema.
  7963. func (m *ChatSessionMutation) AddedField(name string) (ent.Value, bool) {
  7964. switch name {
  7965. case chatsession.FieldUserID:
  7966. return m.AddedUserID()
  7967. case chatsession.FieldBotID:
  7968. return m.AddedBotID()
  7969. case chatsession.FieldBotType:
  7970. return m.AddedBotType()
  7971. }
  7972. return nil, false
  7973. }
  7974. // AddField adds the value to the field with the given name. It returns an error if
  7975. // the field is not defined in the schema, or if the type mismatched the field
  7976. // type.
  7977. func (m *ChatSessionMutation) AddField(name string, value ent.Value) error {
  7978. switch name {
  7979. case chatsession.FieldUserID:
  7980. v, ok := value.(int64)
  7981. if !ok {
  7982. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7983. }
  7984. m.AddUserID(v)
  7985. return nil
  7986. case chatsession.FieldBotID:
  7987. v, ok := value.(int64)
  7988. if !ok {
  7989. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7990. }
  7991. m.AddBotID(v)
  7992. return nil
  7993. case chatsession.FieldBotType:
  7994. v, ok := value.(int8)
  7995. if !ok {
  7996. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7997. }
  7998. m.AddBotType(v)
  7999. return nil
  8000. }
  8001. return fmt.Errorf("unknown ChatSession numeric field %s", name)
  8002. }
  8003. // ClearedFields returns all nullable fields that were cleared during this
  8004. // mutation.
  8005. func (m *ChatSessionMutation) ClearedFields() []string {
  8006. var fields []string
  8007. if m.FieldCleared(chatsession.FieldDeletedAt) {
  8008. fields = append(fields, chatsession.FieldDeletedAt)
  8009. }
  8010. return fields
  8011. }
  8012. // FieldCleared returns a boolean indicating if a field with the given name was
  8013. // cleared in this mutation.
  8014. func (m *ChatSessionMutation) FieldCleared(name string) bool {
  8015. _, ok := m.clearedFields[name]
  8016. return ok
  8017. }
  8018. // ClearField clears the value of the field with the given name. It returns an
  8019. // error if the field is not defined in the schema.
  8020. func (m *ChatSessionMutation) ClearField(name string) error {
  8021. switch name {
  8022. case chatsession.FieldDeletedAt:
  8023. m.ClearDeletedAt()
  8024. return nil
  8025. }
  8026. return fmt.Errorf("unknown ChatSession nullable field %s", name)
  8027. }
  8028. // ResetField resets all changes in the mutation for the field with the given name.
  8029. // It returns an error if the field is not defined in the schema.
  8030. func (m *ChatSessionMutation) ResetField(name string) error {
  8031. switch name {
  8032. case chatsession.FieldCreatedAt:
  8033. m.ResetCreatedAt()
  8034. return nil
  8035. case chatsession.FieldUpdatedAt:
  8036. m.ResetUpdatedAt()
  8037. return nil
  8038. case chatsession.FieldDeletedAt:
  8039. m.ResetDeletedAt()
  8040. return nil
  8041. case chatsession.FieldName:
  8042. m.ResetName()
  8043. return nil
  8044. case chatsession.FieldUserID:
  8045. m.ResetUserID()
  8046. return nil
  8047. case chatsession.FieldBotID:
  8048. m.ResetBotID()
  8049. return nil
  8050. case chatsession.FieldBotType:
  8051. m.ResetBotType()
  8052. return nil
  8053. }
  8054. return fmt.Errorf("unknown ChatSession field %s", name)
  8055. }
  8056. // AddedEdges returns all edge names that were set/added in this mutation.
  8057. func (m *ChatSessionMutation) AddedEdges() []string {
  8058. edges := make([]string, 0, 0)
  8059. return edges
  8060. }
  8061. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  8062. // name in this mutation.
  8063. func (m *ChatSessionMutation) AddedIDs(name string) []ent.Value {
  8064. return nil
  8065. }
  8066. // RemovedEdges returns all edge names that were removed in this mutation.
  8067. func (m *ChatSessionMutation) RemovedEdges() []string {
  8068. edges := make([]string, 0, 0)
  8069. return edges
  8070. }
  8071. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  8072. // the given name in this mutation.
  8073. func (m *ChatSessionMutation) RemovedIDs(name string) []ent.Value {
  8074. return nil
  8075. }
  8076. // ClearedEdges returns all edge names that were cleared in this mutation.
  8077. func (m *ChatSessionMutation) ClearedEdges() []string {
  8078. edges := make([]string, 0, 0)
  8079. return edges
  8080. }
  8081. // EdgeCleared returns a boolean which indicates if the edge with the given name
  8082. // was cleared in this mutation.
  8083. func (m *ChatSessionMutation) EdgeCleared(name string) bool {
  8084. return false
  8085. }
  8086. // ClearEdge clears the value of the edge with the given name. It returns an error
  8087. // if that edge is not defined in the schema.
  8088. func (m *ChatSessionMutation) ClearEdge(name string) error {
  8089. return fmt.Errorf("unknown ChatSession unique edge %s", name)
  8090. }
  8091. // ResetEdge resets all changes to the edge with the given name in this mutation.
  8092. // It returns an error if the edge is not defined in the schema.
  8093. func (m *ChatSessionMutation) ResetEdge(name string) error {
  8094. return fmt.Errorf("unknown ChatSession edge %s", name)
  8095. }
  8096. // ContactMutation represents an operation that mutates the Contact nodes in the graph.
  8097. type ContactMutation struct {
  8098. config
  8099. op Op
  8100. typ string
  8101. id *uint64
  8102. created_at *time.Time
  8103. updated_at *time.Time
  8104. status *uint8
  8105. addstatus *int8
  8106. deleted_at *time.Time
  8107. wx_wxid *string
  8108. _type *int
  8109. add_type *int
  8110. wxid *string
  8111. account *string
  8112. nickname *string
  8113. markname *string
  8114. headimg *string
  8115. sex *int
  8116. addsex *int
  8117. starrole *string
  8118. dontseeit *int
  8119. adddontseeit *int
  8120. dontseeme *int
  8121. adddontseeme *int
  8122. lag *string
  8123. gid *string
  8124. gname *string
  8125. v3 *string
  8126. organization_id *uint64
  8127. addorganization_id *int64
  8128. ctype *uint64
  8129. addctype *int64
  8130. cage *int
  8131. addcage *int
  8132. cname *string
  8133. carea *string
  8134. cbirthday *string
  8135. cbirtharea *string
  8136. cidcard_no *string
  8137. ctitle *string
  8138. cc *string
  8139. phone *string
  8140. clearedFields map[string]struct{}
  8141. contact_relationships map[uint64]struct{}
  8142. removedcontact_relationships map[uint64]struct{}
  8143. clearedcontact_relationships bool
  8144. contact_messages map[uint64]struct{}
  8145. removedcontact_messages map[uint64]struct{}
  8146. clearedcontact_messages bool
  8147. done bool
  8148. oldValue func(context.Context) (*Contact, error)
  8149. predicates []predicate.Contact
  8150. }
  8151. var _ ent.Mutation = (*ContactMutation)(nil)
  8152. // contactOption allows management of the mutation configuration using functional options.
  8153. type contactOption func(*ContactMutation)
  8154. // newContactMutation creates new mutation for the Contact entity.
  8155. func newContactMutation(c config, op Op, opts ...contactOption) *ContactMutation {
  8156. m := &ContactMutation{
  8157. config: c,
  8158. op: op,
  8159. typ: TypeContact,
  8160. clearedFields: make(map[string]struct{}),
  8161. }
  8162. for _, opt := range opts {
  8163. opt(m)
  8164. }
  8165. return m
  8166. }
  8167. // withContactID sets the ID field of the mutation.
  8168. func withContactID(id uint64) contactOption {
  8169. return func(m *ContactMutation) {
  8170. var (
  8171. err error
  8172. once sync.Once
  8173. value *Contact
  8174. )
  8175. m.oldValue = func(ctx context.Context) (*Contact, error) {
  8176. once.Do(func() {
  8177. if m.done {
  8178. err = errors.New("querying old values post mutation is not allowed")
  8179. } else {
  8180. value, err = m.Client().Contact.Get(ctx, id)
  8181. }
  8182. })
  8183. return value, err
  8184. }
  8185. m.id = &id
  8186. }
  8187. }
  8188. // withContact sets the old Contact of the mutation.
  8189. func withContact(node *Contact) contactOption {
  8190. return func(m *ContactMutation) {
  8191. m.oldValue = func(context.Context) (*Contact, error) {
  8192. return node, nil
  8193. }
  8194. m.id = &node.ID
  8195. }
  8196. }
  8197. // Client returns a new `ent.Client` from the mutation. If the mutation was
  8198. // executed in a transaction (ent.Tx), a transactional client is returned.
  8199. func (m ContactMutation) Client() *Client {
  8200. client := &Client{config: m.config}
  8201. client.init()
  8202. return client
  8203. }
  8204. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  8205. // it returns an error otherwise.
  8206. func (m ContactMutation) Tx() (*Tx, error) {
  8207. if _, ok := m.driver.(*txDriver); !ok {
  8208. return nil, errors.New("ent: mutation is not running in a transaction")
  8209. }
  8210. tx := &Tx{config: m.config}
  8211. tx.init()
  8212. return tx, nil
  8213. }
  8214. // SetID sets the value of the id field. Note that this
  8215. // operation is only accepted on creation of Contact entities.
  8216. func (m *ContactMutation) SetID(id uint64) {
  8217. m.id = &id
  8218. }
  8219. // ID returns the ID value in the mutation. Note that the ID is only available
  8220. // if it was provided to the builder or after it was returned from the database.
  8221. func (m *ContactMutation) ID() (id uint64, exists bool) {
  8222. if m.id == nil {
  8223. return
  8224. }
  8225. return *m.id, true
  8226. }
  8227. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  8228. // That means, if the mutation is applied within a transaction with an isolation level such
  8229. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  8230. // or updated by the mutation.
  8231. func (m *ContactMutation) IDs(ctx context.Context) ([]uint64, error) {
  8232. switch {
  8233. case m.op.Is(OpUpdateOne | OpDeleteOne):
  8234. id, exists := m.ID()
  8235. if exists {
  8236. return []uint64{id}, nil
  8237. }
  8238. fallthrough
  8239. case m.op.Is(OpUpdate | OpDelete):
  8240. return m.Client().Contact.Query().Where(m.predicates...).IDs(ctx)
  8241. default:
  8242. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  8243. }
  8244. }
  8245. // SetCreatedAt sets the "created_at" field.
  8246. func (m *ContactMutation) SetCreatedAt(t time.Time) {
  8247. m.created_at = &t
  8248. }
  8249. // CreatedAt returns the value of the "created_at" field in the mutation.
  8250. func (m *ContactMutation) CreatedAt() (r time.Time, exists bool) {
  8251. v := m.created_at
  8252. if v == nil {
  8253. return
  8254. }
  8255. return *v, true
  8256. }
  8257. // OldCreatedAt returns the old "created_at" field's value of the Contact entity.
  8258. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8259. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8260. func (m *ContactMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  8261. if !m.op.Is(OpUpdateOne) {
  8262. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  8263. }
  8264. if m.id == nil || m.oldValue == nil {
  8265. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  8266. }
  8267. oldValue, err := m.oldValue(ctx)
  8268. if err != nil {
  8269. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  8270. }
  8271. return oldValue.CreatedAt, nil
  8272. }
  8273. // ResetCreatedAt resets all changes to the "created_at" field.
  8274. func (m *ContactMutation) ResetCreatedAt() {
  8275. m.created_at = nil
  8276. }
  8277. // SetUpdatedAt sets the "updated_at" field.
  8278. func (m *ContactMutation) SetUpdatedAt(t time.Time) {
  8279. m.updated_at = &t
  8280. }
  8281. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  8282. func (m *ContactMutation) UpdatedAt() (r time.Time, exists bool) {
  8283. v := m.updated_at
  8284. if v == nil {
  8285. return
  8286. }
  8287. return *v, true
  8288. }
  8289. // OldUpdatedAt returns the old "updated_at" field's value of the Contact entity.
  8290. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8291. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8292. func (m *ContactMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  8293. if !m.op.Is(OpUpdateOne) {
  8294. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  8295. }
  8296. if m.id == nil || m.oldValue == nil {
  8297. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  8298. }
  8299. oldValue, err := m.oldValue(ctx)
  8300. if err != nil {
  8301. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  8302. }
  8303. return oldValue.UpdatedAt, nil
  8304. }
  8305. // ResetUpdatedAt resets all changes to the "updated_at" field.
  8306. func (m *ContactMutation) ResetUpdatedAt() {
  8307. m.updated_at = nil
  8308. }
  8309. // SetStatus sets the "status" field.
  8310. func (m *ContactMutation) SetStatus(u uint8) {
  8311. m.status = &u
  8312. m.addstatus = nil
  8313. }
  8314. // Status returns the value of the "status" field in the mutation.
  8315. func (m *ContactMutation) Status() (r uint8, exists bool) {
  8316. v := m.status
  8317. if v == nil {
  8318. return
  8319. }
  8320. return *v, true
  8321. }
  8322. // OldStatus returns the old "status" field's value of the Contact entity.
  8323. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8324. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8325. func (m *ContactMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  8326. if !m.op.Is(OpUpdateOne) {
  8327. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  8328. }
  8329. if m.id == nil || m.oldValue == nil {
  8330. return v, errors.New("OldStatus requires an ID field in the mutation")
  8331. }
  8332. oldValue, err := m.oldValue(ctx)
  8333. if err != nil {
  8334. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  8335. }
  8336. return oldValue.Status, nil
  8337. }
  8338. // AddStatus adds u to the "status" field.
  8339. func (m *ContactMutation) AddStatus(u int8) {
  8340. if m.addstatus != nil {
  8341. *m.addstatus += u
  8342. } else {
  8343. m.addstatus = &u
  8344. }
  8345. }
  8346. // AddedStatus returns the value that was added to the "status" field in this mutation.
  8347. func (m *ContactMutation) AddedStatus() (r int8, exists bool) {
  8348. v := m.addstatus
  8349. if v == nil {
  8350. return
  8351. }
  8352. return *v, true
  8353. }
  8354. // ClearStatus clears the value of the "status" field.
  8355. func (m *ContactMutation) ClearStatus() {
  8356. m.status = nil
  8357. m.addstatus = nil
  8358. m.clearedFields[contact.FieldStatus] = struct{}{}
  8359. }
  8360. // StatusCleared returns if the "status" field was cleared in this mutation.
  8361. func (m *ContactMutation) StatusCleared() bool {
  8362. _, ok := m.clearedFields[contact.FieldStatus]
  8363. return ok
  8364. }
  8365. // ResetStatus resets all changes to the "status" field.
  8366. func (m *ContactMutation) ResetStatus() {
  8367. m.status = nil
  8368. m.addstatus = nil
  8369. delete(m.clearedFields, contact.FieldStatus)
  8370. }
  8371. // SetDeletedAt sets the "deleted_at" field.
  8372. func (m *ContactMutation) SetDeletedAt(t time.Time) {
  8373. m.deleted_at = &t
  8374. }
  8375. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  8376. func (m *ContactMutation) DeletedAt() (r time.Time, exists bool) {
  8377. v := m.deleted_at
  8378. if v == nil {
  8379. return
  8380. }
  8381. return *v, true
  8382. }
  8383. // OldDeletedAt returns the old "deleted_at" 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) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  8387. if !m.op.Is(OpUpdateOne) {
  8388. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  8389. }
  8390. if m.id == nil || m.oldValue == nil {
  8391. return v, errors.New("OldDeletedAt 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 OldDeletedAt: %w", err)
  8396. }
  8397. return oldValue.DeletedAt, nil
  8398. }
  8399. // ClearDeletedAt clears the value of the "deleted_at" field.
  8400. func (m *ContactMutation) ClearDeletedAt() {
  8401. m.deleted_at = nil
  8402. m.clearedFields[contact.FieldDeletedAt] = struct{}{}
  8403. }
  8404. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  8405. func (m *ContactMutation) DeletedAtCleared() bool {
  8406. _, ok := m.clearedFields[contact.FieldDeletedAt]
  8407. return ok
  8408. }
  8409. // ResetDeletedAt resets all changes to the "deleted_at" field.
  8410. func (m *ContactMutation) ResetDeletedAt() {
  8411. m.deleted_at = nil
  8412. delete(m.clearedFields, contact.FieldDeletedAt)
  8413. }
  8414. // SetWxWxid sets the "wx_wxid" field.
  8415. func (m *ContactMutation) SetWxWxid(s string) {
  8416. m.wx_wxid = &s
  8417. }
  8418. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  8419. func (m *ContactMutation) WxWxid() (r string, exists bool) {
  8420. v := m.wx_wxid
  8421. if v == nil {
  8422. return
  8423. }
  8424. return *v, true
  8425. }
  8426. // OldWxWxid returns the old "wx_wxid" field's value of the Contact entity.
  8427. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8428. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8429. func (m *ContactMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  8430. if !m.op.Is(OpUpdateOne) {
  8431. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  8432. }
  8433. if m.id == nil || m.oldValue == nil {
  8434. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  8435. }
  8436. oldValue, err := m.oldValue(ctx)
  8437. if err != nil {
  8438. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  8439. }
  8440. return oldValue.WxWxid, nil
  8441. }
  8442. // ResetWxWxid resets all changes to the "wx_wxid" field.
  8443. func (m *ContactMutation) ResetWxWxid() {
  8444. m.wx_wxid = nil
  8445. }
  8446. // SetType sets the "type" field.
  8447. func (m *ContactMutation) SetType(i int) {
  8448. m._type = &i
  8449. m.add_type = nil
  8450. }
  8451. // GetType returns the value of the "type" field in the mutation.
  8452. func (m *ContactMutation) GetType() (r int, exists bool) {
  8453. v := m._type
  8454. if v == nil {
  8455. return
  8456. }
  8457. return *v, true
  8458. }
  8459. // OldType returns the old "type" field's value of the Contact entity.
  8460. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8461. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8462. func (m *ContactMutation) OldType(ctx context.Context) (v int, err error) {
  8463. if !m.op.Is(OpUpdateOne) {
  8464. return v, errors.New("OldType is only allowed on UpdateOne operations")
  8465. }
  8466. if m.id == nil || m.oldValue == nil {
  8467. return v, errors.New("OldType requires an ID field in the mutation")
  8468. }
  8469. oldValue, err := m.oldValue(ctx)
  8470. if err != nil {
  8471. return v, fmt.Errorf("querying old value for OldType: %w", err)
  8472. }
  8473. return oldValue.Type, nil
  8474. }
  8475. // AddType adds i to the "type" field.
  8476. func (m *ContactMutation) AddType(i int) {
  8477. if m.add_type != nil {
  8478. *m.add_type += i
  8479. } else {
  8480. m.add_type = &i
  8481. }
  8482. }
  8483. // AddedType returns the value that was added to the "type" field in this mutation.
  8484. func (m *ContactMutation) AddedType() (r int, exists bool) {
  8485. v := m.add_type
  8486. if v == nil {
  8487. return
  8488. }
  8489. return *v, true
  8490. }
  8491. // ClearType clears the value of the "type" field.
  8492. func (m *ContactMutation) ClearType() {
  8493. m._type = nil
  8494. m.add_type = nil
  8495. m.clearedFields[contact.FieldType] = struct{}{}
  8496. }
  8497. // TypeCleared returns if the "type" field was cleared in this mutation.
  8498. func (m *ContactMutation) TypeCleared() bool {
  8499. _, ok := m.clearedFields[contact.FieldType]
  8500. return ok
  8501. }
  8502. // ResetType resets all changes to the "type" field.
  8503. func (m *ContactMutation) ResetType() {
  8504. m._type = nil
  8505. m.add_type = nil
  8506. delete(m.clearedFields, contact.FieldType)
  8507. }
  8508. // SetWxid sets the "wxid" field.
  8509. func (m *ContactMutation) SetWxid(s string) {
  8510. m.wxid = &s
  8511. }
  8512. // Wxid returns the value of the "wxid" field in the mutation.
  8513. func (m *ContactMutation) Wxid() (r string, exists bool) {
  8514. v := m.wxid
  8515. if v == nil {
  8516. return
  8517. }
  8518. return *v, true
  8519. }
  8520. // OldWxid returns the old "wxid" field's value of the Contact entity.
  8521. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8522. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8523. func (m *ContactMutation) OldWxid(ctx context.Context) (v string, err error) {
  8524. if !m.op.Is(OpUpdateOne) {
  8525. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  8526. }
  8527. if m.id == nil || m.oldValue == nil {
  8528. return v, errors.New("OldWxid requires an ID field in the mutation")
  8529. }
  8530. oldValue, err := m.oldValue(ctx)
  8531. if err != nil {
  8532. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  8533. }
  8534. return oldValue.Wxid, nil
  8535. }
  8536. // ResetWxid resets all changes to the "wxid" field.
  8537. func (m *ContactMutation) ResetWxid() {
  8538. m.wxid = nil
  8539. }
  8540. // SetAccount sets the "account" field.
  8541. func (m *ContactMutation) SetAccount(s string) {
  8542. m.account = &s
  8543. }
  8544. // Account returns the value of the "account" field in the mutation.
  8545. func (m *ContactMutation) Account() (r string, exists bool) {
  8546. v := m.account
  8547. if v == nil {
  8548. return
  8549. }
  8550. return *v, true
  8551. }
  8552. // OldAccount returns the old "account" field's value of the Contact entity.
  8553. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8554. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8555. func (m *ContactMutation) OldAccount(ctx context.Context) (v string, err error) {
  8556. if !m.op.Is(OpUpdateOne) {
  8557. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  8558. }
  8559. if m.id == nil || m.oldValue == nil {
  8560. return v, errors.New("OldAccount requires an ID field in the mutation")
  8561. }
  8562. oldValue, err := m.oldValue(ctx)
  8563. if err != nil {
  8564. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  8565. }
  8566. return oldValue.Account, nil
  8567. }
  8568. // ResetAccount resets all changes to the "account" field.
  8569. func (m *ContactMutation) ResetAccount() {
  8570. m.account = nil
  8571. }
  8572. // SetNickname sets the "nickname" field.
  8573. func (m *ContactMutation) SetNickname(s string) {
  8574. m.nickname = &s
  8575. }
  8576. // Nickname returns the value of the "nickname" field in the mutation.
  8577. func (m *ContactMutation) Nickname() (r string, exists bool) {
  8578. v := m.nickname
  8579. if v == nil {
  8580. return
  8581. }
  8582. return *v, true
  8583. }
  8584. // OldNickname returns the old "nickname" field's value of the Contact entity.
  8585. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8586. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8587. func (m *ContactMutation) OldNickname(ctx context.Context) (v string, err error) {
  8588. if !m.op.Is(OpUpdateOne) {
  8589. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  8590. }
  8591. if m.id == nil || m.oldValue == nil {
  8592. return v, errors.New("OldNickname requires an ID field in the mutation")
  8593. }
  8594. oldValue, err := m.oldValue(ctx)
  8595. if err != nil {
  8596. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  8597. }
  8598. return oldValue.Nickname, nil
  8599. }
  8600. // ResetNickname resets all changes to the "nickname" field.
  8601. func (m *ContactMutation) ResetNickname() {
  8602. m.nickname = nil
  8603. }
  8604. // SetMarkname sets the "markname" field.
  8605. func (m *ContactMutation) SetMarkname(s string) {
  8606. m.markname = &s
  8607. }
  8608. // Markname returns the value of the "markname" field in the mutation.
  8609. func (m *ContactMutation) Markname() (r string, exists bool) {
  8610. v := m.markname
  8611. if v == nil {
  8612. return
  8613. }
  8614. return *v, true
  8615. }
  8616. // OldMarkname returns the old "markname" field's value of the Contact entity.
  8617. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8618. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8619. func (m *ContactMutation) OldMarkname(ctx context.Context) (v string, err error) {
  8620. if !m.op.Is(OpUpdateOne) {
  8621. return v, errors.New("OldMarkname is only allowed on UpdateOne operations")
  8622. }
  8623. if m.id == nil || m.oldValue == nil {
  8624. return v, errors.New("OldMarkname requires an ID field in the mutation")
  8625. }
  8626. oldValue, err := m.oldValue(ctx)
  8627. if err != nil {
  8628. return v, fmt.Errorf("querying old value for OldMarkname: %w", err)
  8629. }
  8630. return oldValue.Markname, nil
  8631. }
  8632. // ResetMarkname resets all changes to the "markname" field.
  8633. func (m *ContactMutation) ResetMarkname() {
  8634. m.markname = nil
  8635. }
  8636. // SetHeadimg sets the "headimg" field.
  8637. func (m *ContactMutation) SetHeadimg(s string) {
  8638. m.headimg = &s
  8639. }
  8640. // Headimg returns the value of the "headimg" field in the mutation.
  8641. func (m *ContactMutation) Headimg() (r string, exists bool) {
  8642. v := m.headimg
  8643. if v == nil {
  8644. return
  8645. }
  8646. return *v, true
  8647. }
  8648. // OldHeadimg returns the old "headimg" field's value of the Contact entity.
  8649. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8650. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8651. func (m *ContactMutation) OldHeadimg(ctx context.Context) (v string, err error) {
  8652. if !m.op.Is(OpUpdateOne) {
  8653. return v, errors.New("OldHeadimg is only allowed on UpdateOne operations")
  8654. }
  8655. if m.id == nil || m.oldValue == nil {
  8656. return v, errors.New("OldHeadimg requires an ID field in the mutation")
  8657. }
  8658. oldValue, err := m.oldValue(ctx)
  8659. if err != nil {
  8660. return v, fmt.Errorf("querying old value for OldHeadimg: %w", err)
  8661. }
  8662. return oldValue.Headimg, nil
  8663. }
  8664. // ResetHeadimg resets all changes to the "headimg" field.
  8665. func (m *ContactMutation) ResetHeadimg() {
  8666. m.headimg = nil
  8667. }
  8668. // SetSex sets the "sex" field.
  8669. func (m *ContactMutation) SetSex(i int) {
  8670. m.sex = &i
  8671. m.addsex = nil
  8672. }
  8673. // Sex returns the value of the "sex" field in the mutation.
  8674. func (m *ContactMutation) Sex() (r int, exists bool) {
  8675. v := m.sex
  8676. if v == nil {
  8677. return
  8678. }
  8679. return *v, true
  8680. }
  8681. // OldSex returns the old "sex" field's value of the Contact entity.
  8682. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8683. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8684. func (m *ContactMutation) OldSex(ctx context.Context) (v int, err error) {
  8685. if !m.op.Is(OpUpdateOne) {
  8686. return v, errors.New("OldSex is only allowed on UpdateOne operations")
  8687. }
  8688. if m.id == nil || m.oldValue == nil {
  8689. return v, errors.New("OldSex requires an ID field in the mutation")
  8690. }
  8691. oldValue, err := m.oldValue(ctx)
  8692. if err != nil {
  8693. return v, fmt.Errorf("querying old value for OldSex: %w", err)
  8694. }
  8695. return oldValue.Sex, nil
  8696. }
  8697. // AddSex adds i to the "sex" field.
  8698. func (m *ContactMutation) AddSex(i int) {
  8699. if m.addsex != nil {
  8700. *m.addsex += i
  8701. } else {
  8702. m.addsex = &i
  8703. }
  8704. }
  8705. // AddedSex returns the value that was added to the "sex" field in this mutation.
  8706. func (m *ContactMutation) AddedSex() (r int, exists bool) {
  8707. v := m.addsex
  8708. if v == nil {
  8709. return
  8710. }
  8711. return *v, true
  8712. }
  8713. // ResetSex resets all changes to the "sex" field.
  8714. func (m *ContactMutation) ResetSex() {
  8715. m.sex = nil
  8716. m.addsex = nil
  8717. }
  8718. // SetStarrole sets the "starrole" field.
  8719. func (m *ContactMutation) SetStarrole(s string) {
  8720. m.starrole = &s
  8721. }
  8722. // Starrole returns the value of the "starrole" field in the mutation.
  8723. func (m *ContactMutation) Starrole() (r string, exists bool) {
  8724. v := m.starrole
  8725. if v == nil {
  8726. return
  8727. }
  8728. return *v, true
  8729. }
  8730. // OldStarrole returns the old "starrole" field's value of the Contact entity.
  8731. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8732. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8733. func (m *ContactMutation) OldStarrole(ctx context.Context) (v string, err error) {
  8734. if !m.op.Is(OpUpdateOne) {
  8735. return v, errors.New("OldStarrole is only allowed on UpdateOne operations")
  8736. }
  8737. if m.id == nil || m.oldValue == nil {
  8738. return v, errors.New("OldStarrole requires an ID field in the mutation")
  8739. }
  8740. oldValue, err := m.oldValue(ctx)
  8741. if err != nil {
  8742. return v, fmt.Errorf("querying old value for OldStarrole: %w", err)
  8743. }
  8744. return oldValue.Starrole, nil
  8745. }
  8746. // ResetStarrole resets all changes to the "starrole" field.
  8747. func (m *ContactMutation) ResetStarrole() {
  8748. m.starrole = nil
  8749. }
  8750. // SetDontseeit sets the "dontseeit" field.
  8751. func (m *ContactMutation) SetDontseeit(i int) {
  8752. m.dontseeit = &i
  8753. m.adddontseeit = nil
  8754. }
  8755. // Dontseeit returns the value of the "dontseeit" field in the mutation.
  8756. func (m *ContactMutation) Dontseeit() (r int, exists bool) {
  8757. v := m.dontseeit
  8758. if v == nil {
  8759. return
  8760. }
  8761. return *v, true
  8762. }
  8763. // OldDontseeit returns the old "dontseeit" field's value of the Contact entity.
  8764. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8765. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8766. func (m *ContactMutation) OldDontseeit(ctx context.Context) (v int, err error) {
  8767. if !m.op.Is(OpUpdateOne) {
  8768. return v, errors.New("OldDontseeit is only allowed on UpdateOne operations")
  8769. }
  8770. if m.id == nil || m.oldValue == nil {
  8771. return v, errors.New("OldDontseeit requires an ID field in the mutation")
  8772. }
  8773. oldValue, err := m.oldValue(ctx)
  8774. if err != nil {
  8775. return v, fmt.Errorf("querying old value for OldDontseeit: %w", err)
  8776. }
  8777. return oldValue.Dontseeit, nil
  8778. }
  8779. // AddDontseeit adds i to the "dontseeit" field.
  8780. func (m *ContactMutation) AddDontseeit(i int) {
  8781. if m.adddontseeit != nil {
  8782. *m.adddontseeit += i
  8783. } else {
  8784. m.adddontseeit = &i
  8785. }
  8786. }
  8787. // AddedDontseeit returns the value that was added to the "dontseeit" field in this mutation.
  8788. func (m *ContactMutation) AddedDontseeit() (r int, exists bool) {
  8789. v := m.adddontseeit
  8790. if v == nil {
  8791. return
  8792. }
  8793. return *v, true
  8794. }
  8795. // ResetDontseeit resets all changes to the "dontseeit" field.
  8796. func (m *ContactMutation) ResetDontseeit() {
  8797. m.dontseeit = nil
  8798. m.adddontseeit = nil
  8799. }
  8800. // SetDontseeme sets the "dontseeme" field.
  8801. func (m *ContactMutation) SetDontseeme(i int) {
  8802. m.dontseeme = &i
  8803. m.adddontseeme = nil
  8804. }
  8805. // Dontseeme returns the value of the "dontseeme" field in the mutation.
  8806. func (m *ContactMutation) Dontseeme() (r int, exists bool) {
  8807. v := m.dontseeme
  8808. if v == nil {
  8809. return
  8810. }
  8811. return *v, true
  8812. }
  8813. // OldDontseeme returns the old "dontseeme" field's value of the Contact entity.
  8814. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8815. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8816. func (m *ContactMutation) OldDontseeme(ctx context.Context) (v int, err error) {
  8817. if !m.op.Is(OpUpdateOne) {
  8818. return v, errors.New("OldDontseeme is only allowed on UpdateOne operations")
  8819. }
  8820. if m.id == nil || m.oldValue == nil {
  8821. return v, errors.New("OldDontseeme requires an ID field in the mutation")
  8822. }
  8823. oldValue, err := m.oldValue(ctx)
  8824. if err != nil {
  8825. return v, fmt.Errorf("querying old value for OldDontseeme: %w", err)
  8826. }
  8827. return oldValue.Dontseeme, nil
  8828. }
  8829. // AddDontseeme adds i to the "dontseeme" field.
  8830. func (m *ContactMutation) AddDontseeme(i int) {
  8831. if m.adddontseeme != nil {
  8832. *m.adddontseeme += i
  8833. } else {
  8834. m.adddontseeme = &i
  8835. }
  8836. }
  8837. // AddedDontseeme returns the value that was added to the "dontseeme" field in this mutation.
  8838. func (m *ContactMutation) AddedDontseeme() (r int, exists bool) {
  8839. v := m.adddontseeme
  8840. if v == nil {
  8841. return
  8842. }
  8843. return *v, true
  8844. }
  8845. // ResetDontseeme resets all changes to the "dontseeme" field.
  8846. func (m *ContactMutation) ResetDontseeme() {
  8847. m.dontseeme = nil
  8848. m.adddontseeme = nil
  8849. }
  8850. // SetLag sets the "lag" field.
  8851. func (m *ContactMutation) SetLag(s string) {
  8852. m.lag = &s
  8853. }
  8854. // Lag returns the value of the "lag" field in the mutation.
  8855. func (m *ContactMutation) Lag() (r string, exists bool) {
  8856. v := m.lag
  8857. if v == nil {
  8858. return
  8859. }
  8860. return *v, true
  8861. }
  8862. // OldLag returns the old "lag" field's value of the Contact entity.
  8863. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8864. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8865. func (m *ContactMutation) OldLag(ctx context.Context) (v string, err error) {
  8866. if !m.op.Is(OpUpdateOne) {
  8867. return v, errors.New("OldLag is only allowed on UpdateOne operations")
  8868. }
  8869. if m.id == nil || m.oldValue == nil {
  8870. return v, errors.New("OldLag requires an ID field in the mutation")
  8871. }
  8872. oldValue, err := m.oldValue(ctx)
  8873. if err != nil {
  8874. return v, fmt.Errorf("querying old value for OldLag: %w", err)
  8875. }
  8876. return oldValue.Lag, nil
  8877. }
  8878. // ResetLag resets all changes to the "lag" field.
  8879. func (m *ContactMutation) ResetLag() {
  8880. m.lag = nil
  8881. }
  8882. // SetGid sets the "gid" field.
  8883. func (m *ContactMutation) SetGid(s string) {
  8884. m.gid = &s
  8885. }
  8886. // Gid returns the value of the "gid" field in the mutation.
  8887. func (m *ContactMutation) Gid() (r string, exists bool) {
  8888. v := m.gid
  8889. if v == nil {
  8890. return
  8891. }
  8892. return *v, true
  8893. }
  8894. // OldGid returns the old "gid" field's value of the Contact entity.
  8895. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8896. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8897. func (m *ContactMutation) OldGid(ctx context.Context) (v string, err error) {
  8898. if !m.op.Is(OpUpdateOne) {
  8899. return v, errors.New("OldGid is only allowed on UpdateOne operations")
  8900. }
  8901. if m.id == nil || m.oldValue == nil {
  8902. return v, errors.New("OldGid requires an ID field in the mutation")
  8903. }
  8904. oldValue, err := m.oldValue(ctx)
  8905. if err != nil {
  8906. return v, fmt.Errorf("querying old value for OldGid: %w", err)
  8907. }
  8908. return oldValue.Gid, nil
  8909. }
  8910. // ResetGid resets all changes to the "gid" field.
  8911. func (m *ContactMutation) ResetGid() {
  8912. m.gid = nil
  8913. }
  8914. // SetGname sets the "gname" field.
  8915. func (m *ContactMutation) SetGname(s string) {
  8916. m.gname = &s
  8917. }
  8918. // Gname returns the value of the "gname" field in the mutation.
  8919. func (m *ContactMutation) Gname() (r string, exists bool) {
  8920. v := m.gname
  8921. if v == nil {
  8922. return
  8923. }
  8924. return *v, true
  8925. }
  8926. // OldGname returns the old "gname" field's value of the Contact entity.
  8927. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8928. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8929. func (m *ContactMutation) OldGname(ctx context.Context) (v string, err error) {
  8930. if !m.op.Is(OpUpdateOne) {
  8931. return v, errors.New("OldGname is only allowed on UpdateOne operations")
  8932. }
  8933. if m.id == nil || m.oldValue == nil {
  8934. return v, errors.New("OldGname requires an ID field in the mutation")
  8935. }
  8936. oldValue, err := m.oldValue(ctx)
  8937. if err != nil {
  8938. return v, fmt.Errorf("querying old value for OldGname: %w", err)
  8939. }
  8940. return oldValue.Gname, nil
  8941. }
  8942. // ResetGname resets all changes to the "gname" field.
  8943. func (m *ContactMutation) ResetGname() {
  8944. m.gname = nil
  8945. }
  8946. // SetV3 sets the "v3" field.
  8947. func (m *ContactMutation) SetV3(s string) {
  8948. m.v3 = &s
  8949. }
  8950. // V3 returns the value of the "v3" field in the mutation.
  8951. func (m *ContactMutation) V3() (r string, exists bool) {
  8952. v := m.v3
  8953. if v == nil {
  8954. return
  8955. }
  8956. return *v, true
  8957. }
  8958. // OldV3 returns the old "v3" field's value of the Contact entity.
  8959. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8960. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8961. func (m *ContactMutation) OldV3(ctx context.Context) (v string, err error) {
  8962. if !m.op.Is(OpUpdateOne) {
  8963. return v, errors.New("OldV3 is only allowed on UpdateOne operations")
  8964. }
  8965. if m.id == nil || m.oldValue == nil {
  8966. return v, errors.New("OldV3 requires an ID field in the mutation")
  8967. }
  8968. oldValue, err := m.oldValue(ctx)
  8969. if err != nil {
  8970. return v, fmt.Errorf("querying old value for OldV3: %w", err)
  8971. }
  8972. return oldValue.V3, nil
  8973. }
  8974. // ResetV3 resets all changes to the "v3" field.
  8975. func (m *ContactMutation) ResetV3() {
  8976. m.v3 = nil
  8977. }
  8978. // SetOrganizationID sets the "organization_id" field.
  8979. func (m *ContactMutation) SetOrganizationID(u uint64) {
  8980. m.organization_id = &u
  8981. m.addorganization_id = nil
  8982. }
  8983. // OrganizationID returns the value of the "organization_id" field in the mutation.
  8984. func (m *ContactMutation) OrganizationID() (r uint64, exists bool) {
  8985. v := m.organization_id
  8986. if v == nil {
  8987. return
  8988. }
  8989. return *v, true
  8990. }
  8991. // OldOrganizationID returns the old "organization_id" field's value of the Contact entity.
  8992. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8993. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8994. func (m *ContactMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  8995. if !m.op.Is(OpUpdateOne) {
  8996. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  8997. }
  8998. if m.id == nil || m.oldValue == nil {
  8999. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  9000. }
  9001. oldValue, err := m.oldValue(ctx)
  9002. if err != nil {
  9003. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  9004. }
  9005. return oldValue.OrganizationID, nil
  9006. }
  9007. // AddOrganizationID adds u to the "organization_id" field.
  9008. func (m *ContactMutation) AddOrganizationID(u int64) {
  9009. if m.addorganization_id != nil {
  9010. *m.addorganization_id += u
  9011. } else {
  9012. m.addorganization_id = &u
  9013. }
  9014. }
  9015. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  9016. func (m *ContactMutation) AddedOrganizationID() (r int64, exists bool) {
  9017. v := m.addorganization_id
  9018. if v == nil {
  9019. return
  9020. }
  9021. return *v, true
  9022. }
  9023. // ClearOrganizationID clears the value of the "organization_id" field.
  9024. func (m *ContactMutation) ClearOrganizationID() {
  9025. m.organization_id = nil
  9026. m.addorganization_id = nil
  9027. m.clearedFields[contact.FieldOrganizationID] = struct{}{}
  9028. }
  9029. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  9030. func (m *ContactMutation) OrganizationIDCleared() bool {
  9031. _, ok := m.clearedFields[contact.FieldOrganizationID]
  9032. return ok
  9033. }
  9034. // ResetOrganizationID resets all changes to the "organization_id" field.
  9035. func (m *ContactMutation) ResetOrganizationID() {
  9036. m.organization_id = nil
  9037. m.addorganization_id = nil
  9038. delete(m.clearedFields, contact.FieldOrganizationID)
  9039. }
  9040. // SetCtype sets the "ctype" field.
  9041. func (m *ContactMutation) SetCtype(u uint64) {
  9042. m.ctype = &u
  9043. m.addctype = nil
  9044. }
  9045. // Ctype returns the value of the "ctype" field in the mutation.
  9046. func (m *ContactMutation) Ctype() (r uint64, exists bool) {
  9047. v := m.ctype
  9048. if v == nil {
  9049. return
  9050. }
  9051. return *v, true
  9052. }
  9053. // OldCtype returns the old "ctype" field's value of the Contact entity.
  9054. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9055. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9056. func (m *ContactMutation) OldCtype(ctx context.Context) (v uint64, err error) {
  9057. if !m.op.Is(OpUpdateOne) {
  9058. return v, errors.New("OldCtype is only allowed on UpdateOne operations")
  9059. }
  9060. if m.id == nil || m.oldValue == nil {
  9061. return v, errors.New("OldCtype requires an ID field in the mutation")
  9062. }
  9063. oldValue, err := m.oldValue(ctx)
  9064. if err != nil {
  9065. return v, fmt.Errorf("querying old value for OldCtype: %w", err)
  9066. }
  9067. return oldValue.Ctype, nil
  9068. }
  9069. // AddCtype adds u to the "ctype" field.
  9070. func (m *ContactMutation) AddCtype(u int64) {
  9071. if m.addctype != nil {
  9072. *m.addctype += u
  9073. } else {
  9074. m.addctype = &u
  9075. }
  9076. }
  9077. // AddedCtype returns the value that was added to the "ctype" field in this mutation.
  9078. func (m *ContactMutation) AddedCtype() (r int64, exists bool) {
  9079. v := m.addctype
  9080. if v == nil {
  9081. return
  9082. }
  9083. return *v, true
  9084. }
  9085. // ResetCtype resets all changes to the "ctype" field.
  9086. func (m *ContactMutation) ResetCtype() {
  9087. m.ctype = nil
  9088. m.addctype = nil
  9089. }
  9090. // SetCage sets the "cage" field.
  9091. func (m *ContactMutation) SetCage(i int) {
  9092. m.cage = &i
  9093. m.addcage = nil
  9094. }
  9095. // Cage returns the value of the "cage" field in the mutation.
  9096. func (m *ContactMutation) Cage() (r int, exists bool) {
  9097. v := m.cage
  9098. if v == nil {
  9099. return
  9100. }
  9101. return *v, true
  9102. }
  9103. // OldCage returns the old "cage" field's value of the Contact entity.
  9104. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9105. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9106. func (m *ContactMutation) OldCage(ctx context.Context) (v int, err error) {
  9107. if !m.op.Is(OpUpdateOne) {
  9108. return v, errors.New("OldCage is only allowed on UpdateOne operations")
  9109. }
  9110. if m.id == nil || m.oldValue == nil {
  9111. return v, errors.New("OldCage requires an ID field in the mutation")
  9112. }
  9113. oldValue, err := m.oldValue(ctx)
  9114. if err != nil {
  9115. return v, fmt.Errorf("querying old value for OldCage: %w", err)
  9116. }
  9117. return oldValue.Cage, nil
  9118. }
  9119. // AddCage adds i to the "cage" field.
  9120. func (m *ContactMutation) AddCage(i int) {
  9121. if m.addcage != nil {
  9122. *m.addcage += i
  9123. } else {
  9124. m.addcage = &i
  9125. }
  9126. }
  9127. // AddedCage returns the value that was added to the "cage" field in this mutation.
  9128. func (m *ContactMutation) AddedCage() (r int, exists bool) {
  9129. v := m.addcage
  9130. if v == nil {
  9131. return
  9132. }
  9133. return *v, true
  9134. }
  9135. // ResetCage resets all changes to the "cage" field.
  9136. func (m *ContactMutation) ResetCage() {
  9137. m.cage = nil
  9138. m.addcage = nil
  9139. }
  9140. // SetCname sets the "cname" field.
  9141. func (m *ContactMutation) SetCname(s string) {
  9142. m.cname = &s
  9143. }
  9144. // Cname returns the value of the "cname" field in the mutation.
  9145. func (m *ContactMutation) Cname() (r string, exists bool) {
  9146. v := m.cname
  9147. if v == nil {
  9148. return
  9149. }
  9150. return *v, true
  9151. }
  9152. // OldCname returns the old "cname" field's value of the Contact entity.
  9153. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9154. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9155. func (m *ContactMutation) OldCname(ctx context.Context) (v string, err error) {
  9156. if !m.op.Is(OpUpdateOne) {
  9157. return v, errors.New("OldCname is only allowed on UpdateOne operations")
  9158. }
  9159. if m.id == nil || m.oldValue == nil {
  9160. return v, errors.New("OldCname requires an ID field in the mutation")
  9161. }
  9162. oldValue, err := m.oldValue(ctx)
  9163. if err != nil {
  9164. return v, fmt.Errorf("querying old value for OldCname: %w", err)
  9165. }
  9166. return oldValue.Cname, nil
  9167. }
  9168. // ResetCname resets all changes to the "cname" field.
  9169. func (m *ContactMutation) ResetCname() {
  9170. m.cname = nil
  9171. }
  9172. // SetCarea sets the "carea" field.
  9173. func (m *ContactMutation) SetCarea(s string) {
  9174. m.carea = &s
  9175. }
  9176. // Carea returns the value of the "carea" field in the mutation.
  9177. func (m *ContactMutation) Carea() (r string, exists bool) {
  9178. v := m.carea
  9179. if v == nil {
  9180. return
  9181. }
  9182. return *v, true
  9183. }
  9184. // OldCarea returns the old "carea" field's value of the Contact entity.
  9185. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9186. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9187. func (m *ContactMutation) OldCarea(ctx context.Context) (v string, err error) {
  9188. if !m.op.Is(OpUpdateOne) {
  9189. return v, errors.New("OldCarea is only allowed on UpdateOne operations")
  9190. }
  9191. if m.id == nil || m.oldValue == nil {
  9192. return v, errors.New("OldCarea requires an ID field in the mutation")
  9193. }
  9194. oldValue, err := m.oldValue(ctx)
  9195. if err != nil {
  9196. return v, fmt.Errorf("querying old value for OldCarea: %w", err)
  9197. }
  9198. return oldValue.Carea, nil
  9199. }
  9200. // ResetCarea resets all changes to the "carea" field.
  9201. func (m *ContactMutation) ResetCarea() {
  9202. m.carea = nil
  9203. }
  9204. // SetCbirthday sets the "cbirthday" field.
  9205. func (m *ContactMutation) SetCbirthday(s string) {
  9206. m.cbirthday = &s
  9207. }
  9208. // Cbirthday returns the value of the "cbirthday" field in the mutation.
  9209. func (m *ContactMutation) Cbirthday() (r string, exists bool) {
  9210. v := m.cbirthday
  9211. if v == nil {
  9212. return
  9213. }
  9214. return *v, true
  9215. }
  9216. // OldCbirthday returns the old "cbirthday" field's value of the Contact entity.
  9217. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9218. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9219. func (m *ContactMutation) OldCbirthday(ctx context.Context) (v string, err error) {
  9220. if !m.op.Is(OpUpdateOne) {
  9221. return v, errors.New("OldCbirthday is only allowed on UpdateOne operations")
  9222. }
  9223. if m.id == nil || m.oldValue == nil {
  9224. return v, errors.New("OldCbirthday requires an ID field in the mutation")
  9225. }
  9226. oldValue, err := m.oldValue(ctx)
  9227. if err != nil {
  9228. return v, fmt.Errorf("querying old value for OldCbirthday: %w", err)
  9229. }
  9230. return oldValue.Cbirthday, nil
  9231. }
  9232. // ResetCbirthday resets all changes to the "cbirthday" field.
  9233. func (m *ContactMutation) ResetCbirthday() {
  9234. m.cbirthday = nil
  9235. }
  9236. // SetCbirtharea sets the "cbirtharea" field.
  9237. func (m *ContactMutation) SetCbirtharea(s string) {
  9238. m.cbirtharea = &s
  9239. }
  9240. // Cbirtharea returns the value of the "cbirtharea" field in the mutation.
  9241. func (m *ContactMutation) Cbirtharea() (r string, exists bool) {
  9242. v := m.cbirtharea
  9243. if v == nil {
  9244. return
  9245. }
  9246. return *v, true
  9247. }
  9248. // OldCbirtharea returns the old "cbirtharea" field's value of the Contact entity.
  9249. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9250. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9251. func (m *ContactMutation) OldCbirtharea(ctx context.Context) (v string, err error) {
  9252. if !m.op.Is(OpUpdateOne) {
  9253. return v, errors.New("OldCbirtharea is only allowed on UpdateOne operations")
  9254. }
  9255. if m.id == nil || m.oldValue == nil {
  9256. return v, errors.New("OldCbirtharea requires an ID field in the mutation")
  9257. }
  9258. oldValue, err := m.oldValue(ctx)
  9259. if err != nil {
  9260. return v, fmt.Errorf("querying old value for OldCbirtharea: %w", err)
  9261. }
  9262. return oldValue.Cbirtharea, nil
  9263. }
  9264. // ResetCbirtharea resets all changes to the "cbirtharea" field.
  9265. func (m *ContactMutation) ResetCbirtharea() {
  9266. m.cbirtharea = nil
  9267. }
  9268. // SetCidcardNo sets the "cidcard_no" field.
  9269. func (m *ContactMutation) SetCidcardNo(s string) {
  9270. m.cidcard_no = &s
  9271. }
  9272. // CidcardNo returns the value of the "cidcard_no" field in the mutation.
  9273. func (m *ContactMutation) CidcardNo() (r string, exists bool) {
  9274. v := m.cidcard_no
  9275. if v == nil {
  9276. return
  9277. }
  9278. return *v, true
  9279. }
  9280. // OldCidcardNo returns the old "cidcard_no" field's value of the Contact entity.
  9281. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9282. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9283. func (m *ContactMutation) OldCidcardNo(ctx context.Context) (v string, err error) {
  9284. if !m.op.Is(OpUpdateOne) {
  9285. return v, errors.New("OldCidcardNo is only allowed on UpdateOne operations")
  9286. }
  9287. if m.id == nil || m.oldValue == nil {
  9288. return v, errors.New("OldCidcardNo requires an ID field in the mutation")
  9289. }
  9290. oldValue, err := m.oldValue(ctx)
  9291. if err != nil {
  9292. return v, fmt.Errorf("querying old value for OldCidcardNo: %w", err)
  9293. }
  9294. return oldValue.CidcardNo, nil
  9295. }
  9296. // ResetCidcardNo resets all changes to the "cidcard_no" field.
  9297. func (m *ContactMutation) ResetCidcardNo() {
  9298. m.cidcard_no = nil
  9299. }
  9300. // SetCtitle sets the "ctitle" field.
  9301. func (m *ContactMutation) SetCtitle(s string) {
  9302. m.ctitle = &s
  9303. }
  9304. // Ctitle returns the value of the "ctitle" field in the mutation.
  9305. func (m *ContactMutation) Ctitle() (r string, exists bool) {
  9306. v := m.ctitle
  9307. if v == nil {
  9308. return
  9309. }
  9310. return *v, true
  9311. }
  9312. // OldCtitle returns the old "ctitle" field's value of the Contact entity.
  9313. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9314. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9315. func (m *ContactMutation) OldCtitle(ctx context.Context) (v string, err error) {
  9316. if !m.op.Is(OpUpdateOne) {
  9317. return v, errors.New("OldCtitle is only allowed on UpdateOne operations")
  9318. }
  9319. if m.id == nil || m.oldValue == nil {
  9320. return v, errors.New("OldCtitle requires an ID field in the mutation")
  9321. }
  9322. oldValue, err := m.oldValue(ctx)
  9323. if err != nil {
  9324. return v, fmt.Errorf("querying old value for OldCtitle: %w", err)
  9325. }
  9326. return oldValue.Ctitle, nil
  9327. }
  9328. // ResetCtitle resets all changes to the "ctitle" field.
  9329. func (m *ContactMutation) ResetCtitle() {
  9330. m.ctitle = nil
  9331. }
  9332. // SetCc sets the "cc" field.
  9333. func (m *ContactMutation) SetCc(s string) {
  9334. m.cc = &s
  9335. }
  9336. // Cc returns the value of the "cc" field in the mutation.
  9337. func (m *ContactMutation) Cc() (r string, exists bool) {
  9338. v := m.cc
  9339. if v == nil {
  9340. return
  9341. }
  9342. return *v, true
  9343. }
  9344. // OldCc returns the old "cc" field's value of the Contact entity.
  9345. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9346. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9347. func (m *ContactMutation) OldCc(ctx context.Context) (v string, err error) {
  9348. if !m.op.Is(OpUpdateOne) {
  9349. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  9350. }
  9351. if m.id == nil || m.oldValue == nil {
  9352. return v, errors.New("OldCc requires an ID field in the mutation")
  9353. }
  9354. oldValue, err := m.oldValue(ctx)
  9355. if err != nil {
  9356. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  9357. }
  9358. return oldValue.Cc, nil
  9359. }
  9360. // ResetCc resets all changes to the "cc" field.
  9361. func (m *ContactMutation) ResetCc() {
  9362. m.cc = nil
  9363. }
  9364. // SetPhone sets the "phone" field.
  9365. func (m *ContactMutation) SetPhone(s string) {
  9366. m.phone = &s
  9367. }
  9368. // Phone returns the value of the "phone" field in the mutation.
  9369. func (m *ContactMutation) Phone() (r string, exists bool) {
  9370. v := m.phone
  9371. if v == nil {
  9372. return
  9373. }
  9374. return *v, true
  9375. }
  9376. // OldPhone returns the old "phone" field's value of the Contact entity.
  9377. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9378. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9379. func (m *ContactMutation) OldPhone(ctx context.Context) (v string, err error) {
  9380. if !m.op.Is(OpUpdateOne) {
  9381. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  9382. }
  9383. if m.id == nil || m.oldValue == nil {
  9384. return v, errors.New("OldPhone requires an ID field in the mutation")
  9385. }
  9386. oldValue, err := m.oldValue(ctx)
  9387. if err != nil {
  9388. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  9389. }
  9390. return oldValue.Phone, nil
  9391. }
  9392. // ResetPhone resets all changes to the "phone" field.
  9393. func (m *ContactMutation) ResetPhone() {
  9394. m.phone = nil
  9395. }
  9396. // AddContactRelationshipIDs adds the "contact_relationships" edge to the LabelRelationship entity by ids.
  9397. func (m *ContactMutation) AddContactRelationshipIDs(ids ...uint64) {
  9398. if m.contact_relationships == nil {
  9399. m.contact_relationships = make(map[uint64]struct{})
  9400. }
  9401. for i := range ids {
  9402. m.contact_relationships[ids[i]] = struct{}{}
  9403. }
  9404. }
  9405. // ClearContactRelationships clears the "contact_relationships" edge to the LabelRelationship entity.
  9406. func (m *ContactMutation) ClearContactRelationships() {
  9407. m.clearedcontact_relationships = true
  9408. }
  9409. // ContactRelationshipsCleared reports if the "contact_relationships" edge to the LabelRelationship entity was cleared.
  9410. func (m *ContactMutation) ContactRelationshipsCleared() bool {
  9411. return m.clearedcontact_relationships
  9412. }
  9413. // RemoveContactRelationshipIDs removes the "contact_relationships" edge to the LabelRelationship entity by IDs.
  9414. func (m *ContactMutation) RemoveContactRelationshipIDs(ids ...uint64) {
  9415. if m.removedcontact_relationships == nil {
  9416. m.removedcontact_relationships = make(map[uint64]struct{})
  9417. }
  9418. for i := range ids {
  9419. delete(m.contact_relationships, ids[i])
  9420. m.removedcontact_relationships[ids[i]] = struct{}{}
  9421. }
  9422. }
  9423. // RemovedContactRelationships returns the removed IDs of the "contact_relationships" edge to the LabelRelationship entity.
  9424. func (m *ContactMutation) RemovedContactRelationshipsIDs() (ids []uint64) {
  9425. for id := range m.removedcontact_relationships {
  9426. ids = append(ids, id)
  9427. }
  9428. return
  9429. }
  9430. // ContactRelationshipsIDs returns the "contact_relationships" edge IDs in the mutation.
  9431. func (m *ContactMutation) ContactRelationshipsIDs() (ids []uint64) {
  9432. for id := range m.contact_relationships {
  9433. ids = append(ids, id)
  9434. }
  9435. return
  9436. }
  9437. // ResetContactRelationships resets all changes to the "contact_relationships" edge.
  9438. func (m *ContactMutation) ResetContactRelationships() {
  9439. m.contact_relationships = nil
  9440. m.clearedcontact_relationships = false
  9441. m.removedcontact_relationships = nil
  9442. }
  9443. // AddContactMessageIDs adds the "contact_messages" edge to the MessageRecords entity by ids.
  9444. func (m *ContactMutation) AddContactMessageIDs(ids ...uint64) {
  9445. if m.contact_messages == nil {
  9446. m.contact_messages = make(map[uint64]struct{})
  9447. }
  9448. for i := range ids {
  9449. m.contact_messages[ids[i]] = struct{}{}
  9450. }
  9451. }
  9452. // ClearContactMessages clears the "contact_messages" edge to the MessageRecords entity.
  9453. func (m *ContactMutation) ClearContactMessages() {
  9454. m.clearedcontact_messages = true
  9455. }
  9456. // ContactMessagesCleared reports if the "contact_messages" edge to the MessageRecords entity was cleared.
  9457. func (m *ContactMutation) ContactMessagesCleared() bool {
  9458. return m.clearedcontact_messages
  9459. }
  9460. // RemoveContactMessageIDs removes the "contact_messages" edge to the MessageRecords entity by IDs.
  9461. func (m *ContactMutation) RemoveContactMessageIDs(ids ...uint64) {
  9462. if m.removedcontact_messages == nil {
  9463. m.removedcontact_messages = make(map[uint64]struct{})
  9464. }
  9465. for i := range ids {
  9466. delete(m.contact_messages, ids[i])
  9467. m.removedcontact_messages[ids[i]] = struct{}{}
  9468. }
  9469. }
  9470. // RemovedContactMessages returns the removed IDs of the "contact_messages" edge to the MessageRecords entity.
  9471. func (m *ContactMutation) RemovedContactMessagesIDs() (ids []uint64) {
  9472. for id := range m.removedcontact_messages {
  9473. ids = append(ids, id)
  9474. }
  9475. return
  9476. }
  9477. // ContactMessagesIDs returns the "contact_messages" edge IDs in the mutation.
  9478. func (m *ContactMutation) ContactMessagesIDs() (ids []uint64) {
  9479. for id := range m.contact_messages {
  9480. ids = append(ids, id)
  9481. }
  9482. return
  9483. }
  9484. // ResetContactMessages resets all changes to the "contact_messages" edge.
  9485. func (m *ContactMutation) ResetContactMessages() {
  9486. m.contact_messages = nil
  9487. m.clearedcontact_messages = false
  9488. m.removedcontact_messages = nil
  9489. }
  9490. // Where appends a list predicates to the ContactMutation builder.
  9491. func (m *ContactMutation) Where(ps ...predicate.Contact) {
  9492. m.predicates = append(m.predicates, ps...)
  9493. }
  9494. // WhereP appends storage-level predicates to the ContactMutation builder. Using this method,
  9495. // users can use type-assertion to append predicates that do not depend on any generated package.
  9496. func (m *ContactMutation) WhereP(ps ...func(*sql.Selector)) {
  9497. p := make([]predicate.Contact, len(ps))
  9498. for i := range ps {
  9499. p[i] = ps[i]
  9500. }
  9501. m.Where(p...)
  9502. }
  9503. // Op returns the operation name.
  9504. func (m *ContactMutation) Op() Op {
  9505. return m.op
  9506. }
  9507. // SetOp allows setting the mutation operation.
  9508. func (m *ContactMutation) SetOp(op Op) {
  9509. m.op = op
  9510. }
  9511. // Type returns the node type of this mutation (Contact).
  9512. func (m *ContactMutation) Type() string {
  9513. return m.typ
  9514. }
  9515. // Fields returns all fields that were changed during this mutation. Note that in
  9516. // order to get all numeric fields that were incremented/decremented, call
  9517. // AddedFields().
  9518. func (m *ContactMutation) Fields() []string {
  9519. fields := make([]string, 0, 30)
  9520. if m.created_at != nil {
  9521. fields = append(fields, contact.FieldCreatedAt)
  9522. }
  9523. if m.updated_at != nil {
  9524. fields = append(fields, contact.FieldUpdatedAt)
  9525. }
  9526. if m.status != nil {
  9527. fields = append(fields, contact.FieldStatus)
  9528. }
  9529. if m.deleted_at != nil {
  9530. fields = append(fields, contact.FieldDeletedAt)
  9531. }
  9532. if m.wx_wxid != nil {
  9533. fields = append(fields, contact.FieldWxWxid)
  9534. }
  9535. if m._type != nil {
  9536. fields = append(fields, contact.FieldType)
  9537. }
  9538. if m.wxid != nil {
  9539. fields = append(fields, contact.FieldWxid)
  9540. }
  9541. if m.account != nil {
  9542. fields = append(fields, contact.FieldAccount)
  9543. }
  9544. if m.nickname != nil {
  9545. fields = append(fields, contact.FieldNickname)
  9546. }
  9547. if m.markname != nil {
  9548. fields = append(fields, contact.FieldMarkname)
  9549. }
  9550. if m.headimg != nil {
  9551. fields = append(fields, contact.FieldHeadimg)
  9552. }
  9553. if m.sex != nil {
  9554. fields = append(fields, contact.FieldSex)
  9555. }
  9556. if m.starrole != nil {
  9557. fields = append(fields, contact.FieldStarrole)
  9558. }
  9559. if m.dontseeit != nil {
  9560. fields = append(fields, contact.FieldDontseeit)
  9561. }
  9562. if m.dontseeme != nil {
  9563. fields = append(fields, contact.FieldDontseeme)
  9564. }
  9565. if m.lag != nil {
  9566. fields = append(fields, contact.FieldLag)
  9567. }
  9568. if m.gid != nil {
  9569. fields = append(fields, contact.FieldGid)
  9570. }
  9571. if m.gname != nil {
  9572. fields = append(fields, contact.FieldGname)
  9573. }
  9574. if m.v3 != nil {
  9575. fields = append(fields, contact.FieldV3)
  9576. }
  9577. if m.organization_id != nil {
  9578. fields = append(fields, contact.FieldOrganizationID)
  9579. }
  9580. if m.ctype != nil {
  9581. fields = append(fields, contact.FieldCtype)
  9582. }
  9583. if m.cage != nil {
  9584. fields = append(fields, contact.FieldCage)
  9585. }
  9586. if m.cname != nil {
  9587. fields = append(fields, contact.FieldCname)
  9588. }
  9589. if m.carea != nil {
  9590. fields = append(fields, contact.FieldCarea)
  9591. }
  9592. if m.cbirthday != nil {
  9593. fields = append(fields, contact.FieldCbirthday)
  9594. }
  9595. if m.cbirtharea != nil {
  9596. fields = append(fields, contact.FieldCbirtharea)
  9597. }
  9598. if m.cidcard_no != nil {
  9599. fields = append(fields, contact.FieldCidcardNo)
  9600. }
  9601. if m.ctitle != nil {
  9602. fields = append(fields, contact.FieldCtitle)
  9603. }
  9604. if m.cc != nil {
  9605. fields = append(fields, contact.FieldCc)
  9606. }
  9607. if m.phone != nil {
  9608. fields = append(fields, contact.FieldPhone)
  9609. }
  9610. return fields
  9611. }
  9612. // Field returns the value of a field with the given name. The second boolean
  9613. // return value indicates that this field was not set, or was not defined in the
  9614. // schema.
  9615. func (m *ContactMutation) Field(name string) (ent.Value, bool) {
  9616. switch name {
  9617. case contact.FieldCreatedAt:
  9618. return m.CreatedAt()
  9619. case contact.FieldUpdatedAt:
  9620. return m.UpdatedAt()
  9621. case contact.FieldStatus:
  9622. return m.Status()
  9623. case contact.FieldDeletedAt:
  9624. return m.DeletedAt()
  9625. case contact.FieldWxWxid:
  9626. return m.WxWxid()
  9627. case contact.FieldType:
  9628. return m.GetType()
  9629. case contact.FieldWxid:
  9630. return m.Wxid()
  9631. case contact.FieldAccount:
  9632. return m.Account()
  9633. case contact.FieldNickname:
  9634. return m.Nickname()
  9635. case contact.FieldMarkname:
  9636. return m.Markname()
  9637. case contact.FieldHeadimg:
  9638. return m.Headimg()
  9639. case contact.FieldSex:
  9640. return m.Sex()
  9641. case contact.FieldStarrole:
  9642. return m.Starrole()
  9643. case contact.FieldDontseeit:
  9644. return m.Dontseeit()
  9645. case contact.FieldDontseeme:
  9646. return m.Dontseeme()
  9647. case contact.FieldLag:
  9648. return m.Lag()
  9649. case contact.FieldGid:
  9650. return m.Gid()
  9651. case contact.FieldGname:
  9652. return m.Gname()
  9653. case contact.FieldV3:
  9654. return m.V3()
  9655. case contact.FieldOrganizationID:
  9656. return m.OrganizationID()
  9657. case contact.FieldCtype:
  9658. return m.Ctype()
  9659. case contact.FieldCage:
  9660. return m.Cage()
  9661. case contact.FieldCname:
  9662. return m.Cname()
  9663. case contact.FieldCarea:
  9664. return m.Carea()
  9665. case contact.FieldCbirthday:
  9666. return m.Cbirthday()
  9667. case contact.FieldCbirtharea:
  9668. return m.Cbirtharea()
  9669. case contact.FieldCidcardNo:
  9670. return m.CidcardNo()
  9671. case contact.FieldCtitle:
  9672. return m.Ctitle()
  9673. case contact.FieldCc:
  9674. return m.Cc()
  9675. case contact.FieldPhone:
  9676. return m.Phone()
  9677. }
  9678. return nil, false
  9679. }
  9680. // OldField returns the old value of the field from the database. An error is
  9681. // returned if the mutation operation is not UpdateOne, or the query to the
  9682. // database failed.
  9683. func (m *ContactMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  9684. switch name {
  9685. case contact.FieldCreatedAt:
  9686. return m.OldCreatedAt(ctx)
  9687. case contact.FieldUpdatedAt:
  9688. return m.OldUpdatedAt(ctx)
  9689. case contact.FieldStatus:
  9690. return m.OldStatus(ctx)
  9691. case contact.FieldDeletedAt:
  9692. return m.OldDeletedAt(ctx)
  9693. case contact.FieldWxWxid:
  9694. return m.OldWxWxid(ctx)
  9695. case contact.FieldType:
  9696. return m.OldType(ctx)
  9697. case contact.FieldWxid:
  9698. return m.OldWxid(ctx)
  9699. case contact.FieldAccount:
  9700. return m.OldAccount(ctx)
  9701. case contact.FieldNickname:
  9702. return m.OldNickname(ctx)
  9703. case contact.FieldMarkname:
  9704. return m.OldMarkname(ctx)
  9705. case contact.FieldHeadimg:
  9706. return m.OldHeadimg(ctx)
  9707. case contact.FieldSex:
  9708. return m.OldSex(ctx)
  9709. case contact.FieldStarrole:
  9710. return m.OldStarrole(ctx)
  9711. case contact.FieldDontseeit:
  9712. return m.OldDontseeit(ctx)
  9713. case contact.FieldDontseeme:
  9714. return m.OldDontseeme(ctx)
  9715. case contact.FieldLag:
  9716. return m.OldLag(ctx)
  9717. case contact.FieldGid:
  9718. return m.OldGid(ctx)
  9719. case contact.FieldGname:
  9720. return m.OldGname(ctx)
  9721. case contact.FieldV3:
  9722. return m.OldV3(ctx)
  9723. case contact.FieldOrganizationID:
  9724. return m.OldOrganizationID(ctx)
  9725. case contact.FieldCtype:
  9726. return m.OldCtype(ctx)
  9727. case contact.FieldCage:
  9728. return m.OldCage(ctx)
  9729. case contact.FieldCname:
  9730. return m.OldCname(ctx)
  9731. case contact.FieldCarea:
  9732. return m.OldCarea(ctx)
  9733. case contact.FieldCbirthday:
  9734. return m.OldCbirthday(ctx)
  9735. case contact.FieldCbirtharea:
  9736. return m.OldCbirtharea(ctx)
  9737. case contact.FieldCidcardNo:
  9738. return m.OldCidcardNo(ctx)
  9739. case contact.FieldCtitle:
  9740. return m.OldCtitle(ctx)
  9741. case contact.FieldCc:
  9742. return m.OldCc(ctx)
  9743. case contact.FieldPhone:
  9744. return m.OldPhone(ctx)
  9745. }
  9746. return nil, fmt.Errorf("unknown Contact field %s", name)
  9747. }
  9748. // SetField sets the value of a field with the given name. It returns an error if
  9749. // the field is not defined in the schema, or if the type mismatched the field
  9750. // type.
  9751. func (m *ContactMutation) SetField(name string, value ent.Value) error {
  9752. switch name {
  9753. case contact.FieldCreatedAt:
  9754. v, ok := value.(time.Time)
  9755. if !ok {
  9756. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9757. }
  9758. m.SetCreatedAt(v)
  9759. return nil
  9760. case contact.FieldUpdatedAt:
  9761. v, ok := value.(time.Time)
  9762. if !ok {
  9763. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9764. }
  9765. m.SetUpdatedAt(v)
  9766. return nil
  9767. case contact.FieldStatus:
  9768. v, ok := value.(uint8)
  9769. if !ok {
  9770. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9771. }
  9772. m.SetStatus(v)
  9773. return nil
  9774. case contact.FieldDeletedAt:
  9775. v, ok := value.(time.Time)
  9776. if !ok {
  9777. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9778. }
  9779. m.SetDeletedAt(v)
  9780. return nil
  9781. case contact.FieldWxWxid:
  9782. v, ok := value.(string)
  9783. if !ok {
  9784. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9785. }
  9786. m.SetWxWxid(v)
  9787. return nil
  9788. case contact.FieldType:
  9789. v, ok := value.(int)
  9790. if !ok {
  9791. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9792. }
  9793. m.SetType(v)
  9794. return nil
  9795. case contact.FieldWxid:
  9796. v, ok := value.(string)
  9797. if !ok {
  9798. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9799. }
  9800. m.SetWxid(v)
  9801. return nil
  9802. case contact.FieldAccount:
  9803. v, ok := value.(string)
  9804. if !ok {
  9805. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9806. }
  9807. m.SetAccount(v)
  9808. return nil
  9809. case contact.FieldNickname:
  9810. v, ok := value.(string)
  9811. if !ok {
  9812. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9813. }
  9814. m.SetNickname(v)
  9815. return nil
  9816. case contact.FieldMarkname:
  9817. v, ok := value.(string)
  9818. if !ok {
  9819. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9820. }
  9821. m.SetMarkname(v)
  9822. return nil
  9823. case contact.FieldHeadimg:
  9824. v, ok := value.(string)
  9825. if !ok {
  9826. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9827. }
  9828. m.SetHeadimg(v)
  9829. return nil
  9830. case contact.FieldSex:
  9831. v, ok := value.(int)
  9832. if !ok {
  9833. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9834. }
  9835. m.SetSex(v)
  9836. return nil
  9837. case contact.FieldStarrole:
  9838. v, ok := value.(string)
  9839. if !ok {
  9840. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9841. }
  9842. m.SetStarrole(v)
  9843. return nil
  9844. case contact.FieldDontseeit:
  9845. v, ok := value.(int)
  9846. if !ok {
  9847. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9848. }
  9849. m.SetDontseeit(v)
  9850. return nil
  9851. case contact.FieldDontseeme:
  9852. v, ok := value.(int)
  9853. if !ok {
  9854. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9855. }
  9856. m.SetDontseeme(v)
  9857. return nil
  9858. case contact.FieldLag:
  9859. v, ok := value.(string)
  9860. if !ok {
  9861. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9862. }
  9863. m.SetLag(v)
  9864. return nil
  9865. case contact.FieldGid:
  9866. v, ok := value.(string)
  9867. if !ok {
  9868. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9869. }
  9870. m.SetGid(v)
  9871. return nil
  9872. case contact.FieldGname:
  9873. v, ok := value.(string)
  9874. if !ok {
  9875. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9876. }
  9877. m.SetGname(v)
  9878. return nil
  9879. case contact.FieldV3:
  9880. v, ok := value.(string)
  9881. if !ok {
  9882. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9883. }
  9884. m.SetV3(v)
  9885. return nil
  9886. case contact.FieldOrganizationID:
  9887. v, ok := value.(uint64)
  9888. if !ok {
  9889. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9890. }
  9891. m.SetOrganizationID(v)
  9892. return nil
  9893. case contact.FieldCtype:
  9894. v, ok := value.(uint64)
  9895. if !ok {
  9896. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9897. }
  9898. m.SetCtype(v)
  9899. return nil
  9900. case contact.FieldCage:
  9901. v, ok := value.(int)
  9902. if !ok {
  9903. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9904. }
  9905. m.SetCage(v)
  9906. return nil
  9907. case contact.FieldCname:
  9908. v, ok := value.(string)
  9909. if !ok {
  9910. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9911. }
  9912. m.SetCname(v)
  9913. return nil
  9914. case contact.FieldCarea:
  9915. v, ok := value.(string)
  9916. if !ok {
  9917. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9918. }
  9919. m.SetCarea(v)
  9920. return nil
  9921. case contact.FieldCbirthday:
  9922. v, ok := value.(string)
  9923. if !ok {
  9924. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9925. }
  9926. m.SetCbirthday(v)
  9927. return nil
  9928. case contact.FieldCbirtharea:
  9929. v, ok := value.(string)
  9930. if !ok {
  9931. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9932. }
  9933. m.SetCbirtharea(v)
  9934. return nil
  9935. case contact.FieldCidcardNo:
  9936. v, ok := value.(string)
  9937. if !ok {
  9938. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9939. }
  9940. m.SetCidcardNo(v)
  9941. return nil
  9942. case contact.FieldCtitle:
  9943. v, ok := value.(string)
  9944. if !ok {
  9945. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9946. }
  9947. m.SetCtitle(v)
  9948. return nil
  9949. case contact.FieldCc:
  9950. v, ok := value.(string)
  9951. if !ok {
  9952. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9953. }
  9954. m.SetCc(v)
  9955. return nil
  9956. case contact.FieldPhone:
  9957. v, ok := value.(string)
  9958. if !ok {
  9959. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9960. }
  9961. m.SetPhone(v)
  9962. return nil
  9963. }
  9964. return fmt.Errorf("unknown Contact field %s", name)
  9965. }
  9966. // AddedFields returns all numeric fields that were incremented/decremented during
  9967. // this mutation.
  9968. func (m *ContactMutation) AddedFields() []string {
  9969. var fields []string
  9970. if m.addstatus != nil {
  9971. fields = append(fields, contact.FieldStatus)
  9972. }
  9973. if m.add_type != nil {
  9974. fields = append(fields, contact.FieldType)
  9975. }
  9976. if m.addsex != nil {
  9977. fields = append(fields, contact.FieldSex)
  9978. }
  9979. if m.adddontseeit != nil {
  9980. fields = append(fields, contact.FieldDontseeit)
  9981. }
  9982. if m.adddontseeme != nil {
  9983. fields = append(fields, contact.FieldDontseeme)
  9984. }
  9985. if m.addorganization_id != nil {
  9986. fields = append(fields, contact.FieldOrganizationID)
  9987. }
  9988. if m.addctype != nil {
  9989. fields = append(fields, contact.FieldCtype)
  9990. }
  9991. if m.addcage != nil {
  9992. fields = append(fields, contact.FieldCage)
  9993. }
  9994. return fields
  9995. }
  9996. // AddedField returns the numeric value that was incremented/decremented on a field
  9997. // with the given name. The second boolean return value indicates that this field
  9998. // was not set, or was not defined in the schema.
  9999. func (m *ContactMutation) AddedField(name string) (ent.Value, bool) {
  10000. switch name {
  10001. case contact.FieldStatus:
  10002. return m.AddedStatus()
  10003. case contact.FieldType:
  10004. return m.AddedType()
  10005. case contact.FieldSex:
  10006. return m.AddedSex()
  10007. case contact.FieldDontseeit:
  10008. return m.AddedDontseeit()
  10009. case contact.FieldDontseeme:
  10010. return m.AddedDontseeme()
  10011. case contact.FieldOrganizationID:
  10012. return m.AddedOrganizationID()
  10013. case contact.FieldCtype:
  10014. return m.AddedCtype()
  10015. case contact.FieldCage:
  10016. return m.AddedCage()
  10017. }
  10018. return nil, false
  10019. }
  10020. // AddField adds the value to the field with the given name. It returns an error if
  10021. // the field is not defined in the schema, or if the type mismatched the field
  10022. // type.
  10023. func (m *ContactMutation) AddField(name string, value ent.Value) error {
  10024. switch name {
  10025. case contact.FieldStatus:
  10026. v, ok := value.(int8)
  10027. if !ok {
  10028. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10029. }
  10030. m.AddStatus(v)
  10031. return nil
  10032. case contact.FieldType:
  10033. v, ok := value.(int)
  10034. if !ok {
  10035. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10036. }
  10037. m.AddType(v)
  10038. return nil
  10039. case contact.FieldSex:
  10040. v, ok := value.(int)
  10041. if !ok {
  10042. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10043. }
  10044. m.AddSex(v)
  10045. return nil
  10046. case contact.FieldDontseeit:
  10047. v, ok := value.(int)
  10048. if !ok {
  10049. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10050. }
  10051. m.AddDontseeit(v)
  10052. return nil
  10053. case contact.FieldDontseeme:
  10054. v, ok := value.(int)
  10055. if !ok {
  10056. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10057. }
  10058. m.AddDontseeme(v)
  10059. return nil
  10060. case contact.FieldOrganizationID:
  10061. v, ok := value.(int64)
  10062. if !ok {
  10063. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10064. }
  10065. m.AddOrganizationID(v)
  10066. return nil
  10067. case contact.FieldCtype:
  10068. v, ok := value.(int64)
  10069. if !ok {
  10070. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10071. }
  10072. m.AddCtype(v)
  10073. return nil
  10074. case contact.FieldCage:
  10075. v, ok := value.(int)
  10076. if !ok {
  10077. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10078. }
  10079. m.AddCage(v)
  10080. return nil
  10081. }
  10082. return fmt.Errorf("unknown Contact numeric field %s", name)
  10083. }
  10084. // ClearedFields returns all nullable fields that were cleared during this
  10085. // mutation.
  10086. func (m *ContactMutation) ClearedFields() []string {
  10087. var fields []string
  10088. if m.FieldCleared(contact.FieldStatus) {
  10089. fields = append(fields, contact.FieldStatus)
  10090. }
  10091. if m.FieldCleared(contact.FieldDeletedAt) {
  10092. fields = append(fields, contact.FieldDeletedAt)
  10093. }
  10094. if m.FieldCleared(contact.FieldType) {
  10095. fields = append(fields, contact.FieldType)
  10096. }
  10097. if m.FieldCleared(contact.FieldOrganizationID) {
  10098. fields = append(fields, contact.FieldOrganizationID)
  10099. }
  10100. return fields
  10101. }
  10102. // FieldCleared returns a boolean indicating if a field with the given name was
  10103. // cleared in this mutation.
  10104. func (m *ContactMutation) FieldCleared(name string) bool {
  10105. _, ok := m.clearedFields[name]
  10106. return ok
  10107. }
  10108. // ClearField clears the value of the field with the given name. It returns an
  10109. // error if the field is not defined in the schema.
  10110. func (m *ContactMutation) ClearField(name string) error {
  10111. switch name {
  10112. case contact.FieldStatus:
  10113. m.ClearStatus()
  10114. return nil
  10115. case contact.FieldDeletedAt:
  10116. m.ClearDeletedAt()
  10117. return nil
  10118. case contact.FieldType:
  10119. m.ClearType()
  10120. return nil
  10121. case contact.FieldOrganizationID:
  10122. m.ClearOrganizationID()
  10123. return nil
  10124. }
  10125. return fmt.Errorf("unknown Contact nullable field %s", name)
  10126. }
  10127. // ResetField resets all changes in the mutation for the field with the given name.
  10128. // It returns an error if the field is not defined in the schema.
  10129. func (m *ContactMutation) ResetField(name string) error {
  10130. switch name {
  10131. case contact.FieldCreatedAt:
  10132. m.ResetCreatedAt()
  10133. return nil
  10134. case contact.FieldUpdatedAt:
  10135. m.ResetUpdatedAt()
  10136. return nil
  10137. case contact.FieldStatus:
  10138. m.ResetStatus()
  10139. return nil
  10140. case contact.FieldDeletedAt:
  10141. m.ResetDeletedAt()
  10142. return nil
  10143. case contact.FieldWxWxid:
  10144. m.ResetWxWxid()
  10145. return nil
  10146. case contact.FieldType:
  10147. m.ResetType()
  10148. return nil
  10149. case contact.FieldWxid:
  10150. m.ResetWxid()
  10151. return nil
  10152. case contact.FieldAccount:
  10153. m.ResetAccount()
  10154. return nil
  10155. case contact.FieldNickname:
  10156. m.ResetNickname()
  10157. return nil
  10158. case contact.FieldMarkname:
  10159. m.ResetMarkname()
  10160. return nil
  10161. case contact.FieldHeadimg:
  10162. m.ResetHeadimg()
  10163. return nil
  10164. case contact.FieldSex:
  10165. m.ResetSex()
  10166. return nil
  10167. case contact.FieldStarrole:
  10168. m.ResetStarrole()
  10169. return nil
  10170. case contact.FieldDontseeit:
  10171. m.ResetDontseeit()
  10172. return nil
  10173. case contact.FieldDontseeme:
  10174. m.ResetDontseeme()
  10175. return nil
  10176. case contact.FieldLag:
  10177. m.ResetLag()
  10178. return nil
  10179. case contact.FieldGid:
  10180. m.ResetGid()
  10181. return nil
  10182. case contact.FieldGname:
  10183. m.ResetGname()
  10184. return nil
  10185. case contact.FieldV3:
  10186. m.ResetV3()
  10187. return nil
  10188. case contact.FieldOrganizationID:
  10189. m.ResetOrganizationID()
  10190. return nil
  10191. case contact.FieldCtype:
  10192. m.ResetCtype()
  10193. return nil
  10194. case contact.FieldCage:
  10195. m.ResetCage()
  10196. return nil
  10197. case contact.FieldCname:
  10198. m.ResetCname()
  10199. return nil
  10200. case contact.FieldCarea:
  10201. m.ResetCarea()
  10202. return nil
  10203. case contact.FieldCbirthday:
  10204. m.ResetCbirthday()
  10205. return nil
  10206. case contact.FieldCbirtharea:
  10207. m.ResetCbirtharea()
  10208. return nil
  10209. case contact.FieldCidcardNo:
  10210. m.ResetCidcardNo()
  10211. return nil
  10212. case contact.FieldCtitle:
  10213. m.ResetCtitle()
  10214. return nil
  10215. case contact.FieldCc:
  10216. m.ResetCc()
  10217. return nil
  10218. case contact.FieldPhone:
  10219. m.ResetPhone()
  10220. return nil
  10221. }
  10222. return fmt.Errorf("unknown Contact field %s", name)
  10223. }
  10224. // AddedEdges returns all edge names that were set/added in this mutation.
  10225. func (m *ContactMutation) AddedEdges() []string {
  10226. edges := make([]string, 0, 2)
  10227. if m.contact_relationships != nil {
  10228. edges = append(edges, contact.EdgeContactRelationships)
  10229. }
  10230. if m.contact_messages != nil {
  10231. edges = append(edges, contact.EdgeContactMessages)
  10232. }
  10233. return edges
  10234. }
  10235. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  10236. // name in this mutation.
  10237. func (m *ContactMutation) AddedIDs(name string) []ent.Value {
  10238. switch name {
  10239. case contact.EdgeContactRelationships:
  10240. ids := make([]ent.Value, 0, len(m.contact_relationships))
  10241. for id := range m.contact_relationships {
  10242. ids = append(ids, id)
  10243. }
  10244. return ids
  10245. case contact.EdgeContactMessages:
  10246. ids := make([]ent.Value, 0, len(m.contact_messages))
  10247. for id := range m.contact_messages {
  10248. ids = append(ids, id)
  10249. }
  10250. return ids
  10251. }
  10252. return nil
  10253. }
  10254. // RemovedEdges returns all edge names that were removed in this mutation.
  10255. func (m *ContactMutation) RemovedEdges() []string {
  10256. edges := make([]string, 0, 2)
  10257. if m.removedcontact_relationships != nil {
  10258. edges = append(edges, contact.EdgeContactRelationships)
  10259. }
  10260. if m.removedcontact_messages != nil {
  10261. edges = append(edges, contact.EdgeContactMessages)
  10262. }
  10263. return edges
  10264. }
  10265. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  10266. // the given name in this mutation.
  10267. func (m *ContactMutation) RemovedIDs(name string) []ent.Value {
  10268. switch name {
  10269. case contact.EdgeContactRelationships:
  10270. ids := make([]ent.Value, 0, len(m.removedcontact_relationships))
  10271. for id := range m.removedcontact_relationships {
  10272. ids = append(ids, id)
  10273. }
  10274. return ids
  10275. case contact.EdgeContactMessages:
  10276. ids := make([]ent.Value, 0, len(m.removedcontact_messages))
  10277. for id := range m.removedcontact_messages {
  10278. ids = append(ids, id)
  10279. }
  10280. return ids
  10281. }
  10282. return nil
  10283. }
  10284. // ClearedEdges returns all edge names that were cleared in this mutation.
  10285. func (m *ContactMutation) ClearedEdges() []string {
  10286. edges := make([]string, 0, 2)
  10287. if m.clearedcontact_relationships {
  10288. edges = append(edges, contact.EdgeContactRelationships)
  10289. }
  10290. if m.clearedcontact_messages {
  10291. edges = append(edges, contact.EdgeContactMessages)
  10292. }
  10293. return edges
  10294. }
  10295. // EdgeCleared returns a boolean which indicates if the edge with the given name
  10296. // was cleared in this mutation.
  10297. func (m *ContactMutation) EdgeCleared(name string) bool {
  10298. switch name {
  10299. case contact.EdgeContactRelationships:
  10300. return m.clearedcontact_relationships
  10301. case contact.EdgeContactMessages:
  10302. return m.clearedcontact_messages
  10303. }
  10304. return false
  10305. }
  10306. // ClearEdge clears the value of the edge with the given name. It returns an error
  10307. // if that edge is not defined in the schema.
  10308. func (m *ContactMutation) ClearEdge(name string) error {
  10309. switch name {
  10310. }
  10311. return fmt.Errorf("unknown Contact unique edge %s", name)
  10312. }
  10313. // ResetEdge resets all changes to the edge with the given name in this mutation.
  10314. // It returns an error if the edge is not defined in the schema.
  10315. func (m *ContactMutation) ResetEdge(name string) error {
  10316. switch name {
  10317. case contact.EdgeContactRelationships:
  10318. m.ResetContactRelationships()
  10319. return nil
  10320. case contact.EdgeContactMessages:
  10321. m.ResetContactMessages()
  10322. return nil
  10323. }
  10324. return fmt.Errorf("unknown Contact edge %s", name)
  10325. }
  10326. // CreditBalanceMutation represents an operation that mutates the CreditBalance nodes in the graph.
  10327. type CreditBalanceMutation struct {
  10328. config
  10329. op Op
  10330. typ string
  10331. id *uint64
  10332. created_at *time.Time
  10333. updated_at *time.Time
  10334. deleted_at *time.Time
  10335. user_id *string
  10336. balance *float32
  10337. addbalance *float32
  10338. status *int
  10339. addstatus *int
  10340. organization_id *uint64
  10341. addorganization_id *int64
  10342. clearedFields map[string]struct{}
  10343. done bool
  10344. oldValue func(context.Context) (*CreditBalance, error)
  10345. predicates []predicate.CreditBalance
  10346. }
  10347. var _ ent.Mutation = (*CreditBalanceMutation)(nil)
  10348. // creditbalanceOption allows management of the mutation configuration using functional options.
  10349. type creditbalanceOption func(*CreditBalanceMutation)
  10350. // newCreditBalanceMutation creates new mutation for the CreditBalance entity.
  10351. func newCreditBalanceMutation(c config, op Op, opts ...creditbalanceOption) *CreditBalanceMutation {
  10352. m := &CreditBalanceMutation{
  10353. config: c,
  10354. op: op,
  10355. typ: TypeCreditBalance,
  10356. clearedFields: make(map[string]struct{}),
  10357. }
  10358. for _, opt := range opts {
  10359. opt(m)
  10360. }
  10361. return m
  10362. }
  10363. // withCreditBalanceID sets the ID field of the mutation.
  10364. func withCreditBalanceID(id uint64) creditbalanceOption {
  10365. return func(m *CreditBalanceMutation) {
  10366. var (
  10367. err error
  10368. once sync.Once
  10369. value *CreditBalance
  10370. )
  10371. m.oldValue = func(ctx context.Context) (*CreditBalance, error) {
  10372. once.Do(func() {
  10373. if m.done {
  10374. err = errors.New("querying old values post mutation is not allowed")
  10375. } else {
  10376. value, err = m.Client().CreditBalance.Get(ctx, id)
  10377. }
  10378. })
  10379. return value, err
  10380. }
  10381. m.id = &id
  10382. }
  10383. }
  10384. // withCreditBalance sets the old CreditBalance of the mutation.
  10385. func withCreditBalance(node *CreditBalance) creditbalanceOption {
  10386. return func(m *CreditBalanceMutation) {
  10387. m.oldValue = func(context.Context) (*CreditBalance, error) {
  10388. return node, nil
  10389. }
  10390. m.id = &node.ID
  10391. }
  10392. }
  10393. // Client returns a new `ent.Client` from the mutation. If the mutation was
  10394. // executed in a transaction (ent.Tx), a transactional client is returned.
  10395. func (m CreditBalanceMutation) Client() *Client {
  10396. client := &Client{config: m.config}
  10397. client.init()
  10398. return client
  10399. }
  10400. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  10401. // it returns an error otherwise.
  10402. func (m CreditBalanceMutation) Tx() (*Tx, error) {
  10403. if _, ok := m.driver.(*txDriver); !ok {
  10404. return nil, errors.New("ent: mutation is not running in a transaction")
  10405. }
  10406. tx := &Tx{config: m.config}
  10407. tx.init()
  10408. return tx, nil
  10409. }
  10410. // SetID sets the value of the id field. Note that this
  10411. // operation is only accepted on creation of CreditBalance entities.
  10412. func (m *CreditBalanceMutation) SetID(id uint64) {
  10413. m.id = &id
  10414. }
  10415. // ID returns the ID value in the mutation. Note that the ID is only available
  10416. // if it was provided to the builder or after it was returned from the database.
  10417. func (m *CreditBalanceMutation) ID() (id uint64, exists bool) {
  10418. if m.id == nil {
  10419. return
  10420. }
  10421. return *m.id, true
  10422. }
  10423. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  10424. // That means, if the mutation is applied within a transaction with an isolation level such
  10425. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  10426. // or updated by the mutation.
  10427. func (m *CreditBalanceMutation) IDs(ctx context.Context) ([]uint64, error) {
  10428. switch {
  10429. case m.op.Is(OpUpdateOne | OpDeleteOne):
  10430. id, exists := m.ID()
  10431. if exists {
  10432. return []uint64{id}, nil
  10433. }
  10434. fallthrough
  10435. case m.op.Is(OpUpdate | OpDelete):
  10436. return m.Client().CreditBalance.Query().Where(m.predicates...).IDs(ctx)
  10437. default:
  10438. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  10439. }
  10440. }
  10441. // SetCreatedAt sets the "created_at" field.
  10442. func (m *CreditBalanceMutation) SetCreatedAt(t time.Time) {
  10443. m.created_at = &t
  10444. }
  10445. // CreatedAt returns the value of the "created_at" field in the mutation.
  10446. func (m *CreditBalanceMutation) CreatedAt() (r time.Time, exists bool) {
  10447. v := m.created_at
  10448. if v == nil {
  10449. return
  10450. }
  10451. return *v, true
  10452. }
  10453. // OldCreatedAt returns the old "created_at" 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) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  10457. if !m.op.Is(OpUpdateOne) {
  10458. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  10459. }
  10460. if m.id == nil || m.oldValue == nil {
  10461. return v, errors.New("OldCreatedAt 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 OldCreatedAt: %w", err)
  10466. }
  10467. return oldValue.CreatedAt, nil
  10468. }
  10469. // ResetCreatedAt resets all changes to the "created_at" field.
  10470. func (m *CreditBalanceMutation) ResetCreatedAt() {
  10471. m.created_at = nil
  10472. }
  10473. // SetUpdatedAt sets the "updated_at" field.
  10474. func (m *CreditBalanceMutation) SetUpdatedAt(t time.Time) {
  10475. m.updated_at = &t
  10476. }
  10477. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  10478. func (m *CreditBalanceMutation) UpdatedAt() (r time.Time, exists bool) {
  10479. v := m.updated_at
  10480. if v == nil {
  10481. return
  10482. }
  10483. return *v, true
  10484. }
  10485. // OldUpdatedAt returns the old "updated_at" field's value of the CreditBalance entity.
  10486. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  10487. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10488. func (m *CreditBalanceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  10489. if !m.op.Is(OpUpdateOne) {
  10490. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  10491. }
  10492. if m.id == nil || m.oldValue == nil {
  10493. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  10494. }
  10495. oldValue, err := m.oldValue(ctx)
  10496. if err != nil {
  10497. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  10498. }
  10499. return oldValue.UpdatedAt, nil
  10500. }
  10501. // ResetUpdatedAt resets all changes to the "updated_at" field.
  10502. func (m *CreditBalanceMutation) ResetUpdatedAt() {
  10503. m.updated_at = nil
  10504. }
  10505. // SetDeletedAt sets the "deleted_at" field.
  10506. func (m *CreditBalanceMutation) SetDeletedAt(t time.Time) {
  10507. m.deleted_at = &t
  10508. }
  10509. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  10510. func (m *CreditBalanceMutation) DeletedAt() (r time.Time, exists bool) {
  10511. v := m.deleted_at
  10512. if v == nil {
  10513. return
  10514. }
  10515. return *v, true
  10516. }
  10517. // OldDeletedAt returns the old "deleted_at" field's value of the CreditBalance entity.
  10518. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  10519. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10520. func (m *CreditBalanceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  10521. if !m.op.Is(OpUpdateOne) {
  10522. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  10523. }
  10524. if m.id == nil || m.oldValue == nil {
  10525. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  10526. }
  10527. oldValue, err := m.oldValue(ctx)
  10528. if err != nil {
  10529. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  10530. }
  10531. return oldValue.DeletedAt, nil
  10532. }
  10533. // ClearDeletedAt clears the value of the "deleted_at" field.
  10534. func (m *CreditBalanceMutation) ClearDeletedAt() {
  10535. m.deleted_at = nil
  10536. m.clearedFields[creditbalance.FieldDeletedAt] = struct{}{}
  10537. }
  10538. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  10539. func (m *CreditBalanceMutation) DeletedAtCleared() bool {
  10540. _, ok := m.clearedFields[creditbalance.FieldDeletedAt]
  10541. return ok
  10542. }
  10543. // ResetDeletedAt resets all changes to the "deleted_at" field.
  10544. func (m *CreditBalanceMutation) ResetDeletedAt() {
  10545. m.deleted_at = nil
  10546. delete(m.clearedFields, creditbalance.FieldDeletedAt)
  10547. }
  10548. // SetUserID sets the "user_id" field.
  10549. func (m *CreditBalanceMutation) SetUserID(s string) {
  10550. m.user_id = &s
  10551. }
  10552. // UserID returns the value of the "user_id" field in the mutation.
  10553. func (m *CreditBalanceMutation) UserID() (r string, exists bool) {
  10554. v := m.user_id
  10555. if v == nil {
  10556. return
  10557. }
  10558. return *v, true
  10559. }
  10560. // OldUserID returns the old "user_id" field's value of the CreditBalance entity.
  10561. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  10562. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10563. func (m *CreditBalanceMutation) OldUserID(ctx context.Context) (v string, err error) {
  10564. if !m.op.Is(OpUpdateOne) {
  10565. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  10566. }
  10567. if m.id == nil || m.oldValue == nil {
  10568. return v, errors.New("OldUserID requires an ID field in the mutation")
  10569. }
  10570. oldValue, err := m.oldValue(ctx)
  10571. if err != nil {
  10572. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  10573. }
  10574. return oldValue.UserID, nil
  10575. }
  10576. // ClearUserID clears the value of the "user_id" field.
  10577. func (m *CreditBalanceMutation) ClearUserID() {
  10578. m.user_id = nil
  10579. m.clearedFields[creditbalance.FieldUserID] = struct{}{}
  10580. }
  10581. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  10582. func (m *CreditBalanceMutation) UserIDCleared() bool {
  10583. _, ok := m.clearedFields[creditbalance.FieldUserID]
  10584. return ok
  10585. }
  10586. // ResetUserID resets all changes to the "user_id" field.
  10587. func (m *CreditBalanceMutation) ResetUserID() {
  10588. m.user_id = nil
  10589. delete(m.clearedFields, creditbalance.FieldUserID)
  10590. }
  10591. // SetBalance sets the "balance" field.
  10592. func (m *CreditBalanceMutation) SetBalance(f float32) {
  10593. m.balance = &f
  10594. m.addbalance = nil
  10595. }
  10596. // Balance returns the value of the "balance" field in the mutation.
  10597. func (m *CreditBalanceMutation) Balance() (r float32, exists bool) {
  10598. v := m.balance
  10599. if v == nil {
  10600. return
  10601. }
  10602. return *v, true
  10603. }
  10604. // OldBalance returns the old "balance" field's value of the CreditBalance entity.
  10605. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  10606. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10607. func (m *CreditBalanceMutation) OldBalance(ctx context.Context) (v float32, err error) {
  10608. if !m.op.Is(OpUpdateOne) {
  10609. return v, errors.New("OldBalance is only allowed on UpdateOne operations")
  10610. }
  10611. if m.id == nil || m.oldValue == nil {
  10612. return v, errors.New("OldBalance requires an ID field in the mutation")
  10613. }
  10614. oldValue, err := m.oldValue(ctx)
  10615. if err != nil {
  10616. return v, fmt.Errorf("querying old value for OldBalance: %w", err)
  10617. }
  10618. return oldValue.Balance, nil
  10619. }
  10620. // AddBalance adds f to the "balance" field.
  10621. func (m *CreditBalanceMutation) AddBalance(f float32) {
  10622. if m.addbalance != nil {
  10623. *m.addbalance += f
  10624. } else {
  10625. m.addbalance = &f
  10626. }
  10627. }
  10628. // AddedBalance returns the value that was added to the "balance" field in this mutation.
  10629. func (m *CreditBalanceMutation) AddedBalance() (r float32, exists bool) {
  10630. v := m.addbalance
  10631. if v == nil {
  10632. return
  10633. }
  10634. return *v, true
  10635. }
  10636. // ResetBalance resets all changes to the "balance" field.
  10637. func (m *CreditBalanceMutation) ResetBalance() {
  10638. m.balance = nil
  10639. m.addbalance = nil
  10640. }
  10641. // SetStatus sets the "status" field.
  10642. func (m *CreditBalanceMutation) SetStatus(i int) {
  10643. m.status = &i
  10644. m.addstatus = nil
  10645. }
  10646. // Status returns the value of the "status" field in the mutation.
  10647. func (m *CreditBalanceMutation) Status() (r int, exists bool) {
  10648. v := m.status
  10649. if v == nil {
  10650. return
  10651. }
  10652. return *v, true
  10653. }
  10654. // OldStatus returns the old "status" field's value of the CreditBalance entity.
  10655. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  10656. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10657. func (m *CreditBalanceMutation) OldStatus(ctx context.Context) (v int, err error) {
  10658. if !m.op.Is(OpUpdateOne) {
  10659. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  10660. }
  10661. if m.id == nil || m.oldValue == nil {
  10662. return v, errors.New("OldStatus requires an ID field in the mutation")
  10663. }
  10664. oldValue, err := m.oldValue(ctx)
  10665. if err != nil {
  10666. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  10667. }
  10668. return oldValue.Status, nil
  10669. }
  10670. // AddStatus adds i to the "status" field.
  10671. func (m *CreditBalanceMutation) AddStatus(i int) {
  10672. if m.addstatus != nil {
  10673. *m.addstatus += i
  10674. } else {
  10675. m.addstatus = &i
  10676. }
  10677. }
  10678. // AddedStatus returns the value that was added to the "status" field in this mutation.
  10679. func (m *CreditBalanceMutation) AddedStatus() (r int, exists bool) {
  10680. v := m.addstatus
  10681. if v == nil {
  10682. return
  10683. }
  10684. return *v, true
  10685. }
  10686. // ClearStatus clears the value of the "status" field.
  10687. func (m *CreditBalanceMutation) ClearStatus() {
  10688. m.status = nil
  10689. m.addstatus = nil
  10690. m.clearedFields[creditbalance.FieldStatus] = struct{}{}
  10691. }
  10692. // StatusCleared returns if the "status" field was cleared in this mutation.
  10693. func (m *CreditBalanceMutation) StatusCleared() bool {
  10694. _, ok := m.clearedFields[creditbalance.FieldStatus]
  10695. return ok
  10696. }
  10697. // ResetStatus resets all changes to the "status" field.
  10698. func (m *CreditBalanceMutation) ResetStatus() {
  10699. m.status = nil
  10700. m.addstatus = nil
  10701. delete(m.clearedFields, creditbalance.FieldStatus)
  10702. }
  10703. // SetOrganizationID sets the "organization_id" field.
  10704. func (m *CreditBalanceMutation) SetOrganizationID(u uint64) {
  10705. m.organization_id = &u
  10706. m.addorganization_id = nil
  10707. }
  10708. // OrganizationID returns the value of the "organization_id" field in the mutation.
  10709. func (m *CreditBalanceMutation) OrganizationID() (r uint64, exists bool) {
  10710. v := m.organization_id
  10711. if v == nil {
  10712. return
  10713. }
  10714. return *v, true
  10715. }
  10716. // OldOrganizationID returns the old "organization_id" field's value of the CreditBalance entity.
  10717. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  10718. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10719. func (m *CreditBalanceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  10720. if !m.op.Is(OpUpdateOne) {
  10721. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  10722. }
  10723. if m.id == nil || m.oldValue == nil {
  10724. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  10725. }
  10726. oldValue, err := m.oldValue(ctx)
  10727. if err != nil {
  10728. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  10729. }
  10730. return oldValue.OrganizationID, nil
  10731. }
  10732. // AddOrganizationID adds u to the "organization_id" field.
  10733. func (m *CreditBalanceMutation) AddOrganizationID(u int64) {
  10734. if m.addorganization_id != nil {
  10735. *m.addorganization_id += u
  10736. } else {
  10737. m.addorganization_id = &u
  10738. }
  10739. }
  10740. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  10741. func (m *CreditBalanceMutation) AddedOrganizationID() (r int64, exists bool) {
  10742. v := m.addorganization_id
  10743. if v == nil {
  10744. return
  10745. }
  10746. return *v, true
  10747. }
  10748. // ClearOrganizationID clears the value of the "organization_id" field.
  10749. func (m *CreditBalanceMutation) ClearOrganizationID() {
  10750. m.organization_id = nil
  10751. m.addorganization_id = nil
  10752. m.clearedFields[creditbalance.FieldOrganizationID] = struct{}{}
  10753. }
  10754. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  10755. func (m *CreditBalanceMutation) OrganizationIDCleared() bool {
  10756. _, ok := m.clearedFields[creditbalance.FieldOrganizationID]
  10757. return ok
  10758. }
  10759. // ResetOrganizationID resets all changes to the "organization_id" field.
  10760. func (m *CreditBalanceMutation) ResetOrganizationID() {
  10761. m.organization_id = nil
  10762. m.addorganization_id = nil
  10763. delete(m.clearedFields, creditbalance.FieldOrganizationID)
  10764. }
  10765. // Where appends a list predicates to the CreditBalanceMutation builder.
  10766. func (m *CreditBalanceMutation) Where(ps ...predicate.CreditBalance) {
  10767. m.predicates = append(m.predicates, ps...)
  10768. }
  10769. // WhereP appends storage-level predicates to the CreditBalanceMutation builder. Using this method,
  10770. // users can use type-assertion to append predicates that do not depend on any generated package.
  10771. func (m *CreditBalanceMutation) WhereP(ps ...func(*sql.Selector)) {
  10772. p := make([]predicate.CreditBalance, len(ps))
  10773. for i := range ps {
  10774. p[i] = ps[i]
  10775. }
  10776. m.Where(p...)
  10777. }
  10778. // Op returns the operation name.
  10779. func (m *CreditBalanceMutation) Op() Op {
  10780. return m.op
  10781. }
  10782. // SetOp allows setting the mutation operation.
  10783. func (m *CreditBalanceMutation) SetOp(op Op) {
  10784. m.op = op
  10785. }
  10786. // Type returns the node type of this mutation (CreditBalance).
  10787. func (m *CreditBalanceMutation) Type() string {
  10788. return m.typ
  10789. }
  10790. // Fields returns all fields that were changed during this mutation. Note that in
  10791. // order to get all numeric fields that were incremented/decremented, call
  10792. // AddedFields().
  10793. func (m *CreditBalanceMutation) Fields() []string {
  10794. fields := make([]string, 0, 7)
  10795. if m.created_at != nil {
  10796. fields = append(fields, creditbalance.FieldCreatedAt)
  10797. }
  10798. if m.updated_at != nil {
  10799. fields = append(fields, creditbalance.FieldUpdatedAt)
  10800. }
  10801. if m.deleted_at != nil {
  10802. fields = append(fields, creditbalance.FieldDeletedAt)
  10803. }
  10804. if m.user_id != nil {
  10805. fields = append(fields, creditbalance.FieldUserID)
  10806. }
  10807. if m.balance != nil {
  10808. fields = append(fields, creditbalance.FieldBalance)
  10809. }
  10810. if m.status != nil {
  10811. fields = append(fields, creditbalance.FieldStatus)
  10812. }
  10813. if m.organization_id != nil {
  10814. fields = append(fields, creditbalance.FieldOrganizationID)
  10815. }
  10816. return fields
  10817. }
  10818. // Field returns the value of a field with the given name. The second boolean
  10819. // return value indicates that this field was not set, or was not defined in the
  10820. // schema.
  10821. func (m *CreditBalanceMutation) Field(name string) (ent.Value, bool) {
  10822. switch name {
  10823. case creditbalance.FieldCreatedAt:
  10824. return m.CreatedAt()
  10825. case creditbalance.FieldUpdatedAt:
  10826. return m.UpdatedAt()
  10827. case creditbalance.FieldDeletedAt:
  10828. return m.DeletedAt()
  10829. case creditbalance.FieldUserID:
  10830. return m.UserID()
  10831. case creditbalance.FieldBalance:
  10832. return m.Balance()
  10833. case creditbalance.FieldStatus:
  10834. return m.Status()
  10835. case creditbalance.FieldOrganizationID:
  10836. return m.OrganizationID()
  10837. }
  10838. return nil, false
  10839. }
  10840. // OldField returns the old value of the field from the database. An error is
  10841. // returned if the mutation operation is not UpdateOne, or the query to the
  10842. // database failed.
  10843. func (m *CreditBalanceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  10844. switch name {
  10845. case creditbalance.FieldCreatedAt:
  10846. return m.OldCreatedAt(ctx)
  10847. case creditbalance.FieldUpdatedAt:
  10848. return m.OldUpdatedAt(ctx)
  10849. case creditbalance.FieldDeletedAt:
  10850. return m.OldDeletedAt(ctx)
  10851. case creditbalance.FieldUserID:
  10852. return m.OldUserID(ctx)
  10853. case creditbalance.FieldBalance:
  10854. return m.OldBalance(ctx)
  10855. case creditbalance.FieldStatus:
  10856. return m.OldStatus(ctx)
  10857. case creditbalance.FieldOrganizationID:
  10858. return m.OldOrganizationID(ctx)
  10859. }
  10860. return nil, fmt.Errorf("unknown CreditBalance field %s", name)
  10861. }
  10862. // SetField sets the value of a field with the given name. It returns an error if
  10863. // the field is not defined in the schema, or if the type mismatched the field
  10864. // type.
  10865. func (m *CreditBalanceMutation) SetField(name string, value ent.Value) error {
  10866. switch name {
  10867. case creditbalance.FieldCreatedAt:
  10868. v, ok := value.(time.Time)
  10869. if !ok {
  10870. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10871. }
  10872. m.SetCreatedAt(v)
  10873. return nil
  10874. case creditbalance.FieldUpdatedAt:
  10875. v, ok := value.(time.Time)
  10876. if !ok {
  10877. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10878. }
  10879. m.SetUpdatedAt(v)
  10880. return nil
  10881. case creditbalance.FieldDeletedAt:
  10882. v, ok := value.(time.Time)
  10883. if !ok {
  10884. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10885. }
  10886. m.SetDeletedAt(v)
  10887. return nil
  10888. case creditbalance.FieldUserID:
  10889. v, ok := value.(string)
  10890. if !ok {
  10891. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10892. }
  10893. m.SetUserID(v)
  10894. return nil
  10895. case creditbalance.FieldBalance:
  10896. v, ok := value.(float32)
  10897. if !ok {
  10898. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10899. }
  10900. m.SetBalance(v)
  10901. return nil
  10902. case creditbalance.FieldStatus:
  10903. v, ok := value.(int)
  10904. if !ok {
  10905. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10906. }
  10907. m.SetStatus(v)
  10908. return nil
  10909. case creditbalance.FieldOrganizationID:
  10910. v, ok := value.(uint64)
  10911. if !ok {
  10912. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10913. }
  10914. m.SetOrganizationID(v)
  10915. return nil
  10916. }
  10917. return fmt.Errorf("unknown CreditBalance field %s", name)
  10918. }
  10919. // AddedFields returns all numeric fields that were incremented/decremented during
  10920. // this mutation.
  10921. func (m *CreditBalanceMutation) AddedFields() []string {
  10922. var fields []string
  10923. if m.addbalance != nil {
  10924. fields = append(fields, creditbalance.FieldBalance)
  10925. }
  10926. if m.addstatus != nil {
  10927. fields = append(fields, creditbalance.FieldStatus)
  10928. }
  10929. if m.addorganization_id != nil {
  10930. fields = append(fields, creditbalance.FieldOrganizationID)
  10931. }
  10932. return fields
  10933. }
  10934. // AddedField returns the numeric value that was incremented/decremented on a field
  10935. // with the given name. The second boolean return value indicates that this field
  10936. // was not set, or was not defined in the schema.
  10937. func (m *CreditBalanceMutation) AddedField(name string) (ent.Value, bool) {
  10938. switch name {
  10939. case creditbalance.FieldBalance:
  10940. return m.AddedBalance()
  10941. case creditbalance.FieldStatus:
  10942. return m.AddedStatus()
  10943. case creditbalance.FieldOrganizationID:
  10944. return m.AddedOrganizationID()
  10945. }
  10946. return nil, false
  10947. }
  10948. // AddField adds the value to the field with the given name. It returns an error if
  10949. // the field is not defined in the schema, or if the type mismatched the field
  10950. // type.
  10951. func (m *CreditBalanceMutation) AddField(name string, value ent.Value) error {
  10952. switch name {
  10953. case creditbalance.FieldBalance:
  10954. v, ok := value.(float32)
  10955. if !ok {
  10956. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10957. }
  10958. m.AddBalance(v)
  10959. return nil
  10960. case creditbalance.FieldStatus:
  10961. v, ok := value.(int)
  10962. if !ok {
  10963. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10964. }
  10965. m.AddStatus(v)
  10966. return nil
  10967. case creditbalance.FieldOrganizationID:
  10968. v, ok := value.(int64)
  10969. if !ok {
  10970. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10971. }
  10972. m.AddOrganizationID(v)
  10973. return nil
  10974. }
  10975. return fmt.Errorf("unknown CreditBalance numeric field %s", name)
  10976. }
  10977. // ClearedFields returns all nullable fields that were cleared during this
  10978. // mutation.
  10979. func (m *CreditBalanceMutation) ClearedFields() []string {
  10980. var fields []string
  10981. if m.FieldCleared(creditbalance.FieldDeletedAt) {
  10982. fields = append(fields, creditbalance.FieldDeletedAt)
  10983. }
  10984. if m.FieldCleared(creditbalance.FieldUserID) {
  10985. fields = append(fields, creditbalance.FieldUserID)
  10986. }
  10987. if m.FieldCleared(creditbalance.FieldStatus) {
  10988. fields = append(fields, creditbalance.FieldStatus)
  10989. }
  10990. if m.FieldCleared(creditbalance.FieldOrganizationID) {
  10991. fields = append(fields, creditbalance.FieldOrganizationID)
  10992. }
  10993. return fields
  10994. }
  10995. // FieldCleared returns a boolean indicating if a field with the given name was
  10996. // cleared in this mutation.
  10997. func (m *CreditBalanceMutation) FieldCleared(name string) bool {
  10998. _, ok := m.clearedFields[name]
  10999. return ok
  11000. }
  11001. // ClearField clears the value of the field with the given name. It returns an
  11002. // error if the field is not defined in the schema.
  11003. func (m *CreditBalanceMutation) ClearField(name string) error {
  11004. switch name {
  11005. case creditbalance.FieldDeletedAt:
  11006. m.ClearDeletedAt()
  11007. return nil
  11008. case creditbalance.FieldUserID:
  11009. m.ClearUserID()
  11010. return nil
  11011. case creditbalance.FieldStatus:
  11012. m.ClearStatus()
  11013. return nil
  11014. case creditbalance.FieldOrganizationID:
  11015. m.ClearOrganizationID()
  11016. return nil
  11017. }
  11018. return fmt.Errorf("unknown CreditBalance nullable field %s", name)
  11019. }
  11020. // ResetField resets all changes in the mutation for the field with the given name.
  11021. // It returns an error if the field is not defined in the schema.
  11022. func (m *CreditBalanceMutation) ResetField(name string) error {
  11023. switch name {
  11024. case creditbalance.FieldCreatedAt:
  11025. m.ResetCreatedAt()
  11026. return nil
  11027. case creditbalance.FieldUpdatedAt:
  11028. m.ResetUpdatedAt()
  11029. return nil
  11030. case creditbalance.FieldDeletedAt:
  11031. m.ResetDeletedAt()
  11032. return nil
  11033. case creditbalance.FieldUserID:
  11034. m.ResetUserID()
  11035. return nil
  11036. case creditbalance.FieldBalance:
  11037. m.ResetBalance()
  11038. return nil
  11039. case creditbalance.FieldStatus:
  11040. m.ResetStatus()
  11041. return nil
  11042. case creditbalance.FieldOrganizationID:
  11043. m.ResetOrganizationID()
  11044. return nil
  11045. }
  11046. return fmt.Errorf("unknown CreditBalance field %s", name)
  11047. }
  11048. // AddedEdges returns all edge names that were set/added in this mutation.
  11049. func (m *CreditBalanceMutation) AddedEdges() []string {
  11050. edges := make([]string, 0, 0)
  11051. return edges
  11052. }
  11053. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  11054. // name in this mutation.
  11055. func (m *CreditBalanceMutation) AddedIDs(name string) []ent.Value {
  11056. return nil
  11057. }
  11058. // RemovedEdges returns all edge names that were removed in this mutation.
  11059. func (m *CreditBalanceMutation) RemovedEdges() []string {
  11060. edges := make([]string, 0, 0)
  11061. return edges
  11062. }
  11063. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  11064. // the given name in this mutation.
  11065. func (m *CreditBalanceMutation) RemovedIDs(name string) []ent.Value {
  11066. return nil
  11067. }
  11068. // ClearedEdges returns all edge names that were cleared in this mutation.
  11069. func (m *CreditBalanceMutation) ClearedEdges() []string {
  11070. edges := make([]string, 0, 0)
  11071. return edges
  11072. }
  11073. // EdgeCleared returns a boolean which indicates if the edge with the given name
  11074. // was cleared in this mutation.
  11075. func (m *CreditBalanceMutation) EdgeCleared(name string) bool {
  11076. return false
  11077. }
  11078. // ClearEdge clears the value of the edge with the given name. It returns an error
  11079. // if that edge is not defined in the schema.
  11080. func (m *CreditBalanceMutation) ClearEdge(name string) error {
  11081. return fmt.Errorf("unknown CreditBalance unique edge %s", name)
  11082. }
  11083. // ResetEdge resets all changes to the edge with the given name in this mutation.
  11084. // It returns an error if the edge is not defined in the schema.
  11085. func (m *CreditBalanceMutation) ResetEdge(name string) error {
  11086. return fmt.Errorf("unknown CreditBalance edge %s", name)
  11087. }
  11088. // CreditUsageMutation represents an operation that mutates the CreditUsage nodes in the graph.
  11089. type CreditUsageMutation struct {
  11090. config
  11091. op Op
  11092. typ string
  11093. id *uint64
  11094. created_at *time.Time
  11095. updated_at *time.Time
  11096. deleted_at *time.Time
  11097. user_id *string
  11098. number *float32
  11099. addnumber *float32
  11100. status *int
  11101. addstatus *int
  11102. ntype *int
  11103. addntype *int
  11104. table *string
  11105. organization_id *uint64
  11106. addorganization_id *int64
  11107. nid *uint64
  11108. addnid *int64
  11109. reason *string
  11110. operator *string
  11111. clearedFields map[string]struct{}
  11112. done bool
  11113. oldValue func(context.Context) (*CreditUsage, error)
  11114. predicates []predicate.CreditUsage
  11115. }
  11116. var _ ent.Mutation = (*CreditUsageMutation)(nil)
  11117. // creditusageOption allows management of the mutation configuration using functional options.
  11118. type creditusageOption func(*CreditUsageMutation)
  11119. // newCreditUsageMutation creates new mutation for the CreditUsage entity.
  11120. func newCreditUsageMutation(c config, op Op, opts ...creditusageOption) *CreditUsageMutation {
  11121. m := &CreditUsageMutation{
  11122. config: c,
  11123. op: op,
  11124. typ: TypeCreditUsage,
  11125. clearedFields: make(map[string]struct{}),
  11126. }
  11127. for _, opt := range opts {
  11128. opt(m)
  11129. }
  11130. return m
  11131. }
  11132. // withCreditUsageID sets the ID field of the mutation.
  11133. func withCreditUsageID(id uint64) creditusageOption {
  11134. return func(m *CreditUsageMutation) {
  11135. var (
  11136. err error
  11137. once sync.Once
  11138. value *CreditUsage
  11139. )
  11140. m.oldValue = func(ctx context.Context) (*CreditUsage, error) {
  11141. once.Do(func() {
  11142. if m.done {
  11143. err = errors.New("querying old values post mutation is not allowed")
  11144. } else {
  11145. value, err = m.Client().CreditUsage.Get(ctx, id)
  11146. }
  11147. })
  11148. return value, err
  11149. }
  11150. m.id = &id
  11151. }
  11152. }
  11153. // withCreditUsage sets the old CreditUsage of the mutation.
  11154. func withCreditUsage(node *CreditUsage) creditusageOption {
  11155. return func(m *CreditUsageMutation) {
  11156. m.oldValue = func(context.Context) (*CreditUsage, error) {
  11157. return node, nil
  11158. }
  11159. m.id = &node.ID
  11160. }
  11161. }
  11162. // Client returns a new `ent.Client` from the mutation. If the mutation was
  11163. // executed in a transaction (ent.Tx), a transactional client is returned.
  11164. func (m CreditUsageMutation) Client() *Client {
  11165. client := &Client{config: m.config}
  11166. client.init()
  11167. return client
  11168. }
  11169. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  11170. // it returns an error otherwise.
  11171. func (m CreditUsageMutation) Tx() (*Tx, error) {
  11172. if _, ok := m.driver.(*txDriver); !ok {
  11173. return nil, errors.New("ent: mutation is not running in a transaction")
  11174. }
  11175. tx := &Tx{config: m.config}
  11176. tx.init()
  11177. return tx, nil
  11178. }
  11179. // SetID sets the value of the id field. Note that this
  11180. // operation is only accepted on creation of CreditUsage entities.
  11181. func (m *CreditUsageMutation) SetID(id uint64) {
  11182. m.id = &id
  11183. }
  11184. // ID returns the ID value in the mutation. Note that the ID is only available
  11185. // if it was provided to the builder or after it was returned from the database.
  11186. func (m *CreditUsageMutation) ID() (id uint64, exists bool) {
  11187. if m.id == nil {
  11188. return
  11189. }
  11190. return *m.id, true
  11191. }
  11192. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  11193. // That means, if the mutation is applied within a transaction with an isolation level such
  11194. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  11195. // or updated by the mutation.
  11196. func (m *CreditUsageMutation) IDs(ctx context.Context) ([]uint64, error) {
  11197. switch {
  11198. case m.op.Is(OpUpdateOne | OpDeleteOne):
  11199. id, exists := m.ID()
  11200. if exists {
  11201. return []uint64{id}, nil
  11202. }
  11203. fallthrough
  11204. case m.op.Is(OpUpdate | OpDelete):
  11205. return m.Client().CreditUsage.Query().Where(m.predicates...).IDs(ctx)
  11206. default:
  11207. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  11208. }
  11209. }
  11210. // SetCreatedAt sets the "created_at" field.
  11211. func (m *CreditUsageMutation) SetCreatedAt(t time.Time) {
  11212. m.created_at = &t
  11213. }
  11214. // CreatedAt returns the value of the "created_at" field in the mutation.
  11215. func (m *CreditUsageMutation) CreatedAt() (r time.Time, exists bool) {
  11216. v := m.created_at
  11217. if v == nil {
  11218. return
  11219. }
  11220. return *v, true
  11221. }
  11222. // OldCreatedAt returns the old "created_at" 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) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  11226. if !m.op.Is(OpUpdateOne) {
  11227. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  11228. }
  11229. if m.id == nil || m.oldValue == nil {
  11230. return v, errors.New("OldCreatedAt 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 OldCreatedAt: %w", err)
  11235. }
  11236. return oldValue.CreatedAt, nil
  11237. }
  11238. // ResetCreatedAt resets all changes to the "created_at" field.
  11239. func (m *CreditUsageMutation) ResetCreatedAt() {
  11240. m.created_at = nil
  11241. }
  11242. // SetUpdatedAt sets the "updated_at" field.
  11243. func (m *CreditUsageMutation) SetUpdatedAt(t time.Time) {
  11244. m.updated_at = &t
  11245. }
  11246. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  11247. func (m *CreditUsageMutation) UpdatedAt() (r time.Time, exists bool) {
  11248. v := m.updated_at
  11249. if v == nil {
  11250. return
  11251. }
  11252. return *v, true
  11253. }
  11254. // OldUpdatedAt returns the old "updated_at" field's value of the CreditUsage entity.
  11255. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  11256. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11257. func (m *CreditUsageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  11258. if !m.op.Is(OpUpdateOne) {
  11259. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  11260. }
  11261. if m.id == nil || m.oldValue == nil {
  11262. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  11263. }
  11264. oldValue, err := m.oldValue(ctx)
  11265. if err != nil {
  11266. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  11267. }
  11268. return oldValue.UpdatedAt, nil
  11269. }
  11270. // ResetUpdatedAt resets all changes to the "updated_at" field.
  11271. func (m *CreditUsageMutation) ResetUpdatedAt() {
  11272. m.updated_at = nil
  11273. }
  11274. // SetDeletedAt sets the "deleted_at" field.
  11275. func (m *CreditUsageMutation) SetDeletedAt(t time.Time) {
  11276. m.deleted_at = &t
  11277. }
  11278. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  11279. func (m *CreditUsageMutation) DeletedAt() (r time.Time, exists bool) {
  11280. v := m.deleted_at
  11281. if v == nil {
  11282. return
  11283. }
  11284. return *v, true
  11285. }
  11286. // OldDeletedAt returns the old "deleted_at" field's value of the CreditUsage entity.
  11287. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  11288. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11289. func (m *CreditUsageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  11290. if !m.op.Is(OpUpdateOne) {
  11291. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  11292. }
  11293. if m.id == nil || m.oldValue == nil {
  11294. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  11295. }
  11296. oldValue, err := m.oldValue(ctx)
  11297. if err != nil {
  11298. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  11299. }
  11300. return oldValue.DeletedAt, nil
  11301. }
  11302. // ClearDeletedAt clears the value of the "deleted_at" field.
  11303. func (m *CreditUsageMutation) ClearDeletedAt() {
  11304. m.deleted_at = nil
  11305. m.clearedFields[creditusage.FieldDeletedAt] = struct{}{}
  11306. }
  11307. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  11308. func (m *CreditUsageMutation) DeletedAtCleared() bool {
  11309. _, ok := m.clearedFields[creditusage.FieldDeletedAt]
  11310. return ok
  11311. }
  11312. // ResetDeletedAt resets all changes to the "deleted_at" field.
  11313. func (m *CreditUsageMutation) ResetDeletedAt() {
  11314. m.deleted_at = nil
  11315. delete(m.clearedFields, creditusage.FieldDeletedAt)
  11316. }
  11317. // SetUserID sets the "user_id" field.
  11318. func (m *CreditUsageMutation) SetUserID(s string) {
  11319. m.user_id = &s
  11320. }
  11321. // UserID returns the value of the "user_id" field in the mutation.
  11322. func (m *CreditUsageMutation) UserID() (r string, exists bool) {
  11323. v := m.user_id
  11324. if v == nil {
  11325. return
  11326. }
  11327. return *v, true
  11328. }
  11329. // OldUserID returns the old "user_id" field's value of the CreditUsage entity.
  11330. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  11331. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11332. func (m *CreditUsageMutation) OldUserID(ctx context.Context) (v string, err error) {
  11333. if !m.op.Is(OpUpdateOne) {
  11334. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  11335. }
  11336. if m.id == nil || m.oldValue == nil {
  11337. return v, errors.New("OldUserID requires an ID field in the mutation")
  11338. }
  11339. oldValue, err := m.oldValue(ctx)
  11340. if err != nil {
  11341. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  11342. }
  11343. return oldValue.UserID, nil
  11344. }
  11345. // ClearUserID clears the value of the "user_id" field.
  11346. func (m *CreditUsageMutation) ClearUserID() {
  11347. m.user_id = nil
  11348. m.clearedFields[creditusage.FieldUserID] = struct{}{}
  11349. }
  11350. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  11351. func (m *CreditUsageMutation) UserIDCleared() bool {
  11352. _, ok := m.clearedFields[creditusage.FieldUserID]
  11353. return ok
  11354. }
  11355. // ResetUserID resets all changes to the "user_id" field.
  11356. func (m *CreditUsageMutation) ResetUserID() {
  11357. m.user_id = nil
  11358. delete(m.clearedFields, creditusage.FieldUserID)
  11359. }
  11360. // SetNumber sets the "number" field.
  11361. func (m *CreditUsageMutation) SetNumber(f float32) {
  11362. m.number = &f
  11363. m.addnumber = nil
  11364. }
  11365. // Number returns the value of the "number" field in the mutation.
  11366. func (m *CreditUsageMutation) Number() (r float32, exists bool) {
  11367. v := m.number
  11368. if v == nil {
  11369. return
  11370. }
  11371. return *v, true
  11372. }
  11373. // OldNumber returns the old "number" field's value of the CreditUsage entity.
  11374. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  11375. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11376. func (m *CreditUsageMutation) OldNumber(ctx context.Context) (v float32, err error) {
  11377. if !m.op.Is(OpUpdateOne) {
  11378. return v, errors.New("OldNumber is only allowed on UpdateOne operations")
  11379. }
  11380. if m.id == nil || m.oldValue == nil {
  11381. return v, errors.New("OldNumber requires an ID field in the mutation")
  11382. }
  11383. oldValue, err := m.oldValue(ctx)
  11384. if err != nil {
  11385. return v, fmt.Errorf("querying old value for OldNumber: %w", err)
  11386. }
  11387. return oldValue.Number, nil
  11388. }
  11389. // AddNumber adds f to the "number" field.
  11390. func (m *CreditUsageMutation) AddNumber(f float32) {
  11391. if m.addnumber != nil {
  11392. *m.addnumber += f
  11393. } else {
  11394. m.addnumber = &f
  11395. }
  11396. }
  11397. // AddedNumber returns the value that was added to the "number" field in this mutation.
  11398. func (m *CreditUsageMutation) AddedNumber() (r float32, exists bool) {
  11399. v := m.addnumber
  11400. if v == nil {
  11401. return
  11402. }
  11403. return *v, true
  11404. }
  11405. // ResetNumber resets all changes to the "number" field.
  11406. func (m *CreditUsageMutation) ResetNumber() {
  11407. m.number = nil
  11408. m.addnumber = nil
  11409. }
  11410. // SetStatus sets the "status" field.
  11411. func (m *CreditUsageMutation) SetStatus(i int) {
  11412. m.status = &i
  11413. m.addstatus = nil
  11414. }
  11415. // Status returns the value of the "status" field in the mutation.
  11416. func (m *CreditUsageMutation) Status() (r int, exists bool) {
  11417. v := m.status
  11418. if v == nil {
  11419. return
  11420. }
  11421. return *v, true
  11422. }
  11423. // OldStatus returns the old "status" field's value of the CreditUsage entity.
  11424. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  11425. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11426. func (m *CreditUsageMutation) OldStatus(ctx context.Context) (v int, err error) {
  11427. if !m.op.Is(OpUpdateOne) {
  11428. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  11429. }
  11430. if m.id == nil || m.oldValue == nil {
  11431. return v, errors.New("OldStatus requires an ID field in the mutation")
  11432. }
  11433. oldValue, err := m.oldValue(ctx)
  11434. if err != nil {
  11435. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  11436. }
  11437. return oldValue.Status, nil
  11438. }
  11439. // AddStatus adds i to the "status" field.
  11440. func (m *CreditUsageMutation) AddStatus(i int) {
  11441. if m.addstatus != nil {
  11442. *m.addstatus += i
  11443. } else {
  11444. m.addstatus = &i
  11445. }
  11446. }
  11447. // AddedStatus returns the value that was added to the "status" field in this mutation.
  11448. func (m *CreditUsageMutation) AddedStatus() (r int, exists bool) {
  11449. v := m.addstatus
  11450. if v == nil {
  11451. return
  11452. }
  11453. return *v, true
  11454. }
  11455. // ClearStatus clears the value of the "status" field.
  11456. func (m *CreditUsageMutation) ClearStatus() {
  11457. m.status = nil
  11458. m.addstatus = nil
  11459. m.clearedFields[creditusage.FieldStatus] = struct{}{}
  11460. }
  11461. // StatusCleared returns if the "status" field was cleared in this mutation.
  11462. func (m *CreditUsageMutation) StatusCleared() bool {
  11463. _, ok := m.clearedFields[creditusage.FieldStatus]
  11464. return ok
  11465. }
  11466. // ResetStatus resets all changes to the "status" field.
  11467. func (m *CreditUsageMutation) ResetStatus() {
  11468. m.status = nil
  11469. m.addstatus = nil
  11470. delete(m.clearedFields, creditusage.FieldStatus)
  11471. }
  11472. // SetNtype sets the "ntype" field.
  11473. func (m *CreditUsageMutation) SetNtype(i int) {
  11474. m.ntype = &i
  11475. m.addntype = nil
  11476. }
  11477. // Ntype returns the value of the "ntype" field in the mutation.
  11478. func (m *CreditUsageMutation) Ntype() (r int, exists bool) {
  11479. v := m.ntype
  11480. if v == nil {
  11481. return
  11482. }
  11483. return *v, true
  11484. }
  11485. // OldNtype returns the old "ntype" field's value of the CreditUsage entity.
  11486. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  11487. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11488. func (m *CreditUsageMutation) OldNtype(ctx context.Context) (v int, err error) {
  11489. if !m.op.Is(OpUpdateOne) {
  11490. return v, errors.New("OldNtype is only allowed on UpdateOne operations")
  11491. }
  11492. if m.id == nil || m.oldValue == nil {
  11493. return v, errors.New("OldNtype requires an ID field in the mutation")
  11494. }
  11495. oldValue, err := m.oldValue(ctx)
  11496. if err != nil {
  11497. return v, fmt.Errorf("querying old value for OldNtype: %w", err)
  11498. }
  11499. return oldValue.Ntype, nil
  11500. }
  11501. // AddNtype adds i to the "ntype" field.
  11502. func (m *CreditUsageMutation) AddNtype(i int) {
  11503. if m.addntype != nil {
  11504. *m.addntype += i
  11505. } else {
  11506. m.addntype = &i
  11507. }
  11508. }
  11509. // AddedNtype returns the value that was added to the "ntype" field in this mutation.
  11510. func (m *CreditUsageMutation) AddedNtype() (r int, exists bool) {
  11511. v := m.addntype
  11512. if v == nil {
  11513. return
  11514. }
  11515. return *v, true
  11516. }
  11517. // ResetNtype resets all changes to the "ntype" field.
  11518. func (m *CreditUsageMutation) ResetNtype() {
  11519. m.ntype = nil
  11520. m.addntype = nil
  11521. }
  11522. // SetTable sets the "table" field.
  11523. func (m *CreditUsageMutation) SetTable(s string) {
  11524. m.table = &s
  11525. }
  11526. // Table returns the value of the "table" field in the mutation.
  11527. func (m *CreditUsageMutation) Table() (r string, exists bool) {
  11528. v := m.table
  11529. if v == nil {
  11530. return
  11531. }
  11532. return *v, true
  11533. }
  11534. // OldTable returns the old "table" field's value of the CreditUsage entity.
  11535. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  11536. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11537. func (m *CreditUsageMutation) OldTable(ctx context.Context) (v string, err error) {
  11538. if !m.op.Is(OpUpdateOne) {
  11539. return v, errors.New("OldTable is only allowed on UpdateOne operations")
  11540. }
  11541. if m.id == nil || m.oldValue == nil {
  11542. return v, errors.New("OldTable requires an ID field in the mutation")
  11543. }
  11544. oldValue, err := m.oldValue(ctx)
  11545. if err != nil {
  11546. return v, fmt.Errorf("querying old value for OldTable: %w", err)
  11547. }
  11548. return oldValue.Table, nil
  11549. }
  11550. // ResetTable resets all changes to the "table" field.
  11551. func (m *CreditUsageMutation) ResetTable() {
  11552. m.table = nil
  11553. }
  11554. // SetOrganizationID sets the "organization_id" field.
  11555. func (m *CreditUsageMutation) SetOrganizationID(u uint64) {
  11556. m.organization_id = &u
  11557. m.addorganization_id = nil
  11558. }
  11559. // OrganizationID returns the value of the "organization_id" field in the mutation.
  11560. func (m *CreditUsageMutation) OrganizationID() (r uint64, exists bool) {
  11561. v := m.organization_id
  11562. if v == nil {
  11563. return
  11564. }
  11565. return *v, true
  11566. }
  11567. // OldOrganizationID returns the old "organization_id" field's value of the CreditUsage entity.
  11568. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  11569. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11570. func (m *CreditUsageMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  11571. if !m.op.Is(OpUpdateOne) {
  11572. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  11573. }
  11574. if m.id == nil || m.oldValue == nil {
  11575. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  11576. }
  11577. oldValue, err := m.oldValue(ctx)
  11578. if err != nil {
  11579. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  11580. }
  11581. return oldValue.OrganizationID, nil
  11582. }
  11583. // AddOrganizationID adds u to the "organization_id" field.
  11584. func (m *CreditUsageMutation) AddOrganizationID(u int64) {
  11585. if m.addorganization_id != nil {
  11586. *m.addorganization_id += u
  11587. } else {
  11588. m.addorganization_id = &u
  11589. }
  11590. }
  11591. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  11592. func (m *CreditUsageMutation) AddedOrganizationID() (r int64, exists bool) {
  11593. v := m.addorganization_id
  11594. if v == nil {
  11595. return
  11596. }
  11597. return *v, true
  11598. }
  11599. // ClearOrganizationID clears the value of the "organization_id" field.
  11600. func (m *CreditUsageMutation) ClearOrganizationID() {
  11601. m.organization_id = nil
  11602. m.addorganization_id = nil
  11603. m.clearedFields[creditusage.FieldOrganizationID] = struct{}{}
  11604. }
  11605. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  11606. func (m *CreditUsageMutation) OrganizationIDCleared() bool {
  11607. _, ok := m.clearedFields[creditusage.FieldOrganizationID]
  11608. return ok
  11609. }
  11610. // ResetOrganizationID resets all changes to the "organization_id" field.
  11611. func (m *CreditUsageMutation) ResetOrganizationID() {
  11612. m.organization_id = nil
  11613. m.addorganization_id = nil
  11614. delete(m.clearedFields, creditusage.FieldOrganizationID)
  11615. }
  11616. // SetNid sets the "nid" field.
  11617. func (m *CreditUsageMutation) SetNid(u uint64) {
  11618. m.nid = &u
  11619. m.addnid = nil
  11620. }
  11621. // Nid returns the value of the "nid" field in the mutation.
  11622. func (m *CreditUsageMutation) Nid() (r uint64, exists bool) {
  11623. v := m.nid
  11624. if v == nil {
  11625. return
  11626. }
  11627. return *v, true
  11628. }
  11629. // OldNid returns the old "nid" field's value of the CreditUsage entity.
  11630. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  11631. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11632. func (m *CreditUsageMutation) OldNid(ctx context.Context) (v uint64, err error) {
  11633. if !m.op.Is(OpUpdateOne) {
  11634. return v, errors.New("OldNid is only allowed on UpdateOne operations")
  11635. }
  11636. if m.id == nil || m.oldValue == nil {
  11637. return v, errors.New("OldNid requires an ID field in the mutation")
  11638. }
  11639. oldValue, err := m.oldValue(ctx)
  11640. if err != nil {
  11641. return v, fmt.Errorf("querying old value for OldNid: %w", err)
  11642. }
  11643. return oldValue.Nid, nil
  11644. }
  11645. // AddNid adds u to the "nid" field.
  11646. func (m *CreditUsageMutation) AddNid(u int64) {
  11647. if m.addnid != nil {
  11648. *m.addnid += u
  11649. } else {
  11650. m.addnid = &u
  11651. }
  11652. }
  11653. // AddedNid returns the value that was added to the "nid" field in this mutation.
  11654. func (m *CreditUsageMutation) AddedNid() (r int64, exists bool) {
  11655. v := m.addnid
  11656. if v == nil {
  11657. return
  11658. }
  11659. return *v, true
  11660. }
  11661. // ResetNid resets all changes to the "nid" field.
  11662. func (m *CreditUsageMutation) ResetNid() {
  11663. m.nid = nil
  11664. m.addnid = nil
  11665. }
  11666. // SetReason sets the "reason" field.
  11667. func (m *CreditUsageMutation) SetReason(s string) {
  11668. m.reason = &s
  11669. }
  11670. // Reason returns the value of the "reason" field in the mutation.
  11671. func (m *CreditUsageMutation) Reason() (r string, exists bool) {
  11672. v := m.reason
  11673. if v == nil {
  11674. return
  11675. }
  11676. return *v, true
  11677. }
  11678. // OldReason returns the old "reason" field's value of the CreditUsage entity.
  11679. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  11680. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11681. func (m *CreditUsageMutation) OldReason(ctx context.Context) (v string, err error) {
  11682. if !m.op.Is(OpUpdateOne) {
  11683. return v, errors.New("OldReason is only allowed on UpdateOne operations")
  11684. }
  11685. if m.id == nil || m.oldValue == nil {
  11686. return v, errors.New("OldReason requires an ID field in the mutation")
  11687. }
  11688. oldValue, err := m.oldValue(ctx)
  11689. if err != nil {
  11690. return v, fmt.Errorf("querying old value for OldReason: %w", err)
  11691. }
  11692. return oldValue.Reason, nil
  11693. }
  11694. // ResetReason resets all changes to the "reason" field.
  11695. func (m *CreditUsageMutation) ResetReason() {
  11696. m.reason = nil
  11697. }
  11698. // SetOperator sets the "operator" field.
  11699. func (m *CreditUsageMutation) SetOperator(s string) {
  11700. m.operator = &s
  11701. }
  11702. // Operator returns the value of the "operator" field in the mutation.
  11703. func (m *CreditUsageMutation) Operator() (r string, exists bool) {
  11704. v := m.operator
  11705. if v == nil {
  11706. return
  11707. }
  11708. return *v, true
  11709. }
  11710. // OldOperator returns the old "operator" field's value of the CreditUsage entity.
  11711. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  11712. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11713. func (m *CreditUsageMutation) OldOperator(ctx context.Context) (v string, err error) {
  11714. if !m.op.Is(OpUpdateOne) {
  11715. return v, errors.New("OldOperator is only allowed on UpdateOne operations")
  11716. }
  11717. if m.id == nil || m.oldValue == nil {
  11718. return v, errors.New("OldOperator requires an ID field in the mutation")
  11719. }
  11720. oldValue, err := m.oldValue(ctx)
  11721. if err != nil {
  11722. return v, fmt.Errorf("querying old value for OldOperator: %w", err)
  11723. }
  11724. return oldValue.Operator, nil
  11725. }
  11726. // ResetOperator resets all changes to the "operator" field.
  11727. func (m *CreditUsageMutation) ResetOperator() {
  11728. m.operator = nil
  11729. }
  11730. // Where appends a list predicates to the CreditUsageMutation builder.
  11731. func (m *CreditUsageMutation) Where(ps ...predicate.CreditUsage) {
  11732. m.predicates = append(m.predicates, ps...)
  11733. }
  11734. // WhereP appends storage-level predicates to the CreditUsageMutation builder. Using this method,
  11735. // users can use type-assertion to append predicates that do not depend on any generated package.
  11736. func (m *CreditUsageMutation) WhereP(ps ...func(*sql.Selector)) {
  11737. p := make([]predicate.CreditUsage, len(ps))
  11738. for i := range ps {
  11739. p[i] = ps[i]
  11740. }
  11741. m.Where(p...)
  11742. }
  11743. // Op returns the operation name.
  11744. func (m *CreditUsageMutation) Op() Op {
  11745. return m.op
  11746. }
  11747. // SetOp allows setting the mutation operation.
  11748. func (m *CreditUsageMutation) SetOp(op Op) {
  11749. m.op = op
  11750. }
  11751. // Type returns the node type of this mutation (CreditUsage).
  11752. func (m *CreditUsageMutation) Type() string {
  11753. return m.typ
  11754. }
  11755. // Fields returns all fields that were changed during this mutation. Note that in
  11756. // order to get all numeric fields that were incremented/decremented, call
  11757. // AddedFields().
  11758. func (m *CreditUsageMutation) Fields() []string {
  11759. fields := make([]string, 0, 12)
  11760. if m.created_at != nil {
  11761. fields = append(fields, creditusage.FieldCreatedAt)
  11762. }
  11763. if m.updated_at != nil {
  11764. fields = append(fields, creditusage.FieldUpdatedAt)
  11765. }
  11766. if m.deleted_at != nil {
  11767. fields = append(fields, creditusage.FieldDeletedAt)
  11768. }
  11769. if m.user_id != nil {
  11770. fields = append(fields, creditusage.FieldUserID)
  11771. }
  11772. if m.number != nil {
  11773. fields = append(fields, creditusage.FieldNumber)
  11774. }
  11775. if m.status != nil {
  11776. fields = append(fields, creditusage.FieldStatus)
  11777. }
  11778. if m.ntype != nil {
  11779. fields = append(fields, creditusage.FieldNtype)
  11780. }
  11781. if m.table != nil {
  11782. fields = append(fields, creditusage.FieldTable)
  11783. }
  11784. if m.organization_id != nil {
  11785. fields = append(fields, creditusage.FieldOrganizationID)
  11786. }
  11787. if m.nid != nil {
  11788. fields = append(fields, creditusage.FieldNid)
  11789. }
  11790. if m.reason != nil {
  11791. fields = append(fields, creditusage.FieldReason)
  11792. }
  11793. if m.operator != nil {
  11794. fields = append(fields, creditusage.FieldOperator)
  11795. }
  11796. return fields
  11797. }
  11798. // Field returns the value of a field with the given name. The second boolean
  11799. // return value indicates that this field was not set, or was not defined in the
  11800. // schema.
  11801. func (m *CreditUsageMutation) Field(name string) (ent.Value, bool) {
  11802. switch name {
  11803. case creditusage.FieldCreatedAt:
  11804. return m.CreatedAt()
  11805. case creditusage.FieldUpdatedAt:
  11806. return m.UpdatedAt()
  11807. case creditusage.FieldDeletedAt:
  11808. return m.DeletedAt()
  11809. case creditusage.FieldUserID:
  11810. return m.UserID()
  11811. case creditusage.FieldNumber:
  11812. return m.Number()
  11813. case creditusage.FieldStatus:
  11814. return m.Status()
  11815. case creditusage.FieldNtype:
  11816. return m.Ntype()
  11817. case creditusage.FieldTable:
  11818. return m.Table()
  11819. case creditusage.FieldOrganizationID:
  11820. return m.OrganizationID()
  11821. case creditusage.FieldNid:
  11822. return m.Nid()
  11823. case creditusage.FieldReason:
  11824. return m.Reason()
  11825. case creditusage.FieldOperator:
  11826. return m.Operator()
  11827. }
  11828. return nil, false
  11829. }
  11830. // OldField returns the old value of the field from the database. An error is
  11831. // returned if the mutation operation is not UpdateOne, or the query to the
  11832. // database failed.
  11833. func (m *CreditUsageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  11834. switch name {
  11835. case creditusage.FieldCreatedAt:
  11836. return m.OldCreatedAt(ctx)
  11837. case creditusage.FieldUpdatedAt:
  11838. return m.OldUpdatedAt(ctx)
  11839. case creditusage.FieldDeletedAt:
  11840. return m.OldDeletedAt(ctx)
  11841. case creditusage.FieldUserID:
  11842. return m.OldUserID(ctx)
  11843. case creditusage.FieldNumber:
  11844. return m.OldNumber(ctx)
  11845. case creditusage.FieldStatus:
  11846. return m.OldStatus(ctx)
  11847. case creditusage.FieldNtype:
  11848. return m.OldNtype(ctx)
  11849. case creditusage.FieldTable:
  11850. return m.OldTable(ctx)
  11851. case creditusage.FieldOrganizationID:
  11852. return m.OldOrganizationID(ctx)
  11853. case creditusage.FieldNid:
  11854. return m.OldNid(ctx)
  11855. case creditusage.FieldReason:
  11856. return m.OldReason(ctx)
  11857. case creditusage.FieldOperator:
  11858. return m.OldOperator(ctx)
  11859. }
  11860. return nil, fmt.Errorf("unknown CreditUsage field %s", name)
  11861. }
  11862. // SetField sets the value of a field with the given name. It returns an error if
  11863. // the field is not defined in the schema, or if the type mismatched the field
  11864. // type.
  11865. func (m *CreditUsageMutation) SetField(name string, value ent.Value) error {
  11866. switch name {
  11867. case creditusage.FieldCreatedAt:
  11868. v, ok := value.(time.Time)
  11869. if !ok {
  11870. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11871. }
  11872. m.SetCreatedAt(v)
  11873. return nil
  11874. case creditusage.FieldUpdatedAt:
  11875. v, ok := value.(time.Time)
  11876. if !ok {
  11877. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11878. }
  11879. m.SetUpdatedAt(v)
  11880. return nil
  11881. case creditusage.FieldDeletedAt:
  11882. v, ok := value.(time.Time)
  11883. if !ok {
  11884. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11885. }
  11886. m.SetDeletedAt(v)
  11887. return nil
  11888. case creditusage.FieldUserID:
  11889. v, ok := value.(string)
  11890. if !ok {
  11891. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11892. }
  11893. m.SetUserID(v)
  11894. return nil
  11895. case creditusage.FieldNumber:
  11896. v, ok := value.(float32)
  11897. if !ok {
  11898. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11899. }
  11900. m.SetNumber(v)
  11901. return nil
  11902. case creditusage.FieldStatus:
  11903. v, ok := value.(int)
  11904. if !ok {
  11905. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11906. }
  11907. m.SetStatus(v)
  11908. return nil
  11909. case creditusage.FieldNtype:
  11910. v, ok := value.(int)
  11911. if !ok {
  11912. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11913. }
  11914. m.SetNtype(v)
  11915. return nil
  11916. case creditusage.FieldTable:
  11917. v, ok := value.(string)
  11918. if !ok {
  11919. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11920. }
  11921. m.SetTable(v)
  11922. return nil
  11923. case creditusage.FieldOrganizationID:
  11924. v, ok := value.(uint64)
  11925. if !ok {
  11926. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11927. }
  11928. m.SetOrganizationID(v)
  11929. return nil
  11930. case creditusage.FieldNid:
  11931. v, ok := value.(uint64)
  11932. if !ok {
  11933. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11934. }
  11935. m.SetNid(v)
  11936. return nil
  11937. case creditusage.FieldReason:
  11938. v, ok := value.(string)
  11939. if !ok {
  11940. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11941. }
  11942. m.SetReason(v)
  11943. return nil
  11944. case creditusage.FieldOperator:
  11945. v, ok := value.(string)
  11946. if !ok {
  11947. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11948. }
  11949. m.SetOperator(v)
  11950. return nil
  11951. }
  11952. return fmt.Errorf("unknown CreditUsage field %s", name)
  11953. }
  11954. // AddedFields returns all numeric fields that were incremented/decremented during
  11955. // this mutation.
  11956. func (m *CreditUsageMutation) AddedFields() []string {
  11957. var fields []string
  11958. if m.addnumber != nil {
  11959. fields = append(fields, creditusage.FieldNumber)
  11960. }
  11961. if m.addstatus != nil {
  11962. fields = append(fields, creditusage.FieldStatus)
  11963. }
  11964. if m.addntype != nil {
  11965. fields = append(fields, creditusage.FieldNtype)
  11966. }
  11967. if m.addorganization_id != nil {
  11968. fields = append(fields, creditusage.FieldOrganizationID)
  11969. }
  11970. if m.addnid != nil {
  11971. fields = append(fields, creditusage.FieldNid)
  11972. }
  11973. return fields
  11974. }
  11975. // AddedField returns the numeric value that was incremented/decremented on a field
  11976. // with the given name. The second boolean return value indicates that this field
  11977. // was not set, or was not defined in the schema.
  11978. func (m *CreditUsageMutation) AddedField(name string) (ent.Value, bool) {
  11979. switch name {
  11980. case creditusage.FieldNumber:
  11981. return m.AddedNumber()
  11982. case creditusage.FieldStatus:
  11983. return m.AddedStatus()
  11984. case creditusage.FieldNtype:
  11985. return m.AddedNtype()
  11986. case creditusage.FieldOrganizationID:
  11987. return m.AddedOrganizationID()
  11988. case creditusage.FieldNid:
  11989. return m.AddedNid()
  11990. }
  11991. return nil, false
  11992. }
  11993. // AddField adds the value to the field with the given name. It returns an error if
  11994. // the field is not defined in the schema, or if the type mismatched the field
  11995. // type.
  11996. func (m *CreditUsageMutation) AddField(name string, value ent.Value) error {
  11997. switch name {
  11998. case creditusage.FieldNumber:
  11999. v, ok := value.(float32)
  12000. if !ok {
  12001. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12002. }
  12003. m.AddNumber(v)
  12004. return nil
  12005. case creditusage.FieldStatus:
  12006. v, ok := value.(int)
  12007. if !ok {
  12008. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12009. }
  12010. m.AddStatus(v)
  12011. return nil
  12012. case creditusage.FieldNtype:
  12013. v, ok := value.(int)
  12014. if !ok {
  12015. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12016. }
  12017. m.AddNtype(v)
  12018. return nil
  12019. case creditusage.FieldOrganizationID:
  12020. v, ok := value.(int64)
  12021. if !ok {
  12022. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12023. }
  12024. m.AddOrganizationID(v)
  12025. return nil
  12026. case creditusage.FieldNid:
  12027. v, ok := value.(int64)
  12028. if !ok {
  12029. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12030. }
  12031. m.AddNid(v)
  12032. return nil
  12033. }
  12034. return fmt.Errorf("unknown CreditUsage numeric field %s", name)
  12035. }
  12036. // ClearedFields returns all nullable fields that were cleared during this
  12037. // mutation.
  12038. func (m *CreditUsageMutation) ClearedFields() []string {
  12039. var fields []string
  12040. if m.FieldCleared(creditusage.FieldDeletedAt) {
  12041. fields = append(fields, creditusage.FieldDeletedAt)
  12042. }
  12043. if m.FieldCleared(creditusage.FieldUserID) {
  12044. fields = append(fields, creditusage.FieldUserID)
  12045. }
  12046. if m.FieldCleared(creditusage.FieldStatus) {
  12047. fields = append(fields, creditusage.FieldStatus)
  12048. }
  12049. if m.FieldCleared(creditusage.FieldOrganizationID) {
  12050. fields = append(fields, creditusage.FieldOrganizationID)
  12051. }
  12052. return fields
  12053. }
  12054. // FieldCleared returns a boolean indicating if a field with the given name was
  12055. // cleared in this mutation.
  12056. func (m *CreditUsageMutation) FieldCleared(name string) bool {
  12057. _, ok := m.clearedFields[name]
  12058. return ok
  12059. }
  12060. // ClearField clears the value of the field with the given name. It returns an
  12061. // error if the field is not defined in the schema.
  12062. func (m *CreditUsageMutation) ClearField(name string) error {
  12063. switch name {
  12064. case creditusage.FieldDeletedAt:
  12065. m.ClearDeletedAt()
  12066. return nil
  12067. case creditusage.FieldUserID:
  12068. m.ClearUserID()
  12069. return nil
  12070. case creditusage.FieldStatus:
  12071. m.ClearStatus()
  12072. return nil
  12073. case creditusage.FieldOrganizationID:
  12074. m.ClearOrganizationID()
  12075. return nil
  12076. }
  12077. return fmt.Errorf("unknown CreditUsage nullable field %s", name)
  12078. }
  12079. // ResetField resets all changes in the mutation for the field with the given name.
  12080. // It returns an error if the field is not defined in the schema.
  12081. func (m *CreditUsageMutation) ResetField(name string) error {
  12082. switch name {
  12083. case creditusage.FieldCreatedAt:
  12084. m.ResetCreatedAt()
  12085. return nil
  12086. case creditusage.FieldUpdatedAt:
  12087. m.ResetUpdatedAt()
  12088. return nil
  12089. case creditusage.FieldDeletedAt:
  12090. m.ResetDeletedAt()
  12091. return nil
  12092. case creditusage.FieldUserID:
  12093. m.ResetUserID()
  12094. return nil
  12095. case creditusage.FieldNumber:
  12096. m.ResetNumber()
  12097. return nil
  12098. case creditusage.FieldStatus:
  12099. m.ResetStatus()
  12100. return nil
  12101. case creditusage.FieldNtype:
  12102. m.ResetNtype()
  12103. return nil
  12104. case creditusage.FieldTable:
  12105. m.ResetTable()
  12106. return nil
  12107. case creditusage.FieldOrganizationID:
  12108. m.ResetOrganizationID()
  12109. return nil
  12110. case creditusage.FieldNid:
  12111. m.ResetNid()
  12112. return nil
  12113. case creditusage.FieldReason:
  12114. m.ResetReason()
  12115. return nil
  12116. case creditusage.FieldOperator:
  12117. m.ResetOperator()
  12118. return nil
  12119. }
  12120. return fmt.Errorf("unknown CreditUsage field %s", name)
  12121. }
  12122. // AddedEdges returns all edge names that were set/added in this mutation.
  12123. func (m *CreditUsageMutation) AddedEdges() []string {
  12124. edges := make([]string, 0, 0)
  12125. return edges
  12126. }
  12127. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  12128. // name in this mutation.
  12129. func (m *CreditUsageMutation) AddedIDs(name string) []ent.Value {
  12130. return nil
  12131. }
  12132. // RemovedEdges returns all edge names that were removed in this mutation.
  12133. func (m *CreditUsageMutation) RemovedEdges() []string {
  12134. edges := make([]string, 0, 0)
  12135. return edges
  12136. }
  12137. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  12138. // the given name in this mutation.
  12139. func (m *CreditUsageMutation) RemovedIDs(name string) []ent.Value {
  12140. return nil
  12141. }
  12142. // ClearedEdges returns all edge names that were cleared in this mutation.
  12143. func (m *CreditUsageMutation) ClearedEdges() []string {
  12144. edges := make([]string, 0, 0)
  12145. return edges
  12146. }
  12147. // EdgeCleared returns a boolean which indicates if the edge with the given name
  12148. // was cleared in this mutation.
  12149. func (m *CreditUsageMutation) EdgeCleared(name string) bool {
  12150. return false
  12151. }
  12152. // ClearEdge clears the value of the edge with the given name. It returns an error
  12153. // if that edge is not defined in the schema.
  12154. func (m *CreditUsageMutation) ClearEdge(name string) error {
  12155. return fmt.Errorf("unknown CreditUsage unique edge %s", name)
  12156. }
  12157. // ResetEdge resets all changes to the edge with the given name in this mutation.
  12158. // It returns an error if the edge is not defined in the schema.
  12159. func (m *CreditUsageMutation) ResetEdge(name string) error {
  12160. return fmt.Errorf("unknown CreditUsage edge %s", name)
  12161. }
  12162. // EmployeeMutation represents an operation that mutates the Employee nodes in the graph.
  12163. type EmployeeMutation struct {
  12164. config
  12165. op Op
  12166. typ string
  12167. id *uint64
  12168. created_at *time.Time
  12169. updated_at *time.Time
  12170. deleted_at *time.Time
  12171. title *string
  12172. avatar *string
  12173. tags *string
  12174. hire_count *int
  12175. addhire_count *int
  12176. service_count *int
  12177. addservice_count *int
  12178. achievement_count *int
  12179. addachievement_count *int
  12180. intro *string
  12181. estimate *string
  12182. skill *string
  12183. ability_type *string
  12184. scene *string
  12185. switch_in *string
  12186. video_url *string
  12187. organization_id *uint64
  12188. addorganization_id *int64
  12189. category_id *uint64
  12190. addcategory_id *int64
  12191. api_base *string
  12192. api_key *string
  12193. ai_info *string
  12194. is_vip *int
  12195. addis_vip *int
  12196. chat_url *string
  12197. clearedFields map[string]struct{}
  12198. em_work_experiences map[uint64]struct{}
  12199. removedem_work_experiences map[uint64]struct{}
  12200. clearedem_work_experiences bool
  12201. em_tutorial map[uint64]struct{}
  12202. removedem_tutorial map[uint64]struct{}
  12203. clearedem_tutorial bool
  12204. done bool
  12205. oldValue func(context.Context) (*Employee, error)
  12206. predicates []predicate.Employee
  12207. }
  12208. var _ ent.Mutation = (*EmployeeMutation)(nil)
  12209. // employeeOption allows management of the mutation configuration using functional options.
  12210. type employeeOption func(*EmployeeMutation)
  12211. // newEmployeeMutation creates new mutation for the Employee entity.
  12212. func newEmployeeMutation(c config, op Op, opts ...employeeOption) *EmployeeMutation {
  12213. m := &EmployeeMutation{
  12214. config: c,
  12215. op: op,
  12216. typ: TypeEmployee,
  12217. clearedFields: make(map[string]struct{}),
  12218. }
  12219. for _, opt := range opts {
  12220. opt(m)
  12221. }
  12222. return m
  12223. }
  12224. // withEmployeeID sets the ID field of the mutation.
  12225. func withEmployeeID(id uint64) employeeOption {
  12226. return func(m *EmployeeMutation) {
  12227. var (
  12228. err error
  12229. once sync.Once
  12230. value *Employee
  12231. )
  12232. m.oldValue = func(ctx context.Context) (*Employee, error) {
  12233. once.Do(func() {
  12234. if m.done {
  12235. err = errors.New("querying old values post mutation is not allowed")
  12236. } else {
  12237. value, err = m.Client().Employee.Get(ctx, id)
  12238. }
  12239. })
  12240. return value, err
  12241. }
  12242. m.id = &id
  12243. }
  12244. }
  12245. // withEmployee sets the old Employee of the mutation.
  12246. func withEmployee(node *Employee) employeeOption {
  12247. return func(m *EmployeeMutation) {
  12248. m.oldValue = func(context.Context) (*Employee, error) {
  12249. return node, nil
  12250. }
  12251. m.id = &node.ID
  12252. }
  12253. }
  12254. // Client returns a new `ent.Client` from the mutation. If the mutation was
  12255. // executed in a transaction (ent.Tx), a transactional client is returned.
  12256. func (m EmployeeMutation) Client() *Client {
  12257. client := &Client{config: m.config}
  12258. client.init()
  12259. return client
  12260. }
  12261. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  12262. // it returns an error otherwise.
  12263. func (m EmployeeMutation) Tx() (*Tx, error) {
  12264. if _, ok := m.driver.(*txDriver); !ok {
  12265. return nil, errors.New("ent: mutation is not running in a transaction")
  12266. }
  12267. tx := &Tx{config: m.config}
  12268. tx.init()
  12269. return tx, nil
  12270. }
  12271. // SetID sets the value of the id field. Note that this
  12272. // operation is only accepted on creation of Employee entities.
  12273. func (m *EmployeeMutation) SetID(id uint64) {
  12274. m.id = &id
  12275. }
  12276. // ID returns the ID value in the mutation. Note that the ID is only available
  12277. // if it was provided to the builder or after it was returned from the database.
  12278. func (m *EmployeeMutation) ID() (id uint64, exists bool) {
  12279. if m.id == nil {
  12280. return
  12281. }
  12282. return *m.id, true
  12283. }
  12284. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  12285. // That means, if the mutation is applied within a transaction with an isolation level such
  12286. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  12287. // or updated by the mutation.
  12288. func (m *EmployeeMutation) IDs(ctx context.Context) ([]uint64, error) {
  12289. switch {
  12290. case m.op.Is(OpUpdateOne | OpDeleteOne):
  12291. id, exists := m.ID()
  12292. if exists {
  12293. return []uint64{id}, nil
  12294. }
  12295. fallthrough
  12296. case m.op.Is(OpUpdate | OpDelete):
  12297. return m.Client().Employee.Query().Where(m.predicates...).IDs(ctx)
  12298. default:
  12299. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  12300. }
  12301. }
  12302. // SetCreatedAt sets the "created_at" field.
  12303. func (m *EmployeeMutation) SetCreatedAt(t time.Time) {
  12304. m.created_at = &t
  12305. }
  12306. // CreatedAt returns the value of the "created_at" field in the mutation.
  12307. func (m *EmployeeMutation) CreatedAt() (r time.Time, exists bool) {
  12308. v := m.created_at
  12309. if v == nil {
  12310. return
  12311. }
  12312. return *v, true
  12313. }
  12314. // OldCreatedAt returns the old "created_at" field's value of the Employee entity.
  12315. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12316. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12317. func (m *EmployeeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  12318. if !m.op.Is(OpUpdateOne) {
  12319. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  12320. }
  12321. if m.id == nil || m.oldValue == nil {
  12322. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  12323. }
  12324. oldValue, err := m.oldValue(ctx)
  12325. if err != nil {
  12326. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  12327. }
  12328. return oldValue.CreatedAt, nil
  12329. }
  12330. // ResetCreatedAt resets all changes to the "created_at" field.
  12331. func (m *EmployeeMutation) ResetCreatedAt() {
  12332. m.created_at = nil
  12333. }
  12334. // SetUpdatedAt sets the "updated_at" field.
  12335. func (m *EmployeeMutation) SetUpdatedAt(t time.Time) {
  12336. m.updated_at = &t
  12337. }
  12338. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  12339. func (m *EmployeeMutation) UpdatedAt() (r time.Time, exists bool) {
  12340. v := m.updated_at
  12341. if v == nil {
  12342. return
  12343. }
  12344. return *v, true
  12345. }
  12346. // OldUpdatedAt returns the old "updated_at" field's value of the Employee entity.
  12347. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12348. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12349. func (m *EmployeeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  12350. if !m.op.Is(OpUpdateOne) {
  12351. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  12352. }
  12353. if m.id == nil || m.oldValue == nil {
  12354. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  12355. }
  12356. oldValue, err := m.oldValue(ctx)
  12357. if err != nil {
  12358. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  12359. }
  12360. return oldValue.UpdatedAt, nil
  12361. }
  12362. // ResetUpdatedAt resets all changes to the "updated_at" field.
  12363. func (m *EmployeeMutation) ResetUpdatedAt() {
  12364. m.updated_at = nil
  12365. }
  12366. // SetDeletedAt sets the "deleted_at" field.
  12367. func (m *EmployeeMutation) SetDeletedAt(t time.Time) {
  12368. m.deleted_at = &t
  12369. }
  12370. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  12371. func (m *EmployeeMutation) DeletedAt() (r time.Time, exists bool) {
  12372. v := m.deleted_at
  12373. if v == nil {
  12374. return
  12375. }
  12376. return *v, true
  12377. }
  12378. // OldDeletedAt returns the old "deleted_at" field's value of the Employee entity.
  12379. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12380. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12381. func (m *EmployeeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  12382. if !m.op.Is(OpUpdateOne) {
  12383. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  12384. }
  12385. if m.id == nil || m.oldValue == nil {
  12386. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  12387. }
  12388. oldValue, err := m.oldValue(ctx)
  12389. if err != nil {
  12390. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  12391. }
  12392. return oldValue.DeletedAt, nil
  12393. }
  12394. // ClearDeletedAt clears the value of the "deleted_at" field.
  12395. func (m *EmployeeMutation) ClearDeletedAt() {
  12396. m.deleted_at = nil
  12397. m.clearedFields[employee.FieldDeletedAt] = struct{}{}
  12398. }
  12399. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  12400. func (m *EmployeeMutation) DeletedAtCleared() bool {
  12401. _, ok := m.clearedFields[employee.FieldDeletedAt]
  12402. return ok
  12403. }
  12404. // ResetDeletedAt resets all changes to the "deleted_at" field.
  12405. func (m *EmployeeMutation) ResetDeletedAt() {
  12406. m.deleted_at = nil
  12407. delete(m.clearedFields, employee.FieldDeletedAt)
  12408. }
  12409. // SetTitle sets the "title" field.
  12410. func (m *EmployeeMutation) SetTitle(s string) {
  12411. m.title = &s
  12412. }
  12413. // Title returns the value of the "title" field in the mutation.
  12414. func (m *EmployeeMutation) Title() (r string, exists bool) {
  12415. v := m.title
  12416. if v == nil {
  12417. return
  12418. }
  12419. return *v, true
  12420. }
  12421. // OldTitle returns the old "title" field's value of the Employee entity.
  12422. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12423. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12424. func (m *EmployeeMutation) OldTitle(ctx context.Context) (v string, err error) {
  12425. if !m.op.Is(OpUpdateOne) {
  12426. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  12427. }
  12428. if m.id == nil || m.oldValue == nil {
  12429. return v, errors.New("OldTitle requires an ID field in the mutation")
  12430. }
  12431. oldValue, err := m.oldValue(ctx)
  12432. if err != nil {
  12433. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  12434. }
  12435. return oldValue.Title, nil
  12436. }
  12437. // ResetTitle resets all changes to the "title" field.
  12438. func (m *EmployeeMutation) ResetTitle() {
  12439. m.title = nil
  12440. }
  12441. // SetAvatar sets the "avatar" field.
  12442. func (m *EmployeeMutation) SetAvatar(s string) {
  12443. m.avatar = &s
  12444. }
  12445. // Avatar returns the value of the "avatar" field in the mutation.
  12446. func (m *EmployeeMutation) Avatar() (r string, exists bool) {
  12447. v := m.avatar
  12448. if v == nil {
  12449. return
  12450. }
  12451. return *v, true
  12452. }
  12453. // OldAvatar returns the old "avatar" field's value of the Employee entity.
  12454. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12455. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12456. func (m *EmployeeMutation) OldAvatar(ctx context.Context) (v string, err error) {
  12457. if !m.op.Is(OpUpdateOne) {
  12458. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  12459. }
  12460. if m.id == nil || m.oldValue == nil {
  12461. return v, errors.New("OldAvatar requires an ID field in the mutation")
  12462. }
  12463. oldValue, err := m.oldValue(ctx)
  12464. if err != nil {
  12465. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  12466. }
  12467. return oldValue.Avatar, nil
  12468. }
  12469. // ResetAvatar resets all changes to the "avatar" field.
  12470. func (m *EmployeeMutation) ResetAvatar() {
  12471. m.avatar = nil
  12472. }
  12473. // SetTags sets the "tags" field.
  12474. func (m *EmployeeMutation) SetTags(s string) {
  12475. m.tags = &s
  12476. }
  12477. // Tags returns the value of the "tags" field in the mutation.
  12478. func (m *EmployeeMutation) Tags() (r string, exists bool) {
  12479. v := m.tags
  12480. if v == nil {
  12481. return
  12482. }
  12483. return *v, true
  12484. }
  12485. // OldTags returns the old "tags" field's value of the Employee entity.
  12486. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12487. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12488. func (m *EmployeeMutation) OldTags(ctx context.Context) (v string, err error) {
  12489. if !m.op.Is(OpUpdateOne) {
  12490. return v, errors.New("OldTags is only allowed on UpdateOne operations")
  12491. }
  12492. if m.id == nil || m.oldValue == nil {
  12493. return v, errors.New("OldTags requires an ID field in the mutation")
  12494. }
  12495. oldValue, err := m.oldValue(ctx)
  12496. if err != nil {
  12497. return v, fmt.Errorf("querying old value for OldTags: %w", err)
  12498. }
  12499. return oldValue.Tags, nil
  12500. }
  12501. // ResetTags resets all changes to the "tags" field.
  12502. func (m *EmployeeMutation) ResetTags() {
  12503. m.tags = nil
  12504. }
  12505. // SetHireCount sets the "hire_count" field.
  12506. func (m *EmployeeMutation) SetHireCount(i int) {
  12507. m.hire_count = &i
  12508. m.addhire_count = nil
  12509. }
  12510. // HireCount returns the value of the "hire_count" field in the mutation.
  12511. func (m *EmployeeMutation) HireCount() (r int, exists bool) {
  12512. v := m.hire_count
  12513. if v == nil {
  12514. return
  12515. }
  12516. return *v, true
  12517. }
  12518. // OldHireCount returns the old "hire_count" field's value of the Employee entity.
  12519. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12520. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12521. func (m *EmployeeMutation) OldHireCount(ctx context.Context) (v int, err error) {
  12522. if !m.op.Is(OpUpdateOne) {
  12523. return v, errors.New("OldHireCount is only allowed on UpdateOne operations")
  12524. }
  12525. if m.id == nil || m.oldValue == nil {
  12526. return v, errors.New("OldHireCount requires an ID field in the mutation")
  12527. }
  12528. oldValue, err := m.oldValue(ctx)
  12529. if err != nil {
  12530. return v, fmt.Errorf("querying old value for OldHireCount: %w", err)
  12531. }
  12532. return oldValue.HireCount, nil
  12533. }
  12534. // AddHireCount adds i to the "hire_count" field.
  12535. func (m *EmployeeMutation) AddHireCount(i int) {
  12536. if m.addhire_count != nil {
  12537. *m.addhire_count += i
  12538. } else {
  12539. m.addhire_count = &i
  12540. }
  12541. }
  12542. // AddedHireCount returns the value that was added to the "hire_count" field in this mutation.
  12543. func (m *EmployeeMutation) AddedHireCount() (r int, exists bool) {
  12544. v := m.addhire_count
  12545. if v == nil {
  12546. return
  12547. }
  12548. return *v, true
  12549. }
  12550. // ResetHireCount resets all changes to the "hire_count" field.
  12551. func (m *EmployeeMutation) ResetHireCount() {
  12552. m.hire_count = nil
  12553. m.addhire_count = nil
  12554. }
  12555. // SetServiceCount sets the "service_count" field.
  12556. func (m *EmployeeMutation) SetServiceCount(i int) {
  12557. m.service_count = &i
  12558. m.addservice_count = nil
  12559. }
  12560. // ServiceCount returns the value of the "service_count" field in the mutation.
  12561. func (m *EmployeeMutation) ServiceCount() (r int, exists bool) {
  12562. v := m.service_count
  12563. if v == nil {
  12564. return
  12565. }
  12566. return *v, true
  12567. }
  12568. // OldServiceCount returns the old "service_count" field's value of the Employee entity.
  12569. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12570. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12571. func (m *EmployeeMutation) OldServiceCount(ctx context.Context) (v int, err error) {
  12572. if !m.op.Is(OpUpdateOne) {
  12573. return v, errors.New("OldServiceCount is only allowed on UpdateOne operations")
  12574. }
  12575. if m.id == nil || m.oldValue == nil {
  12576. return v, errors.New("OldServiceCount requires an ID field in the mutation")
  12577. }
  12578. oldValue, err := m.oldValue(ctx)
  12579. if err != nil {
  12580. return v, fmt.Errorf("querying old value for OldServiceCount: %w", err)
  12581. }
  12582. return oldValue.ServiceCount, nil
  12583. }
  12584. // AddServiceCount adds i to the "service_count" field.
  12585. func (m *EmployeeMutation) AddServiceCount(i int) {
  12586. if m.addservice_count != nil {
  12587. *m.addservice_count += i
  12588. } else {
  12589. m.addservice_count = &i
  12590. }
  12591. }
  12592. // AddedServiceCount returns the value that was added to the "service_count" field in this mutation.
  12593. func (m *EmployeeMutation) AddedServiceCount() (r int, exists bool) {
  12594. v := m.addservice_count
  12595. if v == nil {
  12596. return
  12597. }
  12598. return *v, true
  12599. }
  12600. // ResetServiceCount resets all changes to the "service_count" field.
  12601. func (m *EmployeeMutation) ResetServiceCount() {
  12602. m.service_count = nil
  12603. m.addservice_count = nil
  12604. }
  12605. // SetAchievementCount sets the "achievement_count" field.
  12606. func (m *EmployeeMutation) SetAchievementCount(i int) {
  12607. m.achievement_count = &i
  12608. m.addachievement_count = nil
  12609. }
  12610. // AchievementCount returns the value of the "achievement_count" field in the mutation.
  12611. func (m *EmployeeMutation) AchievementCount() (r int, exists bool) {
  12612. v := m.achievement_count
  12613. if v == nil {
  12614. return
  12615. }
  12616. return *v, true
  12617. }
  12618. // OldAchievementCount returns the old "achievement_count" field's value of the Employee entity.
  12619. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12620. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12621. func (m *EmployeeMutation) OldAchievementCount(ctx context.Context) (v int, err error) {
  12622. if !m.op.Is(OpUpdateOne) {
  12623. return v, errors.New("OldAchievementCount is only allowed on UpdateOne operations")
  12624. }
  12625. if m.id == nil || m.oldValue == nil {
  12626. return v, errors.New("OldAchievementCount requires an ID field in the mutation")
  12627. }
  12628. oldValue, err := m.oldValue(ctx)
  12629. if err != nil {
  12630. return v, fmt.Errorf("querying old value for OldAchievementCount: %w", err)
  12631. }
  12632. return oldValue.AchievementCount, nil
  12633. }
  12634. // AddAchievementCount adds i to the "achievement_count" field.
  12635. func (m *EmployeeMutation) AddAchievementCount(i int) {
  12636. if m.addachievement_count != nil {
  12637. *m.addachievement_count += i
  12638. } else {
  12639. m.addachievement_count = &i
  12640. }
  12641. }
  12642. // AddedAchievementCount returns the value that was added to the "achievement_count" field in this mutation.
  12643. func (m *EmployeeMutation) AddedAchievementCount() (r int, exists bool) {
  12644. v := m.addachievement_count
  12645. if v == nil {
  12646. return
  12647. }
  12648. return *v, true
  12649. }
  12650. // ResetAchievementCount resets all changes to the "achievement_count" field.
  12651. func (m *EmployeeMutation) ResetAchievementCount() {
  12652. m.achievement_count = nil
  12653. m.addachievement_count = nil
  12654. }
  12655. // SetIntro sets the "intro" field.
  12656. func (m *EmployeeMutation) SetIntro(s string) {
  12657. m.intro = &s
  12658. }
  12659. // Intro returns the value of the "intro" field in the mutation.
  12660. func (m *EmployeeMutation) Intro() (r string, exists bool) {
  12661. v := m.intro
  12662. if v == nil {
  12663. return
  12664. }
  12665. return *v, true
  12666. }
  12667. // OldIntro returns the old "intro" field's value of the Employee entity.
  12668. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12669. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12670. func (m *EmployeeMutation) OldIntro(ctx context.Context) (v string, err error) {
  12671. if !m.op.Is(OpUpdateOne) {
  12672. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  12673. }
  12674. if m.id == nil || m.oldValue == nil {
  12675. return v, errors.New("OldIntro requires an ID field in the mutation")
  12676. }
  12677. oldValue, err := m.oldValue(ctx)
  12678. if err != nil {
  12679. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  12680. }
  12681. return oldValue.Intro, nil
  12682. }
  12683. // ResetIntro resets all changes to the "intro" field.
  12684. func (m *EmployeeMutation) ResetIntro() {
  12685. m.intro = nil
  12686. }
  12687. // SetEstimate sets the "estimate" field.
  12688. func (m *EmployeeMutation) SetEstimate(s string) {
  12689. m.estimate = &s
  12690. }
  12691. // Estimate returns the value of the "estimate" field in the mutation.
  12692. func (m *EmployeeMutation) Estimate() (r string, exists bool) {
  12693. v := m.estimate
  12694. if v == nil {
  12695. return
  12696. }
  12697. return *v, true
  12698. }
  12699. // OldEstimate returns the old "estimate" field's value of the Employee entity.
  12700. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12701. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12702. func (m *EmployeeMutation) OldEstimate(ctx context.Context) (v string, err error) {
  12703. if !m.op.Is(OpUpdateOne) {
  12704. return v, errors.New("OldEstimate is only allowed on UpdateOne operations")
  12705. }
  12706. if m.id == nil || m.oldValue == nil {
  12707. return v, errors.New("OldEstimate requires an ID field in the mutation")
  12708. }
  12709. oldValue, err := m.oldValue(ctx)
  12710. if err != nil {
  12711. return v, fmt.Errorf("querying old value for OldEstimate: %w", err)
  12712. }
  12713. return oldValue.Estimate, nil
  12714. }
  12715. // ResetEstimate resets all changes to the "estimate" field.
  12716. func (m *EmployeeMutation) ResetEstimate() {
  12717. m.estimate = nil
  12718. }
  12719. // SetSkill sets the "skill" field.
  12720. func (m *EmployeeMutation) SetSkill(s string) {
  12721. m.skill = &s
  12722. }
  12723. // Skill returns the value of the "skill" field in the mutation.
  12724. func (m *EmployeeMutation) Skill() (r string, exists bool) {
  12725. v := m.skill
  12726. if v == nil {
  12727. return
  12728. }
  12729. return *v, true
  12730. }
  12731. // OldSkill returns the old "skill" field's value of the Employee entity.
  12732. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12733. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12734. func (m *EmployeeMutation) OldSkill(ctx context.Context) (v string, err error) {
  12735. if !m.op.Is(OpUpdateOne) {
  12736. return v, errors.New("OldSkill is only allowed on UpdateOne operations")
  12737. }
  12738. if m.id == nil || m.oldValue == nil {
  12739. return v, errors.New("OldSkill requires an ID field in the mutation")
  12740. }
  12741. oldValue, err := m.oldValue(ctx)
  12742. if err != nil {
  12743. return v, fmt.Errorf("querying old value for OldSkill: %w", err)
  12744. }
  12745. return oldValue.Skill, nil
  12746. }
  12747. // ResetSkill resets all changes to the "skill" field.
  12748. func (m *EmployeeMutation) ResetSkill() {
  12749. m.skill = nil
  12750. }
  12751. // SetAbilityType sets the "ability_type" field.
  12752. func (m *EmployeeMutation) SetAbilityType(s string) {
  12753. m.ability_type = &s
  12754. }
  12755. // AbilityType returns the value of the "ability_type" field in the mutation.
  12756. func (m *EmployeeMutation) AbilityType() (r string, exists bool) {
  12757. v := m.ability_type
  12758. if v == nil {
  12759. return
  12760. }
  12761. return *v, true
  12762. }
  12763. // OldAbilityType returns the old "ability_type" field's value of the Employee entity.
  12764. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12765. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12766. func (m *EmployeeMutation) OldAbilityType(ctx context.Context) (v string, err error) {
  12767. if !m.op.Is(OpUpdateOne) {
  12768. return v, errors.New("OldAbilityType is only allowed on UpdateOne operations")
  12769. }
  12770. if m.id == nil || m.oldValue == nil {
  12771. return v, errors.New("OldAbilityType requires an ID field in the mutation")
  12772. }
  12773. oldValue, err := m.oldValue(ctx)
  12774. if err != nil {
  12775. return v, fmt.Errorf("querying old value for OldAbilityType: %w", err)
  12776. }
  12777. return oldValue.AbilityType, nil
  12778. }
  12779. // ResetAbilityType resets all changes to the "ability_type" field.
  12780. func (m *EmployeeMutation) ResetAbilityType() {
  12781. m.ability_type = nil
  12782. }
  12783. // SetScene sets the "scene" field.
  12784. func (m *EmployeeMutation) SetScene(s string) {
  12785. m.scene = &s
  12786. }
  12787. // Scene returns the value of the "scene" field in the mutation.
  12788. func (m *EmployeeMutation) Scene() (r string, exists bool) {
  12789. v := m.scene
  12790. if v == nil {
  12791. return
  12792. }
  12793. return *v, true
  12794. }
  12795. // OldScene returns the old "scene" field's value of the Employee entity.
  12796. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12797. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12798. func (m *EmployeeMutation) OldScene(ctx context.Context) (v string, err error) {
  12799. if !m.op.Is(OpUpdateOne) {
  12800. return v, errors.New("OldScene is only allowed on UpdateOne operations")
  12801. }
  12802. if m.id == nil || m.oldValue == nil {
  12803. return v, errors.New("OldScene requires an ID field in the mutation")
  12804. }
  12805. oldValue, err := m.oldValue(ctx)
  12806. if err != nil {
  12807. return v, fmt.Errorf("querying old value for OldScene: %w", err)
  12808. }
  12809. return oldValue.Scene, nil
  12810. }
  12811. // ResetScene resets all changes to the "scene" field.
  12812. func (m *EmployeeMutation) ResetScene() {
  12813. m.scene = nil
  12814. }
  12815. // SetSwitchIn sets the "switch_in" field.
  12816. func (m *EmployeeMutation) SetSwitchIn(s string) {
  12817. m.switch_in = &s
  12818. }
  12819. // SwitchIn returns the value of the "switch_in" field in the mutation.
  12820. func (m *EmployeeMutation) SwitchIn() (r string, exists bool) {
  12821. v := m.switch_in
  12822. if v == nil {
  12823. return
  12824. }
  12825. return *v, true
  12826. }
  12827. // OldSwitchIn returns the old "switch_in" field's value of the Employee entity.
  12828. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12829. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12830. func (m *EmployeeMutation) OldSwitchIn(ctx context.Context) (v string, err error) {
  12831. if !m.op.Is(OpUpdateOne) {
  12832. return v, errors.New("OldSwitchIn is only allowed on UpdateOne operations")
  12833. }
  12834. if m.id == nil || m.oldValue == nil {
  12835. return v, errors.New("OldSwitchIn requires an ID field in the mutation")
  12836. }
  12837. oldValue, err := m.oldValue(ctx)
  12838. if err != nil {
  12839. return v, fmt.Errorf("querying old value for OldSwitchIn: %w", err)
  12840. }
  12841. return oldValue.SwitchIn, nil
  12842. }
  12843. // ResetSwitchIn resets all changes to the "switch_in" field.
  12844. func (m *EmployeeMutation) ResetSwitchIn() {
  12845. m.switch_in = nil
  12846. }
  12847. // SetVideoURL sets the "video_url" field.
  12848. func (m *EmployeeMutation) SetVideoURL(s string) {
  12849. m.video_url = &s
  12850. }
  12851. // VideoURL returns the value of the "video_url" field in the mutation.
  12852. func (m *EmployeeMutation) VideoURL() (r string, exists bool) {
  12853. v := m.video_url
  12854. if v == nil {
  12855. return
  12856. }
  12857. return *v, true
  12858. }
  12859. // OldVideoURL returns the old "video_url" field's value of the Employee entity.
  12860. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12861. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12862. func (m *EmployeeMutation) OldVideoURL(ctx context.Context) (v string, err error) {
  12863. if !m.op.Is(OpUpdateOne) {
  12864. return v, errors.New("OldVideoURL is only allowed on UpdateOne operations")
  12865. }
  12866. if m.id == nil || m.oldValue == nil {
  12867. return v, errors.New("OldVideoURL requires an ID field in the mutation")
  12868. }
  12869. oldValue, err := m.oldValue(ctx)
  12870. if err != nil {
  12871. return v, fmt.Errorf("querying old value for OldVideoURL: %w", err)
  12872. }
  12873. return oldValue.VideoURL, nil
  12874. }
  12875. // ResetVideoURL resets all changes to the "video_url" field.
  12876. func (m *EmployeeMutation) ResetVideoURL() {
  12877. m.video_url = nil
  12878. }
  12879. // SetOrganizationID sets the "organization_id" field.
  12880. func (m *EmployeeMutation) SetOrganizationID(u uint64) {
  12881. m.organization_id = &u
  12882. m.addorganization_id = nil
  12883. }
  12884. // OrganizationID returns the value of the "organization_id" field in the mutation.
  12885. func (m *EmployeeMutation) OrganizationID() (r uint64, exists bool) {
  12886. v := m.organization_id
  12887. if v == nil {
  12888. return
  12889. }
  12890. return *v, true
  12891. }
  12892. // OldOrganizationID returns the old "organization_id" field's value of the Employee entity.
  12893. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12894. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12895. func (m *EmployeeMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  12896. if !m.op.Is(OpUpdateOne) {
  12897. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  12898. }
  12899. if m.id == nil || m.oldValue == nil {
  12900. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  12901. }
  12902. oldValue, err := m.oldValue(ctx)
  12903. if err != nil {
  12904. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  12905. }
  12906. return oldValue.OrganizationID, nil
  12907. }
  12908. // AddOrganizationID adds u to the "organization_id" field.
  12909. func (m *EmployeeMutation) AddOrganizationID(u int64) {
  12910. if m.addorganization_id != nil {
  12911. *m.addorganization_id += u
  12912. } else {
  12913. m.addorganization_id = &u
  12914. }
  12915. }
  12916. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  12917. func (m *EmployeeMutation) AddedOrganizationID() (r int64, exists bool) {
  12918. v := m.addorganization_id
  12919. if v == nil {
  12920. return
  12921. }
  12922. return *v, true
  12923. }
  12924. // ResetOrganizationID resets all changes to the "organization_id" field.
  12925. func (m *EmployeeMutation) ResetOrganizationID() {
  12926. m.organization_id = nil
  12927. m.addorganization_id = nil
  12928. }
  12929. // SetCategoryID sets the "category_id" field.
  12930. func (m *EmployeeMutation) SetCategoryID(u uint64) {
  12931. m.category_id = &u
  12932. m.addcategory_id = nil
  12933. }
  12934. // CategoryID returns the value of the "category_id" field in the mutation.
  12935. func (m *EmployeeMutation) CategoryID() (r uint64, exists bool) {
  12936. v := m.category_id
  12937. if v == nil {
  12938. return
  12939. }
  12940. return *v, true
  12941. }
  12942. // OldCategoryID returns the old "category_id" field's value of the Employee entity.
  12943. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12944. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12945. func (m *EmployeeMutation) OldCategoryID(ctx context.Context) (v uint64, err error) {
  12946. if !m.op.Is(OpUpdateOne) {
  12947. return v, errors.New("OldCategoryID is only allowed on UpdateOne operations")
  12948. }
  12949. if m.id == nil || m.oldValue == nil {
  12950. return v, errors.New("OldCategoryID requires an ID field in the mutation")
  12951. }
  12952. oldValue, err := m.oldValue(ctx)
  12953. if err != nil {
  12954. return v, fmt.Errorf("querying old value for OldCategoryID: %w", err)
  12955. }
  12956. return oldValue.CategoryID, nil
  12957. }
  12958. // AddCategoryID adds u to the "category_id" field.
  12959. func (m *EmployeeMutation) AddCategoryID(u int64) {
  12960. if m.addcategory_id != nil {
  12961. *m.addcategory_id += u
  12962. } else {
  12963. m.addcategory_id = &u
  12964. }
  12965. }
  12966. // AddedCategoryID returns the value that was added to the "category_id" field in this mutation.
  12967. func (m *EmployeeMutation) AddedCategoryID() (r int64, exists bool) {
  12968. v := m.addcategory_id
  12969. if v == nil {
  12970. return
  12971. }
  12972. return *v, true
  12973. }
  12974. // ResetCategoryID resets all changes to the "category_id" field.
  12975. func (m *EmployeeMutation) ResetCategoryID() {
  12976. m.category_id = nil
  12977. m.addcategory_id = nil
  12978. }
  12979. // SetAPIBase sets the "api_base" field.
  12980. func (m *EmployeeMutation) SetAPIBase(s string) {
  12981. m.api_base = &s
  12982. }
  12983. // APIBase returns the value of the "api_base" field in the mutation.
  12984. func (m *EmployeeMutation) APIBase() (r string, exists bool) {
  12985. v := m.api_base
  12986. if v == nil {
  12987. return
  12988. }
  12989. return *v, true
  12990. }
  12991. // OldAPIBase returns the old "api_base" field's value of the Employee entity.
  12992. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12993. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12994. func (m *EmployeeMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  12995. if !m.op.Is(OpUpdateOne) {
  12996. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  12997. }
  12998. if m.id == nil || m.oldValue == nil {
  12999. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  13000. }
  13001. oldValue, err := m.oldValue(ctx)
  13002. if err != nil {
  13003. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  13004. }
  13005. return oldValue.APIBase, nil
  13006. }
  13007. // ResetAPIBase resets all changes to the "api_base" field.
  13008. func (m *EmployeeMutation) ResetAPIBase() {
  13009. m.api_base = nil
  13010. }
  13011. // SetAPIKey sets the "api_key" field.
  13012. func (m *EmployeeMutation) SetAPIKey(s string) {
  13013. m.api_key = &s
  13014. }
  13015. // APIKey returns the value of the "api_key" field in the mutation.
  13016. func (m *EmployeeMutation) APIKey() (r string, exists bool) {
  13017. v := m.api_key
  13018. if v == nil {
  13019. return
  13020. }
  13021. return *v, true
  13022. }
  13023. // OldAPIKey returns the old "api_key" field's value of the Employee entity.
  13024. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13025. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13026. func (m *EmployeeMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  13027. if !m.op.Is(OpUpdateOne) {
  13028. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  13029. }
  13030. if m.id == nil || m.oldValue == nil {
  13031. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  13032. }
  13033. oldValue, err := m.oldValue(ctx)
  13034. if err != nil {
  13035. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  13036. }
  13037. return oldValue.APIKey, nil
  13038. }
  13039. // ResetAPIKey resets all changes to the "api_key" field.
  13040. func (m *EmployeeMutation) ResetAPIKey() {
  13041. m.api_key = nil
  13042. }
  13043. // SetAiInfo sets the "ai_info" field.
  13044. func (m *EmployeeMutation) SetAiInfo(s string) {
  13045. m.ai_info = &s
  13046. }
  13047. // AiInfo returns the value of the "ai_info" field in the mutation.
  13048. func (m *EmployeeMutation) AiInfo() (r string, exists bool) {
  13049. v := m.ai_info
  13050. if v == nil {
  13051. return
  13052. }
  13053. return *v, true
  13054. }
  13055. // OldAiInfo returns the old "ai_info" field's value of the Employee entity.
  13056. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13057. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13058. func (m *EmployeeMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  13059. if !m.op.Is(OpUpdateOne) {
  13060. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  13061. }
  13062. if m.id == nil || m.oldValue == nil {
  13063. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  13064. }
  13065. oldValue, err := m.oldValue(ctx)
  13066. if err != nil {
  13067. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  13068. }
  13069. return oldValue.AiInfo, nil
  13070. }
  13071. // ClearAiInfo clears the value of the "ai_info" field.
  13072. func (m *EmployeeMutation) ClearAiInfo() {
  13073. m.ai_info = nil
  13074. m.clearedFields[employee.FieldAiInfo] = struct{}{}
  13075. }
  13076. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  13077. func (m *EmployeeMutation) AiInfoCleared() bool {
  13078. _, ok := m.clearedFields[employee.FieldAiInfo]
  13079. return ok
  13080. }
  13081. // ResetAiInfo resets all changes to the "ai_info" field.
  13082. func (m *EmployeeMutation) ResetAiInfo() {
  13083. m.ai_info = nil
  13084. delete(m.clearedFields, employee.FieldAiInfo)
  13085. }
  13086. // SetIsVip sets the "is_vip" field.
  13087. func (m *EmployeeMutation) SetIsVip(i int) {
  13088. m.is_vip = &i
  13089. m.addis_vip = nil
  13090. }
  13091. // IsVip returns the value of the "is_vip" field in the mutation.
  13092. func (m *EmployeeMutation) IsVip() (r int, exists bool) {
  13093. v := m.is_vip
  13094. if v == nil {
  13095. return
  13096. }
  13097. return *v, true
  13098. }
  13099. // OldIsVip returns the old "is_vip" field's value of the Employee entity.
  13100. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13101. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13102. func (m *EmployeeMutation) OldIsVip(ctx context.Context) (v int, err error) {
  13103. if !m.op.Is(OpUpdateOne) {
  13104. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  13105. }
  13106. if m.id == nil || m.oldValue == nil {
  13107. return v, errors.New("OldIsVip requires an ID field in the mutation")
  13108. }
  13109. oldValue, err := m.oldValue(ctx)
  13110. if err != nil {
  13111. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  13112. }
  13113. return oldValue.IsVip, nil
  13114. }
  13115. // AddIsVip adds i to the "is_vip" field.
  13116. func (m *EmployeeMutation) AddIsVip(i int) {
  13117. if m.addis_vip != nil {
  13118. *m.addis_vip += i
  13119. } else {
  13120. m.addis_vip = &i
  13121. }
  13122. }
  13123. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  13124. func (m *EmployeeMutation) AddedIsVip() (r int, exists bool) {
  13125. v := m.addis_vip
  13126. if v == nil {
  13127. return
  13128. }
  13129. return *v, true
  13130. }
  13131. // ResetIsVip resets all changes to the "is_vip" field.
  13132. func (m *EmployeeMutation) ResetIsVip() {
  13133. m.is_vip = nil
  13134. m.addis_vip = nil
  13135. }
  13136. // SetChatURL sets the "chat_url" field.
  13137. func (m *EmployeeMutation) SetChatURL(s string) {
  13138. m.chat_url = &s
  13139. }
  13140. // ChatURL returns the value of the "chat_url" field in the mutation.
  13141. func (m *EmployeeMutation) ChatURL() (r string, exists bool) {
  13142. v := m.chat_url
  13143. if v == nil {
  13144. return
  13145. }
  13146. return *v, true
  13147. }
  13148. // OldChatURL returns the old "chat_url" field's value of the Employee entity.
  13149. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13150. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13151. func (m *EmployeeMutation) OldChatURL(ctx context.Context) (v string, err error) {
  13152. if !m.op.Is(OpUpdateOne) {
  13153. return v, errors.New("OldChatURL is only allowed on UpdateOne operations")
  13154. }
  13155. if m.id == nil || m.oldValue == nil {
  13156. return v, errors.New("OldChatURL requires an ID field in the mutation")
  13157. }
  13158. oldValue, err := m.oldValue(ctx)
  13159. if err != nil {
  13160. return v, fmt.Errorf("querying old value for OldChatURL: %w", err)
  13161. }
  13162. return oldValue.ChatURL, nil
  13163. }
  13164. // ResetChatURL resets all changes to the "chat_url" field.
  13165. func (m *EmployeeMutation) ResetChatURL() {
  13166. m.chat_url = nil
  13167. }
  13168. // AddEmWorkExperienceIDs adds the "em_work_experiences" edge to the WorkExperience entity by ids.
  13169. func (m *EmployeeMutation) AddEmWorkExperienceIDs(ids ...uint64) {
  13170. if m.em_work_experiences == nil {
  13171. m.em_work_experiences = make(map[uint64]struct{})
  13172. }
  13173. for i := range ids {
  13174. m.em_work_experiences[ids[i]] = struct{}{}
  13175. }
  13176. }
  13177. // ClearEmWorkExperiences clears the "em_work_experiences" edge to the WorkExperience entity.
  13178. func (m *EmployeeMutation) ClearEmWorkExperiences() {
  13179. m.clearedem_work_experiences = true
  13180. }
  13181. // EmWorkExperiencesCleared reports if the "em_work_experiences" edge to the WorkExperience entity was cleared.
  13182. func (m *EmployeeMutation) EmWorkExperiencesCleared() bool {
  13183. return m.clearedem_work_experiences
  13184. }
  13185. // RemoveEmWorkExperienceIDs removes the "em_work_experiences" edge to the WorkExperience entity by IDs.
  13186. func (m *EmployeeMutation) RemoveEmWorkExperienceIDs(ids ...uint64) {
  13187. if m.removedem_work_experiences == nil {
  13188. m.removedem_work_experiences = make(map[uint64]struct{})
  13189. }
  13190. for i := range ids {
  13191. delete(m.em_work_experiences, ids[i])
  13192. m.removedem_work_experiences[ids[i]] = struct{}{}
  13193. }
  13194. }
  13195. // RemovedEmWorkExperiences returns the removed IDs of the "em_work_experiences" edge to the WorkExperience entity.
  13196. func (m *EmployeeMutation) RemovedEmWorkExperiencesIDs() (ids []uint64) {
  13197. for id := range m.removedem_work_experiences {
  13198. ids = append(ids, id)
  13199. }
  13200. return
  13201. }
  13202. // EmWorkExperiencesIDs returns the "em_work_experiences" edge IDs in the mutation.
  13203. func (m *EmployeeMutation) EmWorkExperiencesIDs() (ids []uint64) {
  13204. for id := range m.em_work_experiences {
  13205. ids = append(ids, id)
  13206. }
  13207. return
  13208. }
  13209. // ResetEmWorkExperiences resets all changes to the "em_work_experiences" edge.
  13210. func (m *EmployeeMutation) ResetEmWorkExperiences() {
  13211. m.em_work_experiences = nil
  13212. m.clearedem_work_experiences = false
  13213. m.removedem_work_experiences = nil
  13214. }
  13215. // AddEmTutorialIDs adds the "em_tutorial" edge to the Tutorial entity by ids.
  13216. func (m *EmployeeMutation) AddEmTutorialIDs(ids ...uint64) {
  13217. if m.em_tutorial == nil {
  13218. m.em_tutorial = make(map[uint64]struct{})
  13219. }
  13220. for i := range ids {
  13221. m.em_tutorial[ids[i]] = struct{}{}
  13222. }
  13223. }
  13224. // ClearEmTutorial clears the "em_tutorial" edge to the Tutorial entity.
  13225. func (m *EmployeeMutation) ClearEmTutorial() {
  13226. m.clearedem_tutorial = true
  13227. }
  13228. // EmTutorialCleared reports if the "em_tutorial" edge to the Tutorial entity was cleared.
  13229. func (m *EmployeeMutation) EmTutorialCleared() bool {
  13230. return m.clearedem_tutorial
  13231. }
  13232. // RemoveEmTutorialIDs removes the "em_tutorial" edge to the Tutorial entity by IDs.
  13233. func (m *EmployeeMutation) RemoveEmTutorialIDs(ids ...uint64) {
  13234. if m.removedem_tutorial == nil {
  13235. m.removedem_tutorial = make(map[uint64]struct{})
  13236. }
  13237. for i := range ids {
  13238. delete(m.em_tutorial, ids[i])
  13239. m.removedem_tutorial[ids[i]] = struct{}{}
  13240. }
  13241. }
  13242. // RemovedEmTutorial returns the removed IDs of the "em_tutorial" edge to the Tutorial entity.
  13243. func (m *EmployeeMutation) RemovedEmTutorialIDs() (ids []uint64) {
  13244. for id := range m.removedem_tutorial {
  13245. ids = append(ids, id)
  13246. }
  13247. return
  13248. }
  13249. // EmTutorialIDs returns the "em_tutorial" edge IDs in the mutation.
  13250. func (m *EmployeeMutation) EmTutorialIDs() (ids []uint64) {
  13251. for id := range m.em_tutorial {
  13252. ids = append(ids, id)
  13253. }
  13254. return
  13255. }
  13256. // ResetEmTutorial resets all changes to the "em_tutorial" edge.
  13257. func (m *EmployeeMutation) ResetEmTutorial() {
  13258. m.em_tutorial = nil
  13259. m.clearedem_tutorial = false
  13260. m.removedem_tutorial = nil
  13261. }
  13262. // Where appends a list predicates to the EmployeeMutation builder.
  13263. func (m *EmployeeMutation) Where(ps ...predicate.Employee) {
  13264. m.predicates = append(m.predicates, ps...)
  13265. }
  13266. // WhereP appends storage-level predicates to the EmployeeMutation builder. Using this method,
  13267. // users can use type-assertion to append predicates that do not depend on any generated package.
  13268. func (m *EmployeeMutation) WhereP(ps ...func(*sql.Selector)) {
  13269. p := make([]predicate.Employee, len(ps))
  13270. for i := range ps {
  13271. p[i] = ps[i]
  13272. }
  13273. m.Where(p...)
  13274. }
  13275. // Op returns the operation name.
  13276. func (m *EmployeeMutation) Op() Op {
  13277. return m.op
  13278. }
  13279. // SetOp allows setting the mutation operation.
  13280. func (m *EmployeeMutation) SetOp(op Op) {
  13281. m.op = op
  13282. }
  13283. // Type returns the node type of this mutation (Employee).
  13284. func (m *EmployeeMutation) Type() string {
  13285. return m.typ
  13286. }
  13287. // Fields returns all fields that were changed during this mutation. Note that in
  13288. // order to get all numeric fields that were incremented/decremented, call
  13289. // AddedFields().
  13290. func (m *EmployeeMutation) Fields() []string {
  13291. fields := make([]string, 0, 23)
  13292. if m.created_at != nil {
  13293. fields = append(fields, employee.FieldCreatedAt)
  13294. }
  13295. if m.updated_at != nil {
  13296. fields = append(fields, employee.FieldUpdatedAt)
  13297. }
  13298. if m.deleted_at != nil {
  13299. fields = append(fields, employee.FieldDeletedAt)
  13300. }
  13301. if m.title != nil {
  13302. fields = append(fields, employee.FieldTitle)
  13303. }
  13304. if m.avatar != nil {
  13305. fields = append(fields, employee.FieldAvatar)
  13306. }
  13307. if m.tags != nil {
  13308. fields = append(fields, employee.FieldTags)
  13309. }
  13310. if m.hire_count != nil {
  13311. fields = append(fields, employee.FieldHireCount)
  13312. }
  13313. if m.service_count != nil {
  13314. fields = append(fields, employee.FieldServiceCount)
  13315. }
  13316. if m.achievement_count != nil {
  13317. fields = append(fields, employee.FieldAchievementCount)
  13318. }
  13319. if m.intro != nil {
  13320. fields = append(fields, employee.FieldIntro)
  13321. }
  13322. if m.estimate != nil {
  13323. fields = append(fields, employee.FieldEstimate)
  13324. }
  13325. if m.skill != nil {
  13326. fields = append(fields, employee.FieldSkill)
  13327. }
  13328. if m.ability_type != nil {
  13329. fields = append(fields, employee.FieldAbilityType)
  13330. }
  13331. if m.scene != nil {
  13332. fields = append(fields, employee.FieldScene)
  13333. }
  13334. if m.switch_in != nil {
  13335. fields = append(fields, employee.FieldSwitchIn)
  13336. }
  13337. if m.video_url != nil {
  13338. fields = append(fields, employee.FieldVideoURL)
  13339. }
  13340. if m.organization_id != nil {
  13341. fields = append(fields, employee.FieldOrganizationID)
  13342. }
  13343. if m.category_id != nil {
  13344. fields = append(fields, employee.FieldCategoryID)
  13345. }
  13346. if m.api_base != nil {
  13347. fields = append(fields, employee.FieldAPIBase)
  13348. }
  13349. if m.api_key != nil {
  13350. fields = append(fields, employee.FieldAPIKey)
  13351. }
  13352. if m.ai_info != nil {
  13353. fields = append(fields, employee.FieldAiInfo)
  13354. }
  13355. if m.is_vip != nil {
  13356. fields = append(fields, employee.FieldIsVip)
  13357. }
  13358. if m.chat_url != nil {
  13359. fields = append(fields, employee.FieldChatURL)
  13360. }
  13361. return fields
  13362. }
  13363. // Field returns the value of a field with the given name. The second boolean
  13364. // return value indicates that this field was not set, or was not defined in the
  13365. // schema.
  13366. func (m *EmployeeMutation) Field(name string) (ent.Value, bool) {
  13367. switch name {
  13368. case employee.FieldCreatedAt:
  13369. return m.CreatedAt()
  13370. case employee.FieldUpdatedAt:
  13371. return m.UpdatedAt()
  13372. case employee.FieldDeletedAt:
  13373. return m.DeletedAt()
  13374. case employee.FieldTitle:
  13375. return m.Title()
  13376. case employee.FieldAvatar:
  13377. return m.Avatar()
  13378. case employee.FieldTags:
  13379. return m.Tags()
  13380. case employee.FieldHireCount:
  13381. return m.HireCount()
  13382. case employee.FieldServiceCount:
  13383. return m.ServiceCount()
  13384. case employee.FieldAchievementCount:
  13385. return m.AchievementCount()
  13386. case employee.FieldIntro:
  13387. return m.Intro()
  13388. case employee.FieldEstimate:
  13389. return m.Estimate()
  13390. case employee.FieldSkill:
  13391. return m.Skill()
  13392. case employee.FieldAbilityType:
  13393. return m.AbilityType()
  13394. case employee.FieldScene:
  13395. return m.Scene()
  13396. case employee.FieldSwitchIn:
  13397. return m.SwitchIn()
  13398. case employee.FieldVideoURL:
  13399. return m.VideoURL()
  13400. case employee.FieldOrganizationID:
  13401. return m.OrganizationID()
  13402. case employee.FieldCategoryID:
  13403. return m.CategoryID()
  13404. case employee.FieldAPIBase:
  13405. return m.APIBase()
  13406. case employee.FieldAPIKey:
  13407. return m.APIKey()
  13408. case employee.FieldAiInfo:
  13409. return m.AiInfo()
  13410. case employee.FieldIsVip:
  13411. return m.IsVip()
  13412. case employee.FieldChatURL:
  13413. return m.ChatURL()
  13414. }
  13415. return nil, false
  13416. }
  13417. // OldField returns the old value of the field from the database. An error is
  13418. // returned if the mutation operation is not UpdateOne, or the query to the
  13419. // database failed.
  13420. func (m *EmployeeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  13421. switch name {
  13422. case employee.FieldCreatedAt:
  13423. return m.OldCreatedAt(ctx)
  13424. case employee.FieldUpdatedAt:
  13425. return m.OldUpdatedAt(ctx)
  13426. case employee.FieldDeletedAt:
  13427. return m.OldDeletedAt(ctx)
  13428. case employee.FieldTitle:
  13429. return m.OldTitle(ctx)
  13430. case employee.FieldAvatar:
  13431. return m.OldAvatar(ctx)
  13432. case employee.FieldTags:
  13433. return m.OldTags(ctx)
  13434. case employee.FieldHireCount:
  13435. return m.OldHireCount(ctx)
  13436. case employee.FieldServiceCount:
  13437. return m.OldServiceCount(ctx)
  13438. case employee.FieldAchievementCount:
  13439. return m.OldAchievementCount(ctx)
  13440. case employee.FieldIntro:
  13441. return m.OldIntro(ctx)
  13442. case employee.FieldEstimate:
  13443. return m.OldEstimate(ctx)
  13444. case employee.FieldSkill:
  13445. return m.OldSkill(ctx)
  13446. case employee.FieldAbilityType:
  13447. return m.OldAbilityType(ctx)
  13448. case employee.FieldScene:
  13449. return m.OldScene(ctx)
  13450. case employee.FieldSwitchIn:
  13451. return m.OldSwitchIn(ctx)
  13452. case employee.FieldVideoURL:
  13453. return m.OldVideoURL(ctx)
  13454. case employee.FieldOrganizationID:
  13455. return m.OldOrganizationID(ctx)
  13456. case employee.FieldCategoryID:
  13457. return m.OldCategoryID(ctx)
  13458. case employee.FieldAPIBase:
  13459. return m.OldAPIBase(ctx)
  13460. case employee.FieldAPIKey:
  13461. return m.OldAPIKey(ctx)
  13462. case employee.FieldAiInfo:
  13463. return m.OldAiInfo(ctx)
  13464. case employee.FieldIsVip:
  13465. return m.OldIsVip(ctx)
  13466. case employee.FieldChatURL:
  13467. return m.OldChatURL(ctx)
  13468. }
  13469. return nil, fmt.Errorf("unknown Employee field %s", name)
  13470. }
  13471. // SetField sets the value of a field with the given name. It returns an error if
  13472. // the field is not defined in the schema, or if the type mismatched the field
  13473. // type.
  13474. func (m *EmployeeMutation) SetField(name string, value ent.Value) error {
  13475. switch name {
  13476. case employee.FieldCreatedAt:
  13477. v, ok := value.(time.Time)
  13478. if !ok {
  13479. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13480. }
  13481. m.SetCreatedAt(v)
  13482. return nil
  13483. case employee.FieldUpdatedAt:
  13484. v, ok := value.(time.Time)
  13485. if !ok {
  13486. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13487. }
  13488. m.SetUpdatedAt(v)
  13489. return nil
  13490. case employee.FieldDeletedAt:
  13491. v, ok := value.(time.Time)
  13492. if !ok {
  13493. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13494. }
  13495. m.SetDeletedAt(v)
  13496. return nil
  13497. case employee.FieldTitle:
  13498. v, ok := value.(string)
  13499. if !ok {
  13500. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13501. }
  13502. m.SetTitle(v)
  13503. return nil
  13504. case employee.FieldAvatar:
  13505. v, ok := value.(string)
  13506. if !ok {
  13507. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13508. }
  13509. m.SetAvatar(v)
  13510. return nil
  13511. case employee.FieldTags:
  13512. v, ok := value.(string)
  13513. if !ok {
  13514. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13515. }
  13516. m.SetTags(v)
  13517. return nil
  13518. case employee.FieldHireCount:
  13519. v, ok := value.(int)
  13520. if !ok {
  13521. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13522. }
  13523. m.SetHireCount(v)
  13524. return nil
  13525. case employee.FieldServiceCount:
  13526. v, ok := value.(int)
  13527. if !ok {
  13528. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13529. }
  13530. m.SetServiceCount(v)
  13531. return nil
  13532. case employee.FieldAchievementCount:
  13533. v, ok := value.(int)
  13534. if !ok {
  13535. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13536. }
  13537. m.SetAchievementCount(v)
  13538. return nil
  13539. case employee.FieldIntro:
  13540. v, ok := value.(string)
  13541. if !ok {
  13542. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13543. }
  13544. m.SetIntro(v)
  13545. return nil
  13546. case employee.FieldEstimate:
  13547. v, ok := value.(string)
  13548. if !ok {
  13549. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13550. }
  13551. m.SetEstimate(v)
  13552. return nil
  13553. case employee.FieldSkill:
  13554. v, ok := value.(string)
  13555. if !ok {
  13556. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13557. }
  13558. m.SetSkill(v)
  13559. return nil
  13560. case employee.FieldAbilityType:
  13561. v, ok := value.(string)
  13562. if !ok {
  13563. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13564. }
  13565. m.SetAbilityType(v)
  13566. return nil
  13567. case employee.FieldScene:
  13568. v, ok := value.(string)
  13569. if !ok {
  13570. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13571. }
  13572. m.SetScene(v)
  13573. return nil
  13574. case employee.FieldSwitchIn:
  13575. v, ok := value.(string)
  13576. if !ok {
  13577. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13578. }
  13579. m.SetSwitchIn(v)
  13580. return nil
  13581. case employee.FieldVideoURL:
  13582. v, ok := value.(string)
  13583. if !ok {
  13584. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13585. }
  13586. m.SetVideoURL(v)
  13587. return nil
  13588. case employee.FieldOrganizationID:
  13589. v, ok := value.(uint64)
  13590. if !ok {
  13591. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13592. }
  13593. m.SetOrganizationID(v)
  13594. return nil
  13595. case employee.FieldCategoryID:
  13596. v, ok := value.(uint64)
  13597. if !ok {
  13598. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13599. }
  13600. m.SetCategoryID(v)
  13601. return nil
  13602. case employee.FieldAPIBase:
  13603. v, ok := value.(string)
  13604. if !ok {
  13605. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13606. }
  13607. m.SetAPIBase(v)
  13608. return nil
  13609. case employee.FieldAPIKey:
  13610. v, ok := value.(string)
  13611. if !ok {
  13612. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13613. }
  13614. m.SetAPIKey(v)
  13615. return nil
  13616. case employee.FieldAiInfo:
  13617. v, ok := value.(string)
  13618. if !ok {
  13619. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13620. }
  13621. m.SetAiInfo(v)
  13622. return nil
  13623. case employee.FieldIsVip:
  13624. v, ok := value.(int)
  13625. if !ok {
  13626. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13627. }
  13628. m.SetIsVip(v)
  13629. return nil
  13630. case employee.FieldChatURL:
  13631. v, ok := value.(string)
  13632. if !ok {
  13633. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13634. }
  13635. m.SetChatURL(v)
  13636. return nil
  13637. }
  13638. return fmt.Errorf("unknown Employee field %s", name)
  13639. }
  13640. // AddedFields returns all numeric fields that were incremented/decremented during
  13641. // this mutation.
  13642. func (m *EmployeeMutation) AddedFields() []string {
  13643. var fields []string
  13644. if m.addhire_count != nil {
  13645. fields = append(fields, employee.FieldHireCount)
  13646. }
  13647. if m.addservice_count != nil {
  13648. fields = append(fields, employee.FieldServiceCount)
  13649. }
  13650. if m.addachievement_count != nil {
  13651. fields = append(fields, employee.FieldAchievementCount)
  13652. }
  13653. if m.addorganization_id != nil {
  13654. fields = append(fields, employee.FieldOrganizationID)
  13655. }
  13656. if m.addcategory_id != nil {
  13657. fields = append(fields, employee.FieldCategoryID)
  13658. }
  13659. if m.addis_vip != nil {
  13660. fields = append(fields, employee.FieldIsVip)
  13661. }
  13662. return fields
  13663. }
  13664. // AddedField returns the numeric value that was incremented/decremented on a field
  13665. // with the given name. The second boolean return value indicates that this field
  13666. // was not set, or was not defined in the schema.
  13667. func (m *EmployeeMutation) AddedField(name string) (ent.Value, bool) {
  13668. switch name {
  13669. case employee.FieldHireCount:
  13670. return m.AddedHireCount()
  13671. case employee.FieldServiceCount:
  13672. return m.AddedServiceCount()
  13673. case employee.FieldAchievementCount:
  13674. return m.AddedAchievementCount()
  13675. case employee.FieldOrganizationID:
  13676. return m.AddedOrganizationID()
  13677. case employee.FieldCategoryID:
  13678. return m.AddedCategoryID()
  13679. case employee.FieldIsVip:
  13680. return m.AddedIsVip()
  13681. }
  13682. return nil, false
  13683. }
  13684. // AddField adds the value to the field with the given name. It returns an error if
  13685. // the field is not defined in the schema, or if the type mismatched the field
  13686. // type.
  13687. func (m *EmployeeMutation) AddField(name string, value ent.Value) error {
  13688. switch name {
  13689. case employee.FieldHireCount:
  13690. v, ok := value.(int)
  13691. if !ok {
  13692. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13693. }
  13694. m.AddHireCount(v)
  13695. return nil
  13696. case employee.FieldServiceCount:
  13697. v, ok := value.(int)
  13698. if !ok {
  13699. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13700. }
  13701. m.AddServiceCount(v)
  13702. return nil
  13703. case employee.FieldAchievementCount:
  13704. v, ok := value.(int)
  13705. if !ok {
  13706. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13707. }
  13708. m.AddAchievementCount(v)
  13709. return nil
  13710. case employee.FieldOrganizationID:
  13711. v, ok := value.(int64)
  13712. if !ok {
  13713. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13714. }
  13715. m.AddOrganizationID(v)
  13716. return nil
  13717. case employee.FieldCategoryID:
  13718. v, ok := value.(int64)
  13719. if !ok {
  13720. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13721. }
  13722. m.AddCategoryID(v)
  13723. return nil
  13724. case employee.FieldIsVip:
  13725. v, ok := value.(int)
  13726. if !ok {
  13727. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13728. }
  13729. m.AddIsVip(v)
  13730. return nil
  13731. }
  13732. return fmt.Errorf("unknown Employee numeric field %s", name)
  13733. }
  13734. // ClearedFields returns all nullable fields that were cleared during this
  13735. // mutation.
  13736. func (m *EmployeeMutation) ClearedFields() []string {
  13737. var fields []string
  13738. if m.FieldCleared(employee.FieldDeletedAt) {
  13739. fields = append(fields, employee.FieldDeletedAt)
  13740. }
  13741. if m.FieldCleared(employee.FieldAiInfo) {
  13742. fields = append(fields, employee.FieldAiInfo)
  13743. }
  13744. return fields
  13745. }
  13746. // FieldCleared returns a boolean indicating if a field with the given name was
  13747. // cleared in this mutation.
  13748. func (m *EmployeeMutation) FieldCleared(name string) bool {
  13749. _, ok := m.clearedFields[name]
  13750. return ok
  13751. }
  13752. // ClearField clears the value of the field with the given name. It returns an
  13753. // error if the field is not defined in the schema.
  13754. func (m *EmployeeMutation) ClearField(name string) error {
  13755. switch name {
  13756. case employee.FieldDeletedAt:
  13757. m.ClearDeletedAt()
  13758. return nil
  13759. case employee.FieldAiInfo:
  13760. m.ClearAiInfo()
  13761. return nil
  13762. }
  13763. return fmt.Errorf("unknown Employee nullable field %s", name)
  13764. }
  13765. // ResetField resets all changes in the mutation for the field with the given name.
  13766. // It returns an error if the field is not defined in the schema.
  13767. func (m *EmployeeMutation) ResetField(name string) error {
  13768. switch name {
  13769. case employee.FieldCreatedAt:
  13770. m.ResetCreatedAt()
  13771. return nil
  13772. case employee.FieldUpdatedAt:
  13773. m.ResetUpdatedAt()
  13774. return nil
  13775. case employee.FieldDeletedAt:
  13776. m.ResetDeletedAt()
  13777. return nil
  13778. case employee.FieldTitle:
  13779. m.ResetTitle()
  13780. return nil
  13781. case employee.FieldAvatar:
  13782. m.ResetAvatar()
  13783. return nil
  13784. case employee.FieldTags:
  13785. m.ResetTags()
  13786. return nil
  13787. case employee.FieldHireCount:
  13788. m.ResetHireCount()
  13789. return nil
  13790. case employee.FieldServiceCount:
  13791. m.ResetServiceCount()
  13792. return nil
  13793. case employee.FieldAchievementCount:
  13794. m.ResetAchievementCount()
  13795. return nil
  13796. case employee.FieldIntro:
  13797. m.ResetIntro()
  13798. return nil
  13799. case employee.FieldEstimate:
  13800. m.ResetEstimate()
  13801. return nil
  13802. case employee.FieldSkill:
  13803. m.ResetSkill()
  13804. return nil
  13805. case employee.FieldAbilityType:
  13806. m.ResetAbilityType()
  13807. return nil
  13808. case employee.FieldScene:
  13809. m.ResetScene()
  13810. return nil
  13811. case employee.FieldSwitchIn:
  13812. m.ResetSwitchIn()
  13813. return nil
  13814. case employee.FieldVideoURL:
  13815. m.ResetVideoURL()
  13816. return nil
  13817. case employee.FieldOrganizationID:
  13818. m.ResetOrganizationID()
  13819. return nil
  13820. case employee.FieldCategoryID:
  13821. m.ResetCategoryID()
  13822. return nil
  13823. case employee.FieldAPIBase:
  13824. m.ResetAPIBase()
  13825. return nil
  13826. case employee.FieldAPIKey:
  13827. m.ResetAPIKey()
  13828. return nil
  13829. case employee.FieldAiInfo:
  13830. m.ResetAiInfo()
  13831. return nil
  13832. case employee.FieldIsVip:
  13833. m.ResetIsVip()
  13834. return nil
  13835. case employee.FieldChatURL:
  13836. m.ResetChatURL()
  13837. return nil
  13838. }
  13839. return fmt.Errorf("unknown Employee field %s", name)
  13840. }
  13841. // AddedEdges returns all edge names that were set/added in this mutation.
  13842. func (m *EmployeeMutation) AddedEdges() []string {
  13843. edges := make([]string, 0, 2)
  13844. if m.em_work_experiences != nil {
  13845. edges = append(edges, employee.EdgeEmWorkExperiences)
  13846. }
  13847. if m.em_tutorial != nil {
  13848. edges = append(edges, employee.EdgeEmTutorial)
  13849. }
  13850. return edges
  13851. }
  13852. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  13853. // name in this mutation.
  13854. func (m *EmployeeMutation) AddedIDs(name string) []ent.Value {
  13855. switch name {
  13856. case employee.EdgeEmWorkExperiences:
  13857. ids := make([]ent.Value, 0, len(m.em_work_experiences))
  13858. for id := range m.em_work_experiences {
  13859. ids = append(ids, id)
  13860. }
  13861. return ids
  13862. case employee.EdgeEmTutorial:
  13863. ids := make([]ent.Value, 0, len(m.em_tutorial))
  13864. for id := range m.em_tutorial {
  13865. ids = append(ids, id)
  13866. }
  13867. return ids
  13868. }
  13869. return nil
  13870. }
  13871. // RemovedEdges returns all edge names that were removed in this mutation.
  13872. func (m *EmployeeMutation) RemovedEdges() []string {
  13873. edges := make([]string, 0, 2)
  13874. if m.removedem_work_experiences != nil {
  13875. edges = append(edges, employee.EdgeEmWorkExperiences)
  13876. }
  13877. if m.removedem_tutorial != nil {
  13878. edges = append(edges, employee.EdgeEmTutorial)
  13879. }
  13880. return edges
  13881. }
  13882. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  13883. // the given name in this mutation.
  13884. func (m *EmployeeMutation) RemovedIDs(name string) []ent.Value {
  13885. switch name {
  13886. case employee.EdgeEmWorkExperiences:
  13887. ids := make([]ent.Value, 0, len(m.removedem_work_experiences))
  13888. for id := range m.removedem_work_experiences {
  13889. ids = append(ids, id)
  13890. }
  13891. return ids
  13892. case employee.EdgeEmTutorial:
  13893. ids := make([]ent.Value, 0, len(m.removedem_tutorial))
  13894. for id := range m.removedem_tutorial {
  13895. ids = append(ids, id)
  13896. }
  13897. return ids
  13898. }
  13899. return nil
  13900. }
  13901. // ClearedEdges returns all edge names that were cleared in this mutation.
  13902. func (m *EmployeeMutation) ClearedEdges() []string {
  13903. edges := make([]string, 0, 2)
  13904. if m.clearedem_work_experiences {
  13905. edges = append(edges, employee.EdgeEmWorkExperiences)
  13906. }
  13907. if m.clearedem_tutorial {
  13908. edges = append(edges, employee.EdgeEmTutorial)
  13909. }
  13910. return edges
  13911. }
  13912. // EdgeCleared returns a boolean which indicates if the edge with the given name
  13913. // was cleared in this mutation.
  13914. func (m *EmployeeMutation) EdgeCleared(name string) bool {
  13915. switch name {
  13916. case employee.EdgeEmWorkExperiences:
  13917. return m.clearedem_work_experiences
  13918. case employee.EdgeEmTutorial:
  13919. return m.clearedem_tutorial
  13920. }
  13921. return false
  13922. }
  13923. // ClearEdge clears the value of the edge with the given name. It returns an error
  13924. // if that edge is not defined in the schema.
  13925. func (m *EmployeeMutation) ClearEdge(name string) error {
  13926. switch name {
  13927. }
  13928. return fmt.Errorf("unknown Employee unique edge %s", name)
  13929. }
  13930. // ResetEdge resets all changes to the edge with the given name in this mutation.
  13931. // It returns an error if the edge is not defined in the schema.
  13932. func (m *EmployeeMutation) ResetEdge(name string) error {
  13933. switch name {
  13934. case employee.EdgeEmWorkExperiences:
  13935. m.ResetEmWorkExperiences()
  13936. return nil
  13937. case employee.EdgeEmTutorial:
  13938. m.ResetEmTutorial()
  13939. return nil
  13940. }
  13941. return fmt.Errorf("unknown Employee edge %s", name)
  13942. }
  13943. // EmployeeConfigMutation represents an operation that mutates the EmployeeConfig nodes in the graph.
  13944. type EmployeeConfigMutation struct {
  13945. config
  13946. op Op
  13947. typ string
  13948. id *uint64
  13949. created_at *time.Time
  13950. updated_at *time.Time
  13951. deleted_at *time.Time
  13952. stype *string
  13953. title *string
  13954. photo *string
  13955. organization_id *uint64
  13956. addorganization_id *int64
  13957. clearedFields map[string]struct{}
  13958. done bool
  13959. oldValue func(context.Context) (*EmployeeConfig, error)
  13960. predicates []predicate.EmployeeConfig
  13961. }
  13962. var _ ent.Mutation = (*EmployeeConfigMutation)(nil)
  13963. // employeeconfigOption allows management of the mutation configuration using functional options.
  13964. type employeeconfigOption func(*EmployeeConfigMutation)
  13965. // newEmployeeConfigMutation creates new mutation for the EmployeeConfig entity.
  13966. func newEmployeeConfigMutation(c config, op Op, opts ...employeeconfigOption) *EmployeeConfigMutation {
  13967. m := &EmployeeConfigMutation{
  13968. config: c,
  13969. op: op,
  13970. typ: TypeEmployeeConfig,
  13971. clearedFields: make(map[string]struct{}),
  13972. }
  13973. for _, opt := range opts {
  13974. opt(m)
  13975. }
  13976. return m
  13977. }
  13978. // withEmployeeConfigID sets the ID field of the mutation.
  13979. func withEmployeeConfigID(id uint64) employeeconfigOption {
  13980. return func(m *EmployeeConfigMutation) {
  13981. var (
  13982. err error
  13983. once sync.Once
  13984. value *EmployeeConfig
  13985. )
  13986. m.oldValue = func(ctx context.Context) (*EmployeeConfig, error) {
  13987. once.Do(func() {
  13988. if m.done {
  13989. err = errors.New("querying old values post mutation is not allowed")
  13990. } else {
  13991. value, err = m.Client().EmployeeConfig.Get(ctx, id)
  13992. }
  13993. })
  13994. return value, err
  13995. }
  13996. m.id = &id
  13997. }
  13998. }
  13999. // withEmployeeConfig sets the old EmployeeConfig of the mutation.
  14000. func withEmployeeConfig(node *EmployeeConfig) employeeconfigOption {
  14001. return func(m *EmployeeConfigMutation) {
  14002. m.oldValue = func(context.Context) (*EmployeeConfig, error) {
  14003. return node, nil
  14004. }
  14005. m.id = &node.ID
  14006. }
  14007. }
  14008. // Client returns a new `ent.Client` from the mutation. If the mutation was
  14009. // executed in a transaction (ent.Tx), a transactional client is returned.
  14010. func (m EmployeeConfigMutation) Client() *Client {
  14011. client := &Client{config: m.config}
  14012. client.init()
  14013. return client
  14014. }
  14015. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  14016. // it returns an error otherwise.
  14017. func (m EmployeeConfigMutation) Tx() (*Tx, error) {
  14018. if _, ok := m.driver.(*txDriver); !ok {
  14019. return nil, errors.New("ent: mutation is not running in a transaction")
  14020. }
  14021. tx := &Tx{config: m.config}
  14022. tx.init()
  14023. return tx, nil
  14024. }
  14025. // SetID sets the value of the id field. Note that this
  14026. // operation is only accepted on creation of EmployeeConfig entities.
  14027. func (m *EmployeeConfigMutation) SetID(id uint64) {
  14028. m.id = &id
  14029. }
  14030. // ID returns the ID value in the mutation. Note that the ID is only available
  14031. // if it was provided to the builder or after it was returned from the database.
  14032. func (m *EmployeeConfigMutation) ID() (id uint64, exists bool) {
  14033. if m.id == nil {
  14034. return
  14035. }
  14036. return *m.id, true
  14037. }
  14038. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  14039. // That means, if the mutation is applied within a transaction with an isolation level such
  14040. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  14041. // or updated by the mutation.
  14042. func (m *EmployeeConfigMutation) IDs(ctx context.Context) ([]uint64, error) {
  14043. switch {
  14044. case m.op.Is(OpUpdateOne | OpDeleteOne):
  14045. id, exists := m.ID()
  14046. if exists {
  14047. return []uint64{id}, nil
  14048. }
  14049. fallthrough
  14050. case m.op.Is(OpUpdate | OpDelete):
  14051. return m.Client().EmployeeConfig.Query().Where(m.predicates...).IDs(ctx)
  14052. default:
  14053. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  14054. }
  14055. }
  14056. // SetCreatedAt sets the "created_at" field.
  14057. func (m *EmployeeConfigMutation) SetCreatedAt(t time.Time) {
  14058. m.created_at = &t
  14059. }
  14060. // CreatedAt returns the value of the "created_at" field in the mutation.
  14061. func (m *EmployeeConfigMutation) CreatedAt() (r time.Time, exists bool) {
  14062. v := m.created_at
  14063. if v == nil {
  14064. return
  14065. }
  14066. return *v, true
  14067. }
  14068. // OldCreatedAt returns the old "created_at" field's value of the EmployeeConfig entity.
  14069. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  14070. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14071. func (m *EmployeeConfigMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  14072. if !m.op.Is(OpUpdateOne) {
  14073. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  14074. }
  14075. if m.id == nil || m.oldValue == nil {
  14076. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  14077. }
  14078. oldValue, err := m.oldValue(ctx)
  14079. if err != nil {
  14080. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  14081. }
  14082. return oldValue.CreatedAt, nil
  14083. }
  14084. // ResetCreatedAt resets all changes to the "created_at" field.
  14085. func (m *EmployeeConfigMutation) ResetCreatedAt() {
  14086. m.created_at = nil
  14087. }
  14088. // SetUpdatedAt sets the "updated_at" field.
  14089. func (m *EmployeeConfigMutation) SetUpdatedAt(t time.Time) {
  14090. m.updated_at = &t
  14091. }
  14092. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  14093. func (m *EmployeeConfigMutation) UpdatedAt() (r time.Time, exists bool) {
  14094. v := m.updated_at
  14095. if v == nil {
  14096. return
  14097. }
  14098. return *v, true
  14099. }
  14100. // OldUpdatedAt returns the old "updated_at" field's value of the EmployeeConfig entity.
  14101. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  14102. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14103. func (m *EmployeeConfigMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  14104. if !m.op.Is(OpUpdateOne) {
  14105. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  14106. }
  14107. if m.id == nil || m.oldValue == nil {
  14108. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  14109. }
  14110. oldValue, err := m.oldValue(ctx)
  14111. if err != nil {
  14112. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  14113. }
  14114. return oldValue.UpdatedAt, nil
  14115. }
  14116. // ResetUpdatedAt resets all changes to the "updated_at" field.
  14117. func (m *EmployeeConfigMutation) ResetUpdatedAt() {
  14118. m.updated_at = nil
  14119. }
  14120. // SetDeletedAt sets the "deleted_at" field.
  14121. func (m *EmployeeConfigMutation) SetDeletedAt(t time.Time) {
  14122. m.deleted_at = &t
  14123. }
  14124. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  14125. func (m *EmployeeConfigMutation) DeletedAt() (r time.Time, exists bool) {
  14126. v := m.deleted_at
  14127. if v == nil {
  14128. return
  14129. }
  14130. return *v, true
  14131. }
  14132. // OldDeletedAt returns the old "deleted_at" field's value of the EmployeeConfig entity.
  14133. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  14134. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14135. func (m *EmployeeConfigMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  14136. if !m.op.Is(OpUpdateOne) {
  14137. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  14138. }
  14139. if m.id == nil || m.oldValue == nil {
  14140. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  14141. }
  14142. oldValue, err := m.oldValue(ctx)
  14143. if err != nil {
  14144. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  14145. }
  14146. return oldValue.DeletedAt, nil
  14147. }
  14148. // ClearDeletedAt clears the value of the "deleted_at" field.
  14149. func (m *EmployeeConfigMutation) ClearDeletedAt() {
  14150. m.deleted_at = nil
  14151. m.clearedFields[employeeconfig.FieldDeletedAt] = struct{}{}
  14152. }
  14153. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  14154. func (m *EmployeeConfigMutation) DeletedAtCleared() bool {
  14155. _, ok := m.clearedFields[employeeconfig.FieldDeletedAt]
  14156. return ok
  14157. }
  14158. // ResetDeletedAt resets all changes to the "deleted_at" field.
  14159. func (m *EmployeeConfigMutation) ResetDeletedAt() {
  14160. m.deleted_at = nil
  14161. delete(m.clearedFields, employeeconfig.FieldDeletedAt)
  14162. }
  14163. // SetStype sets the "stype" field.
  14164. func (m *EmployeeConfigMutation) SetStype(s string) {
  14165. m.stype = &s
  14166. }
  14167. // Stype returns the value of the "stype" field in the mutation.
  14168. func (m *EmployeeConfigMutation) Stype() (r string, exists bool) {
  14169. v := m.stype
  14170. if v == nil {
  14171. return
  14172. }
  14173. return *v, true
  14174. }
  14175. // OldStype returns the old "stype" field's value of the EmployeeConfig entity.
  14176. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  14177. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14178. func (m *EmployeeConfigMutation) OldStype(ctx context.Context) (v string, err error) {
  14179. if !m.op.Is(OpUpdateOne) {
  14180. return v, errors.New("OldStype is only allowed on UpdateOne operations")
  14181. }
  14182. if m.id == nil || m.oldValue == nil {
  14183. return v, errors.New("OldStype requires an ID field in the mutation")
  14184. }
  14185. oldValue, err := m.oldValue(ctx)
  14186. if err != nil {
  14187. return v, fmt.Errorf("querying old value for OldStype: %w", err)
  14188. }
  14189. return oldValue.Stype, nil
  14190. }
  14191. // ResetStype resets all changes to the "stype" field.
  14192. func (m *EmployeeConfigMutation) ResetStype() {
  14193. m.stype = nil
  14194. }
  14195. // SetTitle sets the "title" field.
  14196. func (m *EmployeeConfigMutation) SetTitle(s string) {
  14197. m.title = &s
  14198. }
  14199. // Title returns the value of the "title" field in the mutation.
  14200. func (m *EmployeeConfigMutation) Title() (r string, exists bool) {
  14201. v := m.title
  14202. if v == nil {
  14203. return
  14204. }
  14205. return *v, true
  14206. }
  14207. // OldTitle returns the old "title" field's value of the EmployeeConfig entity.
  14208. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  14209. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14210. func (m *EmployeeConfigMutation) OldTitle(ctx context.Context) (v string, err error) {
  14211. if !m.op.Is(OpUpdateOne) {
  14212. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  14213. }
  14214. if m.id == nil || m.oldValue == nil {
  14215. return v, errors.New("OldTitle requires an ID field in the mutation")
  14216. }
  14217. oldValue, err := m.oldValue(ctx)
  14218. if err != nil {
  14219. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  14220. }
  14221. return oldValue.Title, nil
  14222. }
  14223. // ResetTitle resets all changes to the "title" field.
  14224. func (m *EmployeeConfigMutation) ResetTitle() {
  14225. m.title = nil
  14226. }
  14227. // SetPhoto sets the "photo" field.
  14228. func (m *EmployeeConfigMutation) SetPhoto(s string) {
  14229. m.photo = &s
  14230. }
  14231. // Photo returns the value of the "photo" field in the mutation.
  14232. func (m *EmployeeConfigMutation) Photo() (r string, exists bool) {
  14233. v := m.photo
  14234. if v == nil {
  14235. return
  14236. }
  14237. return *v, true
  14238. }
  14239. // OldPhoto returns the old "photo" field's value of the EmployeeConfig entity.
  14240. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  14241. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14242. func (m *EmployeeConfigMutation) OldPhoto(ctx context.Context) (v string, err error) {
  14243. if !m.op.Is(OpUpdateOne) {
  14244. return v, errors.New("OldPhoto is only allowed on UpdateOne operations")
  14245. }
  14246. if m.id == nil || m.oldValue == nil {
  14247. return v, errors.New("OldPhoto requires an ID field in the mutation")
  14248. }
  14249. oldValue, err := m.oldValue(ctx)
  14250. if err != nil {
  14251. return v, fmt.Errorf("querying old value for OldPhoto: %w", err)
  14252. }
  14253. return oldValue.Photo, nil
  14254. }
  14255. // ResetPhoto resets all changes to the "photo" field.
  14256. func (m *EmployeeConfigMutation) ResetPhoto() {
  14257. m.photo = nil
  14258. }
  14259. // SetOrganizationID sets the "organization_id" field.
  14260. func (m *EmployeeConfigMutation) SetOrganizationID(u uint64) {
  14261. m.organization_id = &u
  14262. m.addorganization_id = nil
  14263. }
  14264. // OrganizationID returns the value of the "organization_id" field in the mutation.
  14265. func (m *EmployeeConfigMutation) OrganizationID() (r uint64, exists bool) {
  14266. v := m.organization_id
  14267. if v == nil {
  14268. return
  14269. }
  14270. return *v, true
  14271. }
  14272. // OldOrganizationID returns the old "organization_id" field's value of the EmployeeConfig entity.
  14273. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  14274. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14275. func (m *EmployeeConfigMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  14276. if !m.op.Is(OpUpdateOne) {
  14277. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  14278. }
  14279. if m.id == nil || m.oldValue == nil {
  14280. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  14281. }
  14282. oldValue, err := m.oldValue(ctx)
  14283. if err != nil {
  14284. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  14285. }
  14286. return oldValue.OrganizationID, nil
  14287. }
  14288. // AddOrganizationID adds u to the "organization_id" field.
  14289. func (m *EmployeeConfigMutation) AddOrganizationID(u int64) {
  14290. if m.addorganization_id != nil {
  14291. *m.addorganization_id += u
  14292. } else {
  14293. m.addorganization_id = &u
  14294. }
  14295. }
  14296. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  14297. func (m *EmployeeConfigMutation) AddedOrganizationID() (r int64, exists bool) {
  14298. v := m.addorganization_id
  14299. if v == nil {
  14300. return
  14301. }
  14302. return *v, true
  14303. }
  14304. // ClearOrganizationID clears the value of the "organization_id" field.
  14305. func (m *EmployeeConfigMutation) ClearOrganizationID() {
  14306. m.organization_id = nil
  14307. m.addorganization_id = nil
  14308. m.clearedFields[employeeconfig.FieldOrganizationID] = struct{}{}
  14309. }
  14310. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  14311. func (m *EmployeeConfigMutation) OrganizationIDCleared() bool {
  14312. _, ok := m.clearedFields[employeeconfig.FieldOrganizationID]
  14313. return ok
  14314. }
  14315. // ResetOrganizationID resets all changes to the "organization_id" field.
  14316. func (m *EmployeeConfigMutation) ResetOrganizationID() {
  14317. m.organization_id = nil
  14318. m.addorganization_id = nil
  14319. delete(m.clearedFields, employeeconfig.FieldOrganizationID)
  14320. }
  14321. // Where appends a list predicates to the EmployeeConfigMutation builder.
  14322. func (m *EmployeeConfigMutation) Where(ps ...predicate.EmployeeConfig) {
  14323. m.predicates = append(m.predicates, ps...)
  14324. }
  14325. // WhereP appends storage-level predicates to the EmployeeConfigMutation builder. Using this method,
  14326. // users can use type-assertion to append predicates that do not depend on any generated package.
  14327. func (m *EmployeeConfigMutation) WhereP(ps ...func(*sql.Selector)) {
  14328. p := make([]predicate.EmployeeConfig, len(ps))
  14329. for i := range ps {
  14330. p[i] = ps[i]
  14331. }
  14332. m.Where(p...)
  14333. }
  14334. // Op returns the operation name.
  14335. func (m *EmployeeConfigMutation) Op() Op {
  14336. return m.op
  14337. }
  14338. // SetOp allows setting the mutation operation.
  14339. func (m *EmployeeConfigMutation) SetOp(op Op) {
  14340. m.op = op
  14341. }
  14342. // Type returns the node type of this mutation (EmployeeConfig).
  14343. func (m *EmployeeConfigMutation) Type() string {
  14344. return m.typ
  14345. }
  14346. // Fields returns all fields that were changed during this mutation. Note that in
  14347. // order to get all numeric fields that were incremented/decremented, call
  14348. // AddedFields().
  14349. func (m *EmployeeConfigMutation) Fields() []string {
  14350. fields := make([]string, 0, 7)
  14351. if m.created_at != nil {
  14352. fields = append(fields, employeeconfig.FieldCreatedAt)
  14353. }
  14354. if m.updated_at != nil {
  14355. fields = append(fields, employeeconfig.FieldUpdatedAt)
  14356. }
  14357. if m.deleted_at != nil {
  14358. fields = append(fields, employeeconfig.FieldDeletedAt)
  14359. }
  14360. if m.stype != nil {
  14361. fields = append(fields, employeeconfig.FieldStype)
  14362. }
  14363. if m.title != nil {
  14364. fields = append(fields, employeeconfig.FieldTitle)
  14365. }
  14366. if m.photo != nil {
  14367. fields = append(fields, employeeconfig.FieldPhoto)
  14368. }
  14369. if m.organization_id != nil {
  14370. fields = append(fields, employeeconfig.FieldOrganizationID)
  14371. }
  14372. return fields
  14373. }
  14374. // Field returns the value of a field with the given name. The second boolean
  14375. // return value indicates that this field was not set, or was not defined in the
  14376. // schema.
  14377. func (m *EmployeeConfigMutation) Field(name string) (ent.Value, bool) {
  14378. switch name {
  14379. case employeeconfig.FieldCreatedAt:
  14380. return m.CreatedAt()
  14381. case employeeconfig.FieldUpdatedAt:
  14382. return m.UpdatedAt()
  14383. case employeeconfig.FieldDeletedAt:
  14384. return m.DeletedAt()
  14385. case employeeconfig.FieldStype:
  14386. return m.Stype()
  14387. case employeeconfig.FieldTitle:
  14388. return m.Title()
  14389. case employeeconfig.FieldPhoto:
  14390. return m.Photo()
  14391. case employeeconfig.FieldOrganizationID:
  14392. return m.OrganizationID()
  14393. }
  14394. return nil, false
  14395. }
  14396. // OldField returns the old value of the field from the database. An error is
  14397. // returned if the mutation operation is not UpdateOne, or the query to the
  14398. // database failed.
  14399. func (m *EmployeeConfigMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  14400. switch name {
  14401. case employeeconfig.FieldCreatedAt:
  14402. return m.OldCreatedAt(ctx)
  14403. case employeeconfig.FieldUpdatedAt:
  14404. return m.OldUpdatedAt(ctx)
  14405. case employeeconfig.FieldDeletedAt:
  14406. return m.OldDeletedAt(ctx)
  14407. case employeeconfig.FieldStype:
  14408. return m.OldStype(ctx)
  14409. case employeeconfig.FieldTitle:
  14410. return m.OldTitle(ctx)
  14411. case employeeconfig.FieldPhoto:
  14412. return m.OldPhoto(ctx)
  14413. case employeeconfig.FieldOrganizationID:
  14414. return m.OldOrganizationID(ctx)
  14415. }
  14416. return nil, fmt.Errorf("unknown EmployeeConfig field %s", name)
  14417. }
  14418. // SetField sets the value of a field with the given name. It returns an error if
  14419. // the field is not defined in the schema, or if the type mismatched the field
  14420. // type.
  14421. func (m *EmployeeConfigMutation) SetField(name string, value ent.Value) error {
  14422. switch name {
  14423. case employeeconfig.FieldCreatedAt:
  14424. v, ok := value.(time.Time)
  14425. if !ok {
  14426. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14427. }
  14428. m.SetCreatedAt(v)
  14429. return nil
  14430. case employeeconfig.FieldUpdatedAt:
  14431. v, ok := value.(time.Time)
  14432. if !ok {
  14433. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14434. }
  14435. m.SetUpdatedAt(v)
  14436. return nil
  14437. case employeeconfig.FieldDeletedAt:
  14438. v, ok := value.(time.Time)
  14439. if !ok {
  14440. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14441. }
  14442. m.SetDeletedAt(v)
  14443. return nil
  14444. case employeeconfig.FieldStype:
  14445. v, ok := value.(string)
  14446. if !ok {
  14447. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14448. }
  14449. m.SetStype(v)
  14450. return nil
  14451. case employeeconfig.FieldTitle:
  14452. v, ok := value.(string)
  14453. if !ok {
  14454. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14455. }
  14456. m.SetTitle(v)
  14457. return nil
  14458. case employeeconfig.FieldPhoto:
  14459. v, ok := value.(string)
  14460. if !ok {
  14461. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14462. }
  14463. m.SetPhoto(v)
  14464. return nil
  14465. case employeeconfig.FieldOrganizationID:
  14466. v, ok := value.(uint64)
  14467. if !ok {
  14468. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14469. }
  14470. m.SetOrganizationID(v)
  14471. return nil
  14472. }
  14473. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  14474. }
  14475. // AddedFields returns all numeric fields that were incremented/decremented during
  14476. // this mutation.
  14477. func (m *EmployeeConfigMutation) AddedFields() []string {
  14478. var fields []string
  14479. if m.addorganization_id != nil {
  14480. fields = append(fields, employeeconfig.FieldOrganizationID)
  14481. }
  14482. return fields
  14483. }
  14484. // AddedField returns the numeric value that was incremented/decremented on a field
  14485. // with the given name. The second boolean return value indicates that this field
  14486. // was not set, or was not defined in the schema.
  14487. func (m *EmployeeConfigMutation) AddedField(name string) (ent.Value, bool) {
  14488. switch name {
  14489. case employeeconfig.FieldOrganizationID:
  14490. return m.AddedOrganizationID()
  14491. }
  14492. return nil, false
  14493. }
  14494. // AddField adds the value to the field with the given name. It returns an error if
  14495. // the field is not defined in the schema, or if the type mismatched the field
  14496. // type.
  14497. func (m *EmployeeConfigMutation) AddField(name string, value ent.Value) error {
  14498. switch name {
  14499. case employeeconfig.FieldOrganizationID:
  14500. v, ok := value.(int64)
  14501. if !ok {
  14502. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14503. }
  14504. m.AddOrganizationID(v)
  14505. return nil
  14506. }
  14507. return fmt.Errorf("unknown EmployeeConfig numeric field %s", name)
  14508. }
  14509. // ClearedFields returns all nullable fields that were cleared during this
  14510. // mutation.
  14511. func (m *EmployeeConfigMutation) ClearedFields() []string {
  14512. var fields []string
  14513. if m.FieldCleared(employeeconfig.FieldDeletedAt) {
  14514. fields = append(fields, employeeconfig.FieldDeletedAt)
  14515. }
  14516. if m.FieldCleared(employeeconfig.FieldOrganizationID) {
  14517. fields = append(fields, employeeconfig.FieldOrganizationID)
  14518. }
  14519. return fields
  14520. }
  14521. // FieldCleared returns a boolean indicating if a field with the given name was
  14522. // cleared in this mutation.
  14523. func (m *EmployeeConfigMutation) FieldCleared(name string) bool {
  14524. _, ok := m.clearedFields[name]
  14525. return ok
  14526. }
  14527. // ClearField clears the value of the field with the given name. It returns an
  14528. // error if the field is not defined in the schema.
  14529. func (m *EmployeeConfigMutation) ClearField(name string) error {
  14530. switch name {
  14531. case employeeconfig.FieldDeletedAt:
  14532. m.ClearDeletedAt()
  14533. return nil
  14534. case employeeconfig.FieldOrganizationID:
  14535. m.ClearOrganizationID()
  14536. return nil
  14537. }
  14538. return fmt.Errorf("unknown EmployeeConfig nullable field %s", name)
  14539. }
  14540. // ResetField resets all changes in the mutation for the field with the given name.
  14541. // It returns an error if the field is not defined in the schema.
  14542. func (m *EmployeeConfigMutation) ResetField(name string) error {
  14543. switch name {
  14544. case employeeconfig.FieldCreatedAt:
  14545. m.ResetCreatedAt()
  14546. return nil
  14547. case employeeconfig.FieldUpdatedAt:
  14548. m.ResetUpdatedAt()
  14549. return nil
  14550. case employeeconfig.FieldDeletedAt:
  14551. m.ResetDeletedAt()
  14552. return nil
  14553. case employeeconfig.FieldStype:
  14554. m.ResetStype()
  14555. return nil
  14556. case employeeconfig.FieldTitle:
  14557. m.ResetTitle()
  14558. return nil
  14559. case employeeconfig.FieldPhoto:
  14560. m.ResetPhoto()
  14561. return nil
  14562. case employeeconfig.FieldOrganizationID:
  14563. m.ResetOrganizationID()
  14564. return nil
  14565. }
  14566. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  14567. }
  14568. // AddedEdges returns all edge names that were set/added in this mutation.
  14569. func (m *EmployeeConfigMutation) AddedEdges() []string {
  14570. edges := make([]string, 0, 0)
  14571. return edges
  14572. }
  14573. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  14574. // name in this mutation.
  14575. func (m *EmployeeConfigMutation) AddedIDs(name string) []ent.Value {
  14576. return nil
  14577. }
  14578. // RemovedEdges returns all edge names that were removed in this mutation.
  14579. func (m *EmployeeConfigMutation) RemovedEdges() []string {
  14580. edges := make([]string, 0, 0)
  14581. return edges
  14582. }
  14583. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  14584. // the given name in this mutation.
  14585. func (m *EmployeeConfigMutation) RemovedIDs(name string) []ent.Value {
  14586. return nil
  14587. }
  14588. // ClearedEdges returns all edge names that were cleared in this mutation.
  14589. func (m *EmployeeConfigMutation) ClearedEdges() []string {
  14590. edges := make([]string, 0, 0)
  14591. return edges
  14592. }
  14593. // EdgeCleared returns a boolean which indicates if the edge with the given name
  14594. // was cleared in this mutation.
  14595. func (m *EmployeeConfigMutation) EdgeCleared(name string) bool {
  14596. return false
  14597. }
  14598. // ClearEdge clears the value of the edge with the given name. It returns an error
  14599. // if that edge is not defined in the schema.
  14600. func (m *EmployeeConfigMutation) ClearEdge(name string) error {
  14601. return fmt.Errorf("unknown EmployeeConfig unique edge %s", name)
  14602. }
  14603. // ResetEdge resets all changes to the edge with the given name in this mutation.
  14604. // It returns an error if the edge is not defined in the schema.
  14605. func (m *EmployeeConfigMutation) ResetEdge(name string) error {
  14606. return fmt.Errorf("unknown EmployeeConfig edge %s", name)
  14607. }
  14608. // LabelMutation represents an operation that mutates the Label nodes in the graph.
  14609. type LabelMutation struct {
  14610. config
  14611. op Op
  14612. typ string
  14613. id *uint64
  14614. created_at *time.Time
  14615. updated_at *time.Time
  14616. status *uint8
  14617. addstatus *int8
  14618. _type *int
  14619. add_type *int
  14620. name *string
  14621. from *int
  14622. addfrom *int
  14623. mode *int
  14624. addmode *int
  14625. conditions *string
  14626. organization_id *uint64
  14627. addorganization_id *int64
  14628. clearedFields map[string]struct{}
  14629. label_relationships map[uint64]struct{}
  14630. removedlabel_relationships map[uint64]struct{}
  14631. clearedlabel_relationships bool
  14632. done bool
  14633. oldValue func(context.Context) (*Label, error)
  14634. predicates []predicate.Label
  14635. }
  14636. var _ ent.Mutation = (*LabelMutation)(nil)
  14637. // labelOption allows management of the mutation configuration using functional options.
  14638. type labelOption func(*LabelMutation)
  14639. // newLabelMutation creates new mutation for the Label entity.
  14640. func newLabelMutation(c config, op Op, opts ...labelOption) *LabelMutation {
  14641. m := &LabelMutation{
  14642. config: c,
  14643. op: op,
  14644. typ: TypeLabel,
  14645. clearedFields: make(map[string]struct{}),
  14646. }
  14647. for _, opt := range opts {
  14648. opt(m)
  14649. }
  14650. return m
  14651. }
  14652. // withLabelID sets the ID field of the mutation.
  14653. func withLabelID(id uint64) labelOption {
  14654. return func(m *LabelMutation) {
  14655. var (
  14656. err error
  14657. once sync.Once
  14658. value *Label
  14659. )
  14660. m.oldValue = func(ctx context.Context) (*Label, error) {
  14661. once.Do(func() {
  14662. if m.done {
  14663. err = errors.New("querying old values post mutation is not allowed")
  14664. } else {
  14665. value, err = m.Client().Label.Get(ctx, id)
  14666. }
  14667. })
  14668. return value, err
  14669. }
  14670. m.id = &id
  14671. }
  14672. }
  14673. // withLabel sets the old Label of the mutation.
  14674. func withLabel(node *Label) labelOption {
  14675. return func(m *LabelMutation) {
  14676. m.oldValue = func(context.Context) (*Label, error) {
  14677. return node, nil
  14678. }
  14679. m.id = &node.ID
  14680. }
  14681. }
  14682. // Client returns a new `ent.Client` from the mutation. If the mutation was
  14683. // executed in a transaction (ent.Tx), a transactional client is returned.
  14684. func (m LabelMutation) Client() *Client {
  14685. client := &Client{config: m.config}
  14686. client.init()
  14687. return client
  14688. }
  14689. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  14690. // it returns an error otherwise.
  14691. func (m LabelMutation) Tx() (*Tx, error) {
  14692. if _, ok := m.driver.(*txDriver); !ok {
  14693. return nil, errors.New("ent: mutation is not running in a transaction")
  14694. }
  14695. tx := &Tx{config: m.config}
  14696. tx.init()
  14697. return tx, nil
  14698. }
  14699. // SetID sets the value of the id field. Note that this
  14700. // operation is only accepted on creation of Label entities.
  14701. func (m *LabelMutation) SetID(id uint64) {
  14702. m.id = &id
  14703. }
  14704. // ID returns the ID value in the mutation. Note that the ID is only available
  14705. // if it was provided to the builder or after it was returned from the database.
  14706. func (m *LabelMutation) ID() (id uint64, exists bool) {
  14707. if m.id == nil {
  14708. return
  14709. }
  14710. return *m.id, true
  14711. }
  14712. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  14713. // That means, if the mutation is applied within a transaction with an isolation level such
  14714. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  14715. // or updated by the mutation.
  14716. func (m *LabelMutation) IDs(ctx context.Context) ([]uint64, error) {
  14717. switch {
  14718. case m.op.Is(OpUpdateOne | OpDeleteOne):
  14719. id, exists := m.ID()
  14720. if exists {
  14721. return []uint64{id}, nil
  14722. }
  14723. fallthrough
  14724. case m.op.Is(OpUpdate | OpDelete):
  14725. return m.Client().Label.Query().Where(m.predicates...).IDs(ctx)
  14726. default:
  14727. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  14728. }
  14729. }
  14730. // SetCreatedAt sets the "created_at" field.
  14731. func (m *LabelMutation) SetCreatedAt(t time.Time) {
  14732. m.created_at = &t
  14733. }
  14734. // CreatedAt returns the value of the "created_at" field in the mutation.
  14735. func (m *LabelMutation) CreatedAt() (r time.Time, exists bool) {
  14736. v := m.created_at
  14737. if v == nil {
  14738. return
  14739. }
  14740. return *v, true
  14741. }
  14742. // OldCreatedAt returns the old "created_at" field's value of the Label entity.
  14743. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  14744. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14745. func (m *LabelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  14746. if !m.op.Is(OpUpdateOne) {
  14747. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  14748. }
  14749. if m.id == nil || m.oldValue == nil {
  14750. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  14751. }
  14752. oldValue, err := m.oldValue(ctx)
  14753. if err != nil {
  14754. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  14755. }
  14756. return oldValue.CreatedAt, nil
  14757. }
  14758. // ResetCreatedAt resets all changes to the "created_at" field.
  14759. func (m *LabelMutation) ResetCreatedAt() {
  14760. m.created_at = nil
  14761. }
  14762. // SetUpdatedAt sets the "updated_at" field.
  14763. func (m *LabelMutation) SetUpdatedAt(t time.Time) {
  14764. m.updated_at = &t
  14765. }
  14766. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  14767. func (m *LabelMutation) UpdatedAt() (r time.Time, exists bool) {
  14768. v := m.updated_at
  14769. if v == nil {
  14770. return
  14771. }
  14772. return *v, true
  14773. }
  14774. // OldUpdatedAt returns the old "updated_at" field's value of the Label entity.
  14775. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  14776. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14777. func (m *LabelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  14778. if !m.op.Is(OpUpdateOne) {
  14779. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  14780. }
  14781. if m.id == nil || m.oldValue == nil {
  14782. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  14783. }
  14784. oldValue, err := m.oldValue(ctx)
  14785. if err != nil {
  14786. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  14787. }
  14788. return oldValue.UpdatedAt, nil
  14789. }
  14790. // ResetUpdatedAt resets all changes to the "updated_at" field.
  14791. func (m *LabelMutation) ResetUpdatedAt() {
  14792. m.updated_at = nil
  14793. }
  14794. // SetStatus sets the "status" field.
  14795. func (m *LabelMutation) SetStatus(u uint8) {
  14796. m.status = &u
  14797. m.addstatus = nil
  14798. }
  14799. // Status returns the value of the "status" field in the mutation.
  14800. func (m *LabelMutation) Status() (r uint8, exists bool) {
  14801. v := m.status
  14802. if v == nil {
  14803. return
  14804. }
  14805. return *v, true
  14806. }
  14807. // OldStatus returns the old "status" field's value of the Label entity.
  14808. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  14809. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14810. func (m *LabelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  14811. if !m.op.Is(OpUpdateOne) {
  14812. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  14813. }
  14814. if m.id == nil || m.oldValue == nil {
  14815. return v, errors.New("OldStatus requires an ID field in the mutation")
  14816. }
  14817. oldValue, err := m.oldValue(ctx)
  14818. if err != nil {
  14819. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  14820. }
  14821. return oldValue.Status, nil
  14822. }
  14823. // AddStatus adds u to the "status" field.
  14824. func (m *LabelMutation) AddStatus(u int8) {
  14825. if m.addstatus != nil {
  14826. *m.addstatus += u
  14827. } else {
  14828. m.addstatus = &u
  14829. }
  14830. }
  14831. // AddedStatus returns the value that was added to the "status" field in this mutation.
  14832. func (m *LabelMutation) AddedStatus() (r int8, exists bool) {
  14833. v := m.addstatus
  14834. if v == nil {
  14835. return
  14836. }
  14837. return *v, true
  14838. }
  14839. // ClearStatus clears the value of the "status" field.
  14840. func (m *LabelMutation) ClearStatus() {
  14841. m.status = nil
  14842. m.addstatus = nil
  14843. m.clearedFields[label.FieldStatus] = struct{}{}
  14844. }
  14845. // StatusCleared returns if the "status" field was cleared in this mutation.
  14846. func (m *LabelMutation) StatusCleared() bool {
  14847. _, ok := m.clearedFields[label.FieldStatus]
  14848. return ok
  14849. }
  14850. // ResetStatus resets all changes to the "status" field.
  14851. func (m *LabelMutation) ResetStatus() {
  14852. m.status = nil
  14853. m.addstatus = nil
  14854. delete(m.clearedFields, label.FieldStatus)
  14855. }
  14856. // SetType sets the "type" field.
  14857. func (m *LabelMutation) SetType(i int) {
  14858. m._type = &i
  14859. m.add_type = nil
  14860. }
  14861. // GetType returns the value of the "type" field in the mutation.
  14862. func (m *LabelMutation) GetType() (r int, exists bool) {
  14863. v := m._type
  14864. if v == nil {
  14865. return
  14866. }
  14867. return *v, true
  14868. }
  14869. // OldType returns the old "type" field's value of the Label entity.
  14870. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  14871. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14872. func (m *LabelMutation) OldType(ctx context.Context) (v int, err error) {
  14873. if !m.op.Is(OpUpdateOne) {
  14874. return v, errors.New("OldType is only allowed on UpdateOne operations")
  14875. }
  14876. if m.id == nil || m.oldValue == nil {
  14877. return v, errors.New("OldType requires an ID field in the mutation")
  14878. }
  14879. oldValue, err := m.oldValue(ctx)
  14880. if err != nil {
  14881. return v, fmt.Errorf("querying old value for OldType: %w", err)
  14882. }
  14883. return oldValue.Type, nil
  14884. }
  14885. // AddType adds i to the "type" field.
  14886. func (m *LabelMutation) AddType(i int) {
  14887. if m.add_type != nil {
  14888. *m.add_type += i
  14889. } else {
  14890. m.add_type = &i
  14891. }
  14892. }
  14893. // AddedType returns the value that was added to the "type" field in this mutation.
  14894. func (m *LabelMutation) AddedType() (r int, exists bool) {
  14895. v := m.add_type
  14896. if v == nil {
  14897. return
  14898. }
  14899. return *v, true
  14900. }
  14901. // ResetType resets all changes to the "type" field.
  14902. func (m *LabelMutation) ResetType() {
  14903. m._type = nil
  14904. m.add_type = nil
  14905. }
  14906. // SetName sets the "name" field.
  14907. func (m *LabelMutation) SetName(s string) {
  14908. m.name = &s
  14909. }
  14910. // Name returns the value of the "name" field in the mutation.
  14911. func (m *LabelMutation) Name() (r string, exists bool) {
  14912. v := m.name
  14913. if v == nil {
  14914. return
  14915. }
  14916. return *v, true
  14917. }
  14918. // OldName returns the old "name" field's value of the Label entity.
  14919. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  14920. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14921. func (m *LabelMutation) OldName(ctx context.Context) (v string, err error) {
  14922. if !m.op.Is(OpUpdateOne) {
  14923. return v, errors.New("OldName is only allowed on UpdateOne operations")
  14924. }
  14925. if m.id == nil || m.oldValue == nil {
  14926. return v, errors.New("OldName requires an ID field in the mutation")
  14927. }
  14928. oldValue, err := m.oldValue(ctx)
  14929. if err != nil {
  14930. return v, fmt.Errorf("querying old value for OldName: %w", err)
  14931. }
  14932. return oldValue.Name, nil
  14933. }
  14934. // ResetName resets all changes to the "name" field.
  14935. func (m *LabelMutation) ResetName() {
  14936. m.name = nil
  14937. }
  14938. // SetFrom sets the "from" field.
  14939. func (m *LabelMutation) SetFrom(i int) {
  14940. m.from = &i
  14941. m.addfrom = nil
  14942. }
  14943. // From returns the value of the "from" field in the mutation.
  14944. func (m *LabelMutation) From() (r int, exists bool) {
  14945. v := m.from
  14946. if v == nil {
  14947. return
  14948. }
  14949. return *v, true
  14950. }
  14951. // OldFrom returns the old "from" field's value of the Label entity.
  14952. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  14953. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14954. func (m *LabelMutation) OldFrom(ctx context.Context) (v int, err error) {
  14955. if !m.op.Is(OpUpdateOne) {
  14956. return v, errors.New("OldFrom is only allowed on UpdateOne operations")
  14957. }
  14958. if m.id == nil || m.oldValue == nil {
  14959. return v, errors.New("OldFrom requires an ID field in the mutation")
  14960. }
  14961. oldValue, err := m.oldValue(ctx)
  14962. if err != nil {
  14963. return v, fmt.Errorf("querying old value for OldFrom: %w", err)
  14964. }
  14965. return oldValue.From, nil
  14966. }
  14967. // AddFrom adds i to the "from" field.
  14968. func (m *LabelMutation) AddFrom(i int) {
  14969. if m.addfrom != nil {
  14970. *m.addfrom += i
  14971. } else {
  14972. m.addfrom = &i
  14973. }
  14974. }
  14975. // AddedFrom returns the value that was added to the "from" field in this mutation.
  14976. func (m *LabelMutation) AddedFrom() (r int, exists bool) {
  14977. v := m.addfrom
  14978. if v == nil {
  14979. return
  14980. }
  14981. return *v, true
  14982. }
  14983. // ResetFrom resets all changes to the "from" field.
  14984. func (m *LabelMutation) ResetFrom() {
  14985. m.from = nil
  14986. m.addfrom = nil
  14987. }
  14988. // SetMode sets the "mode" field.
  14989. func (m *LabelMutation) SetMode(i int) {
  14990. m.mode = &i
  14991. m.addmode = nil
  14992. }
  14993. // Mode returns the value of the "mode" field in the mutation.
  14994. func (m *LabelMutation) Mode() (r int, exists bool) {
  14995. v := m.mode
  14996. if v == nil {
  14997. return
  14998. }
  14999. return *v, true
  15000. }
  15001. // OldMode returns the old "mode" field's value of the Label entity.
  15002. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  15003. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15004. func (m *LabelMutation) OldMode(ctx context.Context) (v int, err error) {
  15005. if !m.op.Is(OpUpdateOne) {
  15006. return v, errors.New("OldMode is only allowed on UpdateOne operations")
  15007. }
  15008. if m.id == nil || m.oldValue == nil {
  15009. return v, errors.New("OldMode requires an ID field in the mutation")
  15010. }
  15011. oldValue, err := m.oldValue(ctx)
  15012. if err != nil {
  15013. return v, fmt.Errorf("querying old value for OldMode: %w", err)
  15014. }
  15015. return oldValue.Mode, nil
  15016. }
  15017. // AddMode adds i to the "mode" field.
  15018. func (m *LabelMutation) AddMode(i int) {
  15019. if m.addmode != nil {
  15020. *m.addmode += i
  15021. } else {
  15022. m.addmode = &i
  15023. }
  15024. }
  15025. // AddedMode returns the value that was added to the "mode" field in this mutation.
  15026. func (m *LabelMutation) AddedMode() (r int, exists bool) {
  15027. v := m.addmode
  15028. if v == nil {
  15029. return
  15030. }
  15031. return *v, true
  15032. }
  15033. // ResetMode resets all changes to the "mode" field.
  15034. func (m *LabelMutation) ResetMode() {
  15035. m.mode = nil
  15036. m.addmode = nil
  15037. }
  15038. // SetConditions sets the "conditions" field.
  15039. func (m *LabelMutation) SetConditions(s string) {
  15040. m.conditions = &s
  15041. }
  15042. // Conditions returns the value of the "conditions" field in the mutation.
  15043. func (m *LabelMutation) Conditions() (r string, exists bool) {
  15044. v := m.conditions
  15045. if v == nil {
  15046. return
  15047. }
  15048. return *v, true
  15049. }
  15050. // OldConditions returns the old "conditions" field's value of the Label entity.
  15051. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  15052. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15053. func (m *LabelMutation) OldConditions(ctx context.Context) (v string, err error) {
  15054. if !m.op.Is(OpUpdateOne) {
  15055. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  15056. }
  15057. if m.id == nil || m.oldValue == nil {
  15058. return v, errors.New("OldConditions requires an ID field in the mutation")
  15059. }
  15060. oldValue, err := m.oldValue(ctx)
  15061. if err != nil {
  15062. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  15063. }
  15064. return oldValue.Conditions, nil
  15065. }
  15066. // ClearConditions clears the value of the "conditions" field.
  15067. func (m *LabelMutation) ClearConditions() {
  15068. m.conditions = nil
  15069. m.clearedFields[label.FieldConditions] = struct{}{}
  15070. }
  15071. // ConditionsCleared returns if the "conditions" field was cleared in this mutation.
  15072. func (m *LabelMutation) ConditionsCleared() bool {
  15073. _, ok := m.clearedFields[label.FieldConditions]
  15074. return ok
  15075. }
  15076. // ResetConditions resets all changes to the "conditions" field.
  15077. func (m *LabelMutation) ResetConditions() {
  15078. m.conditions = nil
  15079. delete(m.clearedFields, label.FieldConditions)
  15080. }
  15081. // SetOrganizationID sets the "organization_id" field.
  15082. func (m *LabelMutation) SetOrganizationID(u uint64) {
  15083. m.organization_id = &u
  15084. m.addorganization_id = nil
  15085. }
  15086. // OrganizationID returns the value of the "organization_id" field in the mutation.
  15087. func (m *LabelMutation) OrganizationID() (r uint64, exists bool) {
  15088. v := m.organization_id
  15089. if v == nil {
  15090. return
  15091. }
  15092. return *v, true
  15093. }
  15094. // OldOrganizationID returns the old "organization_id" field's value of the Label entity.
  15095. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  15096. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15097. func (m *LabelMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  15098. if !m.op.Is(OpUpdateOne) {
  15099. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  15100. }
  15101. if m.id == nil || m.oldValue == nil {
  15102. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  15103. }
  15104. oldValue, err := m.oldValue(ctx)
  15105. if err != nil {
  15106. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  15107. }
  15108. return oldValue.OrganizationID, nil
  15109. }
  15110. // AddOrganizationID adds u to the "organization_id" field.
  15111. func (m *LabelMutation) AddOrganizationID(u int64) {
  15112. if m.addorganization_id != nil {
  15113. *m.addorganization_id += u
  15114. } else {
  15115. m.addorganization_id = &u
  15116. }
  15117. }
  15118. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  15119. func (m *LabelMutation) AddedOrganizationID() (r int64, exists bool) {
  15120. v := m.addorganization_id
  15121. if v == nil {
  15122. return
  15123. }
  15124. return *v, true
  15125. }
  15126. // ClearOrganizationID clears the value of the "organization_id" field.
  15127. func (m *LabelMutation) ClearOrganizationID() {
  15128. m.organization_id = nil
  15129. m.addorganization_id = nil
  15130. m.clearedFields[label.FieldOrganizationID] = struct{}{}
  15131. }
  15132. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  15133. func (m *LabelMutation) OrganizationIDCleared() bool {
  15134. _, ok := m.clearedFields[label.FieldOrganizationID]
  15135. return ok
  15136. }
  15137. // ResetOrganizationID resets all changes to the "organization_id" field.
  15138. func (m *LabelMutation) ResetOrganizationID() {
  15139. m.organization_id = nil
  15140. m.addorganization_id = nil
  15141. delete(m.clearedFields, label.FieldOrganizationID)
  15142. }
  15143. // AddLabelRelationshipIDs adds the "label_relationships" edge to the LabelRelationship entity by ids.
  15144. func (m *LabelMutation) AddLabelRelationshipIDs(ids ...uint64) {
  15145. if m.label_relationships == nil {
  15146. m.label_relationships = make(map[uint64]struct{})
  15147. }
  15148. for i := range ids {
  15149. m.label_relationships[ids[i]] = struct{}{}
  15150. }
  15151. }
  15152. // ClearLabelRelationships clears the "label_relationships" edge to the LabelRelationship entity.
  15153. func (m *LabelMutation) ClearLabelRelationships() {
  15154. m.clearedlabel_relationships = true
  15155. }
  15156. // LabelRelationshipsCleared reports if the "label_relationships" edge to the LabelRelationship entity was cleared.
  15157. func (m *LabelMutation) LabelRelationshipsCleared() bool {
  15158. return m.clearedlabel_relationships
  15159. }
  15160. // RemoveLabelRelationshipIDs removes the "label_relationships" edge to the LabelRelationship entity by IDs.
  15161. func (m *LabelMutation) RemoveLabelRelationshipIDs(ids ...uint64) {
  15162. if m.removedlabel_relationships == nil {
  15163. m.removedlabel_relationships = make(map[uint64]struct{})
  15164. }
  15165. for i := range ids {
  15166. delete(m.label_relationships, ids[i])
  15167. m.removedlabel_relationships[ids[i]] = struct{}{}
  15168. }
  15169. }
  15170. // RemovedLabelRelationships returns the removed IDs of the "label_relationships" edge to the LabelRelationship entity.
  15171. func (m *LabelMutation) RemovedLabelRelationshipsIDs() (ids []uint64) {
  15172. for id := range m.removedlabel_relationships {
  15173. ids = append(ids, id)
  15174. }
  15175. return
  15176. }
  15177. // LabelRelationshipsIDs returns the "label_relationships" edge IDs in the mutation.
  15178. func (m *LabelMutation) LabelRelationshipsIDs() (ids []uint64) {
  15179. for id := range m.label_relationships {
  15180. ids = append(ids, id)
  15181. }
  15182. return
  15183. }
  15184. // ResetLabelRelationships resets all changes to the "label_relationships" edge.
  15185. func (m *LabelMutation) ResetLabelRelationships() {
  15186. m.label_relationships = nil
  15187. m.clearedlabel_relationships = false
  15188. m.removedlabel_relationships = nil
  15189. }
  15190. // Where appends a list predicates to the LabelMutation builder.
  15191. func (m *LabelMutation) Where(ps ...predicate.Label) {
  15192. m.predicates = append(m.predicates, ps...)
  15193. }
  15194. // WhereP appends storage-level predicates to the LabelMutation builder. Using this method,
  15195. // users can use type-assertion to append predicates that do not depend on any generated package.
  15196. func (m *LabelMutation) WhereP(ps ...func(*sql.Selector)) {
  15197. p := make([]predicate.Label, len(ps))
  15198. for i := range ps {
  15199. p[i] = ps[i]
  15200. }
  15201. m.Where(p...)
  15202. }
  15203. // Op returns the operation name.
  15204. func (m *LabelMutation) Op() Op {
  15205. return m.op
  15206. }
  15207. // SetOp allows setting the mutation operation.
  15208. func (m *LabelMutation) SetOp(op Op) {
  15209. m.op = op
  15210. }
  15211. // Type returns the node type of this mutation (Label).
  15212. func (m *LabelMutation) Type() string {
  15213. return m.typ
  15214. }
  15215. // Fields returns all fields that were changed during this mutation. Note that in
  15216. // order to get all numeric fields that were incremented/decremented, call
  15217. // AddedFields().
  15218. func (m *LabelMutation) Fields() []string {
  15219. fields := make([]string, 0, 9)
  15220. if m.created_at != nil {
  15221. fields = append(fields, label.FieldCreatedAt)
  15222. }
  15223. if m.updated_at != nil {
  15224. fields = append(fields, label.FieldUpdatedAt)
  15225. }
  15226. if m.status != nil {
  15227. fields = append(fields, label.FieldStatus)
  15228. }
  15229. if m._type != nil {
  15230. fields = append(fields, label.FieldType)
  15231. }
  15232. if m.name != nil {
  15233. fields = append(fields, label.FieldName)
  15234. }
  15235. if m.from != nil {
  15236. fields = append(fields, label.FieldFrom)
  15237. }
  15238. if m.mode != nil {
  15239. fields = append(fields, label.FieldMode)
  15240. }
  15241. if m.conditions != nil {
  15242. fields = append(fields, label.FieldConditions)
  15243. }
  15244. if m.organization_id != nil {
  15245. fields = append(fields, label.FieldOrganizationID)
  15246. }
  15247. return fields
  15248. }
  15249. // Field returns the value of a field with the given name. The second boolean
  15250. // return value indicates that this field was not set, or was not defined in the
  15251. // schema.
  15252. func (m *LabelMutation) Field(name string) (ent.Value, bool) {
  15253. switch name {
  15254. case label.FieldCreatedAt:
  15255. return m.CreatedAt()
  15256. case label.FieldUpdatedAt:
  15257. return m.UpdatedAt()
  15258. case label.FieldStatus:
  15259. return m.Status()
  15260. case label.FieldType:
  15261. return m.GetType()
  15262. case label.FieldName:
  15263. return m.Name()
  15264. case label.FieldFrom:
  15265. return m.From()
  15266. case label.FieldMode:
  15267. return m.Mode()
  15268. case label.FieldConditions:
  15269. return m.Conditions()
  15270. case label.FieldOrganizationID:
  15271. return m.OrganizationID()
  15272. }
  15273. return nil, false
  15274. }
  15275. // OldField returns the old value of the field from the database. An error is
  15276. // returned if the mutation operation is not UpdateOne, or the query to the
  15277. // database failed.
  15278. func (m *LabelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  15279. switch name {
  15280. case label.FieldCreatedAt:
  15281. return m.OldCreatedAt(ctx)
  15282. case label.FieldUpdatedAt:
  15283. return m.OldUpdatedAt(ctx)
  15284. case label.FieldStatus:
  15285. return m.OldStatus(ctx)
  15286. case label.FieldType:
  15287. return m.OldType(ctx)
  15288. case label.FieldName:
  15289. return m.OldName(ctx)
  15290. case label.FieldFrom:
  15291. return m.OldFrom(ctx)
  15292. case label.FieldMode:
  15293. return m.OldMode(ctx)
  15294. case label.FieldConditions:
  15295. return m.OldConditions(ctx)
  15296. case label.FieldOrganizationID:
  15297. return m.OldOrganizationID(ctx)
  15298. }
  15299. return nil, fmt.Errorf("unknown Label field %s", name)
  15300. }
  15301. // SetField sets the value of a field with the given name. It returns an error if
  15302. // the field is not defined in the schema, or if the type mismatched the field
  15303. // type.
  15304. func (m *LabelMutation) SetField(name string, value ent.Value) error {
  15305. switch name {
  15306. case label.FieldCreatedAt:
  15307. v, ok := value.(time.Time)
  15308. if !ok {
  15309. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15310. }
  15311. m.SetCreatedAt(v)
  15312. return nil
  15313. case label.FieldUpdatedAt:
  15314. v, ok := value.(time.Time)
  15315. if !ok {
  15316. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15317. }
  15318. m.SetUpdatedAt(v)
  15319. return nil
  15320. case label.FieldStatus:
  15321. v, ok := value.(uint8)
  15322. if !ok {
  15323. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15324. }
  15325. m.SetStatus(v)
  15326. return nil
  15327. case label.FieldType:
  15328. v, ok := value.(int)
  15329. if !ok {
  15330. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15331. }
  15332. m.SetType(v)
  15333. return nil
  15334. case label.FieldName:
  15335. v, ok := value.(string)
  15336. if !ok {
  15337. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15338. }
  15339. m.SetName(v)
  15340. return nil
  15341. case label.FieldFrom:
  15342. v, ok := value.(int)
  15343. if !ok {
  15344. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15345. }
  15346. m.SetFrom(v)
  15347. return nil
  15348. case label.FieldMode:
  15349. v, ok := value.(int)
  15350. if !ok {
  15351. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15352. }
  15353. m.SetMode(v)
  15354. return nil
  15355. case label.FieldConditions:
  15356. v, ok := value.(string)
  15357. if !ok {
  15358. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15359. }
  15360. m.SetConditions(v)
  15361. return nil
  15362. case label.FieldOrganizationID:
  15363. v, ok := value.(uint64)
  15364. if !ok {
  15365. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15366. }
  15367. m.SetOrganizationID(v)
  15368. return nil
  15369. }
  15370. return fmt.Errorf("unknown Label field %s", name)
  15371. }
  15372. // AddedFields returns all numeric fields that were incremented/decremented during
  15373. // this mutation.
  15374. func (m *LabelMutation) AddedFields() []string {
  15375. var fields []string
  15376. if m.addstatus != nil {
  15377. fields = append(fields, label.FieldStatus)
  15378. }
  15379. if m.add_type != nil {
  15380. fields = append(fields, label.FieldType)
  15381. }
  15382. if m.addfrom != nil {
  15383. fields = append(fields, label.FieldFrom)
  15384. }
  15385. if m.addmode != nil {
  15386. fields = append(fields, label.FieldMode)
  15387. }
  15388. if m.addorganization_id != nil {
  15389. fields = append(fields, label.FieldOrganizationID)
  15390. }
  15391. return fields
  15392. }
  15393. // AddedField returns the numeric value that was incremented/decremented on a field
  15394. // with the given name. The second boolean return value indicates that this field
  15395. // was not set, or was not defined in the schema.
  15396. func (m *LabelMutation) AddedField(name string) (ent.Value, bool) {
  15397. switch name {
  15398. case label.FieldStatus:
  15399. return m.AddedStatus()
  15400. case label.FieldType:
  15401. return m.AddedType()
  15402. case label.FieldFrom:
  15403. return m.AddedFrom()
  15404. case label.FieldMode:
  15405. return m.AddedMode()
  15406. case label.FieldOrganizationID:
  15407. return m.AddedOrganizationID()
  15408. }
  15409. return nil, false
  15410. }
  15411. // AddField adds the value to the field with the given name. It returns an error if
  15412. // the field is not defined in the schema, or if the type mismatched the field
  15413. // type.
  15414. func (m *LabelMutation) AddField(name string, value ent.Value) error {
  15415. switch name {
  15416. case label.FieldStatus:
  15417. v, ok := value.(int8)
  15418. if !ok {
  15419. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15420. }
  15421. m.AddStatus(v)
  15422. return nil
  15423. case label.FieldType:
  15424. v, ok := value.(int)
  15425. if !ok {
  15426. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15427. }
  15428. m.AddType(v)
  15429. return nil
  15430. case label.FieldFrom:
  15431. v, ok := value.(int)
  15432. if !ok {
  15433. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15434. }
  15435. m.AddFrom(v)
  15436. return nil
  15437. case label.FieldMode:
  15438. v, ok := value.(int)
  15439. if !ok {
  15440. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15441. }
  15442. m.AddMode(v)
  15443. return nil
  15444. case label.FieldOrganizationID:
  15445. v, ok := value.(int64)
  15446. if !ok {
  15447. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15448. }
  15449. m.AddOrganizationID(v)
  15450. return nil
  15451. }
  15452. return fmt.Errorf("unknown Label numeric field %s", name)
  15453. }
  15454. // ClearedFields returns all nullable fields that were cleared during this
  15455. // mutation.
  15456. func (m *LabelMutation) ClearedFields() []string {
  15457. var fields []string
  15458. if m.FieldCleared(label.FieldStatus) {
  15459. fields = append(fields, label.FieldStatus)
  15460. }
  15461. if m.FieldCleared(label.FieldConditions) {
  15462. fields = append(fields, label.FieldConditions)
  15463. }
  15464. if m.FieldCleared(label.FieldOrganizationID) {
  15465. fields = append(fields, label.FieldOrganizationID)
  15466. }
  15467. return fields
  15468. }
  15469. // FieldCleared returns a boolean indicating if a field with the given name was
  15470. // cleared in this mutation.
  15471. func (m *LabelMutation) FieldCleared(name string) bool {
  15472. _, ok := m.clearedFields[name]
  15473. return ok
  15474. }
  15475. // ClearField clears the value of the field with the given name. It returns an
  15476. // error if the field is not defined in the schema.
  15477. func (m *LabelMutation) ClearField(name string) error {
  15478. switch name {
  15479. case label.FieldStatus:
  15480. m.ClearStatus()
  15481. return nil
  15482. case label.FieldConditions:
  15483. m.ClearConditions()
  15484. return nil
  15485. case label.FieldOrganizationID:
  15486. m.ClearOrganizationID()
  15487. return nil
  15488. }
  15489. return fmt.Errorf("unknown Label nullable field %s", name)
  15490. }
  15491. // ResetField resets all changes in the mutation for the field with the given name.
  15492. // It returns an error if the field is not defined in the schema.
  15493. func (m *LabelMutation) ResetField(name string) error {
  15494. switch name {
  15495. case label.FieldCreatedAt:
  15496. m.ResetCreatedAt()
  15497. return nil
  15498. case label.FieldUpdatedAt:
  15499. m.ResetUpdatedAt()
  15500. return nil
  15501. case label.FieldStatus:
  15502. m.ResetStatus()
  15503. return nil
  15504. case label.FieldType:
  15505. m.ResetType()
  15506. return nil
  15507. case label.FieldName:
  15508. m.ResetName()
  15509. return nil
  15510. case label.FieldFrom:
  15511. m.ResetFrom()
  15512. return nil
  15513. case label.FieldMode:
  15514. m.ResetMode()
  15515. return nil
  15516. case label.FieldConditions:
  15517. m.ResetConditions()
  15518. return nil
  15519. case label.FieldOrganizationID:
  15520. m.ResetOrganizationID()
  15521. return nil
  15522. }
  15523. return fmt.Errorf("unknown Label field %s", name)
  15524. }
  15525. // AddedEdges returns all edge names that were set/added in this mutation.
  15526. func (m *LabelMutation) AddedEdges() []string {
  15527. edges := make([]string, 0, 1)
  15528. if m.label_relationships != nil {
  15529. edges = append(edges, label.EdgeLabelRelationships)
  15530. }
  15531. return edges
  15532. }
  15533. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  15534. // name in this mutation.
  15535. func (m *LabelMutation) AddedIDs(name string) []ent.Value {
  15536. switch name {
  15537. case label.EdgeLabelRelationships:
  15538. ids := make([]ent.Value, 0, len(m.label_relationships))
  15539. for id := range m.label_relationships {
  15540. ids = append(ids, id)
  15541. }
  15542. return ids
  15543. }
  15544. return nil
  15545. }
  15546. // RemovedEdges returns all edge names that were removed in this mutation.
  15547. func (m *LabelMutation) RemovedEdges() []string {
  15548. edges := make([]string, 0, 1)
  15549. if m.removedlabel_relationships != nil {
  15550. edges = append(edges, label.EdgeLabelRelationships)
  15551. }
  15552. return edges
  15553. }
  15554. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  15555. // the given name in this mutation.
  15556. func (m *LabelMutation) RemovedIDs(name string) []ent.Value {
  15557. switch name {
  15558. case label.EdgeLabelRelationships:
  15559. ids := make([]ent.Value, 0, len(m.removedlabel_relationships))
  15560. for id := range m.removedlabel_relationships {
  15561. ids = append(ids, id)
  15562. }
  15563. return ids
  15564. }
  15565. return nil
  15566. }
  15567. // ClearedEdges returns all edge names that were cleared in this mutation.
  15568. func (m *LabelMutation) ClearedEdges() []string {
  15569. edges := make([]string, 0, 1)
  15570. if m.clearedlabel_relationships {
  15571. edges = append(edges, label.EdgeLabelRelationships)
  15572. }
  15573. return edges
  15574. }
  15575. // EdgeCleared returns a boolean which indicates if the edge with the given name
  15576. // was cleared in this mutation.
  15577. func (m *LabelMutation) EdgeCleared(name string) bool {
  15578. switch name {
  15579. case label.EdgeLabelRelationships:
  15580. return m.clearedlabel_relationships
  15581. }
  15582. return false
  15583. }
  15584. // ClearEdge clears the value of the edge with the given name. It returns an error
  15585. // if that edge is not defined in the schema.
  15586. func (m *LabelMutation) ClearEdge(name string) error {
  15587. switch name {
  15588. }
  15589. return fmt.Errorf("unknown Label unique edge %s", name)
  15590. }
  15591. // ResetEdge resets all changes to the edge with the given name in this mutation.
  15592. // It returns an error if the edge is not defined in the schema.
  15593. func (m *LabelMutation) ResetEdge(name string) error {
  15594. switch name {
  15595. case label.EdgeLabelRelationships:
  15596. m.ResetLabelRelationships()
  15597. return nil
  15598. }
  15599. return fmt.Errorf("unknown Label edge %s", name)
  15600. }
  15601. // LabelRelationshipMutation represents an operation that mutates the LabelRelationship nodes in the graph.
  15602. type LabelRelationshipMutation struct {
  15603. config
  15604. op Op
  15605. typ string
  15606. id *uint64
  15607. created_at *time.Time
  15608. updated_at *time.Time
  15609. status *uint8
  15610. addstatus *int8
  15611. organization_id *uint64
  15612. addorganization_id *int64
  15613. clearedFields map[string]struct{}
  15614. contacts *uint64
  15615. clearedcontacts bool
  15616. labels *uint64
  15617. clearedlabels bool
  15618. done bool
  15619. oldValue func(context.Context) (*LabelRelationship, error)
  15620. predicates []predicate.LabelRelationship
  15621. }
  15622. var _ ent.Mutation = (*LabelRelationshipMutation)(nil)
  15623. // labelrelationshipOption allows management of the mutation configuration using functional options.
  15624. type labelrelationshipOption func(*LabelRelationshipMutation)
  15625. // newLabelRelationshipMutation creates new mutation for the LabelRelationship entity.
  15626. func newLabelRelationshipMutation(c config, op Op, opts ...labelrelationshipOption) *LabelRelationshipMutation {
  15627. m := &LabelRelationshipMutation{
  15628. config: c,
  15629. op: op,
  15630. typ: TypeLabelRelationship,
  15631. clearedFields: make(map[string]struct{}),
  15632. }
  15633. for _, opt := range opts {
  15634. opt(m)
  15635. }
  15636. return m
  15637. }
  15638. // withLabelRelationshipID sets the ID field of the mutation.
  15639. func withLabelRelationshipID(id uint64) labelrelationshipOption {
  15640. return func(m *LabelRelationshipMutation) {
  15641. var (
  15642. err error
  15643. once sync.Once
  15644. value *LabelRelationship
  15645. )
  15646. m.oldValue = func(ctx context.Context) (*LabelRelationship, error) {
  15647. once.Do(func() {
  15648. if m.done {
  15649. err = errors.New("querying old values post mutation is not allowed")
  15650. } else {
  15651. value, err = m.Client().LabelRelationship.Get(ctx, id)
  15652. }
  15653. })
  15654. return value, err
  15655. }
  15656. m.id = &id
  15657. }
  15658. }
  15659. // withLabelRelationship sets the old LabelRelationship of the mutation.
  15660. func withLabelRelationship(node *LabelRelationship) labelrelationshipOption {
  15661. return func(m *LabelRelationshipMutation) {
  15662. m.oldValue = func(context.Context) (*LabelRelationship, error) {
  15663. return node, nil
  15664. }
  15665. m.id = &node.ID
  15666. }
  15667. }
  15668. // Client returns a new `ent.Client` from the mutation. If the mutation was
  15669. // executed in a transaction (ent.Tx), a transactional client is returned.
  15670. func (m LabelRelationshipMutation) Client() *Client {
  15671. client := &Client{config: m.config}
  15672. client.init()
  15673. return client
  15674. }
  15675. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  15676. // it returns an error otherwise.
  15677. func (m LabelRelationshipMutation) Tx() (*Tx, error) {
  15678. if _, ok := m.driver.(*txDriver); !ok {
  15679. return nil, errors.New("ent: mutation is not running in a transaction")
  15680. }
  15681. tx := &Tx{config: m.config}
  15682. tx.init()
  15683. return tx, nil
  15684. }
  15685. // SetID sets the value of the id field. Note that this
  15686. // operation is only accepted on creation of LabelRelationship entities.
  15687. func (m *LabelRelationshipMutation) SetID(id uint64) {
  15688. m.id = &id
  15689. }
  15690. // ID returns the ID value in the mutation. Note that the ID is only available
  15691. // if it was provided to the builder or after it was returned from the database.
  15692. func (m *LabelRelationshipMutation) ID() (id uint64, exists bool) {
  15693. if m.id == nil {
  15694. return
  15695. }
  15696. return *m.id, true
  15697. }
  15698. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  15699. // That means, if the mutation is applied within a transaction with an isolation level such
  15700. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  15701. // or updated by the mutation.
  15702. func (m *LabelRelationshipMutation) IDs(ctx context.Context) ([]uint64, error) {
  15703. switch {
  15704. case m.op.Is(OpUpdateOne | OpDeleteOne):
  15705. id, exists := m.ID()
  15706. if exists {
  15707. return []uint64{id}, nil
  15708. }
  15709. fallthrough
  15710. case m.op.Is(OpUpdate | OpDelete):
  15711. return m.Client().LabelRelationship.Query().Where(m.predicates...).IDs(ctx)
  15712. default:
  15713. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  15714. }
  15715. }
  15716. // SetCreatedAt sets the "created_at" field.
  15717. func (m *LabelRelationshipMutation) SetCreatedAt(t time.Time) {
  15718. m.created_at = &t
  15719. }
  15720. // CreatedAt returns the value of the "created_at" field in the mutation.
  15721. func (m *LabelRelationshipMutation) CreatedAt() (r time.Time, exists bool) {
  15722. v := m.created_at
  15723. if v == nil {
  15724. return
  15725. }
  15726. return *v, true
  15727. }
  15728. // OldCreatedAt returns the old "created_at" field's value of the LabelRelationship entity.
  15729. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  15730. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15731. func (m *LabelRelationshipMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  15732. if !m.op.Is(OpUpdateOne) {
  15733. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  15734. }
  15735. if m.id == nil || m.oldValue == nil {
  15736. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  15737. }
  15738. oldValue, err := m.oldValue(ctx)
  15739. if err != nil {
  15740. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  15741. }
  15742. return oldValue.CreatedAt, nil
  15743. }
  15744. // ResetCreatedAt resets all changes to the "created_at" field.
  15745. func (m *LabelRelationshipMutation) ResetCreatedAt() {
  15746. m.created_at = nil
  15747. }
  15748. // SetUpdatedAt sets the "updated_at" field.
  15749. func (m *LabelRelationshipMutation) SetUpdatedAt(t time.Time) {
  15750. m.updated_at = &t
  15751. }
  15752. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  15753. func (m *LabelRelationshipMutation) UpdatedAt() (r time.Time, exists bool) {
  15754. v := m.updated_at
  15755. if v == nil {
  15756. return
  15757. }
  15758. return *v, true
  15759. }
  15760. // OldUpdatedAt returns the old "updated_at" field's value of the LabelRelationship entity.
  15761. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  15762. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15763. func (m *LabelRelationshipMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  15764. if !m.op.Is(OpUpdateOne) {
  15765. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  15766. }
  15767. if m.id == nil || m.oldValue == nil {
  15768. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  15769. }
  15770. oldValue, err := m.oldValue(ctx)
  15771. if err != nil {
  15772. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  15773. }
  15774. return oldValue.UpdatedAt, nil
  15775. }
  15776. // ResetUpdatedAt resets all changes to the "updated_at" field.
  15777. func (m *LabelRelationshipMutation) ResetUpdatedAt() {
  15778. m.updated_at = nil
  15779. }
  15780. // SetStatus sets the "status" field.
  15781. func (m *LabelRelationshipMutation) SetStatus(u uint8) {
  15782. m.status = &u
  15783. m.addstatus = nil
  15784. }
  15785. // Status returns the value of the "status" field in the mutation.
  15786. func (m *LabelRelationshipMutation) Status() (r uint8, exists bool) {
  15787. v := m.status
  15788. if v == nil {
  15789. return
  15790. }
  15791. return *v, true
  15792. }
  15793. // OldStatus returns the old "status" field's value of the LabelRelationship entity.
  15794. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  15795. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15796. func (m *LabelRelationshipMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  15797. if !m.op.Is(OpUpdateOne) {
  15798. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  15799. }
  15800. if m.id == nil || m.oldValue == nil {
  15801. return v, errors.New("OldStatus requires an ID field in the mutation")
  15802. }
  15803. oldValue, err := m.oldValue(ctx)
  15804. if err != nil {
  15805. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  15806. }
  15807. return oldValue.Status, nil
  15808. }
  15809. // AddStatus adds u to the "status" field.
  15810. func (m *LabelRelationshipMutation) AddStatus(u int8) {
  15811. if m.addstatus != nil {
  15812. *m.addstatus += u
  15813. } else {
  15814. m.addstatus = &u
  15815. }
  15816. }
  15817. // AddedStatus returns the value that was added to the "status" field in this mutation.
  15818. func (m *LabelRelationshipMutation) AddedStatus() (r int8, exists bool) {
  15819. v := m.addstatus
  15820. if v == nil {
  15821. return
  15822. }
  15823. return *v, true
  15824. }
  15825. // ClearStatus clears the value of the "status" field.
  15826. func (m *LabelRelationshipMutation) ClearStatus() {
  15827. m.status = nil
  15828. m.addstatus = nil
  15829. m.clearedFields[labelrelationship.FieldStatus] = struct{}{}
  15830. }
  15831. // StatusCleared returns if the "status" field was cleared in this mutation.
  15832. func (m *LabelRelationshipMutation) StatusCleared() bool {
  15833. _, ok := m.clearedFields[labelrelationship.FieldStatus]
  15834. return ok
  15835. }
  15836. // ResetStatus resets all changes to the "status" field.
  15837. func (m *LabelRelationshipMutation) ResetStatus() {
  15838. m.status = nil
  15839. m.addstatus = nil
  15840. delete(m.clearedFields, labelrelationship.FieldStatus)
  15841. }
  15842. // SetLabelID sets the "label_id" field.
  15843. func (m *LabelRelationshipMutation) SetLabelID(u uint64) {
  15844. m.labels = &u
  15845. }
  15846. // LabelID returns the value of the "label_id" field in the mutation.
  15847. func (m *LabelRelationshipMutation) LabelID() (r uint64, exists bool) {
  15848. v := m.labels
  15849. if v == nil {
  15850. return
  15851. }
  15852. return *v, true
  15853. }
  15854. // OldLabelID returns the old "label_id" field's value of the LabelRelationship entity.
  15855. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  15856. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15857. func (m *LabelRelationshipMutation) OldLabelID(ctx context.Context) (v uint64, err error) {
  15858. if !m.op.Is(OpUpdateOne) {
  15859. return v, errors.New("OldLabelID is only allowed on UpdateOne operations")
  15860. }
  15861. if m.id == nil || m.oldValue == nil {
  15862. return v, errors.New("OldLabelID requires an ID field in the mutation")
  15863. }
  15864. oldValue, err := m.oldValue(ctx)
  15865. if err != nil {
  15866. return v, fmt.Errorf("querying old value for OldLabelID: %w", err)
  15867. }
  15868. return oldValue.LabelID, nil
  15869. }
  15870. // ResetLabelID resets all changes to the "label_id" field.
  15871. func (m *LabelRelationshipMutation) ResetLabelID() {
  15872. m.labels = nil
  15873. }
  15874. // SetContactID sets the "contact_id" field.
  15875. func (m *LabelRelationshipMutation) SetContactID(u uint64) {
  15876. m.contacts = &u
  15877. }
  15878. // ContactID returns the value of the "contact_id" field in the mutation.
  15879. func (m *LabelRelationshipMutation) ContactID() (r uint64, exists bool) {
  15880. v := m.contacts
  15881. if v == nil {
  15882. return
  15883. }
  15884. return *v, true
  15885. }
  15886. // OldContactID returns the old "contact_id" field's value of the LabelRelationship entity.
  15887. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  15888. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15889. func (m *LabelRelationshipMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  15890. if !m.op.Is(OpUpdateOne) {
  15891. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  15892. }
  15893. if m.id == nil || m.oldValue == nil {
  15894. return v, errors.New("OldContactID requires an ID field in the mutation")
  15895. }
  15896. oldValue, err := m.oldValue(ctx)
  15897. if err != nil {
  15898. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  15899. }
  15900. return oldValue.ContactID, nil
  15901. }
  15902. // ResetContactID resets all changes to the "contact_id" field.
  15903. func (m *LabelRelationshipMutation) ResetContactID() {
  15904. m.contacts = nil
  15905. }
  15906. // SetOrganizationID sets the "organization_id" field.
  15907. func (m *LabelRelationshipMutation) SetOrganizationID(u uint64) {
  15908. m.organization_id = &u
  15909. m.addorganization_id = nil
  15910. }
  15911. // OrganizationID returns the value of the "organization_id" field in the mutation.
  15912. func (m *LabelRelationshipMutation) OrganizationID() (r uint64, exists bool) {
  15913. v := m.organization_id
  15914. if v == nil {
  15915. return
  15916. }
  15917. return *v, true
  15918. }
  15919. // OldOrganizationID returns the old "organization_id" field's value of the LabelRelationship entity.
  15920. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  15921. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15922. func (m *LabelRelationshipMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  15923. if !m.op.Is(OpUpdateOne) {
  15924. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  15925. }
  15926. if m.id == nil || m.oldValue == nil {
  15927. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  15928. }
  15929. oldValue, err := m.oldValue(ctx)
  15930. if err != nil {
  15931. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  15932. }
  15933. return oldValue.OrganizationID, nil
  15934. }
  15935. // AddOrganizationID adds u to the "organization_id" field.
  15936. func (m *LabelRelationshipMutation) AddOrganizationID(u int64) {
  15937. if m.addorganization_id != nil {
  15938. *m.addorganization_id += u
  15939. } else {
  15940. m.addorganization_id = &u
  15941. }
  15942. }
  15943. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  15944. func (m *LabelRelationshipMutation) AddedOrganizationID() (r int64, exists bool) {
  15945. v := m.addorganization_id
  15946. if v == nil {
  15947. return
  15948. }
  15949. return *v, true
  15950. }
  15951. // ClearOrganizationID clears the value of the "organization_id" field.
  15952. func (m *LabelRelationshipMutation) ClearOrganizationID() {
  15953. m.organization_id = nil
  15954. m.addorganization_id = nil
  15955. m.clearedFields[labelrelationship.FieldOrganizationID] = struct{}{}
  15956. }
  15957. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  15958. func (m *LabelRelationshipMutation) OrganizationIDCleared() bool {
  15959. _, ok := m.clearedFields[labelrelationship.FieldOrganizationID]
  15960. return ok
  15961. }
  15962. // ResetOrganizationID resets all changes to the "organization_id" field.
  15963. func (m *LabelRelationshipMutation) ResetOrganizationID() {
  15964. m.organization_id = nil
  15965. m.addorganization_id = nil
  15966. delete(m.clearedFields, labelrelationship.FieldOrganizationID)
  15967. }
  15968. // SetContactsID sets the "contacts" edge to the Contact entity by id.
  15969. func (m *LabelRelationshipMutation) SetContactsID(id uint64) {
  15970. m.contacts = &id
  15971. }
  15972. // ClearContacts clears the "contacts" edge to the Contact entity.
  15973. func (m *LabelRelationshipMutation) ClearContacts() {
  15974. m.clearedcontacts = true
  15975. m.clearedFields[labelrelationship.FieldContactID] = struct{}{}
  15976. }
  15977. // ContactsCleared reports if the "contacts" edge to the Contact entity was cleared.
  15978. func (m *LabelRelationshipMutation) ContactsCleared() bool {
  15979. return m.clearedcontacts
  15980. }
  15981. // ContactsID returns the "contacts" edge ID in the mutation.
  15982. func (m *LabelRelationshipMutation) ContactsID() (id uint64, exists bool) {
  15983. if m.contacts != nil {
  15984. return *m.contacts, true
  15985. }
  15986. return
  15987. }
  15988. // ContactsIDs returns the "contacts" edge IDs in the mutation.
  15989. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  15990. // ContactsID instead. It exists only for internal usage by the builders.
  15991. func (m *LabelRelationshipMutation) ContactsIDs() (ids []uint64) {
  15992. if id := m.contacts; id != nil {
  15993. ids = append(ids, *id)
  15994. }
  15995. return
  15996. }
  15997. // ResetContacts resets all changes to the "contacts" edge.
  15998. func (m *LabelRelationshipMutation) ResetContacts() {
  15999. m.contacts = nil
  16000. m.clearedcontacts = false
  16001. }
  16002. // SetLabelsID sets the "labels" edge to the Label entity by id.
  16003. func (m *LabelRelationshipMutation) SetLabelsID(id uint64) {
  16004. m.labels = &id
  16005. }
  16006. // ClearLabels clears the "labels" edge to the Label entity.
  16007. func (m *LabelRelationshipMutation) ClearLabels() {
  16008. m.clearedlabels = true
  16009. m.clearedFields[labelrelationship.FieldLabelID] = struct{}{}
  16010. }
  16011. // LabelsCleared reports if the "labels" edge to the Label entity was cleared.
  16012. func (m *LabelRelationshipMutation) LabelsCleared() bool {
  16013. return m.clearedlabels
  16014. }
  16015. // LabelsID returns the "labels" edge ID in the mutation.
  16016. func (m *LabelRelationshipMutation) LabelsID() (id uint64, exists bool) {
  16017. if m.labels != nil {
  16018. return *m.labels, true
  16019. }
  16020. return
  16021. }
  16022. // LabelsIDs returns the "labels" edge IDs in the mutation.
  16023. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  16024. // LabelsID instead. It exists only for internal usage by the builders.
  16025. func (m *LabelRelationshipMutation) LabelsIDs() (ids []uint64) {
  16026. if id := m.labels; id != nil {
  16027. ids = append(ids, *id)
  16028. }
  16029. return
  16030. }
  16031. // ResetLabels resets all changes to the "labels" edge.
  16032. func (m *LabelRelationshipMutation) ResetLabels() {
  16033. m.labels = nil
  16034. m.clearedlabels = false
  16035. }
  16036. // Where appends a list predicates to the LabelRelationshipMutation builder.
  16037. func (m *LabelRelationshipMutation) Where(ps ...predicate.LabelRelationship) {
  16038. m.predicates = append(m.predicates, ps...)
  16039. }
  16040. // WhereP appends storage-level predicates to the LabelRelationshipMutation builder. Using this method,
  16041. // users can use type-assertion to append predicates that do not depend on any generated package.
  16042. func (m *LabelRelationshipMutation) WhereP(ps ...func(*sql.Selector)) {
  16043. p := make([]predicate.LabelRelationship, len(ps))
  16044. for i := range ps {
  16045. p[i] = ps[i]
  16046. }
  16047. m.Where(p...)
  16048. }
  16049. // Op returns the operation name.
  16050. func (m *LabelRelationshipMutation) Op() Op {
  16051. return m.op
  16052. }
  16053. // SetOp allows setting the mutation operation.
  16054. func (m *LabelRelationshipMutation) SetOp(op Op) {
  16055. m.op = op
  16056. }
  16057. // Type returns the node type of this mutation (LabelRelationship).
  16058. func (m *LabelRelationshipMutation) Type() string {
  16059. return m.typ
  16060. }
  16061. // Fields returns all fields that were changed during this mutation. Note that in
  16062. // order to get all numeric fields that were incremented/decremented, call
  16063. // AddedFields().
  16064. func (m *LabelRelationshipMutation) Fields() []string {
  16065. fields := make([]string, 0, 6)
  16066. if m.created_at != nil {
  16067. fields = append(fields, labelrelationship.FieldCreatedAt)
  16068. }
  16069. if m.updated_at != nil {
  16070. fields = append(fields, labelrelationship.FieldUpdatedAt)
  16071. }
  16072. if m.status != nil {
  16073. fields = append(fields, labelrelationship.FieldStatus)
  16074. }
  16075. if m.labels != nil {
  16076. fields = append(fields, labelrelationship.FieldLabelID)
  16077. }
  16078. if m.contacts != nil {
  16079. fields = append(fields, labelrelationship.FieldContactID)
  16080. }
  16081. if m.organization_id != nil {
  16082. fields = append(fields, labelrelationship.FieldOrganizationID)
  16083. }
  16084. return fields
  16085. }
  16086. // Field returns the value of a field with the given name. The second boolean
  16087. // return value indicates that this field was not set, or was not defined in the
  16088. // schema.
  16089. func (m *LabelRelationshipMutation) Field(name string) (ent.Value, bool) {
  16090. switch name {
  16091. case labelrelationship.FieldCreatedAt:
  16092. return m.CreatedAt()
  16093. case labelrelationship.FieldUpdatedAt:
  16094. return m.UpdatedAt()
  16095. case labelrelationship.FieldStatus:
  16096. return m.Status()
  16097. case labelrelationship.FieldLabelID:
  16098. return m.LabelID()
  16099. case labelrelationship.FieldContactID:
  16100. return m.ContactID()
  16101. case labelrelationship.FieldOrganizationID:
  16102. return m.OrganizationID()
  16103. }
  16104. return nil, false
  16105. }
  16106. // OldField returns the old value of the field from the database. An error is
  16107. // returned if the mutation operation is not UpdateOne, or the query to the
  16108. // database failed.
  16109. func (m *LabelRelationshipMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  16110. switch name {
  16111. case labelrelationship.FieldCreatedAt:
  16112. return m.OldCreatedAt(ctx)
  16113. case labelrelationship.FieldUpdatedAt:
  16114. return m.OldUpdatedAt(ctx)
  16115. case labelrelationship.FieldStatus:
  16116. return m.OldStatus(ctx)
  16117. case labelrelationship.FieldLabelID:
  16118. return m.OldLabelID(ctx)
  16119. case labelrelationship.FieldContactID:
  16120. return m.OldContactID(ctx)
  16121. case labelrelationship.FieldOrganizationID:
  16122. return m.OldOrganizationID(ctx)
  16123. }
  16124. return nil, fmt.Errorf("unknown LabelRelationship field %s", name)
  16125. }
  16126. // SetField sets the value of a field with the given name. It returns an error if
  16127. // the field is not defined in the schema, or if the type mismatched the field
  16128. // type.
  16129. func (m *LabelRelationshipMutation) SetField(name string, value ent.Value) error {
  16130. switch name {
  16131. case labelrelationship.FieldCreatedAt:
  16132. v, ok := value.(time.Time)
  16133. if !ok {
  16134. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16135. }
  16136. m.SetCreatedAt(v)
  16137. return nil
  16138. case labelrelationship.FieldUpdatedAt:
  16139. v, ok := value.(time.Time)
  16140. if !ok {
  16141. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16142. }
  16143. m.SetUpdatedAt(v)
  16144. return nil
  16145. case labelrelationship.FieldStatus:
  16146. v, ok := value.(uint8)
  16147. if !ok {
  16148. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16149. }
  16150. m.SetStatus(v)
  16151. return nil
  16152. case labelrelationship.FieldLabelID:
  16153. v, ok := value.(uint64)
  16154. if !ok {
  16155. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16156. }
  16157. m.SetLabelID(v)
  16158. return nil
  16159. case labelrelationship.FieldContactID:
  16160. v, ok := value.(uint64)
  16161. if !ok {
  16162. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16163. }
  16164. m.SetContactID(v)
  16165. return nil
  16166. case labelrelationship.FieldOrganizationID:
  16167. v, ok := value.(uint64)
  16168. if !ok {
  16169. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16170. }
  16171. m.SetOrganizationID(v)
  16172. return nil
  16173. }
  16174. return fmt.Errorf("unknown LabelRelationship field %s", name)
  16175. }
  16176. // AddedFields returns all numeric fields that were incremented/decremented during
  16177. // this mutation.
  16178. func (m *LabelRelationshipMutation) AddedFields() []string {
  16179. var fields []string
  16180. if m.addstatus != nil {
  16181. fields = append(fields, labelrelationship.FieldStatus)
  16182. }
  16183. if m.addorganization_id != nil {
  16184. fields = append(fields, labelrelationship.FieldOrganizationID)
  16185. }
  16186. return fields
  16187. }
  16188. // AddedField returns the numeric value that was incremented/decremented on a field
  16189. // with the given name. The second boolean return value indicates that this field
  16190. // was not set, or was not defined in the schema.
  16191. func (m *LabelRelationshipMutation) AddedField(name string) (ent.Value, bool) {
  16192. switch name {
  16193. case labelrelationship.FieldStatus:
  16194. return m.AddedStatus()
  16195. case labelrelationship.FieldOrganizationID:
  16196. return m.AddedOrganizationID()
  16197. }
  16198. return nil, false
  16199. }
  16200. // AddField adds the value to the field with the given name. It returns an error if
  16201. // the field is not defined in the schema, or if the type mismatched the field
  16202. // type.
  16203. func (m *LabelRelationshipMutation) AddField(name string, value ent.Value) error {
  16204. switch name {
  16205. case labelrelationship.FieldStatus:
  16206. v, ok := value.(int8)
  16207. if !ok {
  16208. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16209. }
  16210. m.AddStatus(v)
  16211. return nil
  16212. case labelrelationship.FieldOrganizationID:
  16213. v, ok := value.(int64)
  16214. if !ok {
  16215. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16216. }
  16217. m.AddOrganizationID(v)
  16218. return nil
  16219. }
  16220. return fmt.Errorf("unknown LabelRelationship numeric field %s", name)
  16221. }
  16222. // ClearedFields returns all nullable fields that were cleared during this
  16223. // mutation.
  16224. func (m *LabelRelationshipMutation) ClearedFields() []string {
  16225. var fields []string
  16226. if m.FieldCleared(labelrelationship.FieldStatus) {
  16227. fields = append(fields, labelrelationship.FieldStatus)
  16228. }
  16229. if m.FieldCleared(labelrelationship.FieldOrganizationID) {
  16230. fields = append(fields, labelrelationship.FieldOrganizationID)
  16231. }
  16232. return fields
  16233. }
  16234. // FieldCleared returns a boolean indicating if a field with the given name was
  16235. // cleared in this mutation.
  16236. func (m *LabelRelationshipMutation) FieldCleared(name string) bool {
  16237. _, ok := m.clearedFields[name]
  16238. return ok
  16239. }
  16240. // ClearField clears the value of the field with the given name. It returns an
  16241. // error if the field is not defined in the schema.
  16242. func (m *LabelRelationshipMutation) ClearField(name string) error {
  16243. switch name {
  16244. case labelrelationship.FieldStatus:
  16245. m.ClearStatus()
  16246. return nil
  16247. case labelrelationship.FieldOrganizationID:
  16248. m.ClearOrganizationID()
  16249. return nil
  16250. }
  16251. return fmt.Errorf("unknown LabelRelationship nullable field %s", name)
  16252. }
  16253. // ResetField resets all changes in the mutation for the field with the given name.
  16254. // It returns an error if the field is not defined in the schema.
  16255. func (m *LabelRelationshipMutation) ResetField(name string) error {
  16256. switch name {
  16257. case labelrelationship.FieldCreatedAt:
  16258. m.ResetCreatedAt()
  16259. return nil
  16260. case labelrelationship.FieldUpdatedAt:
  16261. m.ResetUpdatedAt()
  16262. return nil
  16263. case labelrelationship.FieldStatus:
  16264. m.ResetStatus()
  16265. return nil
  16266. case labelrelationship.FieldLabelID:
  16267. m.ResetLabelID()
  16268. return nil
  16269. case labelrelationship.FieldContactID:
  16270. m.ResetContactID()
  16271. return nil
  16272. case labelrelationship.FieldOrganizationID:
  16273. m.ResetOrganizationID()
  16274. return nil
  16275. }
  16276. return fmt.Errorf("unknown LabelRelationship field %s", name)
  16277. }
  16278. // AddedEdges returns all edge names that were set/added in this mutation.
  16279. func (m *LabelRelationshipMutation) AddedEdges() []string {
  16280. edges := make([]string, 0, 2)
  16281. if m.contacts != nil {
  16282. edges = append(edges, labelrelationship.EdgeContacts)
  16283. }
  16284. if m.labels != nil {
  16285. edges = append(edges, labelrelationship.EdgeLabels)
  16286. }
  16287. return edges
  16288. }
  16289. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  16290. // name in this mutation.
  16291. func (m *LabelRelationshipMutation) AddedIDs(name string) []ent.Value {
  16292. switch name {
  16293. case labelrelationship.EdgeContacts:
  16294. if id := m.contacts; id != nil {
  16295. return []ent.Value{*id}
  16296. }
  16297. case labelrelationship.EdgeLabels:
  16298. if id := m.labels; id != nil {
  16299. return []ent.Value{*id}
  16300. }
  16301. }
  16302. return nil
  16303. }
  16304. // RemovedEdges returns all edge names that were removed in this mutation.
  16305. func (m *LabelRelationshipMutation) RemovedEdges() []string {
  16306. edges := make([]string, 0, 2)
  16307. return edges
  16308. }
  16309. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  16310. // the given name in this mutation.
  16311. func (m *LabelRelationshipMutation) RemovedIDs(name string) []ent.Value {
  16312. return nil
  16313. }
  16314. // ClearedEdges returns all edge names that were cleared in this mutation.
  16315. func (m *LabelRelationshipMutation) ClearedEdges() []string {
  16316. edges := make([]string, 0, 2)
  16317. if m.clearedcontacts {
  16318. edges = append(edges, labelrelationship.EdgeContacts)
  16319. }
  16320. if m.clearedlabels {
  16321. edges = append(edges, labelrelationship.EdgeLabels)
  16322. }
  16323. return edges
  16324. }
  16325. // EdgeCleared returns a boolean which indicates if the edge with the given name
  16326. // was cleared in this mutation.
  16327. func (m *LabelRelationshipMutation) EdgeCleared(name string) bool {
  16328. switch name {
  16329. case labelrelationship.EdgeContacts:
  16330. return m.clearedcontacts
  16331. case labelrelationship.EdgeLabels:
  16332. return m.clearedlabels
  16333. }
  16334. return false
  16335. }
  16336. // ClearEdge clears the value of the edge with the given name. It returns an error
  16337. // if that edge is not defined in the schema.
  16338. func (m *LabelRelationshipMutation) ClearEdge(name string) error {
  16339. switch name {
  16340. case labelrelationship.EdgeContacts:
  16341. m.ClearContacts()
  16342. return nil
  16343. case labelrelationship.EdgeLabels:
  16344. m.ClearLabels()
  16345. return nil
  16346. }
  16347. return fmt.Errorf("unknown LabelRelationship unique edge %s", name)
  16348. }
  16349. // ResetEdge resets all changes to the edge with the given name in this mutation.
  16350. // It returns an error if the edge is not defined in the schema.
  16351. func (m *LabelRelationshipMutation) ResetEdge(name string) error {
  16352. switch name {
  16353. case labelrelationship.EdgeContacts:
  16354. m.ResetContacts()
  16355. return nil
  16356. case labelrelationship.EdgeLabels:
  16357. m.ResetLabels()
  16358. return nil
  16359. }
  16360. return fmt.Errorf("unknown LabelRelationship edge %s", name)
  16361. }
  16362. // LabelTaggingMutation represents an operation that mutates the LabelTagging nodes in the graph.
  16363. type LabelTaggingMutation struct {
  16364. config
  16365. op Op
  16366. typ string
  16367. id *uint64
  16368. created_at *time.Time
  16369. updated_at *time.Time
  16370. status *uint8
  16371. addstatus *int8
  16372. deleted_at *time.Time
  16373. organization_id *uint64
  16374. addorganization_id *int64
  16375. _type *int
  16376. add_type *int
  16377. conditions *string
  16378. action_label_add *[]uint64
  16379. appendaction_label_add []uint64
  16380. action_label_del *[]uint64
  16381. appendaction_label_del []uint64
  16382. clearedFields map[string]struct{}
  16383. done bool
  16384. oldValue func(context.Context) (*LabelTagging, error)
  16385. predicates []predicate.LabelTagging
  16386. }
  16387. var _ ent.Mutation = (*LabelTaggingMutation)(nil)
  16388. // labeltaggingOption allows management of the mutation configuration using functional options.
  16389. type labeltaggingOption func(*LabelTaggingMutation)
  16390. // newLabelTaggingMutation creates new mutation for the LabelTagging entity.
  16391. func newLabelTaggingMutation(c config, op Op, opts ...labeltaggingOption) *LabelTaggingMutation {
  16392. m := &LabelTaggingMutation{
  16393. config: c,
  16394. op: op,
  16395. typ: TypeLabelTagging,
  16396. clearedFields: make(map[string]struct{}),
  16397. }
  16398. for _, opt := range opts {
  16399. opt(m)
  16400. }
  16401. return m
  16402. }
  16403. // withLabelTaggingID sets the ID field of the mutation.
  16404. func withLabelTaggingID(id uint64) labeltaggingOption {
  16405. return func(m *LabelTaggingMutation) {
  16406. var (
  16407. err error
  16408. once sync.Once
  16409. value *LabelTagging
  16410. )
  16411. m.oldValue = func(ctx context.Context) (*LabelTagging, error) {
  16412. once.Do(func() {
  16413. if m.done {
  16414. err = errors.New("querying old values post mutation is not allowed")
  16415. } else {
  16416. value, err = m.Client().LabelTagging.Get(ctx, id)
  16417. }
  16418. })
  16419. return value, err
  16420. }
  16421. m.id = &id
  16422. }
  16423. }
  16424. // withLabelTagging sets the old LabelTagging of the mutation.
  16425. func withLabelTagging(node *LabelTagging) labeltaggingOption {
  16426. return func(m *LabelTaggingMutation) {
  16427. m.oldValue = func(context.Context) (*LabelTagging, error) {
  16428. return node, nil
  16429. }
  16430. m.id = &node.ID
  16431. }
  16432. }
  16433. // Client returns a new `ent.Client` from the mutation. If the mutation was
  16434. // executed in a transaction (ent.Tx), a transactional client is returned.
  16435. func (m LabelTaggingMutation) Client() *Client {
  16436. client := &Client{config: m.config}
  16437. client.init()
  16438. return client
  16439. }
  16440. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  16441. // it returns an error otherwise.
  16442. func (m LabelTaggingMutation) Tx() (*Tx, error) {
  16443. if _, ok := m.driver.(*txDriver); !ok {
  16444. return nil, errors.New("ent: mutation is not running in a transaction")
  16445. }
  16446. tx := &Tx{config: m.config}
  16447. tx.init()
  16448. return tx, nil
  16449. }
  16450. // SetID sets the value of the id field. Note that this
  16451. // operation is only accepted on creation of LabelTagging entities.
  16452. func (m *LabelTaggingMutation) SetID(id uint64) {
  16453. m.id = &id
  16454. }
  16455. // ID returns the ID value in the mutation. Note that the ID is only available
  16456. // if it was provided to the builder or after it was returned from the database.
  16457. func (m *LabelTaggingMutation) ID() (id uint64, exists bool) {
  16458. if m.id == nil {
  16459. return
  16460. }
  16461. return *m.id, true
  16462. }
  16463. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  16464. // That means, if the mutation is applied within a transaction with an isolation level such
  16465. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  16466. // or updated by the mutation.
  16467. func (m *LabelTaggingMutation) IDs(ctx context.Context) ([]uint64, error) {
  16468. switch {
  16469. case m.op.Is(OpUpdateOne | OpDeleteOne):
  16470. id, exists := m.ID()
  16471. if exists {
  16472. return []uint64{id}, nil
  16473. }
  16474. fallthrough
  16475. case m.op.Is(OpUpdate | OpDelete):
  16476. return m.Client().LabelTagging.Query().Where(m.predicates...).IDs(ctx)
  16477. default:
  16478. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  16479. }
  16480. }
  16481. // SetCreatedAt sets the "created_at" field.
  16482. func (m *LabelTaggingMutation) SetCreatedAt(t time.Time) {
  16483. m.created_at = &t
  16484. }
  16485. // CreatedAt returns the value of the "created_at" field in the mutation.
  16486. func (m *LabelTaggingMutation) CreatedAt() (r time.Time, exists bool) {
  16487. v := m.created_at
  16488. if v == nil {
  16489. return
  16490. }
  16491. return *v, true
  16492. }
  16493. // OldCreatedAt returns the old "created_at" field's value of the LabelTagging entity.
  16494. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  16495. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16496. func (m *LabelTaggingMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  16497. if !m.op.Is(OpUpdateOne) {
  16498. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  16499. }
  16500. if m.id == nil || m.oldValue == nil {
  16501. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  16502. }
  16503. oldValue, err := m.oldValue(ctx)
  16504. if err != nil {
  16505. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  16506. }
  16507. return oldValue.CreatedAt, nil
  16508. }
  16509. // ResetCreatedAt resets all changes to the "created_at" field.
  16510. func (m *LabelTaggingMutation) ResetCreatedAt() {
  16511. m.created_at = nil
  16512. }
  16513. // SetUpdatedAt sets the "updated_at" field.
  16514. func (m *LabelTaggingMutation) SetUpdatedAt(t time.Time) {
  16515. m.updated_at = &t
  16516. }
  16517. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  16518. func (m *LabelTaggingMutation) UpdatedAt() (r time.Time, exists bool) {
  16519. v := m.updated_at
  16520. if v == nil {
  16521. return
  16522. }
  16523. return *v, true
  16524. }
  16525. // OldUpdatedAt returns the old "updated_at" field's value of the LabelTagging entity.
  16526. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  16527. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16528. func (m *LabelTaggingMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  16529. if !m.op.Is(OpUpdateOne) {
  16530. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  16531. }
  16532. if m.id == nil || m.oldValue == nil {
  16533. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  16534. }
  16535. oldValue, err := m.oldValue(ctx)
  16536. if err != nil {
  16537. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  16538. }
  16539. return oldValue.UpdatedAt, nil
  16540. }
  16541. // ResetUpdatedAt resets all changes to the "updated_at" field.
  16542. func (m *LabelTaggingMutation) ResetUpdatedAt() {
  16543. m.updated_at = nil
  16544. }
  16545. // SetStatus sets the "status" field.
  16546. func (m *LabelTaggingMutation) SetStatus(u uint8) {
  16547. m.status = &u
  16548. m.addstatus = nil
  16549. }
  16550. // Status returns the value of the "status" field in the mutation.
  16551. func (m *LabelTaggingMutation) Status() (r uint8, exists bool) {
  16552. v := m.status
  16553. if v == nil {
  16554. return
  16555. }
  16556. return *v, true
  16557. }
  16558. // OldStatus returns the old "status" field's value of the LabelTagging entity.
  16559. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  16560. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16561. func (m *LabelTaggingMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  16562. if !m.op.Is(OpUpdateOne) {
  16563. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  16564. }
  16565. if m.id == nil || m.oldValue == nil {
  16566. return v, errors.New("OldStatus requires an ID field in the mutation")
  16567. }
  16568. oldValue, err := m.oldValue(ctx)
  16569. if err != nil {
  16570. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  16571. }
  16572. return oldValue.Status, nil
  16573. }
  16574. // AddStatus adds u to the "status" field.
  16575. func (m *LabelTaggingMutation) AddStatus(u int8) {
  16576. if m.addstatus != nil {
  16577. *m.addstatus += u
  16578. } else {
  16579. m.addstatus = &u
  16580. }
  16581. }
  16582. // AddedStatus returns the value that was added to the "status" field in this mutation.
  16583. func (m *LabelTaggingMutation) AddedStatus() (r int8, exists bool) {
  16584. v := m.addstatus
  16585. if v == nil {
  16586. return
  16587. }
  16588. return *v, true
  16589. }
  16590. // ClearStatus clears the value of the "status" field.
  16591. func (m *LabelTaggingMutation) ClearStatus() {
  16592. m.status = nil
  16593. m.addstatus = nil
  16594. m.clearedFields[labeltagging.FieldStatus] = struct{}{}
  16595. }
  16596. // StatusCleared returns if the "status" field was cleared in this mutation.
  16597. func (m *LabelTaggingMutation) StatusCleared() bool {
  16598. _, ok := m.clearedFields[labeltagging.FieldStatus]
  16599. return ok
  16600. }
  16601. // ResetStatus resets all changes to the "status" field.
  16602. func (m *LabelTaggingMutation) ResetStatus() {
  16603. m.status = nil
  16604. m.addstatus = nil
  16605. delete(m.clearedFields, labeltagging.FieldStatus)
  16606. }
  16607. // SetDeletedAt sets the "deleted_at" field.
  16608. func (m *LabelTaggingMutation) SetDeletedAt(t time.Time) {
  16609. m.deleted_at = &t
  16610. }
  16611. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  16612. func (m *LabelTaggingMutation) DeletedAt() (r time.Time, exists bool) {
  16613. v := m.deleted_at
  16614. if v == nil {
  16615. return
  16616. }
  16617. return *v, true
  16618. }
  16619. // OldDeletedAt returns the old "deleted_at" field's value of the LabelTagging entity.
  16620. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  16621. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16622. func (m *LabelTaggingMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  16623. if !m.op.Is(OpUpdateOne) {
  16624. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  16625. }
  16626. if m.id == nil || m.oldValue == nil {
  16627. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  16628. }
  16629. oldValue, err := m.oldValue(ctx)
  16630. if err != nil {
  16631. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  16632. }
  16633. return oldValue.DeletedAt, nil
  16634. }
  16635. // ClearDeletedAt clears the value of the "deleted_at" field.
  16636. func (m *LabelTaggingMutation) ClearDeletedAt() {
  16637. m.deleted_at = nil
  16638. m.clearedFields[labeltagging.FieldDeletedAt] = struct{}{}
  16639. }
  16640. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  16641. func (m *LabelTaggingMutation) DeletedAtCleared() bool {
  16642. _, ok := m.clearedFields[labeltagging.FieldDeletedAt]
  16643. return ok
  16644. }
  16645. // ResetDeletedAt resets all changes to the "deleted_at" field.
  16646. func (m *LabelTaggingMutation) ResetDeletedAt() {
  16647. m.deleted_at = nil
  16648. delete(m.clearedFields, labeltagging.FieldDeletedAt)
  16649. }
  16650. // SetOrganizationID sets the "organization_id" field.
  16651. func (m *LabelTaggingMutation) SetOrganizationID(u uint64) {
  16652. m.organization_id = &u
  16653. m.addorganization_id = nil
  16654. }
  16655. // OrganizationID returns the value of the "organization_id" field in the mutation.
  16656. func (m *LabelTaggingMutation) OrganizationID() (r uint64, exists bool) {
  16657. v := m.organization_id
  16658. if v == nil {
  16659. return
  16660. }
  16661. return *v, true
  16662. }
  16663. // OldOrganizationID returns the old "organization_id" field's value of the LabelTagging entity.
  16664. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  16665. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16666. func (m *LabelTaggingMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  16667. if !m.op.Is(OpUpdateOne) {
  16668. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  16669. }
  16670. if m.id == nil || m.oldValue == nil {
  16671. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  16672. }
  16673. oldValue, err := m.oldValue(ctx)
  16674. if err != nil {
  16675. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  16676. }
  16677. return oldValue.OrganizationID, nil
  16678. }
  16679. // AddOrganizationID adds u to the "organization_id" field.
  16680. func (m *LabelTaggingMutation) AddOrganizationID(u int64) {
  16681. if m.addorganization_id != nil {
  16682. *m.addorganization_id += u
  16683. } else {
  16684. m.addorganization_id = &u
  16685. }
  16686. }
  16687. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  16688. func (m *LabelTaggingMutation) AddedOrganizationID() (r int64, exists bool) {
  16689. v := m.addorganization_id
  16690. if v == nil {
  16691. return
  16692. }
  16693. return *v, true
  16694. }
  16695. // ResetOrganizationID resets all changes to the "organization_id" field.
  16696. func (m *LabelTaggingMutation) ResetOrganizationID() {
  16697. m.organization_id = nil
  16698. m.addorganization_id = nil
  16699. }
  16700. // SetType sets the "type" field.
  16701. func (m *LabelTaggingMutation) SetType(i int) {
  16702. m._type = &i
  16703. m.add_type = nil
  16704. }
  16705. // GetType returns the value of the "type" field in the mutation.
  16706. func (m *LabelTaggingMutation) GetType() (r int, exists bool) {
  16707. v := m._type
  16708. if v == nil {
  16709. return
  16710. }
  16711. return *v, true
  16712. }
  16713. // OldType returns the old "type" field's value of the LabelTagging entity.
  16714. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  16715. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16716. func (m *LabelTaggingMutation) OldType(ctx context.Context) (v int, err error) {
  16717. if !m.op.Is(OpUpdateOne) {
  16718. return v, errors.New("OldType is only allowed on UpdateOne operations")
  16719. }
  16720. if m.id == nil || m.oldValue == nil {
  16721. return v, errors.New("OldType requires an ID field in the mutation")
  16722. }
  16723. oldValue, err := m.oldValue(ctx)
  16724. if err != nil {
  16725. return v, fmt.Errorf("querying old value for OldType: %w", err)
  16726. }
  16727. return oldValue.Type, nil
  16728. }
  16729. // AddType adds i to the "type" field.
  16730. func (m *LabelTaggingMutation) AddType(i int) {
  16731. if m.add_type != nil {
  16732. *m.add_type += i
  16733. } else {
  16734. m.add_type = &i
  16735. }
  16736. }
  16737. // AddedType returns the value that was added to the "type" field in this mutation.
  16738. func (m *LabelTaggingMutation) AddedType() (r int, exists bool) {
  16739. v := m.add_type
  16740. if v == nil {
  16741. return
  16742. }
  16743. return *v, true
  16744. }
  16745. // ResetType resets all changes to the "type" field.
  16746. func (m *LabelTaggingMutation) ResetType() {
  16747. m._type = nil
  16748. m.add_type = nil
  16749. }
  16750. // SetConditions sets the "conditions" field.
  16751. func (m *LabelTaggingMutation) SetConditions(s string) {
  16752. m.conditions = &s
  16753. }
  16754. // Conditions returns the value of the "conditions" field in the mutation.
  16755. func (m *LabelTaggingMutation) Conditions() (r string, exists bool) {
  16756. v := m.conditions
  16757. if v == nil {
  16758. return
  16759. }
  16760. return *v, true
  16761. }
  16762. // OldConditions returns the old "conditions" field's value of the LabelTagging entity.
  16763. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  16764. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16765. func (m *LabelTaggingMutation) OldConditions(ctx context.Context) (v string, err error) {
  16766. if !m.op.Is(OpUpdateOne) {
  16767. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  16768. }
  16769. if m.id == nil || m.oldValue == nil {
  16770. return v, errors.New("OldConditions requires an ID field in the mutation")
  16771. }
  16772. oldValue, err := m.oldValue(ctx)
  16773. if err != nil {
  16774. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  16775. }
  16776. return oldValue.Conditions, nil
  16777. }
  16778. // ResetConditions resets all changes to the "conditions" field.
  16779. func (m *LabelTaggingMutation) ResetConditions() {
  16780. m.conditions = nil
  16781. }
  16782. // SetActionLabelAdd sets the "action_label_add" field.
  16783. func (m *LabelTaggingMutation) SetActionLabelAdd(u []uint64) {
  16784. m.action_label_add = &u
  16785. m.appendaction_label_add = nil
  16786. }
  16787. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  16788. func (m *LabelTaggingMutation) ActionLabelAdd() (r []uint64, exists bool) {
  16789. v := m.action_label_add
  16790. if v == nil {
  16791. return
  16792. }
  16793. return *v, true
  16794. }
  16795. // OldActionLabelAdd returns the old "action_label_add" field's value of the LabelTagging entity.
  16796. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  16797. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16798. func (m *LabelTaggingMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  16799. if !m.op.Is(OpUpdateOne) {
  16800. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  16801. }
  16802. if m.id == nil || m.oldValue == nil {
  16803. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  16804. }
  16805. oldValue, err := m.oldValue(ctx)
  16806. if err != nil {
  16807. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  16808. }
  16809. return oldValue.ActionLabelAdd, nil
  16810. }
  16811. // AppendActionLabelAdd adds u to the "action_label_add" field.
  16812. func (m *LabelTaggingMutation) AppendActionLabelAdd(u []uint64) {
  16813. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  16814. }
  16815. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  16816. func (m *LabelTaggingMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  16817. if len(m.appendaction_label_add) == 0 {
  16818. return nil, false
  16819. }
  16820. return m.appendaction_label_add, true
  16821. }
  16822. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  16823. func (m *LabelTaggingMutation) ClearActionLabelAdd() {
  16824. m.action_label_add = nil
  16825. m.appendaction_label_add = nil
  16826. m.clearedFields[labeltagging.FieldActionLabelAdd] = struct{}{}
  16827. }
  16828. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  16829. func (m *LabelTaggingMutation) ActionLabelAddCleared() bool {
  16830. _, ok := m.clearedFields[labeltagging.FieldActionLabelAdd]
  16831. return ok
  16832. }
  16833. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  16834. func (m *LabelTaggingMutation) ResetActionLabelAdd() {
  16835. m.action_label_add = nil
  16836. m.appendaction_label_add = nil
  16837. delete(m.clearedFields, labeltagging.FieldActionLabelAdd)
  16838. }
  16839. // SetActionLabelDel sets the "action_label_del" field.
  16840. func (m *LabelTaggingMutation) SetActionLabelDel(u []uint64) {
  16841. m.action_label_del = &u
  16842. m.appendaction_label_del = nil
  16843. }
  16844. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  16845. func (m *LabelTaggingMutation) ActionLabelDel() (r []uint64, exists bool) {
  16846. v := m.action_label_del
  16847. if v == nil {
  16848. return
  16849. }
  16850. return *v, true
  16851. }
  16852. // OldActionLabelDel returns the old "action_label_del" field's value of the LabelTagging entity.
  16853. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  16854. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16855. func (m *LabelTaggingMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  16856. if !m.op.Is(OpUpdateOne) {
  16857. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  16858. }
  16859. if m.id == nil || m.oldValue == nil {
  16860. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  16861. }
  16862. oldValue, err := m.oldValue(ctx)
  16863. if err != nil {
  16864. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  16865. }
  16866. return oldValue.ActionLabelDel, nil
  16867. }
  16868. // AppendActionLabelDel adds u to the "action_label_del" field.
  16869. func (m *LabelTaggingMutation) AppendActionLabelDel(u []uint64) {
  16870. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  16871. }
  16872. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  16873. func (m *LabelTaggingMutation) AppendedActionLabelDel() ([]uint64, bool) {
  16874. if len(m.appendaction_label_del) == 0 {
  16875. return nil, false
  16876. }
  16877. return m.appendaction_label_del, true
  16878. }
  16879. // ClearActionLabelDel clears the value of the "action_label_del" field.
  16880. func (m *LabelTaggingMutation) ClearActionLabelDel() {
  16881. m.action_label_del = nil
  16882. m.appendaction_label_del = nil
  16883. m.clearedFields[labeltagging.FieldActionLabelDel] = struct{}{}
  16884. }
  16885. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  16886. func (m *LabelTaggingMutation) ActionLabelDelCleared() bool {
  16887. _, ok := m.clearedFields[labeltagging.FieldActionLabelDel]
  16888. return ok
  16889. }
  16890. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  16891. func (m *LabelTaggingMutation) ResetActionLabelDel() {
  16892. m.action_label_del = nil
  16893. m.appendaction_label_del = nil
  16894. delete(m.clearedFields, labeltagging.FieldActionLabelDel)
  16895. }
  16896. // Where appends a list predicates to the LabelTaggingMutation builder.
  16897. func (m *LabelTaggingMutation) Where(ps ...predicate.LabelTagging) {
  16898. m.predicates = append(m.predicates, ps...)
  16899. }
  16900. // WhereP appends storage-level predicates to the LabelTaggingMutation builder. Using this method,
  16901. // users can use type-assertion to append predicates that do not depend on any generated package.
  16902. func (m *LabelTaggingMutation) WhereP(ps ...func(*sql.Selector)) {
  16903. p := make([]predicate.LabelTagging, len(ps))
  16904. for i := range ps {
  16905. p[i] = ps[i]
  16906. }
  16907. m.Where(p...)
  16908. }
  16909. // Op returns the operation name.
  16910. func (m *LabelTaggingMutation) Op() Op {
  16911. return m.op
  16912. }
  16913. // SetOp allows setting the mutation operation.
  16914. func (m *LabelTaggingMutation) SetOp(op Op) {
  16915. m.op = op
  16916. }
  16917. // Type returns the node type of this mutation (LabelTagging).
  16918. func (m *LabelTaggingMutation) Type() string {
  16919. return m.typ
  16920. }
  16921. // Fields returns all fields that were changed during this mutation. Note that in
  16922. // order to get all numeric fields that were incremented/decremented, call
  16923. // AddedFields().
  16924. func (m *LabelTaggingMutation) Fields() []string {
  16925. fields := make([]string, 0, 9)
  16926. if m.created_at != nil {
  16927. fields = append(fields, labeltagging.FieldCreatedAt)
  16928. }
  16929. if m.updated_at != nil {
  16930. fields = append(fields, labeltagging.FieldUpdatedAt)
  16931. }
  16932. if m.status != nil {
  16933. fields = append(fields, labeltagging.FieldStatus)
  16934. }
  16935. if m.deleted_at != nil {
  16936. fields = append(fields, labeltagging.FieldDeletedAt)
  16937. }
  16938. if m.organization_id != nil {
  16939. fields = append(fields, labeltagging.FieldOrganizationID)
  16940. }
  16941. if m._type != nil {
  16942. fields = append(fields, labeltagging.FieldType)
  16943. }
  16944. if m.conditions != nil {
  16945. fields = append(fields, labeltagging.FieldConditions)
  16946. }
  16947. if m.action_label_add != nil {
  16948. fields = append(fields, labeltagging.FieldActionLabelAdd)
  16949. }
  16950. if m.action_label_del != nil {
  16951. fields = append(fields, labeltagging.FieldActionLabelDel)
  16952. }
  16953. return fields
  16954. }
  16955. // Field returns the value of a field with the given name. The second boolean
  16956. // return value indicates that this field was not set, or was not defined in the
  16957. // schema.
  16958. func (m *LabelTaggingMutation) Field(name string) (ent.Value, bool) {
  16959. switch name {
  16960. case labeltagging.FieldCreatedAt:
  16961. return m.CreatedAt()
  16962. case labeltagging.FieldUpdatedAt:
  16963. return m.UpdatedAt()
  16964. case labeltagging.FieldStatus:
  16965. return m.Status()
  16966. case labeltagging.FieldDeletedAt:
  16967. return m.DeletedAt()
  16968. case labeltagging.FieldOrganizationID:
  16969. return m.OrganizationID()
  16970. case labeltagging.FieldType:
  16971. return m.GetType()
  16972. case labeltagging.FieldConditions:
  16973. return m.Conditions()
  16974. case labeltagging.FieldActionLabelAdd:
  16975. return m.ActionLabelAdd()
  16976. case labeltagging.FieldActionLabelDel:
  16977. return m.ActionLabelDel()
  16978. }
  16979. return nil, false
  16980. }
  16981. // OldField returns the old value of the field from the database. An error is
  16982. // returned if the mutation operation is not UpdateOne, or the query to the
  16983. // database failed.
  16984. func (m *LabelTaggingMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  16985. switch name {
  16986. case labeltagging.FieldCreatedAt:
  16987. return m.OldCreatedAt(ctx)
  16988. case labeltagging.FieldUpdatedAt:
  16989. return m.OldUpdatedAt(ctx)
  16990. case labeltagging.FieldStatus:
  16991. return m.OldStatus(ctx)
  16992. case labeltagging.FieldDeletedAt:
  16993. return m.OldDeletedAt(ctx)
  16994. case labeltagging.FieldOrganizationID:
  16995. return m.OldOrganizationID(ctx)
  16996. case labeltagging.FieldType:
  16997. return m.OldType(ctx)
  16998. case labeltagging.FieldConditions:
  16999. return m.OldConditions(ctx)
  17000. case labeltagging.FieldActionLabelAdd:
  17001. return m.OldActionLabelAdd(ctx)
  17002. case labeltagging.FieldActionLabelDel:
  17003. return m.OldActionLabelDel(ctx)
  17004. }
  17005. return nil, fmt.Errorf("unknown LabelTagging field %s", name)
  17006. }
  17007. // SetField sets the value of a field with the given name. It returns an error if
  17008. // the field is not defined in the schema, or if the type mismatched the field
  17009. // type.
  17010. func (m *LabelTaggingMutation) SetField(name string, value ent.Value) error {
  17011. switch name {
  17012. case labeltagging.FieldCreatedAt:
  17013. v, ok := value.(time.Time)
  17014. if !ok {
  17015. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17016. }
  17017. m.SetCreatedAt(v)
  17018. return nil
  17019. case labeltagging.FieldUpdatedAt:
  17020. v, ok := value.(time.Time)
  17021. if !ok {
  17022. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17023. }
  17024. m.SetUpdatedAt(v)
  17025. return nil
  17026. case labeltagging.FieldStatus:
  17027. v, ok := value.(uint8)
  17028. if !ok {
  17029. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17030. }
  17031. m.SetStatus(v)
  17032. return nil
  17033. case labeltagging.FieldDeletedAt:
  17034. v, ok := value.(time.Time)
  17035. if !ok {
  17036. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17037. }
  17038. m.SetDeletedAt(v)
  17039. return nil
  17040. case labeltagging.FieldOrganizationID:
  17041. v, ok := value.(uint64)
  17042. if !ok {
  17043. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17044. }
  17045. m.SetOrganizationID(v)
  17046. return nil
  17047. case labeltagging.FieldType:
  17048. v, ok := value.(int)
  17049. if !ok {
  17050. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17051. }
  17052. m.SetType(v)
  17053. return nil
  17054. case labeltagging.FieldConditions:
  17055. v, ok := value.(string)
  17056. if !ok {
  17057. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17058. }
  17059. m.SetConditions(v)
  17060. return nil
  17061. case labeltagging.FieldActionLabelAdd:
  17062. v, ok := value.([]uint64)
  17063. if !ok {
  17064. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17065. }
  17066. m.SetActionLabelAdd(v)
  17067. return nil
  17068. case labeltagging.FieldActionLabelDel:
  17069. v, ok := value.([]uint64)
  17070. if !ok {
  17071. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17072. }
  17073. m.SetActionLabelDel(v)
  17074. return nil
  17075. }
  17076. return fmt.Errorf("unknown LabelTagging field %s", name)
  17077. }
  17078. // AddedFields returns all numeric fields that were incremented/decremented during
  17079. // this mutation.
  17080. func (m *LabelTaggingMutation) AddedFields() []string {
  17081. var fields []string
  17082. if m.addstatus != nil {
  17083. fields = append(fields, labeltagging.FieldStatus)
  17084. }
  17085. if m.addorganization_id != nil {
  17086. fields = append(fields, labeltagging.FieldOrganizationID)
  17087. }
  17088. if m.add_type != nil {
  17089. fields = append(fields, labeltagging.FieldType)
  17090. }
  17091. return fields
  17092. }
  17093. // AddedField returns the numeric value that was incremented/decremented on a field
  17094. // with the given name. The second boolean return value indicates that this field
  17095. // was not set, or was not defined in the schema.
  17096. func (m *LabelTaggingMutation) AddedField(name string) (ent.Value, bool) {
  17097. switch name {
  17098. case labeltagging.FieldStatus:
  17099. return m.AddedStatus()
  17100. case labeltagging.FieldOrganizationID:
  17101. return m.AddedOrganizationID()
  17102. case labeltagging.FieldType:
  17103. return m.AddedType()
  17104. }
  17105. return nil, false
  17106. }
  17107. // AddField adds the value to the field with the given name. It returns an error if
  17108. // the field is not defined in the schema, or if the type mismatched the field
  17109. // type.
  17110. func (m *LabelTaggingMutation) AddField(name string, value ent.Value) error {
  17111. switch name {
  17112. case labeltagging.FieldStatus:
  17113. v, ok := value.(int8)
  17114. if !ok {
  17115. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17116. }
  17117. m.AddStatus(v)
  17118. return nil
  17119. case labeltagging.FieldOrganizationID:
  17120. v, ok := value.(int64)
  17121. if !ok {
  17122. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17123. }
  17124. m.AddOrganizationID(v)
  17125. return nil
  17126. case labeltagging.FieldType:
  17127. v, ok := value.(int)
  17128. if !ok {
  17129. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17130. }
  17131. m.AddType(v)
  17132. return nil
  17133. }
  17134. return fmt.Errorf("unknown LabelTagging numeric field %s", name)
  17135. }
  17136. // ClearedFields returns all nullable fields that were cleared during this
  17137. // mutation.
  17138. func (m *LabelTaggingMutation) ClearedFields() []string {
  17139. var fields []string
  17140. if m.FieldCleared(labeltagging.FieldStatus) {
  17141. fields = append(fields, labeltagging.FieldStatus)
  17142. }
  17143. if m.FieldCleared(labeltagging.FieldDeletedAt) {
  17144. fields = append(fields, labeltagging.FieldDeletedAt)
  17145. }
  17146. if m.FieldCleared(labeltagging.FieldActionLabelAdd) {
  17147. fields = append(fields, labeltagging.FieldActionLabelAdd)
  17148. }
  17149. if m.FieldCleared(labeltagging.FieldActionLabelDel) {
  17150. fields = append(fields, labeltagging.FieldActionLabelDel)
  17151. }
  17152. return fields
  17153. }
  17154. // FieldCleared returns a boolean indicating if a field with the given name was
  17155. // cleared in this mutation.
  17156. func (m *LabelTaggingMutation) FieldCleared(name string) bool {
  17157. _, ok := m.clearedFields[name]
  17158. return ok
  17159. }
  17160. // ClearField clears the value of the field with the given name. It returns an
  17161. // error if the field is not defined in the schema.
  17162. func (m *LabelTaggingMutation) ClearField(name string) error {
  17163. switch name {
  17164. case labeltagging.FieldStatus:
  17165. m.ClearStatus()
  17166. return nil
  17167. case labeltagging.FieldDeletedAt:
  17168. m.ClearDeletedAt()
  17169. return nil
  17170. case labeltagging.FieldActionLabelAdd:
  17171. m.ClearActionLabelAdd()
  17172. return nil
  17173. case labeltagging.FieldActionLabelDel:
  17174. m.ClearActionLabelDel()
  17175. return nil
  17176. }
  17177. return fmt.Errorf("unknown LabelTagging nullable field %s", name)
  17178. }
  17179. // ResetField resets all changes in the mutation for the field with the given name.
  17180. // It returns an error if the field is not defined in the schema.
  17181. func (m *LabelTaggingMutation) ResetField(name string) error {
  17182. switch name {
  17183. case labeltagging.FieldCreatedAt:
  17184. m.ResetCreatedAt()
  17185. return nil
  17186. case labeltagging.FieldUpdatedAt:
  17187. m.ResetUpdatedAt()
  17188. return nil
  17189. case labeltagging.FieldStatus:
  17190. m.ResetStatus()
  17191. return nil
  17192. case labeltagging.FieldDeletedAt:
  17193. m.ResetDeletedAt()
  17194. return nil
  17195. case labeltagging.FieldOrganizationID:
  17196. m.ResetOrganizationID()
  17197. return nil
  17198. case labeltagging.FieldType:
  17199. m.ResetType()
  17200. return nil
  17201. case labeltagging.FieldConditions:
  17202. m.ResetConditions()
  17203. return nil
  17204. case labeltagging.FieldActionLabelAdd:
  17205. m.ResetActionLabelAdd()
  17206. return nil
  17207. case labeltagging.FieldActionLabelDel:
  17208. m.ResetActionLabelDel()
  17209. return nil
  17210. }
  17211. return fmt.Errorf("unknown LabelTagging field %s", name)
  17212. }
  17213. // AddedEdges returns all edge names that were set/added in this mutation.
  17214. func (m *LabelTaggingMutation) AddedEdges() []string {
  17215. edges := make([]string, 0, 0)
  17216. return edges
  17217. }
  17218. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  17219. // name in this mutation.
  17220. func (m *LabelTaggingMutation) AddedIDs(name string) []ent.Value {
  17221. return nil
  17222. }
  17223. // RemovedEdges returns all edge names that were removed in this mutation.
  17224. func (m *LabelTaggingMutation) RemovedEdges() []string {
  17225. edges := make([]string, 0, 0)
  17226. return edges
  17227. }
  17228. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  17229. // the given name in this mutation.
  17230. func (m *LabelTaggingMutation) RemovedIDs(name string) []ent.Value {
  17231. return nil
  17232. }
  17233. // ClearedEdges returns all edge names that were cleared in this mutation.
  17234. func (m *LabelTaggingMutation) ClearedEdges() []string {
  17235. edges := make([]string, 0, 0)
  17236. return edges
  17237. }
  17238. // EdgeCleared returns a boolean which indicates if the edge with the given name
  17239. // was cleared in this mutation.
  17240. func (m *LabelTaggingMutation) EdgeCleared(name string) bool {
  17241. return false
  17242. }
  17243. // ClearEdge clears the value of the edge with the given name. It returns an error
  17244. // if that edge is not defined in the schema.
  17245. func (m *LabelTaggingMutation) ClearEdge(name string) error {
  17246. return fmt.Errorf("unknown LabelTagging unique edge %s", name)
  17247. }
  17248. // ResetEdge resets all changes to the edge with the given name in this mutation.
  17249. // It returns an error if the edge is not defined in the schema.
  17250. func (m *LabelTaggingMutation) ResetEdge(name string) error {
  17251. return fmt.Errorf("unknown LabelTagging edge %s", name)
  17252. }
  17253. // MessageMutation represents an operation that mutates the Message nodes in the graph.
  17254. type MessageMutation struct {
  17255. config
  17256. op Op
  17257. typ string
  17258. id *int
  17259. wx_wxid *string
  17260. wxid *string
  17261. content *string
  17262. clearedFields map[string]struct{}
  17263. done bool
  17264. oldValue func(context.Context) (*Message, error)
  17265. predicates []predicate.Message
  17266. }
  17267. var _ ent.Mutation = (*MessageMutation)(nil)
  17268. // messageOption allows management of the mutation configuration using functional options.
  17269. type messageOption func(*MessageMutation)
  17270. // newMessageMutation creates new mutation for the Message entity.
  17271. func newMessageMutation(c config, op Op, opts ...messageOption) *MessageMutation {
  17272. m := &MessageMutation{
  17273. config: c,
  17274. op: op,
  17275. typ: TypeMessage,
  17276. clearedFields: make(map[string]struct{}),
  17277. }
  17278. for _, opt := range opts {
  17279. opt(m)
  17280. }
  17281. return m
  17282. }
  17283. // withMessageID sets the ID field of the mutation.
  17284. func withMessageID(id int) messageOption {
  17285. return func(m *MessageMutation) {
  17286. var (
  17287. err error
  17288. once sync.Once
  17289. value *Message
  17290. )
  17291. m.oldValue = func(ctx context.Context) (*Message, error) {
  17292. once.Do(func() {
  17293. if m.done {
  17294. err = errors.New("querying old values post mutation is not allowed")
  17295. } else {
  17296. value, err = m.Client().Message.Get(ctx, id)
  17297. }
  17298. })
  17299. return value, err
  17300. }
  17301. m.id = &id
  17302. }
  17303. }
  17304. // withMessage sets the old Message of the mutation.
  17305. func withMessage(node *Message) messageOption {
  17306. return func(m *MessageMutation) {
  17307. m.oldValue = func(context.Context) (*Message, error) {
  17308. return node, nil
  17309. }
  17310. m.id = &node.ID
  17311. }
  17312. }
  17313. // Client returns a new `ent.Client` from the mutation. If the mutation was
  17314. // executed in a transaction (ent.Tx), a transactional client is returned.
  17315. func (m MessageMutation) Client() *Client {
  17316. client := &Client{config: m.config}
  17317. client.init()
  17318. return client
  17319. }
  17320. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  17321. // it returns an error otherwise.
  17322. func (m MessageMutation) Tx() (*Tx, error) {
  17323. if _, ok := m.driver.(*txDriver); !ok {
  17324. return nil, errors.New("ent: mutation is not running in a transaction")
  17325. }
  17326. tx := &Tx{config: m.config}
  17327. tx.init()
  17328. return tx, nil
  17329. }
  17330. // ID returns the ID value in the mutation. Note that the ID is only available
  17331. // if it was provided to the builder or after it was returned from the database.
  17332. func (m *MessageMutation) ID() (id int, exists bool) {
  17333. if m.id == nil {
  17334. return
  17335. }
  17336. return *m.id, true
  17337. }
  17338. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  17339. // That means, if the mutation is applied within a transaction with an isolation level such
  17340. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  17341. // or updated by the mutation.
  17342. func (m *MessageMutation) IDs(ctx context.Context) ([]int, error) {
  17343. switch {
  17344. case m.op.Is(OpUpdateOne | OpDeleteOne):
  17345. id, exists := m.ID()
  17346. if exists {
  17347. return []int{id}, nil
  17348. }
  17349. fallthrough
  17350. case m.op.Is(OpUpdate | OpDelete):
  17351. return m.Client().Message.Query().Where(m.predicates...).IDs(ctx)
  17352. default:
  17353. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  17354. }
  17355. }
  17356. // SetWxWxid sets the "wx_wxid" field.
  17357. func (m *MessageMutation) SetWxWxid(s string) {
  17358. m.wx_wxid = &s
  17359. }
  17360. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  17361. func (m *MessageMutation) WxWxid() (r string, exists bool) {
  17362. v := m.wx_wxid
  17363. if v == nil {
  17364. return
  17365. }
  17366. return *v, true
  17367. }
  17368. // OldWxWxid returns the old "wx_wxid" field's value of the Message entity.
  17369. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  17370. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17371. func (m *MessageMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  17372. if !m.op.Is(OpUpdateOne) {
  17373. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  17374. }
  17375. if m.id == nil || m.oldValue == nil {
  17376. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  17377. }
  17378. oldValue, err := m.oldValue(ctx)
  17379. if err != nil {
  17380. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  17381. }
  17382. return oldValue.WxWxid, nil
  17383. }
  17384. // ClearWxWxid clears the value of the "wx_wxid" field.
  17385. func (m *MessageMutation) ClearWxWxid() {
  17386. m.wx_wxid = nil
  17387. m.clearedFields[message.FieldWxWxid] = struct{}{}
  17388. }
  17389. // WxWxidCleared returns if the "wx_wxid" field was cleared in this mutation.
  17390. func (m *MessageMutation) WxWxidCleared() bool {
  17391. _, ok := m.clearedFields[message.FieldWxWxid]
  17392. return ok
  17393. }
  17394. // ResetWxWxid resets all changes to the "wx_wxid" field.
  17395. func (m *MessageMutation) ResetWxWxid() {
  17396. m.wx_wxid = nil
  17397. delete(m.clearedFields, message.FieldWxWxid)
  17398. }
  17399. // SetWxid sets the "wxid" field.
  17400. func (m *MessageMutation) SetWxid(s string) {
  17401. m.wxid = &s
  17402. }
  17403. // Wxid returns the value of the "wxid" field in the mutation.
  17404. func (m *MessageMutation) Wxid() (r string, exists bool) {
  17405. v := m.wxid
  17406. if v == nil {
  17407. return
  17408. }
  17409. return *v, true
  17410. }
  17411. // OldWxid returns the old "wxid" field's value of the Message entity.
  17412. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  17413. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17414. func (m *MessageMutation) OldWxid(ctx context.Context) (v string, err error) {
  17415. if !m.op.Is(OpUpdateOne) {
  17416. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  17417. }
  17418. if m.id == nil || m.oldValue == nil {
  17419. return v, errors.New("OldWxid requires an ID field in the mutation")
  17420. }
  17421. oldValue, err := m.oldValue(ctx)
  17422. if err != nil {
  17423. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  17424. }
  17425. return oldValue.Wxid, nil
  17426. }
  17427. // ResetWxid resets all changes to the "wxid" field.
  17428. func (m *MessageMutation) ResetWxid() {
  17429. m.wxid = nil
  17430. }
  17431. // SetContent sets the "content" field.
  17432. func (m *MessageMutation) SetContent(s string) {
  17433. m.content = &s
  17434. }
  17435. // Content returns the value of the "content" field in the mutation.
  17436. func (m *MessageMutation) Content() (r string, exists bool) {
  17437. v := m.content
  17438. if v == nil {
  17439. return
  17440. }
  17441. return *v, true
  17442. }
  17443. // OldContent returns the old "content" field's value of the Message entity.
  17444. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  17445. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17446. func (m *MessageMutation) OldContent(ctx context.Context) (v string, err error) {
  17447. if !m.op.Is(OpUpdateOne) {
  17448. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  17449. }
  17450. if m.id == nil || m.oldValue == nil {
  17451. return v, errors.New("OldContent requires an ID field in the mutation")
  17452. }
  17453. oldValue, err := m.oldValue(ctx)
  17454. if err != nil {
  17455. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  17456. }
  17457. return oldValue.Content, nil
  17458. }
  17459. // ResetContent resets all changes to the "content" field.
  17460. func (m *MessageMutation) ResetContent() {
  17461. m.content = nil
  17462. }
  17463. // Where appends a list predicates to the MessageMutation builder.
  17464. func (m *MessageMutation) Where(ps ...predicate.Message) {
  17465. m.predicates = append(m.predicates, ps...)
  17466. }
  17467. // WhereP appends storage-level predicates to the MessageMutation builder. Using this method,
  17468. // users can use type-assertion to append predicates that do not depend on any generated package.
  17469. func (m *MessageMutation) WhereP(ps ...func(*sql.Selector)) {
  17470. p := make([]predicate.Message, len(ps))
  17471. for i := range ps {
  17472. p[i] = ps[i]
  17473. }
  17474. m.Where(p...)
  17475. }
  17476. // Op returns the operation name.
  17477. func (m *MessageMutation) Op() Op {
  17478. return m.op
  17479. }
  17480. // SetOp allows setting the mutation operation.
  17481. func (m *MessageMutation) SetOp(op Op) {
  17482. m.op = op
  17483. }
  17484. // Type returns the node type of this mutation (Message).
  17485. func (m *MessageMutation) Type() string {
  17486. return m.typ
  17487. }
  17488. // Fields returns all fields that were changed during this mutation. Note that in
  17489. // order to get all numeric fields that were incremented/decremented, call
  17490. // AddedFields().
  17491. func (m *MessageMutation) Fields() []string {
  17492. fields := make([]string, 0, 3)
  17493. if m.wx_wxid != nil {
  17494. fields = append(fields, message.FieldWxWxid)
  17495. }
  17496. if m.wxid != nil {
  17497. fields = append(fields, message.FieldWxid)
  17498. }
  17499. if m.content != nil {
  17500. fields = append(fields, message.FieldContent)
  17501. }
  17502. return fields
  17503. }
  17504. // Field returns the value of a field with the given name. The second boolean
  17505. // return value indicates that this field was not set, or was not defined in the
  17506. // schema.
  17507. func (m *MessageMutation) Field(name string) (ent.Value, bool) {
  17508. switch name {
  17509. case message.FieldWxWxid:
  17510. return m.WxWxid()
  17511. case message.FieldWxid:
  17512. return m.Wxid()
  17513. case message.FieldContent:
  17514. return m.Content()
  17515. }
  17516. return nil, false
  17517. }
  17518. // OldField returns the old value of the field from the database. An error is
  17519. // returned if the mutation operation is not UpdateOne, or the query to the
  17520. // database failed.
  17521. func (m *MessageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  17522. switch name {
  17523. case message.FieldWxWxid:
  17524. return m.OldWxWxid(ctx)
  17525. case message.FieldWxid:
  17526. return m.OldWxid(ctx)
  17527. case message.FieldContent:
  17528. return m.OldContent(ctx)
  17529. }
  17530. return nil, fmt.Errorf("unknown Message field %s", name)
  17531. }
  17532. // SetField sets the value of a field with the given name. It returns an error if
  17533. // the field is not defined in the schema, or if the type mismatched the field
  17534. // type.
  17535. func (m *MessageMutation) SetField(name string, value ent.Value) error {
  17536. switch name {
  17537. case message.FieldWxWxid:
  17538. v, ok := value.(string)
  17539. if !ok {
  17540. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17541. }
  17542. m.SetWxWxid(v)
  17543. return nil
  17544. case message.FieldWxid:
  17545. v, ok := value.(string)
  17546. if !ok {
  17547. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17548. }
  17549. m.SetWxid(v)
  17550. return nil
  17551. case message.FieldContent:
  17552. v, ok := value.(string)
  17553. if !ok {
  17554. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17555. }
  17556. m.SetContent(v)
  17557. return nil
  17558. }
  17559. return fmt.Errorf("unknown Message field %s", name)
  17560. }
  17561. // AddedFields returns all numeric fields that were incremented/decremented during
  17562. // this mutation.
  17563. func (m *MessageMutation) AddedFields() []string {
  17564. return nil
  17565. }
  17566. // AddedField returns the numeric value that was incremented/decremented on a field
  17567. // with the given name. The second boolean return value indicates that this field
  17568. // was not set, or was not defined in the schema.
  17569. func (m *MessageMutation) AddedField(name string) (ent.Value, bool) {
  17570. return nil, false
  17571. }
  17572. // AddField adds the value to the field with the given name. It returns an error if
  17573. // the field is not defined in the schema, or if the type mismatched the field
  17574. // type.
  17575. func (m *MessageMutation) AddField(name string, value ent.Value) error {
  17576. switch name {
  17577. }
  17578. return fmt.Errorf("unknown Message numeric field %s", name)
  17579. }
  17580. // ClearedFields returns all nullable fields that were cleared during this
  17581. // mutation.
  17582. func (m *MessageMutation) ClearedFields() []string {
  17583. var fields []string
  17584. if m.FieldCleared(message.FieldWxWxid) {
  17585. fields = append(fields, message.FieldWxWxid)
  17586. }
  17587. return fields
  17588. }
  17589. // FieldCleared returns a boolean indicating if a field with the given name was
  17590. // cleared in this mutation.
  17591. func (m *MessageMutation) FieldCleared(name string) bool {
  17592. _, ok := m.clearedFields[name]
  17593. return ok
  17594. }
  17595. // ClearField clears the value of the field with the given name. It returns an
  17596. // error if the field is not defined in the schema.
  17597. func (m *MessageMutation) ClearField(name string) error {
  17598. switch name {
  17599. case message.FieldWxWxid:
  17600. m.ClearWxWxid()
  17601. return nil
  17602. }
  17603. return fmt.Errorf("unknown Message nullable field %s", name)
  17604. }
  17605. // ResetField resets all changes in the mutation for the field with the given name.
  17606. // It returns an error if the field is not defined in the schema.
  17607. func (m *MessageMutation) ResetField(name string) error {
  17608. switch name {
  17609. case message.FieldWxWxid:
  17610. m.ResetWxWxid()
  17611. return nil
  17612. case message.FieldWxid:
  17613. m.ResetWxid()
  17614. return nil
  17615. case message.FieldContent:
  17616. m.ResetContent()
  17617. return nil
  17618. }
  17619. return fmt.Errorf("unknown Message field %s", name)
  17620. }
  17621. // AddedEdges returns all edge names that were set/added in this mutation.
  17622. func (m *MessageMutation) AddedEdges() []string {
  17623. edges := make([]string, 0, 0)
  17624. return edges
  17625. }
  17626. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  17627. // name in this mutation.
  17628. func (m *MessageMutation) AddedIDs(name string) []ent.Value {
  17629. return nil
  17630. }
  17631. // RemovedEdges returns all edge names that were removed in this mutation.
  17632. func (m *MessageMutation) RemovedEdges() []string {
  17633. edges := make([]string, 0, 0)
  17634. return edges
  17635. }
  17636. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  17637. // the given name in this mutation.
  17638. func (m *MessageMutation) RemovedIDs(name string) []ent.Value {
  17639. return nil
  17640. }
  17641. // ClearedEdges returns all edge names that were cleared in this mutation.
  17642. func (m *MessageMutation) ClearedEdges() []string {
  17643. edges := make([]string, 0, 0)
  17644. return edges
  17645. }
  17646. // EdgeCleared returns a boolean which indicates if the edge with the given name
  17647. // was cleared in this mutation.
  17648. func (m *MessageMutation) EdgeCleared(name string) bool {
  17649. return false
  17650. }
  17651. // ClearEdge clears the value of the edge with the given name. It returns an error
  17652. // if that edge is not defined in the schema.
  17653. func (m *MessageMutation) ClearEdge(name string) error {
  17654. return fmt.Errorf("unknown Message unique edge %s", name)
  17655. }
  17656. // ResetEdge resets all changes to the edge with the given name in this mutation.
  17657. // It returns an error if the edge is not defined in the schema.
  17658. func (m *MessageMutation) ResetEdge(name string) error {
  17659. return fmt.Errorf("unknown Message edge %s", name)
  17660. }
  17661. // MessageRecordsMutation represents an operation that mutates the MessageRecords nodes in the graph.
  17662. type MessageRecordsMutation struct {
  17663. config
  17664. op Op
  17665. typ string
  17666. id *uint64
  17667. created_at *time.Time
  17668. updated_at *time.Time
  17669. status *uint8
  17670. addstatus *int8
  17671. bot_wxid *string
  17672. contact_type *int
  17673. addcontact_type *int
  17674. contact_wxid *string
  17675. content_type *int
  17676. addcontent_type *int
  17677. content *string
  17678. meta *custom_types.Meta
  17679. error_detail *string
  17680. send_time *time.Time
  17681. source_type *int
  17682. addsource_type *int
  17683. organization_id *uint64
  17684. addorganization_id *int64
  17685. clearedFields map[string]struct{}
  17686. sop_stage *uint64
  17687. clearedsop_stage bool
  17688. sop_node *uint64
  17689. clearedsop_node bool
  17690. message_contact *uint64
  17691. clearedmessage_contact bool
  17692. done bool
  17693. oldValue func(context.Context) (*MessageRecords, error)
  17694. predicates []predicate.MessageRecords
  17695. }
  17696. var _ ent.Mutation = (*MessageRecordsMutation)(nil)
  17697. // messagerecordsOption allows management of the mutation configuration using functional options.
  17698. type messagerecordsOption func(*MessageRecordsMutation)
  17699. // newMessageRecordsMutation creates new mutation for the MessageRecords entity.
  17700. func newMessageRecordsMutation(c config, op Op, opts ...messagerecordsOption) *MessageRecordsMutation {
  17701. m := &MessageRecordsMutation{
  17702. config: c,
  17703. op: op,
  17704. typ: TypeMessageRecords,
  17705. clearedFields: make(map[string]struct{}),
  17706. }
  17707. for _, opt := range opts {
  17708. opt(m)
  17709. }
  17710. return m
  17711. }
  17712. // withMessageRecordsID sets the ID field of the mutation.
  17713. func withMessageRecordsID(id uint64) messagerecordsOption {
  17714. return func(m *MessageRecordsMutation) {
  17715. var (
  17716. err error
  17717. once sync.Once
  17718. value *MessageRecords
  17719. )
  17720. m.oldValue = func(ctx context.Context) (*MessageRecords, error) {
  17721. once.Do(func() {
  17722. if m.done {
  17723. err = errors.New("querying old values post mutation is not allowed")
  17724. } else {
  17725. value, err = m.Client().MessageRecords.Get(ctx, id)
  17726. }
  17727. })
  17728. return value, err
  17729. }
  17730. m.id = &id
  17731. }
  17732. }
  17733. // withMessageRecords sets the old MessageRecords of the mutation.
  17734. func withMessageRecords(node *MessageRecords) messagerecordsOption {
  17735. return func(m *MessageRecordsMutation) {
  17736. m.oldValue = func(context.Context) (*MessageRecords, error) {
  17737. return node, nil
  17738. }
  17739. m.id = &node.ID
  17740. }
  17741. }
  17742. // Client returns a new `ent.Client` from the mutation. If the mutation was
  17743. // executed in a transaction (ent.Tx), a transactional client is returned.
  17744. func (m MessageRecordsMutation) Client() *Client {
  17745. client := &Client{config: m.config}
  17746. client.init()
  17747. return client
  17748. }
  17749. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  17750. // it returns an error otherwise.
  17751. func (m MessageRecordsMutation) Tx() (*Tx, error) {
  17752. if _, ok := m.driver.(*txDriver); !ok {
  17753. return nil, errors.New("ent: mutation is not running in a transaction")
  17754. }
  17755. tx := &Tx{config: m.config}
  17756. tx.init()
  17757. return tx, nil
  17758. }
  17759. // SetID sets the value of the id field. Note that this
  17760. // operation is only accepted on creation of MessageRecords entities.
  17761. func (m *MessageRecordsMutation) SetID(id uint64) {
  17762. m.id = &id
  17763. }
  17764. // ID returns the ID value in the mutation. Note that the ID is only available
  17765. // if it was provided to the builder or after it was returned from the database.
  17766. func (m *MessageRecordsMutation) ID() (id uint64, exists bool) {
  17767. if m.id == nil {
  17768. return
  17769. }
  17770. return *m.id, true
  17771. }
  17772. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  17773. // That means, if the mutation is applied within a transaction with an isolation level such
  17774. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  17775. // or updated by the mutation.
  17776. func (m *MessageRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  17777. switch {
  17778. case m.op.Is(OpUpdateOne | OpDeleteOne):
  17779. id, exists := m.ID()
  17780. if exists {
  17781. return []uint64{id}, nil
  17782. }
  17783. fallthrough
  17784. case m.op.Is(OpUpdate | OpDelete):
  17785. return m.Client().MessageRecords.Query().Where(m.predicates...).IDs(ctx)
  17786. default:
  17787. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  17788. }
  17789. }
  17790. // SetCreatedAt sets the "created_at" field.
  17791. func (m *MessageRecordsMutation) SetCreatedAt(t time.Time) {
  17792. m.created_at = &t
  17793. }
  17794. // CreatedAt returns the value of the "created_at" field in the mutation.
  17795. func (m *MessageRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  17796. v := m.created_at
  17797. if v == nil {
  17798. return
  17799. }
  17800. return *v, true
  17801. }
  17802. // OldCreatedAt returns the old "created_at" field's value of the MessageRecords entity.
  17803. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17804. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17805. func (m *MessageRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  17806. if !m.op.Is(OpUpdateOne) {
  17807. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  17808. }
  17809. if m.id == nil || m.oldValue == nil {
  17810. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  17811. }
  17812. oldValue, err := m.oldValue(ctx)
  17813. if err != nil {
  17814. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  17815. }
  17816. return oldValue.CreatedAt, nil
  17817. }
  17818. // ResetCreatedAt resets all changes to the "created_at" field.
  17819. func (m *MessageRecordsMutation) ResetCreatedAt() {
  17820. m.created_at = nil
  17821. }
  17822. // SetUpdatedAt sets the "updated_at" field.
  17823. func (m *MessageRecordsMutation) SetUpdatedAt(t time.Time) {
  17824. m.updated_at = &t
  17825. }
  17826. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  17827. func (m *MessageRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  17828. v := m.updated_at
  17829. if v == nil {
  17830. return
  17831. }
  17832. return *v, true
  17833. }
  17834. // OldUpdatedAt returns the old "updated_at" field's value of the MessageRecords entity.
  17835. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17836. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17837. func (m *MessageRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  17838. if !m.op.Is(OpUpdateOne) {
  17839. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  17840. }
  17841. if m.id == nil || m.oldValue == nil {
  17842. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  17843. }
  17844. oldValue, err := m.oldValue(ctx)
  17845. if err != nil {
  17846. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  17847. }
  17848. return oldValue.UpdatedAt, nil
  17849. }
  17850. // ResetUpdatedAt resets all changes to the "updated_at" field.
  17851. func (m *MessageRecordsMutation) ResetUpdatedAt() {
  17852. m.updated_at = nil
  17853. }
  17854. // SetStatus sets the "status" field.
  17855. func (m *MessageRecordsMutation) SetStatus(u uint8) {
  17856. m.status = &u
  17857. m.addstatus = nil
  17858. }
  17859. // Status returns the value of the "status" field in the mutation.
  17860. func (m *MessageRecordsMutation) Status() (r uint8, exists bool) {
  17861. v := m.status
  17862. if v == nil {
  17863. return
  17864. }
  17865. return *v, true
  17866. }
  17867. // OldStatus returns the old "status" field's value of the MessageRecords entity.
  17868. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17869. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17870. func (m *MessageRecordsMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  17871. if !m.op.Is(OpUpdateOne) {
  17872. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  17873. }
  17874. if m.id == nil || m.oldValue == nil {
  17875. return v, errors.New("OldStatus requires an ID field in the mutation")
  17876. }
  17877. oldValue, err := m.oldValue(ctx)
  17878. if err != nil {
  17879. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  17880. }
  17881. return oldValue.Status, nil
  17882. }
  17883. // AddStatus adds u to the "status" field.
  17884. func (m *MessageRecordsMutation) AddStatus(u int8) {
  17885. if m.addstatus != nil {
  17886. *m.addstatus += u
  17887. } else {
  17888. m.addstatus = &u
  17889. }
  17890. }
  17891. // AddedStatus returns the value that was added to the "status" field in this mutation.
  17892. func (m *MessageRecordsMutation) AddedStatus() (r int8, exists bool) {
  17893. v := m.addstatus
  17894. if v == nil {
  17895. return
  17896. }
  17897. return *v, true
  17898. }
  17899. // ClearStatus clears the value of the "status" field.
  17900. func (m *MessageRecordsMutation) ClearStatus() {
  17901. m.status = nil
  17902. m.addstatus = nil
  17903. m.clearedFields[messagerecords.FieldStatus] = struct{}{}
  17904. }
  17905. // StatusCleared returns if the "status" field was cleared in this mutation.
  17906. func (m *MessageRecordsMutation) StatusCleared() bool {
  17907. _, ok := m.clearedFields[messagerecords.FieldStatus]
  17908. return ok
  17909. }
  17910. // ResetStatus resets all changes to the "status" field.
  17911. func (m *MessageRecordsMutation) ResetStatus() {
  17912. m.status = nil
  17913. m.addstatus = nil
  17914. delete(m.clearedFields, messagerecords.FieldStatus)
  17915. }
  17916. // SetBotWxid sets the "bot_wxid" field.
  17917. func (m *MessageRecordsMutation) SetBotWxid(s string) {
  17918. m.bot_wxid = &s
  17919. }
  17920. // BotWxid returns the value of the "bot_wxid" field in the mutation.
  17921. func (m *MessageRecordsMutation) BotWxid() (r string, exists bool) {
  17922. v := m.bot_wxid
  17923. if v == nil {
  17924. return
  17925. }
  17926. return *v, true
  17927. }
  17928. // OldBotWxid returns the old "bot_wxid" field's value of the MessageRecords entity.
  17929. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17930. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17931. func (m *MessageRecordsMutation) OldBotWxid(ctx context.Context) (v string, err error) {
  17932. if !m.op.Is(OpUpdateOne) {
  17933. return v, errors.New("OldBotWxid is only allowed on UpdateOne operations")
  17934. }
  17935. if m.id == nil || m.oldValue == nil {
  17936. return v, errors.New("OldBotWxid requires an ID field in the mutation")
  17937. }
  17938. oldValue, err := m.oldValue(ctx)
  17939. if err != nil {
  17940. return v, fmt.Errorf("querying old value for OldBotWxid: %w", err)
  17941. }
  17942. return oldValue.BotWxid, nil
  17943. }
  17944. // ResetBotWxid resets all changes to the "bot_wxid" field.
  17945. func (m *MessageRecordsMutation) ResetBotWxid() {
  17946. m.bot_wxid = nil
  17947. }
  17948. // SetContactID sets the "contact_id" field.
  17949. func (m *MessageRecordsMutation) SetContactID(u uint64) {
  17950. m.message_contact = &u
  17951. }
  17952. // ContactID returns the value of the "contact_id" field in the mutation.
  17953. func (m *MessageRecordsMutation) ContactID() (r uint64, exists bool) {
  17954. v := m.message_contact
  17955. if v == nil {
  17956. return
  17957. }
  17958. return *v, true
  17959. }
  17960. // OldContactID returns the old "contact_id" field's value of the MessageRecords entity.
  17961. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17962. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17963. func (m *MessageRecordsMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  17964. if !m.op.Is(OpUpdateOne) {
  17965. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  17966. }
  17967. if m.id == nil || m.oldValue == nil {
  17968. return v, errors.New("OldContactID requires an ID field in the mutation")
  17969. }
  17970. oldValue, err := m.oldValue(ctx)
  17971. if err != nil {
  17972. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  17973. }
  17974. return oldValue.ContactID, nil
  17975. }
  17976. // ClearContactID clears the value of the "contact_id" field.
  17977. func (m *MessageRecordsMutation) ClearContactID() {
  17978. m.message_contact = nil
  17979. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  17980. }
  17981. // ContactIDCleared returns if the "contact_id" field was cleared in this mutation.
  17982. func (m *MessageRecordsMutation) ContactIDCleared() bool {
  17983. _, ok := m.clearedFields[messagerecords.FieldContactID]
  17984. return ok
  17985. }
  17986. // ResetContactID resets all changes to the "contact_id" field.
  17987. func (m *MessageRecordsMutation) ResetContactID() {
  17988. m.message_contact = nil
  17989. delete(m.clearedFields, messagerecords.FieldContactID)
  17990. }
  17991. // SetContactType sets the "contact_type" field.
  17992. func (m *MessageRecordsMutation) SetContactType(i int) {
  17993. m.contact_type = &i
  17994. m.addcontact_type = nil
  17995. }
  17996. // ContactType returns the value of the "contact_type" field in the mutation.
  17997. func (m *MessageRecordsMutation) ContactType() (r int, exists bool) {
  17998. v := m.contact_type
  17999. if v == nil {
  18000. return
  18001. }
  18002. return *v, true
  18003. }
  18004. // OldContactType returns the old "contact_type" field's value of the MessageRecords entity.
  18005. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  18006. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18007. func (m *MessageRecordsMutation) OldContactType(ctx context.Context) (v int, err error) {
  18008. if !m.op.Is(OpUpdateOne) {
  18009. return v, errors.New("OldContactType is only allowed on UpdateOne operations")
  18010. }
  18011. if m.id == nil || m.oldValue == nil {
  18012. return v, errors.New("OldContactType requires an ID field in the mutation")
  18013. }
  18014. oldValue, err := m.oldValue(ctx)
  18015. if err != nil {
  18016. return v, fmt.Errorf("querying old value for OldContactType: %w", err)
  18017. }
  18018. return oldValue.ContactType, nil
  18019. }
  18020. // AddContactType adds i to the "contact_type" field.
  18021. func (m *MessageRecordsMutation) AddContactType(i int) {
  18022. if m.addcontact_type != nil {
  18023. *m.addcontact_type += i
  18024. } else {
  18025. m.addcontact_type = &i
  18026. }
  18027. }
  18028. // AddedContactType returns the value that was added to the "contact_type" field in this mutation.
  18029. func (m *MessageRecordsMutation) AddedContactType() (r int, exists bool) {
  18030. v := m.addcontact_type
  18031. if v == nil {
  18032. return
  18033. }
  18034. return *v, true
  18035. }
  18036. // ResetContactType resets all changes to the "contact_type" field.
  18037. func (m *MessageRecordsMutation) ResetContactType() {
  18038. m.contact_type = nil
  18039. m.addcontact_type = nil
  18040. }
  18041. // SetContactWxid sets the "contact_wxid" field.
  18042. func (m *MessageRecordsMutation) SetContactWxid(s string) {
  18043. m.contact_wxid = &s
  18044. }
  18045. // ContactWxid returns the value of the "contact_wxid" field in the mutation.
  18046. func (m *MessageRecordsMutation) ContactWxid() (r string, exists bool) {
  18047. v := m.contact_wxid
  18048. if v == nil {
  18049. return
  18050. }
  18051. return *v, true
  18052. }
  18053. // OldContactWxid returns the old "contact_wxid" field's value of the MessageRecords entity.
  18054. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  18055. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18056. func (m *MessageRecordsMutation) OldContactWxid(ctx context.Context) (v string, err error) {
  18057. if !m.op.Is(OpUpdateOne) {
  18058. return v, errors.New("OldContactWxid is only allowed on UpdateOne operations")
  18059. }
  18060. if m.id == nil || m.oldValue == nil {
  18061. return v, errors.New("OldContactWxid requires an ID field in the mutation")
  18062. }
  18063. oldValue, err := m.oldValue(ctx)
  18064. if err != nil {
  18065. return v, fmt.Errorf("querying old value for OldContactWxid: %w", err)
  18066. }
  18067. return oldValue.ContactWxid, nil
  18068. }
  18069. // ResetContactWxid resets all changes to the "contact_wxid" field.
  18070. func (m *MessageRecordsMutation) ResetContactWxid() {
  18071. m.contact_wxid = nil
  18072. }
  18073. // SetContentType sets the "content_type" field.
  18074. func (m *MessageRecordsMutation) SetContentType(i int) {
  18075. m.content_type = &i
  18076. m.addcontent_type = nil
  18077. }
  18078. // ContentType returns the value of the "content_type" field in the mutation.
  18079. func (m *MessageRecordsMutation) ContentType() (r int, exists bool) {
  18080. v := m.content_type
  18081. if v == nil {
  18082. return
  18083. }
  18084. return *v, true
  18085. }
  18086. // OldContentType returns the old "content_type" field's value of the MessageRecords entity.
  18087. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  18088. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18089. func (m *MessageRecordsMutation) OldContentType(ctx context.Context) (v int, err error) {
  18090. if !m.op.Is(OpUpdateOne) {
  18091. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  18092. }
  18093. if m.id == nil || m.oldValue == nil {
  18094. return v, errors.New("OldContentType requires an ID field in the mutation")
  18095. }
  18096. oldValue, err := m.oldValue(ctx)
  18097. if err != nil {
  18098. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  18099. }
  18100. return oldValue.ContentType, nil
  18101. }
  18102. // AddContentType adds i to the "content_type" field.
  18103. func (m *MessageRecordsMutation) AddContentType(i int) {
  18104. if m.addcontent_type != nil {
  18105. *m.addcontent_type += i
  18106. } else {
  18107. m.addcontent_type = &i
  18108. }
  18109. }
  18110. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  18111. func (m *MessageRecordsMutation) AddedContentType() (r int, exists bool) {
  18112. v := m.addcontent_type
  18113. if v == nil {
  18114. return
  18115. }
  18116. return *v, true
  18117. }
  18118. // ResetContentType resets all changes to the "content_type" field.
  18119. func (m *MessageRecordsMutation) ResetContentType() {
  18120. m.content_type = nil
  18121. m.addcontent_type = nil
  18122. }
  18123. // SetContent sets the "content" field.
  18124. func (m *MessageRecordsMutation) SetContent(s string) {
  18125. m.content = &s
  18126. }
  18127. // Content returns the value of the "content" field in the mutation.
  18128. func (m *MessageRecordsMutation) Content() (r string, exists bool) {
  18129. v := m.content
  18130. if v == nil {
  18131. return
  18132. }
  18133. return *v, true
  18134. }
  18135. // OldContent returns the old "content" field's value of the MessageRecords entity.
  18136. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  18137. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18138. func (m *MessageRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  18139. if !m.op.Is(OpUpdateOne) {
  18140. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  18141. }
  18142. if m.id == nil || m.oldValue == nil {
  18143. return v, errors.New("OldContent requires an ID field in the mutation")
  18144. }
  18145. oldValue, err := m.oldValue(ctx)
  18146. if err != nil {
  18147. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  18148. }
  18149. return oldValue.Content, nil
  18150. }
  18151. // ResetContent resets all changes to the "content" field.
  18152. func (m *MessageRecordsMutation) ResetContent() {
  18153. m.content = nil
  18154. }
  18155. // SetMeta sets the "meta" field.
  18156. func (m *MessageRecordsMutation) SetMeta(ct custom_types.Meta) {
  18157. m.meta = &ct
  18158. }
  18159. // Meta returns the value of the "meta" field in the mutation.
  18160. func (m *MessageRecordsMutation) Meta() (r custom_types.Meta, exists bool) {
  18161. v := m.meta
  18162. if v == nil {
  18163. return
  18164. }
  18165. return *v, true
  18166. }
  18167. // OldMeta returns the old "meta" field's value of the MessageRecords entity.
  18168. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  18169. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18170. func (m *MessageRecordsMutation) OldMeta(ctx context.Context) (v custom_types.Meta, err error) {
  18171. if !m.op.Is(OpUpdateOne) {
  18172. return v, errors.New("OldMeta is only allowed on UpdateOne operations")
  18173. }
  18174. if m.id == nil || m.oldValue == nil {
  18175. return v, errors.New("OldMeta requires an ID field in the mutation")
  18176. }
  18177. oldValue, err := m.oldValue(ctx)
  18178. if err != nil {
  18179. return v, fmt.Errorf("querying old value for OldMeta: %w", err)
  18180. }
  18181. return oldValue.Meta, nil
  18182. }
  18183. // ClearMeta clears the value of the "meta" field.
  18184. func (m *MessageRecordsMutation) ClearMeta() {
  18185. m.meta = nil
  18186. m.clearedFields[messagerecords.FieldMeta] = struct{}{}
  18187. }
  18188. // MetaCleared returns if the "meta" field was cleared in this mutation.
  18189. func (m *MessageRecordsMutation) MetaCleared() bool {
  18190. _, ok := m.clearedFields[messagerecords.FieldMeta]
  18191. return ok
  18192. }
  18193. // ResetMeta resets all changes to the "meta" field.
  18194. func (m *MessageRecordsMutation) ResetMeta() {
  18195. m.meta = nil
  18196. delete(m.clearedFields, messagerecords.FieldMeta)
  18197. }
  18198. // SetErrorDetail sets the "error_detail" field.
  18199. func (m *MessageRecordsMutation) SetErrorDetail(s string) {
  18200. m.error_detail = &s
  18201. }
  18202. // ErrorDetail returns the value of the "error_detail" field in the mutation.
  18203. func (m *MessageRecordsMutation) ErrorDetail() (r string, exists bool) {
  18204. v := m.error_detail
  18205. if v == nil {
  18206. return
  18207. }
  18208. return *v, true
  18209. }
  18210. // OldErrorDetail returns the old "error_detail" field's value of the MessageRecords entity.
  18211. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  18212. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18213. func (m *MessageRecordsMutation) OldErrorDetail(ctx context.Context) (v string, err error) {
  18214. if !m.op.Is(OpUpdateOne) {
  18215. return v, errors.New("OldErrorDetail is only allowed on UpdateOne operations")
  18216. }
  18217. if m.id == nil || m.oldValue == nil {
  18218. return v, errors.New("OldErrorDetail requires an ID field in the mutation")
  18219. }
  18220. oldValue, err := m.oldValue(ctx)
  18221. if err != nil {
  18222. return v, fmt.Errorf("querying old value for OldErrorDetail: %w", err)
  18223. }
  18224. return oldValue.ErrorDetail, nil
  18225. }
  18226. // ResetErrorDetail resets all changes to the "error_detail" field.
  18227. func (m *MessageRecordsMutation) ResetErrorDetail() {
  18228. m.error_detail = nil
  18229. }
  18230. // SetSendTime sets the "send_time" field.
  18231. func (m *MessageRecordsMutation) SetSendTime(t time.Time) {
  18232. m.send_time = &t
  18233. }
  18234. // SendTime returns the value of the "send_time" field in the mutation.
  18235. func (m *MessageRecordsMutation) SendTime() (r time.Time, exists bool) {
  18236. v := m.send_time
  18237. if v == nil {
  18238. return
  18239. }
  18240. return *v, true
  18241. }
  18242. // OldSendTime returns the old "send_time" field's value of the MessageRecords entity.
  18243. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  18244. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18245. func (m *MessageRecordsMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  18246. if !m.op.Is(OpUpdateOne) {
  18247. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  18248. }
  18249. if m.id == nil || m.oldValue == nil {
  18250. return v, errors.New("OldSendTime requires an ID field in the mutation")
  18251. }
  18252. oldValue, err := m.oldValue(ctx)
  18253. if err != nil {
  18254. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  18255. }
  18256. return oldValue.SendTime, nil
  18257. }
  18258. // ClearSendTime clears the value of the "send_time" field.
  18259. func (m *MessageRecordsMutation) ClearSendTime() {
  18260. m.send_time = nil
  18261. m.clearedFields[messagerecords.FieldSendTime] = struct{}{}
  18262. }
  18263. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  18264. func (m *MessageRecordsMutation) SendTimeCleared() bool {
  18265. _, ok := m.clearedFields[messagerecords.FieldSendTime]
  18266. return ok
  18267. }
  18268. // ResetSendTime resets all changes to the "send_time" field.
  18269. func (m *MessageRecordsMutation) ResetSendTime() {
  18270. m.send_time = nil
  18271. delete(m.clearedFields, messagerecords.FieldSendTime)
  18272. }
  18273. // SetSourceType sets the "source_type" field.
  18274. func (m *MessageRecordsMutation) SetSourceType(i int) {
  18275. m.source_type = &i
  18276. m.addsource_type = nil
  18277. }
  18278. // SourceType returns the value of the "source_type" field in the mutation.
  18279. func (m *MessageRecordsMutation) SourceType() (r int, exists bool) {
  18280. v := m.source_type
  18281. if v == nil {
  18282. return
  18283. }
  18284. return *v, true
  18285. }
  18286. // OldSourceType returns the old "source_type" field's value of the MessageRecords entity.
  18287. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  18288. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18289. func (m *MessageRecordsMutation) OldSourceType(ctx context.Context) (v int, err error) {
  18290. if !m.op.Is(OpUpdateOne) {
  18291. return v, errors.New("OldSourceType is only allowed on UpdateOne operations")
  18292. }
  18293. if m.id == nil || m.oldValue == nil {
  18294. return v, errors.New("OldSourceType requires an ID field in the mutation")
  18295. }
  18296. oldValue, err := m.oldValue(ctx)
  18297. if err != nil {
  18298. return v, fmt.Errorf("querying old value for OldSourceType: %w", err)
  18299. }
  18300. return oldValue.SourceType, nil
  18301. }
  18302. // AddSourceType adds i to the "source_type" field.
  18303. func (m *MessageRecordsMutation) AddSourceType(i int) {
  18304. if m.addsource_type != nil {
  18305. *m.addsource_type += i
  18306. } else {
  18307. m.addsource_type = &i
  18308. }
  18309. }
  18310. // AddedSourceType returns the value that was added to the "source_type" field in this mutation.
  18311. func (m *MessageRecordsMutation) AddedSourceType() (r int, exists bool) {
  18312. v := m.addsource_type
  18313. if v == nil {
  18314. return
  18315. }
  18316. return *v, true
  18317. }
  18318. // ResetSourceType resets all changes to the "source_type" field.
  18319. func (m *MessageRecordsMutation) ResetSourceType() {
  18320. m.source_type = nil
  18321. m.addsource_type = nil
  18322. }
  18323. // SetSourceID sets the "source_id" field.
  18324. func (m *MessageRecordsMutation) SetSourceID(u uint64) {
  18325. m.sop_stage = &u
  18326. }
  18327. // SourceID returns the value of the "source_id" field in the mutation.
  18328. func (m *MessageRecordsMutation) SourceID() (r uint64, exists bool) {
  18329. v := m.sop_stage
  18330. if v == nil {
  18331. return
  18332. }
  18333. return *v, true
  18334. }
  18335. // OldSourceID returns the old "source_id" field's value of the MessageRecords entity.
  18336. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  18337. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18338. func (m *MessageRecordsMutation) OldSourceID(ctx context.Context) (v uint64, err error) {
  18339. if !m.op.Is(OpUpdateOne) {
  18340. return v, errors.New("OldSourceID is only allowed on UpdateOne operations")
  18341. }
  18342. if m.id == nil || m.oldValue == nil {
  18343. return v, errors.New("OldSourceID requires an ID field in the mutation")
  18344. }
  18345. oldValue, err := m.oldValue(ctx)
  18346. if err != nil {
  18347. return v, fmt.Errorf("querying old value for OldSourceID: %w", err)
  18348. }
  18349. return oldValue.SourceID, nil
  18350. }
  18351. // ClearSourceID clears the value of the "source_id" field.
  18352. func (m *MessageRecordsMutation) ClearSourceID() {
  18353. m.sop_stage = nil
  18354. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  18355. }
  18356. // SourceIDCleared returns if the "source_id" field was cleared in this mutation.
  18357. func (m *MessageRecordsMutation) SourceIDCleared() bool {
  18358. _, ok := m.clearedFields[messagerecords.FieldSourceID]
  18359. return ok
  18360. }
  18361. // ResetSourceID resets all changes to the "source_id" field.
  18362. func (m *MessageRecordsMutation) ResetSourceID() {
  18363. m.sop_stage = nil
  18364. delete(m.clearedFields, messagerecords.FieldSourceID)
  18365. }
  18366. // SetSubSourceID sets the "sub_source_id" field.
  18367. func (m *MessageRecordsMutation) SetSubSourceID(u uint64) {
  18368. m.sop_node = &u
  18369. }
  18370. // SubSourceID returns the value of the "sub_source_id" field in the mutation.
  18371. func (m *MessageRecordsMutation) SubSourceID() (r uint64, exists bool) {
  18372. v := m.sop_node
  18373. if v == nil {
  18374. return
  18375. }
  18376. return *v, true
  18377. }
  18378. // OldSubSourceID returns the old "sub_source_id" field's value of the MessageRecords entity.
  18379. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  18380. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18381. func (m *MessageRecordsMutation) OldSubSourceID(ctx context.Context) (v uint64, err error) {
  18382. if !m.op.Is(OpUpdateOne) {
  18383. return v, errors.New("OldSubSourceID is only allowed on UpdateOne operations")
  18384. }
  18385. if m.id == nil || m.oldValue == nil {
  18386. return v, errors.New("OldSubSourceID requires an ID field in the mutation")
  18387. }
  18388. oldValue, err := m.oldValue(ctx)
  18389. if err != nil {
  18390. return v, fmt.Errorf("querying old value for OldSubSourceID: %w", err)
  18391. }
  18392. return oldValue.SubSourceID, nil
  18393. }
  18394. // ClearSubSourceID clears the value of the "sub_source_id" field.
  18395. func (m *MessageRecordsMutation) ClearSubSourceID() {
  18396. m.sop_node = nil
  18397. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  18398. }
  18399. // SubSourceIDCleared returns if the "sub_source_id" field was cleared in this mutation.
  18400. func (m *MessageRecordsMutation) SubSourceIDCleared() bool {
  18401. _, ok := m.clearedFields[messagerecords.FieldSubSourceID]
  18402. return ok
  18403. }
  18404. // ResetSubSourceID resets all changes to the "sub_source_id" field.
  18405. func (m *MessageRecordsMutation) ResetSubSourceID() {
  18406. m.sop_node = nil
  18407. delete(m.clearedFields, messagerecords.FieldSubSourceID)
  18408. }
  18409. // SetOrganizationID sets the "organization_id" field.
  18410. func (m *MessageRecordsMutation) SetOrganizationID(u uint64) {
  18411. m.organization_id = &u
  18412. m.addorganization_id = nil
  18413. }
  18414. // OrganizationID returns the value of the "organization_id" field in the mutation.
  18415. func (m *MessageRecordsMutation) OrganizationID() (r uint64, exists bool) {
  18416. v := m.organization_id
  18417. if v == nil {
  18418. return
  18419. }
  18420. return *v, true
  18421. }
  18422. // OldOrganizationID returns the old "organization_id" field's value of the MessageRecords entity.
  18423. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  18424. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18425. func (m *MessageRecordsMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  18426. if !m.op.Is(OpUpdateOne) {
  18427. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  18428. }
  18429. if m.id == nil || m.oldValue == nil {
  18430. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  18431. }
  18432. oldValue, err := m.oldValue(ctx)
  18433. if err != nil {
  18434. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  18435. }
  18436. return oldValue.OrganizationID, nil
  18437. }
  18438. // AddOrganizationID adds u to the "organization_id" field.
  18439. func (m *MessageRecordsMutation) AddOrganizationID(u int64) {
  18440. if m.addorganization_id != nil {
  18441. *m.addorganization_id += u
  18442. } else {
  18443. m.addorganization_id = &u
  18444. }
  18445. }
  18446. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  18447. func (m *MessageRecordsMutation) AddedOrganizationID() (r int64, exists bool) {
  18448. v := m.addorganization_id
  18449. if v == nil {
  18450. return
  18451. }
  18452. return *v, true
  18453. }
  18454. // ClearOrganizationID clears the value of the "organization_id" field.
  18455. func (m *MessageRecordsMutation) ClearOrganizationID() {
  18456. m.organization_id = nil
  18457. m.addorganization_id = nil
  18458. m.clearedFields[messagerecords.FieldOrganizationID] = struct{}{}
  18459. }
  18460. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  18461. func (m *MessageRecordsMutation) OrganizationIDCleared() bool {
  18462. _, ok := m.clearedFields[messagerecords.FieldOrganizationID]
  18463. return ok
  18464. }
  18465. // ResetOrganizationID resets all changes to the "organization_id" field.
  18466. func (m *MessageRecordsMutation) ResetOrganizationID() {
  18467. m.organization_id = nil
  18468. m.addorganization_id = nil
  18469. delete(m.clearedFields, messagerecords.FieldOrganizationID)
  18470. }
  18471. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  18472. func (m *MessageRecordsMutation) SetSopStageID(id uint64) {
  18473. m.sop_stage = &id
  18474. }
  18475. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  18476. func (m *MessageRecordsMutation) ClearSopStage() {
  18477. m.clearedsop_stage = true
  18478. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  18479. }
  18480. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  18481. func (m *MessageRecordsMutation) SopStageCleared() bool {
  18482. return m.SourceIDCleared() || m.clearedsop_stage
  18483. }
  18484. // SopStageID returns the "sop_stage" edge ID in the mutation.
  18485. func (m *MessageRecordsMutation) SopStageID() (id uint64, exists bool) {
  18486. if m.sop_stage != nil {
  18487. return *m.sop_stage, true
  18488. }
  18489. return
  18490. }
  18491. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  18492. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  18493. // SopStageID instead. It exists only for internal usage by the builders.
  18494. func (m *MessageRecordsMutation) SopStageIDs() (ids []uint64) {
  18495. if id := m.sop_stage; id != nil {
  18496. ids = append(ids, *id)
  18497. }
  18498. return
  18499. }
  18500. // ResetSopStage resets all changes to the "sop_stage" edge.
  18501. func (m *MessageRecordsMutation) ResetSopStage() {
  18502. m.sop_stage = nil
  18503. m.clearedsop_stage = false
  18504. }
  18505. // SetSopNodeID sets the "sop_node" edge to the SopNode entity by id.
  18506. func (m *MessageRecordsMutation) SetSopNodeID(id uint64) {
  18507. m.sop_node = &id
  18508. }
  18509. // ClearSopNode clears the "sop_node" edge to the SopNode entity.
  18510. func (m *MessageRecordsMutation) ClearSopNode() {
  18511. m.clearedsop_node = true
  18512. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  18513. }
  18514. // SopNodeCleared reports if the "sop_node" edge to the SopNode entity was cleared.
  18515. func (m *MessageRecordsMutation) SopNodeCleared() bool {
  18516. return m.SubSourceIDCleared() || m.clearedsop_node
  18517. }
  18518. // SopNodeID returns the "sop_node" edge ID in the mutation.
  18519. func (m *MessageRecordsMutation) SopNodeID() (id uint64, exists bool) {
  18520. if m.sop_node != nil {
  18521. return *m.sop_node, true
  18522. }
  18523. return
  18524. }
  18525. // SopNodeIDs returns the "sop_node" edge IDs in the mutation.
  18526. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  18527. // SopNodeID instead. It exists only for internal usage by the builders.
  18528. func (m *MessageRecordsMutation) SopNodeIDs() (ids []uint64) {
  18529. if id := m.sop_node; id != nil {
  18530. ids = append(ids, *id)
  18531. }
  18532. return
  18533. }
  18534. // ResetSopNode resets all changes to the "sop_node" edge.
  18535. func (m *MessageRecordsMutation) ResetSopNode() {
  18536. m.sop_node = nil
  18537. m.clearedsop_node = false
  18538. }
  18539. // SetMessageContactID sets the "message_contact" edge to the Contact entity by id.
  18540. func (m *MessageRecordsMutation) SetMessageContactID(id uint64) {
  18541. m.message_contact = &id
  18542. }
  18543. // ClearMessageContact clears the "message_contact" edge to the Contact entity.
  18544. func (m *MessageRecordsMutation) ClearMessageContact() {
  18545. m.clearedmessage_contact = true
  18546. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  18547. }
  18548. // MessageContactCleared reports if the "message_contact" edge to the Contact entity was cleared.
  18549. func (m *MessageRecordsMutation) MessageContactCleared() bool {
  18550. return m.ContactIDCleared() || m.clearedmessage_contact
  18551. }
  18552. // MessageContactID returns the "message_contact" edge ID in the mutation.
  18553. func (m *MessageRecordsMutation) MessageContactID() (id uint64, exists bool) {
  18554. if m.message_contact != nil {
  18555. return *m.message_contact, true
  18556. }
  18557. return
  18558. }
  18559. // MessageContactIDs returns the "message_contact" edge IDs in the mutation.
  18560. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  18561. // MessageContactID instead. It exists only for internal usage by the builders.
  18562. func (m *MessageRecordsMutation) MessageContactIDs() (ids []uint64) {
  18563. if id := m.message_contact; id != nil {
  18564. ids = append(ids, *id)
  18565. }
  18566. return
  18567. }
  18568. // ResetMessageContact resets all changes to the "message_contact" edge.
  18569. func (m *MessageRecordsMutation) ResetMessageContact() {
  18570. m.message_contact = nil
  18571. m.clearedmessage_contact = false
  18572. }
  18573. // Where appends a list predicates to the MessageRecordsMutation builder.
  18574. func (m *MessageRecordsMutation) Where(ps ...predicate.MessageRecords) {
  18575. m.predicates = append(m.predicates, ps...)
  18576. }
  18577. // WhereP appends storage-level predicates to the MessageRecordsMutation builder. Using this method,
  18578. // users can use type-assertion to append predicates that do not depend on any generated package.
  18579. func (m *MessageRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  18580. p := make([]predicate.MessageRecords, len(ps))
  18581. for i := range ps {
  18582. p[i] = ps[i]
  18583. }
  18584. m.Where(p...)
  18585. }
  18586. // Op returns the operation name.
  18587. func (m *MessageRecordsMutation) Op() Op {
  18588. return m.op
  18589. }
  18590. // SetOp allows setting the mutation operation.
  18591. func (m *MessageRecordsMutation) SetOp(op Op) {
  18592. m.op = op
  18593. }
  18594. // Type returns the node type of this mutation (MessageRecords).
  18595. func (m *MessageRecordsMutation) Type() string {
  18596. return m.typ
  18597. }
  18598. // Fields returns all fields that were changed during this mutation. Note that in
  18599. // order to get all numeric fields that were incremented/decremented, call
  18600. // AddedFields().
  18601. func (m *MessageRecordsMutation) Fields() []string {
  18602. fields := make([]string, 0, 16)
  18603. if m.created_at != nil {
  18604. fields = append(fields, messagerecords.FieldCreatedAt)
  18605. }
  18606. if m.updated_at != nil {
  18607. fields = append(fields, messagerecords.FieldUpdatedAt)
  18608. }
  18609. if m.status != nil {
  18610. fields = append(fields, messagerecords.FieldStatus)
  18611. }
  18612. if m.bot_wxid != nil {
  18613. fields = append(fields, messagerecords.FieldBotWxid)
  18614. }
  18615. if m.message_contact != nil {
  18616. fields = append(fields, messagerecords.FieldContactID)
  18617. }
  18618. if m.contact_type != nil {
  18619. fields = append(fields, messagerecords.FieldContactType)
  18620. }
  18621. if m.contact_wxid != nil {
  18622. fields = append(fields, messagerecords.FieldContactWxid)
  18623. }
  18624. if m.content_type != nil {
  18625. fields = append(fields, messagerecords.FieldContentType)
  18626. }
  18627. if m.content != nil {
  18628. fields = append(fields, messagerecords.FieldContent)
  18629. }
  18630. if m.meta != nil {
  18631. fields = append(fields, messagerecords.FieldMeta)
  18632. }
  18633. if m.error_detail != nil {
  18634. fields = append(fields, messagerecords.FieldErrorDetail)
  18635. }
  18636. if m.send_time != nil {
  18637. fields = append(fields, messagerecords.FieldSendTime)
  18638. }
  18639. if m.source_type != nil {
  18640. fields = append(fields, messagerecords.FieldSourceType)
  18641. }
  18642. if m.sop_stage != nil {
  18643. fields = append(fields, messagerecords.FieldSourceID)
  18644. }
  18645. if m.sop_node != nil {
  18646. fields = append(fields, messagerecords.FieldSubSourceID)
  18647. }
  18648. if m.organization_id != nil {
  18649. fields = append(fields, messagerecords.FieldOrganizationID)
  18650. }
  18651. return fields
  18652. }
  18653. // Field returns the value of a field with the given name. The second boolean
  18654. // return value indicates that this field was not set, or was not defined in the
  18655. // schema.
  18656. func (m *MessageRecordsMutation) Field(name string) (ent.Value, bool) {
  18657. switch name {
  18658. case messagerecords.FieldCreatedAt:
  18659. return m.CreatedAt()
  18660. case messagerecords.FieldUpdatedAt:
  18661. return m.UpdatedAt()
  18662. case messagerecords.FieldStatus:
  18663. return m.Status()
  18664. case messagerecords.FieldBotWxid:
  18665. return m.BotWxid()
  18666. case messagerecords.FieldContactID:
  18667. return m.ContactID()
  18668. case messagerecords.FieldContactType:
  18669. return m.ContactType()
  18670. case messagerecords.FieldContactWxid:
  18671. return m.ContactWxid()
  18672. case messagerecords.FieldContentType:
  18673. return m.ContentType()
  18674. case messagerecords.FieldContent:
  18675. return m.Content()
  18676. case messagerecords.FieldMeta:
  18677. return m.Meta()
  18678. case messagerecords.FieldErrorDetail:
  18679. return m.ErrorDetail()
  18680. case messagerecords.FieldSendTime:
  18681. return m.SendTime()
  18682. case messagerecords.FieldSourceType:
  18683. return m.SourceType()
  18684. case messagerecords.FieldSourceID:
  18685. return m.SourceID()
  18686. case messagerecords.FieldSubSourceID:
  18687. return m.SubSourceID()
  18688. case messagerecords.FieldOrganizationID:
  18689. return m.OrganizationID()
  18690. }
  18691. return nil, false
  18692. }
  18693. // OldField returns the old value of the field from the database. An error is
  18694. // returned if the mutation operation is not UpdateOne, or the query to the
  18695. // database failed.
  18696. func (m *MessageRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  18697. switch name {
  18698. case messagerecords.FieldCreatedAt:
  18699. return m.OldCreatedAt(ctx)
  18700. case messagerecords.FieldUpdatedAt:
  18701. return m.OldUpdatedAt(ctx)
  18702. case messagerecords.FieldStatus:
  18703. return m.OldStatus(ctx)
  18704. case messagerecords.FieldBotWxid:
  18705. return m.OldBotWxid(ctx)
  18706. case messagerecords.FieldContactID:
  18707. return m.OldContactID(ctx)
  18708. case messagerecords.FieldContactType:
  18709. return m.OldContactType(ctx)
  18710. case messagerecords.FieldContactWxid:
  18711. return m.OldContactWxid(ctx)
  18712. case messagerecords.FieldContentType:
  18713. return m.OldContentType(ctx)
  18714. case messagerecords.FieldContent:
  18715. return m.OldContent(ctx)
  18716. case messagerecords.FieldMeta:
  18717. return m.OldMeta(ctx)
  18718. case messagerecords.FieldErrorDetail:
  18719. return m.OldErrorDetail(ctx)
  18720. case messagerecords.FieldSendTime:
  18721. return m.OldSendTime(ctx)
  18722. case messagerecords.FieldSourceType:
  18723. return m.OldSourceType(ctx)
  18724. case messagerecords.FieldSourceID:
  18725. return m.OldSourceID(ctx)
  18726. case messagerecords.FieldSubSourceID:
  18727. return m.OldSubSourceID(ctx)
  18728. case messagerecords.FieldOrganizationID:
  18729. return m.OldOrganizationID(ctx)
  18730. }
  18731. return nil, fmt.Errorf("unknown MessageRecords field %s", name)
  18732. }
  18733. // SetField sets the value of a field with the given name. It returns an error if
  18734. // the field is not defined in the schema, or if the type mismatched the field
  18735. // type.
  18736. func (m *MessageRecordsMutation) SetField(name string, value ent.Value) error {
  18737. switch name {
  18738. case messagerecords.FieldCreatedAt:
  18739. v, ok := value.(time.Time)
  18740. if !ok {
  18741. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18742. }
  18743. m.SetCreatedAt(v)
  18744. return nil
  18745. case messagerecords.FieldUpdatedAt:
  18746. v, ok := value.(time.Time)
  18747. if !ok {
  18748. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18749. }
  18750. m.SetUpdatedAt(v)
  18751. return nil
  18752. case messagerecords.FieldStatus:
  18753. v, ok := value.(uint8)
  18754. if !ok {
  18755. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18756. }
  18757. m.SetStatus(v)
  18758. return nil
  18759. case messagerecords.FieldBotWxid:
  18760. v, ok := value.(string)
  18761. if !ok {
  18762. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18763. }
  18764. m.SetBotWxid(v)
  18765. return nil
  18766. case messagerecords.FieldContactID:
  18767. v, ok := value.(uint64)
  18768. if !ok {
  18769. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18770. }
  18771. m.SetContactID(v)
  18772. return nil
  18773. case messagerecords.FieldContactType:
  18774. v, ok := value.(int)
  18775. if !ok {
  18776. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18777. }
  18778. m.SetContactType(v)
  18779. return nil
  18780. case messagerecords.FieldContactWxid:
  18781. v, ok := value.(string)
  18782. if !ok {
  18783. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18784. }
  18785. m.SetContactWxid(v)
  18786. return nil
  18787. case messagerecords.FieldContentType:
  18788. v, ok := value.(int)
  18789. if !ok {
  18790. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18791. }
  18792. m.SetContentType(v)
  18793. return nil
  18794. case messagerecords.FieldContent:
  18795. v, ok := value.(string)
  18796. if !ok {
  18797. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18798. }
  18799. m.SetContent(v)
  18800. return nil
  18801. case messagerecords.FieldMeta:
  18802. v, ok := value.(custom_types.Meta)
  18803. if !ok {
  18804. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18805. }
  18806. m.SetMeta(v)
  18807. return nil
  18808. case messagerecords.FieldErrorDetail:
  18809. v, ok := value.(string)
  18810. if !ok {
  18811. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18812. }
  18813. m.SetErrorDetail(v)
  18814. return nil
  18815. case messagerecords.FieldSendTime:
  18816. v, ok := value.(time.Time)
  18817. if !ok {
  18818. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18819. }
  18820. m.SetSendTime(v)
  18821. return nil
  18822. case messagerecords.FieldSourceType:
  18823. v, ok := value.(int)
  18824. if !ok {
  18825. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18826. }
  18827. m.SetSourceType(v)
  18828. return nil
  18829. case messagerecords.FieldSourceID:
  18830. v, ok := value.(uint64)
  18831. if !ok {
  18832. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18833. }
  18834. m.SetSourceID(v)
  18835. return nil
  18836. case messagerecords.FieldSubSourceID:
  18837. v, ok := value.(uint64)
  18838. if !ok {
  18839. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18840. }
  18841. m.SetSubSourceID(v)
  18842. return nil
  18843. case messagerecords.FieldOrganizationID:
  18844. v, ok := value.(uint64)
  18845. if !ok {
  18846. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18847. }
  18848. m.SetOrganizationID(v)
  18849. return nil
  18850. }
  18851. return fmt.Errorf("unknown MessageRecords field %s", name)
  18852. }
  18853. // AddedFields returns all numeric fields that were incremented/decremented during
  18854. // this mutation.
  18855. func (m *MessageRecordsMutation) AddedFields() []string {
  18856. var fields []string
  18857. if m.addstatus != nil {
  18858. fields = append(fields, messagerecords.FieldStatus)
  18859. }
  18860. if m.addcontact_type != nil {
  18861. fields = append(fields, messagerecords.FieldContactType)
  18862. }
  18863. if m.addcontent_type != nil {
  18864. fields = append(fields, messagerecords.FieldContentType)
  18865. }
  18866. if m.addsource_type != nil {
  18867. fields = append(fields, messagerecords.FieldSourceType)
  18868. }
  18869. if m.addorganization_id != nil {
  18870. fields = append(fields, messagerecords.FieldOrganizationID)
  18871. }
  18872. return fields
  18873. }
  18874. // AddedField returns the numeric value that was incremented/decremented on a field
  18875. // with the given name. The second boolean return value indicates that this field
  18876. // was not set, or was not defined in the schema.
  18877. func (m *MessageRecordsMutation) AddedField(name string) (ent.Value, bool) {
  18878. switch name {
  18879. case messagerecords.FieldStatus:
  18880. return m.AddedStatus()
  18881. case messagerecords.FieldContactType:
  18882. return m.AddedContactType()
  18883. case messagerecords.FieldContentType:
  18884. return m.AddedContentType()
  18885. case messagerecords.FieldSourceType:
  18886. return m.AddedSourceType()
  18887. case messagerecords.FieldOrganizationID:
  18888. return m.AddedOrganizationID()
  18889. }
  18890. return nil, false
  18891. }
  18892. // AddField adds the value to the field with the given name. It returns an error if
  18893. // the field is not defined in the schema, or if the type mismatched the field
  18894. // type.
  18895. func (m *MessageRecordsMutation) AddField(name string, value ent.Value) error {
  18896. switch name {
  18897. case messagerecords.FieldStatus:
  18898. v, ok := value.(int8)
  18899. if !ok {
  18900. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18901. }
  18902. m.AddStatus(v)
  18903. return nil
  18904. case messagerecords.FieldContactType:
  18905. v, ok := value.(int)
  18906. if !ok {
  18907. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18908. }
  18909. m.AddContactType(v)
  18910. return nil
  18911. case messagerecords.FieldContentType:
  18912. v, ok := value.(int)
  18913. if !ok {
  18914. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18915. }
  18916. m.AddContentType(v)
  18917. return nil
  18918. case messagerecords.FieldSourceType:
  18919. v, ok := value.(int)
  18920. if !ok {
  18921. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18922. }
  18923. m.AddSourceType(v)
  18924. return nil
  18925. case messagerecords.FieldOrganizationID:
  18926. v, ok := value.(int64)
  18927. if !ok {
  18928. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18929. }
  18930. m.AddOrganizationID(v)
  18931. return nil
  18932. }
  18933. return fmt.Errorf("unknown MessageRecords numeric field %s", name)
  18934. }
  18935. // ClearedFields returns all nullable fields that were cleared during this
  18936. // mutation.
  18937. func (m *MessageRecordsMutation) ClearedFields() []string {
  18938. var fields []string
  18939. if m.FieldCleared(messagerecords.FieldStatus) {
  18940. fields = append(fields, messagerecords.FieldStatus)
  18941. }
  18942. if m.FieldCleared(messagerecords.FieldContactID) {
  18943. fields = append(fields, messagerecords.FieldContactID)
  18944. }
  18945. if m.FieldCleared(messagerecords.FieldMeta) {
  18946. fields = append(fields, messagerecords.FieldMeta)
  18947. }
  18948. if m.FieldCleared(messagerecords.FieldSendTime) {
  18949. fields = append(fields, messagerecords.FieldSendTime)
  18950. }
  18951. if m.FieldCleared(messagerecords.FieldSourceID) {
  18952. fields = append(fields, messagerecords.FieldSourceID)
  18953. }
  18954. if m.FieldCleared(messagerecords.FieldSubSourceID) {
  18955. fields = append(fields, messagerecords.FieldSubSourceID)
  18956. }
  18957. if m.FieldCleared(messagerecords.FieldOrganizationID) {
  18958. fields = append(fields, messagerecords.FieldOrganizationID)
  18959. }
  18960. return fields
  18961. }
  18962. // FieldCleared returns a boolean indicating if a field with the given name was
  18963. // cleared in this mutation.
  18964. func (m *MessageRecordsMutation) FieldCleared(name string) bool {
  18965. _, ok := m.clearedFields[name]
  18966. return ok
  18967. }
  18968. // ClearField clears the value of the field with the given name. It returns an
  18969. // error if the field is not defined in the schema.
  18970. func (m *MessageRecordsMutation) ClearField(name string) error {
  18971. switch name {
  18972. case messagerecords.FieldStatus:
  18973. m.ClearStatus()
  18974. return nil
  18975. case messagerecords.FieldContactID:
  18976. m.ClearContactID()
  18977. return nil
  18978. case messagerecords.FieldMeta:
  18979. m.ClearMeta()
  18980. return nil
  18981. case messagerecords.FieldSendTime:
  18982. m.ClearSendTime()
  18983. return nil
  18984. case messagerecords.FieldSourceID:
  18985. m.ClearSourceID()
  18986. return nil
  18987. case messagerecords.FieldSubSourceID:
  18988. m.ClearSubSourceID()
  18989. return nil
  18990. case messagerecords.FieldOrganizationID:
  18991. m.ClearOrganizationID()
  18992. return nil
  18993. }
  18994. return fmt.Errorf("unknown MessageRecords nullable field %s", name)
  18995. }
  18996. // ResetField resets all changes in the mutation for the field with the given name.
  18997. // It returns an error if the field is not defined in the schema.
  18998. func (m *MessageRecordsMutation) ResetField(name string) error {
  18999. switch name {
  19000. case messagerecords.FieldCreatedAt:
  19001. m.ResetCreatedAt()
  19002. return nil
  19003. case messagerecords.FieldUpdatedAt:
  19004. m.ResetUpdatedAt()
  19005. return nil
  19006. case messagerecords.FieldStatus:
  19007. m.ResetStatus()
  19008. return nil
  19009. case messagerecords.FieldBotWxid:
  19010. m.ResetBotWxid()
  19011. return nil
  19012. case messagerecords.FieldContactID:
  19013. m.ResetContactID()
  19014. return nil
  19015. case messagerecords.FieldContactType:
  19016. m.ResetContactType()
  19017. return nil
  19018. case messagerecords.FieldContactWxid:
  19019. m.ResetContactWxid()
  19020. return nil
  19021. case messagerecords.FieldContentType:
  19022. m.ResetContentType()
  19023. return nil
  19024. case messagerecords.FieldContent:
  19025. m.ResetContent()
  19026. return nil
  19027. case messagerecords.FieldMeta:
  19028. m.ResetMeta()
  19029. return nil
  19030. case messagerecords.FieldErrorDetail:
  19031. m.ResetErrorDetail()
  19032. return nil
  19033. case messagerecords.FieldSendTime:
  19034. m.ResetSendTime()
  19035. return nil
  19036. case messagerecords.FieldSourceType:
  19037. m.ResetSourceType()
  19038. return nil
  19039. case messagerecords.FieldSourceID:
  19040. m.ResetSourceID()
  19041. return nil
  19042. case messagerecords.FieldSubSourceID:
  19043. m.ResetSubSourceID()
  19044. return nil
  19045. case messagerecords.FieldOrganizationID:
  19046. m.ResetOrganizationID()
  19047. return nil
  19048. }
  19049. return fmt.Errorf("unknown MessageRecords field %s", name)
  19050. }
  19051. // AddedEdges returns all edge names that were set/added in this mutation.
  19052. func (m *MessageRecordsMutation) AddedEdges() []string {
  19053. edges := make([]string, 0, 3)
  19054. if m.sop_stage != nil {
  19055. edges = append(edges, messagerecords.EdgeSopStage)
  19056. }
  19057. if m.sop_node != nil {
  19058. edges = append(edges, messagerecords.EdgeSopNode)
  19059. }
  19060. if m.message_contact != nil {
  19061. edges = append(edges, messagerecords.EdgeMessageContact)
  19062. }
  19063. return edges
  19064. }
  19065. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  19066. // name in this mutation.
  19067. func (m *MessageRecordsMutation) AddedIDs(name string) []ent.Value {
  19068. switch name {
  19069. case messagerecords.EdgeSopStage:
  19070. if id := m.sop_stage; id != nil {
  19071. return []ent.Value{*id}
  19072. }
  19073. case messagerecords.EdgeSopNode:
  19074. if id := m.sop_node; id != nil {
  19075. return []ent.Value{*id}
  19076. }
  19077. case messagerecords.EdgeMessageContact:
  19078. if id := m.message_contact; id != nil {
  19079. return []ent.Value{*id}
  19080. }
  19081. }
  19082. return nil
  19083. }
  19084. // RemovedEdges returns all edge names that were removed in this mutation.
  19085. func (m *MessageRecordsMutation) RemovedEdges() []string {
  19086. edges := make([]string, 0, 3)
  19087. return edges
  19088. }
  19089. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  19090. // the given name in this mutation.
  19091. func (m *MessageRecordsMutation) RemovedIDs(name string) []ent.Value {
  19092. return nil
  19093. }
  19094. // ClearedEdges returns all edge names that were cleared in this mutation.
  19095. func (m *MessageRecordsMutation) ClearedEdges() []string {
  19096. edges := make([]string, 0, 3)
  19097. if m.clearedsop_stage {
  19098. edges = append(edges, messagerecords.EdgeSopStage)
  19099. }
  19100. if m.clearedsop_node {
  19101. edges = append(edges, messagerecords.EdgeSopNode)
  19102. }
  19103. if m.clearedmessage_contact {
  19104. edges = append(edges, messagerecords.EdgeMessageContact)
  19105. }
  19106. return edges
  19107. }
  19108. // EdgeCleared returns a boolean which indicates if the edge with the given name
  19109. // was cleared in this mutation.
  19110. func (m *MessageRecordsMutation) EdgeCleared(name string) bool {
  19111. switch name {
  19112. case messagerecords.EdgeSopStage:
  19113. return m.clearedsop_stage
  19114. case messagerecords.EdgeSopNode:
  19115. return m.clearedsop_node
  19116. case messagerecords.EdgeMessageContact:
  19117. return m.clearedmessage_contact
  19118. }
  19119. return false
  19120. }
  19121. // ClearEdge clears the value of the edge with the given name. It returns an error
  19122. // if that edge is not defined in the schema.
  19123. func (m *MessageRecordsMutation) ClearEdge(name string) error {
  19124. switch name {
  19125. case messagerecords.EdgeSopStage:
  19126. m.ClearSopStage()
  19127. return nil
  19128. case messagerecords.EdgeSopNode:
  19129. m.ClearSopNode()
  19130. return nil
  19131. case messagerecords.EdgeMessageContact:
  19132. m.ClearMessageContact()
  19133. return nil
  19134. }
  19135. return fmt.Errorf("unknown MessageRecords unique edge %s", name)
  19136. }
  19137. // ResetEdge resets all changes to the edge with the given name in this mutation.
  19138. // It returns an error if the edge is not defined in the schema.
  19139. func (m *MessageRecordsMutation) ResetEdge(name string) error {
  19140. switch name {
  19141. case messagerecords.EdgeSopStage:
  19142. m.ResetSopStage()
  19143. return nil
  19144. case messagerecords.EdgeSopNode:
  19145. m.ResetSopNode()
  19146. return nil
  19147. case messagerecords.EdgeMessageContact:
  19148. m.ResetMessageContact()
  19149. return nil
  19150. }
  19151. return fmt.Errorf("unknown MessageRecords edge %s", name)
  19152. }
  19153. // MsgMutation represents an operation that mutates the Msg nodes in the graph.
  19154. type MsgMutation struct {
  19155. config
  19156. op Op
  19157. typ string
  19158. id *uint64
  19159. created_at *time.Time
  19160. updated_at *time.Time
  19161. deleted_at *time.Time
  19162. status *uint8
  19163. addstatus *int8
  19164. fromwxid *string
  19165. toid *string
  19166. msgtype *int32
  19167. addmsgtype *int32
  19168. msg *string
  19169. batch_no *string
  19170. cc *string
  19171. phone *string
  19172. clearedFields map[string]struct{}
  19173. done bool
  19174. oldValue func(context.Context) (*Msg, error)
  19175. predicates []predicate.Msg
  19176. }
  19177. var _ ent.Mutation = (*MsgMutation)(nil)
  19178. // msgOption allows management of the mutation configuration using functional options.
  19179. type msgOption func(*MsgMutation)
  19180. // newMsgMutation creates new mutation for the Msg entity.
  19181. func newMsgMutation(c config, op Op, opts ...msgOption) *MsgMutation {
  19182. m := &MsgMutation{
  19183. config: c,
  19184. op: op,
  19185. typ: TypeMsg,
  19186. clearedFields: make(map[string]struct{}),
  19187. }
  19188. for _, opt := range opts {
  19189. opt(m)
  19190. }
  19191. return m
  19192. }
  19193. // withMsgID sets the ID field of the mutation.
  19194. func withMsgID(id uint64) msgOption {
  19195. return func(m *MsgMutation) {
  19196. var (
  19197. err error
  19198. once sync.Once
  19199. value *Msg
  19200. )
  19201. m.oldValue = func(ctx context.Context) (*Msg, error) {
  19202. once.Do(func() {
  19203. if m.done {
  19204. err = errors.New("querying old values post mutation is not allowed")
  19205. } else {
  19206. value, err = m.Client().Msg.Get(ctx, id)
  19207. }
  19208. })
  19209. return value, err
  19210. }
  19211. m.id = &id
  19212. }
  19213. }
  19214. // withMsg sets the old Msg of the mutation.
  19215. func withMsg(node *Msg) msgOption {
  19216. return func(m *MsgMutation) {
  19217. m.oldValue = func(context.Context) (*Msg, error) {
  19218. return node, nil
  19219. }
  19220. m.id = &node.ID
  19221. }
  19222. }
  19223. // Client returns a new `ent.Client` from the mutation. If the mutation was
  19224. // executed in a transaction (ent.Tx), a transactional client is returned.
  19225. func (m MsgMutation) Client() *Client {
  19226. client := &Client{config: m.config}
  19227. client.init()
  19228. return client
  19229. }
  19230. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  19231. // it returns an error otherwise.
  19232. func (m MsgMutation) Tx() (*Tx, error) {
  19233. if _, ok := m.driver.(*txDriver); !ok {
  19234. return nil, errors.New("ent: mutation is not running in a transaction")
  19235. }
  19236. tx := &Tx{config: m.config}
  19237. tx.init()
  19238. return tx, nil
  19239. }
  19240. // SetID sets the value of the id field. Note that this
  19241. // operation is only accepted on creation of Msg entities.
  19242. func (m *MsgMutation) SetID(id uint64) {
  19243. m.id = &id
  19244. }
  19245. // ID returns the ID value in the mutation. Note that the ID is only available
  19246. // if it was provided to the builder or after it was returned from the database.
  19247. func (m *MsgMutation) ID() (id uint64, exists bool) {
  19248. if m.id == nil {
  19249. return
  19250. }
  19251. return *m.id, true
  19252. }
  19253. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  19254. // That means, if the mutation is applied within a transaction with an isolation level such
  19255. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  19256. // or updated by the mutation.
  19257. func (m *MsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  19258. switch {
  19259. case m.op.Is(OpUpdateOne | OpDeleteOne):
  19260. id, exists := m.ID()
  19261. if exists {
  19262. return []uint64{id}, nil
  19263. }
  19264. fallthrough
  19265. case m.op.Is(OpUpdate | OpDelete):
  19266. return m.Client().Msg.Query().Where(m.predicates...).IDs(ctx)
  19267. default:
  19268. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  19269. }
  19270. }
  19271. // SetCreatedAt sets the "created_at" field.
  19272. func (m *MsgMutation) SetCreatedAt(t time.Time) {
  19273. m.created_at = &t
  19274. }
  19275. // CreatedAt returns the value of the "created_at" field in the mutation.
  19276. func (m *MsgMutation) CreatedAt() (r time.Time, exists bool) {
  19277. v := m.created_at
  19278. if v == nil {
  19279. return
  19280. }
  19281. return *v, true
  19282. }
  19283. // OldCreatedAt returns the old "created_at" field's value of the Msg entity.
  19284. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  19285. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19286. func (m *MsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  19287. if !m.op.Is(OpUpdateOne) {
  19288. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  19289. }
  19290. if m.id == nil || m.oldValue == nil {
  19291. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  19292. }
  19293. oldValue, err := m.oldValue(ctx)
  19294. if err != nil {
  19295. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  19296. }
  19297. return oldValue.CreatedAt, nil
  19298. }
  19299. // ResetCreatedAt resets all changes to the "created_at" field.
  19300. func (m *MsgMutation) ResetCreatedAt() {
  19301. m.created_at = nil
  19302. }
  19303. // SetUpdatedAt sets the "updated_at" field.
  19304. func (m *MsgMutation) SetUpdatedAt(t time.Time) {
  19305. m.updated_at = &t
  19306. }
  19307. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  19308. func (m *MsgMutation) UpdatedAt() (r time.Time, exists bool) {
  19309. v := m.updated_at
  19310. if v == nil {
  19311. return
  19312. }
  19313. return *v, true
  19314. }
  19315. // OldUpdatedAt returns the old "updated_at" field's value of the Msg entity.
  19316. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  19317. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19318. func (m *MsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  19319. if !m.op.Is(OpUpdateOne) {
  19320. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  19321. }
  19322. if m.id == nil || m.oldValue == nil {
  19323. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  19324. }
  19325. oldValue, err := m.oldValue(ctx)
  19326. if err != nil {
  19327. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  19328. }
  19329. return oldValue.UpdatedAt, nil
  19330. }
  19331. // ResetUpdatedAt resets all changes to the "updated_at" field.
  19332. func (m *MsgMutation) ResetUpdatedAt() {
  19333. m.updated_at = nil
  19334. }
  19335. // SetDeletedAt sets the "deleted_at" field.
  19336. func (m *MsgMutation) SetDeletedAt(t time.Time) {
  19337. m.deleted_at = &t
  19338. }
  19339. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  19340. func (m *MsgMutation) DeletedAt() (r time.Time, exists bool) {
  19341. v := m.deleted_at
  19342. if v == nil {
  19343. return
  19344. }
  19345. return *v, true
  19346. }
  19347. // OldDeletedAt returns the old "deleted_at" field's value of the Msg entity.
  19348. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  19349. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19350. func (m *MsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  19351. if !m.op.Is(OpUpdateOne) {
  19352. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  19353. }
  19354. if m.id == nil || m.oldValue == nil {
  19355. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  19356. }
  19357. oldValue, err := m.oldValue(ctx)
  19358. if err != nil {
  19359. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  19360. }
  19361. return oldValue.DeletedAt, nil
  19362. }
  19363. // ClearDeletedAt clears the value of the "deleted_at" field.
  19364. func (m *MsgMutation) ClearDeletedAt() {
  19365. m.deleted_at = nil
  19366. m.clearedFields[msg.FieldDeletedAt] = struct{}{}
  19367. }
  19368. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  19369. func (m *MsgMutation) DeletedAtCleared() bool {
  19370. _, ok := m.clearedFields[msg.FieldDeletedAt]
  19371. return ok
  19372. }
  19373. // ResetDeletedAt resets all changes to the "deleted_at" field.
  19374. func (m *MsgMutation) ResetDeletedAt() {
  19375. m.deleted_at = nil
  19376. delete(m.clearedFields, msg.FieldDeletedAt)
  19377. }
  19378. // SetStatus sets the "status" field.
  19379. func (m *MsgMutation) SetStatus(u uint8) {
  19380. m.status = &u
  19381. m.addstatus = nil
  19382. }
  19383. // Status returns the value of the "status" field in the mutation.
  19384. func (m *MsgMutation) Status() (r uint8, exists bool) {
  19385. v := m.status
  19386. if v == nil {
  19387. return
  19388. }
  19389. return *v, true
  19390. }
  19391. // OldStatus returns the old "status" field's value of the Msg entity.
  19392. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  19393. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19394. func (m *MsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  19395. if !m.op.Is(OpUpdateOne) {
  19396. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  19397. }
  19398. if m.id == nil || m.oldValue == nil {
  19399. return v, errors.New("OldStatus requires an ID field in the mutation")
  19400. }
  19401. oldValue, err := m.oldValue(ctx)
  19402. if err != nil {
  19403. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  19404. }
  19405. return oldValue.Status, nil
  19406. }
  19407. // AddStatus adds u to the "status" field.
  19408. func (m *MsgMutation) AddStatus(u int8) {
  19409. if m.addstatus != nil {
  19410. *m.addstatus += u
  19411. } else {
  19412. m.addstatus = &u
  19413. }
  19414. }
  19415. // AddedStatus returns the value that was added to the "status" field in this mutation.
  19416. func (m *MsgMutation) AddedStatus() (r int8, exists bool) {
  19417. v := m.addstatus
  19418. if v == nil {
  19419. return
  19420. }
  19421. return *v, true
  19422. }
  19423. // ClearStatus clears the value of the "status" field.
  19424. func (m *MsgMutation) ClearStatus() {
  19425. m.status = nil
  19426. m.addstatus = nil
  19427. m.clearedFields[msg.FieldStatus] = struct{}{}
  19428. }
  19429. // StatusCleared returns if the "status" field was cleared in this mutation.
  19430. func (m *MsgMutation) StatusCleared() bool {
  19431. _, ok := m.clearedFields[msg.FieldStatus]
  19432. return ok
  19433. }
  19434. // ResetStatus resets all changes to the "status" field.
  19435. func (m *MsgMutation) ResetStatus() {
  19436. m.status = nil
  19437. m.addstatus = nil
  19438. delete(m.clearedFields, msg.FieldStatus)
  19439. }
  19440. // SetFromwxid sets the "fromwxid" field.
  19441. func (m *MsgMutation) SetFromwxid(s string) {
  19442. m.fromwxid = &s
  19443. }
  19444. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  19445. func (m *MsgMutation) Fromwxid() (r string, exists bool) {
  19446. v := m.fromwxid
  19447. if v == nil {
  19448. return
  19449. }
  19450. return *v, true
  19451. }
  19452. // OldFromwxid returns the old "fromwxid" field's value of the Msg entity.
  19453. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  19454. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19455. func (m *MsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  19456. if !m.op.Is(OpUpdateOne) {
  19457. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  19458. }
  19459. if m.id == nil || m.oldValue == nil {
  19460. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  19461. }
  19462. oldValue, err := m.oldValue(ctx)
  19463. if err != nil {
  19464. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  19465. }
  19466. return oldValue.Fromwxid, nil
  19467. }
  19468. // ClearFromwxid clears the value of the "fromwxid" field.
  19469. func (m *MsgMutation) ClearFromwxid() {
  19470. m.fromwxid = nil
  19471. m.clearedFields[msg.FieldFromwxid] = struct{}{}
  19472. }
  19473. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  19474. func (m *MsgMutation) FromwxidCleared() bool {
  19475. _, ok := m.clearedFields[msg.FieldFromwxid]
  19476. return ok
  19477. }
  19478. // ResetFromwxid resets all changes to the "fromwxid" field.
  19479. func (m *MsgMutation) ResetFromwxid() {
  19480. m.fromwxid = nil
  19481. delete(m.clearedFields, msg.FieldFromwxid)
  19482. }
  19483. // SetToid sets the "toid" field.
  19484. func (m *MsgMutation) SetToid(s string) {
  19485. m.toid = &s
  19486. }
  19487. // Toid returns the value of the "toid" field in the mutation.
  19488. func (m *MsgMutation) Toid() (r string, exists bool) {
  19489. v := m.toid
  19490. if v == nil {
  19491. return
  19492. }
  19493. return *v, true
  19494. }
  19495. // OldToid returns the old "toid" field's value of the Msg entity.
  19496. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  19497. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19498. func (m *MsgMutation) OldToid(ctx context.Context) (v string, err error) {
  19499. if !m.op.Is(OpUpdateOne) {
  19500. return v, errors.New("OldToid is only allowed on UpdateOne operations")
  19501. }
  19502. if m.id == nil || m.oldValue == nil {
  19503. return v, errors.New("OldToid requires an ID field in the mutation")
  19504. }
  19505. oldValue, err := m.oldValue(ctx)
  19506. if err != nil {
  19507. return v, fmt.Errorf("querying old value for OldToid: %w", err)
  19508. }
  19509. return oldValue.Toid, nil
  19510. }
  19511. // ClearToid clears the value of the "toid" field.
  19512. func (m *MsgMutation) ClearToid() {
  19513. m.toid = nil
  19514. m.clearedFields[msg.FieldToid] = struct{}{}
  19515. }
  19516. // ToidCleared returns if the "toid" field was cleared in this mutation.
  19517. func (m *MsgMutation) ToidCleared() bool {
  19518. _, ok := m.clearedFields[msg.FieldToid]
  19519. return ok
  19520. }
  19521. // ResetToid resets all changes to the "toid" field.
  19522. func (m *MsgMutation) ResetToid() {
  19523. m.toid = nil
  19524. delete(m.clearedFields, msg.FieldToid)
  19525. }
  19526. // SetMsgtype sets the "msgtype" field.
  19527. func (m *MsgMutation) SetMsgtype(i int32) {
  19528. m.msgtype = &i
  19529. m.addmsgtype = nil
  19530. }
  19531. // Msgtype returns the value of the "msgtype" field in the mutation.
  19532. func (m *MsgMutation) Msgtype() (r int32, exists bool) {
  19533. v := m.msgtype
  19534. if v == nil {
  19535. return
  19536. }
  19537. return *v, true
  19538. }
  19539. // OldMsgtype returns the old "msgtype" field's value of the Msg entity.
  19540. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  19541. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19542. func (m *MsgMutation) OldMsgtype(ctx context.Context) (v int32, err error) {
  19543. if !m.op.Is(OpUpdateOne) {
  19544. return v, errors.New("OldMsgtype is only allowed on UpdateOne operations")
  19545. }
  19546. if m.id == nil || m.oldValue == nil {
  19547. return v, errors.New("OldMsgtype requires an ID field in the mutation")
  19548. }
  19549. oldValue, err := m.oldValue(ctx)
  19550. if err != nil {
  19551. return v, fmt.Errorf("querying old value for OldMsgtype: %w", err)
  19552. }
  19553. return oldValue.Msgtype, nil
  19554. }
  19555. // AddMsgtype adds i to the "msgtype" field.
  19556. func (m *MsgMutation) AddMsgtype(i int32) {
  19557. if m.addmsgtype != nil {
  19558. *m.addmsgtype += i
  19559. } else {
  19560. m.addmsgtype = &i
  19561. }
  19562. }
  19563. // AddedMsgtype returns the value that was added to the "msgtype" field in this mutation.
  19564. func (m *MsgMutation) AddedMsgtype() (r int32, exists bool) {
  19565. v := m.addmsgtype
  19566. if v == nil {
  19567. return
  19568. }
  19569. return *v, true
  19570. }
  19571. // ClearMsgtype clears the value of the "msgtype" field.
  19572. func (m *MsgMutation) ClearMsgtype() {
  19573. m.msgtype = nil
  19574. m.addmsgtype = nil
  19575. m.clearedFields[msg.FieldMsgtype] = struct{}{}
  19576. }
  19577. // MsgtypeCleared returns if the "msgtype" field was cleared in this mutation.
  19578. func (m *MsgMutation) MsgtypeCleared() bool {
  19579. _, ok := m.clearedFields[msg.FieldMsgtype]
  19580. return ok
  19581. }
  19582. // ResetMsgtype resets all changes to the "msgtype" field.
  19583. func (m *MsgMutation) ResetMsgtype() {
  19584. m.msgtype = nil
  19585. m.addmsgtype = nil
  19586. delete(m.clearedFields, msg.FieldMsgtype)
  19587. }
  19588. // SetMsg sets the "msg" field.
  19589. func (m *MsgMutation) SetMsg(s string) {
  19590. m.msg = &s
  19591. }
  19592. // Msg returns the value of the "msg" field in the mutation.
  19593. func (m *MsgMutation) Msg() (r string, exists bool) {
  19594. v := m.msg
  19595. if v == nil {
  19596. return
  19597. }
  19598. return *v, true
  19599. }
  19600. // OldMsg returns the old "msg" field's value of the Msg entity.
  19601. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  19602. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19603. func (m *MsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  19604. if !m.op.Is(OpUpdateOne) {
  19605. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  19606. }
  19607. if m.id == nil || m.oldValue == nil {
  19608. return v, errors.New("OldMsg requires an ID field in the mutation")
  19609. }
  19610. oldValue, err := m.oldValue(ctx)
  19611. if err != nil {
  19612. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  19613. }
  19614. return oldValue.Msg, nil
  19615. }
  19616. // ClearMsg clears the value of the "msg" field.
  19617. func (m *MsgMutation) ClearMsg() {
  19618. m.msg = nil
  19619. m.clearedFields[msg.FieldMsg] = struct{}{}
  19620. }
  19621. // MsgCleared returns if the "msg" field was cleared in this mutation.
  19622. func (m *MsgMutation) MsgCleared() bool {
  19623. _, ok := m.clearedFields[msg.FieldMsg]
  19624. return ok
  19625. }
  19626. // ResetMsg resets all changes to the "msg" field.
  19627. func (m *MsgMutation) ResetMsg() {
  19628. m.msg = nil
  19629. delete(m.clearedFields, msg.FieldMsg)
  19630. }
  19631. // SetBatchNo sets the "batch_no" field.
  19632. func (m *MsgMutation) SetBatchNo(s string) {
  19633. m.batch_no = &s
  19634. }
  19635. // BatchNo returns the value of the "batch_no" field in the mutation.
  19636. func (m *MsgMutation) BatchNo() (r string, exists bool) {
  19637. v := m.batch_no
  19638. if v == nil {
  19639. return
  19640. }
  19641. return *v, true
  19642. }
  19643. // OldBatchNo returns the old "batch_no" field's value of the Msg entity.
  19644. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  19645. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19646. func (m *MsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  19647. if !m.op.Is(OpUpdateOne) {
  19648. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  19649. }
  19650. if m.id == nil || m.oldValue == nil {
  19651. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  19652. }
  19653. oldValue, err := m.oldValue(ctx)
  19654. if err != nil {
  19655. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  19656. }
  19657. return oldValue.BatchNo, nil
  19658. }
  19659. // ClearBatchNo clears the value of the "batch_no" field.
  19660. func (m *MsgMutation) ClearBatchNo() {
  19661. m.batch_no = nil
  19662. m.clearedFields[msg.FieldBatchNo] = struct{}{}
  19663. }
  19664. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  19665. func (m *MsgMutation) BatchNoCleared() bool {
  19666. _, ok := m.clearedFields[msg.FieldBatchNo]
  19667. return ok
  19668. }
  19669. // ResetBatchNo resets all changes to the "batch_no" field.
  19670. func (m *MsgMutation) ResetBatchNo() {
  19671. m.batch_no = nil
  19672. delete(m.clearedFields, msg.FieldBatchNo)
  19673. }
  19674. // SetCc sets the "cc" field.
  19675. func (m *MsgMutation) SetCc(s string) {
  19676. m.cc = &s
  19677. }
  19678. // Cc returns the value of the "cc" field in the mutation.
  19679. func (m *MsgMutation) Cc() (r string, exists bool) {
  19680. v := m.cc
  19681. if v == nil {
  19682. return
  19683. }
  19684. return *v, true
  19685. }
  19686. // OldCc returns the old "cc" field's value of the Msg entity.
  19687. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  19688. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19689. func (m *MsgMutation) OldCc(ctx context.Context) (v string, err error) {
  19690. if !m.op.Is(OpUpdateOne) {
  19691. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  19692. }
  19693. if m.id == nil || m.oldValue == nil {
  19694. return v, errors.New("OldCc requires an ID field in the mutation")
  19695. }
  19696. oldValue, err := m.oldValue(ctx)
  19697. if err != nil {
  19698. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  19699. }
  19700. return oldValue.Cc, nil
  19701. }
  19702. // ResetCc resets all changes to the "cc" field.
  19703. func (m *MsgMutation) ResetCc() {
  19704. m.cc = nil
  19705. }
  19706. // SetPhone sets the "phone" field.
  19707. func (m *MsgMutation) SetPhone(s string) {
  19708. m.phone = &s
  19709. }
  19710. // Phone returns the value of the "phone" field in the mutation.
  19711. func (m *MsgMutation) Phone() (r string, exists bool) {
  19712. v := m.phone
  19713. if v == nil {
  19714. return
  19715. }
  19716. return *v, true
  19717. }
  19718. // OldPhone returns the old "phone" field's value of the Msg entity.
  19719. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  19720. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19721. func (m *MsgMutation) OldPhone(ctx context.Context) (v string, err error) {
  19722. if !m.op.Is(OpUpdateOne) {
  19723. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  19724. }
  19725. if m.id == nil || m.oldValue == nil {
  19726. return v, errors.New("OldPhone requires an ID field in the mutation")
  19727. }
  19728. oldValue, err := m.oldValue(ctx)
  19729. if err != nil {
  19730. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  19731. }
  19732. return oldValue.Phone, nil
  19733. }
  19734. // ResetPhone resets all changes to the "phone" field.
  19735. func (m *MsgMutation) ResetPhone() {
  19736. m.phone = nil
  19737. }
  19738. // Where appends a list predicates to the MsgMutation builder.
  19739. func (m *MsgMutation) Where(ps ...predicate.Msg) {
  19740. m.predicates = append(m.predicates, ps...)
  19741. }
  19742. // WhereP appends storage-level predicates to the MsgMutation builder. Using this method,
  19743. // users can use type-assertion to append predicates that do not depend on any generated package.
  19744. func (m *MsgMutation) WhereP(ps ...func(*sql.Selector)) {
  19745. p := make([]predicate.Msg, len(ps))
  19746. for i := range ps {
  19747. p[i] = ps[i]
  19748. }
  19749. m.Where(p...)
  19750. }
  19751. // Op returns the operation name.
  19752. func (m *MsgMutation) Op() Op {
  19753. return m.op
  19754. }
  19755. // SetOp allows setting the mutation operation.
  19756. func (m *MsgMutation) SetOp(op Op) {
  19757. m.op = op
  19758. }
  19759. // Type returns the node type of this mutation (Msg).
  19760. func (m *MsgMutation) Type() string {
  19761. return m.typ
  19762. }
  19763. // Fields returns all fields that were changed during this mutation. Note that in
  19764. // order to get all numeric fields that were incremented/decremented, call
  19765. // AddedFields().
  19766. func (m *MsgMutation) Fields() []string {
  19767. fields := make([]string, 0, 11)
  19768. if m.created_at != nil {
  19769. fields = append(fields, msg.FieldCreatedAt)
  19770. }
  19771. if m.updated_at != nil {
  19772. fields = append(fields, msg.FieldUpdatedAt)
  19773. }
  19774. if m.deleted_at != nil {
  19775. fields = append(fields, msg.FieldDeletedAt)
  19776. }
  19777. if m.status != nil {
  19778. fields = append(fields, msg.FieldStatus)
  19779. }
  19780. if m.fromwxid != nil {
  19781. fields = append(fields, msg.FieldFromwxid)
  19782. }
  19783. if m.toid != nil {
  19784. fields = append(fields, msg.FieldToid)
  19785. }
  19786. if m.msgtype != nil {
  19787. fields = append(fields, msg.FieldMsgtype)
  19788. }
  19789. if m.msg != nil {
  19790. fields = append(fields, msg.FieldMsg)
  19791. }
  19792. if m.batch_no != nil {
  19793. fields = append(fields, msg.FieldBatchNo)
  19794. }
  19795. if m.cc != nil {
  19796. fields = append(fields, msg.FieldCc)
  19797. }
  19798. if m.phone != nil {
  19799. fields = append(fields, msg.FieldPhone)
  19800. }
  19801. return fields
  19802. }
  19803. // Field returns the value of a field with the given name. The second boolean
  19804. // return value indicates that this field was not set, or was not defined in the
  19805. // schema.
  19806. func (m *MsgMutation) Field(name string) (ent.Value, bool) {
  19807. switch name {
  19808. case msg.FieldCreatedAt:
  19809. return m.CreatedAt()
  19810. case msg.FieldUpdatedAt:
  19811. return m.UpdatedAt()
  19812. case msg.FieldDeletedAt:
  19813. return m.DeletedAt()
  19814. case msg.FieldStatus:
  19815. return m.Status()
  19816. case msg.FieldFromwxid:
  19817. return m.Fromwxid()
  19818. case msg.FieldToid:
  19819. return m.Toid()
  19820. case msg.FieldMsgtype:
  19821. return m.Msgtype()
  19822. case msg.FieldMsg:
  19823. return m.Msg()
  19824. case msg.FieldBatchNo:
  19825. return m.BatchNo()
  19826. case msg.FieldCc:
  19827. return m.Cc()
  19828. case msg.FieldPhone:
  19829. return m.Phone()
  19830. }
  19831. return nil, false
  19832. }
  19833. // OldField returns the old value of the field from the database. An error is
  19834. // returned if the mutation operation is not UpdateOne, or the query to the
  19835. // database failed.
  19836. func (m *MsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  19837. switch name {
  19838. case msg.FieldCreatedAt:
  19839. return m.OldCreatedAt(ctx)
  19840. case msg.FieldUpdatedAt:
  19841. return m.OldUpdatedAt(ctx)
  19842. case msg.FieldDeletedAt:
  19843. return m.OldDeletedAt(ctx)
  19844. case msg.FieldStatus:
  19845. return m.OldStatus(ctx)
  19846. case msg.FieldFromwxid:
  19847. return m.OldFromwxid(ctx)
  19848. case msg.FieldToid:
  19849. return m.OldToid(ctx)
  19850. case msg.FieldMsgtype:
  19851. return m.OldMsgtype(ctx)
  19852. case msg.FieldMsg:
  19853. return m.OldMsg(ctx)
  19854. case msg.FieldBatchNo:
  19855. return m.OldBatchNo(ctx)
  19856. case msg.FieldCc:
  19857. return m.OldCc(ctx)
  19858. case msg.FieldPhone:
  19859. return m.OldPhone(ctx)
  19860. }
  19861. return nil, fmt.Errorf("unknown Msg field %s", name)
  19862. }
  19863. // SetField sets the value of a field with the given name. It returns an error if
  19864. // the field is not defined in the schema, or if the type mismatched the field
  19865. // type.
  19866. func (m *MsgMutation) SetField(name string, value ent.Value) error {
  19867. switch name {
  19868. case msg.FieldCreatedAt:
  19869. v, ok := value.(time.Time)
  19870. if !ok {
  19871. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19872. }
  19873. m.SetCreatedAt(v)
  19874. return nil
  19875. case msg.FieldUpdatedAt:
  19876. v, ok := value.(time.Time)
  19877. if !ok {
  19878. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19879. }
  19880. m.SetUpdatedAt(v)
  19881. return nil
  19882. case msg.FieldDeletedAt:
  19883. v, ok := value.(time.Time)
  19884. if !ok {
  19885. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19886. }
  19887. m.SetDeletedAt(v)
  19888. return nil
  19889. case msg.FieldStatus:
  19890. v, ok := value.(uint8)
  19891. if !ok {
  19892. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19893. }
  19894. m.SetStatus(v)
  19895. return nil
  19896. case msg.FieldFromwxid:
  19897. v, ok := value.(string)
  19898. if !ok {
  19899. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19900. }
  19901. m.SetFromwxid(v)
  19902. return nil
  19903. case msg.FieldToid:
  19904. v, ok := value.(string)
  19905. if !ok {
  19906. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19907. }
  19908. m.SetToid(v)
  19909. return nil
  19910. case msg.FieldMsgtype:
  19911. v, ok := value.(int32)
  19912. if !ok {
  19913. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19914. }
  19915. m.SetMsgtype(v)
  19916. return nil
  19917. case msg.FieldMsg:
  19918. v, ok := value.(string)
  19919. if !ok {
  19920. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19921. }
  19922. m.SetMsg(v)
  19923. return nil
  19924. case msg.FieldBatchNo:
  19925. v, ok := value.(string)
  19926. if !ok {
  19927. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19928. }
  19929. m.SetBatchNo(v)
  19930. return nil
  19931. case msg.FieldCc:
  19932. v, ok := value.(string)
  19933. if !ok {
  19934. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19935. }
  19936. m.SetCc(v)
  19937. return nil
  19938. case msg.FieldPhone:
  19939. v, ok := value.(string)
  19940. if !ok {
  19941. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19942. }
  19943. m.SetPhone(v)
  19944. return nil
  19945. }
  19946. return fmt.Errorf("unknown Msg field %s", name)
  19947. }
  19948. // AddedFields returns all numeric fields that were incremented/decremented during
  19949. // this mutation.
  19950. func (m *MsgMutation) AddedFields() []string {
  19951. var fields []string
  19952. if m.addstatus != nil {
  19953. fields = append(fields, msg.FieldStatus)
  19954. }
  19955. if m.addmsgtype != nil {
  19956. fields = append(fields, msg.FieldMsgtype)
  19957. }
  19958. return fields
  19959. }
  19960. // AddedField returns the numeric value that was incremented/decremented on a field
  19961. // with the given name. The second boolean return value indicates that this field
  19962. // was not set, or was not defined in the schema.
  19963. func (m *MsgMutation) AddedField(name string) (ent.Value, bool) {
  19964. switch name {
  19965. case msg.FieldStatus:
  19966. return m.AddedStatus()
  19967. case msg.FieldMsgtype:
  19968. return m.AddedMsgtype()
  19969. }
  19970. return nil, false
  19971. }
  19972. // AddField adds the value to the field with the given name. It returns an error if
  19973. // the field is not defined in the schema, or if the type mismatched the field
  19974. // type.
  19975. func (m *MsgMutation) AddField(name string, value ent.Value) error {
  19976. switch name {
  19977. case msg.FieldStatus:
  19978. v, ok := value.(int8)
  19979. if !ok {
  19980. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19981. }
  19982. m.AddStatus(v)
  19983. return nil
  19984. case msg.FieldMsgtype:
  19985. v, ok := value.(int32)
  19986. if !ok {
  19987. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19988. }
  19989. m.AddMsgtype(v)
  19990. return nil
  19991. }
  19992. return fmt.Errorf("unknown Msg numeric field %s", name)
  19993. }
  19994. // ClearedFields returns all nullable fields that were cleared during this
  19995. // mutation.
  19996. func (m *MsgMutation) ClearedFields() []string {
  19997. var fields []string
  19998. if m.FieldCleared(msg.FieldDeletedAt) {
  19999. fields = append(fields, msg.FieldDeletedAt)
  20000. }
  20001. if m.FieldCleared(msg.FieldStatus) {
  20002. fields = append(fields, msg.FieldStatus)
  20003. }
  20004. if m.FieldCleared(msg.FieldFromwxid) {
  20005. fields = append(fields, msg.FieldFromwxid)
  20006. }
  20007. if m.FieldCleared(msg.FieldToid) {
  20008. fields = append(fields, msg.FieldToid)
  20009. }
  20010. if m.FieldCleared(msg.FieldMsgtype) {
  20011. fields = append(fields, msg.FieldMsgtype)
  20012. }
  20013. if m.FieldCleared(msg.FieldMsg) {
  20014. fields = append(fields, msg.FieldMsg)
  20015. }
  20016. if m.FieldCleared(msg.FieldBatchNo) {
  20017. fields = append(fields, msg.FieldBatchNo)
  20018. }
  20019. return fields
  20020. }
  20021. // FieldCleared returns a boolean indicating if a field with the given name was
  20022. // cleared in this mutation.
  20023. func (m *MsgMutation) FieldCleared(name string) bool {
  20024. _, ok := m.clearedFields[name]
  20025. return ok
  20026. }
  20027. // ClearField clears the value of the field with the given name. It returns an
  20028. // error if the field is not defined in the schema.
  20029. func (m *MsgMutation) ClearField(name string) error {
  20030. switch name {
  20031. case msg.FieldDeletedAt:
  20032. m.ClearDeletedAt()
  20033. return nil
  20034. case msg.FieldStatus:
  20035. m.ClearStatus()
  20036. return nil
  20037. case msg.FieldFromwxid:
  20038. m.ClearFromwxid()
  20039. return nil
  20040. case msg.FieldToid:
  20041. m.ClearToid()
  20042. return nil
  20043. case msg.FieldMsgtype:
  20044. m.ClearMsgtype()
  20045. return nil
  20046. case msg.FieldMsg:
  20047. m.ClearMsg()
  20048. return nil
  20049. case msg.FieldBatchNo:
  20050. m.ClearBatchNo()
  20051. return nil
  20052. }
  20053. return fmt.Errorf("unknown Msg nullable field %s", name)
  20054. }
  20055. // ResetField resets all changes in the mutation for the field with the given name.
  20056. // It returns an error if the field is not defined in the schema.
  20057. func (m *MsgMutation) ResetField(name string) error {
  20058. switch name {
  20059. case msg.FieldCreatedAt:
  20060. m.ResetCreatedAt()
  20061. return nil
  20062. case msg.FieldUpdatedAt:
  20063. m.ResetUpdatedAt()
  20064. return nil
  20065. case msg.FieldDeletedAt:
  20066. m.ResetDeletedAt()
  20067. return nil
  20068. case msg.FieldStatus:
  20069. m.ResetStatus()
  20070. return nil
  20071. case msg.FieldFromwxid:
  20072. m.ResetFromwxid()
  20073. return nil
  20074. case msg.FieldToid:
  20075. m.ResetToid()
  20076. return nil
  20077. case msg.FieldMsgtype:
  20078. m.ResetMsgtype()
  20079. return nil
  20080. case msg.FieldMsg:
  20081. m.ResetMsg()
  20082. return nil
  20083. case msg.FieldBatchNo:
  20084. m.ResetBatchNo()
  20085. return nil
  20086. case msg.FieldCc:
  20087. m.ResetCc()
  20088. return nil
  20089. case msg.FieldPhone:
  20090. m.ResetPhone()
  20091. return nil
  20092. }
  20093. return fmt.Errorf("unknown Msg field %s", name)
  20094. }
  20095. // AddedEdges returns all edge names that were set/added in this mutation.
  20096. func (m *MsgMutation) AddedEdges() []string {
  20097. edges := make([]string, 0, 0)
  20098. return edges
  20099. }
  20100. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  20101. // name in this mutation.
  20102. func (m *MsgMutation) AddedIDs(name string) []ent.Value {
  20103. return nil
  20104. }
  20105. // RemovedEdges returns all edge names that were removed in this mutation.
  20106. func (m *MsgMutation) RemovedEdges() []string {
  20107. edges := make([]string, 0, 0)
  20108. return edges
  20109. }
  20110. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  20111. // the given name in this mutation.
  20112. func (m *MsgMutation) RemovedIDs(name string) []ent.Value {
  20113. return nil
  20114. }
  20115. // ClearedEdges returns all edge names that were cleared in this mutation.
  20116. func (m *MsgMutation) ClearedEdges() []string {
  20117. edges := make([]string, 0, 0)
  20118. return edges
  20119. }
  20120. // EdgeCleared returns a boolean which indicates if the edge with the given name
  20121. // was cleared in this mutation.
  20122. func (m *MsgMutation) EdgeCleared(name string) bool {
  20123. return false
  20124. }
  20125. // ClearEdge clears the value of the edge with the given name. It returns an error
  20126. // if that edge is not defined in the schema.
  20127. func (m *MsgMutation) ClearEdge(name string) error {
  20128. return fmt.Errorf("unknown Msg unique edge %s", name)
  20129. }
  20130. // ResetEdge resets all changes to the edge with the given name in this mutation.
  20131. // It returns an error if the edge is not defined in the schema.
  20132. func (m *MsgMutation) ResetEdge(name string) error {
  20133. return fmt.Errorf("unknown Msg edge %s", name)
  20134. }
  20135. // PayRechargeMutation represents an operation that mutates the PayRecharge nodes in the graph.
  20136. type PayRechargeMutation struct {
  20137. config
  20138. op Op
  20139. typ string
  20140. id *uint64
  20141. created_at *time.Time
  20142. updated_at *time.Time
  20143. deleted_at *time.Time
  20144. user_id *string
  20145. number *float32
  20146. addnumber *float32
  20147. status *int
  20148. addstatus *int
  20149. money *float32
  20150. addmoney *float32
  20151. out_trade_no *string
  20152. organization_id *uint64
  20153. addorganization_id *int64
  20154. clearedFields map[string]struct{}
  20155. done bool
  20156. oldValue func(context.Context) (*PayRecharge, error)
  20157. predicates []predicate.PayRecharge
  20158. }
  20159. var _ ent.Mutation = (*PayRechargeMutation)(nil)
  20160. // payrechargeOption allows management of the mutation configuration using functional options.
  20161. type payrechargeOption func(*PayRechargeMutation)
  20162. // newPayRechargeMutation creates new mutation for the PayRecharge entity.
  20163. func newPayRechargeMutation(c config, op Op, opts ...payrechargeOption) *PayRechargeMutation {
  20164. m := &PayRechargeMutation{
  20165. config: c,
  20166. op: op,
  20167. typ: TypePayRecharge,
  20168. clearedFields: make(map[string]struct{}),
  20169. }
  20170. for _, opt := range opts {
  20171. opt(m)
  20172. }
  20173. return m
  20174. }
  20175. // withPayRechargeID sets the ID field of the mutation.
  20176. func withPayRechargeID(id uint64) payrechargeOption {
  20177. return func(m *PayRechargeMutation) {
  20178. var (
  20179. err error
  20180. once sync.Once
  20181. value *PayRecharge
  20182. )
  20183. m.oldValue = func(ctx context.Context) (*PayRecharge, error) {
  20184. once.Do(func() {
  20185. if m.done {
  20186. err = errors.New("querying old values post mutation is not allowed")
  20187. } else {
  20188. value, err = m.Client().PayRecharge.Get(ctx, id)
  20189. }
  20190. })
  20191. return value, err
  20192. }
  20193. m.id = &id
  20194. }
  20195. }
  20196. // withPayRecharge sets the old PayRecharge of the mutation.
  20197. func withPayRecharge(node *PayRecharge) payrechargeOption {
  20198. return func(m *PayRechargeMutation) {
  20199. m.oldValue = func(context.Context) (*PayRecharge, error) {
  20200. return node, nil
  20201. }
  20202. m.id = &node.ID
  20203. }
  20204. }
  20205. // Client returns a new `ent.Client` from the mutation. If the mutation was
  20206. // executed in a transaction (ent.Tx), a transactional client is returned.
  20207. func (m PayRechargeMutation) Client() *Client {
  20208. client := &Client{config: m.config}
  20209. client.init()
  20210. return client
  20211. }
  20212. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  20213. // it returns an error otherwise.
  20214. func (m PayRechargeMutation) Tx() (*Tx, error) {
  20215. if _, ok := m.driver.(*txDriver); !ok {
  20216. return nil, errors.New("ent: mutation is not running in a transaction")
  20217. }
  20218. tx := &Tx{config: m.config}
  20219. tx.init()
  20220. return tx, nil
  20221. }
  20222. // SetID sets the value of the id field. Note that this
  20223. // operation is only accepted on creation of PayRecharge entities.
  20224. func (m *PayRechargeMutation) SetID(id uint64) {
  20225. m.id = &id
  20226. }
  20227. // ID returns the ID value in the mutation. Note that the ID is only available
  20228. // if it was provided to the builder or after it was returned from the database.
  20229. func (m *PayRechargeMutation) ID() (id uint64, exists bool) {
  20230. if m.id == nil {
  20231. return
  20232. }
  20233. return *m.id, true
  20234. }
  20235. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  20236. // That means, if the mutation is applied within a transaction with an isolation level such
  20237. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  20238. // or updated by the mutation.
  20239. func (m *PayRechargeMutation) IDs(ctx context.Context) ([]uint64, error) {
  20240. switch {
  20241. case m.op.Is(OpUpdateOne | OpDeleteOne):
  20242. id, exists := m.ID()
  20243. if exists {
  20244. return []uint64{id}, nil
  20245. }
  20246. fallthrough
  20247. case m.op.Is(OpUpdate | OpDelete):
  20248. return m.Client().PayRecharge.Query().Where(m.predicates...).IDs(ctx)
  20249. default:
  20250. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  20251. }
  20252. }
  20253. // SetCreatedAt sets the "created_at" field.
  20254. func (m *PayRechargeMutation) SetCreatedAt(t time.Time) {
  20255. m.created_at = &t
  20256. }
  20257. // CreatedAt returns the value of the "created_at" field in the mutation.
  20258. func (m *PayRechargeMutation) CreatedAt() (r time.Time, exists bool) {
  20259. v := m.created_at
  20260. if v == nil {
  20261. return
  20262. }
  20263. return *v, true
  20264. }
  20265. // OldCreatedAt returns the old "created_at" field's value of the PayRecharge entity.
  20266. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  20267. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20268. func (m *PayRechargeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  20269. if !m.op.Is(OpUpdateOne) {
  20270. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  20271. }
  20272. if m.id == nil || m.oldValue == nil {
  20273. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  20274. }
  20275. oldValue, err := m.oldValue(ctx)
  20276. if err != nil {
  20277. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  20278. }
  20279. return oldValue.CreatedAt, nil
  20280. }
  20281. // ResetCreatedAt resets all changes to the "created_at" field.
  20282. func (m *PayRechargeMutation) ResetCreatedAt() {
  20283. m.created_at = nil
  20284. }
  20285. // SetUpdatedAt sets the "updated_at" field.
  20286. func (m *PayRechargeMutation) SetUpdatedAt(t time.Time) {
  20287. m.updated_at = &t
  20288. }
  20289. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  20290. func (m *PayRechargeMutation) UpdatedAt() (r time.Time, exists bool) {
  20291. v := m.updated_at
  20292. if v == nil {
  20293. return
  20294. }
  20295. return *v, true
  20296. }
  20297. // OldUpdatedAt returns the old "updated_at" field's value of the PayRecharge entity.
  20298. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  20299. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20300. func (m *PayRechargeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  20301. if !m.op.Is(OpUpdateOne) {
  20302. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  20303. }
  20304. if m.id == nil || m.oldValue == nil {
  20305. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  20306. }
  20307. oldValue, err := m.oldValue(ctx)
  20308. if err != nil {
  20309. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  20310. }
  20311. return oldValue.UpdatedAt, nil
  20312. }
  20313. // ResetUpdatedAt resets all changes to the "updated_at" field.
  20314. func (m *PayRechargeMutation) ResetUpdatedAt() {
  20315. m.updated_at = nil
  20316. }
  20317. // SetDeletedAt sets the "deleted_at" field.
  20318. func (m *PayRechargeMutation) SetDeletedAt(t time.Time) {
  20319. m.deleted_at = &t
  20320. }
  20321. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  20322. func (m *PayRechargeMutation) DeletedAt() (r time.Time, exists bool) {
  20323. v := m.deleted_at
  20324. if v == nil {
  20325. return
  20326. }
  20327. return *v, true
  20328. }
  20329. // OldDeletedAt returns the old "deleted_at" field's value of the PayRecharge entity.
  20330. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  20331. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20332. func (m *PayRechargeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  20333. if !m.op.Is(OpUpdateOne) {
  20334. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  20335. }
  20336. if m.id == nil || m.oldValue == nil {
  20337. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  20338. }
  20339. oldValue, err := m.oldValue(ctx)
  20340. if err != nil {
  20341. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  20342. }
  20343. return oldValue.DeletedAt, nil
  20344. }
  20345. // ClearDeletedAt clears the value of the "deleted_at" field.
  20346. func (m *PayRechargeMutation) ClearDeletedAt() {
  20347. m.deleted_at = nil
  20348. m.clearedFields[payrecharge.FieldDeletedAt] = struct{}{}
  20349. }
  20350. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  20351. func (m *PayRechargeMutation) DeletedAtCleared() bool {
  20352. _, ok := m.clearedFields[payrecharge.FieldDeletedAt]
  20353. return ok
  20354. }
  20355. // ResetDeletedAt resets all changes to the "deleted_at" field.
  20356. func (m *PayRechargeMutation) ResetDeletedAt() {
  20357. m.deleted_at = nil
  20358. delete(m.clearedFields, payrecharge.FieldDeletedAt)
  20359. }
  20360. // SetUserID sets the "user_id" field.
  20361. func (m *PayRechargeMutation) SetUserID(s string) {
  20362. m.user_id = &s
  20363. }
  20364. // UserID returns the value of the "user_id" field in the mutation.
  20365. func (m *PayRechargeMutation) UserID() (r string, exists bool) {
  20366. v := m.user_id
  20367. if v == nil {
  20368. return
  20369. }
  20370. return *v, true
  20371. }
  20372. // OldUserID returns the old "user_id" field's value of the PayRecharge entity.
  20373. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  20374. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20375. func (m *PayRechargeMutation) OldUserID(ctx context.Context) (v string, err error) {
  20376. if !m.op.Is(OpUpdateOne) {
  20377. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  20378. }
  20379. if m.id == nil || m.oldValue == nil {
  20380. return v, errors.New("OldUserID requires an ID field in the mutation")
  20381. }
  20382. oldValue, err := m.oldValue(ctx)
  20383. if err != nil {
  20384. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  20385. }
  20386. return oldValue.UserID, nil
  20387. }
  20388. // ResetUserID resets all changes to the "user_id" field.
  20389. func (m *PayRechargeMutation) ResetUserID() {
  20390. m.user_id = nil
  20391. }
  20392. // SetNumber sets the "number" field.
  20393. func (m *PayRechargeMutation) SetNumber(f float32) {
  20394. m.number = &f
  20395. m.addnumber = nil
  20396. }
  20397. // Number returns the value of the "number" field in the mutation.
  20398. func (m *PayRechargeMutation) Number() (r float32, exists bool) {
  20399. v := m.number
  20400. if v == nil {
  20401. return
  20402. }
  20403. return *v, true
  20404. }
  20405. // OldNumber returns the old "number" field's value of the PayRecharge entity.
  20406. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  20407. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20408. func (m *PayRechargeMutation) OldNumber(ctx context.Context) (v float32, err error) {
  20409. if !m.op.Is(OpUpdateOne) {
  20410. return v, errors.New("OldNumber is only allowed on UpdateOne operations")
  20411. }
  20412. if m.id == nil || m.oldValue == nil {
  20413. return v, errors.New("OldNumber requires an ID field in the mutation")
  20414. }
  20415. oldValue, err := m.oldValue(ctx)
  20416. if err != nil {
  20417. return v, fmt.Errorf("querying old value for OldNumber: %w", err)
  20418. }
  20419. return oldValue.Number, nil
  20420. }
  20421. // AddNumber adds f to the "number" field.
  20422. func (m *PayRechargeMutation) AddNumber(f float32) {
  20423. if m.addnumber != nil {
  20424. *m.addnumber += f
  20425. } else {
  20426. m.addnumber = &f
  20427. }
  20428. }
  20429. // AddedNumber returns the value that was added to the "number" field in this mutation.
  20430. func (m *PayRechargeMutation) AddedNumber() (r float32, exists bool) {
  20431. v := m.addnumber
  20432. if v == nil {
  20433. return
  20434. }
  20435. return *v, true
  20436. }
  20437. // ResetNumber resets all changes to the "number" field.
  20438. func (m *PayRechargeMutation) ResetNumber() {
  20439. m.number = nil
  20440. m.addnumber = nil
  20441. }
  20442. // SetStatus sets the "status" field.
  20443. func (m *PayRechargeMutation) SetStatus(i int) {
  20444. m.status = &i
  20445. m.addstatus = nil
  20446. }
  20447. // Status returns the value of the "status" field in the mutation.
  20448. func (m *PayRechargeMutation) Status() (r int, exists bool) {
  20449. v := m.status
  20450. if v == nil {
  20451. return
  20452. }
  20453. return *v, true
  20454. }
  20455. // OldStatus returns the old "status" field's value of the PayRecharge entity.
  20456. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  20457. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20458. func (m *PayRechargeMutation) OldStatus(ctx context.Context) (v int, err error) {
  20459. if !m.op.Is(OpUpdateOne) {
  20460. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  20461. }
  20462. if m.id == nil || m.oldValue == nil {
  20463. return v, errors.New("OldStatus requires an ID field in the mutation")
  20464. }
  20465. oldValue, err := m.oldValue(ctx)
  20466. if err != nil {
  20467. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  20468. }
  20469. return oldValue.Status, nil
  20470. }
  20471. // AddStatus adds i to the "status" field.
  20472. func (m *PayRechargeMutation) AddStatus(i int) {
  20473. if m.addstatus != nil {
  20474. *m.addstatus += i
  20475. } else {
  20476. m.addstatus = &i
  20477. }
  20478. }
  20479. // AddedStatus returns the value that was added to the "status" field in this mutation.
  20480. func (m *PayRechargeMutation) AddedStatus() (r int, exists bool) {
  20481. v := m.addstatus
  20482. if v == nil {
  20483. return
  20484. }
  20485. return *v, true
  20486. }
  20487. // ClearStatus clears the value of the "status" field.
  20488. func (m *PayRechargeMutation) ClearStatus() {
  20489. m.status = nil
  20490. m.addstatus = nil
  20491. m.clearedFields[payrecharge.FieldStatus] = struct{}{}
  20492. }
  20493. // StatusCleared returns if the "status" field was cleared in this mutation.
  20494. func (m *PayRechargeMutation) StatusCleared() bool {
  20495. _, ok := m.clearedFields[payrecharge.FieldStatus]
  20496. return ok
  20497. }
  20498. // ResetStatus resets all changes to the "status" field.
  20499. func (m *PayRechargeMutation) ResetStatus() {
  20500. m.status = nil
  20501. m.addstatus = nil
  20502. delete(m.clearedFields, payrecharge.FieldStatus)
  20503. }
  20504. // SetMoney sets the "money" field.
  20505. func (m *PayRechargeMutation) SetMoney(f float32) {
  20506. m.money = &f
  20507. m.addmoney = nil
  20508. }
  20509. // Money returns the value of the "money" field in the mutation.
  20510. func (m *PayRechargeMutation) Money() (r float32, exists bool) {
  20511. v := m.money
  20512. if v == nil {
  20513. return
  20514. }
  20515. return *v, true
  20516. }
  20517. // OldMoney returns the old "money" field's value of the PayRecharge entity.
  20518. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  20519. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20520. func (m *PayRechargeMutation) OldMoney(ctx context.Context) (v float32, err error) {
  20521. if !m.op.Is(OpUpdateOne) {
  20522. return v, errors.New("OldMoney is only allowed on UpdateOne operations")
  20523. }
  20524. if m.id == nil || m.oldValue == nil {
  20525. return v, errors.New("OldMoney requires an ID field in the mutation")
  20526. }
  20527. oldValue, err := m.oldValue(ctx)
  20528. if err != nil {
  20529. return v, fmt.Errorf("querying old value for OldMoney: %w", err)
  20530. }
  20531. return oldValue.Money, nil
  20532. }
  20533. // AddMoney adds f to the "money" field.
  20534. func (m *PayRechargeMutation) AddMoney(f float32) {
  20535. if m.addmoney != nil {
  20536. *m.addmoney += f
  20537. } else {
  20538. m.addmoney = &f
  20539. }
  20540. }
  20541. // AddedMoney returns the value that was added to the "money" field in this mutation.
  20542. func (m *PayRechargeMutation) AddedMoney() (r float32, exists bool) {
  20543. v := m.addmoney
  20544. if v == nil {
  20545. return
  20546. }
  20547. return *v, true
  20548. }
  20549. // ClearMoney clears the value of the "money" field.
  20550. func (m *PayRechargeMutation) ClearMoney() {
  20551. m.money = nil
  20552. m.addmoney = nil
  20553. m.clearedFields[payrecharge.FieldMoney] = struct{}{}
  20554. }
  20555. // MoneyCleared returns if the "money" field was cleared in this mutation.
  20556. func (m *PayRechargeMutation) MoneyCleared() bool {
  20557. _, ok := m.clearedFields[payrecharge.FieldMoney]
  20558. return ok
  20559. }
  20560. // ResetMoney resets all changes to the "money" field.
  20561. func (m *PayRechargeMutation) ResetMoney() {
  20562. m.money = nil
  20563. m.addmoney = nil
  20564. delete(m.clearedFields, payrecharge.FieldMoney)
  20565. }
  20566. // SetOutTradeNo sets the "out_trade_no" field.
  20567. func (m *PayRechargeMutation) SetOutTradeNo(s string) {
  20568. m.out_trade_no = &s
  20569. }
  20570. // OutTradeNo returns the value of the "out_trade_no" field in the mutation.
  20571. func (m *PayRechargeMutation) OutTradeNo() (r string, exists bool) {
  20572. v := m.out_trade_no
  20573. if v == nil {
  20574. return
  20575. }
  20576. return *v, true
  20577. }
  20578. // OldOutTradeNo returns the old "out_trade_no" field's value of the PayRecharge entity.
  20579. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  20580. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20581. func (m *PayRechargeMutation) OldOutTradeNo(ctx context.Context) (v string, err error) {
  20582. if !m.op.Is(OpUpdateOne) {
  20583. return v, errors.New("OldOutTradeNo is only allowed on UpdateOne operations")
  20584. }
  20585. if m.id == nil || m.oldValue == nil {
  20586. return v, errors.New("OldOutTradeNo requires an ID field in the mutation")
  20587. }
  20588. oldValue, err := m.oldValue(ctx)
  20589. if err != nil {
  20590. return v, fmt.Errorf("querying old value for OldOutTradeNo: %w", err)
  20591. }
  20592. return oldValue.OutTradeNo, nil
  20593. }
  20594. // ClearOutTradeNo clears the value of the "out_trade_no" field.
  20595. func (m *PayRechargeMutation) ClearOutTradeNo() {
  20596. m.out_trade_no = nil
  20597. m.clearedFields[payrecharge.FieldOutTradeNo] = struct{}{}
  20598. }
  20599. // OutTradeNoCleared returns if the "out_trade_no" field was cleared in this mutation.
  20600. func (m *PayRechargeMutation) OutTradeNoCleared() bool {
  20601. _, ok := m.clearedFields[payrecharge.FieldOutTradeNo]
  20602. return ok
  20603. }
  20604. // ResetOutTradeNo resets all changes to the "out_trade_no" field.
  20605. func (m *PayRechargeMutation) ResetOutTradeNo() {
  20606. m.out_trade_no = nil
  20607. delete(m.clearedFields, payrecharge.FieldOutTradeNo)
  20608. }
  20609. // SetOrganizationID sets the "organization_id" field.
  20610. func (m *PayRechargeMutation) SetOrganizationID(u uint64) {
  20611. m.organization_id = &u
  20612. m.addorganization_id = nil
  20613. }
  20614. // OrganizationID returns the value of the "organization_id" field in the mutation.
  20615. func (m *PayRechargeMutation) OrganizationID() (r uint64, exists bool) {
  20616. v := m.organization_id
  20617. if v == nil {
  20618. return
  20619. }
  20620. return *v, true
  20621. }
  20622. // OldOrganizationID returns the old "organization_id" field's value of the PayRecharge entity.
  20623. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  20624. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20625. func (m *PayRechargeMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  20626. if !m.op.Is(OpUpdateOne) {
  20627. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  20628. }
  20629. if m.id == nil || m.oldValue == nil {
  20630. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  20631. }
  20632. oldValue, err := m.oldValue(ctx)
  20633. if err != nil {
  20634. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  20635. }
  20636. return oldValue.OrganizationID, nil
  20637. }
  20638. // AddOrganizationID adds u to the "organization_id" field.
  20639. func (m *PayRechargeMutation) AddOrganizationID(u int64) {
  20640. if m.addorganization_id != nil {
  20641. *m.addorganization_id += u
  20642. } else {
  20643. m.addorganization_id = &u
  20644. }
  20645. }
  20646. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  20647. func (m *PayRechargeMutation) AddedOrganizationID() (r int64, exists bool) {
  20648. v := m.addorganization_id
  20649. if v == nil {
  20650. return
  20651. }
  20652. return *v, true
  20653. }
  20654. // ResetOrganizationID resets all changes to the "organization_id" field.
  20655. func (m *PayRechargeMutation) ResetOrganizationID() {
  20656. m.organization_id = nil
  20657. m.addorganization_id = nil
  20658. }
  20659. // Where appends a list predicates to the PayRechargeMutation builder.
  20660. func (m *PayRechargeMutation) Where(ps ...predicate.PayRecharge) {
  20661. m.predicates = append(m.predicates, ps...)
  20662. }
  20663. // WhereP appends storage-level predicates to the PayRechargeMutation builder. Using this method,
  20664. // users can use type-assertion to append predicates that do not depend on any generated package.
  20665. func (m *PayRechargeMutation) WhereP(ps ...func(*sql.Selector)) {
  20666. p := make([]predicate.PayRecharge, len(ps))
  20667. for i := range ps {
  20668. p[i] = ps[i]
  20669. }
  20670. m.Where(p...)
  20671. }
  20672. // Op returns the operation name.
  20673. func (m *PayRechargeMutation) Op() Op {
  20674. return m.op
  20675. }
  20676. // SetOp allows setting the mutation operation.
  20677. func (m *PayRechargeMutation) SetOp(op Op) {
  20678. m.op = op
  20679. }
  20680. // Type returns the node type of this mutation (PayRecharge).
  20681. func (m *PayRechargeMutation) Type() string {
  20682. return m.typ
  20683. }
  20684. // Fields returns all fields that were changed during this mutation. Note that in
  20685. // order to get all numeric fields that were incremented/decremented, call
  20686. // AddedFields().
  20687. func (m *PayRechargeMutation) Fields() []string {
  20688. fields := make([]string, 0, 9)
  20689. if m.created_at != nil {
  20690. fields = append(fields, payrecharge.FieldCreatedAt)
  20691. }
  20692. if m.updated_at != nil {
  20693. fields = append(fields, payrecharge.FieldUpdatedAt)
  20694. }
  20695. if m.deleted_at != nil {
  20696. fields = append(fields, payrecharge.FieldDeletedAt)
  20697. }
  20698. if m.user_id != nil {
  20699. fields = append(fields, payrecharge.FieldUserID)
  20700. }
  20701. if m.number != nil {
  20702. fields = append(fields, payrecharge.FieldNumber)
  20703. }
  20704. if m.status != nil {
  20705. fields = append(fields, payrecharge.FieldStatus)
  20706. }
  20707. if m.money != nil {
  20708. fields = append(fields, payrecharge.FieldMoney)
  20709. }
  20710. if m.out_trade_no != nil {
  20711. fields = append(fields, payrecharge.FieldOutTradeNo)
  20712. }
  20713. if m.organization_id != nil {
  20714. fields = append(fields, payrecharge.FieldOrganizationID)
  20715. }
  20716. return fields
  20717. }
  20718. // Field returns the value of a field with the given name. The second boolean
  20719. // return value indicates that this field was not set, or was not defined in the
  20720. // schema.
  20721. func (m *PayRechargeMutation) Field(name string) (ent.Value, bool) {
  20722. switch name {
  20723. case payrecharge.FieldCreatedAt:
  20724. return m.CreatedAt()
  20725. case payrecharge.FieldUpdatedAt:
  20726. return m.UpdatedAt()
  20727. case payrecharge.FieldDeletedAt:
  20728. return m.DeletedAt()
  20729. case payrecharge.FieldUserID:
  20730. return m.UserID()
  20731. case payrecharge.FieldNumber:
  20732. return m.Number()
  20733. case payrecharge.FieldStatus:
  20734. return m.Status()
  20735. case payrecharge.FieldMoney:
  20736. return m.Money()
  20737. case payrecharge.FieldOutTradeNo:
  20738. return m.OutTradeNo()
  20739. case payrecharge.FieldOrganizationID:
  20740. return m.OrganizationID()
  20741. }
  20742. return nil, false
  20743. }
  20744. // OldField returns the old value of the field from the database. An error is
  20745. // returned if the mutation operation is not UpdateOne, or the query to the
  20746. // database failed.
  20747. func (m *PayRechargeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  20748. switch name {
  20749. case payrecharge.FieldCreatedAt:
  20750. return m.OldCreatedAt(ctx)
  20751. case payrecharge.FieldUpdatedAt:
  20752. return m.OldUpdatedAt(ctx)
  20753. case payrecharge.FieldDeletedAt:
  20754. return m.OldDeletedAt(ctx)
  20755. case payrecharge.FieldUserID:
  20756. return m.OldUserID(ctx)
  20757. case payrecharge.FieldNumber:
  20758. return m.OldNumber(ctx)
  20759. case payrecharge.FieldStatus:
  20760. return m.OldStatus(ctx)
  20761. case payrecharge.FieldMoney:
  20762. return m.OldMoney(ctx)
  20763. case payrecharge.FieldOutTradeNo:
  20764. return m.OldOutTradeNo(ctx)
  20765. case payrecharge.FieldOrganizationID:
  20766. return m.OldOrganizationID(ctx)
  20767. }
  20768. return nil, fmt.Errorf("unknown PayRecharge field %s", name)
  20769. }
  20770. // SetField sets the value of a field with the given name. It returns an error if
  20771. // the field is not defined in the schema, or if the type mismatched the field
  20772. // type.
  20773. func (m *PayRechargeMutation) SetField(name string, value ent.Value) error {
  20774. switch name {
  20775. case payrecharge.FieldCreatedAt:
  20776. v, ok := value.(time.Time)
  20777. if !ok {
  20778. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20779. }
  20780. m.SetCreatedAt(v)
  20781. return nil
  20782. case payrecharge.FieldUpdatedAt:
  20783. v, ok := value.(time.Time)
  20784. if !ok {
  20785. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20786. }
  20787. m.SetUpdatedAt(v)
  20788. return nil
  20789. case payrecharge.FieldDeletedAt:
  20790. v, ok := value.(time.Time)
  20791. if !ok {
  20792. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20793. }
  20794. m.SetDeletedAt(v)
  20795. return nil
  20796. case payrecharge.FieldUserID:
  20797. v, ok := value.(string)
  20798. if !ok {
  20799. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20800. }
  20801. m.SetUserID(v)
  20802. return nil
  20803. case payrecharge.FieldNumber:
  20804. v, ok := value.(float32)
  20805. if !ok {
  20806. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20807. }
  20808. m.SetNumber(v)
  20809. return nil
  20810. case payrecharge.FieldStatus:
  20811. v, ok := value.(int)
  20812. if !ok {
  20813. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20814. }
  20815. m.SetStatus(v)
  20816. return nil
  20817. case payrecharge.FieldMoney:
  20818. v, ok := value.(float32)
  20819. if !ok {
  20820. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20821. }
  20822. m.SetMoney(v)
  20823. return nil
  20824. case payrecharge.FieldOutTradeNo:
  20825. v, ok := value.(string)
  20826. if !ok {
  20827. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20828. }
  20829. m.SetOutTradeNo(v)
  20830. return nil
  20831. case payrecharge.FieldOrganizationID:
  20832. v, ok := value.(uint64)
  20833. if !ok {
  20834. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20835. }
  20836. m.SetOrganizationID(v)
  20837. return nil
  20838. }
  20839. return fmt.Errorf("unknown PayRecharge field %s", name)
  20840. }
  20841. // AddedFields returns all numeric fields that were incremented/decremented during
  20842. // this mutation.
  20843. func (m *PayRechargeMutation) AddedFields() []string {
  20844. var fields []string
  20845. if m.addnumber != nil {
  20846. fields = append(fields, payrecharge.FieldNumber)
  20847. }
  20848. if m.addstatus != nil {
  20849. fields = append(fields, payrecharge.FieldStatus)
  20850. }
  20851. if m.addmoney != nil {
  20852. fields = append(fields, payrecharge.FieldMoney)
  20853. }
  20854. if m.addorganization_id != nil {
  20855. fields = append(fields, payrecharge.FieldOrganizationID)
  20856. }
  20857. return fields
  20858. }
  20859. // AddedField returns the numeric value that was incremented/decremented on a field
  20860. // with the given name. The second boolean return value indicates that this field
  20861. // was not set, or was not defined in the schema.
  20862. func (m *PayRechargeMutation) AddedField(name string) (ent.Value, bool) {
  20863. switch name {
  20864. case payrecharge.FieldNumber:
  20865. return m.AddedNumber()
  20866. case payrecharge.FieldStatus:
  20867. return m.AddedStatus()
  20868. case payrecharge.FieldMoney:
  20869. return m.AddedMoney()
  20870. case payrecharge.FieldOrganizationID:
  20871. return m.AddedOrganizationID()
  20872. }
  20873. return nil, false
  20874. }
  20875. // AddField adds the value to the field with the given name. It returns an error if
  20876. // the field is not defined in the schema, or if the type mismatched the field
  20877. // type.
  20878. func (m *PayRechargeMutation) AddField(name string, value ent.Value) error {
  20879. switch name {
  20880. case payrecharge.FieldNumber:
  20881. v, ok := value.(float32)
  20882. if !ok {
  20883. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20884. }
  20885. m.AddNumber(v)
  20886. return nil
  20887. case payrecharge.FieldStatus:
  20888. v, ok := value.(int)
  20889. if !ok {
  20890. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20891. }
  20892. m.AddStatus(v)
  20893. return nil
  20894. case payrecharge.FieldMoney:
  20895. v, ok := value.(float32)
  20896. if !ok {
  20897. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20898. }
  20899. m.AddMoney(v)
  20900. return nil
  20901. case payrecharge.FieldOrganizationID:
  20902. v, ok := value.(int64)
  20903. if !ok {
  20904. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20905. }
  20906. m.AddOrganizationID(v)
  20907. return nil
  20908. }
  20909. return fmt.Errorf("unknown PayRecharge numeric field %s", name)
  20910. }
  20911. // ClearedFields returns all nullable fields that were cleared during this
  20912. // mutation.
  20913. func (m *PayRechargeMutation) ClearedFields() []string {
  20914. var fields []string
  20915. if m.FieldCleared(payrecharge.FieldDeletedAt) {
  20916. fields = append(fields, payrecharge.FieldDeletedAt)
  20917. }
  20918. if m.FieldCleared(payrecharge.FieldStatus) {
  20919. fields = append(fields, payrecharge.FieldStatus)
  20920. }
  20921. if m.FieldCleared(payrecharge.FieldMoney) {
  20922. fields = append(fields, payrecharge.FieldMoney)
  20923. }
  20924. if m.FieldCleared(payrecharge.FieldOutTradeNo) {
  20925. fields = append(fields, payrecharge.FieldOutTradeNo)
  20926. }
  20927. return fields
  20928. }
  20929. // FieldCleared returns a boolean indicating if a field with the given name was
  20930. // cleared in this mutation.
  20931. func (m *PayRechargeMutation) FieldCleared(name string) bool {
  20932. _, ok := m.clearedFields[name]
  20933. return ok
  20934. }
  20935. // ClearField clears the value of the field with the given name. It returns an
  20936. // error if the field is not defined in the schema.
  20937. func (m *PayRechargeMutation) ClearField(name string) error {
  20938. switch name {
  20939. case payrecharge.FieldDeletedAt:
  20940. m.ClearDeletedAt()
  20941. return nil
  20942. case payrecharge.FieldStatus:
  20943. m.ClearStatus()
  20944. return nil
  20945. case payrecharge.FieldMoney:
  20946. m.ClearMoney()
  20947. return nil
  20948. case payrecharge.FieldOutTradeNo:
  20949. m.ClearOutTradeNo()
  20950. return nil
  20951. }
  20952. return fmt.Errorf("unknown PayRecharge nullable field %s", name)
  20953. }
  20954. // ResetField resets all changes in the mutation for the field with the given name.
  20955. // It returns an error if the field is not defined in the schema.
  20956. func (m *PayRechargeMutation) ResetField(name string) error {
  20957. switch name {
  20958. case payrecharge.FieldCreatedAt:
  20959. m.ResetCreatedAt()
  20960. return nil
  20961. case payrecharge.FieldUpdatedAt:
  20962. m.ResetUpdatedAt()
  20963. return nil
  20964. case payrecharge.FieldDeletedAt:
  20965. m.ResetDeletedAt()
  20966. return nil
  20967. case payrecharge.FieldUserID:
  20968. m.ResetUserID()
  20969. return nil
  20970. case payrecharge.FieldNumber:
  20971. m.ResetNumber()
  20972. return nil
  20973. case payrecharge.FieldStatus:
  20974. m.ResetStatus()
  20975. return nil
  20976. case payrecharge.FieldMoney:
  20977. m.ResetMoney()
  20978. return nil
  20979. case payrecharge.FieldOutTradeNo:
  20980. m.ResetOutTradeNo()
  20981. return nil
  20982. case payrecharge.FieldOrganizationID:
  20983. m.ResetOrganizationID()
  20984. return nil
  20985. }
  20986. return fmt.Errorf("unknown PayRecharge field %s", name)
  20987. }
  20988. // AddedEdges returns all edge names that were set/added in this mutation.
  20989. func (m *PayRechargeMutation) AddedEdges() []string {
  20990. edges := make([]string, 0, 0)
  20991. return edges
  20992. }
  20993. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  20994. // name in this mutation.
  20995. func (m *PayRechargeMutation) AddedIDs(name string) []ent.Value {
  20996. return nil
  20997. }
  20998. // RemovedEdges returns all edge names that were removed in this mutation.
  20999. func (m *PayRechargeMutation) RemovedEdges() []string {
  21000. edges := make([]string, 0, 0)
  21001. return edges
  21002. }
  21003. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  21004. // the given name in this mutation.
  21005. func (m *PayRechargeMutation) RemovedIDs(name string) []ent.Value {
  21006. return nil
  21007. }
  21008. // ClearedEdges returns all edge names that were cleared in this mutation.
  21009. func (m *PayRechargeMutation) ClearedEdges() []string {
  21010. edges := make([]string, 0, 0)
  21011. return edges
  21012. }
  21013. // EdgeCleared returns a boolean which indicates if the edge with the given name
  21014. // was cleared in this mutation.
  21015. func (m *PayRechargeMutation) EdgeCleared(name string) bool {
  21016. return false
  21017. }
  21018. // ClearEdge clears the value of the edge with the given name. It returns an error
  21019. // if that edge is not defined in the schema.
  21020. func (m *PayRechargeMutation) ClearEdge(name string) error {
  21021. return fmt.Errorf("unknown PayRecharge unique edge %s", name)
  21022. }
  21023. // ResetEdge resets all changes to the edge with the given name in this mutation.
  21024. // It returns an error if the edge is not defined in the schema.
  21025. func (m *PayRechargeMutation) ResetEdge(name string) error {
  21026. return fmt.Errorf("unknown PayRecharge edge %s", name)
  21027. }
  21028. // ServerMutation represents an operation that mutates the Server nodes in the graph.
  21029. type ServerMutation struct {
  21030. config
  21031. op Op
  21032. typ string
  21033. id *uint64
  21034. created_at *time.Time
  21035. updated_at *time.Time
  21036. status *uint8
  21037. addstatus *int8
  21038. deleted_at *time.Time
  21039. name *string
  21040. public_ip *string
  21041. private_ip *string
  21042. admin_port *string
  21043. clearedFields map[string]struct{}
  21044. wxs map[uint64]struct{}
  21045. removedwxs map[uint64]struct{}
  21046. clearedwxs bool
  21047. done bool
  21048. oldValue func(context.Context) (*Server, error)
  21049. predicates []predicate.Server
  21050. }
  21051. var _ ent.Mutation = (*ServerMutation)(nil)
  21052. // serverOption allows management of the mutation configuration using functional options.
  21053. type serverOption func(*ServerMutation)
  21054. // newServerMutation creates new mutation for the Server entity.
  21055. func newServerMutation(c config, op Op, opts ...serverOption) *ServerMutation {
  21056. m := &ServerMutation{
  21057. config: c,
  21058. op: op,
  21059. typ: TypeServer,
  21060. clearedFields: make(map[string]struct{}),
  21061. }
  21062. for _, opt := range opts {
  21063. opt(m)
  21064. }
  21065. return m
  21066. }
  21067. // withServerID sets the ID field of the mutation.
  21068. func withServerID(id uint64) serverOption {
  21069. return func(m *ServerMutation) {
  21070. var (
  21071. err error
  21072. once sync.Once
  21073. value *Server
  21074. )
  21075. m.oldValue = func(ctx context.Context) (*Server, error) {
  21076. once.Do(func() {
  21077. if m.done {
  21078. err = errors.New("querying old values post mutation is not allowed")
  21079. } else {
  21080. value, err = m.Client().Server.Get(ctx, id)
  21081. }
  21082. })
  21083. return value, err
  21084. }
  21085. m.id = &id
  21086. }
  21087. }
  21088. // withServer sets the old Server of the mutation.
  21089. func withServer(node *Server) serverOption {
  21090. return func(m *ServerMutation) {
  21091. m.oldValue = func(context.Context) (*Server, error) {
  21092. return node, nil
  21093. }
  21094. m.id = &node.ID
  21095. }
  21096. }
  21097. // Client returns a new `ent.Client` from the mutation. If the mutation was
  21098. // executed in a transaction (ent.Tx), a transactional client is returned.
  21099. func (m ServerMutation) Client() *Client {
  21100. client := &Client{config: m.config}
  21101. client.init()
  21102. return client
  21103. }
  21104. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  21105. // it returns an error otherwise.
  21106. func (m ServerMutation) Tx() (*Tx, error) {
  21107. if _, ok := m.driver.(*txDriver); !ok {
  21108. return nil, errors.New("ent: mutation is not running in a transaction")
  21109. }
  21110. tx := &Tx{config: m.config}
  21111. tx.init()
  21112. return tx, nil
  21113. }
  21114. // SetID sets the value of the id field. Note that this
  21115. // operation is only accepted on creation of Server entities.
  21116. func (m *ServerMutation) SetID(id uint64) {
  21117. m.id = &id
  21118. }
  21119. // ID returns the ID value in the mutation. Note that the ID is only available
  21120. // if it was provided to the builder or after it was returned from the database.
  21121. func (m *ServerMutation) ID() (id uint64, exists bool) {
  21122. if m.id == nil {
  21123. return
  21124. }
  21125. return *m.id, true
  21126. }
  21127. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  21128. // That means, if the mutation is applied within a transaction with an isolation level such
  21129. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  21130. // or updated by the mutation.
  21131. func (m *ServerMutation) IDs(ctx context.Context) ([]uint64, error) {
  21132. switch {
  21133. case m.op.Is(OpUpdateOne | OpDeleteOne):
  21134. id, exists := m.ID()
  21135. if exists {
  21136. return []uint64{id}, nil
  21137. }
  21138. fallthrough
  21139. case m.op.Is(OpUpdate | OpDelete):
  21140. return m.Client().Server.Query().Where(m.predicates...).IDs(ctx)
  21141. default:
  21142. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  21143. }
  21144. }
  21145. // SetCreatedAt sets the "created_at" field.
  21146. func (m *ServerMutation) SetCreatedAt(t time.Time) {
  21147. m.created_at = &t
  21148. }
  21149. // CreatedAt returns the value of the "created_at" field in the mutation.
  21150. func (m *ServerMutation) CreatedAt() (r time.Time, exists bool) {
  21151. v := m.created_at
  21152. if v == nil {
  21153. return
  21154. }
  21155. return *v, true
  21156. }
  21157. // OldCreatedAt returns the old "created_at" 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) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  21161. if !m.op.Is(OpUpdateOne) {
  21162. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  21163. }
  21164. if m.id == nil || m.oldValue == nil {
  21165. return v, errors.New("OldCreatedAt 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 OldCreatedAt: %w", err)
  21170. }
  21171. return oldValue.CreatedAt, nil
  21172. }
  21173. // ResetCreatedAt resets all changes to the "created_at" field.
  21174. func (m *ServerMutation) ResetCreatedAt() {
  21175. m.created_at = nil
  21176. }
  21177. // SetUpdatedAt sets the "updated_at" field.
  21178. func (m *ServerMutation) SetUpdatedAt(t time.Time) {
  21179. m.updated_at = &t
  21180. }
  21181. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  21182. func (m *ServerMutation) UpdatedAt() (r time.Time, exists bool) {
  21183. v := m.updated_at
  21184. if v == nil {
  21185. return
  21186. }
  21187. return *v, true
  21188. }
  21189. // OldUpdatedAt returns the old "updated_at" 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) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  21193. if !m.op.Is(OpUpdateOne) {
  21194. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  21195. }
  21196. if m.id == nil || m.oldValue == nil {
  21197. return v, errors.New("OldUpdatedAt 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 OldUpdatedAt: %w", err)
  21202. }
  21203. return oldValue.UpdatedAt, nil
  21204. }
  21205. // ResetUpdatedAt resets all changes to the "updated_at" field.
  21206. func (m *ServerMutation) ResetUpdatedAt() {
  21207. m.updated_at = nil
  21208. }
  21209. // SetStatus sets the "status" field.
  21210. func (m *ServerMutation) SetStatus(u uint8) {
  21211. m.status = &u
  21212. m.addstatus = nil
  21213. }
  21214. // Status returns the value of the "status" field in the mutation.
  21215. func (m *ServerMutation) Status() (r uint8, exists bool) {
  21216. v := m.status
  21217. if v == nil {
  21218. return
  21219. }
  21220. return *v, true
  21221. }
  21222. // OldStatus returns the old "status" field's value of the Server entity.
  21223. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  21224. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21225. func (m *ServerMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  21226. if !m.op.Is(OpUpdateOne) {
  21227. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  21228. }
  21229. if m.id == nil || m.oldValue == nil {
  21230. return v, errors.New("OldStatus requires an ID field in the mutation")
  21231. }
  21232. oldValue, err := m.oldValue(ctx)
  21233. if err != nil {
  21234. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  21235. }
  21236. return oldValue.Status, nil
  21237. }
  21238. // AddStatus adds u to the "status" field.
  21239. func (m *ServerMutation) AddStatus(u int8) {
  21240. if m.addstatus != nil {
  21241. *m.addstatus += u
  21242. } else {
  21243. m.addstatus = &u
  21244. }
  21245. }
  21246. // AddedStatus returns the value that was added to the "status" field in this mutation.
  21247. func (m *ServerMutation) AddedStatus() (r int8, exists bool) {
  21248. v := m.addstatus
  21249. if v == nil {
  21250. return
  21251. }
  21252. return *v, true
  21253. }
  21254. // ClearStatus clears the value of the "status" field.
  21255. func (m *ServerMutation) ClearStatus() {
  21256. m.status = nil
  21257. m.addstatus = nil
  21258. m.clearedFields[server.FieldStatus] = struct{}{}
  21259. }
  21260. // StatusCleared returns if the "status" field was cleared in this mutation.
  21261. func (m *ServerMutation) StatusCleared() bool {
  21262. _, ok := m.clearedFields[server.FieldStatus]
  21263. return ok
  21264. }
  21265. // ResetStatus resets all changes to the "status" field.
  21266. func (m *ServerMutation) ResetStatus() {
  21267. m.status = nil
  21268. m.addstatus = nil
  21269. delete(m.clearedFields, server.FieldStatus)
  21270. }
  21271. // SetDeletedAt sets the "deleted_at" field.
  21272. func (m *ServerMutation) SetDeletedAt(t time.Time) {
  21273. m.deleted_at = &t
  21274. }
  21275. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  21276. func (m *ServerMutation) DeletedAt() (r time.Time, exists bool) {
  21277. v := m.deleted_at
  21278. if v == nil {
  21279. return
  21280. }
  21281. return *v, true
  21282. }
  21283. // OldDeletedAt returns the old "deleted_at" field's value of the Server entity.
  21284. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  21285. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21286. func (m *ServerMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  21287. if !m.op.Is(OpUpdateOne) {
  21288. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  21289. }
  21290. if m.id == nil || m.oldValue == nil {
  21291. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  21292. }
  21293. oldValue, err := m.oldValue(ctx)
  21294. if err != nil {
  21295. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  21296. }
  21297. return oldValue.DeletedAt, nil
  21298. }
  21299. // ClearDeletedAt clears the value of the "deleted_at" field.
  21300. func (m *ServerMutation) ClearDeletedAt() {
  21301. m.deleted_at = nil
  21302. m.clearedFields[server.FieldDeletedAt] = struct{}{}
  21303. }
  21304. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  21305. func (m *ServerMutation) DeletedAtCleared() bool {
  21306. _, ok := m.clearedFields[server.FieldDeletedAt]
  21307. return ok
  21308. }
  21309. // ResetDeletedAt resets all changes to the "deleted_at" field.
  21310. func (m *ServerMutation) ResetDeletedAt() {
  21311. m.deleted_at = nil
  21312. delete(m.clearedFields, server.FieldDeletedAt)
  21313. }
  21314. // SetName sets the "name" field.
  21315. func (m *ServerMutation) SetName(s string) {
  21316. m.name = &s
  21317. }
  21318. // Name returns the value of the "name" field in the mutation.
  21319. func (m *ServerMutation) Name() (r string, exists bool) {
  21320. v := m.name
  21321. if v == nil {
  21322. return
  21323. }
  21324. return *v, true
  21325. }
  21326. // OldName returns the old "name" field's value of the Server entity.
  21327. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  21328. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21329. func (m *ServerMutation) OldName(ctx context.Context) (v string, err error) {
  21330. if !m.op.Is(OpUpdateOne) {
  21331. return v, errors.New("OldName is only allowed on UpdateOne operations")
  21332. }
  21333. if m.id == nil || m.oldValue == nil {
  21334. return v, errors.New("OldName requires an ID field in the mutation")
  21335. }
  21336. oldValue, err := m.oldValue(ctx)
  21337. if err != nil {
  21338. return v, fmt.Errorf("querying old value for OldName: %w", err)
  21339. }
  21340. return oldValue.Name, nil
  21341. }
  21342. // ResetName resets all changes to the "name" field.
  21343. func (m *ServerMutation) ResetName() {
  21344. m.name = nil
  21345. }
  21346. // SetPublicIP sets the "public_ip" field.
  21347. func (m *ServerMutation) SetPublicIP(s string) {
  21348. m.public_ip = &s
  21349. }
  21350. // PublicIP returns the value of the "public_ip" field in the mutation.
  21351. func (m *ServerMutation) PublicIP() (r string, exists bool) {
  21352. v := m.public_ip
  21353. if v == nil {
  21354. return
  21355. }
  21356. return *v, true
  21357. }
  21358. // OldPublicIP returns the old "public_ip" field's value of the Server entity.
  21359. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  21360. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21361. func (m *ServerMutation) OldPublicIP(ctx context.Context) (v string, err error) {
  21362. if !m.op.Is(OpUpdateOne) {
  21363. return v, errors.New("OldPublicIP is only allowed on UpdateOne operations")
  21364. }
  21365. if m.id == nil || m.oldValue == nil {
  21366. return v, errors.New("OldPublicIP requires an ID field in the mutation")
  21367. }
  21368. oldValue, err := m.oldValue(ctx)
  21369. if err != nil {
  21370. return v, fmt.Errorf("querying old value for OldPublicIP: %w", err)
  21371. }
  21372. return oldValue.PublicIP, nil
  21373. }
  21374. // ResetPublicIP resets all changes to the "public_ip" field.
  21375. func (m *ServerMutation) ResetPublicIP() {
  21376. m.public_ip = nil
  21377. }
  21378. // SetPrivateIP sets the "private_ip" field.
  21379. func (m *ServerMutation) SetPrivateIP(s string) {
  21380. m.private_ip = &s
  21381. }
  21382. // PrivateIP returns the value of the "private_ip" field in the mutation.
  21383. func (m *ServerMutation) PrivateIP() (r string, exists bool) {
  21384. v := m.private_ip
  21385. if v == nil {
  21386. return
  21387. }
  21388. return *v, true
  21389. }
  21390. // OldPrivateIP returns the old "private_ip" field's value of the Server entity.
  21391. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  21392. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21393. func (m *ServerMutation) OldPrivateIP(ctx context.Context) (v string, err error) {
  21394. if !m.op.Is(OpUpdateOne) {
  21395. return v, errors.New("OldPrivateIP is only allowed on UpdateOne operations")
  21396. }
  21397. if m.id == nil || m.oldValue == nil {
  21398. return v, errors.New("OldPrivateIP requires an ID field in the mutation")
  21399. }
  21400. oldValue, err := m.oldValue(ctx)
  21401. if err != nil {
  21402. return v, fmt.Errorf("querying old value for OldPrivateIP: %w", err)
  21403. }
  21404. return oldValue.PrivateIP, nil
  21405. }
  21406. // ResetPrivateIP resets all changes to the "private_ip" field.
  21407. func (m *ServerMutation) ResetPrivateIP() {
  21408. m.private_ip = nil
  21409. }
  21410. // SetAdminPort sets the "admin_port" field.
  21411. func (m *ServerMutation) SetAdminPort(s string) {
  21412. m.admin_port = &s
  21413. }
  21414. // AdminPort returns the value of the "admin_port" field in the mutation.
  21415. func (m *ServerMutation) AdminPort() (r string, exists bool) {
  21416. v := m.admin_port
  21417. if v == nil {
  21418. return
  21419. }
  21420. return *v, true
  21421. }
  21422. // OldAdminPort returns the old "admin_port" field's value of the Server entity.
  21423. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  21424. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21425. func (m *ServerMutation) OldAdminPort(ctx context.Context) (v string, err error) {
  21426. if !m.op.Is(OpUpdateOne) {
  21427. return v, errors.New("OldAdminPort is only allowed on UpdateOne operations")
  21428. }
  21429. if m.id == nil || m.oldValue == nil {
  21430. return v, errors.New("OldAdminPort requires an ID field in the mutation")
  21431. }
  21432. oldValue, err := m.oldValue(ctx)
  21433. if err != nil {
  21434. return v, fmt.Errorf("querying old value for OldAdminPort: %w", err)
  21435. }
  21436. return oldValue.AdminPort, nil
  21437. }
  21438. // ResetAdminPort resets all changes to the "admin_port" field.
  21439. func (m *ServerMutation) ResetAdminPort() {
  21440. m.admin_port = nil
  21441. }
  21442. // AddWxIDs adds the "wxs" edge to the Wx entity by ids.
  21443. func (m *ServerMutation) AddWxIDs(ids ...uint64) {
  21444. if m.wxs == nil {
  21445. m.wxs = make(map[uint64]struct{})
  21446. }
  21447. for i := range ids {
  21448. m.wxs[ids[i]] = struct{}{}
  21449. }
  21450. }
  21451. // ClearWxs clears the "wxs" edge to the Wx entity.
  21452. func (m *ServerMutation) ClearWxs() {
  21453. m.clearedwxs = true
  21454. }
  21455. // WxsCleared reports if the "wxs" edge to the Wx entity was cleared.
  21456. func (m *ServerMutation) WxsCleared() bool {
  21457. return m.clearedwxs
  21458. }
  21459. // RemoveWxIDs removes the "wxs" edge to the Wx entity by IDs.
  21460. func (m *ServerMutation) RemoveWxIDs(ids ...uint64) {
  21461. if m.removedwxs == nil {
  21462. m.removedwxs = make(map[uint64]struct{})
  21463. }
  21464. for i := range ids {
  21465. delete(m.wxs, ids[i])
  21466. m.removedwxs[ids[i]] = struct{}{}
  21467. }
  21468. }
  21469. // RemovedWxs returns the removed IDs of the "wxs" edge to the Wx entity.
  21470. func (m *ServerMutation) RemovedWxsIDs() (ids []uint64) {
  21471. for id := range m.removedwxs {
  21472. ids = append(ids, id)
  21473. }
  21474. return
  21475. }
  21476. // WxsIDs returns the "wxs" edge IDs in the mutation.
  21477. func (m *ServerMutation) WxsIDs() (ids []uint64) {
  21478. for id := range m.wxs {
  21479. ids = append(ids, id)
  21480. }
  21481. return
  21482. }
  21483. // ResetWxs resets all changes to the "wxs" edge.
  21484. func (m *ServerMutation) ResetWxs() {
  21485. m.wxs = nil
  21486. m.clearedwxs = false
  21487. m.removedwxs = nil
  21488. }
  21489. // Where appends a list predicates to the ServerMutation builder.
  21490. func (m *ServerMutation) Where(ps ...predicate.Server) {
  21491. m.predicates = append(m.predicates, ps...)
  21492. }
  21493. // WhereP appends storage-level predicates to the ServerMutation builder. Using this method,
  21494. // users can use type-assertion to append predicates that do not depend on any generated package.
  21495. func (m *ServerMutation) WhereP(ps ...func(*sql.Selector)) {
  21496. p := make([]predicate.Server, len(ps))
  21497. for i := range ps {
  21498. p[i] = ps[i]
  21499. }
  21500. m.Where(p...)
  21501. }
  21502. // Op returns the operation name.
  21503. func (m *ServerMutation) Op() Op {
  21504. return m.op
  21505. }
  21506. // SetOp allows setting the mutation operation.
  21507. func (m *ServerMutation) SetOp(op Op) {
  21508. m.op = op
  21509. }
  21510. // Type returns the node type of this mutation (Server).
  21511. func (m *ServerMutation) Type() string {
  21512. return m.typ
  21513. }
  21514. // Fields returns all fields that were changed during this mutation. Note that in
  21515. // order to get all numeric fields that were incremented/decremented, call
  21516. // AddedFields().
  21517. func (m *ServerMutation) Fields() []string {
  21518. fields := make([]string, 0, 8)
  21519. if m.created_at != nil {
  21520. fields = append(fields, server.FieldCreatedAt)
  21521. }
  21522. if m.updated_at != nil {
  21523. fields = append(fields, server.FieldUpdatedAt)
  21524. }
  21525. if m.status != nil {
  21526. fields = append(fields, server.FieldStatus)
  21527. }
  21528. if m.deleted_at != nil {
  21529. fields = append(fields, server.FieldDeletedAt)
  21530. }
  21531. if m.name != nil {
  21532. fields = append(fields, server.FieldName)
  21533. }
  21534. if m.public_ip != nil {
  21535. fields = append(fields, server.FieldPublicIP)
  21536. }
  21537. if m.private_ip != nil {
  21538. fields = append(fields, server.FieldPrivateIP)
  21539. }
  21540. if m.admin_port != nil {
  21541. fields = append(fields, server.FieldAdminPort)
  21542. }
  21543. return fields
  21544. }
  21545. // Field returns the value of a field with the given name. The second boolean
  21546. // return value indicates that this field was not set, or was not defined in the
  21547. // schema.
  21548. func (m *ServerMutation) Field(name string) (ent.Value, bool) {
  21549. switch name {
  21550. case server.FieldCreatedAt:
  21551. return m.CreatedAt()
  21552. case server.FieldUpdatedAt:
  21553. return m.UpdatedAt()
  21554. case server.FieldStatus:
  21555. return m.Status()
  21556. case server.FieldDeletedAt:
  21557. return m.DeletedAt()
  21558. case server.FieldName:
  21559. return m.Name()
  21560. case server.FieldPublicIP:
  21561. return m.PublicIP()
  21562. case server.FieldPrivateIP:
  21563. return m.PrivateIP()
  21564. case server.FieldAdminPort:
  21565. return m.AdminPort()
  21566. }
  21567. return nil, false
  21568. }
  21569. // OldField returns the old value of the field from the database. An error is
  21570. // returned if the mutation operation is not UpdateOne, or the query to the
  21571. // database failed.
  21572. func (m *ServerMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  21573. switch name {
  21574. case server.FieldCreatedAt:
  21575. return m.OldCreatedAt(ctx)
  21576. case server.FieldUpdatedAt:
  21577. return m.OldUpdatedAt(ctx)
  21578. case server.FieldStatus:
  21579. return m.OldStatus(ctx)
  21580. case server.FieldDeletedAt:
  21581. return m.OldDeletedAt(ctx)
  21582. case server.FieldName:
  21583. return m.OldName(ctx)
  21584. case server.FieldPublicIP:
  21585. return m.OldPublicIP(ctx)
  21586. case server.FieldPrivateIP:
  21587. return m.OldPrivateIP(ctx)
  21588. case server.FieldAdminPort:
  21589. return m.OldAdminPort(ctx)
  21590. }
  21591. return nil, fmt.Errorf("unknown Server field %s", name)
  21592. }
  21593. // SetField sets the value of a field with the given name. It returns an error if
  21594. // the field is not defined in the schema, or if the type mismatched the field
  21595. // type.
  21596. func (m *ServerMutation) SetField(name string, value ent.Value) error {
  21597. switch name {
  21598. case server.FieldCreatedAt:
  21599. v, ok := value.(time.Time)
  21600. if !ok {
  21601. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21602. }
  21603. m.SetCreatedAt(v)
  21604. return nil
  21605. case server.FieldUpdatedAt:
  21606. v, ok := value.(time.Time)
  21607. if !ok {
  21608. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21609. }
  21610. m.SetUpdatedAt(v)
  21611. return nil
  21612. case server.FieldStatus:
  21613. v, ok := value.(uint8)
  21614. if !ok {
  21615. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21616. }
  21617. m.SetStatus(v)
  21618. return nil
  21619. case server.FieldDeletedAt:
  21620. v, ok := value.(time.Time)
  21621. if !ok {
  21622. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21623. }
  21624. m.SetDeletedAt(v)
  21625. return nil
  21626. case server.FieldName:
  21627. v, ok := value.(string)
  21628. if !ok {
  21629. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21630. }
  21631. m.SetName(v)
  21632. return nil
  21633. case server.FieldPublicIP:
  21634. v, ok := value.(string)
  21635. if !ok {
  21636. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21637. }
  21638. m.SetPublicIP(v)
  21639. return nil
  21640. case server.FieldPrivateIP:
  21641. v, ok := value.(string)
  21642. if !ok {
  21643. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21644. }
  21645. m.SetPrivateIP(v)
  21646. return nil
  21647. case server.FieldAdminPort:
  21648. v, ok := value.(string)
  21649. if !ok {
  21650. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21651. }
  21652. m.SetAdminPort(v)
  21653. return nil
  21654. }
  21655. return fmt.Errorf("unknown Server field %s", name)
  21656. }
  21657. // AddedFields returns all numeric fields that were incremented/decremented during
  21658. // this mutation.
  21659. func (m *ServerMutation) AddedFields() []string {
  21660. var fields []string
  21661. if m.addstatus != nil {
  21662. fields = append(fields, server.FieldStatus)
  21663. }
  21664. return fields
  21665. }
  21666. // AddedField returns the numeric value that was incremented/decremented on a field
  21667. // with the given name. The second boolean return value indicates that this field
  21668. // was not set, or was not defined in the schema.
  21669. func (m *ServerMutation) AddedField(name string) (ent.Value, bool) {
  21670. switch name {
  21671. case server.FieldStatus:
  21672. return m.AddedStatus()
  21673. }
  21674. return nil, false
  21675. }
  21676. // AddField adds the value to the field with the given name. It returns an error if
  21677. // the field is not defined in the schema, or if the type mismatched the field
  21678. // type.
  21679. func (m *ServerMutation) AddField(name string, value ent.Value) error {
  21680. switch name {
  21681. case server.FieldStatus:
  21682. v, ok := value.(int8)
  21683. if !ok {
  21684. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21685. }
  21686. m.AddStatus(v)
  21687. return nil
  21688. }
  21689. return fmt.Errorf("unknown Server numeric field %s", name)
  21690. }
  21691. // ClearedFields returns all nullable fields that were cleared during this
  21692. // mutation.
  21693. func (m *ServerMutation) ClearedFields() []string {
  21694. var fields []string
  21695. if m.FieldCleared(server.FieldStatus) {
  21696. fields = append(fields, server.FieldStatus)
  21697. }
  21698. if m.FieldCleared(server.FieldDeletedAt) {
  21699. fields = append(fields, server.FieldDeletedAt)
  21700. }
  21701. return fields
  21702. }
  21703. // FieldCleared returns a boolean indicating if a field with the given name was
  21704. // cleared in this mutation.
  21705. func (m *ServerMutation) FieldCleared(name string) bool {
  21706. _, ok := m.clearedFields[name]
  21707. return ok
  21708. }
  21709. // ClearField clears the value of the field with the given name. It returns an
  21710. // error if the field is not defined in the schema.
  21711. func (m *ServerMutation) ClearField(name string) error {
  21712. switch name {
  21713. case server.FieldStatus:
  21714. m.ClearStatus()
  21715. return nil
  21716. case server.FieldDeletedAt:
  21717. m.ClearDeletedAt()
  21718. return nil
  21719. }
  21720. return fmt.Errorf("unknown Server nullable field %s", name)
  21721. }
  21722. // ResetField resets all changes in the mutation for the field with the given name.
  21723. // It returns an error if the field is not defined in the schema.
  21724. func (m *ServerMutation) ResetField(name string) error {
  21725. switch name {
  21726. case server.FieldCreatedAt:
  21727. m.ResetCreatedAt()
  21728. return nil
  21729. case server.FieldUpdatedAt:
  21730. m.ResetUpdatedAt()
  21731. return nil
  21732. case server.FieldStatus:
  21733. m.ResetStatus()
  21734. return nil
  21735. case server.FieldDeletedAt:
  21736. m.ResetDeletedAt()
  21737. return nil
  21738. case server.FieldName:
  21739. m.ResetName()
  21740. return nil
  21741. case server.FieldPublicIP:
  21742. m.ResetPublicIP()
  21743. return nil
  21744. case server.FieldPrivateIP:
  21745. m.ResetPrivateIP()
  21746. return nil
  21747. case server.FieldAdminPort:
  21748. m.ResetAdminPort()
  21749. return nil
  21750. }
  21751. return fmt.Errorf("unknown Server field %s", name)
  21752. }
  21753. // AddedEdges returns all edge names that were set/added in this mutation.
  21754. func (m *ServerMutation) AddedEdges() []string {
  21755. edges := make([]string, 0, 1)
  21756. if m.wxs != nil {
  21757. edges = append(edges, server.EdgeWxs)
  21758. }
  21759. return edges
  21760. }
  21761. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  21762. // name in this mutation.
  21763. func (m *ServerMutation) AddedIDs(name string) []ent.Value {
  21764. switch name {
  21765. case server.EdgeWxs:
  21766. ids := make([]ent.Value, 0, len(m.wxs))
  21767. for id := range m.wxs {
  21768. ids = append(ids, id)
  21769. }
  21770. return ids
  21771. }
  21772. return nil
  21773. }
  21774. // RemovedEdges returns all edge names that were removed in this mutation.
  21775. func (m *ServerMutation) RemovedEdges() []string {
  21776. edges := make([]string, 0, 1)
  21777. if m.removedwxs != nil {
  21778. edges = append(edges, server.EdgeWxs)
  21779. }
  21780. return edges
  21781. }
  21782. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  21783. // the given name in this mutation.
  21784. func (m *ServerMutation) RemovedIDs(name string) []ent.Value {
  21785. switch name {
  21786. case server.EdgeWxs:
  21787. ids := make([]ent.Value, 0, len(m.removedwxs))
  21788. for id := range m.removedwxs {
  21789. ids = append(ids, id)
  21790. }
  21791. return ids
  21792. }
  21793. return nil
  21794. }
  21795. // ClearedEdges returns all edge names that were cleared in this mutation.
  21796. func (m *ServerMutation) ClearedEdges() []string {
  21797. edges := make([]string, 0, 1)
  21798. if m.clearedwxs {
  21799. edges = append(edges, server.EdgeWxs)
  21800. }
  21801. return edges
  21802. }
  21803. // EdgeCleared returns a boolean which indicates if the edge with the given name
  21804. // was cleared in this mutation.
  21805. func (m *ServerMutation) EdgeCleared(name string) bool {
  21806. switch name {
  21807. case server.EdgeWxs:
  21808. return m.clearedwxs
  21809. }
  21810. return false
  21811. }
  21812. // ClearEdge clears the value of the edge with the given name. It returns an error
  21813. // if that edge is not defined in the schema.
  21814. func (m *ServerMutation) ClearEdge(name string) error {
  21815. switch name {
  21816. }
  21817. return fmt.Errorf("unknown Server unique edge %s", name)
  21818. }
  21819. // ResetEdge resets all changes to the edge with the given name in this mutation.
  21820. // It returns an error if the edge is not defined in the schema.
  21821. func (m *ServerMutation) ResetEdge(name string) error {
  21822. switch name {
  21823. case server.EdgeWxs:
  21824. m.ResetWxs()
  21825. return nil
  21826. }
  21827. return fmt.Errorf("unknown Server edge %s", name)
  21828. }
  21829. // SopNodeMutation represents an operation that mutates the SopNode nodes in the graph.
  21830. type SopNodeMutation struct {
  21831. config
  21832. op Op
  21833. typ string
  21834. id *uint64
  21835. created_at *time.Time
  21836. updated_at *time.Time
  21837. status *uint8
  21838. addstatus *int8
  21839. deleted_at *time.Time
  21840. parent_id *uint64
  21841. addparent_id *int64
  21842. name *string
  21843. condition_type *int
  21844. addcondition_type *int
  21845. condition_list *[]string
  21846. appendcondition_list []string
  21847. no_reply_condition *uint64
  21848. addno_reply_condition *int64
  21849. no_reply_unit *string
  21850. action_message *[]custom_types.Action
  21851. appendaction_message []custom_types.Action
  21852. action_label_add *[]uint64
  21853. appendaction_label_add []uint64
  21854. action_label_del *[]uint64
  21855. appendaction_label_del []uint64
  21856. action_forward **custom_types.ActionForward
  21857. clearedFields map[string]struct{}
  21858. sop_stage *uint64
  21859. clearedsop_stage bool
  21860. node_messages map[uint64]struct{}
  21861. removednode_messages map[uint64]struct{}
  21862. clearednode_messages bool
  21863. done bool
  21864. oldValue func(context.Context) (*SopNode, error)
  21865. predicates []predicate.SopNode
  21866. }
  21867. var _ ent.Mutation = (*SopNodeMutation)(nil)
  21868. // sopnodeOption allows management of the mutation configuration using functional options.
  21869. type sopnodeOption func(*SopNodeMutation)
  21870. // newSopNodeMutation creates new mutation for the SopNode entity.
  21871. func newSopNodeMutation(c config, op Op, opts ...sopnodeOption) *SopNodeMutation {
  21872. m := &SopNodeMutation{
  21873. config: c,
  21874. op: op,
  21875. typ: TypeSopNode,
  21876. clearedFields: make(map[string]struct{}),
  21877. }
  21878. for _, opt := range opts {
  21879. opt(m)
  21880. }
  21881. return m
  21882. }
  21883. // withSopNodeID sets the ID field of the mutation.
  21884. func withSopNodeID(id uint64) sopnodeOption {
  21885. return func(m *SopNodeMutation) {
  21886. var (
  21887. err error
  21888. once sync.Once
  21889. value *SopNode
  21890. )
  21891. m.oldValue = func(ctx context.Context) (*SopNode, error) {
  21892. once.Do(func() {
  21893. if m.done {
  21894. err = errors.New("querying old values post mutation is not allowed")
  21895. } else {
  21896. value, err = m.Client().SopNode.Get(ctx, id)
  21897. }
  21898. })
  21899. return value, err
  21900. }
  21901. m.id = &id
  21902. }
  21903. }
  21904. // withSopNode sets the old SopNode of the mutation.
  21905. func withSopNode(node *SopNode) sopnodeOption {
  21906. return func(m *SopNodeMutation) {
  21907. m.oldValue = func(context.Context) (*SopNode, error) {
  21908. return node, nil
  21909. }
  21910. m.id = &node.ID
  21911. }
  21912. }
  21913. // Client returns a new `ent.Client` from the mutation. If the mutation was
  21914. // executed in a transaction (ent.Tx), a transactional client is returned.
  21915. func (m SopNodeMutation) Client() *Client {
  21916. client := &Client{config: m.config}
  21917. client.init()
  21918. return client
  21919. }
  21920. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  21921. // it returns an error otherwise.
  21922. func (m SopNodeMutation) Tx() (*Tx, error) {
  21923. if _, ok := m.driver.(*txDriver); !ok {
  21924. return nil, errors.New("ent: mutation is not running in a transaction")
  21925. }
  21926. tx := &Tx{config: m.config}
  21927. tx.init()
  21928. return tx, nil
  21929. }
  21930. // SetID sets the value of the id field. Note that this
  21931. // operation is only accepted on creation of SopNode entities.
  21932. func (m *SopNodeMutation) SetID(id uint64) {
  21933. m.id = &id
  21934. }
  21935. // ID returns the ID value in the mutation. Note that the ID is only available
  21936. // if it was provided to the builder or after it was returned from the database.
  21937. func (m *SopNodeMutation) ID() (id uint64, exists bool) {
  21938. if m.id == nil {
  21939. return
  21940. }
  21941. return *m.id, true
  21942. }
  21943. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  21944. // That means, if the mutation is applied within a transaction with an isolation level such
  21945. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  21946. // or updated by the mutation.
  21947. func (m *SopNodeMutation) IDs(ctx context.Context) ([]uint64, error) {
  21948. switch {
  21949. case m.op.Is(OpUpdateOne | OpDeleteOne):
  21950. id, exists := m.ID()
  21951. if exists {
  21952. return []uint64{id}, nil
  21953. }
  21954. fallthrough
  21955. case m.op.Is(OpUpdate | OpDelete):
  21956. return m.Client().SopNode.Query().Where(m.predicates...).IDs(ctx)
  21957. default:
  21958. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  21959. }
  21960. }
  21961. // SetCreatedAt sets the "created_at" field.
  21962. func (m *SopNodeMutation) SetCreatedAt(t time.Time) {
  21963. m.created_at = &t
  21964. }
  21965. // CreatedAt returns the value of the "created_at" field in the mutation.
  21966. func (m *SopNodeMutation) CreatedAt() (r time.Time, exists bool) {
  21967. v := m.created_at
  21968. if v == nil {
  21969. return
  21970. }
  21971. return *v, true
  21972. }
  21973. // OldCreatedAt returns the old "created_at" field's value of the SopNode entity.
  21974. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21975. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21976. func (m *SopNodeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  21977. if !m.op.Is(OpUpdateOne) {
  21978. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  21979. }
  21980. if m.id == nil || m.oldValue == nil {
  21981. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  21982. }
  21983. oldValue, err := m.oldValue(ctx)
  21984. if err != nil {
  21985. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  21986. }
  21987. return oldValue.CreatedAt, nil
  21988. }
  21989. // ResetCreatedAt resets all changes to the "created_at" field.
  21990. func (m *SopNodeMutation) ResetCreatedAt() {
  21991. m.created_at = nil
  21992. }
  21993. // SetUpdatedAt sets the "updated_at" field.
  21994. func (m *SopNodeMutation) SetUpdatedAt(t time.Time) {
  21995. m.updated_at = &t
  21996. }
  21997. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  21998. func (m *SopNodeMutation) UpdatedAt() (r time.Time, exists bool) {
  21999. v := m.updated_at
  22000. if v == nil {
  22001. return
  22002. }
  22003. return *v, true
  22004. }
  22005. // OldUpdatedAt returns the old "updated_at" field's value of the SopNode entity.
  22006. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  22007. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22008. func (m *SopNodeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  22009. if !m.op.Is(OpUpdateOne) {
  22010. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  22011. }
  22012. if m.id == nil || m.oldValue == nil {
  22013. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  22014. }
  22015. oldValue, err := m.oldValue(ctx)
  22016. if err != nil {
  22017. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  22018. }
  22019. return oldValue.UpdatedAt, nil
  22020. }
  22021. // ResetUpdatedAt resets all changes to the "updated_at" field.
  22022. func (m *SopNodeMutation) ResetUpdatedAt() {
  22023. m.updated_at = nil
  22024. }
  22025. // SetStatus sets the "status" field.
  22026. func (m *SopNodeMutation) SetStatus(u uint8) {
  22027. m.status = &u
  22028. m.addstatus = nil
  22029. }
  22030. // Status returns the value of the "status" field in the mutation.
  22031. func (m *SopNodeMutation) Status() (r uint8, exists bool) {
  22032. v := m.status
  22033. if v == nil {
  22034. return
  22035. }
  22036. return *v, true
  22037. }
  22038. // OldStatus returns the old "status" field's value of the SopNode entity.
  22039. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  22040. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22041. func (m *SopNodeMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  22042. if !m.op.Is(OpUpdateOne) {
  22043. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  22044. }
  22045. if m.id == nil || m.oldValue == nil {
  22046. return v, errors.New("OldStatus requires an ID field in the mutation")
  22047. }
  22048. oldValue, err := m.oldValue(ctx)
  22049. if err != nil {
  22050. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  22051. }
  22052. return oldValue.Status, nil
  22053. }
  22054. // AddStatus adds u to the "status" field.
  22055. func (m *SopNodeMutation) AddStatus(u int8) {
  22056. if m.addstatus != nil {
  22057. *m.addstatus += u
  22058. } else {
  22059. m.addstatus = &u
  22060. }
  22061. }
  22062. // AddedStatus returns the value that was added to the "status" field in this mutation.
  22063. func (m *SopNodeMutation) AddedStatus() (r int8, exists bool) {
  22064. v := m.addstatus
  22065. if v == nil {
  22066. return
  22067. }
  22068. return *v, true
  22069. }
  22070. // ClearStatus clears the value of the "status" field.
  22071. func (m *SopNodeMutation) ClearStatus() {
  22072. m.status = nil
  22073. m.addstatus = nil
  22074. m.clearedFields[sopnode.FieldStatus] = struct{}{}
  22075. }
  22076. // StatusCleared returns if the "status" field was cleared in this mutation.
  22077. func (m *SopNodeMutation) StatusCleared() bool {
  22078. _, ok := m.clearedFields[sopnode.FieldStatus]
  22079. return ok
  22080. }
  22081. // ResetStatus resets all changes to the "status" field.
  22082. func (m *SopNodeMutation) ResetStatus() {
  22083. m.status = nil
  22084. m.addstatus = nil
  22085. delete(m.clearedFields, sopnode.FieldStatus)
  22086. }
  22087. // SetDeletedAt sets the "deleted_at" field.
  22088. func (m *SopNodeMutation) SetDeletedAt(t time.Time) {
  22089. m.deleted_at = &t
  22090. }
  22091. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  22092. func (m *SopNodeMutation) DeletedAt() (r time.Time, exists bool) {
  22093. v := m.deleted_at
  22094. if v == nil {
  22095. return
  22096. }
  22097. return *v, true
  22098. }
  22099. // OldDeletedAt returns the old "deleted_at" field's value of the SopNode entity.
  22100. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  22101. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22102. func (m *SopNodeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  22103. if !m.op.Is(OpUpdateOne) {
  22104. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  22105. }
  22106. if m.id == nil || m.oldValue == nil {
  22107. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  22108. }
  22109. oldValue, err := m.oldValue(ctx)
  22110. if err != nil {
  22111. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  22112. }
  22113. return oldValue.DeletedAt, nil
  22114. }
  22115. // ClearDeletedAt clears the value of the "deleted_at" field.
  22116. func (m *SopNodeMutation) ClearDeletedAt() {
  22117. m.deleted_at = nil
  22118. m.clearedFields[sopnode.FieldDeletedAt] = struct{}{}
  22119. }
  22120. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  22121. func (m *SopNodeMutation) DeletedAtCleared() bool {
  22122. _, ok := m.clearedFields[sopnode.FieldDeletedAt]
  22123. return ok
  22124. }
  22125. // ResetDeletedAt resets all changes to the "deleted_at" field.
  22126. func (m *SopNodeMutation) ResetDeletedAt() {
  22127. m.deleted_at = nil
  22128. delete(m.clearedFields, sopnode.FieldDeletedAt)
  22129. }
  22130. // SetStageID sets the "stage_id" field.
  22131. func (m *SopNodeMutation) SetStageID(u uint64) {
  22132. m.sop_stage = &u
  22133. }
  22134. // StageID returns the value of the "stage_id" field in the mutation.
  22135. func (m *SopNodeMutation) StageID() (r uint64, exists bool) {
  22136. v := m.sop_stage
  22137. if v == nil {
  22138. return
  22139. }
  22140. return *v, true
  22141. }
  22142. // OldStageID returns the old "stage_id" field's value of the SopNode entity.
  22143. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  22144. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22145. func (m *SopNodeMutation) OldStageID(ctx context.Context) (v uint64, err error) {
  22146. if !m.op.Is(OpUpdateOne) {
  22147. return v, errors.New("OldStageID is only allowed on UpdateOne operations")
  22148. }
  22149. if m.id == nil || m.oldValue == nil {
  22150. return v, errors.New("OldStageID requires an ID field in the mutation")
  22151. }
  22152. oldValue, err := m.oldValue(ctx)
  22153. if err != nil {
  22154. return v, fmt.Errorf("querying old value for OldStageID: %w", err)
  22155. }
  22156. return oldValue.StageID, nil
  22157. }
  22158. // ResetStageID resets all changes to the "stage_id" field.
  22159. func (m *SopNodeMutation) ResetStageID() {
  22160. m.sop_stage = nil
  22161. }
  22162. // SetParentID sets the "parent_id" field.
  22163. func (m *SopNodeMutation) SetParentID(u uint64) {
  22164. m.parent_id = &u
  22165. m.addparent_id = nil
  22166. }
  22167. // ParentID returns the value of the "parent_id" field in the mutation.
  22168. func (m *SopNodeMutation) ParentID() (r uint64, exists bool) {
  22169. v := m.parent_id
  22170. if v == nil {
  22171. return
  22172. }
  22173. return *v, true
  22174. }
  22175. // OldParentID returns the old "parent_id" field's value of the SopNode entity.
  22176. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  22177. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22178. func (m *SopNodeMutation) OldParentID(ctx context.Context) (v uint64, err error) {
  22179. if !m.op.Is(OpUpdateOne) {
  22180. return v, errors.New("OldParentID is only allowed on UpdateOne operations")
  22181. }
  22182. if m.id == nil || m.oldValue == nil {
  22183. return v, errors.New("OldParentID requires an ID field in the mutation")
  22184. }
  22185. oldValue, err := m.oldValue(ctx)
  22186. if err != nil {
  22187. return v, fmt.Errorf("querying old value for OldParentID: %w", err)
  22188. }
  22189. return oldValue.ParentID, nil
  22190. }
  22191. // AddParentID adds u to the "parent_id" field.
  22192. func (m *SopNodeMutation) AddParentID(u int64) {
  22193. if m.addparent_id != nil {
  22194. *m.addparent_id += u
  22195. } else {
  22196. m.addparent_id = &u
  22197. }
  22198. }
  22199. // AddedParentID returns the value that was added to the "parent_id" field in this mutation.
  22200. func (m *SopNodeMutation) AddedParentID() (r int64, exists bool) {
  22201. v := m.addparent_id
  22202. if v == nil {
  22203. return
  22204. }
  22205. return *v, true
  22206. }
  22207. // ResetParentID resets all changes to the "parent_id" field.
  22208. func (m *SopNodeMutation) ResetParentID() {
  22209. m.parent_id = nil
  22210. m.addparent_id = nil
  22211. }
  22212. // SetName sets the "name" field.
  22213. func (m *SopNodeMutation) SetName(s string) {
  22214. m.name = &s
  22215. }
  22216. // Name returns the value of the "name" field in the mutation.
  22217. func (m *SopNodeMutation) Name() (r string, exists bool) {
  22218. v := m.name
  22219. if v == nil {
  22220. return
  22221. }
  22222. return *v, true
  22223. }
  22224. // OldName returns the old "name" field's value of the SopNode entity.
  22225. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  22226. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22227. func (m *SopNodeMutation) OldName(ctx context.Context) (v string, err error) {
  22228. if !m.op.Is(OpUpdateOne) {
  22229. return v, errors.New("OldName is only allowed on UpdateOne operations")
  22230. }
  22231. if m.id == nil || m.oldValue == nil {
  22232. return v, errors.New("OldName requires an ID field in the mutation")
  22233. }
  22234. oldValue, err := m.oldValue(ctx)
  22235. if err != nil {
  22236. return v, fmt.Errorf("querying old value for OldName: %w", err)
  22237. }
  22238. return oldValue.Name, nil
  22239. }
  22240. // ResetName resets all changes to the "name" field.
  22241. func (m *SopNodeMutation) ResetName() {
  22242. m.name = nil
  22243. }
  22244. // SetConditionType sets the "condition_type" field.
  22245. func (m *SopNodeMutation) SetConditionType(i int) {
  22246. m.condition_type = &i
  22247. m.addcondition_type = nil
  22248. }
  22249. // ConditionType returns the value of the "condition_type" field in the mutation.
  22250. func (m *SopNodeMutation) ConditionType() (r int, exists bool) {
  22251. v := m.condition_type
  22252. if v == nil {
  22253. return
  22254. }
  22255. return *v, true
  22256. }
  22257. // OldConditionType returns the old "condition_type" field's value of the SopNode entity.
  22258. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  22259. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22260. func (m *SopNodeMutation) OldConditionType(ctx context.Context) (v int, err error) {
  22261. if !m.op.Is(OpUpdateOne) {
  22262. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  22263. }
  22264. if m.id == nil || m.oldValue == nil {
  22265. return v, errors.New("OldConditionType requires an ID field in the mutation")
  22266. }
  22267. oldValue, err := m.oldValue(ctx)
  22268. if err != nil {
  22269. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  22270. }
  22271. return oldValue.ConditionType, nil
  22272. }
  22273. // AddConditionType adds i to the "condition_type" field.
  22274. func (m *SopNodeMutation) AddConditionType(i int) {
  22275. if m.addcondition_type != nil {
  22276. *m.addcondition_type += i
  22277. } else {
  22278. m.addcondition_type = &i
  22279. }
  22280. }
  22281. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  22282. func (m *SopNodeMutation) AddedConditionType() (r int, exists bool) {
  22283. v := m.addcondition_type
  22284. if v == nil {
  22285. return
  22286. }
  22287. return *v, true
  22288. }
  22289. // ResetConditionType resets all changes to the "condition_type" field.
  22290. func (m *SopNodeMutation) ResetConditionType() {
  22291. m.condition_type = nil
  22292. m.addcondition_type = nil
  22293. }
  22294. // SetConditionList sets the "condition_list" field.
  22295. func (m *SopNodeMutation) SetConditionList(s []string) {
  22296. m.condition_list = &s
  22297. m.appendcondition_list = nil
  22298. }
  22299. // ConditionList returns the value of the "condition_list" field in the mutation.
  22300. func (m *SopNodeMutation) ConditionList() (r []string, exists bool) {
  22301. v := m.condition_list
  22302. if v == nil {
  22303. return
  22304. }
  22305. return *v, true
  22306. }
  22307. // OldConditionList returns the old "condition_list" field's value of the SopNode entity.
  22308. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  22309. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22310. func (m *SopNodeMutation) OldConditionList(ctx context.Context) (v []string, err error) {
  22311. if !m.op.Is(OpUpdateOne) {
  22312. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  22313. }
  22314. if m.id == nil || m.oldValue == nil {
  22315. return v, errors.New("OldConditionList requires an ID field in the mutation")
  22316. }
  22317. oldValue, err := m.oldValue(ctx)
  22318. if err != nil {
  22319. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  22320. }
  22321. return oldValue.ConditionList, nil
  22322. }
  22323. // AppendConditionList adds s to the "condition_list" field.
  22324. func (m *SopNodeMutation) AppendConditionList(s []string) {
  22325. m.appendcondition_list = append(m.appendcondition_list, s...)
  22326. }
  22327. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  22328. func (m *SopNodeMutation) AppendedConditionList() ([]string, bool) {
  22329. if len(m.appendcondition_list) == 0 {
  22330. return nil, false
  22331. }
  22332. return m.appendcondition_list, true
  22333. }
  22334. // ClearConditionList clears the value of the "condition_list" field.
  22335. func (m *SopNodeMutation) ClearConditionList() {
  22336. m.condition_list = nil
  22337. m.appendcondition_list = nil
  22338. m.clearedFields[sopnode.FieldConditionList] = struct{}{}
  22339. }
  22340. // ConditionListCleared returns if the "condition_list" field was cleared in this mutation.
  22341. func (m *SopNodeMutation) ConditionListCleared() bool {
  22342. _, ok := m.clearedFields[sopnode.FieldConditionList]
  22343. return ok
  22344. }
  22345. // ResetConditionList resets all changes to the "condition_list" field.
  22346. func (m *SopNodeMutation) ResetConditionList() {
  22347. m.condition_list = nil
  22348. m.appendcondition_list = nil
  22349. delete(m.clearedFields, sopnode.FieldConditionList)
  22350. }
  22351. // SetNoReplyCondition sets the "no_reply_condition" field.
  22352. func (m *SopNodeMutation) SetNoReplyCondition(u uint64) {
  22353. m.no_reply_condition = &u
  22354. m.addno_reply_condition = nil
  22355. }
  22356. // NoReplyCondition returns the value of the "no_reply_condition" field in the mutation.
  22357. func (m *SopNodeMutation) NoReplyCondition() (r uint64, exists bool) {
  22358. v := m.no_reply_condition
  22359. if v == nil {
  22360. return
  22361. }
  22362. return *v, true
  22363. }
  22364. // OldNoReplyCondition returns the old "no_reply_condition" field's value of the SopNode entity.
  22365. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  22366. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22367. func (m *SopNodeMutation) OldNoReplyCondition(ctx context.Context) (v uint64, err error) {
  22368. if !m.op.Is(OpUpdateOne) {
  22369. return v, errors.New("OldNoReplyCondition is only allowed on UpdateOne operations")
  22370. }
  22371. if m.id == nil || m.oldValue == nil {
  22372. return v, errors.New("OldNoReplyCondition requires an ID field in the mutation")
  22373. }
  22374. oldValue, err := m.oldValue(ctx)
  22375. if err != nil {
  22376. return v, fmt.Errorf("querying old value for OldNoReplyCondition: %w", err)
  22377. }
  22378. return oldValue.NoReplyCondition, nil
  22379. }
  22380. // AddNoReplyCondition adds u to the "no_reply_condition" field.
  22381. func (m *SopNodeMutation) AddNoReplyCondition(u int64) {
  22382. if m.addno_reply_condition != nil {
  22383. *m.addno_reply_condition += u
  22384. } else {
  22385. m.addno_reply_condition = &u
  22386. }
  22387. }
  22388. // AddedNoReplyCondition returns the value that was added to the "no_reply_condition" field in this mutation.
  22389. func (m *SopNodeMutation) AddedNoReplyCondition() (r int64, exists bool) {
  22390. v := m.addno_reply_condition
  22391. if v == nil {
  22392. return
  22393. }
  22394. return *v, true
  22395. }
  22396. // ResetNoReplyCondition resets all changes to the "no_reply_condition" field.
  22397. func (m *SopNodeMutation) ResetNoReplyCondition() {
  22398. m.no_reply_condition = nil
  22399. m.addno_reply_condition = nil
  22400. }
  22401. // SetNoReplyUnit sets the "no_reply_unit" field.
  22402. func (m *SopNodeMutation) SetNoReplyUnit(s string) {
  22403. m.no_reply_unit = &s
  22404. }
  22405. // NoReplyUnit returns the value of the "no_reply_unit" field in the mutation.
  22406. func (m *SopNodeMutation) NoReplyUnit() (r string, exists bool) {
  22407. v := m.no_reply_unit
  22408. if v == nil {
  22409. return
  22410. }
  22411. return *v, true
  22412. }
  22413. // OldNoReplyUnit returns the old "no_reply_unit" field's value of the SopNode entity.
  22414. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  22415. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22416. func (m *SopNodeMutation) OldNoReplyUnit(ctx context.Context) (v string, err error) {
  22417. if !m.op.Is(OpUpdateOne) {
  22418. return v, errors.New("OldNoReplyUnit is only allowed on UpdateOne operations")
  22419. }
  22420. if m.id == nil || m.oldValue == nil {
  22421. return v, errors.New("OldNoReplyUnit requires an ID field in the mutation")
  22422. }
  22423. oldValue, err := m.oldValue(ctx)
  22424. if err != nil {
  22425. return v, fmt.Errorf("querying old value for OldNoReplyUnit: %w", err)
  22426. }
  22427. return oldValue.NoReplyUnit, nil
  22428. }
  22429. // ResetNoReplyUnit resets all changes to the "no_reply_unit" field.
  22430. func (m *SopNodeMutation) ResetNoReplyUnit() {
  22431. m.no_reply_unit = nil
  22432. }
  22433. // SetActionMessage sets the "action_message" field.
  22434. func (m *SopNodeMutation) SetActionMessage(ct []custom_types.Action) {
  22435. m.action_message = &ct
  22436. m.appendaction_message = nil
  22437. }
  22438. // ActionMessage returns the value of the "action_message" field in the mutation.
  22439. func (m *SopNodeMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  22440. v := m.action_message
  22441. if v == nil {
  22442. return
  22443. }
  22444. return *v, true
  22445. }
  22446. // OldActionMessage returns the old "action_message" field's value of the SopNode entity.
  22447. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  22448. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22449. func (m *SopNodeMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  22450. if !m.op.Is(OpUpdateOne) {
  22451. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  22452. }
  22453. if m.id == nil || m.oldValue == nil {
  22454. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  22455. }
  22456. oldValue, err := m.oldValue(ctx)
  22457. if err != nil {
  22458. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  22459. }
  22460. return oldValue.ActionMessage, nil
  22461. }
  22462. // AppendActionMessage adds ct to the "action_message" field.
  22463. func (m *SopNodeMutation) AppendActionMessage(ct []custom_types.Action) {
  22464. m.appendaction_message = append(m.appendaction_message, ct...)
  22465. }
  22466. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  22467. func (m *SopNodeMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  22468. if len(m.appendaction_message) == 0 {
  22469. return nil, false
  22470. }
  22471. return m.appendaction_message, true
  22472. }
  22473. // ClearActionMessage clears the value of the "action_message" field.
  22474. func (m *SopNodeMutation) ClearActionMessage() {
  22475. m.action_message = nil
  22476. m.appendaction_message = nil
  22477. m.clearedFields[sopnode.FieldActionMessage] = struct{}{}
  22478. }
  22479. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  22480. func (m *SopNodeMutation) ActionMessageCleared() bool {
  22481. _, ok := m.clearedFields[sopnode.FieldActionMessage]
  22482. return ok
  22483. }
  22484. // ResetActionMessage resets all changes to the "action_message" field.
  22485. func (m *SopNodeMutation) ResetActionMessage() {
  22486. m.action_message = nil
  22487. m.appendaction_message = nil
  22488. delete(m.clearedFields, sopnode.FieldActionMessage)
  22489. }
  22490. // SetActionLabelAdd sets the "action_label_add" field.
  22491. func (m *SopNodeMutation) SetActionLabelAdd(u []uint64) {
  22492. m.action_label_add = &u
  22493. m.appendaction_label_add = nil
  22494. }
  22495. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  22496. func (m *SopNodeMutation) ActionLabelAdd() (r []uint64, exists bool) {
  22497. v := m.action_label_add
  22498. if v == nil {
  22499. return
  22500. }
  22501. return *v, true
  22502. }
  22503. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopNode entity.
  22504. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  22505. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22506. func (m *SopNodeMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  22507. if !m.op.Is(OpUpdateOne) {
  22508. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  22509. }
  22510. if m.id == nil || m.oldValue == nil {
  22511. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  22512. }
  22513. oldValue, err := m.oldValue(ctx)
  22514. if err != nil {
  22515. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  22516. }
  22517. return oldValue.ActionLabelAdd, nil
  22518. }
  22519. // AppendActionLabelAdd adds u to the "action_label_add" field.
  22520. func (m *SopNodeMutation) AppendActionLabelAdd(u []uint64) {
  22521. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  22522. }
  22523. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  22524. func (m *SopNodeMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  22525. if len(m.appendaction_label_add) == 0 {
  22526. return nil, false
  22527. }
  22528. return m.appendaction_label_add, true
  22529. }
  22530. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  22531. func (m *SopNodeMutation) ClearActionLabelAdd() {
  22532. m.action_label_add = nil
  22533. m.appendaction_label_add = nil
  22534. m.clearedFields[sopnode.FieldActionLabelAdd] = struct{}{}
  22535. }
  22536. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  22537. func (m *SopNodeMutation) ActionLabelAddCleared() bool {
  22538. _, ok := m.clearedFields[sopnode.FieldActionLabelAdd]
  22539. return ok
  22540. }
  22541. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  22542. func (m *SopNodeMutation) ResetActionLabelAdd() {
  22543. m.action_label_add = nil
  22544. m.appendaction_label_add = nil
  22545. delete(m.clearedFields, sopnode.FieldActionLabelAdd)
  22546. }
  22547. // SetActionLabelDel sets the "action_label_del" field.
  22548. func (m *SopNodeMutation) SetActionLabelDel(u []uint64) {
  22549. m.action_label_del = &u
  22550. m.appendaction_label_del = nil
  22551. }
  22552. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  22553. func (m *SopNodeMutation) ActionLabelDel() (r []uint64, exists bool) {
  22554. v := m.action_label_del
  22555. if v == nil {
  22556. return
  22557. }
  22558. return *v, true
  22559. }
  22560. // OldActionLabelDel returns the old "action_label_del" field's value of the SopNode entity.
  22561. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  22562. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22563. func (m *SopNodeMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  22564. if !m.op.Is(OpUpdateOne) {
  22565. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  22566. }
  22567. if m.id == nil || m.oldValue == nil {
  22568. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  22569. }
  22570. oldValue, err := m.oldValue(ctx)
  22571. if err != nil {
  22572. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  22573. }
  22574. return oldValue.ActionLabelDel, nil
  22575. }
  22576. // AppendActionLabelDel adds u to the "action_label_del" field.
  22577. func (m *SopNodeMutation) AppendActionLabelDel(u []uint64) {
  22578. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  22579. }
  22580. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  22581. func (m *SopNodeMutation) AppendedActionLabelDel() ([]uint64, bool) {
  22582. if len(m.appendaction_label_del) == 0 {
  22583. return nil, false
  22584. }
  22585. return m.appendaction_label_del, true
  22586. }
  22587. // ClearActionLabelDel clears the value of the "action_label_del" field.
  22588. func (m *SopNodeMutation) ClearActionLabelDel() {
  22589. m.action_label_del = nil
  22590. m.appendaction_label_del = nil
  22591. m.clearedFields[sopnode.FieldActionLabelDel] = struct{}{}
  22592. }
  22593. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  22594. func (m *SopNodeMutation) ActionLabelDelCleared() bool {
  22595. _, ok := m.clearedFields[sopnode.FieldActionLabelDel]
  22596. return ok
  22597. }
  22598. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  22599. func (m *SopNodeMutation) ResetActionLabelDel() {
  22600. m.action_label_del = nil
  22601. m.appendaction_label_del = nil
  22602. delete(m.clearedFields, sopnode.FieldActionLabelDel)
  22603. }
  22604. // SetActionForward sets the "action_forward" field.
  22605. func (m *SopNodeMutation) SetActionForward(ctf *custom_types.ActionForward) {
  22606. m.action_forward = &ctf
  22607. }
  22608. // ActionForward returns the value of the "action_forward" field in the mutation.
  22609. func (m *SopNodeMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  22610. v := m.action_forward
  22611. if v == nil {
  22612. return
  22613. }
  22614. return *v, true
  22615. }
  22616. // OldActionForward returns the old "action_forward" field's value of the SopNode entity.
  22617. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  22618. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22619. func (m *SopNodeMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  22620. if !m.op.Is(OpUpdateOne) {
  22621. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  22622. }
  22623. if m.id == nil || m.oldValue == nil {
  22624. return v, errors.New("OldActionForward requires an ID field in the mutation")
  22625. }
  22626. oldValue, err := m.oldValue(ctx)
  22627. if err != nil {
  22628. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  22629. }
  22630. return oldValue.ActionForward, nil
  22631. }
  22632. // ClearActionForward clears the value of the "action_forward" field.
  22633. func (m *SopNodeMutation) ClearActionForward() {
  22634. m.action_forward = nil
  22635. m.clearedFields[sopnode.FieldActionForward] = struct{}{}
  22636. }
  22637. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  22638. func (m *SopNodeMutation) ActionForwardCleared() bool {
  22639. _, ok := m.clearedFields[sopnode.FieldActionForward]
  22640. return ok
  22641. }
  22642. // ResetActionForward resets all changes to the "action_forward" field.
  22643. func (m *SopNodeMutation) ResetActionForward() {
  22644. m.action_forward = nil
  22645. delete(m.clearedFields, sopnode.FieldActionForward)
  22646. }
  22647. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  22648. func (m *SopNodeMutation) SetSopStageID(id uint64) {
  22649. m.sop_stage = &id
  22650. }
  22651. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  22652. func (m *SopNodeMutation) ClearSopStage() {
  22653. m.clearedsop_stage = true
  22654. m.clearedFields[sopnode.FieldStageID] = struct{}{}
  22655. }
  22656. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  22657. func (m *SopNodeMutation) SopStageCleared() bool {
  22658. return m.clearedsop_stage
  22659. }
  22660. // SopStageID returns the "sop_stage" edge ID in the mutation.
  22661. func (m *SopNodeMutation) SopStageID() (id uint64, exists bool) {
  22662. if m.sop_stage != nil {
  22663. return *m.sop_stage, true
  22664. }
  22665. return
  22666. }
  22667. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  22668. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  22669. // SopStageID instead. It exists only for internal usage by the builders.
  22670. func (m *SopNodeMutation) SopStageIDs() (ids []uint64) {
  22671. if id := m.sop_stage; id != nil {
  22672. ids = append(ids, *id)
  22673. }
  22674. return
  22675. }
  22676. // ResetSopStage resets all changes to the "sop_stage" edge.
  22677. func (m *SopNodeMutation) ResetSopStage() {
  22678. m.sop_stage = nil
  22679. m.clearedsop_stage = false
  22680. }
  22681. // AddNodeMessageIDs adds the "node_messages" edge to the MessageRecords entity by ids.
  22682. func (m *SopNodeMutation) AddNodeMessageIDs(ids ...uint64) {
  22683. if m.node_messages == nil {
  22684. m.node_messages = make(map[uint64]struct{})
  22685. }
  22686. for i := range ids {
  22687. m.node_messages[ids[i]] = struct{}{}
  22688. }
  22689. }
  22690. // ClearNodeMessages clears the "node_messages" edge to the MessageRecords entity.
  22691. func (m *SopNodeMutation) ClearNodeMessages() {
  22692. m.clearednode_messages = true
  22693. }
  22694. // NodeMessagesCleared reports if the "node_messages" edge to the MessageRecords entity was cleared.
  22695. func (m *SopNodeMutation) NodeMessagesCleared() bool {
  22696. return m.clearednode_messages
  22697. }
  22698. // RemoveNodeMessageIDs removes the "node_messages" edge to the MessageRecords entity by IDs.
  22699. func (m *SopNodeMutation) RemoveNodeMessageIDs(ids ...uint64) {
  22700. if m.removednode_messages == nil {
  22701. m.removednode_messages = make(map[uint64]struct{})
  22702. }
  22703. for i := range ids {
  22704. delete(m.node_messages, ids[i])
  22705. m.removednode_messages[ids[i]] = struct{}{}
  22706. }
  22707. }
  22708. // RemovedNodeMessages returns the removed IDs of the "node_messages" edge to the MessageRecords entity.
  22709. func (m *SopNodeMutation) RemovedNodeMessagesIDs() (ids []uint64) {
  22710. for id := range m.removednode_messages {
  22711. ids = append(ids, id)
  22712. }
  22713. return
  22714. }
  22715. // NodeMessagesIDs returns the "node_messages" edge IDs in the mutation.
  22716. func (m *SopNodeMutation) NodeMessagesIDs() (ids []uint64) {
  22717. for id := range m.node_messages {
  22718. ids = append(ids, id)
  22719. }
  22720. return
  22721. }
  22722. // ResetNodeMessages resets all changes to the "node_messages" edge.
  22723. func (m *SopNodeMutation) ResetNodeMessages() {
  22724. m.node_messages = nil
  22725. m.clearednode_messages = false
  22726. m.removednode_messages = nil
  22727. }
  22728. // Where appends a list predicates to the SopNodeMutation builder.
  22729. func (m *SopNodeMutation) Where(ps ...predicate.SopNode) {
  22730. m.predicates = append(m.predicates, ps...)
  22731. }
  22732. // WhereP appends storage-level predicates to the SopNodeMutation builder. Using this method,
  22733. // users can use type-assertion to append predicates that do not depend on any generated package.
  22734. func (m *SopNodeMutation) WhereP(ps ...func(*sql.Selector)) {
  22735. p := make([]predicate.SopNode, len(ps))
  22736. for i := range ps {
  22737. p[i] = ps[i]
  22738. }
  22739. m.Where(p...)
  22740. }
  22741. // Op returns the operation name.
  22742. func (m *SopNodeMutation) Op() Op {
  22743. return m.op
  22744. }
  22745. // SetOp allows setting the mutation operation.
  22746. func (m *SopNodeMutation) SetOp(op Op) {
  22747. m.op = op
  22748. }
  22749. // Type returns the node type of this mutation (SopNode).
  22750. func (m *SopNodeMutation) Type() string {
  22751. return m.typ
  22752. }
  22753. // Fields returns all fields that were changed during this mutation. Note that in
  22754. // order to get all numeric fields that were incremented/decremented, call
  22755. // AddedFields().
  22756. func (m *SopNodeMutation) Fields() []string {
  22757. fields := make([]string, 0, 15)
  22758. if m.created_at != nil {
  22759. fields = append(fields, sopnode.FieldCreatedAt)
  22760. }
  22761. if m.updated_at != nil {
  22762. fields = append(fields, sopnode.FieldUpdatedAt)
  22763. }
  22764. if m.status != nil {
  22765. fields = append(fields, sopnode.FieldStatus)
  22766. }
  22767. if m.deleted_at != nil {
  22768. fields = append(fields, sopnode.FieldDeletedAt)
  22769. }
  22770. if m.sop_stage != nil {
  22771. fields = append(fields, sopnode.FieldStageID)
  22772. }
  22773. if m.parent_id != nil {
  22774. fields = append(fields, sopnode.FieldParentID)
  22775. }
  22776. if m.name != nil {
  22777. fields = append(fields, sopnode.FieldName)
  22778. }
  22779. if m.condition_type != nil {
  22780. fields = append(fields, sopnode.FieldConditionType)
  22781. }
  22782. if m.condition_list != nil {
  22783. fields = append(fields, sopnode.FieldConditionList)
  22784. }
  22785. if m.no_reply_condition != nil {
  22786. fields = append(fields, sopnode.FieldNoReplyCondition)
  22787. }
  22788. if m.no_reply_unit != nil {
  22789. fields = append(fields, sopnode.FieldNoReplyUnit)
  22790. }
  22791. if m.action_message != nil {
  22792. fields = append(fields, sopnode.FieldActionMessage)
  22793. }
  22794. if m.action_label_add != nil {
  22795. fields = append(fields, sopnode.FieldActionLabelAdd)
  22796. }
  22797. if m.action_label_del != nil {
  22798. fields = append(fields, sopnode.FieldActionLabelDel)
  22799. }
  22800. if m.action_forward != nil {
  22801. fields = append(fields, sopnode.FieldActionForward)
  22802. }
  22803. return fields
  22804. }
  22805. // Field returns the value of a field with the given name. The second boolean
  22806. // return value indicates that this field was not set, or was not defined in the
  22807. // schema.
  22808. func (m *SopNodeMutation) Field(name string) (ent.Value, bool) {
  22809. switch name {
  22810. case sopnode.FieldCreatedAt:
  22811. return m.CreatedAt()
  22812. case sopnode.FieldUpdatedAt:
  22813. return m.UpdatedAt()
  22814. case sopnode.FieldStatus:
  22815. return m.Status()
  22816. case sopnode.FieldDeletedAt:
  22817. return m.DeletedAt()
  22818. case sopnode.FieldStageID:
  22819. return m.StageID()
  22820. case sopnode.FieldParentID:
  22821. return m.ParentID()
  22822. case sopnode.FieldName:
  22823. return m.Name()
  22824. case sopnode.FieldConditionType:
  22825. return m.ConditionType()
  22826. case sopnode.FieldConditionList:
  22827. return m.ConditionList()
  22828. case sopnode.FieldNoReplyCondition:
  22829. return m.NoReplyCondition()
  22830. case sopnode.FieldNoReplyUnit:
  22831. return m.NoReplyUnit()
  22832. case sopnode.FieldActionMessage:
  22833. return m.ActionMessage()
  22834. case sopnode.FieldActionLabelAdd:
  22835. return m.ActionLabelAdd()
  22836. case sopnode.FieldActionLabelDel:
  22837. return m.ActionLabelDel()
  22838. case sopnode.FieldActionForward:
  22839. return m.ActionForward()
  22840. }
  22841. return nil, false
  22842. }
  22843. // OldField returns the old value of the field from the database. An error is
  22844. // returned if the mutation operation is not UpdateOne, or the query to the
  22845. // database failed.
  22846. func (m *SopNodeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  22847. switch name {
  22848. case sopnode.FieldCreatedAt:
  22849. return m.OldCreatedAt(ctx)
  22850. case sopnode.FieldUpdatedAt:
  22851. return m.OldUpdatedAt(ctx)
  22852. case sopnode.FieldStatus:
  22853. return m.OldStatus(ctx)
  22854. case sopnode.FieldDeletedAt:
  22855. return m.OldDeletedAt(ctx)
  22856. case sopnode.FieldStageID:
  22857. return m.OldStageID(ctx)
  22858. case sopnode.FieldParentID:
  22859. return m.OldParentID(ctx)
  22860. case sopnode.FieldName:
  22861. return m.OldName(ctx)
  22862. case sopnode.FieldConditionType:
  22863. return m.OldConditionType(ctx)
  22864. case sopnode.FieldConditionList:
  22865. return m.OldConditionList(ctx)
  22866. case sopnode.FieldNoReplyCondition:
  22867. return m.OldNoReplyCondition(ctx)
  22868. case sopnode.FieldNoReplyUnit:
  22869. return m.OldNoReplyUnit(ctx)
  22870. case sopnode.FieldActionMessage:
  22871. return m.OldActionMessage(ctx)
  22872. case sopnode.FieldActionLabelAdd:
  22873. return m.OldActionLabelAdd(ctx)
  22874. case sopnode.FieldActionLabelDel:
  22875. return m.OldActionLabelDel(ctx)
  22876. case sopnode.FieldActionForward:
  22877. return m.OldActionForward(ctx)
  22878. }
  22879. return nil, fmt.Errorf("unknown SopNode field %s", name)
  22880. }
  22881. // SetField sets the value of a field with the given name. It returns an error if
  22882. // the field is not defined in the schema, or if the type mismatched the field
  22883. // type.
  22884. func (m *SopNodeMutation) SetField(name string, value ent.Value) error {
  22885. switch name {
  22886. case sopnode.FieldCreatedAt:
  22887. v, ok := value.(time.Time)
  22888. if !ok {
  22889. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22890. }
  22891. m.SetCreatedAt(v)
  22892. return nil
  22893. case sopnode.FieldUpdatedAt:
  22894. v, ok := value.(time.Time)
  22895. if !ok {
  22896. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22897. }
  22898. m.SetUpdatedAt(v)
  22899. return nil
  22900. case sopnode.FieldStatus:
  22901. v, ok := value.(uint8)
  22902. if !ok {
  22903. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22904. }
  22905. m.SetStatus(v)
  22906. return nil
  22907. case sopnode.FieldDeletedAt:
  22908. v, ok := value.(time.Time)
  22909. if !ok {
  22910. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22911. }
  22912. m.SetDeletedAt(v)
  22913. return nil
  22914. case sopnode.FieldStageID:
  22915. v, ok := value.(uint64)
  22916. if !ok {
  22917. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22918. }
  22919. m.SetStageID(v)
  22920. return nil
  22921. case sopnode.FieldParentID:
  22922. v, ok := value.(uint64)
  22923. if !ok {
  22924. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22925. }
  22926. m.SetParentID(v)
  22927. return nil
  22928. case sopnode.FieldName:
  22929. v, ok := value.(string)
  22930. if !ok {
  22931. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22932. }
  22933. m.SetName(v)
  22934. return nil
  22935. case sopnode.FieldConditionType:
  22936. v, ok := value.(int)
  22937. if !ok {
  22938. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22939. }
  22940. m.SetConditionType(v)
  22941. return nil
  22942. case sopnode.FieldConditionList:
  22943. v, ok := value.([]string)
  22944. if !ok {
  22945. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22946. }
  22947. m.SetConditionList(v)
  22948. return nil
  22949. case sopnode.FieldNoReplyCondition:
  22950. v, ok := value.(uint64)
  22951. if !ok {
  22952. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22953. }
  22954. m.SetNoReplyCondition(v)
  22955. return nil
  22956. case sopnode.FieldNoReplyUnit:
  22957. v, ok := value.(string)
  22958. if !ok {
  22959. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22960. }
  22961. m.SetNoReplyUnit(v)
  22962. return nil
  22963. case sopnode.FieldActionMessage:
  22964. v, ok := value.([]custom_types.Action)
  22965. if !ok {
  22966. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22967. }
  22968. m.SetActionMessage(v)
  22969. return nil
  22970. case sopnode.FieldActionLabelAdd:
  22971. v, ok := value.([]uint64)
  22972. if !ok {
  22973. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22974. }
  22975. m.SetActionLabelAdd(v)
  22976. return nil
  22977. case sopnode.FieldActionLabelDel:
  22978. v, ok := value.([]uint64)
  22979. if !ok {
  22980. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22981. }
  22982. m.SetActionLabelDel(v)
  22983. return nil
  22984. case sopnode.FieldActionForward:
  22985. v, ok := value.(*custom_types.ActionForward)
  22986. if !ok {
  22987. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22988. }
  22989. m.SetActionForward(v)
  22990. return nil
  22991. }
  22992. return fmt.Errorf("unknown SopNode field %s", name)
  22993. }
  22994. // AddedFields returns all numeric fields that were incremented/decremented during
  22995. // this mutation.
  22996. func (m *SopNodeMutation) AddedFields() []string {
  22997. var fields []string
  22998. if m.addstatus != nil {
  22999. fields = append(fields, sopnode.FieldStatus)
  23000. }
  23001. if m.addparent_id != nil {
  23002. fields = append(fields, sopnode.FieldParentID)
  23003. }
  23004. if m.addcondition_type != nil {
  23005. fields = append(fields, sopnode.FieldConditionType)
  23006. }
  23007. if m.addno_reply_condition != nil {
  23008. fields = append(fields, sopnode.FieldNoReplyCondition)
  23009. }
  23010. return fields
  23011. }
  23012. // AddedField returns the numeric value that was incremented/decremented on a field
  23013. // with the given name. The second boolean return value indicates that this field
  23014. // was not set, or was not defined in the schema.
  23015. func (m *SopNodeMutation) AddedField(name string) (ent.Value, bool) {
  23016. switch name {
  23017. case sopnode.FieldStatus:
  23018. return m.AddedStatus()
  23019. case sopnode.FieldParentID:
  23020. return m.AddedParentID()
  23021. case sopnode.FieldConditionType:
  23022. return m.AddedConditionType()
  23023. case sopnode.FieldNoReplyCondition:
  23024. return m.AddedNoReplyCondition()
  23025. }
  23026. return nil, false
  23027. }
  23028. // AddField adds the value to the field with the given name. It returns an error if
  23029. // the field is not defined in the schema, or if the type mismatched the field
  23030. // type.
  23031. func (m *SopNodeMutation) AddField(name string, value ent.Value) error {
  23032. switch name {
  23033. case sopnode.FieldStatus:
  23034. v, ok := value.(int8)
  23035. if !ok {
  23036. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23037. }
  23038. m.AddStatus(v)
  23039. return nil
  23040. case sopnode.FieldParentID:
  23041. v, ok := value.(int64)
  23042. if !ok {
  23043. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23044. }
  23045. m.AddParentID(v)
  23046. return nil
  23047. case sopnode.FieldConditionType:
  23048. v, ok := value.(int)
  23049. if !ok {
  23050. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23051. }
  23052. m.AddConditionType(v)
  23053. return nil
  23054. case sopnode.FieldNoReplyCondition:
  23055. v, ok := value.(int64)
  23056. if !ok {
  23057. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23058. }
  23059. m.AddNoReplyCondition(v)
  23060. return nil
  23061. }
  23062. return fmt.Errorf("unknown SopNode numeric field %s", name)
  23063. }
  23064. // ClearedFields returns all nullable fields that were cleared during this
  23065. // mutation.
  23066. func (m *SopNodeMutation) ClearedFields() []string {
  23067. var fields []string
  23068. if m.FieldCleared(sopnode.FieldStatus) {
  23069. fields = append(fields, sopnode.FieldStatus)
  23070. }
  23071. if m.FieldCleared(sopnode.FieldDeletedAt) {
  23072. fields = append(fields, sopnode.FieldDeletedAt)
  23073. }
  23074. if m.FieldCleared(sopnode.FieldConditionList) {
  23075. fields = append(fields, sopnode.FieldConditionList)
  23076. }
  23077. if m.FieldCleared(sopnode.FieldActionMessage) {
  23078. fields = append(fields, sopnode.FieldActionMessage)
  23079. }
  23080. if m.FieldCleared(sopnode.FieldActionLabelAdd) {
  23081. fields = append(fields, sopnode.FieldActionLabelAdd)
  23082. }
  23083. if m.FieldCleared(sopnode.FieldActionLabelDel) {
  23084. fields = append(fields, sopnode.FieldActionLabelDel)
  23085. }
  23086. if m.FieldCleared(sopnode.FieldActionForward) {
  23087. fields = append(fields, sopnode.FieldActionForward)
  23088. }
  23089. return fields
  23090. }
  23091. // FieldCleared returns a boolean indicating if a field with the given name was
  23092. // cleared in this mutation.
  23093. func (m *SopNodeMutation) FieldCleared(name string) bool {
  23094. _, ok := m.clearedFields[name]
  23095. return ok
  23096. }
  23097. // ClearField clears the value of the field with the given name. It returns an
  23098. // error if the field is not defined in the schema.
  23099. func (m *SopNodeMutation) ClearField(name string) error {
  23100. switch name {
  23101. case sopnode.FieldStatus:
  23102. m.ClearStatus()
  23103. return nil
  23104. case sopnode.FieldDeletedAt:
  23105. m.ClearDeletedAt()
  23106. return nil
  23107. case sopnode.FieldConditionList:
  23108. m.ClearConditionList()
  23109. return nil
  23110. case sopnode.FieldActionMessage:
  23111. m.ClearActionMessage()
  23112. return nil
  23113. case sopnode.FieldActionLabelAdd:
  23114. m.ClearActionLabelAdd()
  23115. return nil
  23116. case sopnode.FieldActionLabelDel:
  23117. m.ClearActionLabelDel()
  23118. return nil
  23119. case sopnode.FieldActionForward:
  23120. m.ClearActionForward()
  23121. return nil
  23122. }
  23123. return fmt.Errorf("unknown SopNode nullable field %s", name)
  23124. }
  23125. // ResetField resets all changes in the mutation for the field with the given name.
  23126. // It returns an error if the field is not defined in the schema.
  23127. func (m *SopNodeMutation) ResetField(name string) error {
  23128. switch name {
  23129. case sopnode.FieldCreatedAt:
  23130. m.ResetCreatedAt()
  23131. return nil
  23132. case sopnode.FieldUpdatedAt:
  23133. m.ResetUpdatedAt()
  23134. return nil
  23135. case sopnode.FieldStatus:
  23136. m.ResetStatus()
  23137. return nil
  23138. case sopnode.FieldDeletedAt:
  23139. m.ResetDeletedAt()
  23140. return nil
  23141. case sopnode.FieldStageID:
  23142. m.ResetStageID()
  23143. return nil
  23144. case sopnode.FieldParentID:
  23145. m.ResetParentID()
  23146. return nil
  23147. case sopnode.FieldName:
  23148. m.ResetName()
  23149. return nil
  23150. case sopnode.FieldConditionType:
  23151. m.ResetConditionType()
  23152. return nil
  23153. case sopnode.FieldConditionList:
  23154. m.ResetConditionList()
  23155. return nil
  23156. case sopnode.FieldNoReplyCondition:
  23157. m.ResetNoReplyCondition()
  23158. return nil
  23159. case sopnode.FieldNoReplyUnit:
  23160. m.ResetNoReplyUnit()
  23161. return nil
  23162. case sopnode.FieldActionMessage:
  23163. m.ResetActionMessage()
  23164. return nil
  23165. case sopnode.FieldActionLabelAdd:
  23166. m.ResetActionLabelAdd()
  23167. return nil
  23168. case sopnode.FieldActionLabelDel:
  23169. m.ResetActionLabelDel()
  23170. return nil
  23171. case sopnode.FieldActionForward:
  23172. m.ResetActionForward()
  23173. return nil
  23174. }
  23175. return fmt.Errorf("unknown SopNode field %s", name)
  23176. }
  23177. // AddedEdges returns all edge names that were set/added in this mutation.
  23178. func (m *SopNodeMutation) AddedEdges() []string {
  23179. edges := make([]string, 0, 2)
  23180. if m.sop_stage != nil {
  23181. edges = append(edges, sopnode.EdgeSopStage)
  23182. }
  23183. if m.node_messages != nil {
  23184. edges = append(edges, sopnode.EdgeNodeMessages)
  23185. }
  23186. return edges
  23187. }
  23188. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  23189. // name in this mutation.
  23190. func (m *SopNodeMutation) AddedIDs(name string) []ent.Value {
  23191. switch name {
  23192. case sopnode.EdgeSopStage:
  23193. if id := m.sop_stage; id != nil {
  23194. return []ent.Value{*id}
  23195. }
  23196. case sopnode.EdgeNodeMessages:
  23197. ids := make([]ent.Value, 0, len(m.node_messages))
  23198. for id := range m.node_messages {
  23199. ids = append(ids, id)
  23200. }
  23201. return ids
  23202. }
  23203. return nil
  23204. }
  23205. // RemovedEdges returns all edge names that were removed in this mutation.
  23206. func (m *SopNodeMutation) RemovedEdges() []string {
  23207. edges := make([]string, 0, 2)
  23208. if m.removednode_messages != nil {
  23209. edges = append(edges, sopnode.EdgeNodeMessages)
  23210. }
  23211. return edges
  23212. }
  23213. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  23214. // the given name in this mutation.
  23215. func (m *SopNodeMutation) RemovedIDs(name string) []ent.Value {
  23216. switch name {
  23217. case sopnode.EdgeNodeMessages:
  23218. ids := make([]ent.Value, 0, len(m.removednode_messages))
  23219. for id := range m.removednode_messages {
  23220. ids = append(ids, id)
  23221. }
  23222. return ids
  23223. }
  23224. return nil
  23225. }
  23226. // ClearedEdges returns all edge names that were cleared in this mutation.
  23227. func (m *SopNodeMutation) ClearedEdges() []string {
  23228. edges := make([]string, 0, 2)
  23229. if m.clearedsop_stage {
  23230. edges = append(edges, sopnode.EdgeSopStage)
  23231. }
  23232. if m.clearednode_messages {
  23233. edges = append(edges, sopnode.EdgeNodeMessages)
  23234. }
  23235. return edges
  23236. }
  23237. // EdgeCleared returns a boolean which indicates if the edge with the given name
  23238. // was cleared in this mutation.
  23239. func (m *SopNodeMutation) EdgeCleared(name string) bool {
  23240. switch name {
  23241. case sopnode.EdgeSopStage:
  23242. return m.clearedsop_stage
  23243. case sopnode.EdgeNodeMessages:
  23244. return m.clearednode_messages
  23245. }
  23246. return false
  23247. }
  23248. // ClearEdge clears the value of the edge with the given name. It returns an error
  23249. // if that edge is not defined in the schema.
  23250. func (m *SopNodeMutation) ClearEdge(name string) error {
  23251. switch name {
  23252. case sopnode.EdgeSopStage:
  23253. m.ClearSopStage()
  23254. return nil
  23255. }
  23256. return fmt.Errorf("unknown SopNode unique edge %s", name)
  23257. }
  23258. // ResetEdge resets all changes to the edge with the given name in this mutation.
  23259. // It returns an error if the edge is not defined in the schema.
  23260. func (m *SopNodeMutation) ResetEdge(name string) error {
  23261. switch name {
  23262. case sopnode.EdgeSopStage:
  23263. m.ResetSopStage()
  23264. return nil
  23265. case sopnode.EdgeNodeMessages:
  23266. m.ResetNodeMessages()
  23267. return nil
  23268. }
  23269. return fmt.Errorf("unknown SopNode edge %s", name)
  23270. }
  23271. // SopStageMutation represents an operation that mutates the SopStage nodes in the graph.
  23272. type SopStageMutation struct {
  23273. config
  23274. op Op
  23275. typ string
  23276. id *uint64
  23277. created_at *time.Time
  23278. updated_at *time.Time
  23279. status *uint8
  23280. addstatus *int8
  23281. deleted_at *time.Time
  23282. name *string
  23283. condition_type *int
  23284. addcondition_type *int
  23285. condition_operator *int
  23286. addcondition_operator *int
  23287. condition_list *[]custom_types.Condition
  23288. appendcondition_list []custom_types.Condition
  23289. action_message *[]custom_types.Action
  23290. appendaction_message []custom_types.Action
  23291. action_label_add *[]uint64
  23292. appendaction_label_add []uint64
  23293. action_label_del *[]uint64
  23294. appendaction_label_del []uint64
  23295. action_forward **custom_types.ActionForward
  23296. index_sort *int
  23297. addindex_sort *int
  23298. clearedFields map[string]struct{}
  23299. sop_task *uint64
  23300. clearedsop_task bool
  23301. stage_nodes map[uint64]struct{}
  23302. removedstage_nodes map[uint64]struct{}
  23303. clearedstage_nodes bool
  23304. stage_messages map[uint64]struct{}
  23305. removedstage_messages map[uint64]struct{}
  23306. clearedstage_messages bool
  23307. done bool
  23308. oldValue func(context.Context) (*SopStage, error)
  23309. predicates []predicate.SopStage
  23310. }
  23311. var _ ent.Mutation = (*SopStageMutation)(nil)
  23312. // sopstageOption allows management of the mutation configuration using functional options.
  23313. type sopstageOption func(*SopStageMutation)
  23314. // newSopStageMutation creates new mutation for the SopStage entity.
  23315. func newSopStageMutation(c config, op Op, opts ...sopstageOption) *SopStageMutation {
  23316. m := &SopStageMutation{
  23317. config: c,
  23318. op: op,
  23319. typ: TypeSopStage,
  23320. clearedFields: make(map[string]struct{}),
  23321. }
  23322. for _, opt := range opts {
  23323. opt(m)
  23324. }
  23325. return m
  23326. }
  23327. // withSopStageID sets the ID field of the mutation.
  23328. func withSopStageID(id uint64) sopstageOption {
  23329. return func(m *SopStageMutation) {
  23330. var (
  23331. err error
  23332. once sync.Once
  23333. value *SopStage
  23334. )
  23335. m.oldValue = func(ctx context.Context) (*SopStage, error) {
  23336. once.Do(func() {
  23337. if m.done {
  23338. err = errors.New("querying old values post mutation is not allowed")
  23339. } else {
  23340. value, err = m.Client().SopStage.Get(ctx, id)
  23341. }
  23342. })
  23343. return value, err
  23344. }
  23345. m.id = &id
  23346. }
  23347. }
  23348. // withSopStage sets the old SopStage of the mutation.
  23349. func withSopStage(node *SopStage) sopstageOption {
  23350. return func(m *SopStageMutation) {
  23351. m.oldValue = func(context.Context) (*SopStage, error) {
  23352. return node, nil
  23353. }
  23354. m.id = &node.ID
  23355. }
  23356. }
  23357. // Client returns a new `ent.Client` from the mutation. If the mutation was
  23358. // executed in a transaction (ent.Tx), a transactional client is returned.
  23359. func (m SopStageMutation) Client() *Client {
  23360. client := &Client{config: m.config}
  23361. client.init()
  23362. return client
  23363. }
  23364. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  23365. // it returns an error otherwise.
  23366. func (m SopStageMutation) Tx() (*Tx, error) {
  23367. if _, ok := m.driver.(*txDriver); !ok {
  23368. return nil, errors.New("ent: mutation is not running in a transaction")
  23369. }
  23370. tx := &Tx{config: m.config}
  23371. tx.init()
  23372. return tx, nil
  23373. }
  23374. // SetID sets the value of the id field. Note that this
  23375. // operation is only accepted on creation of SopStage entities.
  23376. func (m *SopStageMutation) SetID(id uint64) {
  23377. m.id = &id
  23378. }
  23379. // ID returns the ID value in the mutation. Note that the ID is only available
  23380. // if it was provided to the builder or after it was returned from the database.
  23381. func (m *SopStageMutation) ID() (id uint64, exists bool) {
  23382. if m.id == nil {
  23383. return
  23384. }
  23385. return *m.id, true
  23386. }
  23387. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  23388. // That means, if the mutation is applied within a transaction with an isolation level such
  23389. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  23390. // or updated by the mutation.
  23391. func (m *SopStageMutation) IDs(ctx context.Context) ([]uint64, error) {
  23392. switch {
  23393. case m.op.Is(OpUpdateOne | OpDeleteOne):
  23394. id, exists := m.ID()
  23395. if exists {
  23396. return []uint64{id}, nil
  23397. }
  23398. fallthrough
  23399. case m.op.Is(OpUpdate | OpDelete):
  23400. return m.Client().SopStage.Query().Where(m.predicates...).IDs(ctx)
  23401. default:
  23402. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  23403. }
  23404. }
  23405. // SetCreatedAt sets the "created_at" field.
  23406. func (m *SopStageMutation) SetCreatedAt(t time.Time) {
  23407. m.created_at = &t
  23408. }
  23409. // CreatedAt returns the value of the "created_at" field in the mutation.
  23410. func (m *SopStageMutation) CreatedAt() (r time.Time, exists bool) {
  23411. v := m.created_at
  23412. if v == nil {
  23413. return
  23414. }
  23415. return *v, true
  23416. }
  23417. // OldCreatedAt returns the old "created_at" 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) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  23421. if !m.op.Is(OpUpdateOne) {
  23422. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  23423. }
  23424. if m.id == nil || m.oldValue == nil {
  23425. return v, errors.New("OldCreatedAt 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 OldCreatedAt: %w", err)
  23430. }
  23431. return oldValue.CreatedAt, nil
  23432. }
  23433. // ResetCreatedAt resets all changes to the "created_at" field.
  23434. func (m *SopStageMutation) ResetCreatedAt() {
  23435. m.created_at = nil
  23436. }
  23437. // SetUpdatedAt sets the "updated_at" field.
  23438. func (m *SopStageMutation) SetUpdatedAt(t time.Time) {
  23439. m.updated_at = &t
  23440. }
  23441. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  23442. func (m *SopStageMutation) UpdatedAt() (r time.Time, exists bool) {
  23443. v := m.updated_at
  23444. if v == nil {
  23445. return
  23446. }
  23447. return *v, true
  23448. }
  23449. // OldUpdatedAt returns the old "updated_at" field's value of the SopStage entity.
  23450. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  23451. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23452. func (m *SopStageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  23453. if !m.op.Is(OpUpdateOne) {
  23454. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  23455. }
  23456. if m.id == nil || m.oldValue == nil {
  23457. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  23458. }
  23459. oldValue, err := m.oldValue(ctx)
  23460. if err != nil {
  23461. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  23462. }
  23463. return oldValue.UpdatedAt, nil
  23464. }
  23465. // ResetUpdatedAt resets all changes to the "updated_at" field.
  23466. func (m *SopStageMutation) ResetUpdatedAt() {
  23467. m.updated_at = nil
  23468. }
  23469. // SetStatus sets the "status" field.
  23470. func (m *SopStageMutation) SetStatus(u uint8) {
  23471. m.status = &u
  23472. m.addstatus = nil
  23473. }
  23474. // Status returns the value of the "status" field in the mutation.
  23475. func (m *SopStageMutation) Status() (r uint8, exists bool) {
  23476. v := m.status
  23477. if v == nil {
  23478. return
  23479. }
  23480. return *v, true
  23481. }
  23482. // OldStatus returns the old "status" field's value of the SopStage entity.
  23483. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  23484. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23485. func (m *SopStageMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  23486. if !m.op.Is(OpUpdateOne) {
  23487. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  23488. }
  23489. if m.id == nil || m.oldValue == nil {
  23490. return v, errors.New("OldStatus requires an ID field in the mutation")
  23491. }
  23492. oldValue, err := m.oldValue(ctx)
  23493. if err != nil {
  23494. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  23495. }
  23496. return oldValue.Status, nil
  23497. }
  23498. // AddStatus adds u to the "status" field.
  23499. func (m *SopStageMutation) AddStatus(u int8) {
  23500. if m.addstatus != nil {
  23501. *m.addstatus += u
  23502. } else {
  23503. m.addstatus = &u
  23504. }
  23505. }
  23506. // AddedStatus returns the value that was added to the "status" field in this mutation.
  23507. func (m *SopStageMutation) AddedStatus() (r int8, exists bool) {
  23508. v := m.addstatus
  23509. if v == nil {
  23510. return
  23511. }
  23512. return *v, true
  23513. }
  23514. // ClearStatus clears the value of the "status" field.
  23515. func (m *SopStageMutation) ClearStatus() {
  23516. m.status = nil
  23517. m.addstatus = nil
  23518. m.clearedFields[sopstage.FieldStatus] = struct{}{}
  23519. }
  23520. // StatusCleared returns if the "status" field was cleared in this mutation.
  23521. func (m *SopStageMutation) StatusCleared() bool {
  23522. _, ok := m.clearedFields[sopstage.FieldStatus]
  23523. return ok
  23524. }
  23525. // ResetStatus resets all changes to the "status" field.
  23526. func (m *SopStageMutation) ResetStatus() {
  23527. m.status = nil
  23528. m.addstatus = nil
  23529. delete(m.clearedFields, sopstage.FieldStatus)
  23530. }
  23531. // SetDeletedAt sets the "deleted_at" field.
  23532. func (m *SopStageMutation) SetDeletedAt(t time.Time) {
  23533. m.deleted_at = &t
  23534. }
  23535. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  23536. func (m *SopStageMutation) DeletedAt() (r time.Time, exists bool) {
  23537. v := m.deleted_at
  23538. if v == nil {
  23539. return
  23540. }
  23541. return *v, true
  23542. }
  23543. // OldDeletedAt returns the old "deleted_at" field's value of the SopStage entity.
  23544. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  23545. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23546. func (m *SopStageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  23547. if !m.op.Is(OpUpdateOne) {
  23548. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  23549. }
  23550. if m.id == nil || m.oldValue == nil {
  23551. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  23552. }
  23553. oldValue, err := m.oldValue(ctx)
  23554. if err != nil {
  23555. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  23556. }
  23557. return oldValue.DeletedAt, nil
  23558. }
  23559. // ClearDeletedAt clears the value of the "deleted_at" field.
  23560. func (m *SopStageMutation) ClearDeletedAt() {
  23561. m.deleted_at = nil
  23562. m.clearedFields[sopstage.FieldDeletedAt] = struct{}{}
  23563. }
  23564. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  23565. func (m *SopStageMutation) DeletedAtCleared() bool {
  23566. _, ok := m.clearedFields[sopstage.FieldDeletedAt]
  23567. return ok
  23568. }
  23569. // ResetDeletedAt resets all changes to the "deleted_at" field.
  23570. func (m *SopStageMutation) ResetDeletedAt() {
  23571. m.deleted_at = nil
  23572. delete(m.clearedFields, sopstage.FieldDeletedAt)
  23573. }
  23574. // SetTaskID sets the "task_id" field.
  23575. func (m *SopStageMutation) SetTaskID(u uint64) {
  23576. m.sop_task = &u
  23577. }
  23578. // TaskID returns the value of the "task_id" field in the mutation.
  23579. func (m *SopStageMutation) TaskID() (r uint64, exists bool) {
  23580. v := m.sop_task
  23581. if v == nil {
  23582. return
  23583. }
  23584. return *v, true
  23585. }
  23586. // OldTaskID returns the old "task_id" field's value of the SopStage entity.
  23587. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  23588. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23589. func (m *SopStageMutation) OldTaskID(ctx context.Context) (v uint64, err error) {
  23590. if !m.op.Is(OpUpdateOne) {
  23591. return v, errors.New("OldTaskID is only allowed on UpdateOne operations")
  23592. }
  23593. if m.id == nil || m.oldValue == nil {
  23594. return v, errors.New("OldTaskID requires an ID field in the mutation")
  23595. }
  23596. oldValue, err := m.oldValue(ctx)
  23597. if err != nil {
  23598. return v, fmt.Errorf("querying old value for OldTaskID: %w", err)
  23599. }
  23600. return oldValue.TaskID, nil
  23601. }
  23602. // ResetTaskID resets all changes to the "task_id" field.
  23603. func (m *SopStageMutation) ResetTaskID() {
  23604. m.sop_task = nil
  23605. }
  23606. // SetName sets the "name" field.
  23607. func (m *SopStageMutation) SetName(s string) {
  23608. m.name = &s
  23609. }
  23610. // Name returns the value of the "name" field in the mutation.
  23611. func (m *SopStageMutation) Name() (r string, exists bool) {
  23612. v := m.name
  23613. if v == nil {
  23614. return
  23615. }
  23616. return *v, true
  23617. }
  23618. // OldName returns the old "name" field's value of the SopStage entity.
  23619. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  23620. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23621. func (m *SopStageMutation) OldName(ctx context.Context) (v string, err error) {
  23622. if !m.op.Is(OpUpdateOne) {
  23623. return v, errors.New("OldName is only allowed on UpdateOne operations")
  23624. }
  23625. if m.id == nil || m.oldValue == nil {
  23626. return v, errors.New("OldName requires an ID field in the mutation")
  23627. }
  23628. oldValue, err := m.oldValue(ctx)
  23629. if err != nil {
  23630. return v, fmt.Errorf("querying old value for OldName: %w", err)
  23631. }
  23632. return oldValue.Name, nil
  23633. }
  23634. // ResetName resets all changes to the "name" field.
  23635. func (m *SopStageMutation) ResetName() {
  23636. m.name = nil
  23637. }
  23638. // SetConditionType sets the "condition_type" field.
  23639. func (m *SopStageMutation) SetConditionType(i int) {
  23640. m.condition_type = &i
  23641. m.addcondition_type = nil
  23642. }
  23643. // ConditionType returns the value of the "condition_type" field in the mutation.
  23644. func (m *SopStageMutation) ConditionType() (r int, exists bool) {
  23645. v := m.condition_type
  23646. if v == nil {
  23647. return
  23648. }
  23649. return *v, true
  23650. }
  23651. // OldConditionType returns the old "condition_type" field's value of the SopStage entity.
  23652. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  23653. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23654. func (m *SopStageMutation) OldConditionType(ctx context.Context) (v int, err error) {
  23655. if !m.op.Is(OpUpdateOne) {
  23656. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  23657. }
  23658. if m.id == nil || m.oldValue == nil {
  23659. return v, errors.New("OldConditionType requires an ID field in the mutation")
  23660. }
  23661. oldValue, err := m.oldValue(ctx)
  23662. if err != nil {
  23663. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  23664. }
  23665. return oldValue.ConditionType, nil
  23666. }
  23667. // AddConditionType adds i to the "condition_type" field.
  23668. func (m *SopStageMutation) AddConditionType(i int) {
  23669. if m.addcondition_type != nil {
  23670. *m.addcondition_type += i
  23671. } else {
  23672. m.addcondition_type = &i
  23673. }
  23674. }
  23675. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  23676. func (m *SopStageMutation) AddedConditionType() (r int, exists bool) {
  23677. v := m.addcondition_type
  23678. if v == nil {
  23679. return
  23680. }
  23681. return *v, true
  23682. }
  23683. // ResetConditionType resets all changes to the "condition_type" field.
  23684. func (m *SopStageMutation) ResetConditionType() {
  23685. m.condition_type = nil
  23686. m.addcondition_type = nil
  23687. }
  23688. // SetConditionOperator sets the "condition_operator" field.
  23689. func (m *SopStageMutation) SetConditionOperator(i int) {
  23690. m.condition_operator = &i
  23691. m.addcondition_operator = nil
  23692. }
  23693. // ConditionOperator returns the value of the "condition_operator" field in the mutation.
  23694. func (m *SopStageMutation) ConditionOperator() (r int, exists bool) {
  23695. v := m.condition_operator
  23696. if v == nil {
  23697. return
  23698. }
  23699. return *v, true
  23700. }
  23701. // OldConditionOperator returns the old "condition_operator" field's value of the SopStage entity.
  23702. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  23703. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23704. func (m *SopStageMutation) OldConditionOperator(ctx context.Context) (v int, err error) {
  23705. if !m.op.Is(OpUpdateOne) {
  23706. return v, errors.New("OldConditionOperator is only allowed on UpdateOne operations")
  23707. }
  23708. if m.id == nil || m.oldValue == nil {
  23709. return v, errors.New("OldConditionOperator requires an ID field in the mutation")
  23710. }
  23711. oldValue, err := m.oldValue(ctx)
  23712. if err != nil {
  23713. return v, fmt.Errorf("querying old value for OldConditionOperator: %w", err)
  23714. }
  23715. return oldValue.ConditionOperator, nil
  23716. }
  23717. // AddConditionOperator adds i to the "condition_operator" field.
  23718. func (m *SopStageMutation) AddConditionOperator(i int) {
  23719. if m.addcondition_operator != nil {
  23720. *m.addcondition_operator += i
  23721. } else {
  23722. m.addcondition_operator = &i
  23723. }
  23724. }
  23725. // AddedConditionOperator returns the value that was added to the "condition_operator" field in this mutation.
  23726. func (m *SopStageMutation) AddedConditionOperator() (r int, exists bool) {
  23727. v := m.addcondition_operator
  23728. if v == nil {
  23729. return
  23730. }
  23731. return *v, true
  23732. }
  23733. // ResetConditionOperator resets all changes to the "condition_operator" field.
  23734. func (m *SopStageMutation) ResetConditionOperator() {
  23735. m.condition_operator = nil
  23736. m.addcondition_operator = nil
  23737. }
  23738. // SetConditionList sets the "condition_list" field.
  23739. func (m *SopStageMutation) SetConditionList(ct []custom_types.Condition) {
  23740. m.condition_list = &ct
  23741. m.appendcondition_list = nil
  23742. }
  23743. // ConditionList returns the value of the "condition_list" field in the mutation.
  23744. func (m *SopStageMutation) ConditionList() (r []custom_types.Condition, exists bool) {
  23745. v := m.condition_list
  23746. if v == nil {
  23747. return
  23748. }
  23749. return *v, true
  23750. }
  23751. // OldConditionList returns the old "condition_list" field's value of the SopStage entity.
  23752. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  23753. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23754. func (m *SopStageMutation) OldConditionList(ctx context.Context) (v []custom_types.Condition, err error) {
  23755. if !m.op.Is(OpUpdateOne) {
  23756. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  23757. }
  23758. if m.id == nil || m.oldValue == nil {
  23759. return v, errors.New("OldConditionList requires an ID field in the mutation")
  23760. }
  23761. oldValue, err := m.oldValue(ctx)
  23762. if err != nil {
  23763. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  23764. }
  23765. return oldValue.ConditionList, nil
  23766. }
  23767. // AppendConditionList adds ct to the "condition_list" field.
  23768. func (m *SopStageMutation) AppendConditionList(ct []custom_types.Condition) {
  23769. m.appendcondition_list = append(m.appendcondition_list, ct...)
  23770. }
  23771. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  23772. func (m *SopStageMutation) AppendedConditionList() ([]custom_types.Condition, bool) {
  23773. if len(m.appendcondition_list) == 0 {
  23774. return nil, false
  23775. }
  23776. return m.appendcondition_list, true
  23777. }
  23778. // ResetConditionList resets all changes to the "condition_list" field.
  23779. func (m *SopStageMutation) ResetConditionList() {
  23780. m.condition_list = nil
  23781. m.appendcondition_list = nil
  23782. }
  23783. // SetActionMessage sets the "action_message" field.
  23784. func (m *SopStageMutation) SetActionMessage(ct []custom_types.Action) {
  23785. m.action_message = &ct
  23786. m.appendaction_message = nil
  23787. }
  23788. // ActionMessage returns the value of the "action_message" field in the mutation.
  23789. func (m *SopStageMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  23790. v := m.action_message
  23791. if v == nil {
  23792. return
  23793. }
  23794. return *v, true
  23795. }
  23796. // OldActionMessage returns the old "action_message" field's value of the SopStage entity.
  23797. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  23798. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23799. func (m *SopStageMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  23800. if !m.op.Is(OpUpdateOne) {
  23801. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  23802. }
  23803. if m.id == nil || m.oldValue == nil {
  23804. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  23805. }
  23806. oldValue, err := m.oldValue(ctx)
  23807. if err != nil {
  23808. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  23809. }
  23810. return oldValue.ActionMessage, nil
  23811. }
  23812. // AppendActionMessage adds ct to the "action_message" field.
  23813. func (m *SopStageMutation) AppendActionMessage(ct []custom_types.Action) {
  23814. m.appendaction_message = append(m.appendaction_message, ct...)
  23815. }
  23816. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  23817. func (m *SopStageMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  23818. if len(m.appendaction_message) == 0 {
  23819. return nil, false
  23820. }
  23821. return m.appendaction_message, true
  23822. }
  23823. // ClearActionMessage clears the value of the "action_message" field.
  23824. func (m *SopStageMutation) ClearActionMessage() {
  23825. m.action_message = nil
  23826. m.appendaction_message = nil
  23827. m.clearedFields[sopstage.FieldActionMessage] = struct{}{}
  23828. }
  23829. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  23830. func (m *SopStageMutation) ActionMessageCleared() bool {
  23831. _, ok := m.clearedFields[sopstage.FieldActionMessage]
  23832. return ok
  23833. }
  23834. // ResetActionMessage resets all changes to the "action_message" field.
  23835. func (m *SopStageMutation) ResetActionMessage() {
  23836. m.action_message = nil
  23837. m.appendaction_message = nil
  23838. delete(m.clearedFields, sopstage.FieldActionMessage)
  23839. }
  23840. // SetActionLabelAdd sets the "action_label_add" field.
  23841. func (m *SopStageMutation) SetActionLabelAdd(u []uint64) {
  23842. m.action_label_add = &u
  23843. m.appendaction_label_add = nil
  23844. }
  23845. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  23846. func (m *SopStageMutation) ActionLabelAdd() (r []uint64, exists bool) {
  23847. v := m.action_label_add
  23848. if v == nil {
  23849. return
  23850. }
  23851. return *v, true
  23852. }
  23853. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopStage entity.
  23854. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  23855. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23856. func (m *SopStageMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  23857. if !m.op.Is(OpUpdateOne) {
  23858. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  23859. }
  23860. if m.id == nil || m.oldValue == nil {
  23861. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  23862. }
  23863. oldValue, err := m.oldValue(ctx)
  23864. if err != nil {
  23865. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  23866. }
  23867. return oldValue.ActionLabelAdd, nil
  23868. }
  23869. // AppendActionLabelAdd adds u to the "action_label_add" field.
  23870. func (m *SopStageMutation) AppendActionLabelAdd(u []uint64) {
  23871. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  23872. }
  23873. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  23874. func (m *SopStageMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  23875. if len(m.appendaction_label_add) == 0 {
  23876. return nil, false
  23877. }
  23878. return m.appendaction_label_add, true
  23879. }
  23880. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  23881. func (m *SopStageMutation) ClearActionLabelAdd() {
  23882. m.action_label_add = nil
  23883. m.appendaction_label_add = nil
  23884. m.clearedFields[sopstage.FieldActionLabelAdd] = struct{}{}
  23885. }
  23886. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  23887. func (m *SopStageMutation) ActionLabelAddCleared() bool {
  23888. _, ok := m.clearedFields[sopstage.FieldActionLabelAdd]
  23889. return ok
  23890. }
  23891. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  23892. func (m *SopStageMutation) ResetActionLabelAdd() {
  23893. m.action_label_add = nil
  23894. m.appendaction_label_add = nil
  23895. delete(m.clearedFields, sopstage.FieldActionLabelAdd)
  23896. }
  23897. // SetActionLabelDel sets the "action_label_del" field.
  23898. func (m *SopStageMutation) SetActionLabelDel(u []uint64) {
  23899. m.action_label_del = &u
  23900. m.appendaction_label_del = nil
  23901. }
  23902. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  23903. func (m *SopStageMutation) ActionLabelDel() (r []uint64, exists bool) {
  23904. v := m.action_label_del
  23905. if v == nil {
  23906. return
  23907. }
  23908. return *v, true
  23909. }
  23910. // OldActionLabelDel returns the old "action_label_del" field's value of the SopStage entity.
  23911. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  23912. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23913. func (m *SopStageMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  23914. if !m.op.Is(OpUpdateOne) {
  23915. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  23916. }
  23917. if m.id == nil || m.oldValue == nil {
  23918. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  23919. }
  23920. oldValue, err := m.oldValue(ctx)
  23921. if err != nil {
  23922. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  23923. }
  23924. return oldValue.ActionLabelDel, nil
  23925. }
  23926. // AppendActionLabelDel adds u to the "action_label_del" field.
  23927. func (m *SopStageMutation) AppendActionLabelDel(u []uint64) {
  23928. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  23929. }
  23930. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  23931. func (m *SopStageMutation) AppendedActionLabelDel() ([]uint64, bool) {
  23932. if len(m.appendaction_label_del) == 0 {
  23933. return nil, false
  23934. }
  23935. return m.appendaction_label_del, true
  23936. }
  23937. // ClearActionLabelDel clears the value of the "action_label_del" field.
  23938. func (m *SopStageMutation) ClearActionLabelDel() {
  23939. m.action_label_del = nil
  23940. m.appendaction_label_del = nil
  23941. m.clearedFields[sopstage.FieldActionLabelDel] = struct{}{}
  23942. }
  23943. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  23944. func (m *SopStageMutation) ActionLabelDelCleared() bool {
  23945. _, ok := m.clearedFields[sopstage.FieldActionLabelDel]
  23946. return ok
  23947. }
  23948. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  23949. func (m *SopStageMutation) ResetActionLabelDel() {
  23950. m.action_label_del = nil
  23951. m.appendaction_label_del = nil
  23952. delete(m.clearedFields, sopstage.FieldActionLabelDel)
  23953. }
  23954. // SetActionForward sets the "action_forward" field.
  23955. func (m *SopStageMutation) SetActionForward(ctf *custom_types.ActionForward) {
  23956. m.action_forward = &ctf
  23957. }
  23958. // ActionForward returns the value of the "action_forward" field in the mutation.
  23959. func (m *SopStageMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  23960. v := m.action_forward
  23961. if v == nil {
  23962. return
  23963. }
  23964. return *v, true
  23965. }
  23966. // OldActionForward returns the old "action_forward" field's value of the SopStage entity.
  23967. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  23968. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23969. func (m *SopStageMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  23970. if !m.op.Is(OpUpdateOne) {
  23971. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  23972. }
  23973. if m.id == nil || m.oldValue == nil {
  23974. return v, errors.New("OldActionForward requires an ID field in the mutation")
  23975. }
  23976. oldValue, err := m.oldValue(ctx)
  23977. if err != nil {
  23978. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  23979. }
  23980. return oldValue.ActionForward, nil
  23981. }
  23982. // ClearActionForward clears the value of the "action_forward" field.
  23983. func (m *SopStageMutation) ClearActionForward() {
  23984. m.action_forward = nil
  23985. m.clearedFields[sopstage.FieldActionForward] = struct{}{}
  23986. }
  23987. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  23988. func (m *SopStageMutation) ActionForwardCleared() bool {
  23989. _, ok := m.clearedFields[sopstage.FieldActionForward]
  23990. return ok
  23991. }
  23992. // ResetActionForward resets all changes to the "action_forward" field.
  23993. func (m *SopStageMutation) ResetActionForward() {
  23994. m.action_forward = nil
  23995. delete(m.clearedFields, sopstage.FieldActionForward)
  23996. }
  23997. // SetIndexSort sets the "index_sort" field.
  23998. func (m *SopStageMutation) SetIndexSort(i int) {
  23999. m.index_sort = &i
  24000. m.addindex_sort = nil
  24001. }
  24002. // IndexSort returns the value of the "index_sort" field in the mutation.
  24003. func (m *SopStageMutation) IndexSort() (r int, exists bool) {
  24004. v := m.index_sort
  24005. if v == nil {
  24006. return
  24007. }
  24008. return *v, true
  24009. }
  24010. // OldIndexSort returns the old "index_sort" field's value of the SopStage entity.
  24011. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  24012. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24013. func (m *SopStageMutation) OldIndexSort(ctx context.Context) (v int, err error) {
  24014. if !m.op.Is(OpUpdateOne) {
  24015. return v, errors.New("OldIndexSort is only allowed on UpdateOne operations")
  24016. }
  24017. if m.id == nil || m.oldValue == nil {
  24018. return v, errors.New("OldIndexSort requires an ID field in the mutation")
  24019. }
  24020. oldValue, err := m.oldValue(ctx)
  24021. if err != nil {
  24022. return v, fmt.Errorf("querying old value for OldIndexSort: %w", err)
  24023. }
  24024. return oldValue.IndexSort, nil
  24025. }
  24026. // AddIndexSort adds i to the "index_sort" field.
  24027. func (m *SopStageMutation) AddIndexSort(i int) {
  24028. if m.addindex_sort != nil {
  24029. *m.addindex_sort += i
  24030. } else {
  24031. m.addindex_sort = &i
  24032. }
  24033. }
  24034. // AddedIndexSort returns the value that was added to the "index_sort" field in this mutation.
  24035. func (m *SopStageMutation) AddedIndexSort() (r int, exists bool) {
  24036. v := m.addindex_sort
  24037. if v == nil {
  24038. return
  24039. }
  24040. return *v, true
  24041. }
  24042. // ClearIndexSort clears the value of the "index_sort" field.
  24043. func (m *SopStageMutation) ClearIndexSort() {
  24044. m.index_sort = nil
  24045. m.addindex_sort = nil
  24046. m.clearedFields[sopstage.FieldIndexSort] = struct{}{}
  24047. }
  24048. // IndexSortCleared returns if the "index_sort" field was cleared in this mutation.
  24049. func (m *SopStageMutation) IndexSortCleared() bool {
  24050. _, ok := m.clearedFields[sopstage.FieldIndexSort]
  24051. return ok
  24052. }
  24053. // ResetIndexSort resets all changes to the "index_sort" field.
  24054. func (m *SopStageMutation) ResetIndexSort() {
  24055. m.index_sort = nil
  24056. m.addindex_sort = nil
  24057. delete(m.clearedFields, sopstage.FieldIndexSort)
  24058. }
  24059. // SetSopTaskID sets the "sop_task" edge to the SopTask entity by id.
  24060. func (m *SopStageMutation) SetSopTaskID(id uint64) {
  24061. m.sop_task = &id
  24062. }
  24063. // ClearSopTask clears the "sop_task" edge to the SopTask entity.
  24064. func (m *SopStageMutation) ClearSopTask() {
  24065. m.clearedsop_task = true
  24066. m.clearedFields[sopstage.FieldTaskID] = struct{}{}
  24067. }
  24068. // SopTaskCleared reports if the "sop_task" edge to the SopTask entity was cleared.
  24069. func (m *SopStageMutation) SopTaskCleared() bool {
  24070. return m.clearedsop_task
  24071. }
  24072. // SopTaskID returns the "sop_task" edge ID in the mutation.
  24073. func (m *SopStageMutation) SopTaskID() (id uint64, exists bool) {
  24074. if m.sop_task != nil {
  24075. return *m.sop_task, true
  24076. }
  24077. return
  24078. }
  24079. // SopTaskIDs returns the "sop_task" edge IDs in the mutation.
  24080. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  24081. // SopTaskID instead. It exists only for internal usage by the builders.
  24082. func (m *SopStageMutation) SopTaskIDs() (ids []uint64) {
  24083. if id := m.sop_task; id != nil {
  24084. ids = append(ids, *id)
  24085. }
  24086. return
  24087. }
  24088. // ResetSopTask resets all changes to the "sop_task" edge.
  24089. func (m *SopStageMutation) ResetSopTask() {
  24090. m.sop_task = nil
  24091. m.clearedsop_task = false
  24092. }
  24093. // AddStageNodeIDs adds the "stage_nodes" edge to the SopNode entity by ids.
  24094. func (m *SopStageMutation) AddStageNodeIDs(ids ...uint64) {
  24095. if m.stage_nodes == nil {
  24096. m.stage_nodes = make(map[uint64]struct{})
  24097. }
  24098. for i := range ids {
  24099. m.stage_nodes[ids[i]] = struct{}{}
  24100. }
  24101. }
  24102. // ClearStageNodes clears the "stage_nodes" edge to the SopNode entity.
  24103. func (m *SopStageMutation) ClearStageNodes() {
  24104. m.clearedstage_nodes = true
  24105. }
  24106. // StageNodesCleared reports if the "stage_nodes" edge to the SopNode entity was cleared.
  24107. func (m *SopStageMutation) StageNodesCleared() bool {
  24108. return m.clearedstage_nodes
  24109. }
  24110. // RemoveStageNodeIDs removes the "stage_nodes" edge to the SopNode entity by IDs.
  24111. func (m *SopStageMutation) RemoveStageNodeIDs(ids ...uint64) {
  24112. if m.removedstage_nodes == nil {
  24113. m.removedstage_nodes = make(map[uint64]struct{})
  24114. }
  24115. for i := range ids {
  24116. delete(m.stage_nodes, ids[i])
  24117. m.removedstage_nodes[ids[i]] = struct{}{}
  24118. }
  24119. }
  24120. // RemovedStageNodes returns the removed IDs of the "stage_nodes" edge to the SopNode entity.
  24121. func (m *SopStageMutation) RemovedStageNodesIDs() (ids []uint64) {
  24122. for id := range m.removedstage_nodes {
  24123. ids = append(ids, id)
  24124. }
  24125. return
  24126. }
  24127. // StageNodesIDs returns the "stage_nodes" edge IDs in the mutation.
  24128. func (m *SopStageMutation) StageNodesIDs() (ids []uint64) {
  24129. for id := range m.stage_nodes {
  24130. ids = append(ids, id)
  24131. }
  24132. return
  24133. }
  24134. // ResetStageNodes resets all changes to the "stage_nodes" edge.
  24135. func (m *SopStageMutation) ResetStageNodes() {
  24136. m.stage_nodes = nil
  24137. m.clearedstage_nodes = false
  24138. m.removedstage_nodes = nil
  24139. }
  24140. // AddStageMessageIDs adds the "stage_messages" edge to the MessageRecords entity by ids.
  24141. func (m *SopStageMutation) AddStageMessageIDs(ids ...uint64) {
  24142. if m.stage_messages == nil {
  24143. m.stage_messages = make(map[uint64]struct{})
  24144. }
  24145. for i := range ids {
  24146. m.stage_messages[ids[i]] = struct{}{}
  24147. }
  24148. }
  24149. // ClearStageMessages clears the "stage_messages" edge to the MessageRecords entity.
  24150. func (m *SopStageMutation) ClearStageMessages() {
  24151. m.clearedstage_messages = true
  24152. }
  24153. // StageMessagesCleared reports if the "stage_messages" edge to the MessageRecords entity was cleared.
  24154. func (m *SopStageMutation) StageMessagesCleared() bool {
  24155. return m.clearedstage_messages
  24156. }
  24157. // RemoveStageMessageIDs removes the "stage_messages" edge to the MessageRecords entity by IDs.
  24158. func (m *SopStageMutation) RemoveStageMessageIDs(ids ...uint64) {
  24159. if m.removedstage_messages == nil {
  24160. m.removedstage_messages = make(map[uint64]struct{})
  24161. }
  24162. for i := range ids {
  24163. delete(m.stage_messages, ids[i])
  24164. m.removedstage_messages[ids[i]] = struct{}{}
  24165. }
  24166. }
  24167. // RemovedStageMessages returns the removed IDs of the "stage_messages" edge to the MessageRecords entity.
  24168. func (m *SopStageMutation) RemovedStageMessagesIDs() (ids []uint64) {
  24169. for id := range m.removedstage_messages {
  24170. ids = append(ids, id)
  24171. }
  24172. return
  24173. }
  24174. // StageMessagesIDs returns the "stage_messages" edge IDs in the mutation.
  24175. func (m *SopStageMutation) StageMessagesIDs() (ids []uint64) {
  24176. for id := range m.stage_messages {
  24177. ids = append(ids, id)
  24178. }
  24179. return
  24180. }
  24181. // ResetStageMessages resets all changes to the "stage_messages" edge.
  24182. func (m *SopStageMutation) ResetStageMessages() {
  24183. m.stage_messages = nil
  24184. m.clearedstage_messages = false
  24185. m.removedstage_messages = nil
  24186. }
  24187. // Where appends a list predicates to the SopStageMutation builder.
  24188. func (m *SopStageMutation) Where(ps ...predicate.SopStage) {
  24189. m.predicates = append(m.predicates, ps...)
  24190. }
  24191. // WhereP appends storage-level predicates to the SopStageMutation builder. Using this method,
  24192. // users can use type-assertion to append predicates that do not depend on any generated package.
  24193. func (m *SopStageMutation) WhereP(ps ...func(*sql.Selector)) {
  24194. p := make([]predicate.SopStage, len(ps))
  24195. for i := range ps {
  24196. p[i] = ps[i]
  24197. }
  24198. m.Where(p...)
  24199. }
  24200. // Op returns the operation name.
  24201. func (m *SopStageMutation) Op() Op {
  24202. return m.op
  24203. }
  24204. // SetOp allows setting the mutation operation.
  24205. func (m *SopStageMutation) SetOp(op Op) {
  24206. m.op = op
  24207. }
  24208. // Type returns the node type of this mutation (SopStage).
  24209. func (m *SopStageMutation) Type() string {
  24210. return m.typ
  24211. }
  24212. // Fields returns all fields that were changed during this mutation. Note that in
  24213. // order to get all numeric fields that were incremented/decremented, call
  24214. // AddedFields().
  24215. func (m *SopStageMutation) Fields() []string {
  24216. fields := make([]string, 0, 14)
  24217. if m.created_at != nil {
  24218. fields = append(fields, sopstage.FieldCreatedAt)
  24219. }
  24220. if m.updated_at != nil {
  24221. fields = append(fields, sopstage.FieldUpdatedAt)
  24222. }
  24223. if m.status != nil {
  24224. fields = append(fields, sopstage.FieldStatus)
  24225. }
  24226. if m.deleted_at != nil {
  24227. fields = append(fields, sopstage.FieldDeletedAt)
  24228. }
  24229. if m.sop_task != nil {
  24230. fields = append(fields, sopstage.FieldTaskID)
  24231. }
  24232. if m.name != nil {
  24233. fields = append(fields, sopstage.FieldName)
  24234. }
  24235. if m.condition_type != nil {
  24236. fields = append(fields, sopstage.FieldConditionType)
  24237. }
  24238. if m.condition_operator != nil {
  24239. fields = append(fields, sopstage.FieldConditionOperator)
  24240. }
  24241. if m.condition_list != nil {
  24242. fields = append(fields, sopstage.FieldConditionList)
  24243. }
  24244. if m.action_message != nil {
  24245. fields = append(fields, sopstage.FieldActionMessage)
  24246. }
  24247. if m.action_label_add != nil {
  24248. fields = append(fields, sopstage.FieldActionLabelAdd)
  24249. }
  24250. if m.action_label_del != nil {
  24251. fields = append(fields, sopstage.FieldActionLabelDel)
  24252. }
  24253. if m.action_forward != nil {
  24254. fields = append(fields, sopstage.FieldActionForward)
  24255. }
  24256. if m.index_sort != nil {
  24257. fields = append(fields, sopstage.FieldIndexSort)
  24258. }
  24259. return fields
  24260. }
  24261. // Field returns the value of a field with the given name. The second boolean
  24262. // return value indicates that this field was not set, or was not defined in the
  24263. // schema.
  24264. func (m *SopStageMutation) Field(name string) (ent.Value, bool) {
  24265. switch name {
  24266. case sopstage.FieldCreatedAt:
  24267. return m.CreatedAt()
  24268. case sopstage.FieldUpdatedAt:
  24269. return m.UpdatedAt()
  24270. case sopstage.FieldStatus:
  24271. return m.Status()
  24272. case sopstage.FieldDeletedAt:
  24273. return m.DeletedAt()
  24274. case sopstage.FieldTaskID:
  24275. return m.TaskID()
  24276. case sopstage.FieldName:
  24277. return m.Name()
  24278. case sopstage.FieldConditionType:
  24279. return m.ConditionType()
  24280. case sopstage.FieldConditionOperator:
  24281. return m.ConditionOperator()
  24282. case sopstage.FieldConditionList:
  24283. return m.ConditionList()
  24284. case sopstage.FieldActionMessage:
  24285. return m.ActionMessage()
  24286. case sopstage.FieldActionLabelAdd:
  24287. return m.ActionLabelAdd()
  24288. case sopstage.FieldActionLabelDel:
  24289. return m.ActionLabelDel()
  24290. case sopstage.FieldActionForward:
  24291. return m.ActionForward()
  24292. case sopstage.FieldIndexSort:
  24293. return m.IndexSort()
  24294. }
  24295. return nil, false
  24296. }
  24297. // OldField returns the old value of the field from the database. An error is
  24298. // returned if the mutation operation is not UpdateOne, or the query to the
  24299. // database failed.
  24300. func (m *SopStageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  24301. switch name {
  24302. case sopstage.FieldCreatedAt:
  24303. return m.OldCreatedAt(ctx)
  24304. case sopstage.FieldUpdatedAt:
  24305. return m.OldUpdatedAt(ctx)
  24306. case sopstage.FieldStatus:
  24307. return m.OldStatus(ctx)
  24308. case sopstage.FieldDeletedAt:
  24309. return m.OldDeletedAt(ctx)
  24310. case sopstage.FieldTaskID:
  24311. return m.OldTaskID(ctx)
  24312. case sopstage.FieldName:
  24313. return m.OldName(ctx)
  24314. case sopstage.FieldConditionType:
  24315. return m.OldConditionType(ctx)
  24316. case sopstage.FieldConditionOperator:
  24317. return m.OldConditionOperator(ctx)
  24318. case sopstage.FieldConditionList:
  24319. return m.OldConditionList(ctx)
  24320. case sopstage.FieldActionMessage:
  24321. return m.OldActionMessage(ctx)
  24322. case sopstage.FieldActionLabelAdd:
  24323. return m.OldActionLabelAdd(ctx)
  24324. case sopstage.FieldActionLabelDel:
  24325. return m.OldActionLabelDel(ctx)
  24326. case sopstage.FieldActionForward:
  24327. return m.OldActionForward(ctx)
  24328. case sopstage.FieldIndexSort:
  24329. return m.OldIndexSort(ctx)
  24330. }
  24331. return nil, fmt.Errorf("unknown SopStage field %s", name)
  24332. }
  24333. // SetField sets the value of a field with the given name. It returns an error if
  24334. // the field is not defined in the schema, or if the type mismatched the field
  24335. // type.
  24336. func (m *SopStageMutation) SetField(name string, value ent.Value) error {
  24337. switch name {
  24338. case sopstage.FieldCreatedAt:
  24339. v, ok := value.(time.Time)
  24340. if !ok {
  24341. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24342. }
  24343. m.SetCreatedAt(v)
  24344. return nil
  24345. case sopstage.FieldUpdatedAt:
  24346. v, ok := value.(time.Time)
  24347. if !ok {
  24348. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24349. }
  24350. m.SetUpdatedAt(v)
  24351. return nil
  24352. case sopstage.FieldStatus:
  24353. v, ok := value.(uint8)
  24354. if !ok {
  24355. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24356. }
  24357. m.SetStatus(v)
  24358. return nil
  24359. case sopstage.FieldDeletedAt:
  24360. v, ok := value.(time.Time)
  24361. if !ok {
  24362. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24363. }
  24364. m.SetDeletedAt(v)
  24365. return nil
  24366. case sopstage.FieldTaskID:
  24367. v, ok := value.(uint64)
  24368. if !ok {
  24369. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24370. }
  24371. m.SetTaskID(v)
  24372. return nil
  24373. case sopstage.FieldName:
  24374. v, ok := value.(string)
  24375. if !ok {
  24376. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24377. }
  24378. m.SetName(v)
  24379. return nil
  24380. case sopstage.FieldConditionType:
  24381. v, ok := value.(int)
  24382. if !ok {
  24383. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24384. }
  24385. m.SetConditionType(v)
  24386. return nil
  24387. case sopstage.FieldConditionOperator:
  24388. v, ok := value.(int)
  24389. if !ok {
  24390. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24391. }
  24392. m.SetConditionOperator(v)
  24393. return nil
  24394. case sopstage.FieldConditionList:
  24395. v, ok := value.([]custom_types.Condition)
  24396. if !ok {
  24397. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24398. }
  24399. m.SetConditionList(v)
  24400. return nil
  24401. case sopstage.FieldActionMessage:
  24402. v, ok := value.([]custom_types.Action)
  24403. if !ok {
  24404. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24405. }
  24406. m.SetActionMessage(v)
  24407. return nil
  24408. case sopstage.FieldActionLabelAdd:
  24409. v, ok := value.([]uint64)
  24410. if !ok {
  24411. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24412. }
  24413. m.SetActionLabelAdd(v)
  24414. return nil
  24415. case sopstage.FieldActionLabelDel:
  24416. v, ok := value.([]uint64)
  24417. if !ok {
  24418. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24419. }
  24420. m.SetActionLabelDel(v)
  24421. return nil
  24422. case sopstage.FieldActionForward:
  24423. v, ok := value.(*custom_types.ActionForward)
  24424. if !ok {
  24425. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24426. }
  24427. m.SetActionForward(v)
  24428. return nil
  24429. case sopstage.FieldIndexSort:
  24430. v, ok := value.(int)
  24431. if !ok {
  24432. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24433. }
  24434. m.SetIndexSort(v)
  24435. return nil
  24436. }
  24437. return fmt.Errorf("unknown SopStage field %s", name)
  24438. }
  24439. // AddedFields returns all numeric fields that were incremented/decremented during
  24440. // this mutation.
  24441. func (m *SopStageMutation) AddedFields() []string {
  24442. var fields []string
  24443. if m.addstatus != nil {
  24444. fields = append(fields, sopstage.FieldStatus)
  24445. }
  24446. if m.addcondition_type != nil {
  24447. fields = append(fields, sopstage.FieldConditionType)
  24448. }
  24449. if m.addcondition_operator != nil {
  24450. fields = append(fields, sopstage.FieldConditionOperator)
  24451. }
  24452. if m.addindex_sort != nil {
  24453. fields = append(fields, sopstage.FieldIndexSort)
  24454. }
  24455. return fields
  24456. }
  24457. // AddedField returns the numeric value that was incremented/decremented on a field
  24458. // with the given name. The second boolean return value indicates that this field
  24459. // was not set, or was not defined in the schema.
  24460. func (m *SopStageMutation) AddedField(name string) (ent.Value, bool) {
  24461. switch name {
  24462. case sopstage.FieldStatus:
  24463. return m.AddedStatus()
  24464. case sopstage.FieldConditionType:
  24465. return m.AddedConditionType()
  24466. case sopstage.FieldConditionOperator:
  24467. return m.AddedConditionOperator()
  24468. case sopstage.FieldIndexSort:
  24469. return m.AddedIndexSort()
  24470. }
  24471. return nil, false
  24472. }
  24473. // AddField adds the value to the field with the given name. It returns an error if
  24474. // the field is not defined in the schema, or if the type mismatched the field
  24475. // type.
  24476. func (m *SopStageMutation) AddField(name string, value ent.Value) error {
  24477. switch name {
  24478. case sopstage.FieldStatus:
  24479. v, ok := value.(int8)
  24480. if !ok {
  24481. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24482. }
  24483. m.AddStatus(v)
  24484. return nil
  24485. case sopstage.FieldConditionType:
  24486. v, ok := value.(int)
  24487. if !ok {
  24488. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24489. }
  24490. m.AddConditionType(v)
  24491. return nil
  24492. case sopstage.FieldConditionOperator:
  24493. v, ok := value.(int)
  24494. if !ok {
  24495. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24496. }
  24497. m.AddConditionOperator(v)
  24498. return nil
  24499. case sopstage.FieldIndexSort:
  24500. v, ok := value.(int)
  24501. if !ok {
  24502. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24503. }
  24504. m.AddIndexSort(v)
  24505. return nil
  24506. }
  24507. return fmt.Errorf("unknown SopStage numeric field %s", name)
  24508. }
  24509. // ClearedFields returns all nullable fields that were cleared during this
  24510. // mutation.
  24511. func (m *SopStageMutation) ClearedFields() []string {
  24512. var fields []string
  24513. if m.FieldCleared(sopstage.FieldStatus) {
  24514. fields = append(fields, sopstage.FieldStatus)
  24515. }
  24516. if m.FieldCleared(sopstage.FieldDeletedAt) {
  24517. fields = append(fields, sopstage.FieldDeletedAt)
  24518. }
  24519. if m.FieldCleared(sopstage.FieldActionMessage) {
  24520. fields = append(fields, sopstage.FieldActionMessage)
  24521. }
  24522. if m.FieldCleared(sopstage.FieldActionLabelAdd) {
  24523. fields = append(fields, sopstage.FieldActionLabelAdd)
  24524. }
  24525. if m.FieldCleared(sopstage.FieldActionLabelDel) {
  24526. fields = append(fields, sopstage.FieldActionLabelDel)
  24527. }
  24528. if m.FieldCleared(sopstage.FieldActionForward) {
  24529. fields = append(fields, sopstage.FieldActionForward)
  24530. }
  24531. if m.FieldCleared(sopstage.FieldIndexSort) {
  24532. fields = append(fields, sopstage.FieldIndexSort)
  24533. }
  24534. return fields
  24535. }
  24536. // FieldCleared returns a boolean indicating if a field with the given name was
  24537. // cleared in this mutation.
  24538. func (m *SopStageMutation) FieldCleared(name string) bool {
  24539. _, ok := m.clearedFields[name]
  24540. return ok
  24541. }
  24542. // ClearField clears the value of the field with the given name. It returns an
  24543. // error if the field is not defined in the schema.
  24544. func (m *SopStageMutation) ClearField(name string) error {
  24545. switch name {
  24546. case sopstage.FieldStatus:
  24547. m.ClearStatus()
  24548. return nil
  24549. case sopstage.FieldDeletedAt:
  24550. m.ClearDeletedAt()
  24551. return nil
  24552. case sopstage.FieldActionMessage:
  24553. m.ClearActionMessage()
  24554. return nil
  24555. case sopstage.FieldActionLabelAdd:
  24556. m.ClearActionLabelAdd()
  24557. return nil
  24558. case sopstage.FieldActionLabelDel:
  24559. m.ClearActionLabelDel()
  24560. return nil
  24561. case sopstage.FieldActionForward:
  24562. m.ClearActionForward()
  24563. return nil
  24564. case sopstage.FieldIndexSort:
  24565. m.ClearIndexSort()
  24566. return nil
  24567. }
  24568. return fmt.Errorf("unknown SopStage nullable field %s", name)
  24569. }
  24570. // ResetField resets all changes in the mutation for the field with the given name.
  24571. // It returns an error if the field is not defined in the schema.
  24572. func (m *SopStageMutation) ResetField(name string) error {
  24573. switch name {
  24574. case sopstage.FieldCreatedAt:
  24575. m.ResetCreatedAt()
  24576. return nil
  24577. case sopstage.FieldUpdatedAt:
  24578. m.ResetUpdatedAt()
  24579. return nil
  24580. case sopstage.FieldStatus:
  24581. m.ResetStatus()
  24582. return nil
  24583. case sopstage.FieldDeletedAt:
  24584. m.ResetDeletedAt()
  24585. return nil
  24586. case sopstage.FieldTaskID:
  24587. m.ResetTaskID()
  24588. return nil
  24589. case sopstage.FieldName:
  24590. m.ResetName()
  24591. return nil
  24592. case sopstage.FieldConditionType:
  24593. m.ResetConditionType()
  24594. return nil
  24595. case sopstage.FieldConditionOperator:
  24596. m.ResetConditionOperator()
  24597. return nil
  24598. case sopstage.FieldConditionList:
  24599. m.ResetConditionList()
  24600. return nil
  24601. case sopstage.FieldActionMessage:
  24602. m.ResetActionMessage()
  24603. return nil
  24604. case sopstage.FieldActionLabelAdd:
  24605. m.ResetActionLabelAdd()
  24606. return nil
  24607. case sopstage.FieldActionLabelDel:
  24608. m.ResetActionLabelDel()
  24609. return nil
  24610. case sopstage.FieldActionForward:
  24611. m.ResetActionForward()
  24612. return nil
  24613. case sopstage.FieldIndexSort:
  24614. m.ResetIndexSort()
  24615. return nil
  24616. }
  24617. return fmt.Errorf("unknown SopStage field %s", name)
  24618. }
  24619. // AddedEdges returns all edge names that were set/added in this mutation.
  24620. func (m *SopStageMutation) AddedEdges() []string {
  24621. edges := make([]string, 0, 3)
  24622. if m.sop_task != nil {
  24623. edges = append(edges, sopstage.EdgeSopTask)
  24624. }
  24625. if m.stage_nodes != nil {
  24626. edges = append(edges, sopstage.EdgeStageNodes)
  24627. }
  24628. if m.stage_messages != nil {
  24629. edges = append(edges, sopstage.EdgeStageMessages)
  24630. }
  24631. return edges
  24632. }
  24633. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  24634. // name in this mutation.
  24635. func (m *SopStageMutation) AddedIDs(name string) []ent.Value {
  24636. switch name {
  24637. case sopstage.EdgeSopTask:
  24638. if id := m.sop_task; id != nil {
  24639. return []ent.Value{*id}
  24640. }
  24641. case sopstage.EdgeStageNodes:
  24642. ids := make([]ent.Value, 0, len(m.stage_nodes))
  24643. for id := range m.stage_nodes {
  24644. ids = append(ids, id)
  24645. }
  24646. return ids
  24647. case sopstage.EdgeStageMessages:
  24648. ids := make([]ent.Value, 0, len(m.stage_messages))
  24649. for id := range m.stage_messages {
  24650. ids = append(ids, id)
  24651. }
  24652. return ids
  24653. }
  24654. return nil
  24655. }
  24656. // RemovedEdges returns all edge names that were removed in this mutation.
  24657. func (m *SopStageMutation) RemovedEdges() []string {
  24658. edges := make([]string, 0, 3)
  24659. if m.removedstage_nodes != nil {
  24660. edges = append(edges, sopstage.EdgeStageNodes)
  24661. }
  24662. if m.removedstage_messages != nil {
  24663. edges = append(edges, sopstage.EdgeStageMessages)
  24664. }
  24665. return edges
  24666. }
  24667. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  24668. // the given name in this mutation.
  24669. func (m *SopStageMutation) RemovedIDs(name string) []ent.Value {
  24670. switch name {
  24671. case sopstage.EdgeStageNodes:
  24672. ids := make([]ent.Value, 0, len(m.removedstage_nodes))
  24673. for id := range m.removedstage_nodes {
  24674. ids = append(ids, id)
  24675. }
  24676. return ids
  24677. case sopstage.EdgeStageMessages:
  24678. ids := make([]ent.Value, 0, len(m.removedstage_messages))
  24679. for id := range m.removedstage_messages {
  24680. ids = append(ids, id)
  24681. }
  24682. return ids
  24683. }
  24684. return nil
  24685. }
  24686. // ClearedEdges returns all edge names that were cleared in this mutation.
  24687. func (m *SopStageMutation) ClearedEdges() []string {
  24688. edges := make([]string, 0, 3)
  24689. if m.clearedsop_task {
  24690. edges = append(edges, sopstage.EdgeSopTask)
  24691. }
  24692. if m.clearedstage_nodes {
  24693. edges = append(edges, sopstage.EdgeStageNodes)
  24694. }
  24695. if m.clearedstage_messages {
  24696. edges = append(edges, sopstage.EdgeStageMessages)
  24697. }
  24698. return edges
  24699. }
  24700. // EdgeCleared returns a boolean which indicates if the edge with the given name
  24701. // was cleared in this mutation.
  24702. func (m *SopStageMutation) EdgeCleared(name string) bool {
  24703. switch name {
  24704. case sopstage.EdgeSopTask:
  24705. return m.clearedsop_task
  24706. case sopstage.EdgeStageNodes:
  24707. return m.clearedstage_nodes
  24708. case sopstage.EdgeStageMessages:
  24709. return m.clearedstage_messages
  24710. }
  24711. return false
  24712. }
  24713. // ClearEdge clears the value of the edge with the given name. It returns an error
  24714. // if that edge is not defined in the schema.
  24715. func (m *SopStageMutation) ClearEdge(name string) error {
  24716. switch name {
  24717. case sopstage.EdgeSopTask:
  24718. m.ClearSopTask()
  24719. return nil
  24720. }
  24721. return fmt.Errorf("unknown SopStage unique edge %s", name)
  24722. }
  24723. // ResetEdge resets all changes to the edge with the given name in this mutation.
  24724. // It returns an error if the edge is not defined in the schema.
  24725. func (m *SopStageMutation) ResetEdge(name string) error {
  24726. switch name {
  24727. case sopstage.EdgeSopTask:
  24728. m.ResetSopTask()
  24729. return nil
  24730. case sopstage.EdgeStageNodes:
  24731. m.ResetStageNodes()
  24732. return nil
  24733. case sopstage.EdgeStageMessages:
  24734. m.ResetStageMessages()
  24735. return nil
  24736. }
  24737. return fmt.Errorf("unknown SopStage edge %s", name)
  24738. }
  24739. // SopTaskMutation represents an operation that mutates the SopTask nodes in the graph.
  24740. type SopTaskMutation struct {
  24741. config
  24742. op Op
  24743. typ string
  24744. id *uint64
  24745. created_at *time.Time
  24746. updated_at *time.Time
  24747. status *uint8
  24748. addstatus *int8
  24749. deleted_at *time.Time
  24750. name *string
  24751. bot_wxid_list *[]string
  24752. appendbot_wxid_list []string
  24753. _type *int
  24754. add_type *int
  24755. plan_start_time *time.Time
  24756. plan_end_time *time.Time
  24757. creator_id *string
  24758. organization_id *uint64
  24759. addorganization_id *int64
  24760. token *[]string
  24761. appendtoken []string
  24762. clearedFields map[string]struct{}
  24763. task_stages map[uint64]struct{}
  24764. removedtask_stages map[uint64]struct{}
  24765. clearedtask_stages bool
  24766. done bool
  24767. oldValue func(context.Context) (*SopTask, error)
  24768. predicates []predicate.SopTask
  24769. }
  24770. var _ ent.Mutation = (*SopTaskMutation)(nil)
  24771. // soptaskOption allows management of the mutation configuration using functional options.
  24772. type soptaskOption func(*SopTaskMutation)
  24773. // newSopTaskMutation creates new mutation for the SopTask entity.
  24774. func newSopTaskMutation(c config, op Op, opts ...soptaskOption) *SopTaskMutation {
  24775. m := &SopTaskMutation{
  24776. config: c,
  24777. op: op,
  24778. typ: TypeSopTask,
  24779. clearedFields: make(map[string]struct{}),
  24780. }
  24781. for _, opt := range opts {
  24782. opt(m)
  24783. }
  24784. return m
  24785. }
  24786. // withSopTaskID sets the ID field of the mutation.
  24787. func withSopTaskID(id uint64) soptaskOption {
  24788. return func(m *SopTaskMutation) {
  24789. var (
  24790. err error
  24791. once sync.Once
  24792. value *SopTask
  24793. )
  24794. m.oldValue = func(ctx context.Context) (*SopTask, error) {
  24795. once.Do(func() {
  24796. if m.done {
  24797. err = errors.New("querying old values post mutation is not allowed")
  24798. } else {
  24799. value, err = m.Client().SopTask.Get(ctx, id)
  24800. }
  24801. })
  24802. return value, err
  24803. }
  24804. m.id = &id
  24805. }
  24806. }
  24807. // withSopTask sets the old SopTask of the mutation.
  24808. func withSopTask(node *SopTask) soptaskOption {
  24809. return func(m *SopTaskMutation) {
  24810. m.oldValue = func(context.Context) (*SopTask, error) {
  24811. return node, nil
  24812. }
  24813. m.id = &node.ID
  24814. }
  24815. }
  24816. // Client returns a new `ent.Client` from the mutation. If the mutation was
  24817. // executed in a transaction (ent.Tx), a transactional client is returned.
  24818. func (m SopTaskMutation) Client() *Client {
  24819. client := &Client{config: m.config}
  24820. client.init()
  24821. return client
  24822. }
  24823. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  24824. // it returns an error otherwise.
  24825. func (m SopTaskMutation) Tx() (*Tx, error) {
  24826. if _, ok := m.driver.(*txDriver); !ok {
  24827. return nil, errors.New("ent: mutation is not running in a transaction")
  24828. }
  24829. tx := &Tx{config: m.config}
  24830. tx.init()
  24831. return tx, nil
  24832. }
  24833. // SetID sets the value of the id field. Note that this
  24834. // operation is only accepted on creation of SopTask entities.
  24835. func (m *SopTaskMutation) SetID(id uint64) {
  24836. m.id = &id
  24837. }
  24838. // ID returns the ID value in the mutation. Note that the ID is only available
  24839. // if it was provided to the builder or after it was returned from the database.
  24840. func (m *SopTaskMutation) ID() (id uint64, exists bool) {
  24841. if m.id == nil {
  24842. return
  24843. }
  24844. return *m.id, true
  24845. }
  24846. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  24847. // That means, if the mutation is applied within a transaction with an isolation level such
  24848. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  24849. // or updated by the mutation.
  24850. func (m *SopTaskMutation) IDs(ctx context.Context) ([]uint64, error) {
  24851. switch {
  24852. case m.op.Is(OpUpdateOne | OpDeleteOne):
  24853. id, exists := m.ID()
  24854. if exists {
  24855. return []uint64{id}, nil
  24856. }
  24857. fallthrough
  24858. case m.op.Is(OpUpdate | OpDelete):
  24859. return m.Client().SopTask.Query().Where(m.predicates...).IDs(ctx)
  24860. default:
  24861. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  24862. }
  24863. }
  24864. // SetCreatedAt sets the "created_at" field.
  24865. func (m *SopTaskMutation) SetCreatedAt(t time.Time) {
  24866. m.created_at = &t
  24867. }
  24868. // CreatedAt returns the value of the "created_at" field in the mutation.
  24869. func (m *SopTaskMutation) CreatedAt() (r time.Time, exists bool) {
  24870. v := m.created_at
  24871. if v == nil {
  24872. return
  24873. }
  24874. return *v, true
  24875. }
  24876. // OldCreatedAt returns the old "created_at" field's value of the SopTask entity.
  24877. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  24878. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24879. func (m *SopTaskMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  24880. if !m.op.Is(OpUpdateOne) {
  24881. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  24882. }
  24883. if m.id == nil || m.oldValue == nil {
  24884. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  24885. }
  24886. oldValue, err := m.oldValue(ctx)
  24887. if err != nil {
  24888. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  24889. }
  24890. return oldValue.CreatedAt, nil
  24891. }
  24892. // ResetCreatedAt resets all changes to the "created_at" field.
  24893. func (m *SopTaskMutation) ResetCreatedAt() {
  24894. m.created_at = nil
  24895. }
  24896. // SetUpdatedAt sets the "updated_at" field.
  24897. func (m *SopTaskMutation) SetUpdatedAt(t time.Time) {
  24898. m.updated_at = &t
  24899. }
  24900. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  24901. func (m *SopTaskMutation) UpdatedAt() (r time.Time, exists bool) {
  24902. v := m.updated_at
  24903. if v == nil {
  24904. return
  24905. }
  24906. return *v, true
  24907. }
  24908. // OldUpdatedAt returns the old "updated_at" field's value of the SopTask entity.
  24909. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  24910. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24911. func (m *SopTaskMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  24912. if !m.op.Is(OpUpdateOne) {
  24913. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  24914. }
  24915. if m.id == nil || m.oldValue == nil {
  24916. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  24917. }
  24918. oldValue, err := m.oldValue(ctx)
  24919. if err != nil {
  24920. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  24921. }
  24922. return oldValue.UpdatedAt, nil
  24923. }
  24924. // ResetUpdatedAt resets all changes to the "updated_at" field.
  24925. func (m *SopTaskMutation) ResetUpdatedAt() {
  24926. m.updated_at = nil
  24927. }
  24928. // SetStatus sets the "status" field.
  24929. func (m *SopTaskMutation) SetStatus(u uint8) {
  24930. m.status = &u
  24931. m.addstatus = nil
  24932. }
  24933. // Status returns the value of the "status" field in the mutation.
  24934. func (m *SopTaskMutation) Status() (r uint8, exists bool) {
  24935. v := m.status
  24936. if v == nil {
  24937. return
  24938. }
  24939. return *v, true
  24940. }
  24941. // OldStatus returns the old "status" field's value of the SopTask entity.
  24942. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  24943. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24944. func (m *SopTaskMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  24945. if !m.op.Is(OpUpdateOne) {
  24946. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  24947. }
  24948. if m.id == nil || m.oldValue == nil {
  24949. return v, errors.New("OldStatus requires an ID field in the mutation")
  24950. }
  24951. oldValue, err := m.oldValue(ctx)
  24952. if err != nil {
  24953. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  24954. }
  24955. return oldValue.Status, nil
  24956. }
  24957. // AddStatus adds u to the "status" field.
  24958. func (m *SopTaskMutation) AddStatus(u int8) {
  24959. if m.addstatus != nil {
  24960. *m.addstatus += u
  24961. } else {
  24962. m.addstatus = &u
  24963. }
  24964. }
  24965. // AddedStatus returns the value that was added to the "status" field in this mutation.
  24966. func (m *SopTaskMutation) AddedStatus() (r int8, exists bool) {
  24967. v := m.addstatus
  24968. if v == nil {
  24969. return
  24970. }
  24971. return *v, true
  24972. }
  24973. // ClearStatus clears the value of the "status" field.
  24974. func (m *SopTaskMutation) ClearStatus() {
  24975. m.status = nil
  24976. m.addstatus = nil
  24977. m.clearedFields[soptask.FieldStatus] = struct{}{}
  24978. }
  24979. // StatusCleared returns if the "status" field was cleared in this mutation.
  24980. func (m *SopTaskMutation) StatusCleared() bool {
  24981. _, ok := m.clearedFields[soptask.FieldStatus]
  24982. return ok
  24983. }
  24984. // ResetStatus resets all changes to the "status" field.
  24985. func (m *SopTaskMutation) ResetStatus() {
  24986. m.status = nil
  24987. m.addstatus = nil
  24988. delete(m.clearedFields, soptask.FieldStatus)
  24989. }
  24990. // SetDeletedAt sets the "deleted_at" field.
  24991. func (m *SopTaskMutation) SetDeletedAt(t time.Time) {
  24992. m.deleted_at = &t
  24993. }
  24994. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  24995. func (m *SopTaskMutation) DeletedAt() (r time.Time, exists bool) {
  24996. v := m.deleted_at
  24997. if v == nil {
  24998. return
  24999. }
  25000. return *v, true
  25001. }
  25002. // OldDeletedAt returns the old "deleted_at" field's value of the SopTask entity.
  25003. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  25004. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25005. func (m *SopTaskMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  25006. if !m.op.Is(OpUpdateOne) {
  25007. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  25008. }
  25009. if m.id == nil || m.oldValue == nil {
  25010. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  25011. }
  25012. oldValue, err := m.oldValue(ctx)
  25013. if err != nil {
  25014. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  25015. }
  25016. return oldValue.DeletedAt, nil
  25017. }
  25018. // ClearDeletedAt clears the value of the "deleted_at" field.
  25019. func (m *SopTaskMutation) ClearDeletedAt() {
  25020. m.deleted_at = nil
  25021. m.clearedFields[soptask.FieldDeletedAt] = struct{}{}
  25022. }
  25023. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  25024. func (m *SopTaskMutation) DeletedAtCleared() bool {
  25025. _, ok := m.clearedFields[soptask.FieldDeletedAt]
  25026. return ok
  25027. }
  25028. // ResetDeletedAt resets all changes to the "deleted_at" field.
  25029. func (m *SopTaskMutation) ResetDeletedAt() {
  25030. m.deleted_at = nil
  25031. delete(m.clearedFields, soptask.FieldDeletedAt)
  25032. }
  25033. // SetName sets the "name" field.
  25034. func (m *SopTaskMutation) SetName(s string) {
  25035. m.name = &s
  25036. }
  25037. // Name returns the value of the "name" field in the mutation.
  25038. func (m *SopTaskMutation) Name() (r string, exists bool) {
  25039. v := m.name
  25040. if v == nil {
  25041. return
  25042. }
  25043. return *v, true
  25044. }
  25045. // OldName returns the old "name" field's value of the SopTask entity.
  25046. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  25047. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25048. func (m *SopTaskMutation) OldName(ctx context.Context) (v string, err error) {
  25049. if !m.op.Is(OpUpdateOne) {
  25050. return v, errors.New("OldName is only allowed on UpdateOne operations")
  25051. }
  25052. if m.id == nil || m.oldValue == nil {
  25053. return v, errors.New("OldName requires an ID field in the mutation")
  25054. }
  25055. oldValue, err := m.oldValue(ctx)
  25056. if err != nil {
  25057. return v, fmt.Errorf("querying old value for OldName: %w", err)
  25058. }
  25059. return oldValue.Name, nil
  25060. }
  25061. // ResetName resets all changes to the "name" field.
  25062. func (m *SopTaskMutation) ResetName() {
  25063. m.name = nil
  25064. }
  25065. // SetBotWxidList sets the "bot_wxid_list" field.
  25066. func (m *SopTaskMutation) SetBotWxidList(s []string) {
  25067. m.bot_wxid_list = &s
  25068. m.appendbot_wxid_list = nil
  25069. }
  25070. // BotWxidList returns the value of the "bot_wxid_list" field in the mutation.
  25071. func (m *SopTaskMutation) BotWxidList() (r []string, exists bool) {
  25072. v := m.bot_wxid_list
  25073. if v == nil {
  25074. return
  25075. }
  25076. return *v, true
  25077. }
  25078. // OldBotWxidList returns the old "bot_wxid_list" field's value of the SopTask entity.
  25079. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  25080. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25081. func (m *SopTaskMutation) OldBotWxidList(ctx context.Context) (v []string, err error) {
  25082. if !m.op.Is(OpUpdateOne) {
  25083. return v, errors.New("OldBotWxidList is only allowed on UpdateOne operations")
  25084. }
  25085. if m.id == nil || m.oldValue == nil {
  25086. return v, errors.New("OldBotWxidList requires an ID field in the mutation")
  25087. }
  25088. oldValue, err := m.oldValue(ctx)
  25089. if err != nil {
  25090. return v, fmt.Errorf("querying old value for OldBotWxidList: %w", err)
  25091. }
  25092. return oldValue.BotWxidList, nil
  25093. }
  25094. // AppendBotWxidList adds s to the "bot_wxid_list" field.
  25095. func (m *SopTaskMutation) AppendBotWxidList(s []string) {
  25096. m.appendbot_wxid_list = append(m.appendbot_wxid_list, s...)
  25097. }
  25098. // AppendedBotWxidList returns the list of values that were appended to the "bot_wxid_list" field in this mutation.
  25099. func (m *SopTaskMutation) AppendedBotWxidList() ([]string, bool) {
  25100. if len(m.appendbot_wxid_list) == 0 {
  25101. return nil, false
  25102. }
  25103. return m.appendbot_wxid_list, true
  25104. }
  25105. // ClearBotWxidList clears the value of the "bot_wxid_list" field.
  25106. func (m *SopTaskMutation) ClearBotWxidList() {
  25107. m.bot_wxid_list = nil
  25108. m.appendbot_wxid_list = nil
  25109. m.clearedFields[soptask.FieldBotWxidList] = struct{}{}
  25110. }
  25111. // BotWxidListCleared returns if the "bot_wxid_list" field was cleared in this mutation.
  25112. func (m *SopTaskMutation) BotWxidListCleared() bool {
  25113. _, ok := m.clearedFields[soptask.FieldBotWxidList]
  25114. return ok
  25115. }
  25116. // ResetBotWxidList resets all changes to the "bot_wxid_list" field.
  25117. func (m *SopTaskMutation) ResetBotWxidList() {
  25118. m.bot_wxid_list = nil
  25119. m.appendbot_wxid_list = nil
  25120. delete(m.clearedFields, soptask.FieldBotWxidList)
  25121. }
  25122. // SetType sets the "type" field.
  25123. func (m *SopTaskMutation) SetType(i int) {
  25124. m._type = &i
  25125. m.add_type = nil
  25126. }
  25127. // GetType returns the value of the "type" field in the mutation.
  25128. func (m *SopTaskMutation) GetType() (r int, exists bool) {
  25129. v := m._type
  25130. if v == nil {
  25131. return
  25132. }
  25133. return *v, true
  25134. }
  25135. // OldType returns the old "type" field's value of the SopTask entity.
  25136. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  25137. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25138. func (m *SopTaskMutation) OldType(ctx context.Context) (v int, err error) {
  25139. if !m.op.Is(OpUpdateOne) {
  25140. return v, errors.New("OldType is only allowed on UpdateOne operations")
  25141. }
  25142. if m.id == nil || m.oldValue == nil {
  25143. return v, errors.New("OldType requires an ID field in the mutation")
  25144. }
  25145. oldValue, err := m.oldValue(ctx)
  25146. if err != nil {
  25147. return v, fmt.Errorf("querying old value for OldType: %w", err)
  25148. }
  25149. return oldValue.Type, nil
  25150. }
  25151. // AddType adds i to the "type" field.
  25152. func (m *SopTaskMutation) AddType(i int) {
  25153. if m.add_type != nil {
  25154. *m.add_type += i
  25155. } else {
  25156. m.add_type = &i
  25157. }
  25158. }
  25159. // AddedType returns the value that was added to the "type" field in this mutation.
  25160. func (m *SopTaskMutation) AddedType() (r int, exists bool) {
  25161. v := m.add_type
  25162. if v == nil {
  25163. return
  25164. }
  25165. return *v, true
  25166. }
  25167. // ResetType resets all changes to the "type" field.
  25168. func (m *SopTaskMutation) ResetType() {
  25169. m._type = nil
  25170. m.add_type = nil
  25171. }
  25172. // SetPlanStartTime sets the "plan_start_time" field.
  25173. func (m *SopTaskMutation) SetPlanStartTime(t time.Time) {
  25174. m.plan_start_time = &t
  25175. }
  25176. // PlanStartTime returns the value of the "plan_start_time" field in the mutation.
  25177. func (m *SopTaskMutation) PlanStartTime() (r time.Time, exists bool) {
  25178. v := m.plan_start_time
  25179. if v == nil {
  25180. return
  25181. }
  25182. return *v, true
  25183. }
  25184. // OldPlanStartTime returns the old "plan_start_time" field's value of the SopTask entity.
  25185. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  25186. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25187. func (m *SopTaskMutation) OldPlanStartTime(ctx context.Context) (v time.Time, err error) {
  25188. if !m.op.Is(OpUpdateOne) {
  25189. return v, errors.New("OldPlanStartTime is only allowed on UpdateOne operations")
  25190. }
  25191. if m.id == nil || m.oldValue == nil {
  25192. return v, errors.New("OldPlanStartTime requires an ID field in the mutation")
  25193. }
  25194. oldValue, err := m.oldValue(ctx)
  25195. if err != nil {
  25196. return v, fmt.Errorf("querying old value for OldPlanStartTime: %w", err)
  25197. }
  25198. return oldValue.PlanStartTime, nil
  25199. }
  25200. // ClearPlanStartTime clears the value of the "plan_start_time" field.
  25201. func (m *SopTaskMutation) ClearPlanStartTime() {
  25202. m.plan_start_time = nil
  25203. m.clearedFields[soptask.FieldPlanStartTime] = struct{}{}
  25204. }
  25205. // PlanStartTimeCleared returns if the "plan_start_time" field was cleared in this mutation.
  25206. func (m *SopTaskMutation) PlanStartTimeCleared() bool {
  25207. _, ok := m.clearedFields[soptask.FieldPlanStartTime]
  25208. return ok
  25209. }
  25210. // ResetPlanStartTime resets all changes to the "plan_start_time" field.
  25211. func (m *SopTaskMutation) ResetPlanStartTime() {
  25212. m.plan_start_time = nil
  25213. delete(m.clearedFields, soptask.FieldPlanStartTime)
  25214. }
  25215. // SetPlanEndTime sets the "plan_end_time" field.
  25216. func (m *SopTaskMutation) SetPlanEndTime(t time.Time) {
  25217. m.plan_end_time = &t
  25218. }
  25219. // PlanEndTime returns the value of the "plan_end_time" field in the mutation.
  25220. func (m *SopTaskMutation) PlanEndTime() (r time.Time, exists bool) {
  25221. v := m.plan_end_time
  25222. if v == nil {
  25223. return
  25224. }
  25225. return *v, true
  25226. }
  25227. // OldPlanEndTime returns the old "plan_end_time" field's value of the SopTask entity.
  25228. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  25229. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25230. func (m *SopTaskMutation) OldPlanEndTime(ctx context.Context) (v time.Time, err error) {
  25231. if !m.op.Is(OpUpdateOne) {
  25232. return v, errors.New("OldPlanEndTime is only allowed on UpdateOne operations")
  25233. }
  25234. if m.id == nil || m.oldValue == nil {
  25235. return v, errors.New("OldPlanEndTime requires an ID field in the mutation")
  25236. }
  25237. oldValue, err := m.oldValue(ctx)
  25238. if err != nil {
  25239. return v, fmt.Errorf("querying old value for OldPlanEndTime: %w", err)
  25240. }
  25241. return oldValue.PlanEndTime, nil
  25242. }
  25243. // ClearPlanEndTime clears the value of the "plan_end_time" field.
  25244. func (m *SopTaskMutation) ClearPlanEndTime() {
  25245. m.plan_end_time = nil
  25246. m.clearedFields[soptask.FieldPlanEndTime] = struct{}{}
  25247. }
  25248. // PlanEndTimeCleared returns if the "plan_end_time" field was cleared in this mutation.
  25249. func (m *SopTaskMutation) PlanEndTimeCleared() bool {
  25250. _, ok := m.clearedFields[soptask.FieldPlanEndTime]
  25251. return ok
  25252. }
  25253. // ResetPlanEndTime resets all changes to the "plan_end_time" field.
  25254. func (m *SopTaskMutation) ResetPlanEndTime() {
  25255. m.plan_end_time = nil
  25256. delete(m.clearedFields, soptask.FieldPlanEndTime)
  25257. }
  25258. // SetCreatorID sets the "creator_id" field.
  25259. func (m *SopTaskMutation) SetCreatorID(s string) {
  25260. m.creator_id = &s
  25261. }
  25262. // CreatorID returns the value of the "creator_id" field in the mutation.
  25263. func (m *SopTaskMutation) CreatorID() (r string, exists bool) {
  25264. v := m.creator_id
  25265. if v == nil {
  25266. return
  25267. }
  25268. return *v, true
  25269. }
  25270. // OldCreatorID returns the old "creator_id" field's value of the SopTask entity.
  25271. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  25272. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25273. func (m *SopTaskMutation) OldCreatorID(ctx context.Context) (v string, err error) {
  25274. if !m.op.Is(OpUpdateOne) {
  25275. return v, errors.New("OldCreatorID is only allowed on UpdateOne operations")
  25276. }
  25277. if m.id == nil || m.oldValue == nil {
  25278. return v, errors.New("OldCreatorID requires an ID field in the mutation")
  25279. }
  25280. oldValue, err := m.oldValue(ctx)
  25281. if err != nil {
  25282. return v, fmt.Errorf("querying old value for OldCreatorID: %w", err)
  25283. }
  25284. return oldValue.CreatorID, nil
  25285. }
  25286. // ClearCreatorID clears the value of the "creator_id" field.
  25287. func (m *SopTaskMutation) ClearCreatorID() {
  25288. m.creator_id = nil
  25289. m.clearedFields[soptask.FieldCreatorID] = struct{}{}
  25290. }
  25291. // CreatorIDCleared returns if the "creator_id" field was cleared in this mutation.
  25292. func (m *SopTaskMutation) CreatorIDCleared() bool {
  25293. _, ok := m.clearedFields[soptask.FieldCreatorID]
  25294. return ok
  25295. }
  25296. // ResetCreatorID resets all changes to the "creator_id" field.
  25297. func (m *SopTaskMutation) ResetCreatorID() {
  25298. m.creator_id = nil
  25299. delete(m.clearedFields, soptask.FieldCreatorID)
  25300. }
  25301. // SetOrganizationID sets the "organization_id" field.
  25302. func (m *SopTaskMutation) SetOrganizationID(u uint64) {
  25303. m.organization_id = &u
  25304. m.addorganization_id = nil
  25305. }
  25306. // OrganizationID returns the value of the "organization_id" field in the mutation.
  25307. func (m *SopTaskMutation) OrganizationID() (r uint64, exists bool) {
  25308. v := m.organization_id
  25309. if v == nil {
  25310. return
  25311. }
  25312. return *v, true
  25313. }
  25314. // OldOrganizationID returns the old "organization_id" field's value of the SopTask entity.
  25315. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  25316. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25317. func (m *SopTaskMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  25318. if !m.op.Is(OpUpdateOne) {
  25319. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  25320. }
  25321. if m.id == nil || m.oldValue == nil {
  25322. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  25323. }
  25324. oldValue, err := m.oldValue(ctx)
  25325. if err != nil {
  25326. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  25327. }
  25328. return oldValue.OrganizationID, nil
  25329. }
  25330. // AddOrganizationID adds u to the "organization_id" field.
  25331. func (m *SopTaskMutation) AddOrganizationID(u int64) {
  25332. if m.addorganization_id != nil {
  25333. *m.addorganization_id += u
  25334. } else {
  25335. m.addorganization_id = &u
  25336. }
  25337. }
  25338. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  25339. func (m *SopTaskMutation) AddedOrganizationID() (r int64, exists bool) {
  25340. v := m.addorganization_id
  25341. if v == nil {
  25342. return
  25343. }
  25344. return *v, true
  25345. }
  25346. // ClearOrganizationID clears the value of the "organization_id" field.
  25347. func (m *SopTaskMutation) ClearOrganizationID() {
  25348. m.organization_id = nil
  25349. m.addorganization_id = nil
  25350. m.clearedFields[soptask.FieldOrganizationID] = struct{}{}
  25351. }
  25352. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  25353. func (m *SopTaskMutation) OrganizationIDCleared() bool {
  25354. _, ok := m.clearedFields[soptask.FieldOrganizationID]
  25355. return ok
  25356. }
  25357. // ResetOrganizationID resets all changes to the "organization_id" field.
  25358. func (m *SopTaskMutation) ResetOrganizationID() {
  25359. m.organization_id = nil
  25360. m.addorganization_id = nil
  25361. delete(m.clearedFields, soptask.FieldOrganizationID)
  25362. }
  25363. // SetToken sets the "token" field.
  25364. func (m *SopTaskMutation) SetToken(s []string) {
  25365. m.token = &s
  25366. m.appendtoken = nil
  25367. }
  25368. // Token returns the value of the "token" field in the mutation.
  25369. func (m *SopTaskMutation) Token() (r []string, exists bool) {
  25370. v := m.token
  25371. if v == nil {
  25372. return
  25373. }
  25374. return *v, true
  25375. }
  25376. // OldToken returns the old "token" field's value of the SopTask entity.
  25377. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  25378. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25379. func (m *SopTaskMutation) OldToken(ctx context.Context) (v []string, err error) {
  25380. if !m.op.Is(OpUpdateOne) {
  25381. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  25382. }
  25383. if m.id == nil || m.oldValue == nil {
  25384. return v, errors.New("OldToken requires an ID field in the mutation")
  25385. }
  25386. oldValue, err := m.oldValue(ctx)
  25387. if err != nil {
  25388. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  25389. }
  25390. return oldValue.Token, nil
  25391. }
  25392. // AppendToken adds s to the "token" field.
  25393. func (m *SopTaskMutation) AppendToken(s []string) {
  25394. m.appendtoken = append(m.appendtoken, s...)
  25395. }
  25396. // AppendedToken returns the list of values that were appended to the "token" field in this mutation.
  25397. func (m *SopTaskMutation) AppendedToken() ([]string, bool) {
  25398. if len(m.appendtoken) == 0 {
  25399. return nil, false
  25400. }
  25401. return m.appendtoken, true
  25402. }
  25403. // ClearToken clears the value of the "token" field.
  25404. func (m *SopTaskMutation) ClearToken() {
  25405. m.token = nil
  25406. m.appendtoken = nil
  25407. m.clearedFields[soptask.FieldToken] = struct{}{}
  25408. }
  25409. // TokenCleared returns if the "token" field was cleared in this mutation.
  25410. func (m *SopTaskMutation) TokenCleared() bool {
  25411. _, ok := m.clearedFields[soptask.FieldToken]
  25412. return ok
  25413. }
  25414. // ResetToken resets all changes to the "token" field.
  25415. func (m *SopTaskMutation) ResetToken() {
  25416. m.token = nil
  25417. m.appendtoken = nil
  25418. delete(m.clearedFields, soptask.FieldToken)
  25419. }
  25420. // AddTaskStageIDs adds the "task_stages" edge to the SopStage entity by ids.
  25421. func (m *SopTaskMutation) AddTaskStageIDs(ids ...uint64) {
  25422. if m.task_stages == nil {
  25423. m.task_stages = make(map[uint64]struct{})
  25424. }
  25425. for i := range ids {
  25426. m.task_stages[ids[i]] = struct{}{}
  25427. }
  25428. }
  25429. // ClearTaskStages clears the "task_stages" edge to the SopStage entity.
  25430. func (m *SopTaskMutation) ClearTaskStages() {
  25431. m.clearedtask_stages = true
  25432. }
  25433. // TaskStagesCleared reports if the "task_stages" edge to the SopStage entity was cleared.
  25434. func (m *SopTaskMutation) TaskStagesCleared() bool {
  25435. return m.clearedtask_stages
  25436. }
  25437. // RemoveTaskStageIDs removes the "task_stages" edge to the SopStage entity by IDs.
  25438. func (m *SopTaskMutation) RemoveTaskStageIDs(ids ...uint64) {
  25439. if m.removedtask_stages == nil {
  25440. m.removedtask_stages = make(map[uint64]struct{})
  25441. }
  25442. for i := range ids {
  25443. delete(m.task_stages, ids[i])
  25444. m.removedtask_stages[ids[i]] = struct{}{}
  25445. }
  25446. }
  25447. // RemovedTaskStages returns the removed IDs of the "task_stages" edge to the SopStage entity.
  25448. func (m *SopTaskMutation) RemovedTaskStagesIDs() (ids []uint64) {
  25449. for id := range m.removedtask_stages {
  25450. ids = append(ids, id)
  25451. }
  25452. return
  25453. }
  25454. // TaskStagesIDs returns the "task_stages" edge IDs in the mutation.
  25455. func (m *SopTaskMutation) TaskStagesIDs() (ids []uint64) {
  25456. for id := range m.task_stages {
  25457. ids = append(ids, id)
  25458. }
  25459. return
  25460. }
  25461. // ResetTaskStages resets all changes to the "task_stages" edge.
  25462. func (m *SopTaskMutation) ResetTaskStages() {
  25463. m.task_stages = nil
  25464. m.clearedtask_stages = false
  25465. m.removedtask_stages = nil
  25466. }
  25467. // Where appends a list predicates to the SopTaskMutation builder.
  25468. func (m *SopTaskMutation) Where(ps ...predicate.SopTask) {
  25469. m.predicates = append(m.predicates, ps...)
  25470. }
  25471. // WhereP appends storage-level predicates to the SopTaskMutation builder. Using this method,
  25472. // users can use type-assertion to append predicates that do not depend on any generated package.
  25473. func (m *SopTaskMutation) WhereP(ps ...func(*sql.Selector)) {
  25474. p := make([]predicate.SopTask, len(ps))
  25475. for i := range ps {
  25476. p[i] = ps[i]
  25477. }
  25478. m.Where(p...)
  25479. }
  25480. // Op returns the operation name.
  25481. func (m *SopTaskMutation) Op() Op {
  25482. return m.op
  25483. }
  25484. // SetOp allows setting the mutation operation.
  25485. func (m *SopTaskMutation) SetOp(op Op) {
  25486. m.op = op
  25487. }
  25488. // Type returns the node type of this mutation (SopTask).
  25489. func (m *SopTaskMutation) Type() string {
  25490. return m.typ
  25491. }
  25492. // Fields returns all fields that were changed during this mutation. Note that in
  25493. // order to get all numeric fields that were incremented/decremented, call
  25494. // AddedFields().
  25495. func (m *SopTaskMutation) Fields() []string {
  25496. fields := make([]string, 0, 12)
  25497. if m.created_at != nil {
  25498. fields = append(fields, soptask.FieldCreatedAt)
  25499. }
  25500. if m.updated_at != nil {
  25501. fields = append(fields, soptask.FieldUpdatedAt)
  25502. }
  25503. if m.status != nil {
  25504. fields = append(fields, soptask.FieldStatus)
  25505. }
  25506. if m.deleted_at != nil {
  25507. fields = append(fields, soptask.FieldDeletedAt)
  25508. }
  25509. if m.name != nil {
  25510. fields = append(fields, soptask.FieldName)
  25511. }
  25512. if m.bot_wxid_list != nil {
  25513. fields = append(fields, soptask.FieldBotWxidList)
  25514. }
  25515. if m._type != nil {
  25516. fields = append(fields, soptask.FieldType)
  25517. }
  25518. if m.plan_start_time != nil {
  25519. fields = append(fields, soptask.FieldPlanStartTime)
  25520. }
  25521. if m.plan_end_time != nil {
  25522. fields = append(fields, soptask.FieldPlanEndTime)
  25523. }
  25524. if m.creator_id != nil {
  25525. fields = append(fields, soptask.FieldCreatorID)
  25526. }
  25527. if m.organization_id != nil {
  25528. fields = append(fields, soptask.FieldOrganizationID)
  25529. }
  25530. if m.token != nil {
  25531. fields = append(fields, soptask.FieldToken)
  25532. }
  25533. return fields
  25534. }
  25535. // Field returns the value of a field with the given name. The second boolean
  25536. // return value indicates that this field was not set, or was not defined in the
  25537. // schema.
  25538. func (m *SopTaskMutation) Field(name string) (ent.Value, bool) {
  25539. switch name {
  25540. case soptask.FieldCreatedAt:
  25541. return m.CreatedAt()
  25542. case soptask.FieldUpdatedAt:
  25543. return m.UpdatedAt()
  25544. case soptask.FieldStatus:
  25545. return m.Status()
  25546. case soptask.FieldDeletedAt:
  25547. return m.DeletedAt()
  25548. case soptask.FieldName:
  25549. return m.Name()
  25550. case soptask.FieldBotWxidList:
  25551. return m.BotWxidList()
  25552. case soptask.FieldType:
  25553. return m.GetType()
  25554. case soptask.FieldPlanStartTime:
  25555. return m.PlanStartTime()
  25556. case soptask.FieldPlanEndTime:
  25557. return m.PlanEndTime()
  25558. case soptask.FieldCreatorID:
  25559. return m.CreatorID()
  25560. case soptask.FieldOrganizationID:
  25561. return m.OrganizationID()
  25562. case soptask.FieldToken:
  25563. return m.Token()
  25564. }
  25565. return nil, false
  25566. }
  25567. // OldField returns the old value of the field from the database. An error is
  25568. // returned if the mutation operation is not UpdateOne, or the query to the
  25569. // database failed.
  25570. func (m *SopTaskMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  25571. switch name {
  25572. case soptask.FieldCreatedAt:
  25573. return m.OldCreatedAt(ctx)
  25574. case soptask.FieldUpdatedAt:
  25575. return m.OldUpdatedAt(ctx)
  25576. case soptask.FieldStatus:
  25577. return m.OldStatus(ctx)
  25578. case soptask.FieldDeletedAt:
  25579. return m.OldDeletedAt(ctx)
  25580. case soptask.FieldName:
  25581. return m.OldName(ctx)
  25582. case soptask.FieldBotWxidList:
  25583. return m.OldBotWxidList(ctx)
  25584. case soptask.FieldType:
  25585. return m.OldType(ctx)
  25586. case soptask.FieldPlanStartTime:
  25587. return m.OldPlanStartTime(ctx)
  25588. case soptask.FieldPlanEndTime:
  25589. return m.OldPlanEndTime(ctx)
  25590. case soptask.FieldCreatorID:
  25591. return m.OldCreatorID(ctx)
  25592. case soptask.FieldOrganizationID:
  25593. return m.OldOrganizationID(ctx)
  25594. case soptask.FieldToken:
  25595. return m.OldToken(ctx)
  25596. }
  25597. return nil, fmt.Errorf("unknown SopTask field %s", name)
  25598. }
  25599. // SetField sets the value of a field with the given name. It returns an error if
  25600. // the field is not defined in the schema, or if the type mismatched the field
  25601. // type.
  25602. func (m *SopTaskMutation) SetField(name string, value ent.Value) error {
  25603. switch name {
  25604. case soptask.FieldCreatedAt:
  25605. v, ok := value.(time.Time)
  25606. if !ok {
  25607. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25608. }
  25609. m.SetCreatedAt(v)
  25610. return nil
  25611. case soptask.FieldUpdatedAt:
  25612. v, ok := value.(time.Time)
  25613. if !ok {
  25614. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25615. }
  25616. m.SetUpdatedAt(v)
  25617. return nil
  25618. case soptask.FieldStatus:
  25619. v, ok := value.(uint8)
  25620. if !ok {
  25621. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25622. }
  25623. m.SetStatus(v)
  25624. return nil
  25625. case soptask.FieldDeletedAt:
  25626. v, ok := value.(time.Time)
  25627. if !ok {
  25628. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25629. }
  25630. m.SetDeletedAt(v)
  25631. return nil
  25632. case soptask.FieldName:
  25633. v, ok := value.(string)
  25634. if !ok {
  25635. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25636. }
  25637. m.SetName(v)
  25638. return nil
  25639. case soptask.FieldBotWxidList:
  25640. v, ok := value.([]string)
  25641. if !ok {
  25642. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25643. }
  25644. m.SetBotWxidList(v)
  25645. return nil
  25646. case soptask.FieldType:
  25647. v, ok := value.(int)
  25648. if !ok {
  25649. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25650. }
  25651. m.SetType(v)
  25652. return nil
  25653. case soptask.FieldPlanStartTime:
  25654. v, ok := value.(time.Time)
  25655. if !ok {
  25656. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25657. }
  25658. m.SetPlanStartTime(v)
  25659. return nil
  25660. case soptask.FieldPlanEndTime:
  25661. v, ok := value.(time.Time)
  25662. if !ok {
  25663. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25664. }
  25665. m.SetPlanEndTime(v)
  25666. return nil
  25667. case soptask.FieldCreatorID:
  25668. v, ok := value.(string)
  25669. if !ok {
  25670. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25671. }
  25672. m.SetCreatorID(v)
  25673. return nil
  25674. case soptask.FieldOrganizationID:
  25675. v, ok := value.(uint64)
  25676. if !ok {
  25677. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25678. }
  25679. m.SetOrganizationID(v)
  25680. return nil
  25681. case soptask.FieldToken:
  25682. v, ok := value.([]string)
  25683. if !ok {
  25684. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25685. }
  25686. m.SetToken(v)
  25687. return nil
  25688. }
  25689. return fmt.Errorf("unknown SopTask field %s", name)
  25690. }
  25691. // AddedFields returns all numeric fields that were incremented/decremented during
  25692. // this mutation.
  25693. func (m *SopTaskMutation) AddedFields() []string {
  25694. var fields []string
  25695. if m.addstatus != nil {
  25696. fields = append(fields, soptask.FieldStatus)
  25697. }
  25698. if m.add_type != nil {
  25699. fields = append(fields, soptask.FieldType)
  25700. }
  25701. if m.addorganization_id != nil {
  25702. fields = append(fields, soptask.FieldOrganizationID)
  25703. }
  25704. return fields
  25705. }
  25706. // AddedField returns the numeric value that was incremented/decremented on a field
  25707. // with the given name. The second boolean return value indicates that this field
  25708. // was not set, or was not defined in the schema.
  25709. func (m *SopTaskMutation) AddedField(name string) (ent.Value, bool) {
  25710. switch name {
  25711. case soptask.FieldStatus:
  25712. return m.AddedStatus()
  25713. case soptask.FieldType:
  25714. return m.AddedType()
  25715. case soptask.FieldOrganizationID:
  25716. return m.AddedOrganizationID()
  25717. }
  25718. return nil, false
  25719. }
  25720. // AddField adds the value to the field with the given name. It returns an error if
  25721. // the field is not defined in the schema, or if the type mismatched the field
  25722. // type.
  25723. func (m *SopTaskMutation) AddField(name string, value ent.Value) error {
  25724. switch name {
  25725. case soptask.FieldStatus:
  25726. v, ok := value.(int8)
  25727. if !ok {
  25728. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25729. }
  25730. m.AddStatus(v)
  25731. return nil
  25732. case soptask.FieldType:
  25733. v, ok := value.(int)
  25734. if !ok {
  25735. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25736. }
  25737. m.AddType(v)
  25738. return nil
  25739. case soptask.FieldOrganizationID:
  25740. v, ok := value.(int64)
  25741. if !ok {
  25742. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25743. }
  25744. m.AddOrganizationID(v)
  25745. return nil
  25746. }
  25747. return fmt.Errorf("unknown SopTask numeric field %s", name)
  25748. }
  25749. // ClearedFields returns all nullable fields that were cleared during this
  25750. // mutation.
  25751. func (m *SopTaskMutation) ClearedFields() []string {
  25752. var fields []string
  25753. if m.FieldCleared(soptask.FieldStatus) {
  25754. fields = append(fields, soptask.FieldStatus)
  25755. }
  25756. if m.FieldCleared(soptask.FieldDeletedAt) {
  25757. fields = append(fields, soptask.FieldDeletedAt)
  25758. }
  25759. if m.FieldCleared(soptask.FieldBotWxidList) {
  25760. fields = append(fields, soptask.FieldBotWxidList)
  25761. }
  25762. if m.FieldCleared(soptask.FieldPlanStartTime) {
  25763. fields = append(fields, soptask.FieldPlanStartTime)
  25764. }
  25765. if m.FieldCleared(soptask.FieldPlanEndTime) {
  25766. fields = append(fields, soptask.FieldPlanEndTime)
  25767. }
  25768. if m.FieldCleared(soptask.FieldCreatorID) {
  25769. fields = append(fields, soptask.FieldCreatorID)
  25770. }
  25771. if m.FieldCleared(soptask.FieldOrganizationID) {
  25772. fields = append(fields, soptask.FieldOrganizationID)
  25773. }
  25774. if m.FieldCleared(soptask.FieldToken) {
  25775. fields = append(fields, soptask.FieldToken)
  25776. }
  25777. return fields
  25778. }
  25779. // FieldCleared returns a boolean indicating if a field with the given name was
  25780. // cleared in this mutation.
  25781. func (m *SopTaskMutation) FieldCleared(name string) bool {
  25782. _, ok := m.clearedFields[name]
  25783. return ok
  25784. }
  25785. // ClearField clears the value of the field with the given name. It returns an
  25786. // error if the field is not defined in the schema.
  25787. func (m *SopTaskMutation) ClearField(name string) error {
  25788. switch name {
  25789. case soptask.FieldStatus:
  25790. m.ClearStatus()
  25791. return nil
  25792. case soptask.FieldDeletedAt:
  25793. m.ClearDeletedAt()
  25794. return nil
  25795. case soptask.FieldBotWxidList:
  25796. m.ClearBotWxidList()
  25797. return nil
  25798. case soptask.FieldPlanStartTime:
  25799. m.ClearPlanStartTime()
  25800. return nil
  25801. case soptask.FieldPlanEndTime:
  25802. m.ClearPlanEndTime()
  25803. return nil
  25804. case soptask.FieldCreatorID:
  25805. m.ClearCreatorID()
  25806. return nil
  25807. case soptask.FieldOrganizationID:
  25808. m.ClearOrganizationID()
  25809. return nil
  25810. case soptask.FieldToken:
  25811. m.ClearToken()
  25812. return nil
  25813. }
  25814. return fmt.Errorf("unknown SopTask nullable field %s", name)
  25815. }
  25816. // ResetField resets all changes in the mutation for the field with the given name.
  25817. // It returns an error if the field is not defined in the schema.
  25818. func (m *SopTaskMutation) ResetField(name string) error {
  25819. switch name {
  25820. case soptask.FieldCreatedAt:
  25821. m.ResetCreatedAt()
  25822. return nil
  25823. case soptask.FieldUpdatedAt:
  25824. m.ResetUpdatedAt()
  25825. return nil
  25826. case soptask.FieldStatus:
  25827. m.ResetStatus()
  25828. return nil
  25829. case soptask.FieldDeletedAt:
  25830. m.ResetDeletedAt()
  25831. return nil
  25832. case soptask.FieldName:
  25833. m.ResetName()
  25834. return nil
  25835. case soptask.FieldBotWxidList:
  25836. m.ResetBotWxidList()
  25837. return nil
  25838. case soptask.FieldType:
  25839. m.ResetType()
  25840. return nil
  25841. case soptask.FieldPlanStartTime:
  25842. m.ResetPlanStartTime()
  25843. return nil
  25844. case soptask.FieldPlanEndTime:
  25845. m.ResetPlanEndTime()
  25846. return nil
  25847. case soptask.FieldCreatorID:
  25848. m.ResetCreatorID()
  25849. return nil
  25850. case soptask.FieldOrganizationID:
  25851. m.ResetOrganizationID()
  25852. return nil
  25853. case soptask.FieldToken:
  25854. m.ResetToken()
  25855. return nil
  25856. }
  25857. return fmt.Errorf("unknown SopTask field %s", name)
  25858. }
  25859. // AddedEdges returns all edge names that were set/added in this mutation.
  25860. func (m *SopTaskMutation) AddedEdges() []string {
  25861. edges := make([]string, 0, 1)
  25862. if m.task_stages != nil {
  25863. edges = append(edges, soptask.EdgeTaskStages)
  25864. }
  25865. return edges
  25866. }
  25867. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  25868. // name in this mutation.
  25869. func (m *SopTaskMutation) AddedIDs(name string) []ent.Value {
  25870. switch name {
  25871. case soptask.EdgeTaskStages:
  25872. ids := make([]ent.Value, 0, len(m.task_stages))
  25873. for id := range m.task_stages {
  25874. ids = append(ids, id)
  25875. }
  25876. return ids
  25877. }
  25878. return nil
  25879. }
  25880. // RemovedEdges returns all edge names that were removed in this mutation.
  25881. func (m *SopTaskMutation) RemovedEdges() []string {
  25882. edges := make([]string, 0, 1)
  25883. if m.removedtask_stages != nil {
  25884. edges = append(edges, soptask.EdgeTaskStages)
  25885. }
  25886. return edges
  25887. }
  25888. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  25889. // the given name in this mutation.
  25890. func (m *SopTaskMutation) RemovedIDs(name string) []ent.Value {
  25891. switch name {
  25892. case soptask.EdgeTaskStages:
  25893. ids := make([]ent.Value, 0, len(m.removedtask_stages))
  25894. for id := range m.removedtask_stages {
  25895. ids = append(ids, id)
  25896. }
  25897. return ids
  25898. }
  25899. return nil
  25900. }
  25901. // ClearedEdges returns all edge names that were cleared in this mutation.
  25902. func (m *SopTaskMutation) ClearedEdges() []string {
  25903. edges := make([]string, 0, 1)
  25904. if m.clearedtask_stages {
  25905. edges = append(edges, soptask.EdgeTaskStages)
  25906. }
  25907. return edges
  25908. }
  25909. // EdgeCleared returns a boolean which indicates if the edge with the given name
  25910. // was cleared in this mutation.
  25911. func (m *SopTaskMutation) EdgeCleared(name string) bool {
  25912. switch name {
  25913. case soptask.EdgeTaskStages:
  25914. return m.clearedtask_stages
  25915. }
  25916. return false
  25917. }
  25918. // ClearEdge clears the value of the edge with the given name. It returns an error
  25919. // if that edge is not defined in the schema.
  25920. func (m *SopTaskMutation) ClearEdge(name string) error {
  25921. switch name {
  25922. }
  25923. return fmt.Errorf("unknown SopTask unique edge %s", name)
  25924. }
  25925. // ResetEdge resets all changes to the edge with the given name in this mutation.
  25926. // It returns an error if the edge is not defined in the schema.
  25927. func (m *SopTaskMutation) ResetEdge(name string) error {
  25928. switch name {
  25929. case soptask.EdgeTaskStages:
  25930. m.ResetTaskStages()
  25931. return nil
  25932. }
  25933. return fmt.Errorf("unknown SopTask edge %s", name)
  25934. }
  25935. // TokenMutation represents an operation that mutates the Token nodes in the graph.
  25936. type TokenMutation struct {
  25937. config
  25938. op Op
  25939. typ string
  25940. id *uint64
  25941. created_at *time.Time
  25942. updated_at *time.Time
  25943. deleted_at *time.Time
  25944. expire_at *time.Time
  25945. token *string
  25946. mac *string
  25947. organization_id *uint64
  25948. addorganization_id *int64
  25949. custom_agent_base *string
  25950. custom_agent_key *string
  25951. openai_base *string
  25952. openai_key *string
  25953. clearedFields map[string]struct{}
  25954. agent *uint64
  25955. clearedagent bool
  25956. done bool
  25957. oldValue func(context.Context) (*Token, error)
  25958. predicates []predicate.Token
  25959. }
  25960. var _ ent.Mutation = (*TokenMutation)(nil)
  25961. // tokenOption allows management of the mutation configuration using functional options.
  25962. type tokenOption func(*TokenMutation)
  25963. // newTokenMutation creates new mutation for the Token entity.
  25964. func newTokenMutation(c config, op Op, opts ...tokenOption) *TokenMutation {
  25965. m := &TokenMutation{
  25966. config: c,
  25967. op: op,
  25968. typ: TypeToken,
  25969. clearedFields: make(map[string]struct{}),
  25970. }
  25971. for _, opt := range opts {
  25972. opt(m)
  25973. }
  25974. return m
  25975. }
  25976. // withTokenID sets the ID field of the mutation.
  25977. func withTokenID(id uint64) tokenOption {
  25978. return func(m *TokenMutation) {
  25979. var (
  25980. err error
  25981. once sync.Once
  25982. value *Token
  25983. )
  25984. m.oldValue = func(ctx context.Context) (*Token, error) {
  25985. once.Do(func() {
  25986. if m.done {
  25987. err = errors.New("querying old values post mutation is not allowed")
  25988. } else {
  25989. value, err = m.Client().Token.Get(ctx, id)
  25990. }
  25991. })
  25992. return value, err
  25993. }
  25994. m.id = &id
  25995. }
  25996. }
  25997. // withToken sets the old Token of the mutation.
  25998. func withToken(node *Token) tokenOption {
  25999. return func(m *TokenMutation) {
  26000. m.oldValue = func(context.Context) (*Token, error) {
  26001. return node, nil
  26002. }
  26003. m.id = &node.ID
  26004. }
  26005. }
  26006. // Client returns a new `ent.Client` from the mutation. If the mutation was
  26007. // executed in a transaction (ent.Tx), a transactional client is returned.
  26008. func (m TokenMutation) Client() *Client {
  26009. client := &Client{config: m.config}
  26010. client.init()
  26011. return client
  26012. }
  26013. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  26014. // it returns an error otherwise.
  26015. func (m TokenMutation) Tx() (*Tx, error) {
  26016. if _, ok := m.driver.(*txDriver); !ok {
  26017. return nil, errors.New("ent: mutation is not running in a transaction")
  26018. }
  26019. tx := &Tx{config: m.config}
  26020. tx.init()
  26021. return tx, nil
  26022. }
  26023. // SetID sets the value of the id field. Note that this
  26024. // operation is only accepted on creation of Token entities.
  26025. func (m *TokenMutation) SetID(id uint64) {
  26026. m.id = &id
  26027. }
  26028. // ID returns the ID value in the mutation. Note that the ID is only available
  26029. // if it was provided to the builder or after it was returned from the database.
  26030. func (m *TokenMutation) ID() (id uint64, exists bool) {
  26031. if m.id == nil {
  26032. return
  26033. }
  26034. return *m.id, true
  26035. }
  26036. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  26037. // That means, if the mutation is applied within a transaction with an isolation level such
  26038. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  26039. // or updated by the mutation.
  26040. func (m *TokenMutation) IDs(ctx context.Context) ([]uint64, error) {
  26041. switch {
  26042. case m.op.Is(OpUpdateOne | OpDeleteOne):
  26043. id, exists := m.ID()
  26044. if exists {
  26045. return []uint64{id}, nil
  26046. }
  26047. fallthrough
  26048. case m.op.Is(OpUpdate | OpDelete):
  26049. return m.Client().Token.Query().Where(m.predicates...).IDs(ctx)
  26050. default:
  26051. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  26052. }
  26053. }
  26054. // SetCreatedAt sets the "created_at" field.
  26055. func (m *TokenMutation) SetCreatedAt(t time.Time) {
  26056. m.created_at = &t
  26057. }
  26058. // CreatedAt returns the value of the "created_at" field in the mutation.
  26059. func (m *TokenMutation) CreatedAt() (r time.Time, exists bool) {
  26060. v := m.created_at
  26061. if v == nil {
  26062. return
  26063. }
  26064. return *v, true
  26065. }
  26066. // OldCreatedAt returns the old "created_at" field's value of the Token entity.
  26067. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  26068. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26069. func (m *TokenMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  26070. if !m.op.Is(OpUpdateOne) {
  26071. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  26072. }
  26073. if m.id == nil || m.oldValue == nil {
  26074. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  26075. }
  26076. oldValue, err := m.oldValue(ctx)
  26077. if err != nil {
  26078. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  26079. }
  26080. return oldValue.CreatedAt, nil
  26081. }
  26082. // ResetCreatedAt resets all changes to the "created_at" field.
  26083. func (m *TokenMutation) ResetCreatedAt() {
  26084. m.created_at = nil
  26085. }
  26086. // SetUpdatedAt sets the "updated_at" field.
  26087. func (m *TokenMutation) SetUpdatedAt(t time.Time) {
  26088. m.updated_at = &t
  26089. }
  26090. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  26091. func (m *TokenMutation) UpdatedAt() (r time.Time, exists bool) {
  26092. v := m.updated_at
  26093. if v == nil {
  26094. return
  26095. }
  26096. return *v, true
  26097. }
  26098. // OldUpdatedAt returns the old "updated_at" field's value of the Token entity.
  26099. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  26100. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26101. func (m *TokenMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  26102. if !m.op.Is(OpUpdateOne) {
  26103. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  26104. }
  26105. if m.id == nil || m.oldValue == nil {
  26106. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  26107. }
  26108. oldValue, err := m.oldValue(ctx)
  26109. if err != nil {
  26110. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  26111. }
  26112. return oldValue.UpdatedAt, nil
  26113. }
  26114. // ResetUpdatedAt resets all changes to the "updated_at" field.
  26115. func (m *TokenMutation) ResetUpdatedAt() {
  26116. m.updated_at = nil
  26117. }
  26118. // SetDeletedAt sets the "deleted_at" field.
  26119. func (m *TokenMutation) SetDeletedAt(t time.Time) {
  26120. m.deleted_at = &t
  26121. }
  26122. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  26123. func (m *TokenMutation) DeletedAt() (r time.Time, exists bool) {
  26124. v := m.deleted_at
  26125. if v == nil {
  26126. return
  26127. }
  26128. return *v, true
  26129. }
  26130. // OldDeletedAt returns the old "deleted_at" field's value of the Token entity.
  26131. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  26132. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26133. func (m *TokenMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  26134. if !m.op.Is(OpUpdateOne) {
  26135. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  26136. }
  26137. if m.id == nil || m.oldValue == nil {
  26138. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  26139. }
  26140. oldValue, err := m.oldValue(ctx)
  26141. if err != nil {
  26142. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  26143. }
  26144. return oldValue.DeletedAt, nil
  26145. }
  26146. // ClearDeletedAt clears the value of the "deleted_at" field.
  26147. func (m *TokenMutation) ClearDeletedAt() {
  26148. m.deleted_at = nil
  26149. m.clearedFields[token.FieldDeletedAt] = struct{}{}
  26150. }
  26151. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  26152. func (m *TokenMutation) DeletedAtCleared() bool {
  26153. _, ok := m.clearedFields[token.FieldDeletedAt]
  26154. return ok
  26155. }
  26156. // ResetDeletedAt resets all changes to the "deleted_at" field.
  26157. func (m *TokenMutation) ResetDeletedAt() {
  26158. m.deleted_at = nil
  26159. delete(m.clearedFields, token.FieldDeletedAt)
  26160. }
  26161. // SetExpireAt sets the "expire_at" field.
  26162. func (m *TokenMutation) SetExpireAt(t time.Time) {
  26163. m.expire_at = &t
  26164. }
  26165. // ExpireAt returns the value of the "expire_at" field in the mutation.
  26166. func (m *TokenMutation) ExpireAt() (r time.Time, exists bool) {
  26167. v := m.expire_at
  26168. if v == nil {
  26169. return
  26170. }
  26171. return *v, true
  26172. }
  26173. // OldExpireAt returns the old "expire_at" field's value of the Token entity.
  26174. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  26175. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26176. func (m *TokenMutation) OldExpireAt(ctx context.Context) (v time.Time, err error) {
  26177. if !m.op.Is(OpUpdateOne) {
  26178. return v, errors.New("OldExpireAt is only allowed on UpdateOne operations")
  26179. }
  26180. if m.id == nil || m.oldValue == nil {
  26181. return v, errors.New("OldExpireAt requires an ID field in the mutation")
  26182. }
  26183. oldValue, err := m.oldValue(ctx)
  26184. if err != nil {
  26185. return v, fmt.Errorf("querying old value for OldExpireAt: %w", err)
  26186. }
  26187. return oldValue.ExpireAt, nil
  26188. }
  26189. // ClearExpireAt clears the value of the "expire_at" field.
  26190. func (m *TokenMutation) ClearExpireAt() {
  26191. m.expire_at = nil
  26192. m.clearedFields[token.FieldExpireAt] = struct{}{}
  26193. }
  26194. // ExpireAtCleared returns if the "expire_at" field was cleared in this mutation.
  26195. func (m *TokenMutation) ExpireAtCleared() bool {
  26196. _, ok := m.clearedFields[token.FieldExpireAt]
  26197. return ok
  26198. }
  26199. // ResetExpireAt resets all changes to the "expire_at" field.
  26200. func (m *TokenMutation) ResetExpireAt() {
  26201. m.expire_at = nil
  26202. delete(m.clearedFields, token.FieldExpireAt)
  26203. }
  26204. // SetToken sets the "token" field.
  26205. func (m *TokenMutation) SetToken(s string) {
  26206. m.token = &s
  26207. }
  26208. // Token returns the value of the "token" field in the mutation.
  26209. func (m *TokenMutation) Token() (r string, exists bool) {
  26210. v := m.token
  26211. if v == nil {
  26212. return
  26213. }
  26214. return *v, true
  26215. }
  26216. // OldToken returns the old "token" field's value of the Token entity.
  26217. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  26218. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26219. func (m *TokenMutation) OldToken(ctx context.Context) (v string, err error) {
  26220. if !m.op.Is(OpUpdateOne) {
  26221. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  26222. }
  26223. if m.id == nil || m.oldValue == nil {
  26224. return v, errors.New("OldToken requires an ID field in the mutation")
  26225. }
  26226. oldValue, err := m.oldValue(ctx)
  26227. if err != nil {
  26228. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  26229. }
  26230. return oldValue.Token, nil
  26231. }
  26232. // ClearToken clears the value of the "token" field.
  26233. func (m *TokenMutation) ClearToken() {
  26234. m.token = nil
  26235. m.clearedFields[token.FieldToken] = struct{}{}
  26236. }
  26237. // TokenCleared returns if the "token" field was cleared in this mutation.
  26238. func (m *TokenMutation) TokenCleared() bool {
  26239. _, ok := m.clearedFields[token.FieldToken]
  26240. return ok
  26241. }
  26242. // ResetToken resets all changes to the "token" field.
  26243. func (m *TokenMutation) ResetToken() {
  26244. m.token = nil
  26245. delete(m.clearedFields, token.FieldToken)
  26246. }
  26247. // SetMAC sets the "mac" field.
  26248. func (m *TokenMutation) SetMAC(s string) {
  26249. m.mac = &s
  26250. }
  26251. // MAC returns the value of the "mac" field in the mutation.
  26252. func (m *TokenMutation) MAC() (r string, exists bool) {
  26253. v := m.mac
  26254. if v == nil {
  26255. return
  26256. }
  26257. return *v, true
  26258. }
  26259. // OldMAC returns the old "mac" field's value of the Token entity.
  26260. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  26261. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26262. func (m *TokenMutation) OldMAC(ctx context.Context) (v string, err error) {
  26263. if !m.op.Is(OpUpdateOne) {
  26264. return v, errors.New("OldMAC is only allowed on UpdateOne operations")
  26265. }
  26266. if m.id == nil || m.oldValue == nil {
  26267. return v, errors.New("OldMAC requires an ID field in the mutation")
  26268. }
  26269. oldValue, err := m.oldValue(ctx)
  26270. if err != nil {
  26271. return v, fmt.Errorf("querying old value for OldMAC: %w", err)
  26272. }
  26273. return oldValue.MAC, nil
  26274. }
  26275. // ClearMAC clears the value of the "mac" field.
  26276. func (m *TokenMutation) ClearMAC() {
  26277. m.mac = nil
  26278. m.clearedFields[token.FieldMAC] = struct{}{}
  26279. }
  26280. // MACCleared returns if the "mac" field was cleared in this mutation.
  26281. func (m *TokenMutation) MACCleared() bool {
  26282. _, ok := m.clearedFields[token.FieldMAC]
  26283. return ok
  26284. }
  26285. // ResetMAC resets all changes to the "mac" field.
  26286. func (m *TokenMutation) ResetMAC() {
  26287. m.mac = nil
  26288. delete(m.clearedFields, token.FieldMAC)
  26289. }
  26290. // SetOrganizationID sets the "organization_id" field.
  26291. func (m *TokenMutation) SetOrganizationID(u uint64) {
  26292. m.organization_id = &u
  26293. m.addorganization_id = nil
  26294. }
  26295. // OrganizationID returns the value of the "organization_id" field in the mutation.
  26296. func (m *TokenMutation) OrganizationID() (r uint64, exists bool) {
  26297. v := m.organization_id
  26298. if v == nil {
  26299. return
  26300. }
  26301. return *v, true
  26302. }
  26303. // OldOrganizationID returns the old "organization_id" field's value of the Token entity.
  26304. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  26305. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26306. func (m *TokenMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  26307. if !m.op.Is(OpUpdateOne) {
  26308. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  26309. }
  26310. if m.id == nil || m.oldValue == nil {
  26311. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  26312. }
  26313. oldValue, err := m.oldValue(ctx)
  26314. if err != nil {
  26315. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  26316. }
  26317. return oldValue.OrganizationID, nil
  26318. }
  26319. // AddOrganizationID adds u to the "organization_id" field.
  26320. func (m *TokenMutation) AddOrganizationID(u int64) {
  26321. if m.addorganization_id != nil {
  26322. *m.addorganization_id += u
  26323. } else {
  26324. m.addorganization_id = &u
  26325. }
  26326. }
  26327. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  26328. func (m *TokenMutation) AddedOrganizationID() (r int64, exists bool) {
  26329. v := m.addorganization_id
  26330. if v == nil {
  26331. return
  26332. }
  26333. return *v, true
  26334. }
  26335. // ResetOrganizationID resets all changes to the "organization_id" field.
  26336. func (m *TokenMutation) ResetOrganizationID() {
  26337. m.organization_id = nil
  26338. m.addorganization_id = nil
  26339. }
  26340. // SetAgentID sets the "agent_id" field.
  26341. func (m *TokenMutation) SetAgentID(u uint64) {
  26342. m.agent = &u
  26343. }
  26344. // AgentID returns the value of the "agent_id" field in the mutation.
  26345. func (m *TokenMutation) AgentID() (r uint64, exists bool) {
  26346. v := m.agent
  26347. if v == nil {
  26348. return
  26349. }
  26350. return *v, true
  26351. }
  26352. // OldAgentID returns the old "agent_id" field's value of the Token entity.
  26353. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  26354. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26355. func (m *TokenMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  26356. if !m.op.Is(OpUpdateOne) {
  26357. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  26358. }
  26359. if m.id == nil || m.oldValue == nil {
  26360. return v, errors.New("OldAgentID requires an ID field in the mutation")
  26361. }
  26362. oldValue, err := m.oldValue(ctx)
  26363. if err != nil {
  26364. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  26365. }
  26366. return oldValue.AgentID, nil
  26367. }
  26368. // ResetAgentID resets all changes to the "agent_id" field.
  26369. func (m *TokenMutation) ResetAgentID() {
  26370. m.agent = nil
  26371. }
  26372. // SetCustomAgentBase sets the "custom_agent_base" field.
  26373. func (m *TokenMutation) SetCustomAgentBase(s string) {
  26374. m.custom_agent_base = &s
  26375. }
  26376. // CustomAgentBase returns the value of the "custom_agent_base" field in the mutation.
  26377. func (m *TokenMutation) CustomAgentBase() (r string, exists bool) {
  26378. v := m.custom_agent_base
  26379. if v == nil {
  26380. return
  26381. }
  26382. return *v, true
  26383. }
  26384. // OldCustomAgentBase returns the old "custom_agent_base" field's value of the Token entity.
  26385. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  26386. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26387. func (m *TokenMutation) OldCustomAgentBase(ctx context.Context) (v string, err error) {
  26388. if !m.op.Is(OpUpdateOne) {
  26389. return v, errors.New("OldCustomAgentBase is only allowed on UpdateOne operations")
  26390. }
  26391. if m.id == nil || m.oldValue == nil {
  26392. return v, errors.New("OldCustomAgentBase requires an ID field in the mutation")
  26393. }
  26394. oldValue, err := m.oldValue(ctx)
  26395. if err != nil {
  26396. return v, fmt.Errorf("querying old value for OldCustomAgentBase: %w", err)
  26397. }
  26398. return oldValue.CustomAgentBase, nil
  26399. }
  26400. // ClearCustomAgentBase clears the value of the "custom_agent_base" field.
  26401. func (m *TokenMutation) ClearCustomAgentBase() {
  26402. m.custom_agent_base = nil
  26403. m.clearedFields[token.FieldCustomAgentBase] = struct{}{}
  26404. }
  26405. // CustomAgentBaseCleared returns if the "custom_agent_base" field was cleared in this mutation.
  26406. func (m *TokenMutation) CustomAgentBaseCleared() bool {
  26407. _, ok := m.clearedFields[token.FieldCustomAgentBase]
  26408. return ok
  26409. }
  26410. // ResetCustomAgentBase resets all changes to the "custom_agent_base" field.
  26411. func (m *TokenMutation) ResetCustomAgentBase() {
  26412. m.custom_agent_base = nil
  26413. delete(m.clearedFields, token.FieldCustomAgentBase)
  26414. }
  26415. // SetCustomAgentKey sets the "custom_agent_key" field.
  26416. func (m *TokenMutation) SetCustomAgentKey(s string) {
  26417. m.custom_agent_key = &s
  26418. }
  26419. // CustomAgentKey returns the value of the "custom_agent_key" field in the mutation.
  26420. func (m *TokenMutation) CustomAgentKey() (r string, exists bool) {
  26421. v := m.custom_agent_key
  26422. if v == nil {
  26423. return
  26424. }
  26425. return *v, true
  26426. }
  26427. // OldCustomAgentKey returns the old "custom_agent_key" field's value of the Token entity.
  26428. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  26429. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26430. func (m *TokenMutation) OldCustomAgentKey(ctx context.Context) (v string, err error) {
  26431. if !m.op.Is(OpUpdateOne) {
  26432. return v, errors.New("OldCustomAgentKey is only allowed on UpdateOne operations")
  26433. }
  26434. if m.id == nil || m.oldValue == nil {
  26435. return v, errors.New("OldCustomAgentKey requires an ID field in the mutation")
  26436. }
  26437. oldValue, err := m.oldValue(ctx)
  26438. if err != nil {
  26439. return v, fmt.Errorf("querying old value for OldCustomAgentKey: %w", err)
  26440. }
  26441. return oldValue.CustomAgentKey, nil
  26442. }
  26443. // ClearCustomAgentKey clears the value of the "custom_agent_key" field.
  26444. func (m *TokenMutation) ClearCustomAgentKey() {
  26445. m.custom_agent_key = nil
  26446. m.clearedFields[token.FieldCustomAgentKey] = struct{}{}
  26447. }
  26448. // CustomAgentKeyCleared returns if the "custom_agent_key" field was cleared in this mutation.
  26449. func (m *TokenMutation) CustomAgentKeyCleared() bool {
  26450. _, ok := m.clearedFields[token.FieldCustomAgentKey]
  26451. return ok
  26452. }
  26453. // ResetCustomAgentKey resets all changes to the "custom_agent_key" field.
  26454. func (m *TokenMutation) ResetCustomAgentKey() {
  26455. m.custom_agent_key = nil
  26456. delete(m.clearedFields, token.FieldCustomAgentKey)
  26457. }
  26458. // SetOpenaiBase sets the "openai_base" field.
  26459. func (m *TokenMutation) SetOpenaiBase(s string) {
  26460. m.openai_base = &s
  26461. }
  26462. // OpenaiBase returns the value of the "openai_base" field in the mutation.
  26463. func (m *TokenMutation) OpenaiBase() (r string, exists bool) {
  26464. v := m.openai_base
  26465. if v == nil {
  26466. return
  26467. }
  26468. return *v, true
  26469. }
  26470. // OldOpenaiBase returns the old "openai_base" field's value of the Token entity.
  26471. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  26472. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26473. func (m *TokenMutation) OldOpenaiBase(ctx context.Context) (v string, err error) {
  26474. if !m.op.Is(OpUpdateOne) {
  26475. return v, errors.New("OldOpenaiBase is only allowed on UpdateOne operations")
  26476. }
  26477. if m.id == nil || m.oldValue == nil {
  26478. return v, errors.New("OldOpenaiBase requires an ID field in the mutation")
  26479. }
  26480. oldValue, err := m.oldValue(ctx)
  26481. if err != nil {
  26482. return v, fmt.Errorf("querying old value for OldOpenaiBase: %w", err)
  26483. }
  26484. return oldValue.OpenaiBase, nil
  26485. }
  26486. // ClearOpenaiBase clears the value of the "openai_base" field.
  26487. func (m *TokenMutation) ClearOpenaiBase() {
  26488. m.openai_base = nil
  26489. m.clearedFields[token.FieldOpenaiBase] = struct{}{}
  26490. }
  26491. // OpenaiBaseCleared returns if the "openai_base" field was cleared in this mutation.
  26492. func (m *TokenMutation) OpenaiBaseCleared() bool {
  26493. _, ok := m.clearedFields[token.FieldOpenaiBase]
  26494. return ok
  26495. }
  26496. // ResetOpenaiBase resets all changes to the "openai_base" field.
  26497. func (m *TokenMutation) ResetOpenaiBase() {
  26498. m.openai_base = nil
  26499. delete(m.clearedFields, token.FieldOpenaiBase)
  26500. }
  26501. // SetOpenaiKey sets the "openai_key" field.
  26502. func (m *TokenMutation) SetOpenaiKey(s string) {
  26503. m.openai_key = &s
  26504. }
  26505. // OpenaiKey returns the value of the "openai_key" field in the mutation.
  26506. func (m *TokenMutation) OpenaiKey() (r string, exists bool) {
  26507. v := m.openai_key
  26508. if v == nil {
  26509. return
  26510. }
  26511. return *v, true
  26512. }
  26513. // OldOpenaiKey returns the old "openai_key" field's value of the Token entity.
  26514. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  26515. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26516. func (m *TokenMutation) OldOpenaiKey(ctx context.Context) (v string, err error) {
  26517. if !m.op.Is(OpUpdateOne) {
  26518. return v, errors.New("OldOpenaiKey is only allowed on UpdateOne operations")
  26519. }
  26520. if m.id == nil || m.oldValue == nil {
  26521. return v, errors.New("OldOpenaiKey requires an ID field in the mutation")
  26522. }
  26523. oldValue, err := m.oldValue(ctx)
  26524. if err != nil {
  26525. return v, fmt.Errorf("querying old value for OldOpenaiKey: %w", err)
  26526. }
  26527. return oldValue.OpenaiKey, nil
  26528. }
  26529. // ClearOpenaiKey clears the value of the "openai_key" field.
  26530. func (m *TokenMutation) ClearOpenaiKey() {
  26531. m.openai_key = nil
  26532. m.clearedFields[token.FieldOpenaiKey] = struct{}{}
  26533. }
  26534. // OpenaiKeyCleared returns if the "openai_key" field was cleared in this mutation.
  26535. func (m *TokenMutation) OpenaiKeyCleared() bool {
  26536. _, ok := m.clearedFields[token.FieldOpenaiKey]
  26537. return ok
  26538. }
  26539. // ResetOpenaiKey resets all changes to the "openai_key" field.
  26540. func (m *TokenMutation) ResetOpenaiKey() {
  26541. m.openai_key = nil
  26542. delete(m.clearedFields, token.FieldOpenaiKey)
  26543. }
  26544. // ClearAgent clears the "agent" edge to the Agent entity.
  26545. func (m *TokenMutation) ClearAgent() {
  26546. m.clearedagent = true
  26547. m.clearedFields[token.FieldAgentID] = struct{}{}
  26548. }
  26549. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  26550. func (m *TokenMutation) AgentCleared() bool {
  26551. return m.clearedagent
  26552. }
  26553. // AgentIDs returns the "agent" edge IDs in the mutation.
  26554. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  26555. // AgentID instead. It exists only for internal usage by the builders.
  26556. func (m *TokenMutation) AgentIDs() (ids []uint64) {
  26557. if id := m.agent; id != nil {
  26558. ids = append(ids, *id)
  26559. }
  26560. return
  26561. }
  26562. // ResetAgent resets all changes to the "agent" edge.
  26563. func (m *TokenMutation) ResetAgent() {
  26564. m.agent = nil
  26565. m.clearedagent = false
  26566. }
  26567. // Where appends a list predicates to the TokenMutation builder.
  26568. func (m *TokenMutation) Where(ps ...predicate.Token) {
  26569. m.predicates = append(m.predicates, ps...)
  26570. }
  26571. // WhereP appends storage-level predicates to the TokenMutation builder. Using this method,
  26572. // users can use type-assertion to append predicates that do not depend on any generated package.
  26573. func (m *TokenMutation) WhereP(ps ...func(*sql.Selector)) {
  26574. p := make([]predicate.Token, len(ps))
  26575. for i := range ps {
  26576. p[i] = ps[i]
  26577. }
  26578. m.Where(p...)
  26579. }
  26580. // Op returns the operation name.
  26581. func (m *TokenMutation) Op() Op {
  26582. return m.op
  26583. }
  26584. // SetOp allows setting the mutation operation.
  26585. func (m *TokenMutation) SetOp(op Op) {
  26586. m.op = op
  26587. }
  26588. // Type returns the node type of this mutation (Token).
  26589. func (m *TokenMutation) Type() string {
  26590. return m.typ
  26591. }
  26592. // Fields returns all fields that were changed during this mutation. Note that in
  26593. // order to get all numeric fields that were incremented/decremented, call
  26594. // AddedFields().
  26595. func (m *TokenMutation) Fields() []string {
  26596. fields := make([]string, 0, 12)
  26597. if m.created_at != nil {
  26598. fields = append(fields, token.FieldCreatedAt)
  26599. }
  26600. if m.updated_at != nil {
  26601. fields = append(fields, token.FieldUpdatedAt)
  26602. }
  26603. if m.deleted_at != nil {
  26604. fields = append(fields, token.FieldDeletedAt)
  26605. }
  26606. if m.expire_at != nil {
  26607. fields = append(fields, token.FieldExpireAt)
  26608. }
  26609. if m.token != nil {
  26610. fields = append(fields, token.FieldToken)
  26611. }
  26612. if m.mac != nil {
  26613. fields = append(fields, token.FieldMAC)
  26614. }
  26615. if m.organization_id != nil {
  26616. fields = append(fields, token.FieldOrganizationID)
  26617. }
  26618. if m.agent != nil {
  26619. fields = append(fields, token.FieldAgentID)
  26620. }
  26621. if m.custom_agent_base != nil {
  26622. fields = append(fields, token.FieldCustomAgentBase)
  26623. }
  26624. if m.custom_agent_key != nil {
  26625. fields = append(fields, token.FieldCustomAgentKey)
  26626. }
  26627. if m.openai_base != nil {
  26628. fields = append(fields, token.FieldOpenaiBase)
  26629. }
  26630. if m.openai_key != nil {
  26631. fields = append(fields, token.FieldOpenaiKey)
  26632. }
  26633. return fields
  26634. }
  26635. // Field returns the value of a field with the given name. The second boolean
  26636. // return value indicates that this field was not set, or was not defined in the
  26637. // schema.
  26638. func (m *TokenMutation) Field(name string) (ent.Value, bool) {
  26639. switch name {
  26640. case token.FieldCreatedAt:
  26641. return m.CreatedAt()
  26642. case token.FieldUpdatedAt:
  26643. return m.UpdatedAt()
  26644. case token.FieldDeletedAt:
  26645. return m.DeletedAt()
  26646. case token.FieldExpireAt:
  26647. return m.ExpireAt()
  26648. case token.FieldToken:
  26649. return m.Token()
  26650. case token.FieldMAC:
  26651. return m.MAC()
  26652. case token.FieldOrganizationID:
  26653. return m.OrganizationID()
  26654. case token.FieldAgentID:
  26655. return m.AgentID()
  26656. case token.FieldCustomAgentBase:
  26657. return m.CustomAgentBase()
  26658. case token.FieldCustomAgentKey:
  26659. return m.CustomAgentKey()
  26660. case token.FieldOpenaiBase:
  26661. return m.OpenaiBase()
  26662. case token.FieldOpenaiKey:
  26663. return m.OpenaiKey()
  26664. }
  26665. return nil, false
  26666. }
  26667. // OldField returns the old value of the field from the database. An error is
  26668. // returned if the mutation operation is not UpdateOne, or the query to the
  26669. // database failed.
  26670. func (m *TokenMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  26671. switch name {
  26672. case token.FieldCreatedAt:
  26673. return m.OldCreatedAt(ctx)
  26674. case token.FieldUpdatedAt:
  26675. return m.OldUpdatedAt(ctx)
  26676. case token.FieldDeletedAt:
  26677. return m.OldDeletedAt(ctx)
  26678. case token.FieldExpireAt:
  26679. return m.OldExpireAt(ctx)
  26680. case token.FieldToken:
  26681. return m.OldToken(ctx)
  26682. case token.FieldMAC:
  26683. return m.OldMAC(ctx)
  26684. case token.FieldOrganizationID:
  26685. return m.OldOrganizationID(ctx)
  26686. case token.FieldAgentID:
  26687. return m.OldAgentID(ctx)
  26688. case token.FieldCustomAgentBase:
  26689. return m.OldCustomAgentBase(ctx)
  26690. case token.FieldCustomAgentKey:
  26691. return m.OldCustomAgentKey(ctx)
  26692. case token.FieldOpenaiBase:
  26693. return m.OldOpenaiBase(ctx)
  26694. case token.FieldOpenaiKey:
  26695. return m.OldOpenaiKey(ctx)
  26696. }
  26697. return nil, fmt.Errorf("unknown Token field %s", name)
  26698. }
  26699. // SetField sets the value of a field with the given name. It returns an error if
  26700. // the field is not defined in the schema, or if the type mismatched the field
  26701. // type.
  26702. func (m *TokenMutation) SetField(name string, value ent.Value) error {
  26703. switch name {
  26704. case token.FieldCreatedAt:
  26705. v, ok := value.(time.Time)
  26706. if !ok {
  26707. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26708. }
  26709. m.SetCreatedAt(v)
  26710. return nil
  26711. case token.FieldUpdatedAt:
  26712. v, ok := value.(time.Time)
  26713. if !ok {
  26714. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26715. }
  26716. m.SetUpdatedAt(v)
  26717. return nil
  26718. case token.FieldDeletedAt:
  26719. v, ok := value.(time.Time)
  26720. if !ok {
  26721. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26722. }
  26723. m.SetDeletedAt(v)
  26724. return nil
  26725. case token.FieldExpireAt:
  26726. v, ok := value.(time.Time)
  26727. if !ok {
  26728. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26729. }
  26730. m.SetExpireAt(v)
  26731. return nil
  26732. case token.FieldToken:
  26733. v, ok := value.(string)
  26734. if !ok {
  26735. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26736. }
  26737. m.SetToken(v)
  26738. return nil
  26739. case token.FieldMAC:
  26740. v, ok := value.(string)
  26741. if !ok {
  26742. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26743. }
  26744. m.SetMAC(v)
  26745. return nil
  26746. case token.FieldOrganizationID:
  26747. v, ok := value.(uint64)
  26748. if !ok {
  26749. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26750. }
  26751. m.SetOrganizationID(v)
  26752. return nil
  26753. case token.FieldAgentID:
  26754. v, ok := value.(uint64)
  26755. if !ok {
  26756. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26757. }
  26758. m.SetAgentID(v)
  26759. return nil
  26760. case token.FieldCustomAgentBase:
  26761. v, ok := value.(string)
  26762. if !ok {
  26763. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26764. }
  26765. m.SetCustomAgentBase(v)
  26766. return nil
  26767. case token.FieldCustomAgentKey:
  26768. v, ok := value.(string)
  26769. if !ok {
  26770. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26771. }
  26772. m.SetCustomAgentKey(v)
  26773. return nil
  26774. case token.FieldOpenaiBase:
  26775. v, ok := value.(string)
  26776. if !ok {
  26777. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26778. }
  26779. m.SetOpenaiBase(v)
  26780. return nil
  26781. case token.FieldOpenaiKey:
  26782. v, ok := value.(string)
  26783. if !ok {
  26784. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26785. }
  26786. m.SetOpenaiKey(v)
  26787. return nil
  26788. }
  26789. return fmt.Errorf("unknown Token field %s", name)
  26790. }
  26791. // AddedFields returns all numeric fields that were incremented/decremented during
  26792. // this mutation.
  26793. func (m *TokenMutation) AddedFields() []string {
  26794. var fields []string
  26795. if m.addorganization_id != nil {
  26796. fields = append(fields, token.FieldOrganizationID)
  26797. }
  26798. return fields
  26799. }
  26800. // AddedField returns the numeric value that was incremented/decremented on a field
  26801. // with the given name. The second boolean return value indicates that this field
  26802. // was not set, or was not defined in the schema.
  26803. func (m *TokenMutation) AddedField(name string) (ent.Value, bool) {
  26804. switch name {
  26805. case token.FieldOrganizationID:
  26806. return m.AddedOrganizationID()
  26807. }
  26808. return nil, false
  26809. }
  26810. // AddField adds the value to the field with the given name. It returns an error if
  26811. // the field is not defined in the schema, or if the type mismatched the field
  26812. // type.
  26813. func (m *TokenMutation) AddField(name string, value ent.Value) error {
  26814. switch name {
  26815. case token.FieldOrganizationID:
  26816. v, ok := value.(int64)
  26817. if !ok {
  26818. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26819. }
  26820. m.AddOrganizationID(v)
  26821. return nil
  26822. }
  26823. return fmt.Errorf("unknown Token numeric field %s", name)
  26824. }
  26825. // ClearedFields returns all nullable fields that were cleared during this
  26826. // mutation.
  26827. func (m *TokenMutation) ClearedFields() []string {
  26828. var fields []string
  26829. if m.FieldCleared(token.FieldDeletedAt) {
  26830. fields = append(fields, token.FieldDeletedAt)
  26831. }
  26832. if m.FieldCleared(token.FieldExpireAt) {
  26833. fields = append(fields, token.FieldExpireAt)
  26834. }
  26835. if m.FieldCleared(token.FieldToken) {
  26836. fields = append(fields, token.FieldToken)
  26837. }
  26838. if m.FieldCleared(token.FieldMAC) {
  26839. fields = append(fields, token.FieldMAC)
  26840. }
  26841. if m.FieldCleared(token.FieldCustomAgentBase) {
  26842. fields = append(fields, token.FieldCustomAgentBase)
  26843. }
  26844. if m.FieldCleared(token.FieldCustomAgentKey) {
  26845. fields = append(fields, token.FieldCustomAgentKey)
  26846. }
  26847. if m.FieldCleared(token.FieldOpenaiBase) {
  26848. fields = append(fields, token.FieldOpenaiBase)
  26849. }
  26850. if m.FieldCleared(token.FieldOpenaiKey) {
  26851. fields = append(fields, token.FieldOpenaiKey)
  26852. }
  26853. return fields
  26854. }
  26855. // FieldCleared returns a boolean indicating if a field with the given name was
  26856. // cleared in this mutation.
  26857. func (m *TokenMutation) FieldCleared(name string) bool {
  26858. _, ok := m.clearedFields[name]
  26859. return ok
  26860. }
  26861. // ClearField clears the value of the field with the given name. It returns an
  26862. // error if the field is not defined in the schema.
  26863. func (m *TokenMutation) ClearField(name string) error {
  26864. switch name {
  26865. case token.FieldDeletedAt:
  26866. m.ClearDeletedAt()
  26867. return nil
  26868. case token.FieldExpireAt:
  26869. m.ClearExpireAt()
  26870. return nil
  26871. case token.FieldToken:
  26872. m.ClearToken()
  26873. return nil
  26874. case token.FieldMAC:
  26875. m.ClearMAC()
  26876. return nil
  26877. case token.FieldCustomAgentBase:
  26878. m.ClearCustomAgentBase()
  26879. return nil
  26880. case token.FieldCustomAgentKey:
  26881. m.ClearCustomAgentKey()
  26882. return nil
  26883. case token.FieldOpenaiBase:
  26884. m.ClearOpenaiBase()
  26885. return nil
  26886. case token.FieldOpenaiKey:
  26887. m.ClearOpenaiKey()
  26888. return nil
  26889. }
  26890. return fmt.Errorf("unknown Token nullable field %s", name)
  26891. }
  26892. // ResetField resets all changes in the mutation for the field with the given name.
  26893. // It returns an error if the field is not defined in the schema.
  26894. func (m *TokenMutation) ResetField(name string) error {
  26895. switch name {
  26896. case token.FieldCreatedAt:
  26897. m.ResetCreatedAt()
  26898. return nil
  26899. case token.FieldUpdatedAt:
  26900. m.ResetUpdatedAt()
  26901. return nil
  26902. case token.FieldDeletedAt:
  26903. m.ResetDeletedAt()
  26904. return nil
  26905. case token.FieldExpireAt:
  26906. m.ResetExpireAt()
  26907. return nil
  26908. case token.FieldToken:
  26909. m.ResetToken()
  26910. return nil
  26911. case token.FieldMAC:
  26912. m.ResetMAC()
  26913. return nil
  26914. case token.FieldOrganizationID:
  26915. m.ResetOrganizationID()
  26916. return nil
  26917. case token.FieldAgentID:
  26918. m.ResetAgentID()
  26919. return nil
  26920. case token.FieldCustomAgentBase:
  26921. m.ResetCustomAgentBase()
  26922. return nil
  26923. case token.FieldCustomAgentKey:
  26924. m.ResetCustomAgentKey()
  26925. return nil
  26926. case token.FieldOpenaiBase:
  26927. m.ResetOpenaiBase()
  26928. return nil
  26929. case token.FieldOpenaiKey:
  26930. m.ResetOpenaiKey()
  26931. return nil
  26932. }
  26933. return fmt.Errorf("unknown Token field %s", name)
  26934. }
  26935. // AddedEdges returns all edge names that were set/added in this mutation.
  26936. func (m *TokenMutation) AddedEdges() []string {
  26937. edges := make([]string, 0, 1)
  26938. if m.agent != nil {
  26939. edges = append(edges, token.EdgeAgent)
  26940. }
  26941. return edges
  26942. }
  26943. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  26944. // name in this mutation.
  26945. func (m *TokenMutation) AddedIDs(name string) []ent.Value {
  26946. switch name {
  26947. case token.EdgeAgent:
  26948. if id := m.agent; id != nil {
  26949. return []ent.Value{*id}
  26950. }
  26951. }
  26952. return nil
  26953. }
  26954. // RemovedEdges returns all edge names that were removed in this mutation.
  26955. func (m *TokenMutation) RemovedEdges() []string {
  26956. edges := make([]string, 0, 1)
  26957. return edges
  26958. }
  26959. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  26960. // the given name in this mutation.
  26961. func (m *TokenMutation) RemovedIDs(name string) []ent.Value {
  26962. return nil
  26963. }
  26964. // ClearedEdges returns all edge names that were cleared in this mutation.
  26965. func (m *TokenMutation) ClearedEdges() []string {
  26966. edges := make([]string, 0, 1)
  26967. if m.clearedagent {
  26968. edges = append(edges, token.EdgeAgent)
  26969. }
  26970. return edges
  26971. }
  26972. // EdgeCleared returns a boolean which indicates if the edge with the given name
  26973. // was cleared in this mutation.
  26974. func (m *TokenMutation) EdgeCleared(name string) bool {
  26975. switch name {
  26976. case token.EdgeAgent:
  26977. return m.clearedagent
  26978. }
  26979. return false
  26980. }
  26981. // ClearEdge clears the value of the edge with the given name. It returns an error
  26982. // if that edge is not defined in the schema.
  26983. func (m *TokenMutation) ClearEdge(name string) error {
  26984. switch name {
  26985. case token.EdgeAgent:
  26986. m.ClearAgent()
  26987. return nil
  26988. }
  26989. return fmt.Errorf("unknown Token unique edge %s", name)
  26990. }
  26991. // ResetEdge resets all changes to the edge with the given name in this mutation.
  26992. // It returns an error if the edge is not defined in the schema.
  26993. func (m *TokenMutation) ResetEdge(name string) error {
  26994. switch name {
  26995. case token.EdgeAgent:
  26996. m.ResetAgent()
  26997. return nil
  26998. }
  26999. return fmt.Errorf("unknown Token edge %s", name)
  27000. }
  27001. // TutorialMutation represents an operation that mutates the Tutorial nodes in the graph.
  27002. type TutorialMutation struct {
  27003. config
  27004. op Op
  27005. typ string
  27006. id *uint64
  27007. created_at *time.Time
  27008. updated_at *time.Time
  27009. deleted_at *time.Time
  27010. index *int
  27011. addindex *int
  27012. title *string
  27013. content *string
  27014. organization_id *uint64
  27015. addorganization_id *int64
  27016. clearedFields map[string]struct{}
  27017. employee *uint64
  27018. clearedemployee bool
  27019. done bool
  27020. oldValue func(context.Context) (*Tutorial, error)
  27021. predicates []predicate.Tutorial
  27022. }
  27023. var _ ent.Mutation = (*TutorialMutation)(nil)
  27024. // tutorialOption allows management of the mutation configuration using functional options.
  27025. type tutorialOption func(*TutorialMutation)
  27026. // newTutorialMutation creates new mutation for the Tutorial entity.
  27027. func newTutorialMutation(c config, op Op, opts ...tutorialOption) *TutorialMutation {
  27028. m := &TutorialMutation{
  27029. config: c,
  27030. op: op,
  27031. typ: TypeTutorial,
  27032. clearedFields: make(map[string]struct{}),
  27033. }
  27034. for _, opt := range opts {
  27035. opt(m)
  27036. }
  27037. return m
  27038. }
  27039. // withTutorialID sets the ID field of the mutation.
  27040. func withTutorialID(id uint64) tutorialOption {
  27041. return func(m *TutorialMutation) {
  27042. var (
  27043. err error
  27044. once sync.Once
  27045. value *Tutorial
  27046. )
  27047. m.oldValue = func(ctx context.Context) (*Tutorial, error) {
  27048. once.Do(func() {
  27049. if m.done {
  27050. err = errors.New("querying old values post mutation is not allowed")
  27051. } else {
  27052. value, err = m.Client().Tutorial.Get(ctx, id)
  27053. }
  27054. })
  27055. return value, err
  27056. }
  27057. m.id = &id
  27058. }
  27059. }
  27060. // withTutorial sets the old Tutorial of the mutation.
  27061. func withTutorial(node *Tutorial) tutorialOption {
  27062. return func(m *TutorialMutation) {
  27063. m.oldValue = func(context.Context) (*Tutorial, error) {
  27064. return node, nil
  27065. }
  27066. m.id = &node.ID
  27067. }
  27068. }
  27069. // Client returns a new `ent.Client` from the mutation. If the mutation was
  27070. // executed in a transaction (ent.Tx), a transactional client is returned.
  27071. func (m TutorialMutation) Client() *Client {
  27072. client := &Client{config: m.config}
  27073. client.init()
  27074. return client
  27075. }
  27076. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  27077. // it returns an error otherwise.
  27078. func (m TutorialMutation) Tx() (*Tx, error) {
  27079. if _, ok := m.driver.(*txDriver); !ok {
  27080. return nil, errors.New("ent: mutation is not running in a transaction")
  27081. }
  27082. tx := &Tx{config: m.config}
  27083. tx.init()
  27084. return tx, nil
  27085. }
  27086. // SetID sets the value of the id field. Note that this
  27087. // operation is only accepted on creation of Tutorial entities.
  27088. func (m *TutorialMutation) SetID(id uint64) {
  27089. m.id = &id
  27090. }
  27091. // ID returns the ID value in the mutation. Note that the ID is only available
  27092. // if it was provided to the builder or after it was returned from the database.
  27093. func (m *TutorialMutation) ID() (id uint64, exists bool) {
  27094. if m.id == nil {
  27095. return
  27096. }
  27097. return *m.id, true
  27098. }
  27099. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  27100. // That means, if the mutation is applied within a transaction with an isolation level such
  27101. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  27102. // or updated by the mutation.
  27103. func (m *TutorialMutation) IDs(ctx context.Context) ([]uint64, error) {
  27104. switch {
  27105. case m.op.Is(OpUpdateOne | OpDeleteOne):
  27106. id, exists := m.ID()
  27107. if exists {
  27108. return []uint64{id}, nil
  27109. }
  27110. fallthrough
  27111. case m.op.Is(OpUpdate | OpDelete):
  27112. return m.Client().Tutorial.Query().Where(m.predicates...).IDs(ctx)
  27113. default:
  27114. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  27115. }
  27116. }
  27117. // SetCreatedAt sets the "created_at" field.
  27118. func (m *TutorialMutation) SetCreatedAt(t time.Time) {
  27119. m.created_at = &t
  27120. }
  27121. // CreatedAt returns the value of the "created_at" field in the mutation.
  27122. func (m *TutorialMutation) CreatedAt() (r time.Time, exists bool) {
  27123. v := m.created_at
  27124. if v == nil {
  27125. return
  27126. }
  27127. return *v, true
  27128. }
  27129. // OldCreatedAt returns the old "created_at" field's value of the Tutorial entity.
  27130. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  27131. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27132. func (m *TutorialMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  27133. if !m.op.Is(OpUpdateOne) {
  27134. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  27135. }
  27136. if m.id == nil || m.oldValue == nil {
  27137. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  27138. }
  27139. oldValue, err := m.oldValue(ctx)
  27140. if err != nil {
  27141. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  27142. }
  27143. return oldValue.CreatedAt, nil
  27144. }
  27145. // ResetCreatedAt resets all changes to the "created_at" field.
  27146. func (m *TutorialMutation) ResetCreatedAt() {
  27147. m.created_at = nil
  27148. }
  27149. // SetUpdatedAt sets the "updated_at" field.
  27150. func (m *TutorialMutation) SetUpdatedAt(t time.Time) {
  27151. m.updated_at = &t
  27152. }
  27153. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  27154. func (m *TutorialMutation) UpdatedAt() (r time.Time, exists bool) {
  27155. v := m.updated_at
  27156. if v == nil {
  27157. return
  27158. }
  27159. return *v, true
  27160. }
  27161. // OldUpdatedAt returns the old "updated_at" field's value of the Tutorial entity.
  27162. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  27163. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27164. func (m *TutorialMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  27165. if !m.op.Is(OpUpdateOne) {
  27166. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  27167. }
  27168. if m.id == nil || m.oldValue == nil {
  27169. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  27170. }
  27171. oldValue, err := m.oldValue(ctx)
  27172. if err != nil {
  27173. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  27174. }
  27175. return oldValue.UpdatedAt, nil
  27176. }
  27177. // ResetUpdatedAt resets all changes to the "updated_at" field.
  27178. func (m *TutorialMutation) ResetUpdatedAt() {
  27179. m.updated_at = nil
  27180. }
  27181. // SetDeletedAt sets the "deleted_at" field.
  27182. func (m *TutorialMutation) SetDeletedAt(t time.Time) {
  27183. m.deleted_at = &t
  27184. }
  27185. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  27186. func (m *TutorialMutation) DeletedAt() (r time.Time, exists bool) {
  27187. v := m.deleted_at
  27188. if v == nil {
  27189. return
  27190. }
  27191. return *v, true
  27192. }
  27193. // OldDeletedAt returns the old "deleted_at" field's value of the Tutorial entity.
  27194. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  27195. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27196. func (m *TutorialMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  27197. if !m.op.Is(OpUpdateOne) {
  27198. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  27199. }
  27200. if m.id == nil || m.oldValue == nil {
  27201. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  27202. }
  27203. oldValue, err := m.oldValue(ctx)
  27204. if err != nil {
  27205. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  27206. }
  27207. return oldValue.DeletedAt, nil
  27208. }
  27209. // ClearDeletedAt clears the value of the "deleted_at" field.
  27210. func (m *TutorialMutation) ClearDeletedAt() {
  27211. m.deleted_at = nil
  27212. m.clearedFields[tutorial.FieldDeletedAt] = struct{}{}
  27213. }
  27214. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  27215. func (m *TutorialMutation) DeletedAtCleared() bool {
  27216. _, ok := m.clearedFields[tutorial.FieldDeletedAt]
  27217. return ok
  27218. }
  27219. // ResetDeletedAt resets all changes to the "deleted_at" field.
  27220. func (m *TutorialMutation) ResetDeletedAt() {
  27221. m.deleted_at = nil
  27222. delete(m.clearedFields, tutorial.FieldDeletedAt)
  27223. }
  27224. // SetEmployeeID sets the "employee_id" field.
  27225. func (m *TutorialMutation) SetEmployeeID(u uint64) {
  27226. m.employee = &u
  27227. }
  27228. // EmployeeID returns the value of the "employee_id" field in the mutation.
  27229. func (m *TutorialMutation) EmployeeID() (r uint64, exists bool) {
  27230. v := m.employee
  27231. if v == nil {
  27232. return
  27233. }
  27234. return *v, true
  27235. }
  27236. // OldEmployeeID returns the old "employee_id" field's value of the Tutorial entity.
  27237. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  27238. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27239. func (m *TutorialMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  27240. if !m.op.Is(OpUpdateOne) {
  27241. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  27242. }
  27243. if m.id == nil || m.oldValue == nil {
  27244. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  27245. }
  27246. oldValue, err := m.oldValue(ctx)
  27247. if err != nil {
  27248. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  27249. }
  27250. return oldValue.EmployeeID, nil
  27251. }
  27252. // ResetEmployeeID resets all changes to the "employee_id" field.
  27253. func (m *TutorialMutation) ResetEmployeeID() {
  27254. m.employee = nil
  27255. }
  27256. // SetIndex sets the "index" field.
  27257. func (m *TutorialMutation) SetIndex(i int) {
  27258. m.index = &i
  27259. m.addindex = nil
  27260. }
  27261. // Index returns the value of the "index" field in the mutation.
  27262. func (m *TutorialMutation) Index() (r int, exists bool) {
  27263. v := m.index
  27264. if v == nil {
  27265. return
  27266. }
  27267. return *v, true
  27268. }
  27269. // OldIndex returns the old "index" field's value of the Tutorial entity.
  27270. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  27271. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27272. func (m *TutorialMutation) OldIndex(ctx context.Context) (v int, err error) {
  27273. if !m.op.Is(OpUpdateOne) {
  27274. return v, errors.New("OldIndex is only allowed on UpdateOne operations")
  27275. }
  27276. if m.id == nil || m.oldValue == nil {
  27277. return v, errors.New("OldIndex requires an ID field in the mutation")
  27278. }
  27279. oldValue, err := m.oldValue(ctx)
  27280. if err != nil {
  27281. return v, fmt.Errorf("querying old value for OldIndex: %w", err)
  27282. }
  27283. return oldValue.Index, nil
  27284. }
  27285. // AddIndex adds i to the "index" field.
  27286. func (m *TutorialMutation) AddIndex(i int) {
  27287. if m.addindex != nil {
  27288. *m.addindex += i
  27289. } else {
  27290. m.addindex = &i
  27291. }
  27292. }
  27293. // AddedIndex returns the value that was added to the "index" field in this mutation.
  27294. func (m *TutorialMutation) AddedIndex() (r int, exists bool) {
  27295. v := m.addindex
  27296. if v == nil {
  27297. return
  27298. }
  27299. return *v, true
  27300. }
  27301. // ResetIndex resets all changes to the "index" field.
  27302. func (m *TutorialMutation) ResetIndex() {
  27303. m.index = nil
  27304. m.addindex = nil
  27305. }
  27306. // SetTitle sets the "title" field.
  27307. func (m *TutorialMutation) SetTitle(s string) {
  27308. m.title = &s
  27309. }
  27310. // Title returns the value of the "title" field in the mutation.
  27311. func (m *TutorialMutation) Title() (r string, exists bool) {
  27312. v := m.title
  27313. if v == nil {
  27314. return
  27315. }
  27316. return *v, true
  27317. }
  27318. // OldTitle returns the old "title" field's value of the Tutorial entity.
  27319. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  27320. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27321. func (m *TutorialMutation) OldTitle(ctx context.Context) (v string, err error) {
  27322. if !m.op.Is(OpUpdateOne) {
  27323. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  27324. }
  27325. if m.id == nil || m.oldValue == nil {
  27326. return v, errors.New("OldTitle requires an ID field in the mutation")
  27327. }
  27328. oldValue, err := m.oldValue(ctx)
  27329. if err != nil {
  27330. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  27331. }
  27332. return oldValue.Title, nil
  27333. }
  27334. // ResetTitle resets all changes to the "title" field.
  27335. func (m *TutorialMutation) ResetTitle() {
  27336. m.title = nil
  27337. }
  27338. // SetContent sets the "content" field.
  27339. func (m *TutorialMutation) SetContent(s string) {
  27340. m.content = &s
  27341. }
  27342. // Content returns the value of the "content" field in the mutation.
  27343. func (m *TutorialMutation) Content() (r string, exists bool) {
  27344. v := m.content
  27345. if v == nil {
  27346. return
  27347. }
  27348. return *v, true
  27349. }
  27350. // OldContent returns the old "content" field's value of the Tutorial entity.
  27351. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  27352. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27353. func (m *TutorialMutation) OldContent(ctx context.Context) (v string, err error) {
  27354. if !m.op.Is(OpUpdateOne) {
  27355. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  27356. }
  27357. if m.id == nil || m.oldValue == nil {
  27358. return v, errors.New("OldContent requires an ID field in the mutation")
  27359. }
  27360. oldValue, err := m.oldValue(ctx)
  27361. if err != nil {
  27362. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  27363. }
  27364. return oldValue.Content, nil
  27365. }
  27366. // ResetContent resets all changes to the "content" field.
  27367. func (m *TutorialMutation) ResetContent() {
  27368. m.content = nil
  27369. }
  27370. // SetOrganizationID sets the "organization_id" field.
  27371. func (m *TutorialMutation) SetOrganizationID(u uint64) {
  27372. m.organization_id = &u
  27373. m.addorganization_id = nil
  27374. }
  27375. // OrganizationID returns the value of the "organization_id" field in the mutation.
  27376. func (m *TutorialMutation) OrganizationID() (r uint64, exists bool) {
  27377. v := m.organization_id
  27378. if v == nil {
  27379. return
  27380. }
  27381. return *v, true
  27382. }
  27383. // OldOrganizationID returns the old "organization_id" field's value of the Tutorial entity.
  27384. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  27385. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27386. func (m *TutorialMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  27387. if !m.op.Is(OpUpdateOne) {
  27388. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  27389. }
  27390. if m.id == nil || m.oldValue == nil {
  27391. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  27392. }
  27393. oldValue, err := m.oldValue(ctx)
  27394. if err != nil {
  27395. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  27396. }
  27397. return oldValue.OrganizationID, nil
  27398. }
  27399. // AddOrganizationID adds u to the "organization_id" field.
  27400. func (m *TutorialMutation) AddOrganizationID(u int64) {
  27401. if m.addorganization_id != nil {
  27402. *m.addorganization_id += u
  27403. } else {
  27404. m.addorganization_id = &u
  27405. }
  27406. }
  27407. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  27408. func (m *TutorialMutation) AddedOrganizationID() (r int64, exists bool) {
  27409. v := m.addorganization_id
  27410. if v == nil {
  27411. return
  27412. }
  27413. return *v, true
  27414. }
  27415. // ResetOrganizationID resets all changes to the "organization_id" field.
  27416. func (m *TutorialMutation) ResetOrganizationID() {
  27417. m.organization_id = nil
  27418. m.addorganization_id = nil
  27419. }
  27420. // ClearEmployee clears the "employee" edge to the Employee entity.
  27421. func (m *TutorialMutation) ClearEmployee() {
  27422. m.clearedemployee = true
  27423. m.clearedFields[tutorial.FieldEmployeeID] = struct{}{}
  27424. }
  27425. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  27426. func (m *TutorialMutation) EmployeeCleared() bool {
  27427. return m.clearedemployee
  27428. }
  27429. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  27430. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  27431. // EmployeeID instead. It exists only for internal usage by the builders.
  27432. func (m *TutorialMutation) EmployeeIDs() (ids []uint64) {
  27433. if id := m.employee; id != nil {
  27434. ids = append(ids, *id)
  27435. }
  27436. return
  27437. }
  27438. // ResetEmployee resets all changes to the "employee" edge.
  27439. func (m *TutorialMutation) ResetEmployee() {
  27440. m.employee = nil
  27441. m.clearedemployee = false
  27442. }
  27443. // Where appends a list predicates to the TutorialMutation builder.
  27444. func (m *TutorialMutation) Where(ps ...predicate.Tutorial) {
  27445. m.predicates = append(m.predicates, ps...)
  27446. }
  27447. // WhereP appends storage-level predicates to the TutorialMutation builder. Using this method,
  27448. // users can use type-assertion to append predicates that do not depend on any generated package.
  27449. func (m *TutorialMutation) WhereP(ps ...func(*sql.Selector)) {
  27450. p := make([]predicate.Tutorial, len(ps))
  27451. for i := range ps {
  27452. p[i] = ps[i]
  27453. }
  27454. m.Where(p...)
  27455. }
  27456. // Op returns the operation name.
  27457. func (m *TutorialMutation) Op() Op {
  27458. return m.op
  27459. }
  27460. // SetOp allows setting the mutation operation.
  27461. func (m *TutorialMutation) SetOp(op Op) {
  27462. m.op = op
  27463. }
  27464. // Type returns the node type of this mutation (Tutorial).
  27465. func (m *TutorialMutation) Type() string {
  27466. return m.typ
  27467. }
  27468. // Fields returns all fields that were changed during this mutation. Note that in
  27469. // order to get all numeric fields that were incremented/decremented, call
  27470. // AddedFields().
  27471. func (m *TutorialMutation) Fields() []string {
  27472. fields := make([]string, 0, 8)
  27473. if m.created_at != nil {
  27474. fields = append(fields, tutorial.FieldCreatedAt)
  27475. }
  27476. if m.updated_at != nil {
  27477. fields = append(fields, tutorial.FieldUpdatedAt)
  27478. }
  27479. if m.deleted_at != nil {
  27480. fields = append(fields, tutorial.FieldDeletedAt)
  27481. }
  27482. if m.employee != nil {
  27483. fields = append(fields, tutorial.FieldEmployeeID)
  27484. }
  27485. if m.index != nil {
  27486. fields = append(fields, tutorial.FieldIndex)
  27487. }
  27488. if m.title != nil {
  27489. fields = append(fields, tutorial.FieldTitle)
  27490. }
  27491. if m.content != nil {
  27492. fields = append(fields, tutorial.FieldContent)
  27493. }
  27494. if m.organization_id != nil {
  27495. fields = append(fields, tutorial.FieldOrganizationID)
  27496. }
  27497. return fields
  27498. }
  27499. // Field returns the value of a field with the given name. The second boolean
  27500. // return value indicates that this field was not set, or was not defined in the
  27501. // schema.
  27502. func (m *TutorialMutation) Field(name string) (ent.Value, bool) {
  27503. switch name {
  27504. case tutorial.FieldCreatedAt:
  27505. return m.CreatedAt()
  27506. case tutorial.FieldUpdatedAt:
  27507. return m.UpdatedAt()
  27508. case tutorial.FieldDeletedAt:
  27509. return m.DeletedAt()
  27510. case tutorial.FieldEmployeeID:
  27511. return m.EmployeeID()
  27512. case tutorial.FieldIndex:
  27513. return m.Index()
  27514. case tutorial.FieldTitle:
  27515. return m.Title()
  27516. case tutorial.FieldContent:
  27517. return m.Content()
  27518. case tutorial.FieldOrganizationID:
  27519. return m.OrganizationID()
  27520. }
  27521. return nil, false
  27522. }
  27523. // OldField returns the old value of the field from the database. An error is
  27524. // returned if the mutation operation is not UpdateOne, or the query to the
  27525. // database failed.
  27526. func (m *TutorialMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  27527. switch name {
  27528. case tutorial.FieldCreatedAt:
  27529. return m.OldCreatedAt(ctx)
  27530. case tutorial.FieldUpdatedAt:
  27531. return m.OldUpdatedAt(ctx)
  27532. case tutorial.FieldDeletedAt:
  27533. return m.OldDeletedAt(ctx)
  27534. case tutorial.FieldEmployeeID:
  27535. return m.OldEmployeeID(ctx)
  27536. case tutorial.FieldIndex:
  27537. return m.OldIndex(ctx)
  27538. case tutorial.FieldTitle:
  27539. return m.OldTitle(ctx)
  27540. case tutorial.FieldContent:
  27541. return m.OldContent(ctx)
  27542. case tutorial.FieldOrganizationID:
  27543. return m.OldOrganizationID(ctx)
  27544. }
  27545. return nil, fmt.Errorf("unknown Tutorial field %s", name)
  27546. }
  27547. // SetField sets the value of a field with the given name. It returns an error if
  27548. // the field is not defined in the schema, or if the type mismatched the field
  27549. // type.
  27550. func (m *TutorialMutation) SetField(name string, value ent.Value) error {
  27551. switch name {
  27552. case tutorial.FieldCreatedAt:
  27553. v, ok := value.(time.Time)
  27554. if !ok {
  27555. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27556. }
  27557. m.SetCreatedAt(v)
  27558. return nil
  27559. case tutorial.FieldUpdatedAt:
  27560. v, ok := value.(time.Time)
  27561. if !ok {
  27562. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27563. }
  27564. m.SetUpdatedAt(v)
  27565. return nil
  27566. case tutorial.FieldDeletedAt:
  27567. v, ok := value.(time.Time)
  27568. if !ok {
  27569. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27570. }
  27571. m.SetDeletedAt(v)
  27572. return nil
  27573. case tutorial.FieldEmployeeID:
  27574. v, ok := value.(uint64)
  27575. if !ok {
  27576. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27577. }
  27578. m.SetEmployeeID(v)
  27579. return nil
  27580. case tutorial.FieldIndex:
  27581. v, ok := value.(int)
  27582. if !ok {
  27583. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27584. }
  27585. m.SetIndex(v)
  27586. return nil
  27587. case tutorial.FieldTitle:
  27588. v, ok := value.(string)
  27589. if !ok {
  27590. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27591. }
  27592. m.SetTitle(v)
  27593. return nil
  27594. case tutorial.FieldContent:
  27595. v, ok := value.(string)
  27596. if !ok {
  27597. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27598. }
  27599. m.SetContent(v)
  27600. return nil
  27601. case tutorial.FieldOrganizationID:
  27602. v, ok := value.(uint64)
  27603. if !ok {
  27604. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27605. }
  27606. m.SetOrganizationID(v)
  27607. return nil
  27608. }
  27609. return fmt.Errorf("unknown Tutorial field %s", name)
  27610. }
  27611. // AddedFields returns all numeric fields that were incremented/decremented during
  27612. // this mutation.
  27613. func (m *TutorialMutation) AddedFields() []string {
  27614. var fields []string
  27615. if m.addindex != nil {
  27616. fields = append(fields, tutorial.FieldIndex)
  27617. }
  27618. if m.addorganization_id != nil {
  27619. fields = append(fields, tutorial.FieldOrganizationID)
  27620. }
  27621. return fields
  27622. }
  27623. // AddedField returns the numeric value that was incremented/decremented on a field
  27624. // with the given name. The second boolean return value indicates that this field
  27625. // was not set, or was not defined in the schema.
  27626. func (m *TutorialMutation) AddedField(name string) (ent.Value, bool) {
  27627. switch name {
  27628. case tutorial.FieldIndex:
  27629. return m.AddedIndex()
  27630. case tutorial.FieldOrganizationID:
  27631. return m.AddedOrganizationID()
  27632. }
  27633. return nil, false
  27634. }
  27635. // AddField adds the value to the field with the given name. It returns an error if
  27636. // the field is not defined in the schema, or if the type mismatched the field
  27637. // type.
  27638. func (m *TutorialMutation) AddField(name string, value ent.Value) error {
  27639. switch name {
  27640. case tutorial.FieldIndex:
  27641. v, ok := value.(int)
  27642. if !ok {
  27643. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27644. }
  27645. m.AddIndex(v)
  27646. return nil
  27647. case tutorial.FieldOrganizationID:
  27648. v, ok := value.(int64)
  27649. if !ok {
  27650. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27651. }
  27652. m.AddOrganizationID(v)
  27653. return nil
  27654. }
  27655. return fmt.Errorf("unknown Tutorial numeric field %s", name)
  27656. }
  27657. // ClearedFields returns all nullable fields that were cleared during this
  27658. // mutation.
  27659. func (m *TutorialMutation) ClearedFields() []string {
  27660. var fields []string
  27661. if m.FieldCleared(tutorial.FieldDeletedAt) {
  27662. fields = append(fields, tutorial.FieldDeletedAt)
  27663. }
  27664. return fields
  27665. }
  27666. // FieldCleared returns a boolean indicating if a field with the given name was
  27667. // cleared in this mutation.
  27668. func (m *TutorialMutation) FieldCleared(name string) bool {
  27669. _, ok := m.clearedFields[name]
  27670. return ok
  27671. }
  27672. // ClearField clears the value of the field with the given name. It returns an
  27673. // error if the field is not defined in the schema.
  27674. func (m *TutorialMutation) ClearField(name string) error {
  27675. switch name {
  27676. case tutorial.FieldDeletedAt:
  27677. m.ClearDeletedAt()
  27678. return nil
  27679. }
  27680. return fmt.Errorf("unknown Tutorial nullable field %s", name)
  27681. }
  27682. // ResetField resets all changes in the mutation for the field with the given name.
  27683. // It returns an error if the field is not defined in the schema.
  27684. func (m *TutorialMutation) ResetField(name string) error {
  27685. switch name {
  27686. case tutorial.FieldCreatedAt:
  27687. m.ResetCreatedAt()
  27688. return nil
  27689. case tutorial.FieldUpdatedAt:
  27690. m.ResetUpdatedAt()
  27691. return nil
  27692. case tutorial.FieldDeletedAt:
  27693. m.ResetDeletedAt()
  27694. return nil
  27695. case tutorial.FieldEmployeeID:
  27696. m.ResetEmployeeID()
  27697. return nil
  27698. case tutorial.FieldIndex:
  27699. m.ResetIndex()
  27700. return nil
  27701. case tutorial.FieldTitle:
  27702. m.ResetTitle()
  27703. return nil
  27704. case tutorial.FieldContent:
  27705. m.ResetContent()
  27706. return nil
  27707. case tutorial.FieldOrganizationID:
  27708. m.ResetOrganizationID()
  27709. return nil
  27710. }
  27711. return fmt.Errorf("unknown Tutorial field %s", name)
  27712. }
  27713. // AddedEdges returns all edge names that were set/added in this mutation.
  27714. func (m *TutorialMutation) AddedEdges() []string {
  27715. edges := make([]string, 0, 1)
  27716. if m.employee != nil {
  27717. edges = append(edges, tutorial.EdgeEmployee)
  27718. }
  27719. return edges
  27720. }
  27721. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  27722. // name in this mutation.
  27723. func (m *TutorialMutation) AddedIDs(name string) []ent.Value {
  27724. switch name {
  27725. case tutorial.EdgeEmployee:
  27726. if id := m.employee; id != nil {
  27727. return []ent.Value{*id}
  27728. }
  27729. }
  27730. return nil
  27731. }
  27732. // RemovedEdges returns all edge names that were removed in this mutation.
  27733. func (m *TutorialMutation) RemovedEdges() []string {
  27734. edges := make([]string, 0, 1)
  27735. return edges
  27736. }
  27737. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  27738. // the given name in this mutation.
  27739. func (m *TutorialMutation) RemovedIDs(name string) []ent.Value {
  27740. return nil
  27741. }
  27742. // ClearedEdges returns all edge names that were cleared in this mutation.
  27743. func (m *TutorialMutation) ClearedEdges() []string {
  27744. edges := make([]string, 0, 1)
  27745. if m.clearedemployee {
  27746. edges = append(edges, tutorial.EdgeEmployee)
  27747. }
  27748. return edges
  27749. }
  27750. // EdgeCleared returns a boolean which indicates if the edge with the given name
  27751. // was cleared in this mutation.
  27752. func (m *TutorialMutation) EdgeCleared(name string) bool {
  27753. switch name {
  27754. case tutorial.EdgeEmployee:
  27755. return m.clearedemployee
  27756. }
  27757. return false
  27758. }
  27759. // ClearEdge clears the value of the edge with the given name. It returns an error
  27760. // if that edge is not defined in the schema.
  27761. func (m *TutorialMutation) ClearEdge(name string) error {
  27762. switch name {
  27763. case tutorial.EdgeEmployee:
  27764. m.ClearEmployee()
  27765. return nil
  27766. }
  27767. return fmt.Errorf("unknown Tutorial unique edge %s", name)
  27768. }
  27769. // ResetEdge resets all changes to the edge with the given name in this mutation.
  27770. // It returns an error if the edge is not defined in the schema.
  27771. func (m *TutorialMutation) ResetEdge(name string) error {
  27772. switch name {
  27773. case tutorial.EdgeEmployee:
  27774. m.ResetEmployee()
  27775. return nil
  27776. }
  27777. return fmt.Errorf("unknown Tutorial edge %s", name)
  27778. }
  27779. // UsageDetailMutation represents an operation that mutates the UsageDetail nodes in the graph.
  27780. type UsageDetailMutation struct {
  27781. config
  27782. op Op
  27783. typ string
  27784. id *uint64
  27785. created_at *time.Time
  27786. updated_at *time.Time
  27787. status *uint8
  27788. addstatus *int8
  27789. _type *int
  27790. add_type *int
  27791. bot_id *string
  27792. receiver_id *string
  27793. app *int
  27794. addapp *int
  27795. session_id *uint64
  27796. addsession_id *int64
  27797. request *string
  27798. response *string
  27799. original_data *custom_types.OriginalData
  27800. total_tokens *uint64
  27801. addtotal_tokens *int64
  27802. prompt_tokens *uint64
  27803. addprompt_tokens *int64
  27804. completion_tokens *uint64
  27805. addcompletion_tokens *int64
  27806. organization_id *uint64
  27807. addorganization_id *int64
  27808. clearedFields map[string]struct{}
  27809. done bool
  27810. oldValue func(context.Context) (*UsageDetail, error)
  27811. predicates []predicate.UsageDetail
  27812. }
  27813. var _ ent.Mutation = (*UsageDetailMutation)(nil)
  27814. // usagedetailOption allows management of the mutation configuration using functional options.
  27815. type usagedetailOption func(*UsageDetailMutation)
  27816. // newUsageDetailMutation creates new mutation for the UsageDetail entity.
  27817. func newUsageDetailMutation(c config, op Op, opts ...usagedetailOption) *UsageDetailMutation {
  27818. m := &UsageDetailMutation{
  27819. config: c,
  27820. op: op,
  27821. typ: TypeUsageDetail,
  27822. clearedFields: make(map[string]struct{}),
  27823. }
  27824. for _, opt := range opts {
  27825. opt(m)
  27826. }
  27827. return m
  27828. }
  27829. // withUsageDetailID sets the ID field of the mutation.
  27830. func withUsageDetailID(id uint64) usagedetailOption {
  27831. return func(m *UsageDetailMutation) {
  27832. var (
  27833. err error
  27834. once sync.Once
  27835. value *UsageDetail
  27836. )
  27837. m.oldValue = func(ctx context.Context) (*UsageDetail, error) {
  27838. once.Do(func() {
  27839. if m.done {
  27840. err = errors.New("querying old values post mutation is not allowed")
  27841. } else {
  27842. value, err = m.Client().UsageDetail.Get(ctx, id)
  27843. }
  27844. })
  27845. return value, err
  27846. }
  27847. m.id = &id
  27848. }
  27849. }
  27850. // withUsageDetail sets the old UsageDetail of the mutation.
  27851. func withUsageDetail(node *UsageDetail) usagedetailOption {
  27852. return func(m *UsageDetailMutation) {
  27853. m.oldValue = func(context.Context) (*UsageDetail, error) {
  27854. return node, nil
  27855. }
  27856. m.id = &node.ID
  27857. }
  27858. }
  27859. // Client returns a new `ent.Client` from the mutation. If the mutation was
  27860. // executed in a transaction (ent.Tx), a transactional client is returned.
  27861. func (m UsageDetailMutation) Client() *Client {
  27862. client := &Client{config: m.config}
  27863. client.init()
  27864. return client
  27865. }
  27866. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  27867. // it returns an error otherwise.
  27868. func (m UsageDetailMutation) Tx() (*Tx, error) {
  27869. if _, ok := m.driver.(*txDriver); !ok {
  27870. return nil, errors.New("ent: mutation is not running in a transaction")
  27871. }
  27872. tx := &Tx{config: m.config}
  27873. tx.init()
  27874. return tx, nil
  27875. }
  27876. // SetID sets the value of the id field. Note that this
  27877. // operation is only accepted on creation of UsageDetail entities.
  27878. func (m *UsageDetailMutation) SetID(id uint64) {
  27879. m.id = &id
  27880. }
  27881. // ID returns the ID value in the mutation. Note that the ID is only available
  27882. // if it was provided to the builder or after it was returned from the database.
  27883. func (m *UsageDetailMutation) ID() (id uint64, exists bool) {
  27884. if m.id == nil {
  27885. return
  27886. }
  27887. return *m.id, true
  27888. }
  27889. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  27890. // That means, if the mutation is applied within a transaction with an isolation level such
  27891. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  27892. // or updated by the mutation.
  27893. func (m *UsageDetailMutation) IDs(ctx context.Context) ([]uint64, error) {
  27894. switch {
  27895. case m.op.Is(OpUpdateOne | OpDeleteOne):
  27896. id, exists := m.ID()
  27897. if exists {
  27898. return []uint64{id}, nil
  27899. }
  27900. fallthrough
  27901. case m.op.Is(OpUpdate | OpDelete):
  27902. return m.Client().UsageDetail.Query().Where(m.predicates...).IDs(ctx)
  27903. default:
  27904. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  27905. }
  27906. }
  27907. // SetCreatedAt sets the "created_at" field.
  27908. func (m *UsageDetailMutation) SetCreatedAt(t time.Time) {
  27909. m.created_at = &t
  27910. }
  27911. // CreatedAt returns the value of the "created_at" field in the mutation.
  27912. func (m *UsageDetailMutation) CreatedAt() (r time.Time, exists bool) {
  27913. v := m.created_at
  27914. if v == nil {
  27915. return
  27916. }
  27917. return *v, true
  27918. }
  27919. // OldCreatedAt returns the old "created_at" field's value of the UsageDetail entity.
  27920. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27921. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27922. func (m *UsageDetailMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  27923. if !m.op.Is(OpUpdateOne) {
  27924. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  27925. }
  27926. if m.id == nil || m.oldValue == nil {
  27927. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  27928. }
  27929. oldValue, err := m.oldValue(ctx)
  27930. if err != nil {
  27931. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  27932. }
  27933. return oldValue.CreatedAt, nil
  27934. }
  27935. // ResetCreatedAt resets all changes to the "created_at" field.
  27936. func (m *UsageDetailMutation) ResetCreatedAt() {
  27937. m.created_at = nil
  27938. }
  27939. // SetUpdatedAt sets the "updated_at" field.
  27940. func (m *UsageDetailMutation) SetUpdatedAt(t time.Time) {
  27941. m.updated_at = &t
  27942. }
  27943. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  27944. func (m *UsageDetailMutation) UpdatedAt() (r time.Time, exists bool) {
  27945. v := m.updated_at
  27946. if v == nil {
  27947. return
  27948. }
  27949. return *v, true
  27950. }
  27951. // OldUpdatedAt returns the old "updated_at" field's value of the UsageDetail entity.
  27952. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27953. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27954. func (m *UsageDetailMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  27955. if !m.op.Is(OpUpdateOne) {
  27956. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  27957. }
  27958. if m.id == nil || m.oldValue == nil {
  27959. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  27960. }
  27961. oldValue, err := m.oldValue(ctx)
  27962. if err != nil {
  27963. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  27964. }
  27965. return oldValue.UpdatedAt, nil
  27966. }
  27967. // ResetUpdatedAt resets all changes to the "updated_at" field.
  27968. func (m *UsageDetailMutation) ResetUpdatedAt() {
  27969. m.updated_at = nil
  27970. }
  27971. // SetStatus sets the "status" field.
  27972. func (m *UsageDetailMutation) SetStatus(u uint8) {
  27973. m.status = &u
  27974. m.addstatus = nil
  27975. }
  27976. // Status returns the value of the "status" field in the mutation.
  27977. func (m *UsageDetailMutation) Status() (r uint8, exists bool) {
  27978. v := m.status
  27979. if v == nil {
  27980. return
  27981. }
  27982. return *v, true
  27983. }
  27984. // OldStatus returns the old "status" field's value of the UsageDetail entity.
  27985. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27986. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27987. func (m *UsageDetailMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  27988. if !m.op.Is(OpUpdateOne) {
  27989. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  27990. }
  27991. if m.id == nil || m.oldValue == nil {
  27992. return v, errors.New("OldStatus requires an ID field in the mutation")
  27993. }
  27994. oldValue, err := m.oldValue(ctx)
  27995. if err != nil {
  27996. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  27997. }
  27998. return oldValue.Status, nil
  27999. }
  28000. // AddStatus adds u to the "status" field.
  28001. func (m *UsageDetailMutation) AddStatus(u int8) {
  28002. if m.addstatus != nil {
  28003. *m.addstatus += u
  28004. } else {
  28005. m.addstatus = &u
  28006. }
  28007. }
  28008. // AddedStatus returns the value that was added to the "status" field in this mutation.
  28009. func (m *UsageDetailMutation) AddedStatus() (r int8, exists bool) {
  28010. v := m.addstatus
  28011. if v == nil {
  28012. return
  28013. }
  28014. return *v, true
  28015. }
  28016. // ClearStatus clears the value of the "status" field.
  28017. func (m *UsageDetailMutation) ClearStatus() {
  28018. m.status = nil
  28019. m.addstatus = nil
  28020. m.clearedFields[usagedetail.FieldStatus] = struct{}{}
  28021. }
  28022. // StatusCleared returns if the "status" field was cleared in this mutation.
  28023. func (m *UsageDetailMutation) StatusCleared() bool {
  28024. _, ok := m.clearedFields[usagedetail.FieldStatus]
  28025. return ok
  28026. }
  28027. // ResetStatus resets all changes to the "status" field.
  28028. func (m *UsageDetailMutation) ResetStatus() {
  28029. m.status = nil
  28030. m.addstatus = nil
  28031. delete(m.clearedFields, usagedetail.FieldStatus)
  28032. }
  28033. // SetType sets the "type" field.
  28034. func (m *UsageDetailMutation) SetType(i int) {
  28035. m._type = &i
  28036. m.add_type = nil
  28037. }
  28038. // GetType returns the value of the "type" field in the mutation.
  28039. func (m *UsageDetailMutation) GetType() (r int, exists bool) {
  28040. v := m._type
  28041. if v == nil {
  28042. return
  28043. }
  28044. return *v, true
  28045. }
  28046. // OldType returns the old "type" field's value of the UsageDetail entity.
  28047. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  28048. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28049. func (m *UsageDetailMutation) OldType(ctx context.Context) (v int, err error) {
  28050. if !m.op.Is(OpUpdateOne) {
  28051. return v, errors.New("OldType is only allowed on UpdateOne operations")
  28052. }
  28053. if m.id == nil || m.oldValue == nil {
  28054. return v, errors.New("OldType requires an ID field in the mutation")
  28055. }
  28056. oldValue, err := m.oldValue(ctx)
  28057. if err != nil {
  28058. return v, fmt.Errorf("querying old value for OldType: %w", err)
  28059. }
  28060. return oldValue.Type, nil
  28061. }
  28062. // AddType adds i to the "type" field.
  28063. func (m *UsageDetailMutation) AddType(i int) {
  28064. if m.add_type != nil {
  28065. *m.add_type += i
  28066. } else {
  28067. m.add_type = &i
  28068. }
  28069. }
  28070. // AddedType returns the value that was added to the "type" field in this mutation.
  28071. func (m *UsageDetailMutation) AddedType() (r int, exists bool) {
  28072. v := m.add_type
  28073. if v == nil {
  28074. return
  28075. }
  28076. return *v, true
  28077. }
  28078. // ClearType clears the value of the "type" field.
  28079. func (m *UsageDetailMutation) ClearType() {
  28080. m._type = nil
  28081. m.add_type = nil
  28082. m.clearedFields[usagedetail.FieldType] = struct{}{}
  28083. }
  28084. // TypeCleared returns if the "type" field was cleared in this mutation.
  28085. func (m *UsageDetailMutation) TypeCleared() bool {
  28086. _, ok := m.clearedFields[usagedetail.FieldType]
  28087. return ok
  28088. }
  28089. // ResetType resets all changes to the "type" field.
  28090. func (m *UsageDetailMutation) ResetType() {
  28091. m._type = nil
  28092. m.add_type = nil
  28093. delete(m.clearedFields, usagedetail.FieldType)
  28094. }
  28095. // SetBotID sets the "bot_id" field.
  28096. func (m *UsageDetailMutation) SetBotID(s string) {
  28097. m.bot_id = &s
  28098. }
  28099. // BotID returns the value of the "bot_id" field in the mutation.
  28100. func (m *UsageDetailMutation) BotID() (r string, exists bool) {
  28101. v := m.bot_id
  28102. if v == nil {
  28103. return
  28104. }
  28105. return *v, true
  28106. }
  28107. // OldBotID returns the old "bot_id" field's value of the UsageDetail entity.
  28108. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  28109. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28110. func (m *UsageDetailMutation) OldBotID(ctx context.Context) (v string, err error) {
  28111. if !m.op.Is(OpUpdateOne) {
  28112. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  28113. }
  28114. if m.id == nil || m.oldValue == nil {
  28115. return v, errors.New("OldBotID requires an ID field in the mutation")
  28116. }
  28117. oldValue, err := m.oldValue(ctx)
  28118. if err != nil {
  28119. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  28120. }
  28121. return oldValue.BotID, nil
  28122. }
  28123. // ResetBotID resets all changes to the "bot_id" field.
  28124. func (m *UsageDetailMutation) ResetBotID() {
  28125. m.bot_id = nil
  28126. }
  28127. // SetReceiverID sets the "receiver_id" field.
  28128. func (m *UsageDetailMutation) SetReceiverID(s string) {
  28129. m.receiver_id = &s
  28130. }
  28131. // ReceiverID returns the value of the "receiver_id" field in the mutation.
  28132. func (m *UsageDetailMutation) ReceiverID() (r string, exists bool) {
  28133. v := m.receiver_id
  28134. if v == nil {
  28135. return
  28136. }
  28137. return *v, true
  28138. }
  28139. // OldReceiverID returns the old "receiver_id" field's value of the UsageDetail entity.
  28140. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  28141. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28142. func (m *UsageDetailMutation) OldReceiverID(ctx context.Context) (v string, err error) {
  28143. if !m.op.Is(OpUpdateOne) {
  28144. return v, errors.New("OldReceiverID is only allowed on UpdateOne operations")
  28145. }
  28146. if m.id == nil || m.oldValue == nil {
  28147. return v, errors.New("OldReceiverID requires an ID field in the mutation")
  28148. }
  28149. oldValue, err := m.oldValue(ctx)
  28150. if err != nil {
  28151. return v, fmt.Errorf("querying old value for OldReceiverID: %w", err)
  28152. }
  28153. return oldValue.ReceiverID, nil
  28154. }
  28155. // ResetReceiverID resets all changes to the "receiver_id" field.
  28156. func (m *UsageDetailMutation) ResetReceiverID() {
  28157. m.receiver_id = nil
  28158. }
  28159. // SetApp sets the "app" field.
  28160. func (m *UsageDetailMutation) SetApp(i int) {
  28161. m.app = &i
  28162. m.addapp = nil
  28163. }
  28164. // App returns the value of the "app" field in the mutation.
  28165. func (m *UsageDetailMutation) App() (r int, exists bool) {
  28166. v := m.app
  28167. if v == nil {
  28168. return
  28169. }
  28170. return *v, true
  28171. }
  28172. // OldApp returns the old "app" field's value of the UsageDetail entity.
  28173. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  28174. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28175. func (m *UsageDetailMutation) OldApp(ctx context.Context) (v int, err error) {
  28176. if !m.op.Is(OpUpdateOne) {
  28177. return v, errors.New("OldApp is only allowed on UpdateOne operations")
  28178. }
  28179. if m.id == nil || m.oldValue == nil {
  28180. return v, errors.New("OldApp requires an ID field in the mutation")
  28181. }
  28182. oldValue, err := m.oldValue(ctx)
  28183. if err != nil {
  28184. return v, fmt.Errorf("querying old value for OldApp: %w", err)
  28185. }
  28186. return oldValue.App, nil
  28187. }
  28188. // AddApp adds i to the "app" field.
  28189. func (m *UsageDetailMutation) AddApp(i int) {
  28190. if m.addapp != nil {
  28191. *m.addapp += i
  28192. } else {
  28193. m.addapp = &i
  28194. }
  28195. }
  28196. // AddedApp returns the value that was added to the "app" field in this mutation.
  28197. func (m *UsageDetailMutation) AddedApp() (r int, exists bool) {
  28198. v := m.addapp
  28199. if v == nil {
  28200. return
  28201. }
  28202. return *v, true
  28203. }
  28204. // ClearApp clears the value of the "app" field.
  28205. func (m *UsageDetailMutation) ClearApp() {
  28206. m.app = nil
  28207. m.addapp = nil
  28208. m.clearedFields[usagedetail.FieldApp] = struct{}{}
  28209. }
  28210. // AppCleared returns if the "app" field was cleared in this mutation.
  28211. func (m *UsageDetailMutation) AppCleared() bool {
  28212. _, ok := m.clearedFields[usagedetail.FieldApp]
  28213. return ok
  28214. }
  28215. // ResetApp resets all changes to the "app" field.
  28216. func (m *UsageDetailMutation) ResetApp() {
  28217. m.app = nil
  28218. m.addapp = nil
  28219. delete(m.clearedFields, usagedetail.FieldApp)
  28220. }
  28221. // SetSessionID sets the "session_id" field.
  28222. func (m *UsageDetailMutation) SetSessionID(u uint64) {
  28223. m.session_id = &u
  28224. m.addsession_id = nil
  28225. }
  28226. // SessionID returns the value of the "session_id" field in the mutation.
  28227. func (m *UsageDetailMutation) SessionID() (r uint64, exists bool) {
  28228. v := m.session_id
  28229. if v == nil {
  28230. return
  28231. }
  28232. return *v, true
  28233. }
  28234. // OldSessionID returns the old "session_id" field's value of the UsageDetail entity.
  28235. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  28236. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28237. func (m *UsageDetailMutation) OldSessionID(ctx context.Context) (v uint64, err error) {
  28238. if !m.op.Is(OpUpdateOne) {
  28239. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  28240. }
  28241. if m.id == nil || m.oldValue == nil {
  28242. return v, errors.New("OldSessionID requires an ID field in the mutation")
  28243. }
  28244. oldValue, err := m.oldValue(ctx)
  28245. if err != nil {
  28246. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  28247. }
  28248. return oldValue.SessionID, nil
  28249. }
  28250. // AddSessionID adds u to the "session_id" field.
  28251. func (m *UsageDetailMutation) AddSessionID(u int64) {
  28252. if m.addsession_id != nil {
  28253. *m.addsession_id += u
  28254. } else {
  28255. m.addsession_id = &u
  28256. }
  28257. }
  28258. // AddedSessionID returns the value that was added to the "session_id" field in this mutation.
  28259. func (m *UsageDetailMutation) AddedSessionID() (r int64, exists bool) {
  28260. v := m.addsession_id
  28261. if v == nil {
  28262. return
  28263. }
  28264. return *v, true
  28265. }
  28266. // ClearSessionID clears the value of the "session_id" field.
  28267. func (m *UsageDetailMutation) ClearSessionID() {
  28268. m.session_id = nil
  28269. m.addsession_id = nil
  28270. m.clearedFields[usagedetail.FieldSessionID] = struct{}{}
  28271. }
  28272. // SessionIDCleared returns if the "session_id" field was cleared in this mutation.
  28273. func (m *UsageDetailMutation) SessionIDCleared() bool {
  28274. _, ok := m.clearedFields[usagedetail.FieldSessionID]
  28275. return ok
  28276. }
  28277. // ResetSessionID resets all changes to the "session_id" field.
  28278. func (m *UsageDetailMutation) ResetSessionID() {
  28279. m.session_id = nil
  28280. m.addsession_id = nil
  28281. delete(m.clearedFields, usagedetail.FieldSessionID)
  28282. }
  28283. // SetRequest sets the "request" field.
  28284. func (m *UsageDetailMutation) SetRequest(s string) {
  28285. m.request = &s
  28286. }
  28287. // Request returns the value of the "request" field in the mutation.
  28288. func (m *UsageDetailMutation) Request() (r string, exists bool) {
  28289. v := m.request
  28290. if v == nil {
  28291. return
  28292. }
  28293. return *v, true
  28294. }
  28295. // OldRequest returns the old "request" field's value of the UsageDetail entity.
  28296. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  28297. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28298. func (m *UsageDetailMutation) OldRequest(ctx context.Context) (v string, err error) {
  28299. if !m.op.Is(OpUpdateOne) {
  28300. return v, errors.New("OldRequest is only allowed on UpdateOne operations")
  28301. }
  28302. if m.id == nil || m.oldValue == nil {
  28303. return v, errors.New("OldRequest requires an ID field in the mutation")
  28304. }
  28305. oldValue, err := m.oldValue(ctx)
  28306. if err != nil {
  28307. return v, fmt.Errorf("querying old value for OldRequest: %w", err)
  28308. }
  28309. return oldValue.Request, nil
  28310. }
  28311. // ResetRequest resets all changes to the "request" field.
  28312. func (m *UsageDetailMutation) ResetRequest() {
  28313. m.request = nil
  28314. }
  28315. // SetResponse sets the "response" field.
  28316. func (m *UsageDetailMutation) SetResponse(s string) {
  28317. m.response = &s
  28318. }
  28319. // Response returns the value of the "response" field in the mutation.
  28320. func (m *UsageDetailMutation) Response() (r string, exists bool) {
  28321. v := m.response
  28322. if v == nil {
  28323. return
  28324. }
  28325. return *v, true
  28326. }
  28327. // OldResponse returns the old "response" field's value of the UsageDetail entity.
  28328. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  28329. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28330. func (m *UsageDetailMutation) OldResponse(ctx context.Context) (v string, err error) {
  28331. if !m.op.Is(OpUpdateOne) {
  28332. return v, errors.New("OldResponse is only allowed on UpdateOne operations")
  28333. }
  28334. if m.id == nil || m.oldValue == nil {
  28335. return v, errors.New("OldResponse requires an ID field in the mutation")
  28336. }
  28337. oldValue, err := m.oldValue(ctx)
  28338. if err != nil {
  28339. return v, fmt.Errorf("querying old value for OldResponse: %w", err)
  28340. }
  28341. return oldValue.Response, nil
  28342. }
  28343. // ResetResponse resets all changes to the "response" field.
  28344. func (m *UsageDetailMutation) ResetResponse() {
  28345. m.response = nil
  28346. }
  28347. // SetOriginalData sets the "original_data" field.
  28348. func (m *UsageDetailMutation) SetOriginalData(ctd custom_types.OriginalData) {
  28349. m.original_data = &ctd
  28350. }
  28351. // OriginalData returns the value of the "original_data" field in the mutation.
  28352. func (m *UsageDetailMutation) OriginalData() (r custom_types.OriginalData, exists bool) {
  28353. v := m.original_data
  28354. if v == nil {
  28355. return
  28356. }
  28357. return *v, true
  28358. }
  28359. // OldOriginalData returns the old "original_data" field's value of the UsageDetail entity.
  28360. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  28361. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28362. func (m *UsageDetailMutation) OldOriginalData(ctx context.Context) (v custom_types.OriginalData, err error) {
  28363. if !m.op.Is(OpUpdateOne) {
  28364. return v, errors.New("OldOriginalData is only allowed on UpdateOne operations")
  28365. }
  28366. if m.id == nil || m.oldValue == nil {
  28367. return v, errors.New("OldOriginalData requires an ID field in the mutation")
  28368. }
  28369. oldValue, err := m.oldValue(ctx)
  28370. if err != nil {
  28371. return v, fmt.Errorf("querying old value for OldOriginalData: %w", err)
  28372. }
  28373. return oldValue.OriginalData, nil
  28374. }
  28375. // ResetOriginalData resets all changes to the "original_data" field.
  28376. func (m *UsageDetailMutation) ResetOriginalData() {
  28377. m.original_data = nil
  28378. }
  28379. // SetTotalTokens sets the "total_tokens" field.
  28380. func (m *UsageDetailMutation) SetTotalTokens(u uint64) {
  28381. m.total_tokens = &u
  28382. m.addtotal_tokens = nil
  28383. }
  28384. // TotalTokens returns the value of the "total_tokens" field in the mutation.
  28385. func (m *UsageDetailMutation) TotalTokens() (r uint64, exists bool) {
  28386. v := m.total_tokens
  28387. if v == nil {
  28388. return
  28389. }
  28390. return *v, true
  28391. }
  28392. // OldTotalTokens returns the old "total_tokens" field's value of the UsageDetail entity.
  28393. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  28394. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28395. func (m *UsageDetailMutation) OldTotalTokens(ctx context.Context) (v uint64, err error) {
  28396. if !m.op.Is(OpUpdateOne) {
  28397. return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
  28398. }
  28399. if m.id == nil || m.oldValue == nil {
  28400. return v, errors.New("OldTotalTokens requires an ID field in the mutation")
  28401. }
  28402. oldValue, err := m.oldValue(ctx)
  28403. if err != nil {
  28404. return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
  28405. }
  28406. return oldValue.TotalTokens, nil
  28407. }
  28408. // AddTotalTokens adds u to the "total_tokens" field.
  28409. func (m *UsageDetailMutation) AddTotalTokens(u int64) {
  28410. if m.addtotal_tokens != nil {
  28411. *m.addtotal_tokens += u
  28412. } else {
  28413. m.addtotal_tokens = &u
  28414. }
  28415. }
  28416. // AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
  28417. func (m *UsageDetailMutation) AddedTotalTokens() (r int64, exists bool) {
  28418. v := m.addtotal_tokens
  28419. if v == nil {
  28420. return
  28421. }
  28422. return *v, true
  28423. }
  28424. // ClearTotalTokens clears the value of the "total_tokens" field.
  28425. func (m *UsageDetailMutation) ClearTotalTokens() {
  28426. m.total_tokens = nil
  28427. m.addtotal_tokens = nil
  28428. m.clearedFields[usagedetail.FieldTotalTokens] = struct{}{}
  28429. }
  28430. // TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
  28431. func (m *UsageDetailMutation) TotalTokensCleared() bool {
  28432. _, ok := m.clearedFields[usagedetail.FieldTotalTokens]
  28433. return ok
  28434. }
  28435. // ResetTotalTokens resets all changes to the "total_tokens" field.
  28436. func (m *UsageDetailMutation) ResetTotalTokens() {
  28437. m.total_tokens = nil
  28438. m.addtotal_tokens = nil
  28439. delete(m.clearedFields, usagedetail.FieldTotalTokens)
  28440. }
  28441. // SetPromptTokens sets the "prompt_tokens" field.
  28442. func (m *UsageDetailMutation) SetPromptTokens(u uint64) {
  28443. m.prompt_tokens = &u
  28444. m.addprompt_tokens = nil
  28445. }
  28446. // PromptTokens returns the value of the "prompt_tokens" field in the mutation.
  28447. func (m *UsageDetailMutation) PromptTokens() (r uint64, exists bool) {
  28448. v := m.prompt_tokens
  28449. if v == nil {
  28450. return
  28451. }
  28452. return *v, true
  28453. }
  28454. // OldPromptTokens returns the old "prompt_tokens" field's value of the UsageDetail entity.
  28455. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  28456. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28457. func (m *UsageDetailMutation) OldPromptTokens(ctx context.Context) (v uint64, err error) {
  28458. if !m.op.Is(OpUpdateOne) {
  28459. return v, errors.New("OldPromptTokens is only allowed on UpdateOne operations")
  28460. }
  28461. if m.id == nil || m.oldValue == nil {
  28462. return v, errors.New("OldPromptTokens requires an ID field in the mutation")
  28463. }
  28464. oldValue, err := m.oldValue(ctx)
  28465. if err != nil {
  28466. return v, fmt.Errorf("querying old value for OldPromptTokens: %w", err)
  28467. }
  28468. return oldValue.PromptTokens, nil
  28469. }
  28470. // AddPromptTokens adds u to the "prompt_tokens" field.
  28471. func (m *UsageDetailMutation) AddPromptTokens(u int64) {
  28472. if m.addprompt_tokens != nil {
  28473. *m.addprompt_tokens += u
  28474. } else {
  28475. m.addprompt_tokens = &u
  28476. }
  28477. }
  28478. // AddedPromptTokens returns the value that was added to the "prompt_tokens" field in this mutation.
  28479. func (m *UsageDetailMutation) AddedPromptTokens() (r int64, exists bool) {
  28480. v := m.addprompt_tokens
  28481. if v == nil {
  28482. return
  28483. }
  28484. return *v, true
  28485. }
  28486. // ClearPromptTokens clears the value of the "prompt_tokens" field.
  28487. func (m *UsageDetailMutation) ClearPromptTokens() {
  28488. m.prompt_tokens = nil
  28489. m.addprompt_tokens = nil
  28490. m.clearedFields[usagedetail.FieldPromptTokens] = struct{}{}
  28491. }
  28492. // PromptTokensCleared returns if the "prompt_tokens" field was cleared in this mutation.
  28493. func (m *UsageDetailMutation) PromptTokensCleared() bool {
  28494. _, ok := m.clearedFields[usagedetail.FieldPromptTokens]
  28495. return ok
  28496. }
  28497. // ResetPromptTokens resets all changes to the "prompt_tokens" field.
  28498. func (m *UsageDetailMutation) ResetPromptTokens() {
  28499. m.prompt_tokens = nil
  28500. m.addprompt_tokens = nil
  28501. delete(m.clearedFields, usagedetail.FieldPromptTokens)
  28502. }
  28503. // SetCompletionTokens sets the "completion_tokens" field.
  28504. func (m *UsageDetailMutation) SetCompletionTokens(u uint64) {
  28505. m.completion_tokens = &u
  28506. m.addcompletion_tokens = nil
  28507. }
  28508. // CompletionTokens returns the value of the "completion_tokens" field in the mutation.
  28509. func (m *UsageDetailMutation) CompletionTokens() (r uint64, exists bool) {
  28510. v := m.completion_tokens
  28511. if v == nil {
  28512. return
  28513. }
  28514. return *v, true
  28515. }
  28516. // OldCompletionTokens returns the old "completion_tokens" field's value of the UsageDetail entity.
  28517. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  28518. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28519. func (m *UsageDetailMutation) OldCompletionTokens(ctx context.Context) (v uint64, err error) {
  28520. if !m.op.Is(OpUpdateOne) {
  28521. return v, errors.New("OldCompletionTokens is only allowed on UpdateOne operations")
  28522. }
  28523. if m.id == nil || m.oldValue == nil {
  28524. return v, errors.New("OldCompletionTokens requires an ID field in the mutation")
  28525. }
  28526. oldValue, err := m.oldValue(ctx)
  28527. if err != nil {
  28528. return v, fmt.Errorf("querying old value for OldCompletionTokens: %w", err)
  28529. }
  28530. return oldValue.CompletionTokens, nil
  28531. }
  28532. // AddCompletionTokens adds u to the "completion_tokens" field.
  28533. func (m *UsageDetailMutation) AddCompletionTokens(u int64) {
  28534. if m.addcompletion_tokens != nil {
  28535. *m.addcompletion_tokens += u
  28536. } else {
  28537. m.addcompletion_tokens = &u
  28538. }
  28539. }
  28540. // AddedCompletionTokens returns the value that was added to the "completion_tokens" field in this mutation.
  28541. func (m *UsageDetailMutation) AddedCompletionTokens() (r int64, exists bool) {
  28542. v := m.addcompletion_tokens
  28543. if v == nil {
  28544. return
  28545. }
  28546. return *v, true
  28547. }
  28548. // ClearCompletionTokens clears the value of the "completion_tokens" field.
  28549. func (m *UsageDetailMutation) ClearCompletionTokens() {
  28550. m.completion_tokens = nil
  28551. m.addcompletion_tokens = nil
  28552. m.clearedFields[usagedetail.FieldCompletionTokens] = struct{}{}
  28553. }
  28554. // CompletionTokensCleared returns if the "completion_tokens" field was cleared in this mutation.
  28555. func (m *UsageDetailMutation) CompletionTokensCleared() bool {
  28556. _, ok := m.clearedFields[usagedetail.FieldCompletionTokens]
  28557. return ok
  28558. }
  28559. // ResetCompletionTokens resets all changes to the "completion_tokens" field.
  28560. func (m *UsageDetailMutation) ResetCompletionTokens() {
  28561. m.completion_tokens = nil
  28562. m.addcompletion_tokens = nil
  28563. delete(m.clearedFields, usagedetail.FieldCompletionTokens)
  28564. }
  28565. // SetOrganizationID sets the "organization_id" field.
  28566. func (m *UsageDetailMutation) SetOrganizationID(u uint64) {
  28567. m.organization_id = &u
  28568. m.addorganization_id = nil
  28569. }
  28570. // OrganizationID returns the value of the "organization_id" field in the mutation.
  28571. func (m *UsageDetailMutation) OrganizationID() (r uint64, exists bool) {
  28572. v := m.organization_id
  28573. if v == nil {
  28574. return
  28575. }
  28576. return *v, true
  28577. }
  28578. // OldOrganizationID returns the old "organization_id" field's value of the UsageDetail entity.
  28579. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  28580. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28581. func (m *UsageDetailMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  28582. if !m.op.Is(OpUpdateOne) {
  28583. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  28584. }
  28585. if m.id == nil || m.oldValue == nil {
  28586. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  28587. }
  28588. oldValue, err := m.oldValue(ctx)
  28589. if err != nil {
  28590. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  28591. }
  28592. return oldValue.OrganizationID, nil
  28593. }
  28594. // AddOrganizationID adds u to the "organization_id" field.
  28595. func (m *UsageDetailMutation) AddOrganizationID(u int64) {
  28596. if m.addorganization_id != nil {
  28597. *m.addorganization_id += u
  28598. } else {
  28599. m.addorganization_id = &u
  28600. }
  28601. }
  28602. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  28603. func (m *UsageDetailMutation) AddedOrganizationID() (r int64, exists bool) {
  28604. v := m.addorganization_id
  28605. if v == nil {
  28606. return
  28607. }
  28608. return *v, true
  28609. }
  28610. // ClearOrganizationID clears the value of the "organization_id" field.
  28611. func (m *UsageDetailMutation) ClearOrganizationID() {
  28612. m.organization_id = nil
  28613. m.addorganization_id = nil
  28614. m.clearedFields[usagedetail.FieldOrganizationID] = struct{}{}
  28615. }
  28616. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  28617. func (m *UsageDetailMutation) OrganizationIDCleared() bool {
  28618. _, ok := m.clearedFields[usagedetail.FieldOrganizationID]
  28619. return ok
  28620. }
  28621. // ResetOrganizationID resets all changes to the "organization_id" field.
  28622. func (m *UsageDetailMutation) ResetOrganizationID() {
  28623. m.organization_id = nil
  28624. m.addorganization_id = nil
  28625. delete(m.clearedFields, usagedetail.FieldOrganizationID)
  28626. }
  28627. // Where appends a list predicates to the UsageDetailMutation builder.
  28628. func (m *UsageDetailMutation) Where(ps ...predicate.UsageDetail) {
  28629. m.predicates = append(m.predicates, ps...)
  28630. }
  28631. // WhereP appends storage-level predicates to the UsageDetailMutation builder. Using this method,
  28632. // users can use type-assertion to append predicates that do not depend on any generated package.
  28633. func (m *UsageDetailMutation) WhereP(ps ...func(*sql.Selector)) {
  28634. p := make([]predicate.UsageDetail, len(ps))
  28635. for i := range ps {
  28636. p[i] = ps[i]
  28637. }
  28638. m.Where(p...)
  28639. }
  28640. // Op returns the operation name.
  28641. func (m *UsageDetailMutation) Op() Op {
  28642. return m.op
  28643. }
  28644. // SetOp allows setting the mutation operation.
  28645. func (m *UsageDetailMutation) SetOp(op Op) {
  28646. m.op = op
  28647. }
  28648. // Type returns the node type of this mutation (UsageDetail).
  28649. func (m *UsageDetailMutation) Type() string {
  28650. return m.typ
  28651. }
  28652. // Fields returns all fields that were changed during this mutation. Note that in
  28653. // order to get all numeric fields that were incremented/decremented, call
  28654. // AddedFields().
  28655. func (m *UsageDetailMutation) Fields() []string {
  28656. fields := make([]string, 0, 15)
  28657. if m.created_at != nil {
  28658. fields = append(fields, usagedetail.FieldCreatedAt)
  28659. }
  28660. if m.updated_at != nil {
  28661. fields = append(fields, usagedetail.FieldUpdatedAt)
  28662. }
  28663. if m.status != nil {
  28664. fields = append(fields, usagedetail.FieldStatus)
  28665. }
  28666. if m._type != nil {
  28667. fields = append(fields, usagedetail.FieldType)
  28668. }
  28669. if m.bot_id != nil {
  28670. fields = append(fields, usagedetail.FieldBotID)
  28671. }
  28672. if m.receiver_id != nil {
  28673. fields = append(fields, usagedetail.FieldReceiverID)
  28674. }
  28675. if m.app != nil {
  28676. fields = append(fields, usagedetail.FieldApp)
  28677. }
  28678. if m.session_id != nil {
  28679. fields = append(fields, usagedetail.FieldSessionID)
  28680. }
  28681. if m.request != nil {
  28682. fields = append(fields, usagedetail.FieldRequest)
  28683. }
  28684. if m.response != nil {
  28685. fields = append(fields, usagedetail.FieldResponse)
  28686. }
  28687. if m.original_data != nil {
  28688. fields = append(fields, usagedetail.FieldOriginalData)
  28689. }
  28690. if m.total_tokens != nil {
  28691. fields = append(fields, usagedetail.FieldTotalTokens)
  28692. }
  28693. if m.prompt_tokens != nil {
  28694. fields = append(fields, usagedetail.FieldPromptTokens)
  28695. }
  28696. if m.completion_tokens != nil {
  28697. fields = append(fields, usagedetail.FieldCompletionTokens)
  28698. }
  28699. if m.organization_id != nil {
  28700. fields = append(fields, usagedetail.FieldOrganizationID)
  28701. }
  28702. return fields
  28703. }
  28704. // Field returns the value of a field with the given name. The second boolean
  28705. // return value indicates that this field was not set, or was not defined in the
  28706. // schema.
  28707. func (m *UsageDetailMutation) Field(name string) (ent.Value, bool) {
  28708. switch name {
  28709. case usagedetail.FieldCreatedAt:
  28710. return m.CreatedAt()
  28711. case usagedetail.FieldUpdatedAt:
  28712. return m.UpdatedAt()
  28713. case usagedetail.FieldStatus:
  28714. return m.Status()
  28715. case usagedetail.FieldType:
  28716. return m.GetType()
  28717. case usagedetail.FieldBotID:
  28718. return m.BotID()
  28719. case usagedetail.FieldReceiverID:
  28720. return m.ReceiverID()
  28721. case usagedetail.FieldApp:
  28722. return m.App()
  28723. case usagedetail.FieldSessionID:
  28724. return m.SessionID()
  28725. case usagedetail.FieldRequest:
  28726. return m.Request()
  28727. case usagedetail.FieldResponse:
  28728. return m.Response()
  28729. case usagedetail.FieldOriginalData:
  28730. return m.OriginalData()
  28731. case usagedetail.FieldTotalTokens:
  28732. return m.TotalTokens()
  28733. case usagedetail.FieldPromptTokens:
  28734. return m.PromptTokens()
  28735. case usagedetail.FieldCompletionTokens:
  28736. return m.CompletionTokens()
  28737. case usagedetail.FieldOrganizationID:
  28738. return m.OrganizationID()
  28739. }
  28740. return nil, false
  28741. }
  28742. // OldField returns the old value of the field from the database. An error is
  28743. // returned if the mutation operation is not UpdateOne, or the query to the
  28744. // database failed.
  28745. func (m *UsageDetailMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  28746. switch name {
  28747. case usagedetail.FieldCreatedAt:
  28748. return m.OldCreatedAt(ctx)
  28749. case usagedetail.FieldUpdatedAt:
  28750. return m.OldUpdatedAt(ctx)
  28751. case usagedetail.FieldStatus:
  28752. return m.OldStatus(ctx)
  28753. case usagedetail.FieldType:
  28754. return m.OldType(ctx)
  28755. case usagedetail.FieldBotID:
  28756. return m.OldBotID(ctx)
  28757. case usagedetail.FieldReceiverID:
  28758. return m.OldReceiverID(ctx)
  28759. case usagedetail.FieldApp:
  28760. return m.OldApp(ctx)
  28761. case usagedetail.FieldSessionID:
  28762. return m.OldSessionID(ctx)
  28763. case usagedetail.FieldRequest:
  28764. return m.OldRequest(ctx)
  28765. case usagedetail.FieldResponse:
  28766. return m.OldResponse(ctx)
  28767. case usagedetail.FieldOriginalData:
  28768. return m.OldOriginalData(ctx)
  28769. case usagedetail.FieldTotalTokens:
  28770. return m.OldTotalTokens(ctx)
  28771. case usagedetail.FieldPromptTokens:
  28772. return m.OldPromptTokens(ctx)
  28773. case usagedetail.FieldCompletionTokens:
  28774. return m.OldCompletionTokens(ctx)
  28775. case usagedetail.FieldOrganizationID:
  28776. return m.OldOrganizationID(ctx)
  28777. }
  28778. return nil, fmt.Errorf("unknown UsageDetail field %s", name)
  28779. }
  28780. // SetField sets the value of a field with the given name. It returns an error if
  28781. // the field is not defined in the schema, or if the type mismatched the field
  28782. // type.
  28783. func (m *UsageDetailMutation) SetField(name string, value ent.Value) error {
  28784. switch name {
  28785. case usagedetail.FieldCreatedAt:
  28786. v, ok := value.(time.Time)
  28787. if !ok {
  28788. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28789. }
  28790. m.SetCreatedAt(v)
  28791. return nil
  28792. case usagedetail.FieldUpdatedAt:
  28793. v, ok := value.(time.Time)
  28794. if !ok {
  28795. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28796. }
  28797. m.SetUpdatedAt(v)
  28798. return nil
  28799. case usagedetail.FieldStatus:
  28800. v, ok := value.(uint8)
  28801. if !ok {
  28802. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28803. }
  28804. m.SetStatus(v)
  28805. return nil
  28806. case usagedetail.FieldType:
  28807. v, ok := value.(int)
  28808. if !ok {
  28809. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28810. }
  28811. m.SetType(v)
  28812. return nil
  28813. case usagedetail.FieldBotID:
  28814. v, ok := value.(string)
  28815. if !ok {
  28816. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28817. }
  28818. m.SetBotID(v)
  28819. return nil
  28820. case usagedetail.FieldReceiverID:
  28821. v, ok := value.(string)
  28822. if !ok {
  28823. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28824. }
  28825. m.SetReceiverID(v)
  28826. return nil
  28827. case usagedetail.FieldApp:
  28828. v, ok := value.(int)
  28829. if !ok {
  28830. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28831. }
  28832. m.SetApp(v)
  28833. return nil
  28834. case usagedetail.FieldSessionID:
  28835. v, ok := value.(uint64)
  28836. if !ok {
  28837. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28838. }
  28839. m.SetSessionID(v)
  28840. return nil
  28841. case usagedetail.FieldRequest:
  28842. v, ok := value.(string)
  28843. if !ok {
  28844. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28845. }
  28846. m.SetRequest(v)
  28847. return nil
  28848. case usagedetail.FieldResponse:
  28849. v, ok := value.(string)
  28850. if !ok {
  28851. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28852. }
  28853. m.SetResponse(v)
  28854. return nil
  28855. case usagedetail.FieldOriginalData:
  28856. v, ok := value.(custom_types.OriginalData)
  28857. if !ok {
  28858. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28859. }
  28860. m.SetOriginalData(v)
  28861. return nil
  28862. case usagedetail.FieldTotalTokens:
  28863. v, ok := value.(uint64)
  28864. if !ok {
  28865. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28866. }
  28867. m.SetTotalTokens(v)
  28868. return nil
  28869. case usagedetail.FieldPromptTokens:
  28870. v, ok := value.(uint64)
  28871. if !ok {
  28872. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28873. }
  28874. m.SetPromptTokens(v)
  28875. return nil
  28876. case usagedetail.FieldCompletionTokens:
  28877. v, ok := value.(uint64)
  28878. if !ok {
  28879. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28880. }
  28881. m.SetCompletionTokens(v)
  28882. return nil
  28883. case usagedetail.FieldOrganizationID:
  28884. v, ok := value.(uint64)
  28885. if !ok {
  28886. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28887. }
  28888. m.SetOrganizationID(v)
  28889. return nil
  28890. }
  28891. return fmt.Errorf("unknown UsageDetail field %s", name)
  28892. }
  28893. // AddedFields returns all numeric fields that were incremented/decremented during
  28894. // this mutation.
  28895. func (m *UsageDetailMutation) AddedFields() []string {
  28896. var fields []string
  28897. if m.addstatus != nil {
  28898. fields = append(fields, usagedetail.FieldStatus)
  28899. }
  28900. if m.add_type != nil {
  28901. fields = append(fields, usagedetail.FieldType)
  28902. }
  28903. if m.addapp != nil {
  28904. fields = append(fields, usagedetail.FieldApp)
  28905. }
  28906. if m.addsession_id != nil {
  28907. fields = append(fields, usagedetail.FieldSessionID)
  28908. }
  28909. if m.addtotal_tokens != nil {
  28910. fields = append(fields, usagedetail.FieldTotalTokens)
  28911. }
  28912. if m.addprompt_tokens != nil {
  28913. fields = append(fields, usagedetail.FieldPromptTokens)
  28914. }
  28915. if m.addcompletion_tokens != nil {
  28916. fields = append(fields, usagedetail.FieldCompletionTokens)
  28917. }
  28918. if m.addorganization_id != nil {
  28919. fields = append(fields, usagedetail.FieldOrganizationID)
  28920. }
  28921. return fields
  28922. }
  28923. // AddedField returns the numeric value that was incremented/decremented on a field
  28924. // with the given name. The second boolean return value indicates that this field
  28925. // was not set, or was not defined in the schema.
  28926. func (m *UsageDetailMutation) AddedField(name string) (ent.Value, bool) {
  28927. switch name {
  28928. case usagedetail.FieldStatus:
  28929. return m.AddedStatus()
  28930. case usagedetail.FieldType:
  28931. return m.AddedType()
  28932. case usagedetail.FieldApp:
  28933. return m.AddedApp()
  28934. case usagedetail.FieldSessionID:
  28935. return m.AddedSessionID()
  28936. case usagedetail.FieldTotalTokens:
  28937. return m.AddedTotalTokens()
  28938. case usagedetail.FieldPromptTokens:
  28939. return m.AddedPromptTokens()
  28940. case usagedetail.FieldCompletionTokens:
  28941. return m.AddedCompletionTokens()
  28942. case usagedetail.FieldOrganizationID:
  28943. return m.AddedOrganizationID()
  28944. }
  28945. return nil, false
  28946. }
  28947. // AddField adds the value to the field with the given name. It returns an error if
  28948. // the field is not defined in the schema, or if the type mismatched the field
  28949. // type.
  28950. func (m *UsageDetailMutation) AddField(name string, value ent.Value) error {
  28951. switch name {
  28952. case usagedetail.FieldStatus:
  28953. v, ok := value.(int8)
  28954. if !ok {
  28955. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28956. }
  28957. m.AddStatus(v)
  28958. return nil
  28959. case usagedetail.FieldType:
  28960. v, ok := value.(int)
  28961. if !ok {
  28962. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28963. }
  28964. m.AddType(v)
  28965. return nil
  28966. case usagedetail.FieldApp:
  28967. v, ok := value.(int)
  28968. if !ok {
  28969. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28970. }
  28971. m.AddApp(v)
  28972. return nil
  28973. case usagedetail.FieldSessionID:
  28974. v, ok := value.(int64)
  28975. if !ok {
  28976. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28977. }
  28978. m.AddSessionID(v)
  28979. return nil
  28980. case usagedetail.FieldTotalTokens:
  28981. v, ok := value.(int64)
  28982. if !ok {
  28983. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28984. }
  28985. m.AddTotalTokens(v)
  28986. return nil
  28987. case usagedetail.FieldPromptTokens:
  28988. v, ok := value.(int64)
  28989. if !ok {
  28990. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28991. }
  28992. m.AddPromptTokens(v)
  28993. return nil
  28994. case usagedetail.FieldCompletionTokens:
  28995. v, ok := value.(int64)
  28996. if !ok {
  28997. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28998. }
  28999. m.AddCompletionTokens(v)
  29000. return nil
  29001. case usagedetail.FieldOrganizationID:
  29002. v, ok := value.(int64)
  29003. if !ok {
  29004. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29005. }
  29006. m.AddOrganizationID(v)
  29007. return nil
  29008. }
  29009. return fmt.Errorf("unknown UsageDetail numeric field %s", name)
  29010. }
  29011. // ClearedFields returns all nullable fields that were cleared during this
  29012. // mutation.
  29013. func (m *UsageDetailMutation) ClearedFields() []string {
  29014. var fields []string
  29015. if m.FieldCleared(usagedetail.FieldStatus) {
  29016. fields = append(fields, usagedetail.FieldStatus)
  29017. }
  29018. if m.FieldCleared(usagedetail.FieldType) {
  29019. fields = append(fields, usagedetail.FieldType)
  29020. }
  29021. if m.FieldCleared(usagedetail.FieldApp) {
  29022. fields = append(fields, usagedetail.FieldApp)
  29023. }
  29024. if m.FieldCleared(usagedetail.FieldSessionID) {
  29025. fields = append(fields, usagedetail.FieldSessionID)
  29026. }
  29027. if m.FieldCleared(usagedetail.FieldTotalTokens) {
  29028. fields = append(fields, usagedetail.FieldTotalTokens)
  29029. }
  29030. if m.FieldCleared(usagedetail.FieldPromptTokens) {
  29031. fields = append(fields, usagedetail.FieldPromptTokens)
  29032. }
  29033. if m.FieldCleared(usagedetail.FieldCompletionTokens) {
  29034. fields = append(fields, usagedetail.FieldCompletionTokens)
  29035. }
  29036. if m.FieldCleared(usagedetail.FieldOrganizationID) {
  29037. fields = append(fields, usagedetail.FieldOrganizationID)
  29038. }
  29039. return fields
  29040. }
  29041. // FieldCleared returns a boolean indicating if a field with the given name was
  29042. // cleared in this mutation.
  29043. func (m *UsageDetailMutation) FieldCleared(name string) bool {
  29044. _, ok := m.clearedFields[name]
  29045. return ok
  29046. }
  29047. // ClearField clears the value of the field with the given name. It returns an
  29048. // error if the field is not defined in the schema.
  29049. func (m *UsageDetailMutation) ClearField(name string) error {
  29050. switch name {
  29051. case usagedetail.FieldStatus:
  29052. m.ClearStatus()
  29053. return nil
  29054. case usagedetail.FieldType:
  29055. m.ClearType()
  29056. return nil
  29057. case usagedetail.FieldApp:
  29058. m.ClearApp()
  29059. return nil
  29060. case usagedetail.FieldSessionID:
  29061. m.ClearSessionID()
  29062. return nil
  29063. case usagedetail.FieldTotalTokens:
  29064. m.ClearTotalTokens()
  29065. return nil
  29066. case usagedetail.FieldPromptTokens:
  29067. m.ClearPromptTokens()
  29068. return nil
  29069. case usagedetail.FieldCompletionTokens:
  29070. m.ClearCompletionTokens()
  29071. return nil
  29072. case usagedetail.FieldOrganizationID:
  29073. m.ClearOrganizationID()
  29074. return nil
  29075. }
  29076. return fmt.Errorf("unknown UsageDetail nullable field %s", name)
  29077. }
  29078. // ResetField resets all changes in the mutation for the field with the given name.
  29079. // It returns an error if the field is not defined in the schema.
  29080. func (m *UsageDetailMutation) ResetField(name string) error {
  29081. switch name {
  29082. case usagedetail.FieldCreatedAt:
  29083. m.ResetCreatedAt()
  29084. return nil
  29085. case usagedetail.FieldUpdatedAt:
  29086. m.ResetUpdatedAt()
  29087. return nil
  29088. case usagedetail.FieldStatus:
  29089. m.ResetStatus()
  29090. return nil
  29091. case usagedetail.FieldType:
  29092. m.ResetType()
  29093. return nil
  29094. case usagedetail.FieldBotID:
  29095. m.ResetBotID()
  29096. return nil
  29097. case usagedetail.FieldReceiverID:
  29098. m.ResetReceiverID()
  29099. return nil
  29100. case usagedetail.FieldApp:
  29101. m.ResetApp()
  29102. return nil
  29103. case usagedetail.FieldSessionID:
  29104. m.ResetSessionID()
  29105. return nil
  29106. case usagedetail.FieldRequest:
  29107. m.ResetRequest()
  29108. return nil
  29109. case usagedetail.FieldResponse:
  29110. m.ResetResponse()
  29111. return nil
  29112. case usagedetail.FieldOriginalData:
  29113. m.ResetOriginalData()
  29114. return nil
  29115. case usagedetail.FieldTotalTokens:
  29116. m.ResetTotalTokens()
  29117. return nil
  29118. case usagedetail.FieldPromptTokens:
  29119. m.ResetPromptTokens()
  29120. return nil
  29121. case usagedetail.FieldCompletionTokens:
  29122. m.ResetCompletionTokens()
  29123. return nil
  29124. case usagedetail.FieldOrganizationID:
  29125. m.ResetOrganizationID()
  29126. return nil
  29127. }
  29128. return fmt.Errorf("unknown UsageDetail field %s", name)
  29129. }
  29130. // AddedEdges returns all edge names that were set/added in this mutation.
  29131. func (m *UsageDetailMutation) AddedEdges() []string {
  29132. edges := make([]string, 0, 0)
  29133. return edges
  29134. }
  29135. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  29136. // name in this mutation.
  29137. func (m *UsageDetailMutation) AddedIDs(name string) []ent.Value {
  29138. return nil
  29139. }
  29140. // RemovedEdges returns all edge names that were removed in this mutation.
  29141. func (m *UsageDetailMutation) RemovedEdges() []string {
  29142. edges := make([]string, 0, 0)
  29143. return edges
  29144. }
  29145. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  29146. // the given name in this mutation.
  29147. func (m *UsageDetailMutation) RemovedIDs(name string) []ent.Value {
  29148. return nil
  29149. }
  29150. // ClearedEdges returns all edge names that were cleared in this mutation.
  29151. func (m *UsageDetailMutation) ClearedEdges() []string {
  29152. edges := make([]string, 0, 0)
  29153. return edges
  29154. }
  29155. // EdgeCleared returns a boolean which indicates if the edge with the given name
  29156. // was cleared in this mutation.
  29157. func (m *UsageDetailMutation) EdgeCleared(name string) bool {
  29158. return false
  29159. }
  29160. // ClearEdge clears the value of the edge with the given name. It returns an error
  29161. // if that edge is not defined in the schema.
  29162. func (m *UsageDetailMutation) ClearEdge(name string) error {
  29163. return fmt.Errorf("unknown UsageDetail unique edge %s", name)
  29164. }
  29165. // ResetEdge resets all changes to the edge with the given name in this mutation.
  29166. // It returns an error if the edge is not defined in the schema.
  29167. func (m *UsageDetailMutation) ResetEdge(name string) error {
  29168. return fmt.Errorf("unknown UsageDetail edge %s", name)
  29169. }
  29170. // UsageStatisticDayMutation represents an operation that mutates the UsageStatisticDay nodes in the graph.
  29171. type UsageStatisticDayMutation struct {
  29172. config
  29173. op Op
  29174. typ string
  29175. id *uint64
  29176. created_at *time.Time
  29177. updated_at *time.Time
  29178. status *uint8
  29179. addstatus *int8
  29180. deleted_at *time.Time
  29181. addtime *uint64
  29182. addaddtime *int64
  29183. _type *int
  29184. add_type *int
  29185. bot_id *string
  29186. organization_id *uint64
  29187. addorganization_id *int64
  29188. ai_response *uint64
  29189. addai_response *int64
  29190. sop_run *uint64
  29191. addsop_run *int64
  29192. total_friend *uint64
  29193. addtotal_friend *int64
  29194. total_group *uint64
  29195. addtotal_group *int64
  29196. account_balance *uint64
  29197. addaccount_balance *int64
  29198. consume_token *uint64
  29199. addconsume_token *int64
  29200. active_user *uint64
  29201. addactive_user *int64
  29202. new_user *int64
  29203. addnew_user *int64
  29204. label_dist *[]custom_types.LabelDist
  29205. appendlabel_dist []custom_types.LabelDist
  29206. clearedFields map[string]struct{}
  29207. done bool
  29208. oldValue func(context.Context) (*UsageStatisticDay, error)
  29209. predicates []predicate.UsageStatisticDay
  29210. }
  29211. var _ ent.Mutation = (*UsageStatisticDayMutation)(nil)
  29212. // usagestatisticdayOption allows management of the mutation configuration using functional options.
  29213. type usagestatisticdayOption func(*UsageStatisticDayMutation)
  29214. // newUsageStatisticDayMutation creates new mutation for the UsageStatisticDay entity.
  29215. func newUsageStatisticDayMutation(c config, op Op, opts ...usagestatisticdayOption) *UsageStatisticDayMutation {
  29216. m := &UsageStatisticDayMutation{
  29217. config: c,
  29218. op: op,
  29219. typ: TypeUsageStatisticDay,
  29220. clearedFields: make(map[string]struct{}),
  29221. }
  29222. for _, opt := range opts {
  29223. opt(m)
  29224. }
  29225. return m
  29226. }
  29227. // withUsageStatisticDayID sets the ID field of the mutation.
  29228. func withUsageStatisticDayID(id uint64) usagestatisticdayOption {
  29229. return func(m *UsageStatisticDayMutation) {
  29230. var (
  29231. err error
  29232. once sync.Once
  29233. value *UsageStatisticDay
  29234. )
  29235. m.oldValue = func(ctx context.Context) (*UsageStatisticDay, error) {
  29236. once.Do(func() {
  29237. if m.done {
  29238. err = errors.New("querying old values post mutation is not allowed")
  29239. } else {
  29240. value, err = m.Client().UsageStatisticDay.Get(ctx, id)
  29241. }
  29242. })
  29243. return value, err
  29244. }
  29245. m.id = &id
  29246. }
  29247. }
  29248. // withUsageStatisticDay sets the old UsageStatisticDay of the mutation.
  29249. func withUsageStatisticDay(node *UsageStatisticDay) usagestatisticdayOption {
  29250. return func(m *UsageStatisticDayMutation) {
  29251. m.oldValue = func(context.Context) (*UsageStatisticDay, error) {
  29252. return node, nil
  29253. }
  29254. m.id = &node.ID
  29255. }
  29256. }
  29257. // Client returns a new `ent.Client` from the mutation. If the mutation was
  29258. // executed in a transaction (ent.Tx), a transactional client is returned.
  29259. func (m UsageStatisticDayMutation) Client() *Client {
  29260. client := &Client{config: m.config}
  29261. client.init()
  29262. return client
  29263. }
  29264. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  29265. // it returns an error otherwise.
  29266. func (m UsageStatisticDayMutation) Tx() (*Tx, error) {
  29267. if _, ok := m.driver.(*txDriver); !ok {
  29268. return nil, errors.New("ent: mutation is not running in a transaction")
  29269. }
  29270. tx := &Tx{config: m.config}
  29271. tx.init()
  29272. return tx, nil
  29273. }
  29274. // SetID sets the value of the id field. Note that this
  29275. // operation is only accepted on creation of UsageStatisticDay entities.
  29276. func (m *UsageStatisticDayMutation) SetID(id uint64) {
  29277. m.id = &id
  29278. }
  29279. // ID returns the ID value in the mutation. Note that the ID is only available
  29280. // if it was provided to the builder or after it was returned from the database.
  29281. func (m *UsageStatisticDayMutation) ID() (id uint64, exists bool) {
  29282. if m.id == nil {
  29283. return
  29284. }
  29285. return *m.id, true
  29286. }
  29287. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  29288. // That means, if the mutation is applied within a transaction with an isolation level such
  29289. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  29290. // or updated by the mutation.
  29291. func (m *UsageStatisticDayMutation) IDs(ctx context.Context) ([]uint64, error) {
  29292. switch {
  29293. case m.op.Is(OpUpdateOne | OpDeleteOne):
  29294. id, exists := m.ID()
  29295. if exists {
  29296. return []uint64{id}, nil
  29297. }
  29298. fallthrough
  29299. case m.op.Is(OpUpdate | OpDelete):
  29300. return m.Client().UsageStatisticDay.Query().Where(m.predicates...).IDs(ctx)
  29301. default:
  29302. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  29303. }
  29304. }
  29305. // SetCreatedAt sets the "created_at" field.
  29306. func (m *UsageStatisticDayMutation) SetCreatedAt(t time.Time) {
  29307. m.created_at = &t
  29308. }
  29309. // CreatedAt returns the value of the "created_at" field in the mutation.
  29310. func (m *UsageStatisticDayMutation) CreatedAt() (r time.Time, exists bool) {
  29311. v := m.created_at
  29312. if v == nil {
  29313. return
  29314. }
  29315. return *v, true
  29316. }
  29317. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticDay entity.
  29318. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  29319. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29320. func (m *UsageStatisticDayMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  29321. if !m.op.Is(OpUpdateOne) {
  29322. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  29323. }
  29324. if m.id == nil || m.oldValue == nil {
  29325. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  29326. }
  29327. oldValue, err := m.oldValue(ctx)
  29328. if err != nil {
  29329. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  29330. }
  29331. return oldValue.CreatedAt, nil
  29332. }
  29333. // ResetCreatedAt resets all changes to the "created_at" field.
  29334. func (m *UsageStatisticDayMutation) ResetCreatedAt() {
  29335. m.created_at = nil
  29336. }
  29337. // SetUpdatedAt sets the "updated_at" field.
  29338. func (m *UsageStatisticDayMutation) SetUpdatedAt(t time.Time) {
  29339. m.updated_at = &t
  29340. }
  29341. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  29342. func (m *UsageStatisticDayMutation) UpdatedAt() (r time.Time, exists bool) {
  29343. v := m.updated_at
  29344. if v == nil {
  29345. return
  29346. }
  29347. return *v, true
  29348. }
  29349. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticDay entity.
  29350. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  29351. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29352. func (m *UsageStatisticDayMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  29353. if !m.op.Is(OpUpdateOne) {
  29354. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  29355. }
  29356. if m.id == nil || m.oldValue == nil {
  29357. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  29358. }
  29359. oldValue, err := m.oldValue(ctx)
  29360. if err != nil {
  29361. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  29362. }
  29363. return oldValue.UpdatedAt, nil
  29364. }
  29365. // ResetUpdatedAt resets all changes to the "updated_at" field.
  29366. func (m *UsageStatisticDayMutation) ResetUpdatedAt() {
  29367. m.updated_at = nil
  29368. }
  29369. // SetStatus sets the "status" field.
  29370. func (m *UsageStatisticDayMutation) SetStatus(u uint8) {
  29371. m.status = &u
  29372. m.addstatus = nil
  29373. }
  29374. // Status returns the value of the "status" field in the mutation.
  29375. func (m *UsageStatisticDayMutation) Status() (r uint8, exists bool) {
  29376. v := m.status
  29377. if v == nil {
  29378. return
  29379. }
  29380. return *v, true
  29381. }
  29382. // OldStatus returns the old "status" field's value of the UsageStatisticDay entity.
  29383. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  29384. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29385. func (m *UsageStatisticDayMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  29386. if !m.op.Is(OpUpdateOne) {
  29387. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  29388. }
  29389. if m.id == nil || m.oldValue == nil {
  29390. return v, errors.New("OldStatus requires an ID field in the mutation")
  29391. }
  29392. oldValue, err := m.oldValue(ctx)
  29393. if err != nil {
  29394. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  29395. }
  29396. return oldValue.Status, nil
  29397. }
  29398. // AddStatus adds u to the "status" field.
  29399. func (m *UsageStatisticDayMutation) AddStatus(u int8) {
  29400. if m.addstatus != nil {
  29401. *m.addstatus += u
  29402. } else {
  29403. m.addstatus = &u
  29404. }
  29405. }
  29406. // AddedStatus returns the value that was added to the "status" field in this mutation.
  29407. func (m *UsageStatisticDayMutation) AddedStatus() (r int8, exists bool) {
  29408. v := m.addstatus
  29409. if v == nil {
  29410. return
  29411. }
  29412. return *v, true
  29413. }
  29414. // ClearStatus clears the value of the "status" field.
  29415. func (m *UsageStatisticDayMutation) ClearStatus() {
  29416. m.status = nil
  29417. m.addstatus = nil
  29418. m.clearedFields[usagestatisticday.FieldStatus] = struct{}{}
  29419. }
  29420. // StatusCleared returns if the "status" field was cleared in this mutation.
  29421. func (m *UsageStatisticDayMutation) StatusCleared() bool {
  29422. _, ok := m.clearedFields[usagestatisticday.FieldStatus]
  29423. return ok
  29424. }
  29425. // ResetStatus resets all changes to the "status" field.
  29426. func (m *UsageStatisticDayMutation) ResetStatus() {
  29427. m.status = nil
  29428. m.addstatus = nil
  29429. delete(m.clearedFields, usagestatisticday.FieldStatus)
  29430. }
  29431. // SetDeletedAt sets the "deleted_at" field.
  29432. func (m *UsageStatisticDayMutation) SetDeletedAt(t time.Time) {
  29433. m.deleted_at = &t
  29434. }
  29435. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  29436. func (m *UsageStatisticDayMutation) DeletedAt() (r time.Time, exists bool) {
  29437. v := m.deleted_at
  29438. if v == nil {
  29439. return
  29440. }
  29441. return *v, true
  29442. }
  29443. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticDay entity.
  29444. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  29445. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29446. func (m *UsageStatisticDayMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  29447. if !m.op.Is(OpUpdateOne) {
  29448. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  29449. }
  29450. if m.id == nil || m.oldValue == nil {
  29451. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  29452. }
  29453. oldValue, err := m.oldValue(ctx)
  29454. if err != nil {
  29455. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  29456. }
  29457. return oldValue.DeletedAt, nil
  29458. }
  29459. // ClearDeletedAt clears the value of the "deleted_at" field.
  29460. func (m *UsageStatisticDayMutation) ClearDeletedAt() {
  29461. m.deleted_at = nil
  29462. m.clearedFields[usagestatisticday.FieldDeletedAt] = struct{}{}
  29463. }
  29464. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  29465. func (m *UsageStatisticDayMutation) DeletedAtCleared() bool {
  29466. _, ok := m.clearedFields[usagestatisticday.FieldDeletedAt]
  29467. return ok
  29468. }
  29469. // ResetDeletedAt resets all changes to the "deleted_at" field.
  29470. func (m *UsageStatisticDayMutation) ResetDeletedAt() {
  29471. m.deleted_at = nil
  29472. delete(m.clearedFields, usagestatisticday.FieldDeletedAt)
  29473. }
  29474. // SetAddtime sets the "addtime" field.
  29475. func (m *UsageStatisticDayMutation) SetAddtime(u uint64) {
  29476. m.addtime = &u
  29477. m.addaddtime = nil
  29478. }
  29479. // Addtime returns the value of the "addtime" field in the mutation.
  29480. func (m *UsageStatisticDayMutation) Addtime() (r uint64, exists bool) {
  29481. v := m.addtime
  29482. if v == nil {
  29483. return
  29484. }
  29485. return *v, true
  29486. }
  29487. // OldAddtime returns the old "addtime" field's value of the UsageStatisticDay entity.
  29488. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  29489. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29490. func (m *UsageStatisticDayMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  29491. if !m.op.Is(OpUpdateOne) {
  29492. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  29493. }
  29494. if m.id == nil || m.oldValue == nil {
  29495. return v, errors.New("OldAddtime requires an ID field in the mutation")
  29496. }
  29497. oldValue, err := m.oldValue(ctx)
  29498. if err != nil {
  29499. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  29500. }
  29501. return oldValue.Addtime, nil
  29502. }
  29503. // AddAddtime adds u to the "addtime" field.
  29504. func (m *UsageStatisticDayMutation) AddAddtime(u int64) {
  29505. if m.addaddtime != nil {
  29506. *m.addaddtime += u
  29507. } else {
  29508. m.addaddtime = &u
  29509. }
  29510. }
  29511. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  29512. func (m *UsageStatisticDayMutation) AddedAddtime() (r int64, exists bool) {
  29513. v := m.addaddtime
  29514. if v == nil {
  29515. return
  29516. }
  29517. return *v, true
  29518. }
  29519. // ResetAddtime resets all changes to the "addtime" field.
  29520. func (m *UsageStatisticDayMutation) ResetAddtime() {
  29521. m.addtime = nil
  29522. m.addaddtime = nil
  29523. }
  29524. // SetType sets the "type" field.
  29525. func (m *UsageStatisticDayMutation) SetType(i int) {
  29526. m._type = &i
  29527. m.add_type = nil
  29528. }
  29529. // GetType returns the value of the "type" field in the mutation.
  29530. func (m *UsageStatisticDayMutation) GetType() (r int, exists bool) {
  29531. v := m._type
  29532. if v == nil {
  29533. return
  29534. }
  29535. return *v, true
  29536. }
  29537. // OldType returns the old "type" field's value of the UsageStatisticDay entity.
  29538. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  29539. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29540. func (m *UsageStatisticDayMutation) OldType(ctx context.Context) (v int, err error) {
  29541. if !m.op.Is(OpUpdateOne) {
  29542. return v, errors.New("OldType is only allowed on UpdateOne operations")
  29543. }
  29544. if m.id == nil || m.oldValue == nil {
  29545. return v, errors.New("OldType requires an ID field in the mutation")
  29546. }
  29547. oldValue, err := m.oldValue(ctx)
  29548. if err != nil {
  29549. return v, fmt.Errorf("querying old value for OldType: %w", err)
  29550. }
  29551. return oldValue.Type, nil
  29552. }
  29553. // AddType adds i to the "type" field.
  29554. func (m *UsageStatisticDayMutation) AddType(i int) {
  29555. if m.add_type != nil {
  29556. *m.add_type += i
  29557. } else {
  29558. m.add_type = &i
  29559. }
  29560. }
  29561. // AddedType returns the value that was added to the "type" field in this mutation.
  29562. func (m *UsageStatisticDayMutation) AddedType() (r int, exists bool) {
  29563. v := m.add_type
  29564. if v == nil {
  29565. return
  29566. }
  29567. return *v, true
  29568. }
  29569. // ResetType resets all changes to the "type" field.
  29570. func (m *UsageStatisticDayMutation) ResetType() {
  29571. m._type = nil
  29572. m.add_type = nil
  29573. }
  29574. // SetBotID sets the "bot_id" field.
  29575. func (m *UsageStatisticDayMutation) SetBotID(s string) {
  29576. m.bot_id = &s
  29577. }
  29578. // BotID returns the value of the "bot_id" field in the mutation.
  29579. func (m *UsageStatisticDayMutation) BotID() (r string, exists bool) {
  29580. v := m.bot_id
  29581. if v == nil {
  29582. return
  29583. }
  29584. return *v, true
  29585. }
  29586. // OldBotID returns the old "bot_id" field's value of the UsageStatisticDay entity.
  29587. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  29588. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29589. func (m *UsageStatisticDayMutation) OldBotID(ctx context.Context) (v string, err error) {
  29590. if !m.op.Is(OpUpdateOne) {
  29591. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  29592. }
  29593. if m.id == nil || m.oldValue == nil {
  29594. return v, errors.New("OldBotID requires an ID field in the mutation")
  29595. }
  29596. oldValue, err := m.oldValue(ctx)
  29597. if err != nil {
  29598. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  29599. }
  29600. return oldValue.BotID, nil
  29601. }
  29602. // ClearBotID clears the value of the "bot_id" field.
  29603. func (m *UsageStatisticDayMutation) ClearBotID() {
  29604. m.bot_id = nil
  29605. m.clearedFields[usagestatisticday.FieldBotID] = struct{}{}
  29606. }
  29607. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  29608. func (m *UsageStatisticDayMutation) BotIDCleared() bool {
  29609. _, ok := m.clearedFields[usagestatisticday.FieldBotID]
  29610. return ok
  29611. }
  29612. // ResetBotID resets all changes to the "bot_id" field.
  29613. func (m *UsageStatisticDayMutation) ResetBotID() {
  29614. m.bot_id = nil
  29615. delete(m.clearedFields, usagestatisticday.FieldBotID)
  29616. }
  29617. // SetOrganizationID sets the "organization_id" field.
  29618. func (m *UsageStatisticDayMutation) SetOrganizationID(u uint64) {
  29619. m.organization_id = &u
  29620. m.addorganization_id = nil
  29621. }
  29622. // OrganizationID returns the value of the "organization_id" field in the mutation.
  29623. func (m *UsageStatisticDayMutation) OrganizationID() (r uint64, exists bool) {
  29624. v := m.organization_id
  29625. if v == nil {
  29626. return
  29627. }
  29628. return *v, true
  29629. }
  29630. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticDay entity.
  29631. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  29632. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29633. func (m *UsageStatisticDayMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  29634. if !m.op.Is(OpUpdateOne) {
  29635. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  29636. }
  29637. if m.id == nil || m.oldValue == nil {
  29638. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  29639. }
  29640. oldValue, err := m.oldValue(ctx)
  29641. if err != nil {
  29642. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  29643. }
  29644. return oldValue.OrganizationID, nil
  29645. }
  29646. // AddOrganizationID adds u to the "organization_id" field.
  29647. func (m *UsageStatisticDayMutation) AddOrganizationID(u int64) {
  29648. if m.addorganization_id != nil {
  29649. *m.addorganization_id += u
  29650. } else {
  29651. m.addorganization_id = &u
  29652. }
  29653. }
  29654. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  29655. func (m *UsageStatisticDayMutation) AddedOrganizationID() (r int64, exists bool) {
  29656. v := m.addorganization_id
  29657. if v == nil {
  29658. return
  29659. }
  29660. return *v, true
  29661. }
  29662. // ClearOrganizationID clears the value of the "organization_id" field.
  29663. func (m *UsageStatisticDayMutation) ClearOrganizationID() {
  29664. m.organization_id = nil
  29665. m.addorganization_id = nil
  29666. m.clearedFields[usagestatisticday.FieldOrganizationID] = struct{}{}
  29667. }
  29668. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  29669. func (m *UsageStatisticDayMutation) OrganizationIDCleared() bool {
  29670. _, ok := m.clearedFields[usagestatisticday.FieldOrganizationID]
  29671. return ok
  29672. }
  29673. // ResetOrganizationID resets all changes to the "organization_id" field.
  29674. func (m *UsageStatisticDayMutation) ResetOrganizationID() {
  29675. m.organization_id = nil
  29676. m.addorganization_id = nil
  29677. delete(m.clearedFields, usagestatisticday.FieldOrganizationID)
  29678. }
  29679. // SetAiResponse sets the "ai_response" field.
  29680. func (m *UsageStatisticDayMutation) SetAiResponse(u uint64) {
  29681. m.ai_response = &u
  29682. m.addai_response = nil
  29683. }
  29684. // AiResponse returns the value of the "ai_response" field in the mutation.
  29685. func (m *UsageStatisticDayMutation) AiResponse() (r uint64, exists bool) {
  29686. v := m.ai_response
  29687. if v == nil {
  29688. return
  29689. }
  29690. return *v, true
  29691. }
  29692. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticDay entity.
  29693. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  29694. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29695. func (m *UsageStatisticDayMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  29696. if !m.op.Is(OpUpdateOne) {
  29697. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  29698. }
  29699. if m.id == nil || m.oldValue == nil {
  29700. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  29701. }
  29702. oldValue, err := m.oldValue(ctx)
  29703. if err != nil {
  29704. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  29705. }
  29706. return oldValue.AiResponse, nil
  29707. }
  29708. // AddAiResponse adds u to the "ai_response" field.
  29709. func (m *UsageStatisticDayMutation) AddAiResponse(u int64) {
  29710. if m.addai_response != nil {
  29711. *m.addai_response += u
  29712. } else {
  29713. m.addai_response = &u
  29714. }
  29715. }
  29716. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  29717. func (m *UsageStatisticDayMutation) AddedAiResponse() (r int64, exists bool) {
  29718. v := m.addai_response
  29719. if v == nil {
  29720. return
  29721. }
  29722. return *v, true
  29723. }
  29724. // ResetAiResponse resets all changes to the "ai_response" field.
  29725. func (m *UsageStatisticDayMutation) ResetAiResponse() {
  29726. m.ai_response = nil
  29727. m.addai_response = nil
  29728. }
  29729. // SetSopRun sets the "sop_run" field.
  29730. func (m *UsageStatisticDayMutation) SetSopRun(u uint64) {
  29731. m.sop_run = &u
  29732. m.addsop_run = nil
  29733. }
  29734. // SopRun returns the value of the "sop_run" field in the mutation.
  29735. func (m *UsageStatisticDayMutation) SopRun() (r uint64, exists bool) {
  29736. v := m.sop_run
  29737. if v == nil {
  29738. return
  29739. }
  29740. return *v, true
  29741. }
  29742. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticDay entity.
  29743. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  29744. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29745. func (m *UsageStatisticDayMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  29746. if !m.op.Is(OpUpdateOne) {
  29747. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  29748. }
  29749. if m.id == nil || m.oldValue == nil {
  29750. return v, errors.New("OldSopRun requires an ID field in the mutation")
  29751. }
  29752. oldValue, err := m.oldValue(ctx)
  29753. if err != nil {
  29754. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  29755. }
  29756. return oldValue.SopRun, nil
  29757. }
  29758. // AddSopRun adds u to the "sop_run" field.
  29759. func (m *UsageStatisticDayMutation) AddSopRun(u int64) {
  29760. if m.addsop_run != nil {
  29761. *m.addsop_run += u
  29762. } else {
  29763. m.addsop_run = &u
  29764. }
  29765. }
  29766. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  29767. func (m *UsageStatisticDayMutation) AddedSopRun() (r int64, exists bool) {
  29768. v := m.addsop_run
  29769. if v == nil {
  29770. return
  29771. }
  29772. return *v, true
  29773. }
  29774. // ResetSopRun resets all changes to the "sop_run" field.
  29775. func (m *UsageStatisticDayMutation) ResetSopRun() {
  29776. m.sop_run = nil
  29777. m.addsop_run = nil
  29778. }
  29779. // SetTotalFriend sets the "total_friend" field.
  29780. func (m *UsageStatisticDayMutation) SetTotalFriend(u uint64) {
  29781. m.total_friend = &u
  29782. m.addtotal_friend = nil
  29783. }
  29784. // TotalFriend returns the value of the "total_friend" field in the mutation.
  29785. func (m *UsageStatisticDayMutation) TotalFriend() (r uint64, exists bool) {
  29786. v := m.total_friend
  29787. if v == nil {
  29788. return
  29789. }
  29790. return *v, true
  29791. }
  29792. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticDay entity.
  29793. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  29794. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29795. func (m *UsageStatisticDayMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  29796. if !m.op.Is(OpUpdateOne) {
  29797. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  29798. }
  29799. if m.id == nil || m.oldValue == nil {
  29800. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  29801. }
  29802. oldValue, err := m.oldValue(ctx)
  29803. if err != nil {
  29804. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  29805. }
  29806. return oldValue.TotalFriend, nil
  29807. }
  29808. // AddTotalFriend adds u to the "total_friend" field.
  29809. func (m *UsageStatisticDayMutation) AddTotalFriend(u int64) {
  29810. if m.addtotal_friend != nil {
  29811. *m.addtotal_friend += u
  29812. } else {
  29813. m.addtotal_friend = &u
  29814. }
  29815. }
  29816. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  29817. func (m *UsageStatisticDayMutation) AddedTotalFriend() (r int64, exists bool) {
  29818. v := m.addtotal_friend
  29819. if v == nil {
  29820. return
  29821. }
  29822. return *v, true
  29823. }
  29824. // ResetTotalFriend resets all changes to the "total_friend" field.
  29825. func (m *UsageStatisticDayMutation) ResetTotalFriend() {
  29826. m.total_friend = nil
  29827. m.addtotal_friend = nil
  29828. }
  29829. // SetTotalGroup sets the "total_group" field.
  29830. func (m *UsageStatisticDayMutation) SetTotalGroup(u uint64) {
  29831. m.total_group = &u
  29832. m.addtotal_group = nil
  29833. }
  29834. // TotalGroup returns the value of the "total_group" field in the mutation.
  29835. func (m *UsageStatisticDayMutation) TotalGroup() (r uint64, exists bool) {
  29836. v := m.total_group
  29837. if v == nil {
  29838. return
  29839. }
  29840. return *v, true
  29841. }
  29842. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticDay entity.
  29843. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  29844. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29845. func (m *UsageStatisticDayMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  29846. if !m.op.Is(OpUpdateOne) {
  29847. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  29848. }
  29849. if m.id == nil || m.oldValue == nil {
  29850. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  29851. }
  29852. oldValue, err := m.oldValue(ctx)
  29853. if err != nil {
  29854. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  29855. }
  29856. return oldValue.TotalGroup, nil
  29857. }
  29858. // AddTotalGroup adds u to the "total_group" field.
  29859. func (m *UsageStatisticDayMutation) AddTotalGroup(u int64) {
  29860. if m.addtotal_group != nil {
  29861. *m.addtotal_group += u
  29862. } else {
  29863. m.addtotal_group = &u
  29864. }
  29865. }
  29866. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  29867. func (m *UsageStatisticDayMutation) AddedTotalGroup() (r int64, exists bool) {
  29868. v := m.addtotal_group
  29869. if v == nil {
  29870. return
  29871. }
  29872. return *v, true
  29873. }
  29874. // ResetTotalGroup resets all changes to the "total_group" field.
  29875. func (m *UsageStatisticDayMutation) ResetTotalGroup() {
  29876. m.total_group = nil
  29877. m.addtotal_group = nil
  29878. }
  29879. // SetAccountBalance sets the "account_balance" field.
  29880. func (m *UsageStatisticDayMutation) SetAccountBalance(u uint64) {
  29881. m.account_balance = &u
  29882. m.addaccount_balance = nil
  29883. }
  29884. // AccountBalance returns the value of the "account_balance" field in the mutation.
  29885. func (m *UsageStatisticDayMutation) AccountBalance() (r uint64, exists bool) {
  29886. v := m.account_balance
  29887. if v == nil {
  29888. return
  29889. }
  29890. return *v, true
  29891. }
  29892. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticDay entity.
  29893. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  29894. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29895. func (m *UsageStatisticDayMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  29896. if !m.op.Is(OpUpdateOne) {
  29897. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  29898. }
  29899. if m.id == nil || m.oldValue == nil {
  29900. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  29901. }
  29902. oldValue, err := m.oldValue(ctx)
  29903. if err != nil {
  29904. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  29905. }
  29906. return oldValue.AccountBalance, nil
  29907. }
  29908. // AddAccountBalance adds u to the "account_balance" field.
  29909. func (m *UsageStatisticDayMutation) AddAccountBalance(u int64) {
  29910. if m.addaccount_balance != nil {
  29911. *m.addaccount_balance += u
  29912. } else {
  29913. m.addaccount_balance = &u
  29914. }
  29915. }
  29916. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  29917. func (m *UsageStatisticDayMutation) AddedAccountBalance() (r int64, exists bool) {
  29918. v := m.addaccount_balance
  29919. if v == nil {
  29920. return
  29921. }
  29922. return *v, true
  29923. }
  29924. // ResetAccountBalance resets all changes to the "account_balance" field.
  29925. func (m *UsageStatisticDayMutation) ResetAccountBalance() {
  29926. m.account_balance = nil
  29927. m.addaccount_balance = nil
  29928. }
  29929. // SetConsumeToken sets the "consume_token" field.
  29930. func (m *UsageStatisticDayMutation) SetConsumeToken(u uint64) {
  29931. m.consume_token = &u
  29932. m.addconsume_token = nil
  29933. }
  29934. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  29935. func (m *UsageStatisticDayMutation) ConsumeToken() (r uint64, exists bool) {
  29936. v := m.consume_token
  29937. if v == nil {
  29938. return
  29939. }
  29940. return *v, true
  29941. }
  29942. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticDay entity.
  29943. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  29944. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29945. func (m *UsageStatisticDayMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  29946. if !m.op.Is(OpUpdateOne) {
  29947. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  29948. }
  29949. if m.id == nil || m.oldValue == nil {
  29950. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  29951. }
  29952. oldValue, err := m.oldValue(ctx)
  29953. if err != nil {
  29954. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  29955. }
  29956. return oldValue.ConsumeToken, nil
  29957. }
  29958. // AddConsumeToken adds u to the "consume_token" field.
  29959. func (m *UsageStatisticDayMutation) AddConsumeToken(u int64) {
  29960. if m.addconsume_token != nil {
  29961. *m.addconsume_token += u
  29962. } else {
  29963. m.addconsume_token = &u
  29964. }
  29965. }
  29966. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  29967. func (m *UsageStatisticDayMutation) AddedConsumeToken() (r int64, exists bool) {
  29968. v := m.addconsume_token
  29969. if v == nil {
  29970. return
  29971. }
  29972. return *v, true
  29973. }
  29974. // ResetConsumeToken resets all changes to the "consume_token" field.
  29975. func (m *UsageStatisticDayMutation) ResetConsumeToken() {
  29976. m.consume_token = nil
  29977. m.addconsume_token = nil
  29978. }
  29979. // SetActiveUser sets the "active_user" field.
  29980. func (m *UsageStatisticDayMutation) SetActiveUser(u uint64) {
  29981. m.active_user = &u
  29982. m.addactive_user = nil
  29983. }
  29984. // ActiveUser returns the value of the "active_user" field in the mutation.
  29985. func (m *UsageStatisticDayMutation) ActiveUser() (r uint64, exists bool) {
  29986. v := m.active_user
  29987. if v == nil {
  29988. return
  29989. }
  29990. return *v, true
  29991. }
  29992. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticDay entity.
  29993. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  29994. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29995. func (m *UsageStatisticDayMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  29996. if !m.op.Is(OpUpdateOne) {
  29997. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  29998. }
  29999. if m.id == nil || m.oldValue == nil {
  30000. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  30001. }
  30002. oldValue, err := m.oldValue(ctx)
  30003. if err != nil {
  30004. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  30005. }
  30006. return oldValue.ActiveUser, nil
  30007. }
  30008. // AddActiveUser adds u to the "active_user" field.
  30009. func (m *UsageStatisticDayMutation) AddActiveUser(u int64) {
  30010. if m.addactive_user != nil {
  30011. *m.addactive_user += u
  30012. } else {
  30013. m.addactive_user = &u
  30014. }
  30015. }
  30016. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  30017. func (m *UsageStatisticDayMutation) AddedActiveUser() (r int64, exists bool) {
  30018. v := m.addactive_user
  30019. if v == nil {
  30020. return
  30021. }
  30022. return *v, true
  30023. }
  30024. // ResetActiveUser resets all changes to the "active_user" field.
  30025. func (m *UsageStatisticDayMutation) ResetActiveUser() {
  30026. m.active_user = nil
  30027. m.addactive_user = nil
  30028. }
  30029. // SetNewUser sets the "new_user" field.
  30030. func (m *UsageStatisticDayMutation) SetNewUser(i int64) {
  30031. m.new_user = &i
  30032. m.addnew_user = nil
  30033. }
  30034. // NewUser returns the value of the "new_user" field in the mutation.
  30035. func (m *UsageStatisticDayMutation) NewUser() (r int64, exists bool) {
  30036. v := m.new_user
  30037. if v == nil {
  30038. return
  30039. }
  30040. return *v, true
  30041. }
  30042. // OldNewUser returns the old "new_user" field's value of the UsageStatisticDay entity.
  30043. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  30044. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30045. func (m *UsageStatisticDayMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  30046. if !m.op.Is(OpUpdateOne) {
  30047. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  30048. }
  30049. if m.id == nil || m.oldValue == nil {
  30050. return v, errors.New("OldNewUser requires an ID field in the mutation")
  30051. }
  30052. oldValue, err := m.oldValue(ctx)
  30053. if err != nil {
  30054. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  30055. }
  30056. return oldValue.NewUser, nil
  30057. }
  30058. // AddNewUser adds i to the "new_user" field.
  30059. func (m *UsageStatisticDayMutation) AddNewUser(i int64) {
  30060. if m.addnew_user != nil {
  30061. *m.addnew_user += i
  30062. } else {
  30063. m.addnew_user = &i
  30064. }
  30065. }
  30066. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  30067. func (m *UsageStatisticDayMutation) AddedNewUser() (r int64, exists bool) {
  30068. v := m.addnew_user
  30069. if v == nil {
  30070. return
  30071. }
  30072. return *v, true
  30073. }
  30074. // ResetNewUser resets all changes to the "new_user" field.
  30075. func (m *UsageStatisticDayMutation) ResetNewUser() {
  30076. m.new_user = nil
  30077. m.addnew_user = nil
  30078. }
  30079. // SetLabelDist sets the "label_dist" field.
  30080. func (m *UsageStatisticDayMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  30081. m.label_dist = &ctd
  30082. m.appendlabel_dist = nil
  30083. }
  30084. // LabelDist returns the value of the "label_dist" field in the mutation.
  30085. func (m *UsageStatisticDayMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  30086. v := m.label_dist
  30087. if v == nil {
  30088. return
  30089. }
  30090. return *v, true
  30091. }
  30092. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticDay entity.
  30093. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  30094. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30095. func (m *UsageStatisticDayMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  30096. if !m.op.Is(OpUpdateOne) {
  30097. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  30098. }
  30099. if m.id == nil || m.oldValue == nil {
  30100. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  30101. }
  30102. oldValue, err := m.oldValue(ctx)
  30103. if err != nil {
  30104. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  30105. }
  30106. return oldValue.LabelDist, nil
  30107. }
  30108. // AppendLabelDist adds ctd to the "label_dist" field.
  30109. func (m *UsageStatisticDayMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  30110. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  30111. }
  30112. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  30113. func (m *UsageStatisticDayMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  30114. if len(m.appendlabel_dist) == 0 {
  30115. return nil, false
  30116. }
  30117. return m.appendlabel_dist, true
  30118. }
  30119. // ResetLabelDist resets all changes to the "label_dist" field.
  30120. func (m *UsageStatisticDayMutation) ResetLabelDist() {
  30121. m.label_dist = nil
  30122. m.appendlabel_dist = nil
  30123. }
  30124. // Where appends a list predicates to the UsageStatisticDayMutation builder.
  30125. func (m *UsageStatisticDayMutation) Where(ps ...predicate.UsageStatisticDay) {
  30126. m.predicates = append(m.predicates, ps...)
  30127. }
  30128. // WhereP appends storage-level predicates to the UsageStatisticDayMutation builder. Using this method,
  30129. // users can use type-assertion to append predicates that do not depend on any generated package.
  30130. func (m *UsageStatisticDayMutation) WhereP(ps ...func(*sql.Selector)) {
  30131. p := make([]predicate.UsageStatisticDay, len(ps))
  30132. for i := range ps {
  30133. p[i] = ps[i]
  30134. }
  30135. m.Where(p...)
  30136. }
  30137. // Op returns the operation name.
  30138. func (m *UsageStatisticDayMutation) Op() Op {
  30139. return m.op
  30140. }
  30141. // SetOp allows setting the mutation operation.
  30142. func (m *UsageStatisticDayMutation) SetOp(op Op) {
  30143. m.op = op
  30144. }
  30145. // Type returns the node type of this mutation (UsageStatisticDay).
  30146. func (m *UsageStatisticDayMutation) Type() string {
  30147. return m.typ
  30148. }
  30149. // Fields returns all fields that were changed during this mutation. Note that in
  30150. // order to get all numeric fields that were incremented/decremented, call
  30151. // AddedFields().
  30152. func (m *UsageStatisticDayMutation) Fields() []string {
  30153. fields := make([]string, 0, 17)
  30154. if m.created_at != nil {
  30155. fields = append(fields, usagestatisticday.FieldCreatedAt)
  30156. }
  30157. if m.updated_at != nil {
  30158. fields = append(fields, usagestatisticday.FieldUpdatedAt)
  30159. }
  30160. if m.status != nil {
  30161. fields = append(fields, usagestatisticday.FieldStatus)
  30162. }
  30163. if m.deleted_at != nil {
  30164. fields = append(fields, usagestatisticday.FieldDeletedAt)
  30165. }
  30166. if m.addtime != nil {
  30167. fields = append(fields, usagestatisticday.FieldAddtime)
  30168. }
  30169. if m._type != nil {
  30170. fields = append(fields, usagestatisticday.FieldType)
  30171. }
  30172. if m.bot_id != nil {
  30173. fields = append(fields, usagestatisticday.FieldBotID)
  30174. }
  30175. if m.organization_id != nil {
  30176. fields = append(fields, usagestatisticday.FieldOrganizationID)
  30177. }
  30178. if m.ai_response != nil {
  30179. fields = append(fields, usagestatisticday.FieldAiResponse)
  30180. }
  30181. if m.sop_run != nil {
  30182. fields = append(fields, usagestatisticday.FieldSopRun)
  30183. }
  30184. if m.total_friend != nil {
  30185. fields = append(fields, usagestatisticday.FieldTotalFriend)
  30186. }
  30187. if m.total_group != nil {
  30188. fields = append(fields, usagestatisticday.FieldTotalGroup)
  30189. }
  30190. if m.account_balance != nil {
  30191. fields = append(fields, usagestatisticday.FieldAccountBalance)
  30192. }
  30193. if m.consume_token != nil {
  30194. fields = append(fields, usagestatisticday.FieldConsumeToken)
  30195. }
  30196. if m.active_user != nil {
  30197. fields = append(fields, usagestatisticday.FieldActiveUser)
  30198. }
  30199. if m.new_user != nil {
  30200. fields = append(fields, usagestatisticday.FieldNewUser)
  30201. }
  30202. if m.label_dist != nil {
  30203. fields = append(fields, usagestatisticday.FieldLabelDist)
  30204. }
  30205. return fields
  30206. }
  30207. // Field returns the value of a field with the given name. The second boolean
  30208. // return value indicates that this field was not set, or was not defined in the
  30209. // schema.
  30210. func (m *UsageStatisticDayMutation) Field(name string) (ent.Value, bool) {
  30211. switch name {
  30212. case usagestatisticday.FieldCreatedAt:
  30213. return m.CreatedAt()
  30214. case usagestatisticday.FieldUpdatedAt:
  30215. return m.UpdatedAt()
  30216. case usagestatisticday.FieldStatus:
  30217. return m.Status()
  30218. case usagestatisticday.FieldDeletedAt:
  30219. return m.DeletedAt()
  30220. case usagestatisticday.FieldAddtime:
  30221. return m.Addtime()
  30222. case usagestatisticday.FieldType:
  30223. return m.GetType()
  30224. case usagestatisticday.FieldBotID:
  30225. return m.BotID()
  30226. case usagestatisticday.FieldOrganizationID:
  30227. return m.OrganizationID()
  30228. case usagestatisticday.FieldAiResponse:
  30229. return m.AiResponse()
  30230. case usagestatisticday.FieldSopRun:
  30231. return m.SopRun()
  30232. case usagestatisticday.FieldTotalFriend:
  30233. return m.TotalFriend()
  30234. case usagestatisticday.FieldTotalGroup:
  30235. return m.TotalGroup()
  30236. case usagestatisticday.FieldAccountBalance:
  30237. return m.AccountBalance()
  30238. case usagestatisticday.FieldConsumeToken:
  30239. return m.ConsumeToken()
  30240. case usagestatisticday.FieldActiveUser:
  30241. return m.ActiveUser()
  30242. case usagestatisticday.FieldNewUser:
  30243. return m.NewUser()
  30244. case usagestatisticday.FieldLabelDist:
  30245. return m.LabelDist()
  30246. }
  30247. return nil, false
  30248. }
  30249. // OldField returns the old value of the field from the database. An error is
  30250. // returned if the mutation operation is not UpdateOne, or the query to the
  30251. // database failed.
  30252. func (m *UsageStatisticDayMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  30253. switch name {
  30254. case usagestatisticday.FieldCreatedAt:
  30255. return m.OldCreatedAt(ctx)
  30256. case usagestatisticday.FieldUpdatedAt:
  30257. return m.OldUpdatedAt(ctx)
  30258. case usagestatisticday.FieldStatus:
  30259. return m.OldStatus(ctx)
  30260. case usagestatisticday.FieldDeletedAt:
  30261. return m.OldDeletedAt(ctx)
  30262. case usagestatisticday.FieldAddtime:
  30263. return m.OldAddtime(ctx)
  30264. case usagestatisticday.FieldType:
  30265. return m.OldType(ctx)
  30266. case usagestatisticday.FieldBotID:
  30267. return m.OldBotID(ctx)
  30268. case usagestatisticday.FieldOrganizationID:
  30269. return m.OldOrganizationID(ctx)
  30270. case usagestatisticday.FieldAiResponse:
  30271. return m.OldAiResponse(ctx)
  30272. case usagestatisticday.FieldSopRun:
  30273. return m.OldSopRun(ctx)
  30274. case usagestatisticday.FieldTotalFriend:
  30275. return m.OldTotalFriend(ctx)
  30276. case usagestatisticday.FieldTotalGroup:
  30277. return m.OldTotalGroup(ctx)
  30278. case usagestatisticday.FieldAccountBalance:
  30279. return m.OldAccountBalance(ctx)
  30280. case usagestatisticday.FieldConsumeToken:
  30281. return m.OldConsumeToken(ctx)
  30282. case usagestatisticday.FieldActiveUser:
  30283. return m.OldActiveUser(ctx)
  30284. case usagestatisticday.FieldNewUser:
  30285. return m.OldNewUser(ctx)
  30286. case usagestatisticday.FieldLabelDist:
  30287. return m.OldLabelDist(ctx)
  30288. }
  30289. return nil, fmt.Errorf("unknown UsageStatisticDay field %s", name)
  30290. }
  30291. // SetField sets the value of a 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) SetField(name string, value ent.Value) error {
  30295. switch name {
  30296. case usagestatisticday.FieldCreatedAt:
  30297. v, ok := value.(time.Time)
  30298. if !ok {
  30299. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30300. }
  30301. m.SetCreatedAt(v)
  30302. return nil
  30303. case usagestatisticday.FieldUpdatedAt:
  30304. v, ok := value.(time.Time)
  30305. if !ok {
  30306. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30307. }
  30308. m.SetUpdatedAt(v)
  30309. return nil
  30310. case usagestatisticday.FieldStatus:
  30311. v, ok := value.(uint8)
  30312. if !ok {
  30313. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30314. }
  30315. m.SetStatus(v)
  30316. return nil
  30317. case usagestatisticday.FieldDeletedAt:
  30318. v, ok := value.(time.Time)
  30319. if !ok {
  30320. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30321. }
  30322. m.SetDeletedAt(v)
  30323. return nil
  30324. case usagestatisticday.FieldAddtime:
  30325. v, ok := value.(uint64)
  30326. if !ok {
  30327. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30328. }
  30329. m.SetAddtime(v)
  30330. return nil
  30331. case usagestatisticday.FieldType:
  30332. v, ok := value.(int)
  30333. if !ok {
  30334. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30335. }
  30336. m.SetType(v)
  30337. return nil
  30338. case usagestatisticday.FieldBotID:
  30339. v, ok := value.(string)
  30340. if !ok {
  30341. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30342. }
  30343. m.SetBotID(v)
  30344. return nil
  30345. case usagestatisticday.FieldOrganizationID:
  30346. v, ok := value.(uint64)
  30347. if !ok {
  30348. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30349. }
  30350. m.SetOrganizationID(v)
  30351. return nil
  30352. case usagestatisticday.FieldAiResponse:
  30353. v, ok := value.(uint64)
  30354. if !ok {
  30355. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30356. }
  30357. m.SetAiResponse(v)
  30358. return nil
  30359. case usagestatisticday.FieldSopRun:
  30360. v, ok := value.(uint64)
  30361. if !ok {
  30362. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30363. }
  30364. m.SetSopRun(v)
  30365. return nil
  30366. case usagestatisticday.FieldTotalFriend:
  30367. v, ok := value.(uint64)
  30368. if !ok {
  30369. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30370. }
  30371. m.SetTotalFriend(v)
  30372. return nil
  30373. case usagestatisticday.FieldTotalGroup:
  30374. v, ok := value.(uint64)
  30375. if !ok {
  30376. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30377. }
  30378. m.SetTotalGroup(v)
  30379. return nil
  30380. case usagestatisticday.FieldAccountBalance:
  30381. v, ok := value.(uint64)
  30382. if !ok {
  30383. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30384. }
  30385. m.SetAccountBalance(v)
  30386. return nil
  30387. case usagestatisticday.FieldConsumeToken:
  30388. v, ok := value.(uint64)
  30389. if !ok {
  30390. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30391. }
  30392. m.SetConsumeToken(v)
  30393. return nil
  30394. case usagestatisticday.FieldActiveUser:
  30395. v, ok := value.(uint64)
  30396. if !ok {
  30397. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30398. }
  30399. m.SetActiveUser(v)
  30400. return nil
  30401. case usagestatisticday.FieldNewUser:
  30402. v, ok := value.(int64)
  30403. if !ok {
  30404. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30405. }
  30406. m.SetNewUser(v)
  30407. return nil
  30408. case usagestatisticday.FieldLabelDist:
  30409. v, ok := value.([]custom_types.LabelDist)
  30410. if !ok {
  30411. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30412. }
  30413. m.SetLabelDist(v)
  30414. return nil
  30415. }
  30416. return fmt.Errorf("unknown UsageStatisticDay field %s", name)
  30417. }
  30418. // AddedFields returns all numeric fields that were incremented/decremented during
  30419. // this mutation.
  30420. func (m *UsageStatisticDayMutation) AddedFields() []string {
  30421. var fields []string
  30422. if m.addstatus != nil {
  30423. fields = append(fields, usagestatisticday.FieldStatus)
  30424. }
  30425. if m.addaddtime != nil {
  30426. fields = append(fields, usagestatisticday.FieldAddtime)
  30427. }
  30428. if m.add_type != nil {
  30429. fields = append(fields, usagestatisticday.FieldType)
  30430. }
  30431. if m.addorganization_id != nil {
  30432. fields = append(fields, usagestatisticday.FieldOrganizationID)
  30433. }
  30434. if m.addai_response != nil {
  30435. fields = append(fields, usagestatisticday.FieldAiResponse)
  30436. }
  30437. if m.addsop_run != nil {
  30438. fields = append(fields, usagestatisticday.FieldSopRun)
  30439. }
  30440. if m.addtotal_friend != nil {
  30441. fields = append(fields, usagestatisticday.FieldTotalFriend)
  30442. }
  30443. if m.addtotal_group != nil {
  30444. fields = append(fields, usagestatisticday.FieldTotalGroup)
  30445. }
  30446. if m.addaccount_balance != nil {
  30447. fields = append(fields, usagestatisticday.FieldAccountBalance)
  30448. }
  30449. if m.addconsume_token != nil {
  30450. fields = append(fields, usagestatisticday.FieldConsumeToken)
  30451. }
  30452. if m.addactive_user != nil {
  30453. fields = append(fields, usagestatisticday.FieldActiveUser)
  30454. }
  30455. if m.addnew_user != nil {
  30456. fields = append(fields, usagestatisticday.FieldNewUser)
  30457. }
  30458. return fields
  30459. }
  30460. // AddedField returns the numeric value that was incremented/decremented on a field
  30461. // with the given name. The second boolean return value indicates that this field
  30462. // was not set, or was not defined in the schema.
  30463. func (m *UsageStatisticDayMutation) AddedField(name string) (ent.Value, bool) {
  30464. switch name {
  30465. case usagestatisticday.FieldStatus:
  30466. return m.AddedStatus()
  30467. case usagestatisticday.FieldAddtime:
  30468. return m.AddedAddtime()
  30469. case usagestatisticday.FieldType:
  30470. return m.AddedType()
  30471. case usagestatisticday.FieldOrganizationID:
  30472. return m.AddedOrganizationID()
  30473. case usagestatisticday.FieldAiResponse:
  30474. return m.AddedAiResponse()
  30475. case usagestatisticday.FieldSopRun:
  30476. return m.AddedSopRun()
  30477. case usagestatisticday.FieldTotalFriend:
  30478. return m.AddedTotalFriend()
  30479. case usagestatisticday.FieldTotalGroup:
  30480. return m.AddedTotalGroup()
  30481. case usagestatisticday.FieldAccountBalance:
  30482. return m.AddedAccountBalance()
  30483. case usagestatisticday.FieldConsumeToken:
  30484. return m.AddedConsumeToken()
  30485. case usagestatisticday.FieldActiveUser:
  30486. return m.AddedActiveUser()
  30487. case usagestatisticday.FieldNewUser:
  30488. return m.AddedNewUser()
  30489. }
  30490. return nil, false
  30491. }
  30492. // AddField adds the value to the field with the given name. It returns an error if
  30493. // the field is not defined in the schema, or if the type mismatched the field
  30494. // type.
  30495. func (m *UsageStatisticDayMutation) AddField(name string, value ent.Value) error {
  30496. switch name {
  30497. case usagestatisticday.FieldStatus:
  30498. v, ok := value.(int8)
  30499. if !ok {
  30500. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30501. }
  30502. m.AddStatus(v)
  30503. return nil
  30504. case usagestatisticday.FieldAddtime:
  30505. v, ok := value.(int64)
  30506. if !ok {
  30507. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30508. }
  30509. m.AddAddtime(v)
  30510. return nil
  30511. case usagestatisticday.FieldType:
  30512. v, ok := value.(int)
  30513. if !ok {
  30514. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30515. }
  30516. m.AddType(v)
  30517. return nil
  30518. case usagestatisticday.FieldOrganizationID:
  30519. v, ok := value.(int64)
  30520. if !ok {
  30521. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30522. }
  30523. m.AddOrganizationID(v)
  30524. return nil
  30525. case usagestatisticday.FieldAiResponse:
  30526. v, ok := value.(int64)
  30527. if !ok {
  30528. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30529. }
  30530. m.AddAiResponse(v)
  30531. return nil
  30532. case usagestatisticday.FieldSopRun:
  30533. v, ok := value.(int64)
  30534. if !ok {
  30535. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30536. }
  30537. m.AddSopRun(v)
  30538. return nil
  30539. case usagestatisticday.FieldTotalFriend:
  30540. v, ok := value.(int64)
  30541. if !ok {
  30542. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30543. }
  30544. m.AddTotalFriend(v)
  30545. return nil
  30546. case usagestatisticday.FieldTotalGroup:
  30547. v, ok := value.(int64)
  30548. if !ok {
  30549. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30550. }
  30551. m.AddTotalGroup(v)
  30552. return nil
  30553. case usagestatisticday.FieldAccountBalance:
  30554. v, ok := value.(int64)
  30555. if !ok {
  30556. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30557. }
  30558. m.AddAccountBalance(v)
  30559. return nil
  30560. case usagestatisticday.FieldConsumeToken:
  30561. v, ok := value.(int64)
  30562. if !ok {
  30563. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30564. }
  30565. m.AddConsumeToken(v)
  30566. return nil
  30567. case usagestatisticday.FieldActiveUser:
  30568. v, ok := value.(int64)
  30569. if !ok {
  30570. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30571. }
  30572. m.AddActiveUser(v)
  30573. return nil
  30574. case usagestatisticday.FieldNewUser:
  30575. v, ok := value.(int64)
  30576. if !ok {
  30577. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30578. }
  30579. m.AddNewUser(v)
  30580. return nil
  30581. }
  30582. return fmt.Errorf("unknown UsageStatisticDay numeric field %s", name)
  30583. }
  30584. // ClearedFields returns all nullable fields that were cleared during this
  30585. // mutation.
  30586. func (m *UsageStatisticDayMutation) ClearedFields() []string {
  30587. var fields []string
  30588. if m.FieldCleared(usagestatisticday.FieldStatus) {
  30589. fields = append(fields, usagestatisticday.FieldStatus)
  30590. }
  30591. if m.FieldCleared(usagestatisticday.FieldDeletedAt) {
  30592. fields = append(fields, usagestatisticday.FieldDeletedAt)
  30593. }
  30594. if m.FieldCleared(usagestatisticday.FieldBotID) {
  30595. fields = append(fields, usagestatisticday.FieldBotID)
  30596. }
  30597. if m.FieldCleared(usagestatisticday.FieldOrganizationID) {
  30598. fields = append(fields, usagestatisticday.FieldOrganizationID)
  30599. }
  30600. return fields
  30601. }
  30602. // FieldCleared returns a boolean indicating if a field with the given name was
  30603. // cleared in this mutation.
  30604. func (m *UsageStatisticDayMutation) FieldCleared(name string) bool {
  30605. _, ok := m.clearedFields[name]
  30606. return ok
  30607. }
  30608. // ClearField clears the value of the field with the given name. It returns an
  30609. // error if the field is not defined in the schema.
  30610. func (m *UsageStatisticDayMutation) ClearField(name string) error {
  30611. switch name {
  30612. case usagestatisticday.FieldStatus:
  30613. m.ClearStatus()
  30614. return nil
  30615. case usagestatisticday.FieldDeletedAt:
  30616. m.ClearDeletedAt()
  30617. return nil
  30618. case usagestatisticday.FieldBotID:
  30619. m.ClearBotID()
  30620. return nil
  30621. case usagestatisticday.FieldOrganizationID:
  30622. m.ClearOrganizationID()
  30623. return nil
  30624. }
  30625. return fmt.Errorf("unknown UsageStatisticDay nullable field %s", name)
  30626. }
  30627. // ResetField resets all changes in the mutation for the field with the given name.
  30628. // It returns an error if the field is not defined in the schema.
  30629. func (m *UsageStatisticDayMutation) ResetField(name string) error {
  30630. switch name {
  30631. case usagestatisticday.FieldCreatedAt:
  30632. m.ResetCreatedAt()
  30633. return nil
  30634. case usagestatisticday.FieldUpdatedAt:
  30635. m.ResetUpdatedAt()
  30636. return nil
  30637. case usagestatisticday.FieldStatus:
  30638. m.ResetStatus()
  30639. return nil
  30640. case usagestatisticday.FieldDeletedAt:
  30641. m.ResetDeletedAt()
  30642. return nil
  30643. case usagestatisticday.FieldAddtime:
  30644. m.ResetAddtime()
  30645. return nil
  30646. case usagestatisticday.FieldType:
  30647. m.ResetType()
  30648. return nil
  30649. case usagestatisticday.FieldBotID:
  30650. m.ResetBotID()
  30651. return nil
  30652. case usagestatisticday.FieldOrganizationID:
  30653. m.ResetOrganizationID()
  30654. return nil
  30655. case usagestatisticday.FieldAiResponse:
  30656. m.ResetAiResponse()
  30657. return nil
  30658. case usagestatisticday.FieldSopRun:
  30659. m.ResetSopRun()
  30660. return nil
  30661. case usagestatisticday.FieldTotalFriend:
  30662. m.ResetTotalFriend()
  30663. return nil
  30664. case usagestatisticday.FieldTotalGroup:
  30665. m.ResetTotalGroup()
  30666. return nil
  30667. case usagestatisticday.FieldAccountBalance:
  30668. m.ResetAccountBalance()
  30669. return nil
  30670. case usagestatisticday.FieldConsumeToken:
  30671. m.ResetConsumeToken()
  30672. return nil
  30673. case usagestatisticday.FieldActiveUser:
  30674. m.ResetActiveUser()
  30675. return nil
  30676. case usagestatisticday.FieldNewUser:
  30677. m.ResetNewUser()
  30678. return nil
  30679. case usagestatisticday.FieldLabelDist:
  30680. m.ResetLabelDist()
  30681. return nil
  30682. }
  30683. return fmt.Errorf("unknown UsageStatisticDay field %s", name)
  30684. }
  30685. // AddedEdges returns all edge names that were set/added in this mutation.
  30686. func (m *UsageStatisticDayMutation) AddedEdges() []string {
  30687. edges := make([]string, 0, 0)
  30688. return edges
  30689. }
  30690. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  30691. // name in this mutation.
  30692. func (m *UsageStatisticDayMutation) AddedIDs(name string) []ent.Value {
  30693. return nil
  30694. }
  30695. // RemovedEdges returns all edge names that were removed in this mutation.
  30696. func (m *UsageStatisticDayMutation) RemovedEdges() []string {
  30697. edges := make([]string, 0, 0)
  30698. return edges
  30699. }
  30700. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  30701. // the given name in this mutation.
  30702. func (m *UsageStatisticDayMutation) RemovedIDs(name string) []ent.Value {
  30703. return nil
  30704. }
  30705. // ClearedEdges returns all edge names that were cleared in this mutation.
  30706. func (m *UsageStatisticDayMutation) ClearedEdges() []string {
  30707. edges := make([]string, 0, 0)
  30708. return edges
  30709. }
  30710. // EdgeCleared returns a boolean which indicates if the edge with the given name
  30711. // was cleared in this mutation.
  30712. func (m *UsageStatisticDayMutation) EdgeCleared(name string) bool {
  30713. return false
  30714. }
  30715. // ClearEdge clears the value of the edge with the given name. It returns an error
  30716. // if that edge is not defined in the schema.
  30717. func (m *UsageStatisticDayMutation) ClearEdge(name string) error {
  30718. return fmt.Errorf("unknown UsageStatisticDay unique edge %s", name)
  30719. }
  30720. // ResetEdge resets all changes to the edge with the given name in this mutation.
  30721. // It returns an error if the edge is not defined in the schema.
  30722. func (m *UsageStatisticDayMutation) ResetEdge(name string) error {
  30723. return fmt.Errorf("unknown UsageStatisticDay edge %s", name)
  30724. }
  30725. // UsageStatisticHourMutation represents an operation that mutates the UsageStatisticHour nodes in the graph.
  30726. type UsageStatisticHourMutation struct {
  30727. config
  30728. op Op
  30729. typ string
  30730. id *uint64
  30731. created_at *time.Time
  30732. updated_at *time.Time
  30733. status *uint8
  30734. addstatus *int8
  30735. deleted_at *time.Time
  30736. addtime *uint64
  30737. addaddtime *int64
  30738. _type *int
  30739. add_type *int
  30740. bot_id *string
  30741. organization_id *uint64
  30742. addorganization_id *int64
  30743. ai_response *uint64
  30744. addai_response *int64
  30745. sop_run *uint64
  30746. addsop_run *int64
  30747. total_friend *uint64
  30748. addtotal_friend *int64
  30749. total_group *uint64
  30750. addtotal_group *int64
  30751. account_balance *uint64
  30752. addaccount_balance *int64
  30753. consume_token *uint64
  30754. addconsume_token *int64
  30755. active_user *uint64
  30756. addactive_user *int64
  30757. new_user *int64
  30758. addnew_user *int64
  30759. label_dist *[]custom_types.LabelDist
  30760. appendlabel_dist []custom_types.LabelDist
  30761. clearedFields map[string]struct{}
  30762. done bool
  30763. oldValue func(context.Context) (*UsageStatisticHour, error)
  30764. predicates []predicate.UsageStatisticHour
  30765. }
  30766. var _ ent.Mutation = (*UsageStatisticHourMutation)(nil)
  30767. // usagestatistichourOption allows management of the mutation configuration using functional options.
  30768. type usagestatistichourOption func(*UsageStatisticHourMutation)
  30769. // newUsageStatisticHourMutation creates new mutation for the UsageStatisticHour entity.
  30770. func newUsageStatisticHourMutation(c config, op Op, opts ...usagestatistichourOption) *UsageStatisticHourMutation {
  30771. m := &UsageStatisticHourMutation{
  30772. config: c,
  30773. op: op,
  30774. typ: TypeUsageStatisticHour,
  30775. clearedFields: make(map[string]struct{}),
  30776. }
  30777. for _, opt := range opts {
  30778. opt(m)
  30779. }
  30780. return m
  30781. }
  30782. // withUsageStatisticHourID sets the ID field of the mutation.
  30783. func withUsageStatisticHourID(id uint64) usagestatistichourOption {
  30784. return func(m *UsageStatisticHourMutation) {
  30785. var (
  30786. err error
  30787. once sync.Once
  30788. value *UsageStatisticHour
  30789. )
  30790. m.oldValue = func(ctx context.Context) (*UsageStatisticHour, error) {
  30791. once.Do(func() {
  30792. if m.done {
  30793. err = errors.New("querying old values post mutation is not allowed")
  30794. } else {
  30795. value, err = m.Client().UsageStatisticHour.Get(ctx, id)
  30796. }
  30797. })
  30798. return value, err
  30799. }
  30800. m.id = &id
  30801. }
  30802. }
  30803. // withUsageStatisticHour sets the old UsageStatisticHour of the mutation.
  30804. func withUsageStatisticHour(node *UsageStatisticHour) usagestatistichourOption {
  30805. return func(m *UsageStatisticHourMutation) {
  30806. m.oldValue = func(context.Context) (*UsageStatisticHour, error) {
  30807. return node, nil
  30808. }
  30809. m.id = &node.ID
  30810. }
  30811. }
  30812. // Client returns a new `ent.Client` from the mutation. If the mutation was
  30813. // executed in a transaction (ent.Tx), a transactional client is returned.
  30814. func (m UsageStatisticHourMutation) Client() *Client {
  30815. client := &Client{config: m.config}
  30816. client.init()
  30817. return client
  30818. }
  30819. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  30820. // it returns an error otherwise.
  30821. func (m UsageStatisticHourMutation) Tx() (*Tx, error) {
  30822. if _, ok := m.driver.(*txDriver); !ok {
  30823. return nil, errors.New("ent: mutation is not running in a transaction")
  30824. }
  30825. tx := &Tx{config: m.config}
  30826. tx.init()
  30827. return tx, nil
  30828. }
  30829. // SetID sets the value of the id field. Note that this
  30830. // operation is only accepted on creation of UsageStatisticHour entities.
  30831. func (m *UsageStatisticHourMutation) SetID(id uint64) {
  30832. m.id = &id
  30833. }
  30834. // ID returns the ID value in the mutation. Note that the ID is only available
  30835. // if it was provided to the builder or after it was returned from the database.
  30836. func (m *UsageStatisticHourMutation) ID() (id uint64, exists bool) {
  30837. if m.id == nil {
  30838. return
  30839. }
  30840. return *m.id, true
  30841. }
  30842. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  30843. // That means, if the mutation is applied within a transaction with an isolation level such
  30844. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  30845. // or updated by the mutation.
  30846. func (m *UsageStatisticHourMutation) IDs(ctx context.Context) ([]uint64, error) {
  30847. switch {
  30848. case m.op.Is(OpUpdateOne | OpDeleteOne):
  30849. id, exists := m.ID()
  30850. if exists {
  30851. return []uint64{id}, nil
  30852. }
  30853. fallthrough
  30854. case m.op.Is(OpUpdate | OpDelete):
  30855. return m.Client().UsageStatisticHour.Query().Where(m.predicates...).IDs(ctx)
  30856. default:
  30857. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  30858. }
  30859. }
  30860. // SetCreatedAt sets the "created_at" field.
  30861. func (m *UsageStatisticHourMutation) SetCreatedAt(t time.Time) {
  30862. m.created_at = &t
  30863. }
  30864. // CreatedAt returns the value of the "created_at" field in the mutation.
  30865. func (m *UsageStatisticHourMutation) CreatedAt() (r time.Time, exists bool) {
  30866. v := m.created_at
  30867. if v == nil {
  30868. return
  30869. }
  30870. return *v, true
  30871. }
  30872. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticHour entity.
  30873. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30874. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30875. func (m *UsageStatisticHourMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  30876. if !m.op.Is(OpUpdateOne) {
  30877. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  30878. }
  30879. if m.id == nil || m.oldValue == nil {
  30880. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  30881. }
  30882. oldValue, err := m.oldValue(ctx)
  30883. if err != nil {
  30884. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  30885. }
  30886. return oldValue.CreatedAt, nil
  30887. }
  30888. // ResetCreatedAt resets all changes to the "created_at" field.
  30889. func (m *UsageStatisticHourMutation) ResetCreatedAt() {
  30890. m.created_at = nil
  30891. }
  30892. // SetUpdatedAt sets the "updated_at" field.
  30893. func (m *UsageStatisticHourMutation) SetUpdatedAt(t time.Time) {
  30894. m.updated_at = &t
  30895. }
  30896. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  30897. func (m *UsageStatisticHourMutation) UpdatedAt() (r time.Time, exists bool) {
  30898. v := m.updated_at
  30899. if v == nil {
  30900. return
  30901. }
  30902. return *v, true
  30903. }
  30904. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticHour entity.
  30905. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30906. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30907. func (m *UsageStatisticHourMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  30908. if !m.op.Is(OpUpdateOne) {
  30909. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  30910. }
  30911. if m.id == nil || m.oldValue == nil {
  30912. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  30913. }
  30914. oldValue, err := m.oldValue(ctx)
  30915. if err != nil {
  30916. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  30917. }
  30918. return oldValue.UpdatedAt, nil
  30919. }
  30920. // ResetUpdatedAt resets all changes to the "updated_at" field.
  30921. func (m *UsageStatisticHourMutation) ResetUpdatedAt() {
  30922. m.updated_at = nil
  30923. }
  30924. // SetStatus sets the "status" field.
  30925. func (m *UsageStatisticHourMutation) SetStatus(u uint8) {
  30926. m.status = &u
  30927. m.addstatus = nil
  30928. }
  30929. // Status returns the value of the "status" field in the mutation.
  30930. func (m *UsageStatisticHourMutation) Status() (r uint8, exists bool) {
  30931. v := m.status
  30932. if v == nil {
  30933. return
  30934. }
  30935. return *v, true
  30936. }
  30937. // OldStatus returns the old "status" field's value of the UsageStatisticHour entity.
  30938. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30939. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30940. func (m *UsageStatisticHourMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  30941. if !m.op.Is(OpUpdateOne) {
  30942. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  30943. }
  30944. if m.id == nil || m.oldValue == nil {
  30945. return v, errors.New("OldStatus requires an ID field in the mutation")
  30946. }
  30947. oldValue, err := m.oldValue(ctx)
  30948. if err != nil {
  30949. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  30950. }
  30951. return oldValue.Status, nil
  30952. }
  30953. // AddStatus adds u to the "status" field.
  30954. func (m *UsageStatisticHourMutation) AddStatus(u int8) {
  30955. if m.addstatus != nil {
  30956. *m.addstatus += u
  30957. } else {
  30958. m.addstatus = &u
  30959. }
  30960. }
  30961. // AddedStatus returns the value that was added to the "status" field in this mutation.
  30962. func (m *UsageStatisticHourMutation) AddedStatus() (r int8, exists bool) {
  30963. v := m.addstatus
  30964. if v == nil {
  30965. return
  30966. }
  30967. return *v, true
  30968. }
  30969. // ClearStatus clears the value of the "status" field.
  30970. func (m *UsageStatisticHourMutation) ClearStatus() {
  30971. m.status = nil
  30972. m.addstatus = nil
  30973. m.clearedFields[usagestatistichour.FieldStatus] = struct{}{}
  30974. }
  30975. // StatusCleared returns if the "status" field was cleared in this mutation.
  30976. func (m *UsageStatisticHourMutation) StatusCleared() bool {
  30977. _, ok := m.clearedFields[usagestatistichour.FieldStatus]
  30978. return ok
  30979. }
  30980. // ResetStatus resets all changes to the "status" field.
  30981. func (m *UsageStatisticHourMutation) ResetStatus() {
  30982. m.status = nil
  30983. m.addstatus = nil
  30984. delete(m.clearedFields, usagestatistichour.FieldStatus)
  30985. }
  30986. // SetDeletedAt sets the "deleted_at" field.
  30987. func (m *UsageStatisticHourMutation) SetDeletedAt(t time.Time) {
  30988. m.deleted_at = &t
  30989. }
  30990. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  30991. func (m *UsageStatisticHourMutation) DeletedAt() (r time.Time, exists bool) {
  30992. v := m.deleted_at
  30993. if v == nil {
  30994. return
  30995. }
  30996. return *v, true
  30997. }
  30998. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticHour entity.
  30999. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  31000. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31001. func (m *UsageStatisticHourMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  31002. if !m.op.Is(OpUpdateOne) {
  31003. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  31004. }
  31005. if m.id == nil || m.oldValue == nil {
  31006. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  31007. }
  31008. oldValue, err := m.oldValue(ctx)
  31009. if err != nil {
  31010. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  31011. }
  31012. return oldValue.DeletedAt, nil
  31013. }
  31014. // ClearDeletedAt clears the value of the "deleted_at" field.
  31015. func (m *UsageStatisticHourMutation) ClearDeletedAt() {
  31016. m.deleted_at = nil
  31017. m.clearedFields[usagestatistichour.FieldDeletedAt] = struct{}{}
  31018. }
  31019. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  31020. func (m *UsageStatisticHourMutation) DeletedAtCleared() bool {
  31021. _, ok := m.clearedFields[usagestatistichour.FieldDeletedAt]
  31022. return ok
  31023. }
  31024. // ResetDeletedAt resets all changes to the "deleted_at" field.
  31025. func (m *UsageStatisticHourMutation) ResetDeletedAt() {
  31026. m.deleted_at = nil
  31027. delete(m.clearedFields, usagestatistichour.FieldDeletedAt)
  31028. }
  31029. // SetAddtime sets the "addtime" field.
  31030. func (m *UsageStatisticHourMutation) SetAddtime(u uint64) {
  31031. m.addtime = &u
  31032. m.addaddtime = nil
  31033. }
  31034. // Addtime returns the value of the "addtime" field in the mutation.
  31035. func (m *UsageStatisticHourMutation) Addtime() (r uint64, exists bool) {
  31036. v := m.addtime
  31037. if v == nil {
  31038. return
  31039. }
  31040. return *v, true
  31041. }
  31042. // OldAddtime returns the old "addtime" field's value of the UsageStatisticHour entity.
  31043. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  31044. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31045. func (m *UsageStatisticHourMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  31046. if !m.op.Is(OpUpdateOne) {
  31047. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  31048. }
  31049. if m.id == nil || m.oldValue == nil {
  31050. return v, errors.New("OldAddtime requires an ID field in the mutation")
  31051. }
  31052. oldValue, err := m.oldValue(ctx)
  31053. if err != nil {
  31054. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  31055. }
  31056. return oldValue.Addtime, nil
  31057. }
  31058. // AddAddtime adds u to the "addtime" field.
  31059. func (m *UsageStatisticHourMutation) AddAddtime(u int64) {
  31060. if m.addaddtime != nil {
  31061. *m.addaddtime += u
  31062. } else {
  31063. m.addaddtime = &u
  31064. }
  31065. }
  31066. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  31067. func (m *UsageStatisticHourMutation) AddedAddtime() (r int64, exists bool) {
  31068. v := m.addaddtime
  31069. if v == nil {
  31070. return
  31071. }
  31072. return *v, true
  31073. }
  31074. // ResetAddtime resets all changes to the "addtime" field.
  31075. func (m *UsageStatisticHourMutation) ResetAddtime() {
  31076. m.addtime = nil
  31077. m.addaddtime = nil
  31078. }
  31079. // SetType sets the "type" field.
  31080. func (m *UsageStatisticHourMutation) SetType(i int) {
  31081. m._type = &i
  31082. m.add_type = nil
  31083. }
  31084. // GetType returns the value of the "type" field in the mutation.
  31085. func (m *UsageStatisticHourMutation) GetType() (r int, exists bool) {
  31086. v := m._type
  31087. if v == nil {
  31088. return
  31089. }
  31090. return *v, true
  31091. }
  31092. // OldType returns the old "type" field's value of the UsageStatisticHour entity.
  31093. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  31094. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31095. func (m *UsageStatisticHourMutation) OldType(ctx context.Context) (v int, err error) {
  31096. if !m.op.Is(OpUpdateOne) {
  31097. return v, errors.New("OldType is only allowed on UpdateOne operations")
  31098. }
  31099. if m.id == nil || m.oldValue == nil {
  31100. return v, errors.New("OldType requires an ID field in the mutation")
  31101. }
  31102. oldValue, err := m.oldValue(ctx)
  31103. if err != nil {
  31104. return v, fmt.Errorf("querying old value for OldType: %w", err)
  31105. }
  31106. return oldValue.Type, nil
  31107. }
  31108. // AddType adds i to the "type" field.
  31109. func (m *UsageStatisticHourMutation) AddType(i int) {
  31110. if m.add_type != nil {
  31111. *m.add_type += i
  31112. } else {
  31113. m.add_type = &i
  31114. }
  31115. }
  31116. // AddedType returns the value that was added to the "type" field in this mutation.
  31117. func (m *UsageStatisticHourMutation) AddedType() (r int, exists bool) {
  31118. v := m.add_type
  31119. if v == nil {
  31120. return
  31121. }
  31122. return *v, true
  31123. }
  31124. // ResetType resets all changes to the "type" field.
  31125. func (m *UsageStatisticHourMutation) ResetType() {
  31126. m._type = nil
  31127. m.add_type = nil
  31128. }
  31129. // SetBotID sets the "bot_id" field.
  31130. func (m *UsageStatisticHourMutation) SetBotID(s string) {
  31131. m.bot_id = &s
  31132. }
  31133. // BotID returns the value of the "bot_id" field in the mutation.
  31134. func (m *UsageStatisticHourMutation) BotID() (r string, exists bool) {
  31135. v := m.bot_id
  31136. if v == nil {
  31137. return
  31138. }
  31139. return *v, true
  31140. }
  31141. // OldBotID returns the old "bot_id" field's value of the UsageStatisticHour entity.
  31142. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  31143. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31144. func (m *UsageStatisticHourMutation) OldBotID(ctx context.Context) (v string, err error) {
  31145. if !m.op.Is(OpUpdateOne) {
  31146. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  31147. }
  31148. if m.id == nil || m.oldValue == nil {
  31149. return v, errors.New("OldBotID requires an ID field in the mutation")
  31150. }
  31151. oldValue, err := m.oldValue(ctx)
  31152. if err != nil {
  31153. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  31154. }
  31155. return oldValue.BotID, nil
  31156. }
  31157. // ClearBotID clears the value of the "bot_id" field.
  31158. func (m *UsageStatisticHourMutation) ClearBotID() {
  31159. m.bot_id = nil
  31160. m.clearedFields[usagestatistichour.FieldBotID] = struct{}{}
  31161. }
  31162. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  31163. func (m *UsageStatisticHourMutation) BotIDCleared() bool {
  31164. _, ok := m.clearedFields[usagestatistichour.FieldBotID]
  31165. return ok
  31166. }
  31167. // ResetBotID resets all changes to the "bot_id" field.
  31168. func (m *UsageStatisticHourMutation) ResetBotID() {
  31169. m.bot_id = nil
  31170. delete(m.clearedFields, usagestatistichour.FieldBotID)
  31171. }
  31172. // SetOrganizationID sets the "organization_id" field.
  31173. func (m *UsageStatisticHourMutation) SetOrganizationID(u uint64) {
  31174. m.organization_id = &u
  31175. m.addorganization_id = nil
  31176. }
  31177. // OrganizationID returns the value of the "organization_id" field in the mutation.
  31178. func (m *UsageStatisticHourMutation) OrganizationID() (r uint64, exists bool) {
  31179. v := m.organization_id
  31180. if v == nil {
  31181. return
  31182. }
  31183. return *v, true
  31184. }
  31185. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticHour entity.
  31186. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  31187. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31188. func (m *UsageStatisticHourMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  31189. if !m.op.Is(OpUpdateOne) {
  31190. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  31191. }
  31192. if m.id == nil || m.oldValue == nil {
  31193. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  31194. }
  31195. oldValue, err := m.oldValue(ctx)
  31196. if err != nil {
  31197. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  31198. }
  31199. return oldValue.OrganizationID, nil
  31200. }
  31201. // AddOrganizationID adds u to the "organization_id" field.
  31202. func (m *UsageStatisticHourMutation) AddOrganizationID(u int64) {
  31203. if m.addorganization_id != nil {
  31204. *m.addorganization_id += u
  31205. } else {
  31206. m.addorganization_id = &u
  31207. }
  31208. }
  31209. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  31210. func (m *UsageStatisticHourMutation) AddedOrganizationID() (r int64, exists bool) {
  31211. v := m.addorganization_id
  31212. if v == nil {
  31213. return
  31214. }
  31215. return *v, true
  31216. }
  31217. // ClearOrganizationID clears the value of the "organization_id" field.
  31218. func (m *UsageStatisticHourMutation) ClearOrganizationID() {
  31219. m.organization_id = nil
  31220. m.addorganization_id = nil
  31221. m.clearedFields[usagestatistichour.FieldOrganizationID] = struct{}{}
  31222. }
  31223. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  31224. func (m *UsageStatisticHourMutation) OrganizationIDCleared() bool {
  31225. _, ok := m.clearedFields[usagestatistichour.FieldOrganizationID]
  31226. return ok
  31227. }
  31228. // ResetOrganizationID resets all changes to the "organization_id" field.
  31229. func (m *UsageStatisticHourMutation) ResetOrganizationID() {
  31230. m.organization_id = nil
  31231. m.addorganization_id = nil
  31232. delete(m.clearedFields, usagestatistichour.FieldOrganizationID)
  31233. }
  31234. // SetAiResponse sets the "ai_response" field.
  31235. func (m *UsageStatisticHourMutation) SetAiResponse(u uint64) {
  31236. m.ai_response = &u
  31237. m.addai_response = nil
  31238. }
  31239. // AiResponse returns the value of the "ai_response" field in the mutation.
  31240. func (m *UsageStatisticHourMutation) AiResponse() (r uint64, exists bool) {
  31241. v := m.ai_response
  31242. if v == nil {
  31243. return
  31244. }
  31245. return *v, true
  31246. }
  31247. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticHour entity.
  31248. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  31249. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31250. func (m *UsageStatisticHourMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  31251. if !m.op.Is(OpUpdateOne) {
  31252. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  31253. }
  31254. if m.id == nil || m.oldValue == nil {
  31255. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  31256. }
  31257. oldValue, err := m.oldValue(ctx)
  31258. if err != nil {
  31259. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  31260. }
  31261. return oldValue.AiResponse, nil
  31262. }
  31263. // AddAiResponse adds u to the "ai_response" field.
  31264. func (m *UsageStatisticHourMutation) AddAiResponse(u int64) {
  31265. if m.addai_response != nil {
  31266. *m.addai_response += u
  31267. } else {
  31268. m.addai_response = &u
  31269. }
  31270. }
  31271. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  31272. func (m *UsageStatisticHourMutation) AddedAiResponse() (r int64, exists bool) {
  31273. v := m.addai_response
  31274. if v == nil {
  31275. return
  31276. }
  31277. return *v, true
  31278. }
  31279. // ResetAiResponse resets all changes to the "ai_response" field.
  31280. func (m *UsageStatisticHourMutation) ResetAiResponse() {
  31281. m.ai_response = nil
  31282. m.addai_response = nil
  31283. }
  31284. // SetSopRun sets the "sop_run" field.
  31285. func (m *UsageStatisticHourMutation) SetSopRun(u uint64) {
  31286. m.sop_run = &u
  31287. m.addsop_run = nil
  31288. }
  31289. // SopRun returns the value of the "sop_run" field in the mutation.
  31290. func (m *UsageStatisticHourMutation) SopRun() (r uint64, exists bool) {
  31291. v := m.sop_run
  31292. if v == nil {
  31293. return
  31294. }
  31295. return *v, true
  31296. }
  31297. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticHour entity.
  31298. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  31299. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31300. func (m *UsageStatisticHourMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  31301. if !m.op.Is(OpUpdateOne) {
  31302. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  31303. }
  31304. if m.id == nil || m.oldValue == nil {
  31305. return v, errors.New("OldSopRun requires an ID field in the mutation")
  31306. }
  31307. oldValue, err := m.oldValue(ctx)
  31308. if err != nil {
  31309. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  31310. }
  31311. return oldValue.SopRun, nil
  31312. }
  31313. // AddSopRun adds u to the "sop_run" field.
  31314. func (m *UsageStatisticHourMutation) AddSopRun(u int64) {
  31315. if m.addsop_run != nil {
  31316. *m.addsop_run += u
  31317. } else {
  31318. m.addsop_run = &u
  31319. }
  31320. }
  31321. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  31322. func (m *UsageStatisticHourMutation) AddedSopRun() (r int64, exists bool) {
  31323. v := m.addsop_run
  31324. if v == nil {
  31325. return
  31326. }
  31327. return *v, true
  31328. }
  31329. // ResetSopRun resets all changes to the "sop_run" field.
  31330. func (m *UsageStatisticHourMutation) ResetSopRun() {
  31331. m.sop_run = nil
  31332. m.addsop_run = nil
  31333. }
  31334. // SetTotalFriend sets the "total_friend" field.
  31335. func (m *UsageStatisticHourMutation) SetTotalFriend(u uint64) {
  31336. m.total_friend = &u
  31337. m.addtotal_friend = nil
  31338. }
  31339. // TotalFriend returns the value of the "total_friend" field in the mutation.
  31340. func (m *UsageStatisticHourMutation) TotalFriend() (r uint64, exists bool) {
  31341. v := m.total_friend
  31342. if v == nil {
  31343. return
  31344. }
  31345. return *v, true
  31346. }
  31347. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticHour entity.
  31348. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  31349. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31350. func (m *UsageStatisticHourMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  31351. if !m.op.Is(OpUpdateOne) {
  31352. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  31353. }
  31354. if m.id == nil || m.oldValue == nil {
  31355. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  31356. }
  31357. oldValue, err := m.oldValue(ctx)
  31358. if err != nil {
  31359. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  31360. }
  31361. return oldValue.TotalFriend, nil
  31362. }
  31363. // AddTotalFriend adds u to the "total_friend" field.
  31364. func (m *UsageStatisticHourMutation) AddTotalFriend(u int64) {
  31365. if m.addtotal_friend != nil {
  31366. *m.addtotal_friend += u
  31367. } else {
  31368. m.addtotal_friend = &u
  31369. }
  31370. }
  31371. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  31372. func (m *UsageStatisticHourMutation) AddedTotalFriend() (r int64, exists bool) {
  31373. v := m.addtotal_friend
  31374. if v == nil {
  31375. return
  31376. }
  31377. return *v, true
  31378. }
  31379. // ResetTotalFriend resets all changes to the "total_friend" field.
  31380. func (m *UsageStatisticHourMutation) ResetTotalFriend() {
  31381. m.total_friend = nil
  31382. m.addtotal_friend = nil
  31383. }
  31384. // SetTotalGroup sets the "total_group" field.
  31385. func (m *UsageStatisticHourMutation) SetTotalGroup(u uint64) {
  31386. m.total_group = &u
  31387. m.addtotal_group = nil
  31388. }
  31389. // TotalGroup returns the value of the "total_group" field in the mutation.
  31390. func (m *UsageStatisticHourMutation) TotalGroup() (r uint64, exists bool) {
  31391. v := m.total_group
  31392. if v == nil {
  31393. return
  31394. }
  31395. return *v, true
  31396. }
  31397. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticHour entity.
  31398. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  31399. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31400. func (m *UsageStatisticHourMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  31401. if !m.op.Is(OpUpdateOne) {
  31402. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  31403. }
  31404. if m.id == nil || m.oldValue == nil {
  31405. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  31406. }
  31407. oldValue, err := m.oldValue(ctx)
  31408. if err != nil {
  31409. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  31410. }
  31411. return oldValue.TotalGroup, nil
  31412. }
  31413. // AddTotalGroup adds u to the "total_group" field.
  31414. func (m *UsageStatisticHourMutation) AddTotalGroup(u int64) {
  31415. if m.addtotal_group != nil {
  31416. *m.addtotal_group += u
  31417. } else {
  31418. m.addtotal_group = &u
  31419. }
  31420. }
  31421. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  31422. func (m *UsageStatisticHourMutation) AddedTotalGroup() (r int64, exists bool) {
  31423. v := m.addtotal_group
  31424. if v == nil {
  31425. return
  31426. }
  31427. return *v, true
  31428. }
  31429. // ResetTotalGroup resets all changes to the "total_group" field.
  31430. func (m *UsageStatisticHourMutation) ResetTotalGroup() {
  31431. m.total_group = nil
  31432. m.addtotal_group = nil
  31433. }
  31434. // SetAccountBalance sets the "account_balance" field.
  31435. func (m *UsageStatisticHourMutation) SetAccountBalance(u uint64) {
  31436. m.account_balance = &u
  31437. m.addaccount_balance = nil
  31438. }
  31439. // AccountBalance returns the value of the "account_balance" field in the mutation.
  31440. func (m *UsageStatisticHourMutation) AccountBalance() (r uint64, exists bool) {
  31441. v := m.account_balance
  31442. if v == nil {
  31443. return
  31444. }
  31445. return *v, true
  31446. }
  31447. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticHour entity.
  31448. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  31449. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31450. func (m *UsageStatisticHourMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  31451. if !m.op.Is(OpUpdateOne) {
  31452. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  31453. }
  31454. if m.id == nil || m.oldValue == nil {
  31455. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  31456. }
  31457. oldValue, err := m.oldValue(ctx)
  31458. if err != nil {
  31459. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  31460. }
  31461. return oldValue.AccountBalance, nil
  31462. }
  31463. // AddAccountBalance adds u to the "account_balance" field.
  31464. func (m *UsageStatisticHourMutation) AddAccountBalance(u int64) {
  31465. if m.addaccount_balance != nil {
  31466. *m.addaccount_balance += u
  31467. } else {
  31468. m.addaccount_balance = &u
  31469. }
  31470. }
  31471. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  31472. func (m *UsageStatisticHourMutation) AddedAccountBalance() (r int64, exists bool) {
  31473. v := m.addaccount_balance
  31474. if v == nil {
  31475. return
  31476. }
  31477. return *v, true
  31478. }
  31479. // ResetAccountBalance resets all changes to the "account_balance" field.
  31480. func (m *UsageStatisticHourMutation) ResetAccountBalance() {
  31481. m.account_balance = nil
  31482. m.addaccount_balance = nil
  31483. }
  31484. // SetConsumeToken sets the "consume_token" field.
  31485. func (m *UsageStatisticHourMutation) SetConsumeToken(u uint64) {
  31486. m.consume_token = &u
  31487. m.addconsume_token = nil
  31488. }
  31489. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  31490. func (m *UsageStatisticHourMutation) ConsumeToken() (r uint64, exists bool) {
  31491. v := m.consume_token
  31492. if v == nil {
  31493. return
  31494. }
  31495. return *v, true
  31496. }
  31497. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticHour entity.
  31498. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  31499. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31500. func (m *UsageStatisticHourMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  31501. if !m.op.Is(OpUpdateOne) {
  31502. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  31503. }
  31504. if m.id == nil || m.oldValue == nil {
  31505. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  31506. }
  31507. oldValue, err := m.oldValue(ctx)
  31508. if err != nil {
  31509. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  31510. }
  31511. return oldValue.ConsumeToken, nil
  31512. }
  31513. // AddConsumeToken adds u to the "consume_token" field.
  31514. func (m *UsageStatisticHourMutation) AddConsumeToken(u int64) {
  31515. if m.addconsume_token != nil {
  31516. *m.addconsume_token += u
  31517. } else {
  31518. m.addconsume_token = &u
  31519. }
  31520. }
  31521. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  31522. func (m *UsageStatisticHourMutation) AddedConsumeToken() (r int64, exists bool) {
  31523. v := m.addconsume_token
  31524. if v == nil {
  31525. return
  31526. }
  31527. return *v, true
  31528. }
  31529. // ResetConsumeToken resets all changes to the "consume_token" field.
  31530. func (m *UsageStatisticHourMutation) ResetConsumeToken() {
  31531. m.consume_token = nil
  31532. m.addconsume_token = nil
  31533. }
  31534. // SetActiveUser sets the "active_user" field.
  31535. func (m *UsageStatisticHourMutation) SetActiveUser(u uint64) {
  31536. m.active_user = &u
  31537. m.addactive_user = nil
  31538. }
  31539. // ActiveUser returns the value of the "active_user" field in the mutation.
  31540. func (m *UsageStatisticHourMutation) ActiveUser() (r uint64, exists bool) {
  31541. v := m.active_user
  31542. if v == nil {
  31543. return
  31544. }
  31545. return *v, true
  31546. }
  31547. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticHour entity.
  31548. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  31549. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31550. func (m *UsageStatisticHourMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  31551. if !m.op.Is(OpUpdateOne) {
  31552. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  31553. }
  31554. if m.id == nil || m.oldValue == nil {
  31555. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  31556. }
  31557. oldValue, err := m.oldValue(ctx)
  31558. if err != nil {
  31559. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  31560. }
  31561. return oldValue.ActiveUser, nil
  31562. }
  31563. // AddActiveUser adds u to the "active_user" field.
  31564. func (m *UsageStatisticHourMutation) AddActiveUser(u int64) {
  31565. if m.addactive_user != nil {
  31566. *m.addactive_user += u
  31567. } else {
  31568. m.addactive_user = &u
  31569. }
  31570. }
  31571. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  31572. func (m *UsageStatisticHourMutation) AddedActiveUser() (r int64, exists bool) {
  31573. v := m.addactive_user
  31574. if v == nil {
  31575. return
  31576. }
  31577. return *v, true
  31578. }
  31579. // ResetActiveUser resets all changes to the "active_user" field.
  31580. func (m *UsageStatisticHourMutation) ResetActiveUser() {
  31581. m.active_user = nil
  31582. m.addactive_user = nil
  31583. }
  31584. // SetNewUser sets the "new_user" field.
  31585. func (m *UsageStatisticHourMutation) SetNewUser(i int64) {
  31586. m.new_user = &i
  31587. m.addnew_user = nil
  31588. }
  31589. // NewUser returns the value of the "new_user" field in the mutation.
  31590. func (m *UsageStatisticHourMutation) NewUser() (r int64, exists bool) {
  31591. v := m.new_user
  31592. if v == nil {
  31593. return
  31594. }
  31595. return *v, true
  31596. }
  31597. // OldNewUser returns the old "new_user" field's value of the UsageStatisticHour entity.
  31598. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  31599. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31600. func (m *UsageStatisticHourMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  31601. if !m.op.Is(OpUpdateOne) {
  31602. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  31603. }
  31604. if m.id == nil || m.oldValue == nil {
  31605. return v, errors.New("OldNewUser requires an ID field in the mutation")
  31606. }
  31607. oldValue, err := m.oldValue(ctx)
  31608. if err != nil {
  31609. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  31610. }
  31611. return oldValue.NewUser, nil
  31612. }
  31613. // AddNewUser adds i to the "new_user" field.
  31614. func (m *UsageStatisticHourMutation) AddNewUser(i int64) {
  31615. if m.addnew_user != nil {
  31616. *m.addnew_user += i
  31617. } else {
  31618. m.addnew_user = &i
  31619. }
  31620. }
  31621. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  31622. func (m *UsageStatisticHourMutation) AddedNewUser() (r int64, exists bool) {
  31623. v := m.addnew_user
  31624. if v == nil {
  31625. return
  31626. }
  31627. return *v, true
  31628. }
  31629. // ResetNewUser resets all changes to the "new_user" field.
  31630. func (m *UsageStatisticHourMutation) ResetNewUser() {
  31631. m.new_user = nil
  31632. m.addnew_user = nil
  31633. }
  31634. // SetLabelDist sets the "label_dist" field.
  31635. func (m *UsageStatisticHourMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  31636. m.label_dist = &ctd
  31637. m.appendlabel_dist = nil
  31638. }
  31639. // LabelDist returns the value of the "label_dist" field in the mutation.
  31640. func (m *UsageStatisticHourMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  31641. v := m.label_dist
  31642. if v == nil {
  31643. return
  31644. }
  31645. return *v, true
  31646. }
  31647. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticHour entity.
  31648. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  31649. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31650. func (m *UsageStatisticHourMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  31651. if !m.op.Is(OpUpdateOne) {
  31652. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  31653. }
  31654. if m.id == nil || m.oldValue == nil {
  31655. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  31656. }
  31657. oldValue, err := m.oldValue(ctx)
  31658. if err != nil {
  31659. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  31660. }
  31661. return oldValue.LabelDist, nil
  31662. }
  31663. // AppendLabelDist adds ctd to the "label_dist" field.
  31664. func (m *UsageStatisticHourMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  31665. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  31666. }
  31667. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  31668. func (m *UsageStatisticHourMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  31669. if len(m.appendlabel_dist) == 0 {
  31670. return nil, false
  31671. }
  31672. return m.appendlabel_dist, true
  31673. }
  31674. // ResetLabelDist resets all changes to the "label_dist" field.
  31675. func (m *UsageStatisticHourMutation) ResetLabelDist() {
  31676. m.label_dist = nil
  31677. m.appendlabel_dist = nil
  31678. }
  31679. // Where appends a list predicates to the UsageStatisticHourMutation builder.
  31680. func (m *UsageStatisticHourMutation) Where(ps ...predicate.UsageStatisticHour) {
  31681. m.predicates = append(m.predicates, ps...)
  31682. }
  31683. // WhereP appends storage-level predicates to the UsageStatisticHourMutation builder. Using this method,
  31684. // users can use type-assertion to append predicates that do not depend on any generated package.
  31685. func (m *UsageStatisticHourMutation) WhereP(ps ...func(*sql.Selector)) {
  31686. p := make([]predicate.UsageStatisticHour, len(ps))
  31687. for i := range ps {
  31688. p[i] = ps[i]
  31689. }
  31690. m.Where(p...)
  31691. }
  31692. // Op returns the operation name.
  31693. func (m *UsageStatisticHourMutation) Op() Op {
  31694. return m.op
  31695. }
  31696. // SetOp allows setting the mutation operation.
  31697. func (m *UsageStatisticHourMutation) SetOp(op Op) {
  31698. m.op = op
  31699. }
  31700. // Type returns the node type of this mutation (UsageStatisticHour).
  31701. func (m *UsageStatisticHourMutation) Type() string {
  31702. return m.typ
  31703. }
  31704. // Fields returns all fields that were changed during this mutation. Note that in
  31705. // order to get all numeric fields that were incremented/decremented, call
  31706. // AddedFields().
  31707. func (m *UsageStatisticHourMutation) Fields() []string {
  31708. fields := make([]string, 0, 17)
  31709. if m.created_at != nil {
  31710. fields = append(fields, usagestatistichour.FieldCreatedAt)
  31711. }
  31712. if m.updated_at != nil {
  31713. fields = append(fields, usagestatistichour.FieldUpdatedAt)
  31714. }
  31715. if m.status != nil {
  31716. fields = append(fields, usagestatistichour.FieldStatus)
  31717. }
  31718. if m.deleted_at != nil {
  31719. fields = append(fields, usagestatistichour.FieldDeletedAt)
  31720. }
  31721. if m.addtime != nil {
  31722. fields = append(fields, usagestatistichour.FieldAddtime)
  31723. }
  31724. if m._type != nil {
  31725. fields = append(fields, usagestatistichour.FieldType)
  31726. }
  31727. if m.bot_id != nil {
  31728. fields = append(fields, usagestatistichour.FieldBotID)
  31729. }
  31730. if m.organization_id != nil {
  31731. fields = append(fields, usagestatistichour.FieldOrganizationID)
  31732. }
  31733. if m.ai_response != nil {
  31734. fields = append(fields, usagestatistichour.FieldAiResponse)
  31735. }
  31736. if m.sop_run != nil {
  31737. fields = append(fields, usagestatistichour.FieldSopRun)
  31738. }
  31739. if m.total_friend != nil {
  31740. fields = append(fields, usagestatistichour.FieldTotalFriend)
  31741. }
  31742. if m.total_group != nil {
  31743. fields = append(fields, usagestatistichour.FieldTotalGroup)
  31744. }
  31745. if m.account_balance != nil {
  31746. fields = append(fields, usagestatistichour.FieldAccountBalance)
  31747. }
  31748. if m.consume_token != nil {
  31749. fields = append(fields, usagestatistichour.FieldConsumeToken)
  31750. }
  31751. if m.active_user != nil {
  31752. fields = append(fields, usagestatistichour.FieldActiveUser)
  31753. }
  31754. if m.new_user != nil {
  31755. fields = append(fields, usagestatistichour.FieldNewUser)
  31756. }
  31757. if m.label_dist != nil {
  31758. fields = append(fields, usagestatistichour.FieldLabelDist)
  31759. }
  31760. return fields
  31761. }
  31762. // Field returns the value of a field with the given name. The second boolean
  31763. // return value indicates that this field was not set, or was not defined in the
  31764. // schema.
  31765. func (m *UsageStatisticHourMutation) Field(name string) (ent.Value, bool) {
  31766. switch name {
  31767. case usagestatistichour.FieldCreatedAt:
  31768. return m.CreatedAt()
  31769. case usagestatistichour.FieldUpdatedAt:
  31770. return m.UpdatedAt()
  31771. case usagestatistichour.FieldStatus:
  31772. return m.Status()
  31773. case usagestatistichour.FieldDeletedAt:
  31774. return m.DeletedAt()
  31775. case usagestatistichour.FieldAddtime:
  31776. return m.Addtime()
  31777. case usagestatistichour.FieldType:
  31778. return m.GetType()
  31779. case usagestatistichour.FieldBotID:
  31780. return m.BotID()
  31781. case usagestatistichour.FieldOrganizationID:
  31782. return m.OrganizationID()
  31783. case usagestatistichour.FieldAiResponse:
  31784. return m.AiResponse()
  31785. case usagestatistichour.FieldSopRun:
  31786. return m.SopRun()
  31787. case usagestatistichour.FieldTotalFriend:
  31788. return m.TotalFriend()
  31789. case usagestatistichour.FieldTotalGroup:
  31790. return m.TotalGroup()
  31791. case usagestatistichour.FieldAccountBalance:
  31792. return m.AccountBalance()
  31793. case usagestatistichour.FieldConsumeToken:
  31794. return m.ConsumeToken()
  31795. case usagestatistichour.FieldActiveUser:
  31796. return m.ActiveUser()
  31797. case usagestatistichour.FieldNewUser:
  31798. return m.NewUser()
  31799. case usagestatistichour.FieldLabelDist:
  31800. return m.LabelDist()
  31801. }
  31802. return nil, false
  31803. }
  31804. // OldField returns the old value of the field from the database. An error is
  31805. // returned if the mutation operation is not UpdateOne, or the query to the
  31806. // database failed.
  31807. func (m *UsageStatisticHourMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  31808. switch name {
  31809. case usagestatistichour.FieldCreatedAt:
  31810. return m.OldCreatedAt(ctx)
  31811. case usagestatistichour.FieldUpdatedAt:
  31812. return m.OldUpdatedAt(ctx)
  31813. case usagestatistichour.FieldStatus:
  31814. return m.OldStatus(ctx)
  31815. case usagestatistichour.FieldDeletedAt:
  31816. return m.OldDeletedAt(ctx)
  31817. case usagestatistichour.FieldAddtime:
  31818. return m.OldAddtime(ctx)
  31819. case usagestatistichour.FieldType:
  31820. return m.OldType(ctx)
  31821. case usagestatistichour.FieldBotID:
  31822. return m.OldBotID(ctx)
  31823. case usagestatistichour.FieldOrganizationID:
  31824. return m.OldOrganizationID(ctx)
  31825. case usagestatistichour.FieldAiResponse:
  31826. return m.OldAiResponse(ctx)
  31827. case usagestatistichour.FieldSopRun:
  31828. return m.OldSopRun(ctx)
  31829. case usagestatistichour.FieldTotalFriend:
  31830. return m.OldTotalFriend(ctx)
  31831. case usagestatistichour.FieldTotalGroup:
  31832. return m.OldTotalGroup(ctx)
  31833. case usagestatistichour.FieldAccountBalance:
  31834. return m.OldAccountBalance(ctx)
  31835. case usagestatistichour.FieldConsumeToken:
  31836. return m.OldConsumeToken(ctx)
  31837. case usagestatistichour.FieldActiveUser:
  31838. return m.OldActiveUser(ctx)
  31839. case usagestatistichour.FieldNewUser:
  31840. return m.OldNewUser(ctx)
  31841. case usagestatistichour.FieldLabelDist:
  31842. return m.OldLabelDist(ctx)
  31843. }
  31844. return nil, fmt.Errorf("unknown UsageStatisticHour field %s", name)
  31845. }
  31846. // SetField sets the value of a 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) SetField(name string, value ent.Value) error {
  31850. switch name {
  31851. case usagestatistichour.FieldCreatedAt:
  31852. v, ok := value.(time.Time)
  31853. if !ok {
  31854. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31855. }
  31856. m.SetCreatedAt(v)
  31857. return nil
  31858. case usagestatistichour.FieldUpdatedAt:
  31859. v, ok := value.(time.Time)
  31860. if !ok {
  31861. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31862. }
  31863. m.SetUpdatedAt(v)
  31864. return nil
  31865. case usagestatistichour.FieldStatus:
  31866. v, ok := value.(uint8)
  31867. if !ok {
  31868. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31869. }
  31870. m.SetStatus(v)
  31871. return nil
  31872. case usagestatistichour.FieldDeletedAt:
  31873. v, ok := value.(time.Time)
  31874. if !ok {
  31875. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31876. }
  31877. m.SetDeletedAt(v)
  31878. return nil
  31879. case usagestatistichour.FieldAddtime:
  31880. v, ok := value.(uint64)
  31881. if !ok {
  31882. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31883. }
  31884. m.SetAddtime(v)
  31885. return nil
  31886. case usagestatistichour.FieldType:
  31887. v, ok := value.(int)
  31888. if !ok {
  31889. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31890. }
  31891. m.SetType(v)
  31892. return nil
  31893. case usagestatistichour.FieldBotID:
  31894. v, ok := value.(string)
  31895. if !ok {
  31896. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31897. }
  31898. m.SetBotID(v)
  31899. return nil
  31900. case usagestatistichour.FieldOrganizationID:
  31901. v, ok := value.(uint64)
  31902. if !ok {
  31903. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31904. }
  31905. m.SetOrganizationID(v)
  31906. return nil
  31907. case usagestatistichour.FieldAiResponse:
  31908. v, ok := value.(uint64)
  31909. if !ok {
  31910. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31911. }
  31912. m.SetAiResponse(v)
  31913. return nil
  31914. case usagestatistichour.FieldSopRun:
  31915. v, ok := value.(uint64)
  31916. if !ok {
  31917. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31918. }
  31919. m.SetSopRun(v)
  31920. return nil
  31921. case usagestatistichour.FieldTotalFriend:
  31922. v, ok := value.(uint64)
  31923. if !ok {
  31924. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31925. }
  31926. m.SetTotalFriend(v)
  31927. return nil
  31928. case usagestatistichour.FieldTotalGroup:
  31929. v, ok := value.(uint64)
  31930. if !ok {
  31931. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31932. }
  31933. m.SetTotalGroup(v)
  31934. return nil
  31935. case usagestatistichour.FieldAccountBalance:
  31936. v, ok := value.(uint64)
  31937. if !ok {
  31938. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31939. }
  31940. m.SetAccountBalance(v)
  31941. return nil
  31942. case usagestatistichour.FieldConsumeToken:
  31943. v, ok := value.(uint64)
  31944. if !ok {
  31945. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31946. }
  31947. m.SetConsumeToken(v)
  31948. return nil
  31949. case usagestatistichour.FieldActiveUser:
  31950. v, ok := value.(uint64)
  31951. if !ok {
  31952. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31953. }
  31954. m.SetActiveUser(v)
  31955. return nil
  31956. case usagestatistichour.FieldNewUser:
  31957. v, ok := value.(int64)
  31958. if !ok {
  31959. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31960. }
  31961. m.SetNewUser(v)
  31962. return nil
  31963. case usagestatistichour.FieldLabelDist:
  31964. v, ok := value.([]custom_types.LabelDist)
  31965. if !ok {
  31966. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31967. }
  31968. m.SetLabelDist(v)
  31969. return nil
  31970. }
  31971. return fmt.Errorf("unknown UsageStatisticHour field %s", name)
  31972. }
  31973. // AddedFields returns all numeric fields that were incremented/decremented during
  31974. // this mutation.
  31975. func (m *UsageStatisticHourMutation) AddedFields() []string {
  31976. var fields []string
  31977. if m.addstatus != nil {
  31978. fields = append(fields, usagestatistichour.FieldStatus)
  31979. }
  31980. if m.addaddtime != nil {
  31981. fields = append(fields, usagestatistichour.FieldAddtime)
  31982. }
  31983. if m.add_type != nil {
  31984. fields = append(fields, usagestatistichour.FieldType)
  31985. }
  31986. if m.addorganization_id != nil {
  31987. fields = append(fields, usagestatistichour.FieldOrganizationID)
  31988. }
  31989. if m.addai_response != nil {
  31990. fields = append(fields, usagestatistichour.FieldAiResponse)
  31991. }
  31992. if m.addsop_run != nil {
  31993. fields = append(fields, usagestatistichour.FieldSopRun)
  31994. }
  31995. if m.addtotal_friend != nil {
  31996. fields = append(fields, usagestatistichour.FieldTotalFriend)
  31997. }
  31998. if m.addtotal_group != nil {
  31999. fields = append(fields, usagestatistichour.FieldTotalGroup)
  32000. }
  32001. if m.addaccount_balance != nil {
  32002. fields = append(fields, usagestatistichour.FieldAccountBalance)
  32003. }
  32004. if m.addconsume_token != nil {
  32005. fields = append(fields, usagestatistichour.FieldConsumeToken)
  32006. }
  32007. if m.addactive_user != nil {
  32008. fields = append(fields, usagestatistichour.FieldActiveUser)
  32009. }
  32010. if m.addnew_user != nil {
  32011. fields = append(fields, usagestatistichour.FieldNewUser)
  32012. }
  32013. return fields
  32014. }
  32015. // AddedField returns the numeric value that was incremented/decremented on a field
  32016. // with the given name. The second boolean return value indicates that this field
  32017. // was not set, or was not defined in the schema.
  32018. func (m *UsageStatisticHourMutation) AddedField(name string) (ent.Value, bool) {
  32019. switch name {
  32020. case usagestatistichour.FieldStatus:
  32021. return m.AddedStatus()
  32022. case usagestatistichour.FieldAddtime:
  32023. return m.AddedAddtime()
  32024. case usagestatistichour.FieldType:
  32025. return m.AddedType()
  32026. case usagestatistichour.FieldOrganizationID:
  32027. return m.AddedOrganizationID()
  32028. case usagestatistichour.FieldAiResponse:
  32029. return m.AddedAiResponse()
  32030. case usagestatistichour.FieldSopRun:
  32031. return m.AddedSopRun()
  32032. case usagestatistichour.FieldTotalFriend:
  32033. return m.AddedTotalFriend()
  32034. case usagestatistichour.FieldTotalGroup:
  32035. return m.AddedTotalGroup()
  32036. case usagestatistichour.FieldAccountBalance:
  32037. return m.AddedAccountBalance()
  32038. case usagestatistichour.FieldConsumeToken:
  32039. return m.AddedConsumeToken()
  32040. case usagestatistichour.FieldActiveUser:
  32041. return m.AddedActiveUser()
  32042. case usagestatistichour.FieldNewUser:
  32043. return m.AddedNewUser()
  32044. }
  32045. return nil, false
  32046. }
  32047. // AddField adds the value to the field with the given name. It returns an error if
  32048. // the field is not defined in the schema, or if the type mismatched the field
  32049. // type.
  32050. func (m *UsageStatisticHourMutation) AddField(name string, value ent.Value) error {
  32051. switch name {
  32052. case usagestatistichour.FieldStatus:
  32053. v, ok := value.(int8)
  32054. if !ok {
  32055. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32056. }
  32057. m.AddStatus(v)
  32058. return nil
  32059. case usagestatistichour.FieldAddtime:
  32060. v, ok := value.(int64)
  32061. if !ok {
  32062. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32063. }
  32064. m.AddAddtime(v)
  32065. return nil
  32066. case usagestatistichour.FieldType:
  32067. v, ok := value.(int)
  32068. if !ok {
  32069. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32070. }
  32071. m.AddType(v)
  32072. return nil
  32073. case usagestatistichour.FieldOrganizationID:
  32074. v, ok := value.(int64)
  32075. if !ok {
  32076. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32077. }
  32078. m.AddOrganizationID(v)
  32079. return nil
  32080. case usagestatistichour.FieldAiResponse:
  32081. v, ok := value.(int64)
  32082. if !ok {
  32083. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32084. }
  32085. m.AddAiResponse(v)
  32086. return nil
  32087. case usagestatistichour.FieldSopRun:
  32088. v, ok := value.(int64)
  32089. if !ok {
  32090. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32091. }
  32092. m.AddSopRun(v)
  32093. return nil
  32094. case usagestatistichour.FieldTotalFriend:
  32095. v, ok := value.(int64)
  32096. if !ok {
  32097. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32098. }
  32099. m.AddTotalFriend(v)
  32100. return nil
  32101. case usagestatistichour.FieldTotalGroup:
  32102. v, ok := value.(int64)
  32103. if !ok {
  32104. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32105. }
  32106. m.AddTotalGroup(v)
  32107. return nil
  32108. case usagestatistichour.FieldAccountBalance:
  32109. v, ok := value.(int64)
  32110. if !ok {
  32111. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32112. }
  32113. m.AddAccountBalance(v)
  32114. return nil
  32115. case usagestatistichour.FieldConsumeToken:
  32116. v, ok := value.(int64)
  32117. if !ok {
  32118. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32119. }
  32120. m.AddConsumeToken(v)
  32121. return nil
  32122. case usagestatistichour.FieldActiveUser:
  32123. v, ok := value.(int64)
  32124. if !ok {
  32125. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32126. }
  32127. m.AddActiveUser(v)
  32128. return nil
  32129. case usagestatistichour.FieldNewUser:
  32130. v, ok := value.(int64)
  32131. if !ok {
  32132. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32133. }
  32134. m.AddNewUser(v)
  32135. return nil
  32136. }
  32137. return fmt.Errorf("unknown UsageStatisticHour numeric field %s", name)
  32138. }
  32139. // ClearedFields returns all nullable fields that were cleared during this
  32140. // mutation.
  32141. func (m *UsageStatisticHourMutation) ClearedFields() []string {
  32142. var fields []string
  32143. if m.FieldCleared(usagestatistichour.FieldStatus) {
  32144. fields = append(fields, usagestatistichour.FieldStatus)
  32145. }
  32146. if m.FieldCleared(usagestatistichour.FieldDeletedAt) {
  32147. fields = append(fields, usagestatistichour.FieldDeletedAt)
  32148. }
  32149. if m.FieldCleared(usagestatistichour.FieldBotID) {
  32150. fields = append(fields, usagestatistichour.FieldBotID)
  32151. }
  32152. if m.FieldCleared(usagestatistichour.FieldOrganizationID) {
  32153. fields = append(fields, usagestatistichour.FieldOrganizationID)
  32154. }
  32155. return fields
  32156. }
  32157. // FieldCleared returns a boolean indicating if a field with the given name was
  32158. // cleared in this mutation.
  32159. func (m *UsageStatisticHourMutation) FieldCleared(name string) bool {
  32160. _, ok := m.clearedFields[name]
  32161. return ok
  32162. }
  32163. // ClearField clears the value of the field with the given name. It returns an
  32164. // error if the field is not defined in the schema.
  32165. func (m *UsageStatisticHourMutation) ClearField(name string) error {
  32166. switch name {
  32167. case usagestatistichour.FieldStatus:
  32168. m.ClearStatus()
  32169. return nil
  32170. case usagestatistichour.FieldDeletedAt:
  32171. m.ClearDeletedAt()
  32172. return nil
  32173. case usagestatistichour.FieldBotID:
  32174. m.ClearBotID()
  32175. return nil
  32176. case usagestatistichour.FieldOrganizationID:
  32177. m.ClearOrganizationID()
  32178. return nil
  32179. }
  32180. return fmt.Errorf("unknown UsageStatisticHour nullable field %s", name)
  32181. }
  32182. // ResetField resets all changes in the mutation for the field with the given name.
  32183. // It returns an error if the field is not defined in the schema.
  32184. func (m *UsageStatisticHourMutation) ResetField(name string) error {
  32185. switch name {
  32186. case usagestatistichour.FieldCreatedAt:
  32187. m.ResetCreatedAt()
  32188. return nil
  32189. case usagestatistichour.FieldUpdatedAt:
  32190. m.ResetUpdatedAt()
  32191. return nil
  32192. case usagestatistichour.FieldStatus:
  32193. m.ResetStatus()
  32194. return nil
  32195. case usagestatistichour.FieldDeletedAt:
  32196. m.ResetDeletedAt()
  32197. return nil
  32198. case usagestatistichour.FieldAddtime:
  32199. m.ResetAddtime()
  32200. return nil
  32201. case usagestatistichour.FieldType:
  32202. m.ResetType()
  32203. return nil
  32204. case usagestatistichour.FieldBotID:
  32205. m.ResetBotID()
  32206. return nil
  32207. case usagestatistichour.FieldOrganizationID:
  32208. m.ResetOrganizationID()
  32209. return nil
  32210. case usagestatistichour.FieldAiResponse:
  32211. m.ResetAiResponse()
  32212. return nil
  32213. case usagestatistichour.FieldSopRun:
  32214. m.ResetSopRun()
  32215. return nil
  32216. case usagestatistichour.FieldTotalFriend:
  32217. m.ResetTotalFriend()
  32218. return nil
  32219. case usagestatistichour.FieldTotalGroup:
  32220. m.ResetTotalGroup()
  32221. return nil
  32222. case usagestatistichour.FieldAccountBalance:
  32223. m.ResetAccountBalance()
  32224. return nil
  32225. case usagestatistichour.FieldConsumeToken:
  32226. m.ResetConsumeToken()
  32227. return nil
  32228. case usagestatistichour.FieldActiveUser:
  32229. m.ResetActiveUser()
  32230. return nil
  32231. case usagestatistichour.FieldNewUser:
  32232. m.ResetNewUser()
  32233. return nil
  32234. case usagestatistichour.FieldLabelDist:
  32235. m.ResetLabelDist()
  32236. return nil
  32237. }
  32238. return fmt.Errorf("unknown UsageStatisticHour field %s", name)
  32239. }
  32240. // AddedEdges returns all edge names that were set/added in this mutation.
  32241. func (m *UsageStatisticHourMutation) AddedEdges() []string {
  32242. edges := make([]string, 0, 0)
  32243. return edges
  32244. }
  32245. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  32246. // name in this mutation.
  32247. func (m *UsageStatisticHourMutation) AddedIDs(name string) []ent.Value {
  32248. return nil
  32249. }
  32250. // RemovedEdges returns all edge names that were removed in this mutation.
  32251. func (m *UsageStatisticHourMutation) RemovedEdges() []string {
  32252. edges := make([]string, 0, 0)
  32253. return edges
  32254. }
  32255. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  32256. // the given name in this mutation.
  32257. func (m *UsageStatisticHourMutation) RemovedIDs(name string) []ent.Value {
  32258. return nil
  32259. }
  32260. // ClearedEdges returns all edge names that were cleared in this mutation.
  32261. func (m *UsageStatisticHourMutation) ClearedEdges() []string {
  32262. edges := make([]string, 0, 0)
  32263. return edges
  32264. }
  32265. // EdgeCleared returns a boolean which indicates if the edge with the given name
  32266. // was cleared in this mutation.
  32267. func (m *UsageStatisticHourMutation) EdgeCleared(name string) bool {
  32268. return false
  32269. }
  32270. // ClearEdge clears the value of the edge with the given name. It returns an error
  32271. // if that edge is not defined in the schema.
  32272. func (m *UsageStatisticHourMutation) ClearEdge(name string) error {
  32273. return fmt.Errorf("unknown UsageStatisticHour unique edge %s", name)
  32274. }
  32275. // ResetEdge resets all changes to the edge with the given name in this mutation.
  32276. // It returns an error if the edge is not defined in the schema.
  32277. func (m *UsageStatisticHourMutation) ResetEdge(name string) error {
  32278. return fmt.Errorf("unknown UsageStatisticHour edge %s", name)
  32279. }
  32280. // UsageStatisticMonthMutation represents an operation that mutates the UsageStatisticMonth nodes in the graph.
  32281. type UsageStatisticMonthMutation struct {
  32282. config
  32283. op Op
  32284. typ string
  32285. id *uint64
  32286. created_at *time.Time
  32287. updated_at *time.Time
  32288. status *uint8
  32289. addstatus *int8
  32290. deleted_at *time.Time
  32291. addtime *uint64
  32292. addaddtime *int64
  32293. _type *int
  32294. add_type *int
  32295. bot_id *string
  32296. organization_id *uint64
  32297. addorganization_id *int64
  32298. ai_response *uint64
  32299. addai_response *int64
  32300. sop_run *uint64
  32301. addsop_run *int64
  32302. total_friend *uint64
  32303. addtotal_friend *int64
  32304. total_group *uint64
  32305. addtotal_group *int64
  32306. account_balance *uint64
  32307. addaccount_balance *int64
  32308. consume_token *uint64
  32309. addconsume_token *int64
  32310. active_user *uint64
  32311. addactive_user *int64
  32312. new_user *int64
  32313. addnew_user *int64
  32314. label_dist *[]custom_types.LabelDist
  32315. appendlabel_dist []custom_types.LabelDist
  32316. clearedFields map[string]struct{}
  32317. done bool
  32318. oldValue func(context.Context) (*UsageStatisticMonth, error)
  32319. predicates []predicate.UsageStatisticMonth
  32320. }
  32321. var _ ent.Mutation = (*UsageStatisticMonthMutation)(nil)
  32322. // usagestatisticmonthOption allows management of the mutation configuration using functional options.
  32323. type usagestatisticmonthOption func(*UsageStatisticMonthMutation)
  32324. // newUsageStatisticMonthMutation creates new mutation for the UsageStatisticMonth entity.
  32325. func newUsageStatisticMonthMutation(c config, op Op, opts ...usagestatisticmonthOption) *UsageStatisticMonthMutation {
  32326. m := &UsageStatisticMonthMutation{
  32327. config: c,
  32328. op: op,
  32329. typ: TypeUsageStatisticMonth,
  32330. clearedFields: make(map[string]struct{}),
  32331. }
  32332. for _, opt := range opts {
  32333. opt(m)
  32334. }
  32335. return m
  32336. }
  32337. // withUsageStatisticMonthID sets the ID field of the mutation.
  32338. func withUsageStatisticMonthID(id uint64) usagestatisticmonthOption {
  32339. return func(m *UsageStatisticMonthMutation) {
  32340. var (
  32341. err error
  32342. once sync.Once
  32343. value *UsageStatisticMonth
  32344. )
  32345. m.oldValue = func(ctx context.Context) (*UsageStatisticMonth, error) {
  32346. once.Do(func() {
  32347. if m.done {
  32348. err = errors.New("querying old values post mutation is not allowed")
  32349. } else {
  32350. value, err = m.Client().UsageStatisticMonth.Get(ctx, id)
  32351. }
  32352. })
  32353. return value, err
  32354. }
  32355. m.id = &id
  32356. }
  32357. }
  32358. // withUsageStatisticMonth sets the old UsageStatisticMonth of the mutation.
  32359. func withUsageStatisticMonth(node *UsageStatisticMonth) usagestatisticmonthOption {
  32360. return func(m *UsageStatisticMonthMutation) {
  32361. m.oldValue = func(context.Context) (*UsageStatisticMonth, error) {
  32362. return node, nil
  32363. }
  32364. m.id = &node.ID
  32365. }
  32366. }
  32367. // Client returns a new `ent.Client` from the mutation. If the mutation was
  32368. // executed in a transaction (ent.Tx), a transactional client is returned.
  32369. func (m UsageStatisticMonthMutation) Client() *Client {
  32370. client := &Client{config: m.config}
  32371. client.init()
  32372. return client
  32373. }
  32374. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  32375. // it returns an error otherwise.
  32376. func (m UsageStatisticMonthMutation) Tx() (*Tx, error) {
  32377. if _, ok := m.driver.(*txDriver); !ok {
  32378. return nil, errors.New("ent: mutation is not running in a transaction")
  32379. }
  32380. tx := &Tx{config: m.config}
  32381. tx.init()
  32382. return tx, nil
  32383. }
  32384. // SetID sets the value of the id field. Note that this
  32385. // operation is only accepted on creation of UsageStatisticMonth entities.
  32386. func (m *UsageStatisticMonthMutation) SetID(id uint64) {
  32387. m.id = &id
  32388. }
  32389. // ID returns the ID value in the mutation. Note that the ID is only available
  32390. // if it was provided to the builder or after it was returned from the database.
  32391. func (m *UsageStatisticMonthMutation) ID() (id uint64, exists bool) {
  32392. if m.id == nil {
  32393. return
  32394. }
  32395. return *m.id, true
  32396. }
  32397. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  32398. // That means, if the mutation is applied within a transaction with an isolation level such
  32399. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  32400. // or updated by the mutation.
  32401. func (m *UsageStatisticMonthMutation) IDs(ctx context.Context) ([]uint64, error) {
  32402. switch {
  32403. case m.op.Is(OpUpdateOne | OpDeleteOne):
  32404. id, exists := m.ID()
  32405. if exists {
  32406. return []uint64{id}, nil
  32407. }
  32408. fallthrough
  32409. case m.op.Is(OpUpdate | OpDelete):
  32410. return m.Client().UsageStatisticMonth.Query().Where(m.predicates...).IDs(ctx)
  32411. default:
  32412. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  32413. }
  32414. }
  32415. // SetCreatedAt sets the "created_at" field.
  32416. func (m *UsageStatisticMonthMutation) SetCreatedAt(t time.Time) {
  32417. m.created_at = &t
  32418. }
  32419. // CreatedAt returns the value of the "created_at" field in the mutation.
  32420. func (m *UsageStatisticMonthMutation) CreatedAt() (r time.Time, exists bool) {
  32421. v := m.created_at
  32422. if v == nil {
  32423. return
  32424. }
  32425. return *v, true
  32426. }
  32427. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticMonth entity.
  32428. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  32429. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32430. func (m *UsageStatisticMonthMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  32431. if !m.op.Is(OpUpdateOne) {
  32432. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  32433. }
  32434. if m.id == nil || m.oldValue == nil {
  32435. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  32436. }
  32437. oldValue, err := m.oldValue(ctx)
  32438. if err != nil {
  32439. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  32440. }
  32441. return oldValue.CreatedAt, nil
  32442. }
  32443. // ResetCreatedAt resets all changes to the "created_at" field.
  32444. func (m *UsageStatisticMonthMutation) ResetCreatedAt() {
  32445. m.created_at = nil
  32446. }
  32447. // SetUpdatedAt sets the "updated_at" field.
  32448. func (m *UsageStatisticMonthMutation) SetUpdatedAt(t time.Time) {
  32449. m.updated_at = &t
  32450. }
  32451. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  32452. func (m *UsageStatisticMonthMutation) UpdatedAt() (r time.Time, exists bool) {
  32453. v := m.updated_at
  32454. if v == nil {
  32455. return
  32456. }
  32457. return *v, true
  32458. }
  32459. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticMonth entity.
  32460. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  32461. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32462. func (m *UsageStatisticMonthMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  32463. if !m.op.Is(OpUpdateOne) {
  32464. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  32465. }
  32466. if m.id == nil || m.oldValue == nil {
  32467. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  32468. }
  32469. oldValue, err := m.oldValue(ctx)
  32470. if err != nil {
  32471. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  32472. }
  32473. return oldValue.UpdatedAt, nil
  32474. }
  32475. // ResetUpdatedAt resets all changes to the "updated_at" field.
  32476. func (m *UsageStatisticMonthMutation) ResetUpdatedAt() {
  32477. m.updated_at = nil
  32478. }
  32479. // SetStatus sets the "status" field.
  32480. func (m *UsageStatisticMonthMutation) SetStatus(u uint8) {
  32481. m.status = &u
  32482. m.addstatus = nil
  32483. }
  32484. // Status returns the value of the "status" field in the mutation.
  32485. func (m *UsageStatisticMonthMutation) Status() (r uint8, exists bool) {
  32486. v := m.status
  32487. if v == nil {
  32488. return
  32489. }
  32490. return *v, true
  32491. }
  32492. // OldStatus returns the old "status" field's value of the UsageStatisticMonth entity.
  32493. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  32494. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32495. func (m *UsageStatisticMonthMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  32496. if !m.op.Is(OpUpdateOne) {
  32497. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  32498. }
  32499. if m.id == nil || m.oldValue == nil {
  32500. return v, errors.New("OldStatus requires an ID field in the mutation")
  32501. }
  32502. oldValue, err := m.oldValue(ctx)
  32503. if err != nil {
  32504. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  32505. }
  32506. return oldValue.Status, nil
  32507. }
  32508. // AddStatus adds u to the "status" field.
  32509. func (m *UsageStatisticMonthMutation) AddStatus(u int8) {
  32510. if m.addstatus != nil {
  32511. *m.addstatus += u
  32512. } else {
  32513. m.addstatus = &u
  32514. }
  32515. }
  32516. // AddedStatus returns the value that was added to the "status" field in this mutation.
  32517. func (m *UsageStatisticMonthMutation) AddedStatus() (r int8, exists bool) {
  32518. v := m.addstatus
  32519. if v == nil {
  32520. return
  32521. }
  32522. return *v, true
  32523. }
  32524. // ClearStatus clears the value of the "status" field.
  32525. func (m *UsageStatisticMonthMutation) ClearStatus() {
  32526. m.status = nil
  32527. m.addstatus = nil
  32528. m.clearedFields[usagestatisticmonth.FieldStatus] = struct{}{}
  32529. }
  32530. // StatusCleared returns if the "status" field was cleared in this mutation.
  32531. func (m *UsageStatisticMonthMutation) StatusCleared() bool {
  32532. _, ok := m.clearedFields[usagestatisticmonth.FieldStatus]
  32533. return ok
  32534. }
  32535. // ResetStatus resets all changes to the "status" field.
  32536. func (m *UsageStatisticMonthMutation) ResetStatus() {
  32537. m.status = nil
  32538. m.addstatus = nil
  32539. delete(m.clearedFields, usagestatisticmonth.FieldStatus)
  32540. }
  32541. // SetDeletedAt sets the "deleted_at" field.
  32542. func (m *UsageStatisticMonthMutation) SetDeletedAt(t time.Time) {
  32543. m.deleted_at = &t
  32544. }
  32545. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  32546. func (m *UsageStatisticMonthMutation) DeletedAt() (r time.Time, exists bool) {
  32547. v := m.deleted_at
  32548. if v == nil {
  32549. return
  32550. }
  32551. return *v, true
  32552. }
  32553. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticMonth entity.
  32554. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  32555. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32556. func (m *UsageStatisticMonthMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  32557. if !m.op.Is(OpUpdateOne) {
  32558. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  32559. }
  32560. if m.id == nil || m.oldValue == nil {
  32561. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  32562. }
  32563. oldValue, err := m.oldValue(ctx)
  32564. if err != nil {
  32565. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  32566. }
  32567. return oldValue.DeletedAt, nil
  32568. }
  32569. // ClearDeletedAt clears the value of the "deleted_at" field.
  32570. func (m *UsageStatisticMonthMutation) ClearDeletedAt() {
  32571. m.deleted_at = nil
  32572. m.clearedFields[usagestatisticmonth.FieldDeletedAt] = struct{}{}
  32573. }
  32574. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  32575. func (m *UsageStatisticMonthMutation) DeletedAtCleared() bool {
  32576. _, ok := m.clearedFields[usagestatisticmonth.FieldDeletedAt]
  32577. return ok
  32578. }
  32579. // ResetDeletedAt resets all changes to the "deleted_at" field.
  32580. func (m *UsageStatisticMonthMutation) ResetDeletedAt() {
  32581. m.deleted_at = nil
  32582. delete(m.clearedFields, usagestatisticmonth.FieldDeletedAt)
  32583. }
  32584. // SetAddtime sets the "addtime" field.
  32585. func (m *UsageStatisticMonthMutation) SetAddtime(u uint64) {
  32586. m.addtime = &u
  32587. m.addaddtime = nil
  32588. }
  32589. // Addtime returns the value of the "addtime" field in the mutation.
  32590. func (m *UsageStatisticMonthMutation) Addtime() (r uint64, exists bool) {
  32591. v := m.addtime
  32592. if v == nil {
  32593. return
  32594. }
  32595. return *v, true
  32596. }
  32597. // OldAddtime returns the old "addtime" field's value of the UsageStatisticMonth entity.
  32598. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  32599. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32600. func (m *UsageStatisticMonthMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  32601. if !m.op.Is(OpUpdateOne) {
  32602. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  32603. }
  32604. if m.id == nil || m.oldValue == nil {
  32605. return v, errors.New("OldAddtime requires an ID field in the mutation")
  32606. }
  32607. oldValue, err := m.oldValue(ctx)
  32608. if err != nil {
  32609. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  32610. }
  32611. return oldValue.Addtime, nil
  32612. }
  32613. // AddAddtime adds u to the "addtime" field.
  32614. func (m *UsageStatisticMonthMutation) AddAddtime(u int64) {
  32615. if m.addaddtime != nil {
  32616. *m.addaddtime += u
  32617. } else {
  32618. m.addaddtime = &u
  32619. }
  32620. }
  32621. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  32622. func (m *UsageStatisticMonthMutation) AddedAddtime() (r int64, exists bool) {
  32623. v := m.addaddtime
  32624. if v == nil {
  32625. return
  32626. }
  32627. return *v, true
  32628. }
  32629. // ResetAddtime resets all changes to the "addtime" field.
  32630. func (m *UsageStatisticMonthMutation) ResetAddtime() {
  32631. m.addtime = nil
  32632. m.addaddtime = nil
  32633. }
  32634. // SetType sets the "type" field.
  32635. func (m *UsageStatisticMonthMutation) SetType(i int) {
  32636. m._type = &i
  32637. m.add_type = nil
  32638. }
  32639. // GetType returns the value of the "type" field in the mutation.
  32640. func (m *UsageStatisticMonthMutation) GetType() (r int, exists bool) {
  32641. v := m._type
  32642. if v == nil {
  32643. return
  32644. }
  32645. return *v, true
  32646. }
  32647. // OldType returns the old "type" field's value of the UsageStatisticMonth entity.
  32648. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  32649. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32650. func (m *UsageStatisticMonthMutation) OldType(ctx context.Context) (v int, err error) {
  32651. if !m.op.Is(OpUpdateOne) {
  32652. return v, errors.New("OldType is only allowed on UpdateOne operations")
  32653. }
  32654. if m.id == nil || m.oldValue == nil {
  32655. return v, errors.New("OldType requires an ID field in the mutation")
  32656. }
  32657. oldValue, err := m.oldValue(ctx)
  32658. if err != nil {
  32659. return v, fmt.Errorf("querying old value for OldType: %w", err)
  32660. }
  32661. return oldValue.Type, nil
  32662. }
  32663. // AddType adds i to the "type" field.
  32664. func (m *UsageStatisticMonthMutation) AddType(i int) {
  32665. if m.add_type != nil {
  32666. *m.add_type += i
  32667. } else {
  32668. m.add_type = &i
  32669. }
  32670. }
  32671. // AddedType returns the value that was added to the "type" field in this mutation.
  32672. func (m *UsageStatisticMonthMutation) AddedType() (r int, exists bool) {
  32673. v := m.add_type
  32674. if v == nil {
  32675. return
  32676. }
  32677. return *v, true
  32678. }
  32679. // ResetType resets all changes to the "type" field.
  32680. func (m *UsageStatisticMonthMutation) ResetType() {
  32681. m._type = nil
  32682. m.add_type = nil
  32683. }
  32684. // SetBotID sets the "bot_id" field.
  32685. func (m *UsageStatisticMonthMutation) SetBotID(s string) {
  32686. m.bot_id = &s
  32687. }
  32688. // BotID returns the value of the "bot_id" field in the mutation.
  32689. func (m *UsageStatisticMonthMutation) BotID() (r string, exists bool) {
  32690. v := m.bot_id
  32691. if v == nil {
  32692. return
  32693. }
  32694. return *v, true
  32695. }
  32696. // OldBotID returns the old "bot_id" field's value of the UsageStatisticMonth entity.
  32697. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  32698. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32699. func (m *UsageStatisticMonthMutation) OldBotID(ctx context.Context) (v string, err error) {
  32700. if !m.op.Is(OpUpdateOne) {
  32701. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  32702. }
  32703. if m.id == nil || m.oldValue == nil {
  32704. return v, errors.New("OldBotID requires an ID field in the mutation")
  32705. }
  32706. oldValue, err := m.oldValue(ctx)
  32707. if err != nil {
  32708. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  32709. }
  32710. return oldValue.BotID, nil
  32711. }
  32712. // ClearBotID clears the value of the "bot_id" field.
  32713. func (m *UsageStatisticMonthMutation) ClearBotID() {
  32714. m.bot_id = nil
  32715. m.clearedFields[usagestatisticmonth.FieldBotID] = struct{}{}
  32716. }
  32717. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  32718. func (m *UsageStatisticMonthMutation) BotIDCleared() bool {
  32719. _, ok := m.clearedFields[usagestatisticmonth.FieldBotID]
  32720. return ok
  32721. }
  32722. // ResetBotID resets all changes to the "bot_id" field.
  32723. func (m *UsageStatisticMonthMutation) ResetBotID() {
  32724. m.bot_id = nil
  32725. delete(m.clearedFields, usagestatisticmonth.FieldBotID)
  32726. }
  32727. // SetOrganizationID sets the "organization_id" field.
  32728. func (m *UsageStatisticMonthMutation) SetOrganizationID(u uint64) {
  32729. m.organization_id = &u
  32730. m.addorganization_id = nil
  32731. }
  32732. // OrganizationID returns the value of the "organization_id" field in the mutation.
  32733. func (m *UsageStatisticMonthMutation) OrganizationID() (r uint64, exists bool) {
  32734. v := m.organization_id
  32735. if v == nil {
  32736. return
  32737. }
  32738. return *v, true
  32739. }
  32740. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticMonth entity.
  32741. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  32742. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32743. func (m *UsageStatisticMonthMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  32744. if !m.op.Is(OpUpdateOne) {
  32745. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  32746. }
  32747. if m.id == nil || m.oldValue == nil {
  32748. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  32749. }
  32750. oldValue, err := m.oldValue(ctx)
  32751. if err != nil {
  32752. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  32753. }
  32754. return oldValue.OrganizationID, nil
  32755. }
  32756. // AddOrganizationID adds u to the "organization_id" field.
  32757. func (m *UsageStatisticMonthMutation) AddOrganizationID(u int64) {
  32758. if m.addorganization_id != nil {
  32759. *m.addorganization_id += u
  32760. } else {
  32761. m.addorganization_id = &u
  32762. }
  32763. }
  32764. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  32765. func (m *UsageStatisticMonthMutation) AddedOrganizationID() (r int64, exists bool) {
  32766. v := m.addorganization_id
  32767. if v == nil {
  32768. return
  32769. }
  32770. return *v, true
  32771. }
  32772. // ClearOrganizationID clears the value of the "organization_id" field.
  32773. func (m *UsageStatisticMonthMutation) ClearOrganizationID() {
  32774. m.organization_id = nil
  32775. m.addorganization_id = nil
  32776. m.clearedFields[usagestatisticmonth.FieldOrganizationID] = struct{}{}
  32777. }
  32778. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  32779. func (m *UsageStatisticMonthMutation) OrganizationIDCleared() bool {
  32780. _, ok := m.clearedFields[usagestatisticmonth.FieldOrganizationID]
  32781. return ok
  32782. }
  32783. // ResetOrganizationID resets all changes to the "organization_id" field.
  32784. func (m *UsageStatisticMonthMutation) ResetOrganizationID() {
  32785. m.organization_id = nil
  32786. m.addorganization_id = nil
  32787. delete(m.clearedFields, usagestatisticmonth.FieldOrganizationID)
  32788. }
  32789. // SetAiResponse sets the "ai_response" field.
  32790. func (m *UsageStatisticMonthMutation) SetAiResponse(u uint64) {
  32791. m.ai_response = &u
  32792. m.addai_response = nil
  32793. }
  32794. // AiResponse returns the value of the "ai_response" field in the mutation.
  32795. func (m *UsageStatisticMonthMutation) AiResponse() (r uint64, exists bool) {
  32796. v := m.ai_response
  32797. if v == nil {
  32798. return
  32799. }
  32800. return *v, true
  32801. }
  32802. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticMonth entity.
  32803. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  32804. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32805. func (m *UsageStatisticMonthMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  32806. if !m.op.Is(OpUpdateOne) {
  32807. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  32808. }
  32809. if m.id == nil || m.oldValue == nil {
  32810. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  32811. }
  32812. oldValue, err := m.oldValue(ctx)
  32813. if err != nil {
  32814. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  32815. }
  32816. return oldValue.AiResponse, nil
  32817. }
  32818. // AddAiResponse adds u to the "ai_response" field.
  32819. func (m *UsageStatisticMonthMutation) AddAiResponse(u int64) {
  32820. if m.addai_response != nil {
  32821. *m.addai_response += u
  32822. } else {
  32823. m.addai_response = &u
  32824. }
  32825. }
  32826. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  32827. func (m *UsageStatisticMonthMutation) AddedAiResponse() (r int64, exists bool) {
  32828. v := m.addai_response
  32829. if v == nil {
  32830. return
  32831. }
  32832. return *v, true
  32833. }
  32834. // ResetAiResponse resets all changes to the "ai_response" field.
  32835. func (m *UsageStatisticMonthMutation) ResetAiResponse() {
  32836. m.ai_response = nil
  32837. m.addai_response = nil
  32838. }
  32839. // SetSopRun sets the "sop_run" field.
  32840. func (m *UsageStatisticMonthMutation) SetSopRun(u uint64) {
  32841. m.sop_run = &u
  32842. m.addsop_run = nil
  32843. }
  32844. // SopRun returns the value of the "sop_run" field in the mutation.
  32845. func (m *UsageStatisticMonthMutation) SopRun() (r uint64, exists bool) {
  32846. v := m.sop_run
  32847. if v == nil {
  32848. return
  32849. }
  32850. return *v, true
  32851. }
  32852. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticMonth entity.
  32853. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  32854. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32855. func (m *UsageStatisticMonthMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  32856. if !m.op.Is(OpUpdateOne) {
  32857. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  32858. }
  32859. if m.id == nil || m.oldValue == nil {
  32860. return v, errors.New("OldSopRun requires an ID field in the mutation")
  32861. }
  32862. oldValue, err := m.oldValue(ctx)
  32863. if err != nil {
  32864. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  32865. }
  32866. return oldValue.SopRun, nil
  32867. }
  32868. // AddSopRun adds u to the "sop_run" field.
  32869. func (m *UsageStatisticMonthMutation) AddSopRun(u int64) {
  32870. if m.addsop_run != nil {
  32871. *m.addsop_run += u
  32872. } else {
  32873. m.addsop_run = &u
  32874. }
  32875. }
  32876. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  32877. func (m *UsageStatisticMonthMutation) AddedSopRun() (r int64, exists bool) {
  32878. v := m.addsop_run
  32879. if v == nil {
  32880. return
  32881. }
  32882. return *v, true
  32883. }
  32884. // ResetSopRun resets all changes to the "sop_run" field.
  32885. func (m *UsageStatisticMonthMutation) ResetSopRun() {
  32886. m.sop_run = nil
  32887. m.addsop_run = nil
  32888. }
  32889. // SetTotalFriend sets the "total_friend" field.
  32890. func (m *UsageStatisticMonthMutation) SetTotalFriend(u uint64) {
  32891. m.total_friend = &u
  32892. m.addtotal_friend = nil
  32893. }
  32894. // TotalFriend returns the value of the "total_friend" field in the mutation.
  32895. func (m *UsageStatisticMonthMutation) TotalFriend() (r uint64, exists bool) {
  32896. v := m.total_friend
  32897. if v == nil {
  32898. return
  32899. }
  32900. return *v, true
  32901. }
  32902. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticMonth entity.
  32903. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  32904. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32905. func (m *UsageStatisticMonthMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  32906. if !m.op.Is(OpUpdateOne) {
  32907. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  32908. }
  32909. if m.id == nil || m.oldValue == nil {
  32910. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  32911. }
  32912. oldValue, err := m.oldValue(ctx)
  32913. if err != nil {
  32914. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  32915. }
  32916. return oldValue.TotalFriend, nil
  32917. }
  32918. // AddTotalFriend adds u to the "total_friend" field.
  32919. func (m *UsageStatisticMonthMutation) AddTotalFriend(u int64) {
  32920. if m.addtotal_friend != nil {
  32921. *m.addtotal_friend += u
  32922. } else {
  32923. m.addtotal_friend = &u
  32924. }
  32925. }
  32926. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  32927. func (m *UsageStatisticMonthMutation) AddedTotalFriend() (r int64, exists bool) {
  32928. v := m.addtotal_friend
  32929. if v == nil {
  32930. return
  32931. }
  32932. return *v, true
  32933. }
  32934. // ResetTotalFriend resets all changes to the "total_friend" field.
  32935. func (m *UsageStatisticMonthMutation) ResetTotalFriend() {
  32936. m.total_friend = nil
  32937. m.addtotal_friend = nil
  32938. }
  32939. // SetTotalGroup sets the "total_group" field.
  32940. func (m *UsageStatisticMonthMutation) SetTotalGroup(u uint64) {
  32941. m.total_group = &u
  32942. m.addtotal_group = nil
  32943. }
  32944. // TotalGroup returns the value of the "total_group" field in the mutation.
  32945. func (m *UsageStatisticMonthMutation) TotalGroup() (r uint64, exists bool) {
  32946. v := m.total_group
  32947. if v == nil {
  32948. return
  32949. }
  32950. return *v, true
  32951. }
  32952. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticMonth entity.
  32953. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  32954. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32955. func (m *UsageStatisticMonthMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  32956. if !m.op.Is(OpUpdateOne) {
  32957. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  32958. }
  32959. if m.id == nil || m.oldValue == nil {
  32960. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  32961. }
  32962. oldValue, err := m.oldValue(ctx)
  32963. if err != nil {
  32964. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  32965. }
  32966. return oldValue.TotalGroup, nil
  32967. }
  32968. // AddTotalGroup adds u to the "total_group" field.
  32969. func (m *UsageStatisticMonthMutation) AddTotalGroup(u int64) {
  32970. if m.addtotal_group != nil {
  32971. *m.addtotal_group += u
  32972. } else {
  32973. m.addtotal_group = &u
  32974. }
  32975. }
  32976. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  32977. func (m *UsageStatisticMonthMutation) AddedTotalGroup() (r int64, exists bool) {
  32978. v := m.addtotal_group
  32979. if v == nil {
  32980. return
  32981. }
  32982. return *v, true
  32983. }
  32984. // ResetTotalGroup resets all changes to the "total_group" field.
  32985. func (m *UsageStatisticMonthMutation) ResetTotalGroup() {
  32986. m.total_group = nil
  32987. m.addtotal_group = nil
  32988. }
  32989. // SetAccountBalance sets the "account_balance" field.
  32990. func (m *UsageStatisticMonthMutation) SetAccountBalance(u uint64) {
  32991. m.account_balance = &u
  32992. m.addaccount_balance = nil
  32993. }
  32994. // AccountBalance returns the value of the "account_balance" field in the mutation.
  32995. func (m *UsageStatisticMonthMutation) AccountBalance() (r uint64, exists bool) {
  32996. v := m.account_balance
  32997. if v == nil {
  32998. return
  32999. }
  33000. return *v, true
  33001. }
  33002. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticMonth entity.
  33003. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  33004. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33005. func (m *UsageStatisticMonthMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  33006. if !m.op.Is(OpUpdateOne) {
  33007. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  33008. }
  33009. if m.id == nil || m.oldValue == nil {
  33010. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  33011. }
  33012. oldValue, err := m.oldValue(ctx)
  33013. if err != nil {
  33014. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  33015. }
  33016. return oldValue.AccountBalance, nil
  33017. }
  33018. // AddAccountBalance adds u to the "account_balance" field.
  33019. func (m *UsageStatisticMonthMutation) AddAccountBalance(u int64) {
  33020. if m.addaccount_balance != nil {
  33021. *m.addaccount_balance += u
  33022. } else {
  33023. m.addaccount_balance = &u
  33024. }
  33025. }
  33026. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  33027. func (m *UsageStatisticMonthMutation) AddedAccountBalance() (r int64, exists bool) {
  33028. v := m.addaccount_balance
  33029. if v == nil {
  33030. return
  33031. }
  33032. return *v, true
  33033. }
  33034. // ResetAccountBalance resets all changes to the "account_balance" field.
  33035. func (m *UsageStatisticMonthMutation) ResetAccountBalance() {
  33036. m.account_balance = nil
  33037. m.addaccount_balance = nil
  33038. }
  33039. // SetConsumeToken sets the "consume_token" field.
  33040. func (m *UsageStatisticMonthMutation) SetConsumeToken(u uint64) {
  33041. m.consume_token = &u
  33042. m.addconsume_token = nil
  33043. }
  33044. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  33045. func (m *UsageStatisticMonthMutation) ConsumeToken() (r uint64, exists bool) {
  33046. v := m.consume_token
  33047. if v == nil {
  33048. return
  33049. }
  33050. return *v, true
  33051. }
  33052. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticMonth entity.
  33053. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  33054. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33055. func (m *UsageStatisticMonthMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  33056. if !m.op.Is(OpUpdateOne) {
  33057. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  33058. }
  33059. if m.id == nil || m.oldValue == nil {
  33060. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  33061. }
  33062. oldValue, err := m.oldValue(ctx)
  33063. if err != nil {
  33064. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  33065. }
  33066. return oldValue.ConsumeToken, nil
  33067. }
  33068. // AddConsumeToken adds u to the "consume_token" field.
  33069. func (m *UsageStatisticMonthMutation) AddConsumeToken(u int64) {
  33070. if m.addconsume_token != nil {
  33071. *m.addconsume_token += u
  33072. } else {
  33073. m.addconsume_token = &u
  33074. }
  33075. }
  33076. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  33077. func (m *UsageStatisticMonthMutation) AddedConsumeToken() (r int64, exists bool) {
  33078. v := m.addconsume_token
  33079. if v == nil {
  33080. return
  33081. }
  33082. return *v, true
  33083. }
  33084. // ResetConsumeToken resets all changes to the "consume_token" field.
  33085. func (m *UsageStatisticMonthMutation) ResetConsumeToken() {
  33086. m.consume_token = nil
  33087. m.addconsume_token = nil
  33088. }
  33089. // SetActiveUser sets the "active_user" field.
  33090. func (m *UsageStatisticMonthMutation) SetActiveUser(u uint64) {
  33091. m.active_user = &u
  33092. m.addactive_user = nil
  33093. }
  33094. // ActiveUser returns the value of the "active_user" field in the mutation.
  33095. func (m *UsageStatisticMonthMutation) ActiveUser() (r uint64, exists bool) {
  33096. v := m.active_user
  33097. if v == nil {
  33098. return
  33099. }
  33100. return *v, true
  33101. }
  33102. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticMonth entity.
  33103. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  33104. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33105. func (m *UsageStatisticMonthMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  33106. if !m.op.Is(OpUpdateOne) {
  33107. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  33108. }
  33109. if m.id == nil || m.oldValue == nil {
  33110. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  33111. }
  33112. oldValue, err := m.oldValue(ctx)
  33113. if err != nil {
  33114. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  33115. }
  33116. return oldValue.ActiveUser, nil
  33117. }
  33118. // AddActiveUser adds u to the "active_user" field.
  33119. func (m *UsageStatisticMonthMutation) AddActiveUser(u int64) {
  33120. if m.addactive_user != nil {
  33121. *m.addactive_user += u
  33122. } else {
  33123. m.addactive_user = &u
  33124. }
  33125. }
  33126. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  33127. func (m *UsageStatisticMonthMutation) AddedActiveUser() (r int64, exists bool) {
  33128. v := m.addactive_user
  33129. if v == nil {
  33130. return
  33131. }
  33132. return *v, true
  33133. }
  33134. // ResetActiveUser resets all changes to the "active_user" field.
  33135. func (m *UsageStatisticMonthMutation) ResetActiveUser() {
  33136. m.active_user = nil
  33137. m.addactive_user = nil
  33138. }
  33139. // SetNewUser sets the "new_user" field.
  33140. func (m *UsageStatisticMonthMutation) SetNewUser(i int64) {
  33141. m.new_user = &i
  33142. m.addnew_user = nil
  33143. }
  33144. // NewUser returns the value of the "new_user" field in the mutation.
  33145. func (m *UsageStatisticMonthMutation) NewUser() (r int64, exists bool) {
  33146. v := m.new_user
  33147. if v == nil {
  33148. return
  33149. }
  33150. return *v, true
  33151. }
  33152. // OldNewUser returns the old "new_user" field's value of the UsageStatisticMonth entity.
  33153. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  33154. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33155. func (m *UsageStatisticMonthMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  33156. if !m.op.Is(OpUpdateOne) {
  33157. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  33158. }
  33159. if m.id == nil || m.oldValue == nil {
  33160. return v, errors.New("OldNewUser requires an ID field in the mutation")
  33161. }
  33162. oldValue, err := m.oldValue(ctx)
  33163. if err != nil {
  33164. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  33165. }
  33166. return oldValue.NewUser, nil
  33167. }
  33168. // AddNewUser adds i to the "new_user" field.
  33169. func (m *UsageStatisticMonthMutation) AddNewUser(i int64) {
  33170. if m.addnew_user != nil {
  33171. *m.addnew_user += i
  33172. } else {
  33173. m.addnew_user = &i
  33174. }
  33175. }
  33176. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  33177. func (m *UsageStatisticMonthMutation) AddedNewUser() (r int64, exists bool) {
  33178. v := m.addnew_user
  33179. if v == nil {
  33180. return
  33181. }
  33182. return *v, true
  33183. }
  33184. // ResetNewUser resets all changes to the "new_user" field.
  33185. func (m *UsageStatisticMonthMutation) ResetNewUser() {
  33186. m.new_user = nil
  33187. m.addnew_user = nil
  33188. }
  33189. // SetLabelDist sets the "label_dist" field.
  33190. func (m *UsageStatisticMonthMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  33191. m.label_dist = &ctd
  33192. m.appendlabel_dist = nil
  33193. }
  33194. // LabelDist returns the value of the "label_dist" field in the mutation.
  33195. func (m *UsageStatisticMonthMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  33196. v := m.label_dist
  33197. if v == nil {
  33198. return
  33199. }
  33200. return *v, true
  33201. }
  33202. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticMonth entity.
  33203. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  33204. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33205. func (m *UsageStatisticMonthMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  33206. if !m.op.Is(OpUpdateOne) {
  33207. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  33208. }
  33209. if m.id == nil || m.oldValue == nil {
  33210. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  33211. }
  33212. oldValue, err := m.oldValue(ctx)
  33213. if err != nil {
  33214. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  33215. }
  33216. return oldValue.LabelDist, nil
  33217. }
  33218. // AppendLabelDist adds ctd to the "label_dist" field.
  33219. func (m *UsageStatisticMonthMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  33220. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  33221. }
  33222. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  33223. func (m *UsageStatisticMonthMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  33224. if len(m.appendlabel_dist) == 0 {
  33225. return nil, false
  33226. }
  33227. return m.appendlabel_dist, true
  33228. }
  33229. // ResetLabelDist resets all changes to the "label_dist" field.
  33230. func (m *UsageStatisticMonthMutation) ResetLabelDist() {
  33231. m.label_dist = nil
  33232. m.appendlabel_dist = nil
  33233. }
  33234. // Where appends a list predicates to the UsageStatisticMonthMutation builder.
  33235. func (m *UsageStatisticMonthMutation) Where(ps ...predicate.UsageStatisticMonth) {
  33236. m.predicates = append(m.predicates, ps...)
  33237. }
  33238. // WhereP appends storage-level predicates to the UsageStatisticMonthMutation builder. Using this method,
  33239. // users can use type-assertion to append predicates that do not depend on any generated package.
  33240. func (m *UsageStatisticMonthMutation) WhereP(ps ...func(*sql.Selector)) {
  33241. p := make([]predicate.UsageStatisticMonth, len(ps))
  33242. for i := range ps {
  33243. p[i] = ps[i]
  33244. }
  33245. m.Where(p...)
  33246. }
  33247. // Op returns the operation name.
  33248. func (m *UsageStatisticMonthMutation) Op() Op {
  33249. return m.op
  33250. }
  33251. // SetOp allows setting the mutation operation.
  33252. func (m *UsageStatisticMonthMutation) SetOp(op Op) {
  33253. m.op = op
  33254. }
  33255. // Type returns the node type of this mutation (UsageStatisticMonth).
  33256. func (m *UsageStatisticMonthMutation) Type() string {
  33257. return m.typ
  33258. }
  33259. // Fields returns all fields that were changed during this mutation. Note that in
  33260. // order to get all numeric fields that were incremented/decremented, call
  33261. // AddedFields().
  33262. func (m *UsageStatisticMonthMutation) Fields() []string {
  33263. fields := make([]string, 0, 17)
  33264. if m.created_at != nil {
  33265. fields = append(fields, usagestatisticmonth.FieldCreatedAt)
  33266. }
  33267. if m.updated_at != nil {
  33268. fields = append(fields, usagestatisticmonth.FieldUpdatedAt)
  33269. }
  33270. if m.status != nil {
  33271. fields = append(fields, usagestatisticmonth.FieldStatus)
  33272. }
  33273. if m.deleted_at != nil {
  33274. fields = append(fields, usagestatisticmonth.FieldDeletedAt)
  33275. }
  33276. if m.addtime != nil {
  33277. fields = append(fields, usagestatisticmonth.FieldAddtime)
  33278. }
  33279. if m._type != nil {
  33280. fields = append(fields, usagestatisticmonth.FieldType)
  33281. }
  33282. if m.bot_id != nil {
  33283. fields = append(fields, usagestatisticmonth.FieldBotID)
  33284. }
  33285. if m.organization_id != nil {
  33286. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  33287. }
  33288. if m.ai_response != nil {
  33289. fields = append(fields, usagestatisticmonth.FieldAiResponse)
  33290. }
  33291. if m.sop_run != nil {
  33292. fields = append(fields, usagestatisticmonth.FieldSopRun)
  33293. }
  33294. if m.total_friend != nil {
  33295. fields = append(fields, usagestatisticmonth.FieldTotalFriend)
  33296. }
  33297. if m.total_group != nil {
  33298. fields = append(fields, usagestatisticmonth.FieldTotalGroup)
  33299. }
  33300. if m.account_balance != nil {
  33301. fields = append(fields, usagestatisticmonth.FieldAccountBalance)
  33302. }
  33303. if m.consume_token != nil {
  33304. fields = append(fields, usagestatisticmonth.FieldConsumeToken)
  33305. }
  33306. if m.active_user != nil {
  33307. fields = append(fields, usagestatisticmonth.FieldActiveUser)
  33308. }
  33309. if m.new_user != nil {
  33310. fields = append(fields, usagestatisticmonth.FieldNewUser)
  33311. }
  33312. if m.label_dist != nil {
  33313. fields = append(fields, usagestatisticmonth.FieldLabelDist)
  33314. }
  33315. return fields
  33316. }
  33317. // Field returns the value of a field with the given name. The second boolean
  33318. // return value indicates that this field was not set, or was not defined in the
  33319. // schema.
  33320. func (m *UsageStatisticMonthMutation) Field(name string) (ent.Value, bool) {
  33321. switch name {
  33322. case usagestatisticmonth.FieldCreatedAt:
  33323. return m.CreatedAt()
  33324. case usagestatisticmonth.FieldUpdatedAt:
  33325. return m.UpdatedAt()
  33326. case usagestatisticmonth.FieldStatus:
  33327. return m.Status()
  33328. case usagestatisticmonth.FieldDeletedAt:
  33329. return m.DeletedAt()
  33330. case usagestatisticmonth.FieldAddtime:
  33331. return m.Addtime()
  33332. case usagestatisticmonth.FieldType:
  33333. return m.GetType()
  33334. case usagestatisticmonth.FieldBotID:
  33335. return m.BotID()
  33336. case usagestatisticmonth.FieldOrganizationID:
  33337. return m.OrganizationID()
  33338. case usagestatisticmonth.FieldAiResponse:
  33339. return m.AiResponse()
  33340. case usagestatisticmonth.FieldSopRun:
  33341. return m.SopRun()
  33342. case usagestatisticmonth.FieldTotalFriend:
  33343. return m.TotalFriend()
  33344. case usagestatisticmonth.FieldTotalGroup:
  33345. return m.TotalGroup()
  33346. case usagestatisticmonth.FieldAccountBalance:
  33347. return m.AccountBalance()
  33348. case usagestatisticmonth.FieldConsumeToken:
  33349. return m.ConsumeToken()
  33350. case usagestatisticmonth.FieldActiveUser:
  33351. return m.ActiveUser()
  33352. case usagestatisticmonth.FieldNewUser:
  33353. return m.NewUser()
  33354. case usagestatisticmonth.FieldLabelDist:
  33355. return m.LabelDist()
  33356. }
  33357. return nil, false
  33358. }
  33359. // OldField returns the old value of the field from the database. An error is
  33360. // returned if the mutation operation is not UpdateOne, or the query to the
  33361. // database failed.
  33362. func (m *UsageStatisticMonthMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  33363. switch name {
  33364. case usagestatisticmonth.FieldCreatedAt:
  33365. return m.OldCreatedAt(ctx)
  33366. case usagestatisticmonth.FieldUpdatedAt:
  33367. return m.OldUpdatedAt(ctx)
  33368. case usagestatisticmonth.FieldStatus:
  33369. return m.OldStatus(ctx)
  33370. case usagestatisticmonth.FieldDeletedAt:
  33371. return m.OldDeletedAt(ctx)
  33372. case usagestatisticmonth.FieldAddtime:
  33373. return m.OldAddtime(ctx)
  33374. case usagestatisticmonth.FieldType:
  33375. return m.OldType(ctx)
  33376. case usagestatisticmonth.FieldBotID:
  33377. return m.OldBotID(ctx)
  33378. case usagestatisticmonth.FieldOrganizationID:
  33379. return m.OldOrganizationID(ctx)
  33380. case usagestatisticmonth.FieldAiResponse:
  33381. return m.OldAiResponse(ctx)
  33382. case usagestatisticmonth.FieldSopRun:
  33383. return m.OldSopRun(ctx)
  33384. case usagestatisticmonth.FieldTotalFriend:
  33385. return m.OldTotalFriend(ctx)
  33386. case usagestatisticmonth.FieldTotalGroup:
  33387. return m.OldTotalGroup(ctx)
  33388. case usagestatisticmonth.FieldAccountBalance:
  33389. return m.OldAccountBalance(ctx)
  33390. case usagestatisticmonth.FieldConsumeToken:
  33391. return m.OldConsumeToken(ctx)
  33392. case usagestatisticmonth.FieldActiveUser:
  33393. return m.OldActiveUser(ctx)
  33394. case usagestatisticmonth.FieldNewUser:
  33395. return m.OldNewUser(ctx)
  33396. case usagestatisticmonth.FieldLabelDist:
  33397. return m.OldLabelDist(ctx)
  33398. }
  33399. return nil, fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  33400. }
  33401. // SetField sets the value of a 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) SetField(name string, value ent.Value) error {
  33405. switch name {
  33406. case usagestatisticmonth.FieldCreatedAt:
  33407. v, ok := value.(time.Time)
  33408. if !ok {
  33409. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33410. }
  33411. m.SetCreatedAt(v)
  33412. return nil
  33413. case usagestatisticmonth.FieldUpdatedAt:
  33414. v, ok := value.(time.Time)
  33415. if !ok {
  33416. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33417. }
  33418. m.SetUpdatedAt(v)
  33419. return nil
  33420. case usagestatisticmonth.FieldStatus:
  33421. v, ok := value.(uint8)
  33422. if !ok {
  33423. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33424. }
  33425. m.SetStatus(v)
  33426. return nil
  33427. case usagestatisticmonth.FieldDeletedAt:
  33428. v, ok := value.(time.Time)
  33429. if !ok {
  33430. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33431. }
  33432. m.SetDeletedAt(v)
  33433. return nil
  33434. case usagestatisticmonth.FieldAddtime:
  33435. v, ok := value.(uint64)
  33436. if !ok {
  33437. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33438. }
  33439. m.SetAddtime(v)
  33440. return nil
  33441. case usagestatisticmonth.FieldType:
  33442. v, ok := value.(int)
  33443. if !ok {
  33444. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33445. }
  33446. m.SetType(v)
  33447. return nil
  33448. case usagestatisticmonth.FieldBotID:
  33449. v, ok := value.(string)
  33450. if !ok {
  33451. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33452. }
  33453. m.SetBotID(v)
  33454. return nil
  33455. case usagestatisticmonth.FieldOrganizationID:
  33456. v, ok := value.(uint64)
  33457. if !ok {
  33458. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33459. }
  33460. m.SetOrganizationID(v)
  33461. return nil
  33462. case usagestatisticmonth.FieldAiResponse:
  33463. v, ok := value.(uint64)
  33464. if !ok {
  33465. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33466. }
  33467. m.SetAiResponse(v)
  33468. return nil
  33469. case usagestatisticmonth.FieldSopRun:
  33470. v, ok := value.(uint64)
  33471. if !ok {
  33472. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33473. }
  33474. m.SetSopRun(v)
  33475. return nil
  33476. case usagestatisticmonth.FieldTotalFriend:
  33477. v, ok := value.(uint64)
  33478. if !ok {
  33479. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33480. }
  33481. m.SetTotalFriend(v)
  33482. return nil
  33483. case usagestatisticmonth.FieldTotalGroup:
  33484. v, ok := value.(uint64)
  33485. if !ok {
  33486. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33487. }
  33488. m.SetTotalGroup(v)
  33489. return nil
  33490. case usagestatisticmonth.FieldAccountBalance:
  33491. v, ok := value.(uint64)
  33492. if !ok {
  33493. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33494. }
  33495. m.SetAccountBalance(v)
  33496. return nil
  33497. case usagestatisticmonth.FieldConsumeToken:
  33498. v, ok := value.(uint64)
  33499. if !ok {
  33500. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33501. }
  33502. m.SetConsumeToken(v)
  33503. return nil
  33504. case usagestatisticmonth.FieldActiveUser:
  33505. v, ok := value.(uint64)
  33506. if !ok {
  33507. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33508. }
  33509. m.SetActiveUser(v)
  33510. return nil
  33511. case usagestatisticmonth.FieldNewUser:
  33512. v, ok := value.(int64)
  33513. if !ok {
  33514. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33515. }
  33516. m.SetNewUser(v)
  33517. return nil
  33518. case usagestatisticmonth.FieldLabelDist:
  33519. v, ok := value.([]custom_types.LabelDist)
  33520. if !ok {
  33521. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33522. }
  33523. m.SetLabelDist(v)
  33524. return nil
  33525. }
  33526. return fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  33527. }
  33528. // AddedFields returns all numeric fields that were incremented/decremented during
  33529. // this mutation.
  33530. func (m *UsageStatisticMonthMutation) AddedFields() []string {
  33531. var fields []string
  33532. if m.addstatus != nil {
  33533. fields = append(fields, usagestatisticmonth.FieldStatus)
  33534. }
  33535. if m.addaddtime != nil {
  33536. fields = append(fields, usagestatisticmonth.FieldAddtime)
  33537. }
  33538. if m.add_type != nil {
  33539. fields = append(fields, usagestatisticmonth.FieldType)
  33540. }
  33541. if m.addorganization_id != nil {
  33542. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  33543. }
  33544. if m.addai_response != nil {
  33545. fields = append(fields, usagestatisticmonth.FieldAiResponse)
  33546. }
  33547. if m.addsop_run != nil {
  33548. fields = append(fields, usagestatisticmonth.FieldSopRun)
  33549. }
  33550. if m.addtotal_friend != nil {
  33551. fields = append(fields, usagestatisticmonth.FieldTotalFriend)
  33552. }
  33553. if m.addtotal_group != nil {
  33554. fields = append(fields, usagestatisticmonth.FieldTotalGroup)
  33555. }
  33556. if m.addaccount_balance != nil {
  33557. fields = append(fields, usagestatisticmonth.FieldAccountBalance)
  33558. }
  33559. if m.addconsume_token != nil {
  33560. fields = append(fields, usagestatisticmonth.FieldConsumeToken)
  33561. }
  33562. if m.addactive_user != nil {
  33563. fields = append(fields, usagestatisticmonth.FieldActiveUser)
  33564. }
  33565. if m.addnew_user != nil {
  33566. fields = append(fields, usagestatisticmonth.FieldNewUser)
  33567. }
  33568. return fields
  33569. }
  33570. // AddedField returns the numeric value that was incremented/decremented on a field
  33571. // with the given name. The second boolean return value indicates that this field
  33572. // was not set, or was not defined in the schema.
  33573. func (m *UsageStatisticMonthMutation) AddedField(name string) (ent.Value, bool) {
  33574. switch name {
  33575. case usagestatisticmonth.FieldStatus:
  33576. return m.AddedStatus()
  33577. case usagestatisticmonth.FieldAddtime:
  33578. return m.AddedAddtime()
  33579. case usagestatisticmonth.FieldType:
  33580. return m.AddedType()
  33581. case usagestatisticmonth.FieldOrganizationID:
  33582. return m.AddedOrganizationID()
  33583. case usagestatisticmonth.FieldAiResponse:
  33584. return m.AddedAiResponse()
  33585. case usagestatisticmonth.FieldSopRun:
  33586. return m.AddedSopRun()
  33587. case usagestatisticmonth.FieldTotalFriend:
  33588. return m.AddedTotalFriend()
  33589. case usagestatisticmonth.FieldTotalGroup:
  33590. return m.AddedTotalGroup()
  33591. case usagestatisticmonth.FieldAccountBalance:
  33592. return m.AddedAccountBalance()
  33593. case usagestatisticmonth.FieldConsumeToken:
  33594. return m.AddedConsumeToken()
  33595. case usagestatisticmonth.FieldActiveUser:
  33596. return m.AddedActiveUser()
  33597. case usagestatisticmonth.FieldNewUser:
  33598. return m.AddedNewUser()
  33599. }
  33600. return nil, false
  33601. }
  33602. // AddField adds the value to the field with the given name. It returns an error if
  33603. // the field is not defined in the schema, or if the type mismatched the field
  33604. // type.
  33605. func (m *UsageStatisticMonthMutation) AddField(name string, value ent.Value) error {
  33606. switch name {
  33607. case usagestatisticmonth.FieldStatus:
  33608. v, ok := value.(int8)
  33609. if !ok {
  33610. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33611. }
  33612. m.AddStatus(v)
  33613. return nil
  33614. case usagestatisticmonth.FieldAddtime:
  33615. v, ok := value.(int64)
  33616. if !ok {
  33617. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33618. }
  33619. m.AddAddtime(v)
  33620. return nil
  33621. case usagestatisticmonth.FieldType:
  33622. v, ok := value.(int)
  33623. if !ok {
  33624. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33625. }
  33626. m.AddType(v)
  33627. return nil
  33628. case usagestatisticmonth.FieldOrganizationID:
  33629. v, ok := value.(int64)
  33630. if !ok {
  33631. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33632. }
  33633. m.AddOrganizationID(v)
  33634. return nil
  33635. case usagestatisticmonth.FieldAiResponse:
  33636. v, ok := value.(int64)
  33637. if !ok {
  33638. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33639. }
  33640. m.AddAiResponse(v)
  33641. return nil
  33642. case usagestatisticmonth.FieldSopRun:
  33643. v, ok := value.(int64)
  33644. if !ok {
  33645. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33646. }
  33647. m.AddSopRun(v)
  33648. return nil
  33649. case usagestatisticmonth.FieldTotalFriend:
  33650. v, ok := value.(int64)
  33651. if !ok {
  33652. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33653. }
  33654. m.AddTotalFriend(v)
  33655. return nil
  33656. case usagestatisticmonth.FieldTotalGroup:
  33657. v, ok := value.(int64)
  33658. if !ok {
  33659. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33660. }
  33661. m.AddTotalGroup(v)
  33662. return nil
  33663. case usagestatisticmonth.FieldAccountBalance:
  33664. v, ok := value.(int64)
  33665. if !ok {
  33666. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33667. }
  33668. m.AddAccountBalance(v)
  33669. return nil
  33670. case usagestatisticmonth.FieldConsumeToken:
  33671. v, ok := value.(int64)
  33672. if !ok {
  33673. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33674. }
  33675. m.AddConsumeToken(v)
  33676. return nil
  33677. case usagestatisticmonth.FieldActiveUser:
  33678. v, ok := value.(int64)
  33679. if !ok {
  33680. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33681. }
  33682. m.AddActiveUser(v)
  33683. return nil
  33684. case usagestatisticmonth.FieldNewUser:
  33685. v, ok := value.(int64)
  33686. if !ok {
  33687. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33688. }
  33689. m.AddNewUser(v)
  33690. return nil
  33691. }
  33692. return fmt.Errorf("unknown UsageStatisticMonth numeric field %s", name)
  33693. }
  33694. // ClearedFields returns all nullable fields that were cleared during this
  33695. // mutation.
  33696. func (m *UsageStatisticMonthMutation) ClearedFields() []string {
  33697. var fields []string
  33698. if m.FieldCleared(usagestatisticmonth.FieldStatus) {
  33699. fields = append(fields, usagestatisticmonth.FieldStatus)
  33700. }
  33701. if m.FieldCleared(usagestatisticmonth.FieldDeletedAt) {
  33702. fields = append(fields, usagestatisticmonth.FieldDeletedAt)
  33703. }
  33704. if m.FieldCleared(usagestatisticmonth.FieldBotID) {
  33705. fields = append(fields, usagestatisticmonth.FieldBotID)
  33706. }
  33707. if m.FieldCleared(usagestatisticmonth.FieldOrganizationID) {
  33708. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  33709. }
  33710. return fields
  33711. }
  33712. // FieldCleared returns a boolean indicating if a field with the given name was
  33713. // cleared in this mutation.
  33714. func (m *UsageStatisticMonthMutation) FieldCleared(name string) bool {
  33715. _, ok := m.clearedFields[name]
  33716. return ok
  33717. }
  33718. // ClearField clears the value of the field with the given name. It returns an
  33719. // error if the field is not defined in the schema.
  33720. func (m *UsageStatisticMonthMutation) ClearField(name string) error {
  33721. switch name {
  33722. case usagestatisticmonth.FieldStatus:
  33723. m.ClearStatus()
  33724. return nil
  33725. case usagestatisticmonth.FieldDeletedAt:
  33726. m.ClearDeletedAt()
  33727. return nil
  33728. case usagestatisticmonth.FieldBotID:
  33729. m.ClearBotID()
  33730. return nil
  33731. case usagestatisticmonth.FieldOrganizationID:
  33732. m.ClearOrganizationID()
  33733. return nil
  33734. }
  33735. return fmt.Errorf("unknown UsageStatisticMonth nullable field %s", name)
  33736. }
  33737. // ResetField resets all changes in the mutation for the field with the given name.
  33738. // It returns an error if the field is not defined in the schema.
  33739. func (m *UsageStatisticMonthMutation) ResetField(name string) error {
  33740. switch name {
  33741. case usagestatisticmonth.FieldCreatedAt:
  33742. m.ResetCreatedAt()
  33743. return nil
  33744. case usagestatisticmonth.FieldUpdatedAt:
  33745. m.ResetUpdatedAt()
  33746. return nil
  33747. case usagestatisticmonth.FieldStatus:
  33748. m.ResetStatus()
  33749. return nil
  33750. case usagestatisticmonth.FieldDeletedAt:
  33751. m.ResetDeletedAt()
  33752. return nil
  33753. case usagestatisticmonth.FieldAddtime:
  33754. m.ResetAddtime()
  33755. return nil
  33756. case usagestatisticmonth.FieldType:
  33757. m.ResetType()
  33758. return nil
  33759. case usagestatisticmonth.FieldBotID:
  33760. m.ResetBotID()
  33761. return nil
  33762. case usagestatisticmonth.FieldOrganizationID:
  33763. m.ResetOrganizationID()
  33764. return nil
  33765. case usagestatisticmonth.FieldAiResponse:
  33766. m.ResetAiResponse()
  33767. return nil
  33768. case usagestatisticmonth.FieldSopRun:
  33769. m.ResetSopRun()
  33770. return nil
  33771. case usagestatisticmonth.FieldTotalFriend:
  33772. m.ResetTotalFriend()
  33773. return nil
  33774. case usagestatisticmonth.FieldTotalGroup:
  33775. m.ResetTotalGroup()
  33776. return nil
  33777. case usagestatisticmonth.FieldAccountBalance:
  33778. m.ResetAccountBalance()
  33779. return nil
  33780. case usagestatisticmonth.FieldConsumeToken:
  33781. m.ResetConsumeToken()
  33782. return nil
  33783. case usagestatisticmonth.FieldActiveUser:
  33784. m.ResetActiveUser()
  33785. return nil
  33786. case usagestatisticmonth.FieldNewUser:
  33787. m.ResetNewUser()
  33788. return nil
  33789. case usagestatisticmonth.FieldLabelDist:
  33790. m.ResetLabelDist()
  33791. return nil
  33792. }
  33793. return fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  33794. }
  33795. // AddedEdges returns all edge names that were set/added in this mutation.
  33796. func (m *UsageStatisticMonthMutation) AddedEdges() []string {
  33797. edges := make([]string, 0, 0)
  33798. return edges
  33799. }
  33800. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  33801. // name in this mutation.
  33802. func (m *UsageStatisticMonthMutation) AddedIDs(name string) []ent.Value {
  33803. return nil
  33804. }
  33805. // RemovedEdges returns all edge names that were removed in this mutation.
  33806. func (m *UsageStatisticMonthMutation) RemovedEdges() []string {
  33807. edges := make([]string, 0, 0)
  33808. return edges
  33809. }
  33810. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  33811. // the given name in this mutation.
  33812. func (m *UsageStatisticMonthMutation) RemovedIDs(name string) []ent.Value {
  33813. return nil
  33814. }
  33815. // ClearedEdges returns all edge names that were cleared in this mutation.
  33816. func (m *UsageStatisticMonthMutation) ClearedEdges() []string {
  33817. edges := make([]string, 0, 0)
  33818. return edges
  33819. }
  33820. // EdgeCleared returns a boolean which indicates if the edge with the given name
  33821. // was cleared in this mutation.
  33822. func (m *UsageStatisticMonthMutation) EdgeCleared(name string) bool {
  33823. return false
  33824. }
  33825. // ClearEdge clears the value of the edge with the given name. It returns an error
  33826. // if that edge is not defined in the schema.
  33827. func (m *UsageStatisticMonthMutation) ClearEdge(name string) error {
  33828. return fmt.Errorf("unknown UsageStatisticMonth unique edge %s", name)
  33829. }
  33830. // ResetEdge resets all changes to the edge with the given name in this mutation.
  33831. // It returns an error if the edge is not defined in the schema.
  33832. func (m *UsageStatisticMonthMutation) ResetEdge(name string) error {
  33833. return fmt.Errorf("unknown UsageStatisticMonth edge %s", name)
  33834. }
  33835. // UsageTotalMutation represents an operation that mutates the UsageTotal nodes in the graph.
  33836. type UsageTotalMutation struct {
  33837. config
  33838. op Op
  33839. typ string
  33840. id *uint64
  33841. created_at *time.Time
  33842. updated_at *time.Time
  33843. status *uint8
  33844. addstatus *int8
  33845. _type *int
  33846. add_type *int
  33847. bot_id *string
  33848. total_tokens *uint64
  33849. addtotal_tokens *int64
  33850. start_index *uint64
  33851. addstart_index *int64
  33852. end_index *uint64
  33853. addend_index *int64
  33854. organization_id *uint64
  33855. addorganization_id *int64
  33856. clearedFields map[string]struct{}
  33857. done bool
  33858. oldValue func(context.Context) (*UsageTotal, error)
  33859. predicates []predicate.UsageTotal
  33860. }
  33861. var _ ent.Mutation = (*UsageTotalMutation)(nil)
  33862. // usagetotalOption allows management of the mutation configuration using functional options.
  33863. type usagetotalOption func(*UsageTotalMutation)
  33864. // newUsageTotalMutation creates new mutation for the UsageTotal entity.
  33865. func newUsageTotalMutation(c config, op Op, opts ...usagetotalOption) *UsageTotalMutation {
  33866. m := &UsageTotalMutation{
  33867. config: c,
  33868. op: op,
  33869. typ: TypeUsageTotal,
  33870. clearedFields: make(map[string]struct{}),
  33871. }
  33872. for _, opt := range opts {
  33873. opt(m)
  33874. }
  33875. return m
  33876. }
  33877. // withUsageTotalID sets the ID field of the mutation.
  33878. func withUsageTotalID(id uint64) usagetotalOption {
  33879. return func(m *UsageTotalMutation) {
  33880. var (
  33881. err error
  33882. once sync.Once
  33883. value *UsageTotal
  33884. )
  33885. m.oldValue = func(ctx context.Context) (*UsageTotal, error) {
  33886. once.Do(func() {
  33887. if m.done {
  33888. err = errors.New("querying old values post mutation is not allowed")
  33889. } else {
  33890. value, err = m.Client().UsageTotal.Get(ctx, id)
  33891. }
  33892. })
  33893. return value, err
  33894. }
  33895. m.id = &id
  33896. }
  33897. }
  33898. // withUsageTotal sets the old UsageTotal of the mutation.
  33899. func withUsageTotal(node *UsageTotal) usagetotalOption {
  33900. return func(m *UsageTotalMutation) {
  33901. m.oldValue = func(context.Context) (*UsageTotal, error) {
  33902. return node, nil
  33903. }
  33904. m.id = &node.ID
  33905. }
  33906. }
  33907. // Client returns a new `ent.Client` from the mutation. If the mutation was
  33908. // executed in a transaction (ent.Tx), a transactional client is returned.
  33909. func (m UsageTotalMutation) Client() *Client {
  33910. client := &Client{config: m.config}
  33911. client.init()
  33912. return client
  33913. }
  33914. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  33915. // it returns an error otherwise.
  33916. func (m UsageTotalMutation) Tx() (*Tx, error) {
  33917. if _, ok := m.driver.(*txDriver); !ok {
  33918. return nil, errors.New("ent: mutation is not running in a transaction")
  33919. }
  33920. tx := &Tx{config: m.config}
  33921. tx.init()
  33922. return tx, nil
  33923. }
  33924. // SetID sets the value of the id field. Note that this
  33925. // operation is only accepted on creation of UsageTotal entities.
  33926. func (m *UsageTotalMutation) SetID(id uint64) {
  33927. m.id = &id
  33928. }
  33929. // ID returns the ID value in the mutation. Note that the ID is only available
  33930. // if it was provided to the builder or after it was returned from the database.
  33931. func (m *UsageTotalMutation) ID() (id uint64, exists bool) {
  33932. if m.id == nil {
  33933. return
  33934. }
  33935. return *m.id, true
  33936. }
  33937. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  33938. // That means, if the mutation is applied within a transaction with an isolation level such
  33939. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  33940. // or updated by the mutation.
  33941. func (m *UsageTotalMutation) IDs(ctx context.Context) ([]uint64, error) {
  33942. switch {
  33943. case m.op.Is(OpUpdateOne | OpDeleteOne):
  33944. id, exists := m.ID()
  33945. if exists {
  33946. return []uint64{id}, nil
  33947. }
  33948. fallthrough
  33949. case m.op.Is(OpUpdate | OpDelete):
  33950. return m.Client().UsageTotal.Query().Where(m.predicates...).IDs(ctx)
  33951. default:
  33952. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  33953. }
  33954. }
  33955. // SetCreatedAt sets the "created_at" field.
  33956. func (m *UsageTotalMutation) SetCreatedAt(t time.Time) {
  33957. m.created_at = &t
  33958. }
  33959. // CreatedAt returns the value of the "created_at" field in the mutation.
  33960. func (m *UsageTotalMutation) CreatedAt() (r time.Time, exists bool) {
  33961. v := m.created_at
  33962. if v == nil {
  33963. return
  33964. }
  33965. return *v, true
  33966. }
  33967. // OldCreatedAt returns the old "created_at" field's value of the UsageTotal entity.
  33968. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  33969. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33970. func (m *UsageTotalMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  33971. if !m.op.Is(OpUpdateOne) {
  33972. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  33973. }
  33974. if m.id == nil || m.oldValue == nil {
  33975. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  33976. }
  33977. oldValue, err := m.oldValue(ctx)
  33978. if err != nil {
  33979. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  33980. }
  33981. return oldValue.CreatedAt, nil
  33982. }
  33983. // ResetCreatedAt resets all changes to the "created_at" field.
  33984. func (m *UsageTotalMutation) ResetCreatedAt() {
  33985. m.created_at = nil
  33986. }
  33987. // SetUpdatedAt sets the "updated_at" field.
  33988. func (m *UsageTotalMutation) SetUpdatedAt(t time.Time) {
  33989. m.updated_at = &t
  33990. }
  33991. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  33992. func (m *UsageTotalMutation) UpdatedAt() (r time.Time, exists bool) {
  33993. v := m.updated_at
  33994. if v == nil {
  33995. return
  33996. }
  33997. return *v, true
  33998. }
  33999. // OldUpdatedAt returns the old "updated_at" field's value of the UsageTotal entity.
  34000. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  34001. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34002. func (m *UsageTotalMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  34003. if !m.op.Is(OpUpdateOne) {
  34004. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  34005. }
  34006. if m.id == nil || m.oldValue == nil {
  34007. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  34008. }
  34009. oldValue, err := m.oldValue(ctx)
  34010. if err != nil {
  34011. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  34012. }
  34013. return oldValue.UpdatedAt, nil
  34014. }
  34015. // ResetUpdatedAt resets all changes to the "updated_at" field.
  34016. func (m *UsageTotalMutation) ResetUpdatedAt() {
  34017. m.updated_at = nil
  34018. }
  34019. // SetStatus sets the "status" field.
  34020. func (m *UsageTotalMutation) SetStatus(u uint8) {
  34021. m.status = &u
  34022. m.addstatus = nil
  34023. }
  34024. // Status returns the value of the "status" field in the mutation.
  34025. func (m *UsageTotalMutation) Status() (r uint8, exists bool) {
  34026. v := m.status
  34027. if v == nil {
  34028. return
  34029. }
  34030. return *v, true
  34031. }
  34032. // OldStatus returns the old "status" field's value of the UsageTotal entity.
  34033. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  34034. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34035. func (m *UsageTotalMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  34036. if !m.op.Is(OpUpdateOne) {
  34037. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  34038. }
  34039. if m.id == nil || m.oldValue == nil {
  34040. return v, errors.New("OldStatus requires an ID field in the mutation")
  34041. }
  34042. oldValue, err := m.oldValue(ctx)
  34043. if err != nil {
  34044. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  34045. }
  34046. return oldValue.Status, nil
  34047. }
  34048. // AddStatus adds u to the "status" field.
  34049. func (m *UsageTotalMutation) AddStatus(u int8) {
  34050. if m.addstatus != nil {
  34051. *m.addstatus += u
  34052. } else {
  34053. m.addstatus = &u
  34054. }
  34055. }
  34056. // AddedStatus returns the value that was added to the "status" field in this mutation.
  34057. func (m *UsageTotalMutation) AddedStatus() (r int8, exists bool) {
  34058. v := m.addstatus
  34059. if v == nil {
  34060. return
  34061. }
  34062. return *v, true
  34063. }
  34064. // ClearStatus clears the value of the "status" field.
  34065. func (m *UsageTotalMutation) ClearStatus() {
  34066. m.status = nil
  34067. m.addstatus = nil
  34068. m.clearedFields[usagetotal.FieldStatus] = struct{}{}
  34069. }
  34070. // StatusCleared returns if the "status" field was cleared in this mutation.
  34071. func (m *UsageTotalMutation) StatusCleared() bool {
  34072. _, ok := m.clearedFields[usagetotal.FieldStatus]
  34073. return ok
  34074. }
  34075. // ResetStatus resets all changes to the "status" field.
  34076. func (m *UsageTotalMutation) ResetStatus() {
  34077. m.status = nil
  34078. m.addstatus = nil
  34079. delete(m.clearedFields, usagetotal.FieldStatus)
  34080. }
  34081. // SetType sets the "type" field.
  34082. func (m *UsageTotalMutation) SetType(i int) {
  34083. m._type = &i
  34084. m.add_type = nil
  34085. }
  34086. // GetType returns the value of the "type" field in the mutation.
  34087. func (m *UsageTotalMutation) GetType() (r int, exists bool) {
  34088. v := m._type
  34089. if v == nil {
  34090. return
  34091. }
  34092. return *v, true
  34093. }
  34094. // OldType returns the old "type" field's value of the UsageTotal entity.
  34095. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  34096. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34097. func (m *UsageTotalMutation) OldType(ctx context.Context) (v int, err error) {
  34098. if !m.op.Is(OpUpdateOne) {
  34099. return v, errors.New("OldType is only allowed on UpdateOne operations")
  34100. }
  34101. if m.id == nil || m.oldValue == nil {
  34102. return v, errors.New("OldType requires an ID field in the mutation")
  34103. }
  34104. oldValue, err := m.oldValue(ctx)
  34105. if err != nil {
  34106. return v, fmt.Errorf("querying old value for OldType: %w", err)
  34107. }
  34108. return oldValue.Type, nil
  34109. }
  34110. // AddType adds i to the "type" field.
  34111. func (m *UsageTotalMutation) AddType(i int) {
  34112. if m.add_type != nil {
  34113. *m.add_type += i
  34114. } else {
  34115. m.add_type = &i
  34116. }
  34117. }
  34118. // AddedType returns the value that was added to the "type" field in this mutation.
  34119. func (m *UsageTotalMutation) AddedType() (r int, exists bool) {
  34120. v := m.add_type
  34121. if v == nil {
  34122. return
  34123. }
  34124. return *v, true
  34125. }
  34126. // ClearType clears the value of the "type" field.
  34127. func (m *UsageTotalMutation) ClearType() {
  34128. m._type = nil
  34129. m.add_type = nil
  34130. m.clearedFields[usagetotal.FieldType] = struct{}{}
  34131. }
  34132. // TypeCleared returns if the "type" field was cleared in this mutation.
  34133. func (m *UsageTotalMutation) TypeCleared() bool {
  34134. _, ok := m.clearedFields[usagetotal.FieldType]
  34135. return ok
  34136. }
  34137. // ResetType resets all changes to the "type" field.
  34138. func (m *UsageTotalMutation) ResetType() {
  34139. m._type = nil
  34140. m.add_type = nil
  34141. delete(m.clearedFields, usagetotal.FieldType)
  34142. }
  34143. // SetBotID sets the "bot_id" field.
  34144. func (m *UsageTotalMutation) SetBotID(s string) {
  34145. m.bot_id = &s
  34146. }
  34147. // BotID returns the value of the "bot_id" field in the mutation.
  34148. func (m *UsageTotalMutation) BotID() (r string, exists bool) {
  34149. v := m.bot_id
  34150. if v == nil {
  34151. return
  34152. }
  34153. return *v, true
  34154. }
  34155. // OldBotID returns the old "bot_id" field's value of the UsageTotal entity.
  34156. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  34157. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34158. func (m *UsageTotalMutation) OldBotID(ctx context.Context) (v string, err error) {
  34159. if !m.op.Is(OpUpdateOne) {
  34160. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  34161. }
  34162. if m.id == nil || m.oldValue == nil {
  34163. return v, errors.New("OldBotID requires an ID field in the mutation")
  34164. }
  34165. oldValue, err := m.oldValue(ctx)
  34166. if err != nil {
  34167. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  34168. }
  34169. return oldValue.BotID, nil
  34170. }
  34171. // ResetBotID resets all changes to the "bot_id" field.
  34172. func (m *UsageTotalMutation) ResetBotID() {
  34173. m.bot_id = nil
  34174. }
  34175. // SetTotalTokens sets the "total_tokens" field.
  34176. func (m *UsageTotalMutation) SetTotalTokens(u uint64) {
  34177. m.total_tokens = &u
  34178. m.addtotal_tokens = nil
  34179. }
  34180. // TotalTokens returns the value of the "total_tokens" field in the mutation.
  34181. func (m *UsageTotalMutation) TotalTokens() (r uint64, exists bool) {
  34182. v := m.total_tokens
  34183. if v == nil {
  34184. return
  34185. }
  34186. return *v, true
  34187. }
  34188. // OldTotalTokens returns the old "total_tokens" field's value of the UsageTotal entity.
  34189. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  34190. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34191. func (m *UsageTotalMutation) OldTotalTokens(ctx context.Context) (v uint64, err error) {
  34192. if !m.op.Is(OpUpdateOne) {
  34193. return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
  34194. }
  34195. if m.id == nil || m.oldValue == nil {
  34196. return v, errors.New("OldTotalTokens requires an ID field in the mutation")
  34197. }
  34198. oldValue, err := m.oldValue(ctx)
  34199. if err != nil {
  34200. return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
  34201. }
  34202. return oldValue.TotalTokens, nil
  34203. }
  34204. // AddTotalTokens adds u to the "total_tokens" field.
  34205. func (m *UsageTotalMutation) AddTotalTokens(u int64) {
  34206. if m.addtotal_tokens != nil {
  34207. *m.addtotal_tokens += u
  34208. } else {
  34209. m.addtotal_tokens = &u
  34210. }
  34211. }
  34212. // AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
  34213. func (m *UsageTotalMutation) AddedTotalTokens() (r int64, exists bool) {
  34214. v := m.addtotal_tokens
  34215. if v == nil {
  34216. return
  34217. }
  34218. return *v, true
  34219. }
  34220. // ClearTotalTokens clears the value of the "total_tokens" field.
  34221. func (m *UsageTotalMutation) ClearTotalTokens() {
  34222. m.total_tokens = nil
  34223. m.addtotal_tokens = nil
  34224. m.clearedFields[usagetotal.FieldTotalTokens] = struct{}{}
  34225. }
  34226. // TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
  34227. func (m *UsageTotalMutation) TotalTokensCleared() bool {
  34228. _, ok := m.clearedFields[usagetotal.FieldTotalTokens]
  34229. return ok
  34230. }
  34231. // ResetTotalTokens resets all changes to the "total_tokens" field.
  34232. func (m *UsageTotalMutation) ResetTotalTokens() {
  34233. m.total_tokens = nil
  34234. m.addtotal_tokens = nil
  34235. delete(m.clearedFields, usagetotal.FieldTotalTokens)
  34236. }
  34237. // SetStartIndex sets the "start_index" field.
  34238. func (m *UsageTotalMutation) SetStartIndex(u uint64) {
  34239. m.start_index = &u
  34240. m.addstart_index = nil
  34241. }
  34242. // StartIndex returns the value of the "start_index" field in the mutation.
  34243. func (m *UsageTotalMutation) StartIndex() (r uint64, exists bool) {
  34244. v := m.start_index
  34245. if v == nil {
  34246. return
  34247. }
  34248. return *v, true
  34249. }
  34250. // OldStartIndex returns the old "start_index" field's value of the UsageTotal entity.
  34251. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  34252. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34253. func (m *UsageTotalMutation) OldStartIndex(ctx context.Context) (v uint64, err error) {
  34254. if !m.op.Is(OpUpdateOne) {
  34255. return v, errors.New("OldStartIndex is only allowed on UpdateOne operations")
  34256. }
  34257. if m.id == nil || m.oldValue == nil {
  34258. return v, errors.New("OldStartIndex requires an ID field in the mutation")
  34259. }
  34260. oldValue, err := m.oldValue(ctx)
  34261. if err != nil {
  34262. return v, fmt.Errorf("querying old value for OldStartIndex: %w", err)
  34263. }
  34264. return oldValue.StartIndex, nil
  34265. }
  34266. // AddStartIndex adds u to the "start_index" field.
  34267. func (m *UsageTotalMutation) AddStartIndex(u int64) {
  34268. if m.addstart_index != nil {
  34269. *m.addstart_index += u
  34270. } else {
  34271. m.addstart_index = &u
  34272. }
  34273. }
  34274. // AddedStartIndex returns the value that was added to the "start_index" field in this mutation.
  34275. func (m *UsageTotalMutation) AddedStartIndex() (r int64, exists bool) {
  34276. v := m.addstart_index
  34277. if v == nil {
  34278. return
  34279. }
  34280. return *v, true
  34281. }
  34282. // ClearStartIndex clears the value of the "start_index" field.
  34283. func (m *UsageTotalMutation) ClearStartIndex() {
  34284. m.start_index = nil
  34285. m.addstart_index = nil
  34286. m.clearedFields[usagetotal.FieldStartIndex] = struct{}{}
  34287. }
  34288. // StartIndexCleared returns if the "start_index" field was cleared in this mutation.
  34289. func (m *UsageTotalMutation) StartIndexCleared() bool {
  34290. _, ok := m.clearedFields[usagetotal.FieldStartIndex]
  34291. return ok
  34292. }
  34293. // ResetStartIndex resets all changes to the "start_index" field.
  34294. func (m *UsageTotalMutation) ResetStartIndex() {
  34295. m.start_index = nil
  34296. m.addstart_index = nil
  34297. delete(m.clearedFields, usagetotal.FieldStartIndex)
  34298. }
  34299. // SetEndIndex sets the "end_index" field.
  34300. func (m *UsageTotalMutation) SetEndIndex(u uint64) {
  34301. m.end_index = &u
  34302. m.addend_index = nil
  34303. }
  34304. // EndIndex returns the value of the "end_index" field in the mutation.
  34305. func (m *UsageTotalMutation) EndIndex() (r uint64, exists bool) {
  34306. v := m.end_index
  34307. if v == nil {
  34308. return
  34309. }
  34310. return *v, true
  34311. }
  34312. // OldEndIndex returns the old "end_index" field's value of the UsageTotal entity.
  34313. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  34314. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34315. func (m *UsageTotalMutation) OldEndIndex(ctx context.Context) (v uint64, err error) {
  34316. if !m.op.Is(OpUpdateOne) {
  34317. return v, errors.New("OldEndIndex is only allowed on UpdateOne operations")
  34318. }
  34319. if m.id == nil || m.oldValue == nil {
  34320. return v, errors.New("OldEndIndex requires an ID field in the mutation")
  34321. }
  34322. oldValue, err := m.oldValue(ctx)
  34323. if err != nil {
  34324. return v, fmt.Errorf("querying old value for OldEndIndex: %w", err)
  34325. }
  34326. return oldValue.EndIndex, nil
  34327. }
  34328. // AddEndIndex adds u to the "end_index" field.
  34329. func (m *UsageTotalMutation) AddEndIndex(u int64) {
  34330. if m.addend_index != nil {
  34331. *m.addend_index += u
  34332. } else {
  34333. m.addend_index = &u
  34334. }
  34335. }
  34336. // AddedEndIndex returns the value that was added to the "end_index" field in this mutation.
  34337. func (m *UsageTotalMutation) AddedEndIndex() (r int64, exists bool) {
  34338. v := m.addend_index
  34339. if v == nil {
  34340. return
  34341. }
  34342. return *v, true
  34343. }
  34344. // ClearEndIndex clears the value of the "end_index" field.
  34345. func (m *UsageTotalMutation) ClearEndIndex() {
  34346. m.end_index = nil
  34347. m.addend_index = nil
  34348. m.clearedFields[usagetotal.FieldEndIndex] = struct{}{}
  34349. }
  34350. // EndIndexCleared returns if the "end_index" field was cleared in this mutation.
  34351. func (m *UsageTotalMutation) EndIndexCleared() bool {
  34352. _, ok := m.clearedFields[usagetotal.FieldEndIndex]
  34353. return ok
  34354. }
  34355. // ResetEndIndex resets all changes to the "end_index" field.
  34356. func (m *UsageTotalMutation) ResetEndIndex() {
  34357. m.end_index = nil
  34358. m.addend_index = nil
  34359. delete(m.clearedFields, usagetotal.FieldEndIndex)
  34360. }
  34361. // SetOrganizationID sets the "organization_id" field.
  34362. func (m *UsageTotalMutation) SetOrganizationID(u uint64) {
  34363. m.organization_id = &u
  34364. m.addorganization_id = nil
  34365. }
  34366. // OrganizationID returns the value of the "organization_id" field in the mutation.
  34367. func (m *UsageTotalMutation) OrganizationID() (r uint64, exists bool) {
  34368. v := m.organization_id
  34369. if v == nil {
  34370. return
  34371. }
  34372. return *v, true
  34373. }
  34374. // OldOrganizationID returns the old "organization_id" field's value of the UsageTotal entity.
  34375. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  34376. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34377. func (m *UsageTotalMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  34378. if !m.op.Is(OpUpdateOne) {
  34379. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  34380. }
  34381. if m.id == nil || m.oldValue == nil {
  34382. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  34383. }
  34384. oldValue, err := m.oldValue(ctx)
  34385. if err != nil {
  34386. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  34387. }
  34388. return oldValue.OrganizationID, nil
  34389. }
  34390. // AddOrganizationID adds u to the "organization_id" field.
  34391. func (m *UsageTotalMutation) AddOrganizationID(u int64) {
  34392. if m.addorganization_id != nil {
  34393. *m.addorganization_id += u
  34394. } else {
  34395. m.addorganization_id = &u
  34396. }
  34397. }
  34398. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  34399. func (m *UsageTotalMutation) AddedOrganizationID() (r int64, exists bool) {
  34400. v := m.addorganization_id
  34401. if v == nil {
  34402. return
  34403. }
  34404. return *v, true
  34405. }
  34406. // ClearOrganizationID clears the value of the "organization_id" field.
  34407. func (m *UsageTotalMutation) ClearOrganizationID() {
  34408. m.organization_id = nil
  34409. m.addorganization_id = nil
  34410. m.clearedFields[usagetotal.FieldOrganizationID] = struct{}{}
  34411. }
  34412. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  34413. func (m *UsageTotalMutation) OrganizationIDCleared() bool {
  34414. _, ok := m.clearedFields[usagetotal.FieldOrganizationID]
  34415. return ok
  34416. }
  34417. // ResetOrganizationID resets all changes to the "organization_id" field.
  34418. func (m *UsageTotalMutation) ResetOrganizationID() {
  34419. m.organization_id = nil
  34420. m.addorganization_id = nil
  34421. delete(m.clearedFields, usagetotal.FieldOrganizationID)
  34422. }
  34423. // Where appends a list predicates to the UsageTotalMutation builder.
  34424. func (m *UsageTotalMutation) Where(ps ...predicate.UsageTotal) {
  34425. m.predicates = append(m.predicates, ps...)
  34426. }
  34427. // WhereP appends storage-level predicates to the UsageTotalMutation builder. Using this method,
  34428. // users can use type-assertion to append predicates that do not depend on any generated package.
  34429. func (m *UsageTotalMutation) WhereP(ps ...func(*sql.Selector)) {
  34430. p := make([]predicate.UsageTotal, len(ps))
  34431. for i := range ps {
  34432. p[i] = ps[i]
  34433. }
  34434. m.Where(p...)
  34435. }
  34436. // Op returns the operation name.
  34437. func (m *UsageTotalMutation) Op() Op {
  34438. return m.op
  34439. }
  34440. // SetOp allows setting the mutation operation.
  34441. func (m *UsageTotalMutation) SetOp(op Op) {
  34442. m.op = op
  34443. }
  34444. // Type returns the node type of this mutation (UsageTotal).
  34445. func (m *UsageTotalMutation) Type() string {
  34446. return m.typ
  34447. }
  34448. // Fields returns all fields that were changed during this mutation. Note that in
  34449. // order to get all numeric fields that were incremented/decremented, call
  34450. // AddedFields().
  34451. func (m *UsageTotalMutation) Fields() []string {
  34452. fields := make([]string, 0, 9)
  34453. if m.created_at != nil {
  34454. fields = append(fields, usagetotal.FieldCreatedAt)
  34455. }
  34456. if m.updated_at != nil {
  34457. fields = append(fields, usagetotal.FieldUpdatedAt)
  34458. }
  34459. if m.status != nil {
  34460. fields = append(fields, usagetotal.FieldStatus)
  34461. }
  34462. if m._type != nil {
  34463. fields = append(fields, usagetotal.FieldType)
  34464. }
  34465. if m.bot_id != nil {
  34466. fields = append(fields, usagetotal.FieldBotID)
  34467. }
  34468. if m.total_tokens != nil {
  34469. fields = append(fields, usagetotal.FieldTotalTokens)
  34470. }
  34471. if m.start_index != nil {
  34472. fields = append(fields, usagetotal.FieldStartIndex)
  34473. }
  34474. if m.end_index != nil {
  34475. fields = append(fields, usagetotal.FieldEndIndex)
  34476. }
  34477. if m.organization_id != nil {
  34478. fields = append(fields, usagetotal.FieldOrganizationID)
  34479. }
  34480. return fields
  34481. }
  34482. // Field returns the value of a field with the given name. The second boolean
  34483. // return value indicates that this field was not set, or was not defined in the
  34484. // schema.
  34485. func (m *UsageTotalMutation) Field(name string) (ent.Value, bool) {
  34486. switch name {
  34487. case usagetotal.FieldCreatedAt:
  34488. return m.CreatedAt()
  34489. case usagetotal.FieldUpdatedAt:
  34490. return m.UpdatedAt()
  34491. case usagetotal.FieldStatus:
  34492. return m.Status()
  34493. case usagetotal.FieldType:
  34494. return m.GetType()
  34495. case usagetotal.FieldBotID:
  34496. return m.BotID()
  34497. case usagetotal.FieldTotalTokens:
  34498. return m.TotalTokens()
  34499. case usagetotal.FieldStartIndex:
  34500. return m.StartIndex()
  34501. case usagetotal.FieldEndIndex:
  34502. return m.EndIndex()
  34503. case usagetotal.FieldOrganizationID:
  34504. return m.OrganizationID()
  34505. }
  34506. return nil, false
  34507. }
  34508. // OldField returns the old value of the field from the database. An error is
  34509. // returned if the mutation operation is not UpdateOne, or the query to the
  34510. // database failed.
  34511. func (m *UsageTotalMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  34512. switch name {
  34513. case usagetotal.FieldCreatedAt:
  34514. return m.OldCreatedAt(ctx)
  34515. case usagetotal.FieldUpdatedAt:
  34516. return m.OldUpdatedAt(ctx)
  34517. case usagetotal.FieldStatus:
  34518. return m.OldStatus(ctx)
  34519. case usagetotal.FieldType:
  34520. return m.OldType(ctx)
  34521. case usagetotal.FieldBotID:
  34522. return m.OldBotID(ctx)
  34523. case usagetotal.FieldTotalTokens:
  34524. return m.OldTotalTokens(ctx)
  34525. case usagetotal.FieldStartIndex:
  34526. return m.OldStartIndex(ctx)
  34527. case usagetotal.FieldEndIndex:
  34528. return m.OldEndIndex(ctx)
  34529. case usagetotal.FieldOrganizationID:
  34530. return m.OldOrganizationID(ctx)
  34531. }
  34532. return nil, fmt.Errorf("unknown UsageTotal field %s", name)
  34533. }
  34534. // SetField sets the value of a field with the given name. It returns an error if
  34535. // the field is not defined in the schema, or if the type mismatched the field
  34536. // type.
  34537. func (m *UsageTotalMutation) SetField(name string, value ent.Value) error {
  34538. switch name {
  34539. case usagetotal.FieldCreatedAt:
  34540. v, ok := value.(time.Time)
  34541. if !ok {
  34542. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34543. }
  34544. m.SetCreatedAt(v)
  34545. return nil
  34546. case usagetotal.FieldUpdatedAt:
  34547. v, ok := value.(time.Time)
  34548. if !ok {
  34549. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34550. }
  34551. m.SetUpdatedAt(v)
  34552. return nil
  34553. case usagetotal.FieldStatus:
  34554. v, ok := value.(uint8)
  34555. if !ok {
  34556. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34557. }
  34558. m.SetStatus(v)
  34559. return nil
  34560. case usagetotal.FieldType:
  34561. v, ok := value.(int)
  34562. if !ok {
  34563. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34564. }
  34565. m.SetType(v)
  34566. return nil
  34567. case usagetotal.FieldBotID:
  34568. v, ok := value.(string)
  34569. if !ok {
  34570. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34571. }
  34572. m.SetBotID(v)
  34573. return nil
  34574. case usagetotal.FieldTotalTokens:
  34575. v, ok := value.(uint64)
  34576. if !ok {
  34577. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34578. }
  34579. m.SetTotalTokens(v)
  34580. return nil
  34581. case usagetotal.FieldStartIndex:
  34582. v, ok := value.(uint64)
  34583. if !ok {
  34584. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34585. }
  34586. m.SetStartIndex(v)
  34587. return nil
  34588. case usagetotal.FieldEndIndex:
  34589. v, ok := value.(uint64)
  34590. if !ok {
  34591. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34592. }
  34593. m.SetEndIndex(v)
  34594. return nil
  34595. case usagetotal.FieldOrganizationID:
  34596. v, ok := value.(uint64)
  34597. if !ok {
  34598. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34599. }
  34600. m.SetOrganizationID(v)
  34601. return nil
  34602. }
  34603. return fmt.Errorf("unknown UsageTotal field %s", name)
  34604. }
  34605. // AddedFields returns all numeric fields that were incremented/decremented during
  34606. // this mutation.
  34607. func (m *UsageTotalMutation) AddedFields() []string {
  34608. var fields []string
  34609. if m.addstatus != nil {
  34610. fields = append(fields, usagetotal.FieldStatus)
  34611. }
  34612. if m.add_type != nil {
  34613. fields = append(fields, usagetotal.FieldType)
  34614. }
  34615. if m.addtotal_tokens != nil {
  34616. fields = append(fields, usagetotal.FieldTotalTokens)
  34617. }
  34618. if m.addstart_index != nil {
  34619. fields = append(fields, usagetotal.FieldStartIndex)
  34620. }
  34621. if m.addend_index != nil {
  34622. fields = append(fields, usagetotal.FieldEndIndex)
  34623. }
  34624. if m.addorganization_id != nil {
  34625. fields = append(fields, usagetotal.FieldOrganizationID)
  34626. }
  34627. return fields
  34628. }
  34629. // AddedField returns the numeric value that was incremented/decremented on a field
  34630. // with the given name. The second boolean return value indicates that this field
  34631. // was not set, or was not defined in the schema.
  34632. func (m *UsageTotalMutation) AddedField(name string) (ent.Value, bool) {
  34633. switch name {
  34634. case usagetotal.FieldStatus:
  34635. return m.AddedStatus()
  34636. case usagetotal.FieldType:
  34637. return m.AddedType()
  34638. case usagetotal.FieldTotalTokens:
  34639. return m.AddedTotalTokens()
  34640. case usagetotal.FieldStartIndex:
  34641. return m.AddedStartIndex()
  34642. case usagetotal.FieldEndIndex:
  34643. return m.AddedEndIndex()
  34644. case usagetotal.FieldOrganizationID:
  34645. return m.AddedOrganizationID()
  34646. }
  34647. return nil, false
  34648. }
  34649. // AddField adds the value to the field with the given name. It returns an error if
  34650. // the field is not defined in the schema, or if the type mismatched the field
  34651. // type.
  34652. func (m *UsageTotalMutation) AddField(name string, value ent.Value) error {
  34653. switch name {
  34654. case usagetotal.FieldStatus:
  34655. v, ok := value.(int8)
  34656. if !ok {
  34657. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34658. }
  34659. m.AddStatus(v)
  34660. return nil
  34661. case usagetotal.FieldType:
  34662. v, ok := value.(int)
  34663. if !ok {
  34664. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34665. }
  34666. m.AddType(v)
  34667. return nil
  34668. case usagetotal.FieldTotalTokens:
  34669. v, ok := value.(int64)
  34670. if !ok {
  34671. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34672. }
  34673. m.AddTotalTokens(v)
  34674. return nil
  34675. case usagetotal.FieldStartIndex:
  34676. v, ok := value.(int64)
  34677. if !ok {
  34678. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34679. }
  34680. m.AddStartIndex(v)
  34681. return nil
  34682. case usagetotal.FieldEndIndex:
  34683. v, ok := value.(int64)
  34684. if !ok {
  34685. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34686. }
  34687. m.AddEndIndex(v)
  34688. return nil
  34689. case usagetotal.FieldOrganizationID:
  34690. v, ok := value.(int64)
  34691. if !ok {
  34692. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34693. }
  34694. m.AddOrganizationID(v)
  34695. return nil
  34696. }
  34697. return fmt.Errorf("unknown UsageTotal numeric field %s", name)
  34698. }
  34699. // ClearedFields returns all nullable fields that were cleared during this
  34700. // mutation.
  34701. func (m *UsageTotalMutation) ClearedFields() []string {
  34702. var fields []string
  34703. if m.FieldCleared(usagetotal.FieldStatus) {
  34704. fields = append(fields, usagetotal.FieldStatus)
  34705. }
  34706. if m.FieldCleared(usagetotal.FieldType) {
  34707. fields = append(fields, usagetotal.FieldType)
  34708. }
  34709. if m.FieldCleared(usagetotal.FieldTotalTokens) {
  34710. fields = append(fields, usagetotal.FieldTotalTokens)
  34711. }
  34712. if m.FieldCleared(usagetotal.FieldStartIndex) {
  34713. fields = append(fields, usagetotal.FieldStartIndex)
  34714. }
  34715. if m.FieldCleared(usagetotal.FieldEndIndex) {
  34716. fields = append(fields, usagetotal.FieldEndIndex)
  34717. }
  34718. if m.FieldCleared(usagetotal.FieldOrganizationID) {
  34719. fields = append(fields, usagetotal.FieldOrganizationID)
  34720. }
  34721. return fields
  34722. }
  34723. // FieldCleared returns a boolean indicating if a field with the given name was
  34724. // cleared in this mutation.
  34725. func (m *UsageTotalMutation) FieldCleared(name string) bool {
  34726. _, ok := m.clearedFields[name]
  34727. return ok
  34728. }
  34729. // ClearField clears the value of the field with the given name. It returns an
  34730. // error if the field is not defined in the schema.
  34731. func (m *UsageTotalMutation) ClearField(name string) error {
  34732. switch name {
  34733. case usagetotal.FieldStatus:
  34734. m.ClearStatus()
  34735. return nil
  34736. case usagetotal.FieldType:
  34737. m.ClearType()
  34738. return nil
  34739. case usagetotal.FieldTotalTokens:
  34740. m.ClearTotalTokens()
  34741. return nil
  34742. case usagetotal.FieldStartIndex:
  34743. m.ClearStartIndex()
  34744. return nil
  34745. case usagetotal.FieldEndIndex:
  34746. m.ClearEndIndex()
  34747. return nil
  34748. case usagetotal.FieldOrganizationID:
  34749. m.ClearOrganizationID()
  34750. return nil
  34751. }
  34752. return fmt.Errorf("unknown UsageTotal nullable field %s", name)
  34753. }
  34754. // ResetField resets all changes in the mutation for the field with the given name.
  34755. // It returns an error if the field is not defined in the schema.
  34756. func (m *UsageTotalMutation) ResetField(name string) error {
  34757. switch name {
  34758. case usagetotal.FieldCreatedAt:
  34759. m.ResetCreatedAt()
  34760. return nil
  34761. case usagetotal.FieldUpdatedAt:
  34762. m.ResetUpdatedAt()
  34763. return nil
  34764. case usagetotal.FieldStatus:
  34765. m.ResetStatus()
  34766. return nil
  34767. case usagetotal.FieldType:
  34768. m.ResetType()
  34769. return nil
  34770. case usagetotal.FieldBotID:
  34771. m.ResetBotID()
  34772. return nil
  34773. case usagetotal.FieldTotalTokens:
  34774. m.ResetTotalTokens()
  34775. return nil
  34776. case usagetotal.FieldStartIndex:
  34777. m.ResetStartIndex()
  34778. return nil
  34779. case usagetotal.FieldEndIndex:
  34780. m.ResetEndIndex()
  34781. return nil
  34782. case usagetotal.FieldOrganizationID:
  34783. m.ResetOrganizationID()
  34784. return nil
  34785. }
  34786. return fmt.Errorf("unknown UsageTotal field %s", name)
  34787. }
  34788. // AddedEdges returns all edge names that were set/added in this mutation.
  34789. func (m *UsageTotalMutation) AddedEdges() []string {
  34790. edges := make([]string, 0, 0)
  34791. return edges
  34792. }
  34793. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  34794. // name in this mutation.
  34795. func (m *UsageTotalMutation) AddedIDs(name string) []ent.Value {
  34796. return nil
  34797. }
  34798. // RemovedEdges returns all edge names that were removed in this mutation.
  34799. func (m *UsageTotalMutation) RemovedEdges() []string {
  34800. edges := make([]string, 0, 0)
  34801. return edges
  34802. }
  34803. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  34804. // the given name in this mutation.
  34805. func (m *UsageTotalMutation) RemovedIDs(name string) []ent.Value {
  34806. return nil
  34807. }
  34808. // ClearedEdges returns all edge names that were cleared in this mutation.
  34809. func (m *UsageTotalMutation) ClearedEdges() []string {
  34810. edges := make([]string, 0, 0)
  34811. return edges
  34812. }
  34813. // EdgeCleared returns a boolean which indicates if the edge with the given name
  34814. // was cleared in this mutation.
  34815. func (m *UsageTotalMutation) EdgeCleared(name string) bool {
  34816. return false
  34817. }
  34818. // ClearEdge clears the value of the edge with the given name. It returns an error
  34819. // if that edge is not defined in the schema.
  34820. func (m *UsageTotalMutation) ClearEdge(name string) error {
  34821. return fmt.Errorf("unknown UsageTotal unique edge %s", name)
  34822. }
  34823. // ResetEdge resets all changes to the edge with the given name in this mutation.
  34824. // It returns an error if the edge is not defined in the schema.
  34825. func (m *UsageTotalMutation) ResetEdge(name string) error {
  34826. return fmt.Errorf("unknown UsageTotal edge %s", name)
  34827. }
  34828. // WhatsappMutation represents an operation that mutates the Whatsapp nodes in the graph.
  34829. type WhatsappMutation struct {
  34830. config
  34831. op Op
  34832. typ string
  34833. id *uint64
  34834. created_at *time.Time
  34835. updated_at *time.Time
  34836. status *uint8
  34837. addstatus *int8
  34838. deleted_at *time.Time
  34839. wa_id *string
  34840. wa_name *string
  34841. callback *string
  34842. account *string
  34843. cc *string
  34844. phone *string
  34845. cc_phone *string
  34846. phone_name *string
  34847. phone_status *int8
  34848. addphone_status *int8
  34849. organization_id *uint64
  34850. addorganization_id *int64
  34851. api_base *string
  34852. api_key *string
  34853. allow_list *[]string
  34854. appendallow_list []string
  34855. group_allow_list *[]string
  34856. appendgroup_allow_list []string
  34857. block_list *[]string
  34858. appendblock_list []string
  34859. group_block_list *[]string
  34860. appendgroup_block_list []string
  34861. clearedFields map[string]struct{}
  34862. agent *uint64
  34863. clearedagent bool
  34864. done bool
  34865. oldValue func(context.Context) (*Whatsapp, error)
  34866. predicates []predicate.Whatsapp
  34867. }
  34868. var _ ent.Mutation = (*WhatsappMutation)(nil)
  34869. // whatsappOption allows management of the mutation configuration using functional options.
  34870. type whatsappOption func(*WhatsappMutation)
  34871. // newWhatsappMutation creates new mutation for the Whatsapp entity.
  34872. func newWhatsappMutation(c config, op Op, opts ...whatsappOption) *WhatsappMutation {
  34873. m := &WhatsappMutation{
  34874. config: c,
  34875. op: op,
  34876. typ: TypeWhatsapp,
  34877. clearedFields: make(map[string]struct{}),
  34878. }
  34879. for _, opt := range opts {
  34880. opt(m)
  34881. }
  34882. return m
  34883. }
  34884. // withWhatsappID sets the ID field of the mutation.
  34885. func withWhatsappID(id uint64) whatsappOption {
  34886. return func(m *WhatsappMutation) {
  34887. var (
  34888. err error
  34889. once sync.Once
  34890. value *Whatsapp
  34891. )
  34892. m.oldValue = func(ctx context.Context) (*Whatsapp, error) {
  34893. once.Do(func() {
  34894. if m.done {
  34895. err = errors.New("querying old values post mutation is not allowed")
  34896. } else {
  34897. value, err = m.Client().Whatsapp.Get(ctx, id)
  34898. }
  34899. })
  34900. return value, err
  34901. }
  34902. m.id = &id
  34903. }
  34904. }
  34905. // withWhatsapp sets the old Whatsapp of the mutation.
  34906. func withWhatsapp(node *Whatsapp) whatsappOption {
  34907. return func(m *WhatsappMutation) {
  34908. m.oldValue = func(context.Context) (*Whatsapp, error) {
  34909. return node, nil
  34910. }
  34911. m.id = &node.ID
  34912. }
  34913. }
  34914. // Client returns a new `ent.Client` from the mutation. If the mutation was
  34915. // executed in a transaction (ent.Tx), a transactional client is returned.
  34916. func (m WhatsappMutation) Client() *Client {
  34917. client := &Client{config: m.config}
  34918. client.init()
  34919. return client
  34920. }
  34921. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  34922. // it returns an error otherwise.
  34923. func (m WhatsappMutation) Tx() (*Tx, error) {
  34924. if _, ok := m.driver.(*txDriver); !ok {
  34925. return nil, errors.New("ent: mutation is not running in a transaction")
  34926. }
  34927. tx := &Tx{config: m.config}
  34928. tx.init()
  34929. return tx, nil
  34930. }
  34931. // SetID sets the value of the id field. Note that this
  34932. // operation is only accepted on creation of Whatsapp entities.
  34933. func (m *WhatsappMutation) SetID(id uint64) {
  34934. m.id = &id
  34935. }
  34936. // ID returns the ID value in the mutation. Note that the ID is only available
  34937. // if it was provided to the builder or after it was returned from the database.
  34938. func (m *WhatsappMutation) ID() (id uint64, exists bool) {
  34939. if m.id == nil {
  34940. return
  34941. }
  34942. return *m.id, true
  34943. }
  34944. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  34945. // That means, if the mutation is applied within a transaction with an isolation level such
  34946. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  34947. // or updated by the mutation.
  34948. func (m *WhatsappMutation) IDs(ctx context.Context) ([]uint64, error) {
  34949. switch {
  34950. case m.op.Is(OpUpdateOne | OpDeleteOne):
  34951. id, exists := m.ID()
  34952. if exists {
  34953. return []uint64{id}, nil
  34954. }
  34955. fallthrough
  34956. case m.op.Is(OpUpdate | OpDelete):
  34957. return m.Client().Whatsapp.Query().Where(m.predicates...).IDs(ctx)
  34958. default:
  34959. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  34960. }
  34961. }
  34962. // SetCreatedAt sets the "created_at" field.
  34963. func (m *WhatsappMutation) SetCreatedAt(t time.Time) {
  34964. m.created_at = &t
  34965. }
  34966. // CreatedAt returns the value of the "created_at" field in the mutation.
  34967. func (m *WhatsappMutation) CreatedAt() (r time.Time, exists bool) {
  34968. v := m.created_at
  34969. if v == nil {
  34970. return
  34971. }
  34972. return *v, true
  34973. }
  34974. // OldCreatedAt returns the old "created_at" field's value of the Whatsapp entity.
  34975. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34976. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34977. func (m *WhatsappMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  34978. if !m.op.Is(OpUpdateOne) {
  34979. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  34980. }
  34981. if m.id == nil || m.oldValue == nil {
  34982. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  34983. }
  34984. oldValue, err := m.oldValue(ctx)
  34985. if err != nil {
  34986. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  34987. }
  34988. return oldValue.CreatedAt, nil
  34989. }
  34990. // ResetCreatedAt resets all changes to the "created_at" field.
  34991. func (m *WhatsappMutation) ResetCreatedAt() {
  34992. m.created_at = nil
  34993. }
  34994. // SetUpdatedAt sets the "updated_at" field.
  34995. func (m *WhatsappMutation) SetUpdatedAt(t time.Time) {
  34996. m.updated_at = &t
  34997. }
  34998. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  34999. func (m *WhatsappMutation) UpdatedAt() (r time.Time, exists bool) {
  35000. v := m.updated_at
  35001. if v == nil {
  35002. return
  35003. }
  35004. return *v, true
  35005. }
  35006. // OldUpdatedAt returns the old "updated_at" field's value of the Whatsapp entity.
  35007. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35008. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35009. func (m *WhatsappMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  35010. if !m.op.Is(OpUpdateOne) {
  35011. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  35012. }
  35013. if m.id == nil || m.oldValue == nil {
  35014. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  35015. }
  35016. oldValue, err := m.oldValue(ctx)
  35017. if err != nil {
  35018. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  35019. }
  35020. return oldValue.UpdatedAt, nil
  35021. }
  35022. // ResetUpdatedAt resets all changes to the "updated_at" field.
  35023. func (m *WhatsappMutation) ResetUpdatedAt() {
  35024. m.updated_at = nil
  35025. }
  35026. // SetStatus sets the "status" field.
  35027. func (m *WhatsappMutation) SetStatus(u uint8) {
  35028. m.status = &u
  35029. m.addstatus = nil
  35030. }
  35031. // Status returns the value of the "status" field in the mutation.
  35032. func (m *WhatsappMutation) Status() (r uint8, exists bool) {
  35033. v := m.status
  35034. if v == nil {
  35035. return
  35036. }
  35037. return *v, true
  35038. }
  35039. // OldStatus returns the old "status" field's value of the Whatsapp entity.
  35040. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35041. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35042. func (m *WhatsappMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  35043. if !m.op.Is(OpUpdateOne) {
  35044. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  35045. }
  35046. if m.id == nil || m.oldValue == nil {
  35047. return v, errors.New("OldStatus requires an ID field in the mutation")
  35048. }
  35049. oldValue, err := m.oldValue(ctx)
  35050. if err != nil {
  35051. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  35052. }
  35053. return oldValue.Status, nil
  35054. }
  35055. // AddStatus adds u to the "status" field.
  35056. func (m *WhatsappMutation) AddStatus(u int8) {
  35057. if m.addstatus != nil {
  35058. *m.addstatus += u
  35059. } else {
  35060. m.addstatus = &u
  35061. }
  35062. }
  35063. // AddedStatus returns the value that was added to the "status" field in this mutation.
  35064. func (m *WhatsappMutation) AddedStatus() (r int8, exists bool) {
  35065. v := m.addstatus
  35066. if v == nil {
  35067. return
  35068. }
  35069. return *v, true
  35070. }
  35071. // ClearStatus clears the value of the "status" field.
  35072. func (m *WhatsappMutation) ClearStatus() {
  35073. m.status = nil
  35074. m.addstatus = nil
  35075. m.clearedFields[whatsapp.FieldStatus] = struct{}{}
  35076. }
  35077. // StatusCleared returns if the "status" field was cleared in this mutation.
  35078. func (m *WhatsappMutation) StatusCleared() bool {
  35079. _, ok := m.clearedFields[whatsapp.FieldStatus]
  35080. return ok
  35081. }
  35082. // ResetStatus resets all changes to the "status" field.
  35083. func (m *WhatsappMutation) ResetStatus() {
  35084. m.status = nil
  35085. m.addstatus = nil
  35086. delete(m.clearedFields, whatsapp.FieldStatus)
  35087. }
  35088. // SetDeletedAt sets the "deleted_at" field.
  35089. func (m *WhatsappMutation) SetDeletedAt(t time.Time) {
  35090. m.deleted_at = &t
  35091. }
  35092. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  35093. func (m *WhatsappMutation) DeletedAt() (r time.Time, exists bool) {
  35094. v := m.deleted_at
  35095. if v == nil {
  35096. return
  35097. }
  35098. return *v, true
  35099. }
  35100. // OldDeletedAt returns the old "deleted_at" field's value of the Whatsapp entity.
  35101. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35102. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35103. func (m *WhatsappMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  35104. if !m.op.Is(OpUpdateOne) {
  35105. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  35106. }
  35107. if m.id == nil || m.oldValue == nil {
  35108. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  35109. }
  35110. oldValue, err := m.oldValue(ctx)
  35111. if err != nil {
  35112. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  35113. }
  35114. return oldValue.DeletedAt, nil
  35115. }
  35116. // ClearDeletedAt clears the value of the "deleted_at" field.
  35117. func (m *WhatsappMutation) ClearDeletedAt() {
  35118. m.deleted_at = nil
  35119. m.clearedFields[whatsapp.FieldDeletedAt] = struct{}{}
  35120. }
  35121. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  35122. func (m *WhatsappMutation) DeletedAtCleared() bool {
  35123. _, ok := m.clearedFields[whatsapp.FieldDeletedAt]
  35124. return ok
  35125. }
  35126. // ResetDeletedAt resets all changes to the "deleted_at" field.
  35127. func (m *WhatsappMutation) ResetDeletedAt() {
  35128. m.deleted_at = nil
  35129. delete(m.clearedFields, whatsapp.FieldDeletedAt)
  35130. }
  35131. // SetWaID sets the "wa_id" field.
  35132. func (m *WhatsappMutation) SetWaID(s string) {
  35133. m.wa_id = &s
  35134. }
  35135. // WaID returns the value of the "wa_id" field in the mutation.
  35136. func (m *WhatsappMutation) WaID() (r string, exists bool) {
  35137. v := m.wa_id
  35138. if v == nil {
  35139. return
  35140. }
  35141. return *v, true
  35142. }
  35143. // OldWaID returns the old "wa_id" field's value of the Whatsapp entity.
  35144. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35145. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35146. func (m *WhatsappMutation) OldWaID(ctx context.Context) (v string, err error) {
  35147. if !m.op.Is(OpUpdateOne) {
  35148. return v, errors.New("OldWaID is only allowed on UpdateOne operations")
  35149. }
  35150. if m.id == nil || m.oldValue == nil {
  35151. return v, errors.New("OldWaID requires an ID field in the mutation")
  35152. }
  35153. oldValue, err := m.oldValue(ctx)
  35154. if err != nil {
  35155. return v, fmt.Errorf("querying old value for OldWaID: %w", err)
  35156. }
  35157. return oldValue.WaID, nil
  35158. }
  35159. // ClearWaID clears the value of the "wa_id" field.
  35160. func (m *WhatsappMutation) ClearWaID() {
  35161. m.wa_id = nil
  35162. m.clearedFields[whatsapp.FieldWaID] = struct{}{}
  35163. }
  35164. // WaIDCleared returns if the "wa_id" field was cleared in this mutation.
  35165. func (m *WhatsappMutation) WaIDCleared() bool {
  35166. _, ok := m.clearedFields[whatsapp.FieldWaID]
  35167. return ok
  35168. }
  35169. // ResetWaID resets all changes to the "wa_id" field.
  35170. func (m *WhatsappMutation) ResetWaID() {
  35171. m.wa_id = nil
  35172. delete(m.clearedFields, whatsapp.FieldWaID)
  35173. }
  35174. // SetWaName sets the "wa_name" field.
  35175. func (m *WhatsappMutation) SetWaName(s string) {
  35176. m.wa_name = &s
  35177. }
  35178. // WaName returns the value of the "wa_name" field in the mutation.
  35179. func (m *WhatsappMutation) WaName() (r string, exists bool) {
  35180. v := m.wa_name
  35181. if v == nil {
  35182. return
  35183. }
  35184. return *v, true
  35185. }
  35186. // OldWaName returns the old "wa_name" field's value of the Whatsapp entity.
  35187. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35188. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35189. func (m *WhatsappMutation) OldWaName(ctx context.Context) (v string, err error) {
  35190. if !m.op.Is(OpUpdateOne) {
  35191. return v, errors.New("OldWaName is only allowed on UpdateOne operations")
  35192. }
  35193. if m.id == nil || m.oldValue == nil {
  35194. return v, errors.New("OldWaName requires an ID field in the mutation")
  35195. }
  35196. oldValue, err := m.oldValue(ctx)
  35197. if err != nil {
  35198. return v, fmt.Errorf("querying old value for OldWaName: %w", err)
  35199. }
  35200. return oldValue.WaName, nil
  35201. }
  35202. // ClearWaName clears the value of the "wa_name" field.
  35203. func (m *WhatsappMutation) ClearWaName() {
  35204. m.wa_name = nil
  35205. m.clearedFields[whatsapp.FieldWaName] = struct{}{}
  35206. }
  35207. // WaNameCleared returns if the "wa_name" field was cleared in this mutation.
  35208. func (m *WhatsappMutation) WaNameCleared() bool {
  35209. _, ok := m.clearedFields[whatsapp.FieldWaName]
  35210. return ok
  35211. }
  35212. // ResetWaName resets all changes to the "wa_name" field.
  35213. func (m *WhatsappMutation) ResetWaName() {
  35214. m.wa_name = nil
  35215. delete(m.clearedFields, whatsapp.FieldWaName)
  35216. }
  35217. // SetCallback sets the "callback" field.
  35218. func (m *WhatsappMutation) SetCallback(s string) {
  35219. m.callback = &s
  35220. }
  35221. // Callback returns the value of the "callback" field in the mutation.
  35222. func (m *WhatsappMutation) Callback() (r string, exists bool) {
  35223. v := m.callback
  35224. if v == nil {
  35225. return
  35226. }
  35227. return *v, true
  35228. }
  35229. // OldCallback returns the old "callback" field's value of the Whatsapp entity.
  35230. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35231. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35232. func (m *WhatsappMutation) OldCallback(ctx context.Context) (v string, err error) {
  35233. if !m.op.Is(OpUpdateOne) {
  35234. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  35235. }
  35236. if m.id == nil || m.oldValue == nil {
  35237. return v, errors.New("OldCallback requires an ID field in the mutation")
  35238. }
  35239. oldValue, err := m.oldValue(ctx)
  35240. if err != nil {
  35241. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  35242. }
  35243. return oldValue.Callback, nil
  35244. }
  35245. // ClearCallback clears the value of the "callback" field.
  35246. func (m *WhatsappMutation) ClearCallback() {
  35247. m.callback = nil
  35248. m.clearedFields[whatsapp.FieldCallback] = struct{}{}
  35249. }
  35250. // CallbackCleared returns if the "callback" field was cleared in this mutation.
  35251. func (m *WhatsappMutation) CallbackCleared() bool {
  35252. _, ok := m.clearedFields[whatsapp.FieldCallback]
  35253. return ok
  35254. }
  35255. // ResetCallback resets all changes to the "callback" field.
  35256. func (m *WhatsappMutation) ResetCallback() {
  35257. m.callback = nil
  35258. delete(m.clearedFields, whatsapp.FieldCallback)
  35259. }
  35260. // SetAgentID sets the "agent_id" field.
  35261. func (m *WhatsappMutation) SetAgentID(u uint64) {
  35262. m.agent = &u
  35263. }
  35264. // AgentID returns the value of the "agent_id" field in the mutation.
  35265. func (m *WhatsappMutation) AgentID() (r uint64, exists bool) {
  35266. v := m.agent
  35267. if v == nil {
  35268. return
  35269. }
  35270. return *v, true
  35271. }
  35272. // OldAgentID returns the old "agent_id" field's value of the Whatsapp entity.
  35273. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35274. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35275. func (m *WhatsappMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  35276. if !m.op.Is(OpUpdateOne) {
  35277. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  35278. }
  35279. if m.id == nil || m.oldValue == nil {
  35280. return v, errors.New("OldAgentID requires an ID field in the mutation")
  35281. }
  35282. oldValue, err := m.oldValue(ctx)
  35283. if err != nil {
  35284. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  35285. }
  35286. return oldValue.AgentID, nil
  35287. }
  35288. // ResetAgentID resets all changes to the "agent_id" field.
  35289. func (m *WhatsappMutation) ResetAgentID() {
  35290. m.agent = nil
  35291. }
  35292. // SetAccount sets the "account" field.
  35293. func (m *WhatsappMutation) SetAccount(s string) {
  35294. m.account = &s
  35295. }
  35296. // Account returns the value of the "account" field in the mutation.
  35297. func (m *WhatsappMutation) Account() (r string, exists bool) {
  35298. v := m.account
  35299. if v == nil {
  35300. return
  35301. }
  35302. return *v, true
  35303. }
  35304. // OldAccount returns the old "account" field's value of the Whatsapp entity.
  35305. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35306. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35307. func (m *WhatsappMutation) OldAccount(ctx context.Context) (v string, err error) {
  35308. if !m.op.Is(OpUpdateOne) {
  35309. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  35310. }
  35311. if m.id == nil || m.oldValue == nil {
  35312. return v, errors.New("OldAccount requires an ID field in the mutation")
  35313. }
  35314. oldValue, err := m.oldValue(ctx)
  35315. if err != nil {
  35316. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  35317. }
  35318. return oldValue.Account, nil
  35319. }
  35320. // ClearAccount clears the value of the "account" field.
  35321. func (m *WhatsappMutation) ClearAccount() {
  35322. m.account = nil
  35323. m.clearedFields[whatsapp.FieldAccount] = struct{}{}
  35324. }
  35325. // AccountCleared returns if the "account" field was cleared in this mutation.
  35326. func (m *WhatsappMutation) AccountCleared() bool {
  35327. _, ok := m.clearedFields[whatsapp.FieldAccount]
  35328. return ok
  35329. }
  35330. // ResetAccount resets all changes to the "account" field.
  35331. func (m *WhatsappMutation) ResetAccount() {
  35332. m.account = nil
  35333. delete(m.clearedFields, whatsapp.FieldAccount)
  35334. }
  35335. // SetCc sets the "cc" field.
  35336. func (m *WhatsappMutation) SetCc(s string) {
  35337. m.cc = &s
  35338. }
  35339. // Cc returns the value of the "cc" field in the mutation.
  35340. func (m *WhatsappMutation) Cc() (r string, exists bool) {
  35341. v := m.cc
  35342. if v == nil {
  35343. return
  35344. }
  35345. return *v, true
  35346. }
  35347. // OldCc returns the old "cc" field's value of the Whatsapp entity.
  35348. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35349. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35350. func (m *WhatsappMutation) OldCc(ctx context.Context) (v string, err error) {
  35351. if !m.op.Is(OpUpdateOne) {
  35352. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  35353. }
  35354. if m.id == nil || m.oldValue == nil {
  35355. return v, errors.New("OldCc requires an ID field in the mutation")
  35356. }
  35357. oldValue, err := m.oldValue(ctx)
  35358. if err != nil {
  35359. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  35360. }
  35361. return oldValue.Cc, nil
  35362. }
  35363. // ResetCc resets all changes to the "cc" field.
  35364. func (m *WhatsappMutation) ResetCc() {
  35365. m.cc = nil
  35366. }
  35367. // SetPhone sets the "phone" field.
  35368. func (m *WhatsappMutation) SetPhone(s string) {
  35369. m.phone = &s
  35370. }
  35371. // Phone returns the value of the "phone" field in the mutation.
  35372. func (m *WhatsappMutation) Phone() (r string, exists bool) {
  35373. v := m.phone
  35374. if v == nil {
  35375. return
  35376. }
  35377. return *v, true
  35378. }
  35379. // OldPhone returns the old "phone" field's value of the Whatsapp entity.
  35380. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35381. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35382. func (m *WhatsappMutation) OldPhone(ctx context.Context) (v string, err error) {
  35383. if !m.op.Is(OpUpdateOne) {
  35384. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  35385. }
  35386. if m.id == nil || m.oldValue == nil {
  35387. return v, errors.New("OldPhone requires an ID field in the mutation")
  35388. }
  35389. oldValue, err := m.oldValue(ctx)
  35390. if err != nil {
  35391. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  35392. }
  35393. return oldValue.Phone, nil
  35394. }
  35395. // ResetPhone resets all changes to the "phone" field.
  35396. func (m *WhatsappMutation) ResetPhone() {
  35397. m.phone = nil
  35398. }
  35399. // SetCcPhone sets the "cc_phone" field.
  35400. func (m *WhatsappMutation) SetCcPhone(s string) {
  35401. m.cc_phone = &s
  35402. }
  35403. // CcPhone returns the value of the "cc_phone" field in the mutation.
  35404. func (m *WhatsappMutation) CcPhone() (r string, exists bool) {
  35405. v := m.cc_phone
  35406. if v == nil {
  35407. return
  35408. }
  35409. return *v, true
  35410. }
  35411. // OldCcPhone returns the old "cc_phone" field's value of the Whatsapp entity.
  35412. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35413. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35414. func (m *WhatsappMutation) OldCcPhone(ctx context.Context) (v string, err error) {
  35415. if !m.op.Is(OpUpdateOne) {
  35416. return v, errors.New("OldCcPhone is only allowed on UpdateOne operations")
  35417. }
  35418. if m.id == nil || m.oldValue == nil {
  35419. return v, errors.New("OldCcPhone requires an ID field in the mutation")
  35420. }
  35421. oldValue, err := m.oldValue(ctx)
  35422. if err != nil {
  35423. return v, fmt.Errorf("querying old value for OldCcPhone: %w", err)
  35424. }
  35425. return oldValue.CcPhone, nil
  35426. }
  35427. // ResetCcPhone resets all changes to the "cc_phone" field.
  35428. func (m *WhatsappMutation) ResetCcPhone() {
  35429. m.cc_phone = nil
  35430. }
  35431. // SetPhoneName sets the "phone_name" field.
  35432. func (m *WhatsappMutation) SetPhoneName(s string) {
  35433. m.phone_name = &s
  35434. }
  35435. // PhoneName returns the value of the "phone_name" field in the mutation.
  35436. func (m *WhatsappMutation) PhoneName() (r string, exists bool) {
  35437. v := m.phone_name
  35438. if v == nil {
  35439. return
  35440. }
  35441. return *v, true
  35442. }
  35443. // OldPhoneName returns the old "phone_name" field's value of the Whatsapp entity.
  35444. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35445. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35446. func (m *WhatsappMutation) OldPhoneName(ctx context.Context) (v string, err error) {
  35447. if !m.op.Is(OpUpdateOne) {
  35448. return v, errors.New("OldPhoneName is only allowed on UpdateOne operations")
  35449. }
  35450. if m.id == nil || m.oldValue == nil {
  35451. return v, errors.New("OldPhoneName requires an ID field in the mutation")
  35452. }
  35453. oldValue, err := m.oldValue(ctx)
  35454. if err != nil {
  35455. return v, fmt.Errorf("querying old value for OldPhoneName: %w", err)
  35456. }
  35457. return oldValue.PhoneName, nil
  35458. }
  35459. // ResetPhoneName resets all changes to the "phone_name" field.
  35460. func (m *WhatsappMutation) ResetPhoneName() {
  35461. m.phone_name = nil
  35462. }
  35463. // SetPhoneStatus sets the "phone_status" field.
  35464. func (m *WhatsappMutation) SetPhoneStatus(i int8) {
  35465. m.phone_status = &i
  35466. m.addphone_status = nil
  35467. }
  35468. // PhoneStatus returns the value of the "phone_status" field in the mutation.
  35469. func (m *WhatsappMutation) PhoneStatus() (r int8, exists bool) {
  35470. v := m.phone_status
  35471. if v == nil {
  35472. return
  35473. }
  35474. return *v, true
  35475. }
  35476. // OldPhoneStatus returns the old "phone_status" field's value of the Whatsapp entity.
  35477. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35478. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35479. func (m *WhatsappMutation) OldPhoneStatus(ctx context.Context) (v int8, err error) {
  35480. if !m.op.Is(OpUpdateOne) {
  35481. return v, errors.New("OldPhoneStatus is only allowed on UpdateOne operations")
  35482. }
  35483. if m.id == nil || m.oldValue == nil {
  35484. return v, errors.New("OldPhoneStatus requires an ID field in the mutation")
  35485. }
  35486. oldValue, err := m.oldValue(ctx)
  35487. if err != nil {
  35488. return v, fmt.Errorf("querying old value for OldPhoneStatus: %w", err)
  35489. }
  35490. return oldValue.PhoneStatus, nil
  35491. }
  35492. // AddPhoneStatus adds i to the "phone_status" field.
  35493. func (m *WhatsappMutation) AddPhoneStatus(i int8) {
  35494. if m.addphone_status != nil {
  35495. *m.addphone_status += i
  35496. } else {
  35497. m.addphone_status = &i
  35498. }
  35499. }
  35500. // AddedPhoneStatus returns the value that was added to the "phone_status" field in this mutation.
  35501. func (m *WhatsappMutation) AddedPhoneStatus() (r int8, exists bool) {
  35502. v := m.addphone_status
  35503. if v == nil {
  35504. return
  35505. }
  35506. return *v, true
  35507. }
  35508. // ResetPhoneStatus resets all changes to the "phone_status" field.
  35509. func (m *WhatsappMutation) ResetPhoneStatus() {
  35510. m.phone_status = nil
  35511. m.addphone_status = nil
  35512. }
  35513. // SetOrganizationID sets the "organization_id" field.
  35514. func (m *WhatsappMutation) SetOrganizationID(u uint64) {
  35515. m.organization_id = &u
  35516. m.addorganization_id = nil
  35517. }
  35518. // OrganizationID returns the value of the "organization_id" field in the mutation.
  35519. func (m *WhatsappMutation) OrganizationID() (r uint64, exists bool) {
  35520. v := m.organization_id
  35521. if v == nil {
  35522. return
  35523. }
  35524. return *v, true
  35525. }
  35526. // OldOrganizationID returns the old "organization_id" field's value of the Whatsapp entity.
  35527. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35528. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35529. func (m *WhatsappMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  35530. if !m.op.Is(OpUpdateOne) {
  35531. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  35532. }
  35533. if m.id == nil || m.oldValue == nil {
  35534. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  35535. }
  35536. oldValue, err := m.oldValue(ctx)
  35537. if err != nil {
  35538. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  35539. }
  35540. return oldValue.OrganizationID, nil
  35541. }
  35542. // AddOrganizationID adds u to the "organization_id" field.
  35543. func (m *WhatsappMutation) AddOrganizationID(u int64) {
  35544. if m.addorganization_id != nil {
  35545. *m.addorganization_id += u
  35546. } else {
  35547. m.addorganization_id = &u
  35548. }
  35549. }
  35550. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  35551. func (m *WhatsappMutation) AddedOrganizationID() (r int64, exists bool) {
  35552. v := m.addorganization_id
  35553. if v == nil {
  35554. return
  35555. }
  35556. return *v, true
  35557. }
  35558. // ClearOrganizationID clears the value of the "organization_id" field.
  35559. func (m *WhatsappMutation) ClearOrganizationID() {
  35560. m.organization_id = nil
  35561. m.addorganization_id = nil
  35562. m.clearedFields[whatsapp.FieldOrganizationID] = struct{}{}
  35563. }
  35564. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  35565. func (m *WhatsappMutation) OrganizationIDCleared() bool {
  35566. _, ok := m.clearedFields[whatsapp.FieldOrganizationID]
  35567. return ok
  35568. }
  35569. // ResetOrganizationID resets all changes to the "organization_id" field.
  35570. func (m *WhatsappMutation) ResetOrganizationID() {
  35571. m.organization_id = nil
  35572. m.addorganization_id = nil
  35573. delete(m.clearedFields, whatsapp.FieldOrganizationID)
  35574. }
  35575. // SetAPIBase sets the "api_base" field.
  35576. func (m *WhatsappMutation) SetAPIBase(s string) {
  35577. m.api_base = &s
  35578. }
  35579. // APIBase returns the value of the "api_base" field in the mutation.
  35580. func (m *WhatsappMutation) APIBase() (r string, exists bool) {
  35581. v := m.api_base
  35582. if v == nil {
  35583. return
  35584. }
  35585. return *v, true
  35586. }
  35587. // OldAPIBase returns the old "api_base" 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) OldAPIBase(ctx context.Context) (v string, err error) {
  35591. if !m.op.Is(OpUpdateOne) {
  35592. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  35593. }
  35594. if m.id == nil || m.oldValue == nil {
  35595. return v, errors.New("OldAPIBase 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 OldAPIBase: %w", err)
  35600. }
  35601. return oldValue.APIBase, nil
  35602. }
  35603. // ClearAPIBase clears the value of the "api_base" field.
  35604. func (m *WhatsappMutation) ClearAPIBase() {
  35605. m.api_base = nil
  35606. m.clearedFields[whatsapp.FieldAPIBase] = struct{}{}
  35607. }
  35608. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  35609. func (m *WhatsappMutation) APIBaseCleared() bool {
  35610. _, ok := m.clearedFields[whatsapp.FieldAPIBase]
  35611. return ok
  35612. }
  35613. // ResetAPIBase resets all changes to the "api_base" field.
  35614. func (m *WhatsappMutation) ResetAPIBase() {
  35615. m.api_base = nil
  35616. delete(m.clearedFields, whatsapp.FieldAPIBase)
  35617. }
  35618. // SetAPIKey sets the "api_key" field.
  35619. func (m *WhatsappMutation) SetAPIKey(s string) {
  35620. m.api_key = &s
  35621. }
  35622. // APIKey returns the value of the "api_key" field in the mutation.
  35623. func (m *WhatsappMutation) APIKey() (r string, exists bool) {
  35624. v := m.api_key
  35625. if v == nil {
  35626. return
  35627. }
  35628. return *v, true
  35629. }
  35630. // OldAPIKey returns the old "api_key" field's value of the Whatsapp entity.
  35631. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35632. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35633. func (m *WhatsappMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  35634. if !m.op.Is(OpUpdateOne) {
  35635. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  35636. }
  35637. if m.id == nil || m.oldValue == nil {
  35638. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  35639. }
  35640. oldValue, err := m.oldValue(ctx)
  35641. if err != nil {
  35642. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  35643. }
  35644. return oldValue.APIKey, nil
  35645. }
  35646. // ClearAPIKey clears the value of the "api_key" field.
  35647. func (m *WhatsappMutation) ClearAPIKey() {
  35648. m.api_key = nil
  35649. m.clearedFields[whatsapp.FieldAPIKey] = struct{}{}
  35650. }
  35651. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  35652. func (m *WhatsappMutation) APIKeyCleared() bool {
  35653. _, ok := m.clearedFields[whatsapp.FieldAPIKey]
  35654. return ok
  35655. }
  35656. // ResetAPIKey resets all changes to the "api_key" field.
  35657. func (m *WhatsappMutation) ResetAPIKey() {
  35658. m.api_key = nil
  35659. delete(m.clearedFields, whatsapp.FieldAPIKey)
  35660. }
  35661. // SetAllowList sets the "allow_list" field.
  35662. func (m *WhatsappMutation) SetAllowList(s []string) {
  35663. m.allow_list = &s
  35664. m.appendallow_list = nil
  35665. }
  35666. // AllowList returns the value of the "allow_list" field in the mutation.
  35667. func (m *WhatsappMutation) AllowList() (r []string, exists bool) {
  35668. v := m.allow_list
  35669. if v == nil {
  35670. return
  35671. }
  35672. return *v, true
  35673. }
  35674. // OldAllowList returns the old "allow_list" field's value of the Whatsapp entity.
  35675. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35676. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35677. func (m *WhatsappMutation) OldAllowList(ctx context.Context) (v []string, err error) {
  35678. if !m.op.Is(OpUpdateOne) {
  35679. return v, errors.New("OldAllowList is only allowed on UpdateOne operations")
  35680. }
  35681. if m.id == nil || m.oldValue == nil {
  35682. return v, errors.New("OldAllowList requires an ID field in the mutation")
  35683. }
  35684. oldValue, err := m.oldValue(ctx)
  35685. if err != nil {
  35686. return v, fmt.Errorf("querying old value for OldAllowList: %w", err)
  35687. }
  35688. return oldValue.AllowList, nil
  35689. }
  35690. // AppendAllowList adds s to the "allow_list" field.
  35691. func (m *WhatsappMutation) AppendAllowList(s []string) {
  35692. m.appendallow_list = append(m.appendallow_list, s...)
  35693. }
  35694. // AppendedAllowList returns the list of values that were appended to the "allow_list" field in this mutation.
  35695. func (m *WhatsappMutation) AppendedAllowList() ([]string, bool) {
  35696. if len(m.appendallow_list) == 0 {
  35697. return nil, false
  35698. }
  35699. return m.appendallow_list, true
  35700. }
  35701. // ClearAllowList clears the value of the "allow_list" field.
  35702. func (m *WhatsappMutation) ClearAllowList() {
  35703. m.allow_list = nil
  35704. m.appendallow_list = nil
  35705. m.clearedFields[whatsapp.FieldAllowList] = struct{}{}
  35706. }
  35707. // AllowListCleared returns if the "allow_list" field was cleared in this mutation.
  35708. func (m *WhatsappMutation) AllowListCleared() bool {
  35709. _, ok := m.clearedFields[whatsapp.FieldAllowList]
  35710. return ok
  35711. }
  35712. // ResetAllowList resets all changes to the "allow_list" field.
  35713. func (m *WhatsappMutation) ResetAllowList() {
  35714. m.allow_list = nil
  35715. m.appendallow_list = nil
  35716. delete(m.clearedFields, whatsapp.FieldAllowList)
  35717. }
  35718. // SetGroupAllowList sets the "group_allow_list" field.
  35719. func (m *WhatsappMutation) SetGroupAllowList(s []string) {
  35720. m.group_allow_list = &s
  35721. m.appendgroup_allow_list = nil
  35722. }
  35723. // GroupAllowList returns the value of the "group_allow_list" field in the mutation.
  35724. func (m *WhatsappMutation) GroupAllowList() (r []string, exists bool) {
  35725. v := m.group_allow_list
  35726. if v == nil {
  35727. return
  35728. }
  35729. return *v, true
  35730. }
  35731. // OldGroupAllowList returns the old "group_allow_list" field's value of the Whatsapp entity.
  35732. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35733. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35734. func (m *WhatsappMutation) OldGroupAllowList(ctx context.Context) (v []string, err error) {
  35735. if !m.op.Is(OpUpdateOne) {
  35736. return v, errors.New("OldGroupAllowList is only allowed on UpdateOne operations")
  35737. }
  35738. if m.id == nil || m.oldValue == nil {
  35739. return v, errors.New("OldGroupAllowList requires an ID field in the mutation")
  35740. }
  35741. oldValue, err := m.oldValue(ctx)
  35742. if err != nil {
  35743. return v, fmt.Errorf("querying old value for OldGroupAllowList: %w", err)
  35744. }
  35745. return oldValue.GroupAllowList, nil
  35746. }
  35747. // AppendGroupAllowList adds s to the "group_allow_list" field.
  35748. func (m *WhatsappMutation) AppendGroupAllowList(s []string) {
  35749. m.appendgroup_allow_list = append(m.appendgroup_allow_list, s...)
  35750. }
  35751. // AppendedGroupAllowList returns the list of values that were appended to the "group_allow_list" field in this mutation.
  35752. func (m *WhatsappMutation) AppendedGroupAllowList() ([]string, bool) {
  35753. if len(m.appendgroup_allow_list) == 0 {
  35754. return nil, false
  35755. }
  35756. return m.appendgroup_allow_list, true
  35757. }
  35758. // ClearGroupAllowList clears the value of the "group_allow_list" field.
  35759. func (m *WhatsappMutation) ClearGroupAllowList() {
  35760. m.group_allow_list = nil
  35761. m.appendgroup_allow_list = nil
  35762. m.clearedFields[whatsapp.FieldGroupAllowList] = struct{}{}
  35763. }
  35764. // GroupAllowListCleared returns if the "group_allow_list" field was cleared in this mutation.
  35765. func (m *WhatsappMutation) GroupAllowListCleared() bool {
  35766. _, ok := m.clearedFields[whatsapp.FieldGroupAllowList]
  35767. return ok
  35768. }
  35769. // ResetGroupAllowList resets all changes to the "group_allow_list" field.
  35770. func (m *WhatsappMutation) ResetGroupAllowList() {
  35771. m.group_allow_list = nil
  35772. m.appendgroup_allow_list = nil
  35773. delete(m.clearedFields, whatsapp.FieldGroupAllowList)
  35774. }
  35775. // SetBlockList sets the "block_list" field.
  35776. func (m *WhatsappMutation) SetBlockList(s []string) {
  35777. m.block_list = &s
  35778. m.appendblock_list = nil
  35779. }
  35780. // BlockList returns the value of the "block_list" field in the mutation.
  35781. func (m *WhatsappMutation) BlockList() (r []string, exists bool) {
  35782. v := m.block_list
  35783. if v == nil {
  35784. return
  35785. }
  35786. return *v, true
  35787. }
  35788. // OldBlockList returns the old "block_list" field's value of the Whatsapp entity.
  35789. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35790. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35791. func (m *WhatsappMutation) OldBlockList(ctx context.Context) (v []string, err error) {
  35792. if !m.op.Is(OpUpdateOne) {
  35793. return v, errors.New("OldBlockList is only allowed on UpdateOne operations")
  35794. }
  35795. if m.id == nil || m.oldValue == nil {
  35796. return v, errors.New("OldBlockList requires an ID field in the mutation")
  35797. }
  35798. oldValue, err := m.oldValue(ctx)
  35799. if err != nil {
  35800. return v, fmt.Errorf("querying old value for OldBlockList: %w", err)
  35801. }
  35802. return oldValue.BlockList, nil
  35803. }
  35804. // AppendBlockList adds s to the "block_list" field.
  35805. func (m *WhatsappMutation) AppendBlockList(s []string) {
  35806. m.appendblock_list = append(m.appendblock_list, s...)
  35807. }
  35808. // AppendedBlockList returns the list of values that were appended to the "block_list" field in this mutation.
  35809. func (m *WhatsappMutation) AppendedBlockList() ([]string, bool) {
  35810. if len(m.appendblock_list) == 0 {
  35811. return nil, false
  35812. }
  35813. return m.appendblock_list, true
  35814. }
  35815. // ClearBlockList clears the value of the "block_list" field.
  35816. func (m *WhatsappMutation) ClearBlockList() {
  35817. m.block_list = nil
  35818. m.appendblock_list = nil
  35819. m.clearedFields[whatsapp.FieldBlockList] = struct{}{}
  35820. }
  35821. // BlockListCleared returns if the "block_list" field was cleared in this mutation.
  35822. func (m *WhatsappMutation) BlockListCleared() bool {
  35823. _, ok := m.clearedFields[whatsapp.FieldBlockList]
  35824. return ok
  35825. }
  35826. // ResetBlockList resets all changes to the "block_list" field.
  35827. func (m *WhatsappMutation) ResetBlockList() {
  35828. m.block_list = nil
  35829. m.appendblock_list = nil
  35830. delete(m.clearedFields, whatsapp.FieldBlockList)
  35831. }
  35832. // SetGroupBlockList sets the "group_block_list" field.
  35833. func (m *WhatsappMutation) SetGroupBlockList(s []string) {
  35834. m.group_block_list = &s
  35835. m.appendgroup_block_list = nil
  35836. }
  35837. // GroupBlockList returns the value of the "group_block_list" field in the mutation.
  35838. func (m *WhatsappMutation) GroupBlockList() (r []string, exists bool) {
  35839. v := m.group_block_list
  35840. if v == nil {
  35841. return
  35842. }
  35843. return *v, true
  35844. }
  35845. // OldGroupBlockList returns the old "group_block_list" field's value of the Whatsapp entity.
  35846. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35847. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35848. func (m *WhatsappMutation) OldGroupBlockList(ctx context.Context) (v []string, err error) {
  35849. if !m.op.Is(OpUpdateOne) {
  35850. return v, errors.New("OldGroupBlockList is only allowed on UpdateOne operations")
  35851. }
  35852. if m.id == nil || m.oldValue == nil {
  35853. return v, errors.New("OldGroupBlockList requires an ID field in the mutation")
  35854. }
  35855. oldValue, err := m.oldValue(ctx)
  35856. if err != nil {
  35857. return v, fmt.Errorf("querying old value for OldGroupBlockList: %w", err)
  35858. }
  35859. return oldValue.GroupBlockList, nil
  35860. }
  35861. // AppendGroupBlockList adds s to the "group_block_list" field.
  35862. func (m *WhatsappMutation) AppendGroupBlockList(s []string) {
  35863. m.appendgroup_block_list = append(m.appendgroup_block_list, s...)
  35864. }
  35865. // AppendedGroupBlockList returns the list of values that were appended to the "group_block_list" field in this mutation.
  35866. func (m *WhatsappMutation) AppendedGroupBlockList() ([]string, bool) {
  35867. if len(m.appendgroup_block_list) == 0 {
  35868. return nil, false
  35869. }
  35870. return m.appendgroup_block_list, true
  35871. }
  35872. // ClearGroupBlockList clears the value of the "group_block_list" field.
  35873. func (m *WhatsappMutation) ClearGroupBlockList() {
  35874. m.group_block_list = nil
  35875. m.appendgroup_block_list = nil
  35876. m.clearedFields[whatsapp.FieldGroupBlockList] = struct{}{}
  35877. }
  35878. // GroupBlockListCleared returns if the "group_block_list" field was cleared in this mutation.
  35879. func (m *WhatsappMutation) GroupBlockListCleared() bool {
  35880. _, ok := m.clearedFields[whatsapp.FieldGroupBlockList]
  35881. return ok
  35882. }
  35883. // ResetGroupBlockList resets all changes to the "group_block_list" field.
  35884. func (m *WhatsappMutation) ResetGroupBlockList() {
  35885. m.group_block_list = nil
  35886. m.appendgroup_block_list = nil
  35887. delete(m.clearedFields, whatsapp.FieldGroupBlockList)
  35888. }
  35889. // ClearAgent clears the "agent" edge to the Agent entity.
  35890. func (m *WhatsappMutation) ClearAgent() {
  35891. m.clearedagent = true
  35892. m.clearedFields[whatsapp.FieldAgentID] = struct{}{}
  35893. }
  35894. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  35895. func (m *WhatsappMutation) AgentCleared() bool {
  35896. return m.clearedagent
  35897. }
  35898. // AgentIDs returns the "agent" edge IDs in the mutation.
  35899. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  35900. // AgentID instead. It exists only for internal usage by the builders.
  35901. func (m *WhatsappMutation) AgentIDs() (ids []uint64) {
  35902. if id := m.agent; id != nil {
  35903. ids = append(ids, *id)
  35904. }
  35905. return
  35906. }
  35907. // ResetAgent resets all changes to the "agent" edge.
  35908. func (m *WhatsappMutation) ResetAgent() {
  35909. m.agent = nil
  35910. m.clearedagent = false
  35911. }
  35912. // Where appends a list predicates to the WhatsappMutation builder.
  35913. func (m *WhatsappMutation) Where(ps ...predicate.Whatsapp) {
  35914. m.predicates = append(m.predicates, ps...)
  35915. }
  35916. // WhereP appends storage-level predicates to the WhatsappMutation builder. Using this method,
  35917. // users can use type-assertion to append predicates that do not depend on any generated package.
  35918. func (m *WhatsappMutation) WhereP(ps ...func(*sql.Selector)) {
  35919. p := make([]predicate.Whatsapp, len(ps))
  35920. for i := range ps {
  35921. p[i] = ps[i]
  35922. }
  35923. m.Where(p...)
  35924. }
  35925. // Op returns the operation name.
  35926. func (m *WhatsappMutation) Op() Op {
  35927. return m.op
  35928. }
  35929. // SetOp allows setting the mutation operation.
  35930. func (m *WhatsappMutation) SetOp(op Op) {
  35931. m.op = op
  35932. }
  35933. // Type returns the node type of this mutation (Whatsapp).
  35934. func (m *WhatsappMutation) Type() string {
  35935. return m.typ
  35936. }
  35937. // Fields returns all fields that were changed during this mutation. Note that in
  35938. // order to get all numeric fields that were incremented/decremented, call
  35939. // AddedFields().
  35940. func (m *WhatsappMutation) Fields() []string {
  35941. fields := make([]string, 0, 21)
  35942. if m.created_at != nil {
  35943. fields = append(fields, whatsapp.FieldCreatedAt)
  35944. }
  35945. if m.updated_at != nil {
  35946. fields = append(fields, whatsapp.FieldUpdatedAt)
  35947. }
  35948. if m.status != nil {
  35949. fields = append(fields, whatsapp.FieldStatus)
  35950. }
  35951. if m.deleted_at != nil {
  35952. fields = append(fields, whatsapp.FieldDeletedAt)
  35953. }
  35954. if m.wa_id != nil {
  35955. fields = append(fields, whatsapp.FieldWaID)
  35956. }
  35957. if m.wa_name != nil {
  35958. fields = append(fields, whatsapp.FieldWaName)
  35959. }
  35960. if m.callback != nil {
  35961. fields = append(fields, whatsapp.FieldCallback)
  35962. }
  35963. if m.agent != nil {
  35964. fields = append(fields, whatsapp.FieldAgentID)
  35965. }
  35966. if m.account != nil {
  35967. fields = append(fields, whatsapp.FieldAccount)
  35968. }
  35969. if m.cc != nil {
  35970. fields = append(fields, whatsapp.FieldCc)
  35971. }
  35972. if m.phone != nil {
  35973. fields = append(fields, whatsapp.FieldPhone)
  35974. }
  35975. if m.cc_phone != nil {
  35976. fields = append(fields, whatsapp.FieldCcPhone)
  35977. }
  35978. if m.phone_name != nil {
  35979. fields = append(fields, whatsapp.FieldPhoneName)
  35980. }
  35981. if m.phone_status != nil {
  35982. fields = append(fields, whatsapp.FieldPhoneStatus)
  35983. }
  35984. if m.organization_id != nil {
  35985. fields = append(fields, whatsapp.FieldOrganizationID)
  35986. }
  35987. if m.api_base != nil {
  35988. fields = append(fields, whatsapp.FieldAPIBase)
  35989. }
  35990. if m.api_key != nil {
  35991. fields = append(fields, whatsapp.FieldAPIKey)
  35992. }
  35993. if m.allow_list != nil {
  35994. fields = append(fields, whatsapp.FieldAllowList)
  35995. }
  35996. if m.group_allow_list != nil {
  35997. fields = append(fields, whatsapp.FieldGroupAllowList)
  35998. }
  35999. if m.block_list != nil {
  36000. fields = append(fields, whatsapp.FieldBlockList)
  36001. }
  36002. if m.group_block_list != nil {
  36003. fields = append(fields, whatsapp.FieldGroupBlockList)
  36004. }
  36005. return fields
  36006. }
  36007. // Field returns the value of a field with the given name. The second boolean
  36008. // return value indicates that this field was not set, or was not defined in the
  36009. // schema.
  36010. func (m *WhatsappMutation) Field(name string) (ent.Value, bool) {
  36011. switch name {
  36012. case whatsapp.FieldCreatedAt:
  36013. return m.CreatedAt()
  36014. case whatsapp.FieldUpdatedAt:
  36015. return m.UpdatedAt()
  36016. case whatsapp.FieldStatus:
  36017. return m.Status()
  36018. case whatsapp.FieldDeletedAt:
  36019. return m.DeletedAt()
  36020. case whatsapp.FieldWaID:
  36021. return m.WaID()
  36022. case whatsapp.FieldWaName:
  36023. return m.WaName()
  36024. case whatsapp.FieldCallback:
  36025. return m.Callback()
  36026. case whatsapp.FieldAgentID:
  36027. return m.AgentID()
  36028. case whatsapp.FieldAccount:
  36029. return m.Account()
  36030. case whatsapp.FieldCc:
  36031. return m.Cc()
  36032. case whatsapp.FieldPhone:
  36033. return m.Phone()
  36034. case whatsapp.FieldCcPhone:
  36035. return m.CcPhone()
  36036. case whatsapp.FieldPhoneName:
  36037. return m.PhoneName()
  36038. case whatsapp.FieldPhoneStatus:
  36039. return m.PhoneStatus()
  36040. case whatsapp.FieldOrganizationID:
  36041. return m.OrganizationID()
  36042. case whatsapp.FieldAPIBase:
  36043. return m.APIBase()
  36044. case whatsapp.FieldAPIKey:
  36045. return m.APIKey()
  36046. case whatsapp.FieldAllowList:
  36047. return m.AllowList()
  36048. case whatsapp.FieldGroupAllowList:
  36049. return m.GroupAllowList()
  36050. case whatsapp.FieldBlockList:
  36051. return m.BlockList()
  36052. case whatsapp.FieldGroupBlockList:
  36053. return m.GroupBlockList()
  36054. }
  36055. return nil, false
  36056. }
  36057. // OldField returns the old value of the field from the database. An error is
  36058. // returned if the mutation operation is not UpdateOne, or the query to the
  36059. // database failed.
  36060. func (m *WhatsappMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  36061. switch name {
  36062. case whatsapp.FieldCreatedAt:
  36063. return m.OldCreatedAt(ctx)
  36064. case whatsapp.FieldUpdatedAt:
  36065. return m.OldUpdatedAt(ctx)
  36066. case whatsapp.FieldStatus:
  36067. return m.OldStatus(ctx)
  36068. case whatsapp.FieldDeletedAt:
  36069. return m.OldDeletedAt(ctx)
  36070. case whatsapp.FieldWaID:
  36071. return m.OldWaID(ctx)
  36072. case whatsapp.FieldWaName:
  36073. return m.OldWaName(ctx)
  36074. case whatsapp.FieldCallback:
  36075. return m.OldCallback(ctx)
  36076. case whatsapp.FieldAgentID:
  36077. return m.OldAgentID(ctx)
  36078. case whatsapp.FieldAccount:
  36079. return m.OldAccount(ctx)
  36080. case whatsapp.FieldCc:
  36081. return m.OldCc(ctx)
  36082. case whatsapp.FieldPhone:
  36083. return m.OldPhone(ctx)
  36084. case whatsapp.FieldCcPhone:
  36085. return m.OldCcPhone(ctx)
  36086. case whatsapp.FieldPhoneName:
  36087. return m.OldPhoneName(ctx)
  36088. case whatsapp.FieldPhoneStatus:
  36089. return m.OldPhoneStatus(ctx)
  36090. case whatsapp.FieldOrganizationID:
  36091. return m.OldOrganizationID(ctx)
  36092. case whatsapp.FieldAPIBase:
  36093. return m.OldAPIBase(ctx)
  36094. case whatsapp.FieldAPIKey:
  36095. return m.OldAPIKey(ctx)
  36096. case whatsapp.FieldAllowList:
  36097. return m.OldAllowList(ctx)
  36098. case whatsapp.FieldGroupAllowList:
  36099. return m.OldGroupAllowList(ctx)
  36100. case whatsapp.FieldBlockList:
  36101. return m.OldBlockList(ctx)
  36102. case whatsapp.FieldGroupBlockList:
  36103. return m.OldGroupBlockList(ctx)
  36104. }
  36105. return nil, fmt.Errorf("unknown Whatsapp field %s", name)
  36106. }
  36107. // SetField sets the value of a field with the given name. It returns an error if
  36108. // the field is not defined in the schema, or if the type mismatched the field
  36109. // type.
  36110. func (m *WhatsappMutation) SetField(name string, value ent.Value) error {
  36111. switch name {
  36112. case whatsapp.FieldCreatedAt:
  36113. v, ok := value.(time.Time)
  36114. if !ok {
  36115. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36116. }
  36117. m.SetCreatedAt(v)
  36118. return nil
  36119. case whatsapp.FieldUpdatedAt:
  36120. v, ok := value.(time.Time)
  36121. if !ok {
  36122. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36123. }
  36124. m.SetUpdatedAt(v)
  36125. return nil
  36126. case whatsapp.FieldStatus:
  36127. v, ok := value.(uint8)
  36128. if !ok {
  36129. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36130. }
  36131. m.SetStatus(v)
  36132. return nil
  36133. case whatsapp.FieldDeletedAt:
  36134. v, ok := value.(time.Time)
  36135. if !ok {
  36136. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36137. }
  36138. m.SetDeletedAt(v)
  36139. return nil
  36140. case whatsapp.FieldWaID:
  36141. v, ok := value.(string)
  36142. if !ok {
  36143. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36144. }
  36145. m.SetWaID(v)
  36146. return nil
  36147. case whatsapp.FieldWaName:
  36148. v, ok := value.(string)
  36149. if !ok {
  36150. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36151. }
  36152. m.SetWaName(v)
  36153. return nil
  36154. case whatsapp.FieldCallback:
  36155. v, ok := value.(string)
  36156. if !ok {
  36157. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36158. }
  36159. m.SetCallback(v)
  36160. return nil
  36161. case whatsapp.FieldAgentID:
  36162. v, ok := value.(uint64)
  36163. if !ok {
  36164. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36165. }
  36166. m.SetAgentID(v)
  36167. return nil
  36168. case whatsapp.FieldAccount:
  36169. v, ok := value.(string)
  36170. if !ok {
  36171. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36172. }
  36173. m.SetAccount(v)
  36174. return nil
  36175. case whatsapp.FieldCc:
  36176. v, ok := value.(string)
  36177. if !ok {
  36178. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36179. }
  36180. m.SetCc(v)
  36181. return nil
  36182. case whatsapp.FieldPhone:
  36183. v, ok := value.(string)
  36184. if !ok {
  36185. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36186. }
  36187. m.SetPhone(v)
  36188. return nil
  36189. case whatsapp.FieldCcPhone:
  36190. v, ok := value.(string)
  36191. if !ok {
  36192. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36193. }
  36194. m.SetCcPhone(v)
  36195. return nil
  36196. case whatsapp.FieldPhoneName:
  36197. v, ok := value.(string)
  36198. if !ok {
  36199. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36200. }
  36201. m.SetPhoneName(v)
  36202. return nil
  36203. case whatsapp.FieldPhoneStatus:
  36204. v, ok := value.(int8)
  36205. if !ok {
  36206. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36207. }
  36208. m.SetPhoneStatus(v)
  36209. return nil
  36210. case whatsapp.FieldOrganizationID:
  36211. v, ok := value.(uint64)
  36212. if !ok {
  36213. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36214. }
  36215. m.SetOrganizationID(v)
  36216. return nil
  36217. case whatsapp.FieldAPIBase:
  36218. v, ok := value.(string)
  36219. if !ok {
  36220. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36221. }
  36222. m.SetAPIBase(v)
  36223. return nil
  36224. case whatsapp.FieldAPIKey:
  36225. v, ok := value.(string)
  36226. if !ok {
  36227. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36228. }
  36229. m.SetAPIKey(v)
  36230. return nil
  36231. case whatsapp.FieldAllowList:
  36232. v, ok := value.([]string)
  36233. if !ok {
  36234. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36235. }
  36236. m.SetAllowList(v)
  36237. return nil
  36238. case whatsapp.FieldGroupAllowList:
  36239. v, ok := value.([]string)
  36240. if !ok {
  36241. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36242. }
  36243. m.SetGroupAllowList(v)
  36244. return nil
  36245. case whatsapp.FieldBlockList:
  36246. v, ok := value.([]string)
  36247. if !ok {
  36248. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36249. }
  36250. m.SetBlockList(v)
  36251. return nil
  36252. case whatsapp.FieldGroupBlockList:
  36253. v, ok := value.([]string)
  36254. if !ok {
  36255. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36256. }
  36257. m.SetGroupBlockList(v)
  36258. return nil
  36259. }
  36260. return fmt.Errorf("unknown Whatsapp field %s", name)
  36261. }
  36262. // AddedFields returns all numeric fields that were incremented/decremented during
  36263. // this mutation.
  36264. func (m *WhatsappMutation) AddedFields() []string {
  36265. var fields []string
  36266. if m.addstatus != nil {
  36267. fields = append(fields, whatsapp.FieldStatus)
  36268. }
  36269. if m.addphone_status != nil {
  36270. fields = append(fields, whatsapp.FieldPhoneStatus)
  36271. }
  36272. if m.addorganization_id != nil {
  36273. fields = append(fields, whatsapp.FieldOrganizationID)
  36274. }
  36275. return fields
  36276. }
  36277. // AddedField returns the numeric value that was incremented/decremented on a field
  36278. // with the given name. The second boolean return value indicates that this field
  36279. // was not set, or was not defined in the schema.
  36280. func (m *WhatsappMutation) AddedField(name string) (ent.Value, bool) {
  36281. switch name {
  36282. case whatsapp.FieldStatus:
  36283. return m.AddedStatus()
  36284. case whatsapp.FieldPhoneStatus:
  36285. return m.AddedPhoneStatus()
  36286. case whatsapp.FieldOrganizationID:
  36287. return m.AddedOrganizationID()
  36288. }
  36289. return nil, false
  36290. }
  36291. // AddField adds the value to the field with the given name. It returns an error if
  36292. // the field is not defined in the schema, or if the type mismatched the field
  36293. // type.
  36294. func (m *WhatsappMutation) AddField(name string, value ent.Value) error {
  36295. switch name {
  36296. case whatsapp.FieldStatus:
  36297. v, ok := value.(int8)
  36298. if !ok {
  36299. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36300. }
  36301. m.AddStatus(v)
  36302. return nil
  36303. case whatsapp.FieldPhoneStatus:
  36304. v, ok := value.(int8)
  36305. if !ok {
  36306. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36307. }
  36308. m.AddPhoneStatus(v)
  36309. return nil
  36310. case whatsapp.FieldOrganizationID:
  36311. v, ok := value.(int64)
  36312. if !ok {
  36313. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36314. }
  36315. m.AddOrganizationID(v)
  36316. return nil
  36317. }
  36318. return fmt.Errorf("unknown Whatsapp numeric field %s", name)
  36319. }
  36320. // ClearedFields returns all nullable fields that were cleared during this
  36321. // mutation.
  36322. func (m *WhatsappMutation) ClearedFields() []string {
  36323. var fields []string
  36324. if m.FieldCleared(whatsapp.FieldStatus) {
  36325. fields = append(fields, whatsapp.FieldStatus)
  36326. }
  36327. if m.FieldCleared(whatsapp.FieldDeletedAt) {
  36328. fields = append(fields, whatsapp.FieldDeletedAt)
  36329. }
  36330. if m.FieldCleared(whatsapp.FieldWaID) {
  36331. fields = append(fields, whatsapp.FieldWaID)
  36332. }
  36333. if m.FieldCleared(whatsapp.FieldWaName) {
  36334. fields = append(fields, whatsapp.FieldWaName)
  36335. }
  36336. if m.FieldCleared(whatsapp.FieldCallback) {
  36337. fields = append(fields, whatsapp.FieldCallback)
  36338. }
  36339. if m.FieldCleared(whatsapp.FieldAccount) {
  36340. fields = append(fields, whatsapp.FieldAccount)
  36341. }
  36342. if m.FieldCleared(whatsapp.FieldOrganizationID) {
  36343. fields = append(fields, whatsapp.FieldOrganizationID)
  36344. }
  36345. if m.FieldCleared(whatsapp.FieldAPIBase) {
  36346. fields = append(fields, whatsapp.FieldAPIBase)
  36347. }
  36348. if m.FieldCleared(whatsapp.FieldAPIKey) {
  36349. fields = append(fields, whatsapp.FieldAPIKey)
  36350. }
  36351. if m.FieldCleared(whatsapp.FieldAllowList) {
  36352. fields = append(fields, whatsapp.FieldAllowList)
  36353. }
  36354. if m.FieldCleared(whatsapp.FieldGroupAllowList) {
  36355. fields = append(fields, whatsapp.FieldGroupAllowList)
  36356. }
  36357. if m.FieldCleared(whatsapp.FieldBlockList) {
  36358. fields = append(fields, whatsapp.FieldBlockList)
  36359. }
  36360. if m.FieldCleared(whatsapp.FieldGroupBlockList) {
  36361. fields = append(fields, whatsapp.FieldGroupBlockList)
  36362. }
  36363. return fields
  36364. }
  36365. // FieldCleared returns a boolean indicating if a field with the given name was
  36366. // cleared in this mutation.
  36367. func (m *WhatsappMutation) FieldCleared(name string) bool {
  36368. _, ok := m.clearedFields[name]
  36369. return ok
  36370. }
  36371. // ClearField clears the value of the field with the given name. It returns an
  36372. // error if the field is not defined in the schema.
  36373. func (m *WhatsappMutation) ClearField(name string) error {
  36374. switch name {
  36375. case whatsapp.FieldStatus:
  36376. m.ClearStatus()
  36377. return nil
  36378. case whatsapp.FieldDeletedAt:
  36379. m.ClearDeletedAt()
  36380. return nil
  36381. case whatsapp.FieldWaID:
  36382. m.ClearWaID()
  36383. return nil
  36384. case whatsapp.FieldWaName:
  36385. m.ClearWaName()
  36386. return nil
  36387. case whatsapp.FieldCallback:
  36388. m.ClearCallback()
  36389. return nil
  36390. case whatsapp.FieldAccount:
  36391. m.ClearAccount()
  36392. return nil
  36393. case whatsapp.FieldOrganizationID:
  36394. m.ClearOrganizationID()
  36395. return nil
  36396. case whatsapp.FieldAPIBase:
  36397. m.ClearAPIBase()
  36398. return nil
  36399. case whatsapp.FieldAPIKey:
  36400. m.ClearAPIKey()
  36401. return nil
  36402. case whatsapp.FieldAllowList:
  36403. m.ClearAllowList()
  36404. return nil
  36405. case whatsapp.FieldGroupAllowList:
  36406. m.ClearGroupAllowList()
  36407. return nil
  36408. case whatsapp.FieldBlockList:
  36409. m.ClearBlockList()
  36410. return nil
  36411. case whatsapp.FieldGroupBlockList:
  36412. m.ClearGroupBlockList()
  36413. return nil
  36414. }
  36415. return fmt.Errorf("unknown Whatsapp nullable field %s", name)
  36416. }
  36417. // ResetField resets all changes in the mutation for the field with the given name.
  36418. // It returns an error if the field is not defined in the schema.
  36419. func (m *WhatsappMutation) ResetField(name string) error {
  36420. switch name {
  36421. case whatsapp.FieldCreatedAt:
  36422. m.ResetCreatedAt()
  36423. return nil
  36424. case whatsapp.FieldUpdatedAt:
  36425. m.ResetUpdatedAt()
  36426. return nil
  36427. case whatsapp.FieldStatus:
  36428. m.ResetStatus()
  36429. return nil
  36430. case whatsapp.FieldDeletedAt:
  36431. m.ResetDeletedAt()
  36432. return nil
  36433. case whatsapp.FieldWaID:
  36434. m.ResetWaID()
  36435. return nil
  36436. case whatsapp.FieldWaName:
  36437. m.ResetWaName()
  36438. return nil
  36439. case whatsapp.FieldCallback:
  36440. m.ResetCallback()
  36441. return nil
  36442. case whatsapp.FieldAgentID:
  36443. m.ResetAgentID()
  36444. return nil
  36445. case whatsapp.FieldAccount:
  36446. m.ResetAccount()
  36447. return nil
  36448. case whatsapp.FieldCc:
  36449. m.ResetCc()
  36450. return nil
  36451. case whatsapp.FieldPhone:
  36452. m.ResetPhone()
  36453. return nil
  36454. case whatsapp.FieldCcPhone:
  36455. m.ResetCcPhone()
  36456. return nil
  36457. case whatsapp.FieldPhoneName:
  36458. m.ResetPhoneName()
  36459. return nil
  36460. case whatsapp.FieldPhoneStatus:
  36461. m.ResetPhoneStatus()
  36462. return nil
  36463. case whatsapp.FieldOrganizationID:
  36464. m.ResetOrganizationID()
  36465. return nil
  36466. case whatsapp.FieldAPIBase:
  36467. m.ResetAPIBase()
  36468. return nil
  36469. case whatsapp.FieldAPIKey:
  36470. m.ResetAPIKey()
  36471. return nil
  36472. case whatsapp.FieldAllowList:
  36473. m.ResetAllowList()
  36474. return nil
  36475. case whatsapp.FieldGroupAllowList:
  36476. m.ResetGroupAllowList()
  36477. return nil
  36478. case whatsapp.FieldBlockList:
  36479. m.ResetBlockList()
  36480. return nil
  36481. case whatsapp.FieldGroupBlockList:
  36482. m.ResetGroupBlockList()
  36483. return nil
  36484. }
  36485. return fmt.Errorf("unknown Whatsapp field %s", name)
  36486. }
  36487. // AddedEdges returns all edge names that were set/added in this mutation.
  36488. func (m *WhatsappMutation) AddedEdges() []string {
  36489. edges := make([]string, 0, 1)
  36490. if m.agent != nil {
  36491. edges = append(edges, whatsapp.EdgeAgent)
  36492. }
  36493. return edges
  36494. }
  36495. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  36496. // name in this mutation.
  36497. func (m *WhatsappMutation) AddedIDs(name string) []ent.Value {
  36498. switch name {
  36499. case whatsapp.EdgeAgent:
  36500. if id := m.agent; id != nil {
  36501. return []ent.Value{*id}
  36502. }
  36503. }
  36504. return nil
  36505. }
  36506. // RemovedEdges returns all edge names that were removed in this mutation.
  36507. func (m *WhatsappMutation) RemovedEdges() []string {
  36508. edges := make([]string, 0, 1)
  36509. return edges
  36510. }
  36511. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  36512. // the given name in this mutation.
  36513. func (m *WhatsappMutation) RemovedIDs(name string) []ent.Value {
  36514. return nil
  36515. }
  36516. // ClearedEdges returns all edge names that were cleared in this mutation.
  36517. func (m *WhatsappMutation) ClearedEdges() []string {
  36518. edges := make([]string, 0, 1)
  36519. if m.clearedagent {
  36520. edges = append(edges, whatsapp.EdgeAgent)
  36521. }
  36522. return edges
  36523. }
  36524. // EdgeCleared returns a boolean which indicates if the edge with the given name
  36525. // was cleared in this mutation.
  36526. func (m *WhatsappMutation) EdgeCleared(name string) bool {
  36527. switch name {
  36528. case whatsapp.EdgeAgent:
  36529. return m.clearedagent
  36530. }
  36531. return false
  36532. }
  36533. // ClearEdge clears the value of the edge with the given name. It returns an error
  36534. // if that edge is not defined in the schema.
  36535. func (m *WhatsappMutation) ClearEdge(name string) error {
  36536. switch name {
  36537. case whatsapp.EdgeAgent:
  36538. m.ClearAgent()
  36539. return nil
  36540. }
  36541. return fmt.Errorf("unknown Whatsapp unique edge %s", name)
  36542. }
  36543. // ResetEdge resets all changes to the edge with the given name in this mutation.
  36544. // It returns an error if the edge is not defined in the schema.
  36545. func (m *WhatsappMutation) ResetEdge(name string) error {
  36546. switch name {
  36547. case whatsapp.EdgeAgent:
  36548. m.ResetAgent()
  36549. return nil
  36550. }
  36551. return fmt.Errorf("unknown Whatsapp edge %s", name)
  36552. }
  36553. // WhatsappChannelMutation represents an operation that mutates the WhatsappChannel nodes in the graph.
  36554. type WhatsappChannelMutation struct {
  36555. config
  36556. op Op
  36557. typ string
  36558. id *uint64
  36559. created_at *time.Time
  36560. updated_at *time.Time
  36561. status *uint8
  36562. addstatus *int8
  36563. deleted_at *time.Time
  36564. ak *string
  36565. sk *string
  36566. wa_id *string
  36567. wa_name *string
  36568. waba_id *uint64
  36569. addwaba_id *int64
  36570. business_id *uint64
  36571. addbusiness_id *int64
  36572. organization_id *uint64
  36573. addorganization_id *int64
  36574. verify_account *string
  36575. clearedFields map[string]struct{}
  36576. done bool
  36577. oldValue func(context.Context) (*WhatsappChannel, error)
  36578. predicates []predicate.WhatsappChannel
  36579. }
  36580. var _ ent.Mutation = (*WhatsappChannelMutation)(nil)
  36581. // whatsappchannelOption allows management of the mutation configuration using functional options.
  36582. type whatsappchannelOption func(*WhatsappChannelMutation)
  36583. // newWhatsappChannelMutation creates new mutation for the WhatsappChannel entity.
  36584. func newWhatsappChannelMutation(c config, op Op, opts ...whatsappchannelOption) *WhatsappChannelMutation {
  36585. m := &WhatsappChannelMutation{
  36586. config: c,
  36587. op: op,
  36588. typ: TypeWhatsappChannel,
  36589. clearedFields: make(map[string]struct{}),
  36590. }
  36591. for _, opt := range opts {
  36592. opt(m)
  36593. }
  36594. return m
  36595. }
  36596. // withWhatsappChannelID sets the ID field of the mutation.
  36597. func withWhatsappChannelID(id uint64) whatsappchannelOption {
  36598. return func(m *WhatsappChannelMutation) {
  36599. var (
  36600. err error
  36601. once sync.Once
  36602. value *WhatsappChannel
  36603. )
  36604. m.oldValue = func(ctx context.Context) (*WhatsappChannel, error) {
  36605. once.Do(func() {
  36606. if m.done {
  36607. err = errors.New("querying old values post mutation is not allowed")
  36608. } else {
  36609. value, err = m.Client().WhatsappChannel.Get(ctx, id)
  36610. }
  36611. })
  36612. return value, err
  36613. }
  36614. m.id = &id
  36615. }
  36616. }
  36617. // withWhatsappChannel sets the old WhatsappChannel of the mutation.
  36618. func withWhatsappChannel(node *WhatsappChannel) whatsappchannelOption {
  36619. return func(m *WhatsappChannelMutation) {
  36620. m.oldValue = func(context.Context) (*WhatsappChannel, error) {
  36621. return node, nil
  36622. }
  36623. m.id = &node.ID
  36624. }
  36625. }
  36626. // Client returns a new `ent.Client` from the mutation. If the mutation was
  36627. // executed in a transaction (ent.Tx), a transactional client is returned.
  36628. func (m WhatsappChannelMutation) Client() *Client {
  36629. client := &Client{config: m.config}
  36630. client.init()
  36631. return client
  36632. }
  36633. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  36634. // it returns an error otherwise.
  36635. func (m WhatsappChannelMutation) Tx() (*Tx, error) {
  36636. if _, ok := m.driver.(*txDriver); !ok {
  36637. return nil, errors.New("ent: mutation is not running in a transaction")
  36638. }
  36639. tx := &Tx{config: m.config}
  36640. tx.init()
  36641. return tx, nil
  36642. }
  36643. // SetID sets the value of the id field. Note that this
  36644. // operation is only accepted on creation of WhatsappChannel entities.
  36645. func (m *WhatsappChannelMutation) SetID(id uint64) {
  36646. m.id = &id
  36647. }
  36648. // ID returns the ID value in the mutation. Note that the ID is only available
  36649. // if it was provided to the builder or after it was returned from the database.
  36650. func (m *WhatsappChannelMutation) ID() (id uint64, exists bool) {
  36651. if m.id == nil {
  36652. return
  36653. }
  36654. return *m.id, true
  36655. }
  36656. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  36657. // That means, if the mutation is applied within a transaction with an isolation level such
  36658. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  36659. // or updated by the mutation.
  36660. func (m *WhatsappChannelMutation) IDs(ctx context.Context) ([]uint64, error) {
  36661. switch {
  36662. case m.op.Is(OpUpdateOne | OpDeleteOne):
  36663. id, exists := m.ID()
  36664. if exists {
  36665. return []uint64{id}, nil
  36666. }
  36667. fallthrough
  36668. case m.op.Is(OpUpdate | OpDelete):
  36669. return m.Client().WhatsappChannel.Query().Where(m.predicates...).IDs(ctx)
  36670. default:
  36671. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  36672. }
  36673. }
  36674. // SetCreatedAt sets the "created_at" field.
  36675. func (m *WhatsappChannelMutation) SetCreatedAt(t time.Time) {
  36676. m.created_at = &t
  36677. }
  36678. // CreatedAt returns the value of the "created_at" field in the mutation.
  36679. func (m *WhatsappChannelMutation) CreatedAt() (r time.Time, exists bool) {
  36680. v := m.created_at
  36681. if v == nil {
  36682. return
  36683. }
  36684. return *v, true
  36685. }
  36686. // OldCreatedAt returns the old "created_at" field's value of the WhatsappChannel entity.
  36687. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  36688. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36689. func (m *WhatsappChannelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  36690. if !m.op.Is(OpUpdateOne) {
  36691. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  36692. }
  36693. if m.id == nil || m.oldValue == nil {
  36694. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  36695. }
  36696. oldValue, err := m.oldValue(ctx)
  36697. if err != nil {
  36698. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  36699. }
  36700. return oldValue.CreatedAt, nil
  36701. }
  36702. // ResetCreatedAt resets all changes to the "created_at" field.
  36703. func (m *WhatsappChannelMutation) ResetCreatedAt() {
  36704. m.created_at = nil
  36705. }
  36706. // SetUpdatedAt sets the "updated_at" field.
  36707. func (m *WhatsappChannelMutation) SetUpdatedAt(t time.Time) {
  36708. m.updated_at = &t
  36709. }
  36710. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  36711. func (m *WhatsappChannelMutation) UpdatedAt() (r time.Time, exists bool) {
  36712. v := m.updated_at
  36713. if v == nil {
  36714. return
  36715. }
  36716. return *v, true
  36717. }
  36718. // OldUpdatedAt returns the old "updated_at" field's value of the WhatsappChannel entity.
  36719. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  36720. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36721. func (m *WhatsappChannelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  36722. if !m.op.Is(OpUpdateOne) {
  36723. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  36724. }
  36725. if m.id == nil || m.oldValue == nil {
  36726. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  36727. }
  36728. oldValue, err := m.oldValue(ctx)
  36729. if err != nil {
  36730. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  36731. }
  36732. return oldValue.UpdatedAt, nil
  36733. }
  36734. // ResetUpdatedAt resets all changes to the "updated_at" field.
  36735. func (m *WhatsappChannelMutation) ResetUpdatedAt() {
  36736. m.updated_at = nil
  36737. }
  36738. // SetStatus sets the "status" field.
  36739. func (m *WhatsappChannelMutation) SetStatus(u uint8) {
  36740. m.status = &u
  36741. m.addstatus = nil
  36742. }
  36743. // Status returns the value of the "status" field in the mutation.
  36744. func (m *WhatsappChannelMutation) Status() (r uint8, exists bool) {
  36745. v := m.status
  36746. if v == nil {
  36747. return
  36748. }
  36749. return *v, true
  36750. }
  36751. // OldStatus returns the old "status" field's value of the WhatsappChannel entity.
  36752. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  36753. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36754. func (m *WhatsappChannelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  36755. if !m.op.Is(OpUpdateOne) {
  36756. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  36757. }
  36758. if m.id == nil || m.oldValue == nil {
  36759. return v, errors.New("OldStatus requires an ID field in the mutation")
  36760. }
  36761. oldValue, err := m.oldValue(ctx)
  36762. if err != nil {
  36763. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  36764. }
  36765. return oldValue.Status, nil
  36766. }
  36767. // AddStatus adds u to the "status" field.
  36768. func (m *WhatsappChannelMutation) AddStatus(u int8) {
  36769. if m.addstatus != nil {
  36770. *m.addstatus += u
  36771. } else {
  36772. m.addstatus = &u
  36773. }
  36774. }
  36775. // AddedStatus returns the value that was added to the "status" field in this mutation.
  36776. func (m *WhatsappChannelMutation) AddedStatus() (r int8, exists bool) {
  36777. v := m.addstatus
  36778. if v == nil {
  36779. return
  36780. }
  36781. return *v, true
  36782. }
  36783. // ClearStatus clears the value of the "status" field.
  36784. func (m *WhatsappChannelMutation) ClearStatus() {
  36785. m.status = nil
  36786. m.addstatus = nil
  36787. m.clearedFields[whatsappchannel.FieldStatus] = struct{}{}
  36788. }
  36789. // StatusCleared returns if the "status" field was cleared in this mutation.
  36790. func (m *WhatsappChannelMutation) StatusCleared() bool {
  36791. _, ok := m.clearedFields[whatsappchannel.FieldStatus]
  36792. return ok
  36793. }
  36794. // ResetStatus resets all changes to the "status" field.
  36795. func (m *WhatsappChannelMutation) ResetStatus() {
  36796. m.status = nil
  36797. m.addstatus = nil
  36798. delete(m.clearedFields, whatsappchannel.FieldStatus)
  36799. }
  36800. // SetDeletedAt sets the "deleted_at" field.
  36801. func (m *WhatsappChannelMutation) SetDeletedAt(t time.Time) {
  36802. m.deleted_at = &t
  36803. }
  36804. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  36805. func (m *WhatsappChannelMutation) DeletedAt() (r time.Time, exists bool) {
  36806. v := m.deleted_at
  36807. if v == nil {
  36808. return
  36809. }
  36810. return *v, true
  36811. }
  36812. // OldDeletedAt returns the old "deleted_at" field's value of the WhatsappChannel entity.
  36813. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  36814. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36815. func (m *WhatsappChannelMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  36816. if !m.op.Is(OpUpdateOne) {
  36817. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  36818. }
  36819. if m.id == nil || m.oldValue == nil {
  36820. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  36821. }
  36822. oldValue, err := m.oldValue(ctx)
  36823. if err != nil {
  36824. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  36825. }
  36826. return oldValue.DeletedAt, nil
  36827. }
  36828. // ClearDeletedAt clears the value of the "deleted_at" field.
  36829. func (m *WhatsappChannelMutation) ClearDeletedAt() {
  36830. m.deleted_at = nil
  36831. m.clearedFields[whatsappchannel.FieldDeletedAt] = struct{}{}
  36832. }
  36833. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  36834. func (m *WhatsappChannelMutation) DeletedAtCleared() bool {
  36835. _, ok := m.clearedFields[whatsappchannel.FieldDeletedAt]
  36836. return ok
  36837. }
  36838. // ResetDeletedAt resets all changes to the "deleted_at" field.
  36839. func (m *WhatsappChannelMutation) ResetDeletedAt() {
  36840. m.deleted_at = nil
  36841. delete(m.clearedFields, whatsappchannel.FieldDeletedAt)
  36842. }
  36843. // SetAk sets the "ak" field.
  36844. func (m *WhatsappChannelMutation) SetAk(s string) {
  36845. m.ak = &s
  36846. }
  36847. // Ak returns the value of the "ak" field in the mutation.
  36848. func (m *WhatsappChannelMutation) Ak() (r string, exists bool) {
  36849. v := m.ak
  36850. if v == nil {
  36851. return
  36852. }
  36853. return *v, true
  36854. }
  36855. // OldAk returns the old "ak" field's value of the WhatsappChannel entity.
  36856. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  36857. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36858. func (m *WhatsappChannelMutation) OldAk(ctx context.Context) (v string, err error) {
  36859. if !m.op.Is(OpUpdateOne) {
  36860. return v, errors.New("OldAk is only allowed on UpdateOne operations")
  36861. }
  36862. if m.id == nil || m.oldValue == nil {
  36863. return v, errors.New("OldAk requires an ID field in the mutation")
  36864. }
  36865. oldValue, err := m.oldValue(ctx)
  36866. if err != nil {
  36867. return v, fmt.Errorf("querying old value for OldAk: %w", err)
  36868. }
  36869. return oldValue.Ak, nil
  36870. }
  36871. // ClearAk clears the value of the "ak" field.
  36872. func (m *WhatsappChannelMutation) ClearAk() {
  36873. m.ak = nil
  36874. m.clearedFields[whatsappchannel.FieldAk] = struct{}{}
  36875. }
  36876. // AkCleared returns if the "ak" field was cleared in this mutation.
  36877. func (m *WhatsappChannelMutation) AkCleared() bool {
  36878. _, ok := m.clearedFields[whatsappchannel.FieldAk]
  36879. return ok
  36880. }
  36881. // ResetAk resets all changes to the "ak" field.
  36882. func (m *WhatsappChannelMutation) ResetAk() {
  36883. m.ak = nil
  36884. delete(m.clearedFields, whatsappchannel.FieldAk)
  36885. }
  36886. // SetSk sets the "sk" field.
  36887. func (m *WhatsappChannelMutation) SetSk(s string) {
  36888. m.sk = &s
  36889. }
  36890. // Sk returns the value of the "sk" field in the mutation.
  36891. func (m *WhatsappChannelMutation) Sk() (r string, exists bool) {
  36892. v := m.sk
  36893. if v == nil {
  36894. return
  36895. }
  36896. return *v, true
  36897. }
  36898. // OldSk returns the old "sk" field's value of the WhatsappChannel entity.
  36899. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  36900. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36901. func (m *WhatsappChannelMutation) OldSk(ctx context.Context) (v string, err error) {
  36902. if !m.op.Is(OpUpdateOne) {
  36903. return v, errors.New("OldSk is only allowed on UpdateOne operations")
  36904. }
  36905. if m.id == nil || m.oldValue == nil {
  36906. return v, errors.New("OldSk requires an ID field in the mutation")
  36907. }
  36908. oldValue, err := m.oldValue(ctx)
  36909. if err != nil {
  36910. return v, fmt.Errorf("querying old value for OldSk: %w", err)
  36911. }
  36912. return oldValue.Sk, nil
  36913. }
  36914. // ResetSk resets all changes to the "sk" field.
  36915. func (m *WhatsappChannelMutation) ResetSk() {
  36916. m.sk = nil
  36917. }
  36918. // SetWaID sets the "wa_id" field.
  36919. func (m *WhatsappChannelMutation) SetWaID(s string) {
  36920. m.wa_id = &s
  36921. }
  36922. // WaID returns the value of the "wa_id" field in the mutation.
  36923. func (m *WhatsappChannelMutation) WaID() (r string, exists bool) {
  36924. v := m.wa_id
  36925. if v == nil {
  36926. return
  36927. }
  36928. return *v, true
  36929. }
  36930. // OldWaID returns the old "wa_id" field's value of the WhatsappChannel entity.
  36931. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  36932. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36933. func (m *WhatsappChannelMutation) OldWaID(ctx context.Context) (v string, err error) {
  36934. if !m.op.Is(OpUpdateOne) {
  36935. return v, errors.New("OldWaID is only allowed on UpdateOne operations")
  36936. }
  36937. if m.id == nil || m.oldValue == nil {
  36938. return v, errors.New("OldWaID requires an ID field in the mutation")
  36939. }
  36940. oldValue, err := m.oldValue(ctx)
  36941. if err != nil {
  36942. return v, fmt.Errorf("querying old value for OldWaID: %w", err)
  36943. }
  36944. return oldValue.WaID, nil
  36945. }
  36946. // ClearWaID clears the value of the "wa_id" field.
  36947. func (m *WhatsappChannelMutation) ClearWaID() {
  36948. m.wa_id = nil
  36949. m.clearedFields[whatsappchannel.FieldWaID] = struct{}{}
  36950. }
  36951. // WaIDCleared returns if the "wa_id" field was cleared in this mutation.
  36952. func (m *WhatsappChannelMutation) WaIDCleared() bool {
  36953. _, ok := m.clearedFields[whatsappchannel.FieldWaID]
  36954. return ok
  36955. }
  36956. // ResetWaID resets all changes to the "wa_id" field.
  36957. func (m *WhatsappChannelMutation) ResetWaID() {
  36958. m.wa_id = nil
  36959. delete(m.clearedFields, whatsappchannel.FieldWaID)
  36960. }
  36961. // SetWaName sets the "wa_name" field.
  36962. func (m *WhatsappChannelMutation) SetWaName(s string) {
  36963. m.wa_name = &s
  36964. }
  36965. // WaName returns the value of the "wa_name" field in the mutation.
  36966. func (m *WhatsappChannelMutation) WaName() (r string, exists bool) {
  36967. v := m.wa_name
  36968. if v == nil {
  36969. return
  36970. }
  36971. return *v, true
  36972. }
  36973. // OldWaName returns the old "wa_name" field's value of the WhatsappChannel entity.
  36974. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  36975. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36976. func (m *WhatsappChannelMutation) OldWaName(ctx context.Context) (v string, err error) {
  36977. if !m.op.Is(OpUpdateOne) {
  36978. return v, errors.New("OldWaName is only allowed on UpdateOne operations")
  36979. }
  36980. if m.id == nil || m.oldValue == nil {
  36981. return v, errors.New("OldWaName requires an ID field in the mutation")
  36982. }
  36983. oldValue, err := m.oldValue(ctx)
  36984. if err != nil {
  36985. return v, fmt.Errorf("querying old value for OldWaName: %w", err)
  36986. }
  36987. return oldValue.WaName, nil
  36988. }
  36989. // ClearWaName clears the value of the "wa_name" field.
  36990. func (m *WhatsappChannelMutation) ClearWaName() {
  36991. m.wa_name = nil
  36992. m.clearedFields[whatsappchannel.FieldWaName] = struct{}{}
  36993. }
  36994. // WaNameCleared returns if the "wa_name" field was cleared in this mutation.
  36995. func (m *WhatsappChannelMutation) WaNameCleared() bool {
  36996. _, ok := m.clearedFields[whatsappchannel.FieldWaName]
  36997. return ok
  36998. }
  36999. // ResetWaName resets all changes to the "wa_name" field.
  37000. func (m *WhatsappChannelMutation) ResetWaName() {
  37001. m.wa_name = nil
  37002. delete(m.clearedFields, whatsappchannel.FieldWaName)
  37003. }
  37004. // SetWabaID sets the "waba_id" field.
  37005. func (m *WhatsappChannelMutation) SetWabaID(u uint64) {
  37006. m.waba_id = &u
  37007. m.addwaba_id = nil
  37008. }
  37009. // WabaID returns the value of the "waba_id" field in the mutation.
  37010. func (m *WhatsappChannelMutation) WabaID() (r uint64, exists bool) {
  37011. v := m.waba_id
  37012. if v == nil {
  37013. return
  37014. }
  37015. return *v, true
  37016. }
  37017. // OldWabaID returns the old "waba_id" field's value of the WhatsappChannel entity.
  37018. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  37019. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37020. func (m *WhatsappChannelMutation) OldWabaID(ctx context.Context) (v uint64, err error) {
  37021. if !m.op.Is(OpUpdateOne) {
  37022. return v, errors.New("OldWabaID is only allowed on UpdateOne operations")
  37023. }
  37024. if m.id == nil || m.oldValue == nil {
  37025. return v, errors.New("OldWabaID requires an ID field in the mutation")
  37026. }
  37027. oldValue, err := m.oldValue(ctx)
  37028. if err != nil {
  37029. return v, fmt.Errorf("querying old value for OldWabaID: %w", err)
  37030. }
  37031. return oldValue.WabaID, nil
  37032. }
  37033. // AddWabaID adds u to the "waba_id" field.
  37034. func (m *WhatsappChannelMutation) AddWabaID(u int64) {
  37035. if m.addwaba_id != nil {
  37036. *m.addwaba_id += u
  37037. } else {
  37038. m.addwaba_id = &u
  37039. }
  37040. }
  37041. // AddedWabaID returns the value that was added to the "waba_id" field in this mutation.
  37042. func (m *WhatsappChannelMutation) AddedWabaID() (r int64, exists bool) {
  37043. v := m.addwaba_id
  37044. if v == nil {
  37045. return
  37046. }
  37047. return *v, true
  37048. }
  37049. // ResetWabaID resets all changes to the "waba_id" field.
  37050. func (m *WhatsappChannelMutation) ResetWabaID() {
  37051. m.waba_id = nil
  37052. m.addwaba_id = nil
  37053. }
  37054. // SetBusinessID sets the "business_id" field.
  37055. func (m *WhatsappChannelMutation) SetBusinessID(u uint64) {
  37056. m.business_id = &u
  37057. m.addbusiness_id = nil
  37058. }
  37059. // BusinessID returns the value of the "business_id" field in the mutation.
  37060. func (m *WhatsappChannelMutation) BusinessID() (r uint64, exists bool) {
  37061. v := m.business_id
  37062. if v == nil {
  37063. return
  37064. }
  37065. return *v, true
  37066. }
  37067. // OldBusinessID returns the old "business_id" field's value of the WhatsappChannel entity.
  37068. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  37069. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37070. func (m *WhatsappChannelMutation) OldBusinessID(ctx context.Context) (v uint64, err error) {
  37071. if !m.op.Is(OpUpdateOne) {
  37072. return v, errors.New("OldBusinessID is only allowed on UpdateOne operations")
  37073. }
  37074. if m.id == nil || m.oldValue == nil {
  37075. return v, errors.New("OldBusinessID requires an ID field in the mutation")
  37076. }
  37077. oldValue, err := m.oldValue(ctx)
  37078. if err != nil {
  37079. return v, fmt.Errorf("querying old value for OldBusinessID: %w", err)
  37080. }
  37081. return oldValue.BusinessID, nil
  37082. }
  37083. // AddBusinessID adds u to the "business_id" field.
  37084. func (m *WhatsappChannelMutation) AddBusinessID(u int64) {
  37085. if m.addbusiness_id != nil {
  37086. *m.addbusiness_id += u
  37087. } else {
  37088. m.addbusiness_id = &u
  37089. }
  37090. }
  37091. // AddedBusinessID returns the value that was added to the "business_id" field in this mutation.
  37092. func (m *WhatsappChannelMutation) AddedBusinessID() (r int64, exists bool) {
  37093. v := m.addbusiness_id
  37094. if v == nil {
  37095. return
  37096. }
  37097. return *v, true
  37098. }
  37099. // ResetBusinessID resets all changes to the "business_id" field.
  37100. func (m *WhatsappChannelMutation) ResetBusinessID() {
  37101. m.business_id = nil
  37102. m.addbusiness_id = nil
  37103. }
  37104. // SetOrganizationID sets the "organization_id" field.
  37105. func (m *WhatsappChannelMutation) SetOrganizationID(u uint64) {
  37106. m.organization_id = &u
  37107. m.addorganization_id = nil
  37108. }
  37109. // OrganizationID returns the value of the "organization_id" field in the mutation.
  37110. func (m *WhatsappChannelMutation) OrganizationID() (r uint64, exists bool) {
  37111. v := m.organization_id
  37112. if v == nil {
  37113. return
  37114. }
  37115. return *v, true
  37116. }
  37117. // OldOrganizationID returns the old "organization_id" field's value of the WhatsappChannel entity.
  37118. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  37119. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37120. func (m *WhatsappChannelMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  37121. if !m.op.Is(OpUpdateOne) {
  37122. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  37123. }
  37124. if m.id == nil || m.oldValue == nil {
  37125. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  37126. }
  37127. oldValue, err := m.oldValue(ctx)
  37128. if err != nil {
  37129. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  37130. }
  37131. return oldValue.OrganizationID, nil
  37132. }
  37133. // AddOrganizationID adds u to the "organization_id" field.
  37134. func (m *WhatsappChannelMutation) AddOrganizationID(u int64) {
  37135. if m.addorganization_id != nil {
  37136. *m.addorganization_id += u
  37137. } else {
  37138. m.addorganization_id = &u
  37139. }
  37140. }
  37141. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  37142. func (m *WhatsappChannelMutation) AddedOrganizationID() (r int64, exists bool) {
  37143. v := m.addorganization_id
  37144. if v == nil {
  37145. return
  37146. }
  37147. return *v, true
  37148. }
  37149. // ClearOrganizationID clears the value of the "organization_id" field.
  37150. func (m *WhatsappChannelMutation) ClearOrganizationID() {
  37151. m.organization_id = nil
  37152. m.addorganization_id = nil
  37153. m.clearedFields[whatsappchannel.FieldOrganizationID] = struct{}{}
  37154. }
  37155. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  37156. func (m *WhatsappChannelMutation) OrganizationIDCleared() bool {
  37157. _, ok := m.clearedFields[whatsappchannel.FieldOrganizationID]
  37158. return ok
  37159. }
  37160. // ResetOrganizationID resets all changes to the "organization_id" field.
  37161. func (m *WhatsappChannelMutation) ResetOrganizationID() {
  37162. m.organization_id = nil
  37163. m.addorganization_id = nil
  37164. delete(m.clearedFields, whatsappchannel.FieldOrganizationID)
  37165. }
  37166. // SetVerifyAccount sets the "verify_account" field.
  37167. func (m *WhatsappChannelMutation) SetVerifyAccount(s string) {
  37168. m.verify_account = &s
  37169. }
  37170. // VerifyAccount returns the value of the "verify_account" field in the mutation.
  37171. func (m *WhatsappChannelMutation) VerifyAccount() (r string, exists bool) {
  37172. v := m.verify_account
  37173. if v == nil {
  37174. return
  37175. }
  37176. return *v, true
  37177. }
  37178. // OldVerifyAccount returns the old "verify_account" field's value of the WhatsappChannel entity.
  37179. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  37180. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37181. func (m *WhatsappChannelMutation) OldVerifyAccount(ctx context.Context) (v string, err error) {
  37182. if !m.op.Is(OpUpdateOne) {
  37183. return v, errors.New("OldVerifyAccount is only allowed on UpdateOne operations")
  37184. }
  37185. if m.id == nil || m.oldValue == nil {
  37186. return v, errors.New("OldVerifyAccount requires an ID field in the mutation")
  37187. }
  37188. oldValue, err := m.oldValue(ctx)
  37189. if err != nil {
  37190. return v, fmt.Errorf("querying old value for OldVerifyAccount: %w", err)
  37191. }
  37192. return oldValue.VerifyAccount, nil
  37193. }
  37194. // ResetVerifyAccount resets all changes to the "verify_account" field.
  37195. func (m *WhatsappChannelMutation) ResetVerifyAccount() {
  37196. m.verify_account = nil
  37197. }
  37198. // Where appends a list predicates to the WhatsappChannelMutation builder.
  37199. func (m *WhatsappChannelMutation) Where(ps ...predicate.WhatsappChannel) {
  37200. m.predicates = append(m.predicates, ps...)
  37201. }
  37202. // WhereP appends storage-level predicates to the WhatsappChannelMutation builder. Using this method,
  37203. // users can use type-assertion to append predicates that do not depend on any generated package.
  37204. func (m *WhatsappChannelMutation) WhereP(ps ...func(*sql.Selector)) {
  37205. p := make([]predicate.WhatsappChannel, len(ps))
  37206. for i := range ps {
  37207. p[i] = ps[i]
  37208. }
  37209. m.Where(p...)
  37210. }
  37211. // Op returns the operation name.
  37212. func (m *WhatsappChannelMutation) Op() Op {
  37213. return m.op
  37214. }
  37215. // SetOp allows setting the mutation operation.
  37216. func (m *WhatsappChannelMutation) SetOp(op Op) {
  37217. m.op = op
  37218. }
  37219. // Type returns the node type of this mutation (WhatsappChannel).
  37220. func (m *WhatsappChannelMutation) Type() string {
  37221. return m.typ
  37222. }
  37223. // Fields returns all fields that were changed during this mutation. Note that in
  37224. // order to get all numeric fields that were incremented/decremented, call
  37225. // AddedFields().
  37226. func (m *WhatsappChannelMutation) Fields() []string {
  37227. fields := make([]string, 0, 12)
  37228. if m.created_at != nil {
  37229. fields = append(fields, whatsappchannel.FieldCreatedAt)
  37230. }
  37231. if m.updated_at != nil {
  37232. fields = append(fields, whatsappchannel.FieldUpdatedAt)
  37233. }
  37234. if m.status != nil {
  37235. fields = append(fields, whatsappchannel.FieldStatus)
  37236. }
  37237. if m.deleted_at != nil {
  37238. fields = append(fields, whatsappchannel.FieldDeletedAt)
  37239. }
  37240. if m.ak != nil {
  37241. fields = append(fields, whatsappchannel.FieldAk)
  37242. }
  37243. if m.sk != nil {
  37244. fields = append(fields, whatsappchannel.FieldSk)
  37245. }
  37246. if m.wa_id != nil {
  37247. fields = append(fields, whatsappchannel.FieldWaID)
  37248. }
  37249. if m.wa_name != nil {
  37250. fields = append(fields, whatsappchannel.FieldWaName)
  37251. }
  37252. if m.waba_id != nil {
  37253. fields = append(fields, whatsappchannel.FieldWabaID)
  37254. }
  37255. if m.business_id != nil {
  37256. fields = append(fields, whatsappchannel.FieldBusinessID)
  37257. }
  37258. if m.organization_id != nil {
  37259. fields = append(fields, whatsappchannel.FieldOrganizationID)
  37260. }
  37261. if m.verify_account != nil {
  37262. fields = append(fields, whatsappchannel.FieldVerifyAccount)
  37263. }
  37264. return fields
  37265. }
  37266. // Field returns the value of a field with the given name. The second boolean
  37267. // return value indicates that this field was not set, or was not defined in the
  37268. // schema.
  37269. func (m *WhatsappChannelMutation) Field(name string) (ent.Value, bool) {
  37270. switch name {
  37271. case whatsappchannel.FieldCreatedAt:
  37272. return m.CreatedAt()
  37273. case whatsappchannel.FieldUpdatedAt:
  37274. return m.UpdatedAt()
  37275. case whatsappchannel.FieldStatus:
  37276. return m.Status()
  37277. case whatsappchannel.FieldDeletedAt:
  37278. return m.DeletedAt()
  37279. case whatsappchannel.FieldAk:
  37280. return m.Ak()
  37281. case whatsappchannel.FieldSk:
  37282. return m.Sk()
  37283. case whatsappchannel.FieldWaID:
  37284. return m.WaID()
  37285. case whatsappchannel.FieldWaName:
  37286. return m.WaName()
  37287. case whatsappchannel.FieldWabaID:
  37288. return m.WabaID()
  37289. case whatsappchannel.FieldBusinessID:
  37290. return m.BusinessID()
  37291. case whatsappchannel.FieldOrganizationID:
  37292. return m.OrganizationID()
  37293. case whatsappchannel.FieldVerifyAccount:
  37294. return m.VerifyAccount()
  37295. }
  37296. return nil, false
  37297. }
  37298. // OldField returns the old value of the field from the database. An error is
  37299. // returned if the mutation operation is not UpdateOne, or the query to the
  37300. // database failed.
  37301. func (m *WhatsappChannelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  37302. switch name {
  37303. case whatsappchannel.FieldCreatedAt:
  37304. return m.OldCreatedAt(ctx)
  37305. case whatsappchannel.FieldUpdatedAt:
  37306. return m.OldUpdatedAt(ctx)
  37307. case whatsappchannel.FieldStatus:
  37308. return m.OldStatus(ctx)
  37309. case whatsappchannel.FieldDeletedAt:
  37310. return m.OldDeletedAt(ctx)
  37311. case whatsappchannel.FieldAk:
  37312. return m.OldAk(ctx)
  37313. case whatsappchannel.FieldSk:
  37314. return m.OldSk(ctx)
  37315. case whatsappchannel.FieldWaID:
  37316. return m.OldWaID(ctx)
  37317. case whatsappchannel.FieldWaName:
  37318. return m.OldWaName(ctx)
  37319. case whatsappchannel.FieldWabaID:
  37320. return m.OldWabaID(ctx)
  37321. case whatsappchannel.FieldBusinessID:
  37322. return m.OldBusinessID(ctx)
  37323. case whatsappchannel.FieldOrganizationID:
  37324. return m.OldOrganizationID(ctx)
  37325. case whatsappchannel.FieldVerifyAccount:
  37326. return m.OldVerifyAccount(ctx)
  37327. }
  37328. return nil, fmt.Errorf("unknown WhatsappChannel field %s", name)
  37329. }
  37330. // SetField sets the value of a field with the given name. It returns an error if
  37331. // the field is not defined in the schema, or if the type mismatched the field
  37332. // type.
  37333. func (m *WhatsappChannelMutation) SetField(name string, value ent.Value) error {
  37334. switch name {
  37335. case whatsappchannel.FieldCreatedAt:
  37336. v, ok := value.(time.Time)
  37337. if !ok {
  37338. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37339. }
  37340. m.SetCreatedAt(v)
  37341. return nil
  37342. case whatsappchannel.FieldUpdatedAt:
  37343. v, ok := value.(time.Time)
  37344. if !ok {
  37345. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37346. }
  37347. m.SetUpdatedAt(v)
  37348. return nil
  37349. case whatsappchannel.FieldStatus:
  37350. v, ok := value.(uint8)
  37351. if !ok {
  37352. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37353. }
  37354. m.SetStatus(v)
  37355. return nil
  37356. case whatsappchannel.FieldDeletedAt:
  37357. v, ok := value.(time.Time)
  37358. if !ok {
  37359. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37360. }
  37361. m.SetDeletedAt(v)
  37362. return nil
  37363. case whatsappchannel.FieldAk:
  37364. v, ok := value.(string)
  37365. if !ok {
  37366. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37367. }
  37368. m.SetAk(v)
  37369. return nil
  37370. case whatsappchannel.FieldSk:
  37371. v, ok := value.(string)
  37372. if !ok {
  37373. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37374. }
  37375. m.SetSk(v)
  37376. return nil
  37377. case whatsappchannel.FieldWaID:
  37378. v, ok := value.(string)
  37379. if !ok {
  37380. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37381. }
  37382. m.SetWaID(v)
  37383. return nil
  37384. case whatsappchannel.FieldWaName:
  37385. v, ok := value.(string)
  37386. if !ok {
  37387. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37388. }
  37389. m.SetWaName(v)
  37390. return nil
  37391. case whatsappchannel.FieldWabaID:
  37392. v, ok := value.(uint64)
  37393. if !ok {
  37394. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37395. }
  37396. m.SetWabaID(v)
  37397. return nil
  37398. case whatsappchannel.FieldBusinessID:
  37399. v, ok := value.(uint64)
  37400. if !ok {
  37401. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37402. }
  37403. m.SetBusinessID(v)
  37404. return nil
  37405. case whatsappchannel.FieldOrganizationID:
  37406. v, ok := value.(uint64)
  37407. if !ok {
  37408. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37409. }
  37410. m.SetOrganizationID(v)
  37411. return nil
  37412. case whatsappchannel.FieldVerifyAccount:
  37413. v, ok := value.(string)
  37414. if !ok {
  37415. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37416. }
  37417. m.SetVerifyAccount(v)
  37418. return nil
  37419. }
  37420. return fmt.Errorf("unknown WhatsappChannel field %s", name)
  37421. }
  37422. // AddedFields returns all numeric fields that were incremented/decremented during
  37423. // this mutation.
  37424. func (m *WhatsappChannelMutation) AddedFields() []string {
  37425. var fields []string
  37426. if m.addstatus != nil {
  37427. fields = append(fields, whatsappchannel.FieldStatus)
  37428. }
  37429. if m.addwaba_id != nil {
  37430. fields = append(fields, whatsappchannel.FieldWabaID)
  37431. }
  37432. if m.addbusiness_id != nil {
  37433. fields = append(fields, whatsappchannel.FieldBusinessID)
  37434. }
  37435. if m.addorganization_id != nil {
  37436. fields = append(fields, whatsappchannel.FieldOrganizationID)
  37437. }
  37438. return fields
  37439. }
  37440. // AddedField returns the numeric value that was incremented/decremented on a field
  37441. // with the given name. The second boolean return value indicates that this field
  37442. // was not set, or was not defined in the schema.
  37443. func (m *WhatsappChannelMutation) AddedField(name string) (ent.Value, bool) {
  37444. switch name {
  37445. case whatsappchannel.FieldStatus:
  37446. return m.AddedStatus()
  37447. case whatsappchannel.FieldWabaID:
  37448. return m.AddedWabaID()
  37449. case whatsappchannel.FieldBusinessID:
  37450. return m.AddedBusinessID()
  37451. case whatsappchannel.FieldOrganizationID:
  37452. return m.AddedOrganizationID()
  37453. }
  37454. return nil, false
  37455. }
  37456. // AddField adds the value to the field with the given name. It returns an error if
  37457. // the field is not defined in the schema, or if the type mismatched the field
  37458. // type.
  37459. func (m *WhatsappChannelMutation) AddField(name string, value ent.Value) error {
  37460. switch name {
  37461. case whatsappchannel.FieldStatus:
  37462. v, ok := value.(int8)
  37463. if !ok {
  37464. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37465. }
  37466. m.AddStatus(v)
  37467. return nil
  37468. case whatsappchannel.FieldWabaID:
  37469. v, ok := value.(int64)
  37470. if !ok {
  37471. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37472. }
  37473. m.AddWabaID(v)
  37474. return nil
  37475. case whatsappchannel.FieldBusinessID:
  37476. v, ok := value.(int64)
  37477. if !ok {
  37478. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37479. }
  37480. m.AddBusinessID(v)
  37481. return nil
  37482. case whatsappchannel.FieldOrganizationID:
  37483. v, ok := value.(int64)
  37484. if !ok {
  37485. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37486. }
  37487. m.AddOrganizationID(v)
  37488. return nil
  37489. }
  37490. return fmt.Errorf("unknown WhatsappChannel numeric field %s", name)
  37491. }
  37492. // ClearedFields returns all nullable fields that were cleared during this
  37493. // mutation.
  37494. func (m *WhatsappChannelMutation) ClearedFields() []string {
  37495. var fields []string
  37496. if m.FieldCleared(whatsappchannel.FieldStatus) {
  37497. fields = append(fields, whatsappchannel.FieldStatus)
  37498. }
  37499. if m.FieldCleared(whatsappchannel.FieldDeletedAt) {
  37500. fields = append(fields, whatsappchannel.FieldDeletedAt)
  37501. }
  37502. if m.FieldCleared(whatsappchannel.FieldAk) {
  37503. fields = append(fields, whatsappchannel.FieldAk)
  37504. }
  37505. if m.FieldCleared(whatsappchannel.FieldWaID) {
  37506. fields = append(fields, whatsappchannel.FieldWaID)
  37507. }
  37508. if m.FieldCleared(whatsappchannel.FieldWaName) {
  37509. fields = append(fields, whatsappchannel.FieldWaName)
  37510. }
  37511. if m.FieldCleared(whatsappchannel.FieldOrganizationID) {
  37512. fields = append(fields, whatsappchannel.FieldOrganizationID)
  37513. }
  37514. return fields
  37515. }
  37516. // FieldCleared returns a boolean indicating if a field with the given name was
  37517. // cleared in this mutation.
  37518. func (m *WhatsappChannelMutation) FieldCleared(name string) bool {
  37519. _, ok := m.clearedFields[name]
  37520. return ok
  37521. }
  37522. // ClearField clears the value of the field with the given name. It returns an
  37523. // error if the field is not defined in the schema.
  37524. func (m *WhatsappChannelMutation) ClearField(name string) error {
  37525. switch name {
  37526. case whatsappchannel.FieldStatus:
  37527. m.ClearStatus()
  37528. return nil
  37529. case whatsappchannel.FieldDeletedAt:
  37530. m.ClearDeletedAt()
  37531. return nil
  37532. case whatsappchannel.FieldAk:
  37533. m.ClearAk()
  37534. return nil
  37535. case whatsappchannel.FieldWaID:
  37536. m.ClearWaID()
  37537. return nil
  37538. case whatsappchannel.FieldWaName:
  37539. m.ClearWaName()
  37540. return nil
  37541. case whatsappchannel.FieldOrganizationID:
  37542. m.ClearOrganizationID()
  37543. return nil
  37544. }
  37545. return fmt.Errorf("unknown WhatsappChannel nullable field %s", name)
  37546. }
  37547. // ResetField resets all changes in the mutation for the field with the given name.
  37548. // It returns an error if the field is not defined in the schema.
  37549. func (m *WhatsappChannelMutation) ResetField(name string) error {
  37550. switch name {
  37551. case whatsappchannel.FieldCreatedAt:
  37552. m.ResetCreatedAt()
  37553. return nil
  37554. case whatsappchannel.FieldUpdatedAt:
  37555. m.ResetUpdatedAt()
  37556. return nil
  37557. case whatsappchannel.FieldStatus:
  37558. m.ResetStatus()
  37559. return nil
  37560. case whatsappchannel.FieldDeletedAt:
  37561. m.ResetDeletedAt()
  37562. return nil
  37563. case whatsappchannel.FieldAk:
  37564. m.ResetAk()
  37565. return nil
  37566. case whatsappchannel.FieldSk:
  37567. m.ResetSk()
  37568. return nil
  37569. case whatsappchannel.FieldWaID:
  37570. m.ResetWaID()
  37571. return nil
  37572. case whatsappchannel.FieldWaName:
  37573. m.ResetWaName()
  37574. return nil
  37575. case whatsappchannel.FieldWabaID:
  37576. m.ResetWabaID()
  37577. return nil
  37578. case whatsappchannel.FieldBusinessID:
  37579. m.ResetBusinessID()
  37580. return nil
  37581. case whatsappchannel.FieldOrganizationID:
  37582. m.ResetOrganizationID()
  37583. return nil
  37584. case whatsappchannel.FieldVerifyAccount:
  37585. m.ResetVerifyAccount()
  37586. return nil
  37587. }
  37588. return fmt.Errorf("unknown WhatsappChannel field %s", name)
  37589. }
  37590. // AddedEdges returns all edge names that were set/added in this mutation.
  37591. func (m *WhatsappChannelMutation) AddedEdges() []string {
  37592. edges := make([]string, 0, 0)
  37593. return edges
  37594. }
  37595. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  37596. // name in this mutation.
  37597. func (m *WhatsappChannelMutation) AddedIDs(name string) []ent.Value {
  37598. return nil
  37599. }
  37600. // RemovedEdges returns all edge names that were removed in this mutation.
  37601. func (m *WhatsappChannelMutation) RemovedEdges() []string {
  37602. edges := make([]string, 0, 0)
  37603. return edges
  37604. }
  37605. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  37606. // the given name in this mutation.
  37607. func (m *WhatsappChannelMutation) RemovedIDs(name string) []ent.Value {
  37608. return nil
  37609. }
  37610. // ClearedEdges returns all edge names that were cleared in this mutation.
  37611. func (m *WhatsappChannelMutation) ClearedEdges() []string {
  37612. edges := make([]string, 0, 0)
  37613. return edges
  37614. }
  37615. // EdgeCleared returns a boolean which indicates if the edge with the given name
  37616. // was cleared in this mutation.
  37617. func (m *WhatsappChannelMutation) EdgeCleared(name string) bool {
  37618. return false
  37619. }
  37620. // ClearEdge clears the value of the edge with the given name. It returns an error
  37621. // if that edge is not defined in the schema.
  37622. func (m *WhatsappChannelMutation) ClearEdge(name string) error {
  37623. return fmt.Errorf("unknown WhatsappChannel unique edge %s", name)
  37624. }
  37625. // ResetEdge resets all changes to the edge with the given name in this mutation.
  37626. // It returns an error if the edge is not defined in the schema.
  37627. func (m *WhatsappChannelMutation) ResetEdge(name string) error {
  37628. return fmt.Errorf("unknown WhatsappChannel edge %s", name)
  37629. }
  37630. // WorkExperienceMutation represents an operation that mutates the WorkExperience nodes in the graph.
  37631. type WorkExperienceMutation struct {
  37632. config
  37633. op Op
  37634. typ string
  37635. id *uint64
  37636. created_at *time.Time
  37637. updated_at *time.Time
  37638. deleted_at *time.Time
  37639. start_date *time.Time
  37640. end_date *time.Time
  37641. company *string
  37642. experience *string
  37643. organization_id *uint64
  37644. addorganization_id *int64
  37645. clearedFields map[string]struct{}
  37646. employee *uint64
  37647. clearedemployee bool
  37648. done bool
  37649. oldValue func(context.Context) (*WorkExperience, error)
  37650. predicates []predicate.WorkExperience
  37651. }
  37652. var _ ent.Mutation = (*WorkExperienceMutation)(nil)
  37653. // workexperienceOption allows management of the mutation configuration using functional options.
  37654. type workexperienceOption func(*WorkExperienceMutation)
  37655. // newWorkExperienceMutation creates new mutation for the WorkExperience entity.
  37656. func newWorkExperienceMutation(c config, op Op, opts ...workexperienceOption) *WorkExperienceMutation {
  37657. m := &WorkExperienceMutation{
  37658. config: c,
  37659. op: op,
  37660. typ: TypeWorkExperience,
  37661. clearedFields: make(map[string]struct{}),
  37662. }
  37663. for _, opt := range opts {
  37664. opt(m)
  37665. }
  37666. return m
  37667. }
  37668. // withWorkExperienceID sets the ID field of the mutation.
  37669. func withWorkExperienceID(id uint64) workexperienceOption {
  37670. return func(m *WorkExperienceMutation) {
  37671. var (
  37672. err error
  37673. once sync.Once
  37674. value *WorkExperience
  37675. )
  37676. m.oldValue = func(ctx context.Context) (*WorkExperience, error) {
  37677. once.Do(func() {
  37678. if m.done {
  37679. err = errors.New("querying old values post mutation is not allowed")
  37680. } else {
  37681. value, err = m.Client().WorkExperience.Get(ctx, id)
  37682. }
  37683. })
  37684. return value, err
  37685. }
  37686. m.id = &id
  37687. }
  37688. }
  37689. // withWorkExperience sets the old WorkExperience of the mutation.
  37690. func withWorkExperience(node *WorkExperience) workexperienceOption {
  37691. return func(m *WorkExperienceMutation) {
  37692. m.oldValue = func(context.Context) (*WorkExperience, error) {
  37693. return node, nil
  37694. }
  37695. m.id = &node.ID
  37696. }
  37697. }
  37698. // Client returns a new `ent.Client` from the mutation. If the mutation was
  37699. // executed in a transaction (ent.Tx), a transactional client is returned.
  37700. func (m WorkExperienceMutation) Client() *Client {
  37701. client := &Client{config: m.config}
  37702. client.init()
  37703. return client
  37704. }
  37705. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  37706. // it returns an error otherwise.
  37707. func (m WorkExperienceMutation) Tx() (*Tx, error) {
  37708. if _, ok := m.driver.(*txDriver); !ok {
  37709. return nil, errors.New("ent: mutation is not running in a transaction")
  37710. }
  37711. tx := &Tx{config: m.config}
  37712. tx.init()
  37713. return tx, nil
  37714. }
  37715. // SetID sets the value of the id field. Note that this
  37716. // operation is only accepted on creation of WorkExperience entities.
  37717. func (m *WorkExperienceMutation) SetID(id uint64) {
  37718. m.id = &id
  37719. }
  37720. // ID returns the ID value in the mutation. Note that the ID is only available
  37721. // if it was provided to the builder or after it was returned from the database.
  37722. func (m *WorkExperienceMutation) ID() (id uint64, exists bool) {
  37723. if m.id == nil {
  37724. return
  37725. }
  37726. return *m.id, true
  37727. }
  37728. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  37729. // That means, if the mutation is applied within a transaction with an isolation level such
  37730. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  37731. // or updated by the mutation.
  37732. func (m *WorkExperienceMutation) IDs(ctx context.Context) ([]uint64, error) {
  37733. switch {
  37734. case m.op.Is(OpUpdateOne | OpDeleteOne):
  37735. id, exists := m.ID()
  37736. if exists {
  37737. return []uint64{id}, nil
  37738. }
  37739. fallthrough
  37740. case m.op.Is(OpUpdate | OpDelete):
  37741. return m.Client().WorkExperience.Query().Where(m.predicates...).IDs(ctx)
  37742. default:
  37743. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  37744. }
  37745. }
  37746. // SetCreatedAt sets the "created_at" field.
  37747. func (m *WorkExperienceMutation) SetCreatedAt(t time.Time) {
  37748. m.created_at = &t
  37749. }
  37750. // CreatedAt returns the value of the "created_at" field in the mutation.
  37751. func (m *WorkExperienceMutation) CreatedAt() (r time.Time, exists bool) {
  37752. v := m.created_at
  37753. if v == nil {
  37754. return
  37755. }
  37756. return *v, true
  37757. }
  37758. // OldCreatedAt returns the old "created_at" field's value of the WorkExperience entity.
  37759. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  37760. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37761. func (m *WorkExperienceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  37762. if !m.op.Is(OpUpdateOne) {
  37763. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  37764. }
  37765. if m.id == nil || m.oldValue == nil {
  37766. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  37767. }
  37768. oldValue, err := m.oldValue(ctx)
  37769. if err != nil {
  37770. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  37771. }
  37772. return oldValue.CreatedAt, nil
  37773. }
  37774. // ResetCreatedAt resets all changes to the "created_at" field.
  37775. func (m *WorkExperienceMutation) ResetCreatedAt() {
  37776. m.created_at = nil
  37777. }
  37778. // SetUpdatedAt sets the "updated_at" field.
  37779. func (m *WorkExperienceMutation) SetUpdatedAt(t time.Time) {
  37780. m.updated_at = &t
  37781. }
  37782. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  37783. func (m *WorkExperienceMutation) UpdatedAt() (r time.Time, exists bool) {
  37784. v := m.updated_at
  37785. if v == nil {
  37786. return
  37787. }
  37788. return *v, true
  37789. }
  37790. // OldUpdatedAt returns the old "updated_at" field's value of the WorkExperience entity.
  37791. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  37792. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37793. func (m *WorkExperienceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  37794. if !m.op.Is(OpUpdateOne) {
  37795. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  37796. }
  37797. if m.id == nil || m.oldValue == nil {
  37798. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  37799. }
  37800. oldValue, err := m.oldValue(ctx)
  37801. if err != nil {
  37802. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  37803. }
  37804. return oldValue.UpdatedAt, nil
  37805. }
  37806. // ResetUpdatedAt resets all changes to the "updated_at" field.
  37807. func (m *WorkExperienceMutation) ResetUpdatedAt() {
  37808. m.updated_at = nil
  37809. }
  37810. // SetDeletedAt sets the "deleted_at" field.
  37811. func (m *WorkExperienceMutation) SetDeletedAt(t time.Time) {
  37812. m.deleted_at = &t
  37813. }
  37814. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  37815. func (m *WorkExperienceMutation) DeletedAt() (r time.Time, exists bool) {
  37816. v := m.deleted_at
  37817. if v == nil {
  37818. return
  37819. }
  37820. return *v, true
  37821. }
  37822. // OldDeletedAt returns the old "deleted_at" field's value of the WorkExperience entity.
  37823. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  37824. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37825. func (m *WorkExperienceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  37826. if !m.op.Is(OpUpdateOne) {
  37827. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  37828. }
  37829. if m.id == nil || m.oldValue == nil {
  37830. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  37831. }
  37832. oldValue, err := m.oldValue(ctx)
  37833. if err != nil {
  37834. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  37835. }
  37836. return oldValue.DeletedAt, nil
  37837. }
  37838. // ClearDeletedAt clears the value of the "deleted_at" field.
  37839. func (m *WorkExperienceMutation) ClearDeletedAt() {
  37840. m.deleted_at = nil
  37841. m.clearedFields[workexperience.FieldDeletedAt] = struct{}{}
  37842. }
  37843. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  37844. func (m *WorkExperienceMutation) DeletedAtCleared() bool {
  37845. _, ok := m.clearedFields[workexperience.FieldDeletedAt]
  37846. return ok
  37847. }
  37848. // ResetDeletedAt resets all changes to the "deleted_at" field.
  37849. func (m *WorkExperienceMutation) ResetDeletedAt() {
  37850. m.deleted_at = nil
  37851. delete(m.clearedFields, workexperience.FieldDeletedAt)
  37852. }
  37853. // SetEmployeeID sets the "employee_id" field.
  37854. func (m *WorkExperienceMutation) SetEmployeeID(u uint64) {
  37855. m.employee = &u
  37856. }
  37857. // EmployeeID returns the value of the "employee_id" field in the mutation.
  37858. func (m *WorkExperienceMutation) EmployeeID() (r uint64, exists bool) {
  37859. v := m.employee
  37860. if v == nil {
  37861. return
  37862. }
  37863. return *v, true
  37864. }
  37865. // OldEmployeeID returns the old "employee_id" field's value of the WorkExperience entity.
  37866. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  37867. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37868. func (m *WorkExperienceMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  37869. if !m.op.Is(OpUpdateOne) {
  37870. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  37871. }
  37872. if m.id == nil || m.oldValue == nil {
  37873. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  37874. }
  37875. oldValue, err := m.oldValue(ctx)
  37876. if err != nil {
  37877. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  37878. }
  37879. return oldValue.EmployeeID, nil
  37880. }
  37881. // ResetEmployeeID resets all changes to the "employee_id" field.
  37882. func (m *WorkExperienceMutation) ResetEmployeeID() {
  37883. m.employee = nil
  37884. }
  37885. // SetStartDate sets the "start_date" field.
  37886. func (m *WorkExperienceMutation) SetStartDate(t time.Time) {
  37887. m.start_date = &t
  37888. }
  37889. // StartDate returns the value of the "start_date" field in the mutation.
  37890. func (m *WorkExperienceMutation) StartDate() (r time.Time, exists bool) {
  37891. v := m.start_date
  37892. if v == nil {
  37893. return
  37894. }
  37895. return *v, true
  37896. }
  37897. // OldStartDate returns the old "start_date" field's value of the WorkExperience entity.
  37898. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  37899. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37900. func (m *WorkExperienceMutation) OldStartDate(ctx context.Context) (v time.Time, err error) {
  37901. if !m.op.Is(OpUpdateOne) {
  37902. return v, errors.New("OldStartDate is only allowed on UpdateOne operations")
  37903. }
  37904. if m.id == nil || m.oldValue == nil {
  37905. return v, errors.New("OldStartDate requires an ID field in the mutation")
  37906. }
  37907. oldValue, err := m.oldValue(ctx)
  37908. if err != nil {
  37909. return v, fmt.Errorf("querying old value for OldStartDate: %w", err)
  37910. }
  37911. return oldValue.StartDate, nil
  37912. }
  37913. // ResetStartDate resets all changes to the "start_date" field.
  37914. func (m *WorkExperienceMutation) ResetStartDate() {
  37915. m.start_date = nil
  37916. }
  37917. // SetEndDate sets the "end_date" field.
  37918. func (m *WorkExperienceMutation) SetEndDate(t time.Time) {
  37919. m.end_date = &t
  37920. }
  37921. // EndDate returns the value of the "end_date" field in the mutation.
  37922. func (m *WorkExperienceMutation) EndDate() (r time.Time, exists bool) {
  37923. v := m.end_date
  37924. if v == nil {
  37925. return
  37926. }
  37927. return *v, true
  37928. }
  37929. // OldEndDate returns the old "end_date" field's value of the WorkExperience entity.
  37930. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  37931. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37932. func (m *WorkExperienceMutation) OldEndDate(ctx context.Context) (v time.Time, err error) {
  37933. if !m.op.Is(OpUpdateOne) {
  37934. return v, errors.New("OldEndDate is only allowed on UpdateOne operations")
  37935. }
  37936. if m.id == nil || m.oldValue == nil {
  37937. return v, errors.New("OldEndDate requires an ID field in the mutation")
  37938. }
  37939. oldValue, err := m.oldValue(ctx)
  37940. if err != nil {
  37941. return v, fmt.Errorf("querying old value for OldEndDate: %w", err)
  37942. }
  37943. return oldValue.EndDate, nil
  37944. }
  37945. // ResetEndDate resets all changes to the "end_date" field.
  37946. func (m *WorkExperienceMutation) ResetEndDate() {
  37947. m.end_date = nil
  37948. }
  37949. // SetCompany sets the "company" field.
  37950. func (m *WorkExperienceMutation) SetCompany(s string) {
  37951. m.company = &s
  37952. }
  37953. // Company returns the value of the "company" field in the mutation.
  37954. func (m *WorkExperienceMutation) Company() (r string, exists bool) {
  37955. v := m.company
  37956. if v == nil {
  37957. return
  37958. }
  37959. return *v, true
  37960. }
  37961. // OldCompany returns the old "company" field's value of the WorkExperience entity.
  37962. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  37963. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37964. func (m *WorkExperienceMutation) OldCompany(ctx context.Context) (v string, err error) {
  37965. if !m.op.Is(OpUpdateOne) {
  37966. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  37967. }
  37968. if m.id == nil || m.oldValue == nil {
  37969. return v, errors.New("OldCompany requires an ID field in the mutation")
  37970. }
  37971. oldValue, err := m.oldValue(ctx)
  37972. if err != nil {
  37973. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  37974. }
  37975. return oldValue.Company, nil
  37976. }
  37977. // ResetCompany resets all changes to the "company" field.
  37978. func (m *WorkExperienceMutation) ResetCompany() {
  37979. m.company = nil
  37980. }
  37981. // SetExperience sets the "experience" field.
  37982. func (m *WorkExperienceMutation) SetExperience(s string) {
  37983. m.experience = &s
  37984. }
  37985. // Experience returns the value of the "experience" field in the mutation.
  37986. func (m *WorkExperienceMutation) Experience() (r string, exists bool) {
  37987. v := m.experience
  37988. if v == nil {
  37989. return
  37990. }
  37991. return *v, true
  37992. }
  37993. // OldExperience returns the old "experience" field's value of the WorkExperience entity.
  37994. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  37995. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37996. func (m *WorkExperienceMutation) OldExperience(ctx context.Context) (v string, err error) {
  37997. if !m.op.Is(OpUpdateOne) {
  37998. return v, errors.New("OldExperience is only allowed on UpdateOne operations")
  37999. }
  38000. if m.id == nil || m.oldValue == nil {
  38001. return v, errors.New("OldExperience requires an ID field in the mutation")
  38002. }
  38003. oldValue, err := m.oldValue(ctx)
  38004. if err != nil {
  38005. return v, fmt.Errorf("querying old value for OldExperience: %w", err)
  38006. }
  38007. return oldValue.Experience, nil
  38008. }
  38009. // ResetExperience resets all changes to the "experience" field.
  38010. func (m *WorkExperienceMutation) ResetExperience() {
  38011. m.experience = nil
  38012. }
  38013. // SetOrganizationID sets the "organization_id" field.
  38014. func (m *WorkExperienceMutation) SetOrganizationID(u uint64) {
  38015. m.organization_id = &u
  38016. m.addorganization_id = nil
  38017. }
  38018. // OrganizationID returns the value of the "organization_id" field in the mutation.
  38019. func (m *WorkExperienceMutation) OrganizationID() (r uint64, exists bool) {
  38020. v := m.organization_id
  38021. if v == nil {
  38022. return
  38023. }
  38024. return *v, true
  38025. }
  38026. // OldOrganizationID returns the old "organization_id" field's value of the WorkExperience entity.
  38027. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  38028. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38029. func (m *WorkExperienceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  38030. if !m.op.Is(OpUpdateOne) {
  38031. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  38032. }
  38033. if m.id == nil || m.oldValue == nil {
  38034. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  38035. }
  38036. oldValue, err := m.oldValue(ctx)
  38037. if err != nil {
  38038. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  38039. }
  38040. return oldValue.OrganizationID, nil
  38041. }
  38042. // AddOrganizationID adds u to the "organization_id" field.
  38043. func (m *WorkExperienceMutation) AddOrganizationID(u int64) {
  38044. if m.addorganization_id != nil {
  38045. *m.addorganization_id += u
  38046. } else {
  38047. m.addorganization_id = &u
  38048. }
  38049. }
  38050. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  38051. func (m *WorkExperienceMutation) AddedOrganizationID() (r int64, exists bool) {
  38052. v := m.addorganization_id
  38053. if v == nil {
  38054. return
  38055. }
  38056. return *v, true
  38057. }
  38058. // ResetOrganizationID resets all changes to the "organization_id" field.
  38059. func (m *WorkExperienceMutation) ResetOrganizationID() {
  38060. m.organization_id = nil
  38061. m.addorganization_id = nil
  38062. }
  38063. // ClearEmployee clears the "employee" edge to the Employee entity.
  38064. func (m *WorkExperienceMutation) ClearEmployee() {
  38065. m.clearedemployee = true
  38066. m.clearedFields[workexperience.FieldEmployeeID] = struct{}{}
  38067. }
  38068. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  38069. func (m *WorkExperienceMutation) EmployeeCleared() bool {
  38070. return m.clearedemployee
  38071. }
  38072. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  38073. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  38074. // EmployeeID instead. It exists only for internal usage by the builders.
  38075. func (m *WorkExperienceMutation) EmployeeIDs() (ids []uint64) {
  38076. if id := m.employee; id != nil {
  38077. ids = append(ids, *id)
  38078. }
  38079. return
  38080. }
  38081. // ResetEmployee resets all changes to the "employee" edge.
  38082. func (m *WorkExperienceMutation) ResetEmployee() {
  38083. m.employee = nil
  38084. m.clearedemployee = false
  38085. }
  38086. // Where appends a list predicates to the WorkExperienceMutation builder.
  38087. func (m *WorkExperienceMutation) Where(ps ...predicate.WorkExperience) {
  38088. m.predicates = append(m.predicates, ps...)
  38089. }
  38090. // WhereP appends storage-level predicates to the WorkExperienceMutation builder. Using this method,
  38091. // users can use type-assertion to append predicates that do not depend on any generated package.
  38092. func (m *WorkExperienceMutation) WhereP(ps ...func(*sql.Selector)) {
  38093. p := make([]predicate.WorkExperience, len(ps))
  38094. for i := range ps {
  38095. p[i] = ps[i]
  38096. }
  38097. m.Where(p...)
  38098. }
  38099. // Op returns the operation name.
  38100. func (m *WorkExperienceMutation) Op() Op {
  38101. return m.op
  38102. }
  38103. // SetOp allows setting the mutation operation.
  38104. func (m *WorkExperienceMutation) SetOp(op Op) {
  38105. m.op = op
  38106. }
  38107. // Type returns the node type of this mutation (WorkExperience).
  38108. func (m *WorkExperienceMutation) Type() string {
  38109. return m.typ
  38110. }
  38111. // Fields returns all fields that were changed during this mutation. Note that in
  38112. // order to get all numeric fields that were incremented/decremented, call
  38113. // AddedFields().
  38114. func (m *WorkExperienceMutation) Fields() []string {
  38115. fields := make([]string, 0, 9)
  38116. if m.created_at != nil {
  38117. fields = append(fields, workexperience.FieldCreatedAt)
  38118. }
  38119. if m.updated_at != nil {
  38120. fields = append(fields, workexperience.FieldUpdatedAt)
  38121. }
  38122. if m.deleted_at != nil {
  38123. fields = append(fields, workexperience.FieldDeletedAt)
  38124. }
  38125. if m.employee != nil {
  38126. fields = append(fields, workexperience.FieldEmployeeID)
  38127. }
  38128. if m.start_date != nil {
  38129. fields = append(fields, workexperience.FieldStartDate)
  38130. }
  38131. if m.end_date != nil {
  38132. fields = append(fields, workexperience.FieldEndDate)
  38133. }
  38134. if m.company != nil {
  38135. fields = append(fields, workexperience.FieldCompany)
  38136. }
  38137. if m.experience != nil {
  38138. fields = append(fields, workexperience.FieldExperience)
  38139. }
  38140. if m.organization_id != nil {
  38141. fields = append(fields, workexperience.FieldOrganizationID)
  38142. }
  38143. return fields
  38144. }
  38145. // Field returns the value of a field with the given name. The second boolean
  38146. // return value indicates that this field was not set, or was not defined in the
  38147. // schema.
  38148. func (m *WorkExperienceMutation) Field(name string) (ent.Value, bool) {
  38149. switch name {
  38150. case workexperience.FieldCreatedAt:
  38151. return m.CreatedAt()
  38152. case workexperience.FieldUpdatedAt:
  38153. return m.UpdatedAt()
  38154. case workexperience.FieldDeletedAt:
  38155. return m.DeletedAt()
  38156. case workexperience.FieldEmployeeID:
  38157. return m.EmployeeID()
  38158. case workexperience.FieldStartDate:
  38159. return m.StartDate()
  38160. case workexperience.FieldEndDate:
  38161. return m.EndDate()
  38162. case workexperience.FieldCompany:
  38163. return m.Company()
  38164. case workexperience.FieldExperience:
  38165. return m.Experience()
  38166. case workexperience.FieldOrganizationID:
  38167. return m.OrganizationID()
  38168. }
  38169. return nil, false
  38170. }
  38171. // OldField returns the old value of the field from the database. An error is
  38172. // returned if the mutation operation is not UpdateOne, or the query to the
  38173. // database failed.
  38174. func (m *WorkExperienceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  38175. switch name {
  38176. case workexperience.FieldCreatedAt:
  38177. return m.OldCreatedAt(ctx)
  38178. case workexperience.FieldUpdatedAt:
  38179. return m.OldUpdatedAt(ctx)
  38180. case workexperience.FieldDeletedAt:
  38181. return m.OldDeletedAt(ctx)
  38182. case workexperience.FieldEmployeeID:
  38183. return m.OldEmployeeID(ctx)
  38184. case workexperience.FieldStartDate:
  38185. return m.OldStartDate(ctx)
  38186. case workexperience.FieldEndDate:
  38187. return m.OldEndDate(ctx)
  38188. case workexperience.FieldCompany:
  38189. return m.OldCompany(ctx)
  38190. case workexperience.FieldExperience:
  38191. return m.OldExperience(ctx)
  38192. case workexperience.FieldOrganizationID:
  38193. return m.OldOrganizationID(ctx)
  38194. }
  38195. return nil, fmt.Errorf("unknown WorkExperience field %s", name)
  38196. }
  38197. // SetField sets the value of a field with the given name. It returns an error if
  38198. // the field is not defined in the schema, or if the type mismatched the field
  38199. // type.
  38200. func (m *WorkExperienceMutation) SetField(name string, value ent.Value) error {
  38201. switch name {
  38202. case workexperience.FieldCreatedAt:
  38203. v, ok := value.(time.Time)
  38204. if !ok {
  38205. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38206. }
  38207. m.SetCreatedAt(v)
  38208. return nil
  38209. case workexperience.FieldUpdatedAt:
  38210. v, ok := value.(time.Time)
  38211. if !ok {
  38212. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38213. }
  38214. m.SetUpdatedAt(v)
  38215. return nil
  38216. case workexperience.FieldDeletedAt:
  38217. v, ok := value.(time.Time)
  38218. if !ok {
  38219. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38220. }
  38221. m.SetDeletedAt(v)
  38222. return nil
  38223. case workexperience.FieldEmployeeID:
  38224. v, ok := value.(uint64)
  38225. if !ok {
  38226. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38227. }
  38228. m.SetEmployeeID(v)
  38229. return nil
  38230. case workexperience.FieldStartDate:
  38231. v, ok := value.(time.Time)
  38232. if !ok {
  38233. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38234. }
  38235. m.SetStartDate(v)
  38236. return nil
  38237. case workexperience.FieldEndDate:
  38238. v, ok := value.(time.Time)
  38239. if !ok {
  38240. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38241. }
  38242. m.SetEndDate(v)
  38243. return nil
  38244. case workexperience.FieldCompany:
  38245. v, ok := value.(string)
  38246. if !ok {
  38247. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38248. }
  38249. m.SetCompany(v)
  38250. return nil
  38251. case workexperience.FieldExperience:
  38252. v, ok := value.(string)
  38253. if !ok {
  38254. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38255. }
  38256. m.SetExperience(v)
  38257. return nil
  38258. case workexperience.FieldOrganizationID:
  38259. v, ok := value.(uint64)
  38260. if !ok {
  38261. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38262. }
  38263. m.SetOrganizationID(v)
  38264. return nil
  38265. }
  38266. return fmt.Errorf("unknown WorkExperience field %s", name)
  38267. }
  38268. // AddedFields returns all numeric fields that were incremented/decremented during
  38269. // this mutation.
  38270. func (m *WorkExperienceMutation) AddedFields() []string {
  38271. var fields []string
  38272. if m.addorganization_id != nil {
  38273. fields = append(fields, workexperience.FieldOrganizationID)
  38274. }
  38275. return fields
  38276. }
  38277. // AddedField returns the numeric value that was incremented/decremented on a field
  38278. // with the given name. The second boolean return value indicates that this field
  38279. // was not set, or was not defined in the schema.
  38280. func (m *WorkExperienceMutation) AddedField(name string) (ent.Value, bool) {
  38281. switch name {
  38282. case workexperience.FieldOrganizationID:
  38283. return m.AddedOrganizationID()
  38284. }
  38285. return nil, false
  38286. }
  38287. // AddField adds the value to the field with the given name. It returns an error if
  38288. // the field is not defined in the schema, or if the type mismatched the field
  38289. // type.
  38290. func (m *WorkExperienceMutation) AddField(name string, value ent.Value) error {
  38291. switch name {
  38292. case workexperience.FieldOrganizationID:
  38293. v, ok := value.(int64)
  38294. if !ok {
  38295. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38296. }
  38297. m.AddOrganizationID(v)
  38298. return nil
  38299. }
  38300. return fmt.Errorf("unknown WorkExperience numeric field %s", name)
  38301. }
  38302. // ClearedFields returns all nullable fields that were cleared during this
  38303. // mutation.
  38304. func (m *WorkExperienceMutation) ClearedFields() []string {
  38305. var fields []string
  38306. if m.FieldCleared(workexperience.FieldDeletedAt) {
  38307. fields = append(fields, workexperience.FieldDeletedAt)
  38308. }
  38309. return fields
  38310. }
  38311. // FieldCleared returns a boolean indicating if a field with the given name was
  38312. // cleared in this mutation.
  38313. func (m *WorkExperienceMutation) FieldCleared(name string) bool {
  38314. _, ok := m.clearedFields[name]
  38315. return ok
  38316. }
  38317. // ClearField clears the value of the field with the given name. It returns an
  38318. // error if the field is not defined in the schema.
  38319. func (m *WorkExperienceMutation) ClearField(name string) error {
  38320. switch name {
  38321. case workexperience.FieldDeletedAt:
  38322. m.ClearDeletedAt()
  38323. return nil
  38324. }
  38325. return fmt.Errorf("unknown WorkExperience nullable field %s", name)
  38326. }
  38327. // ResetField resets all changes in the mutation for the field with the given name.
  38328. // It returns an error if the field is not defined in the schema.
  38329. func (m *WorkExperienceMutation) ResetField(name string) error {
  38330. switch name {
  38331. case workexperience.FieldCreatedAt:
  38332. m.ResetCreatedAt()
  38333. return nil
  38334. case workexperience.FieldUpdatedAt:
  38335. m.ResetUpdatedAt()
  38336. return nil
  38337. case workexperience.FieldDeletedAt:
  38338. m.ResetDeletedAt()
  38339. return nil
  38340. case workexperience.FieldEmployeeID:
  38341. m.ResetEmployeeID()
  38342. return nil
  38343. case workexperience.FieldStartDate:
  38344. m.ResetStartDate()
  38345. return nil
  38346. case workexperience.FieldEndDate:
  38347. m.ResetEndDate()
  38348. return nil
  38349. case workexperience.FieldCompany:
  38350. m.ResetCompany()
  38351. return nil
  38352. case workexperience.FieldExperience:
  38353. m.ResetExperience()
  38354. return nil
  38355. case workexperience.FieldOrganizationID:
  38356. m.ResetOrganizationID()
  38357. return nil
  38358. }
  38359. return fmt.Errorf("unknown WorkExperience field %s", name)
  38360. }
  38361. // AddedEdges returns all edge names that were set/added in this mutation.
  38362. func (m *WorkExperienceMutation) AddedEdges() []string {
  38363. edges := make([]string, 0, 1)
  38364. if m.employee != nil {
  38365. edges = append(edges, workexperience.EdgeEmployee)
  38366. }
  38367. return edges
  38368. }
  38369. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  38370. // name in this mutation.
  38371. func (m *WorkExperienceMutation) AddedIDs(name string) []ent.Value {
  38372. switch name {
  38373. case workexperience.EdgeEmployee:
  38374. if id := m.employee; id != nil {
  38375. return []ent.Value{*id}
  38376. }
  38377. }
  38378. return nil
  38379. }
  38380. // RemovedEdges returns all edge names that were removed in this mutation.
  38381. func (m *WorkExperienceMutation) RemovedEdges() []string {
  38382. edges := make([]string, 0, 1)
  38383. return edges
  38384. }
  38385. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  38386. // the given name in this mutation.
  38387. func (m *WorkExperienceMutation) RemovedIDs(name string) []ent.Value {
  38388. return nil
  38389. }
  38390. // ClearedEdges returns all edge names that were cleared in this mutation.
  38391. func (m *WorkExperienceMutation) ClearedEdges() []string {
  38392. edges := make([]string, 0, 1)
  38393. if m.clearedemployee {
  38394. edges = append(edges, workexperience.EdgeEmployee)
  38395. }
  38396. return edges
  38397. }
  38398. // EdgeCleared returns a boolean which indicates if the edge with the given name
  38399. // was cleared in this mutation.
  38400. func (m *WorkExperienceMutation) EdgeCleared(name string) bool {
  38401. switch name {
  38402. case workexperience.EdgeEmployee:
  38403. return m.clearedemployee
  38404. }
  38405. return false
  38406. }
  38407. // ClearEdge clears the value of the edge with the given name. It returns an error
  38408. // if that edge is not defined in the schema.
  38409. func (m *WorkExperienceMutation) ClearEdge(name string) error {
  38410. switch name {
  38411. case workexperience.EdgeEmployee:
  38412. m.ClearEmployee()
  38413. return nil
  38414. }
  38415. return fmt.Errorf("unknown WorkExperience unique edge %s", name)
  38416. }
  38417. // ResetEdge resets all changes to the edge with the given name in this mutation.
  38418. // It returns an error if the edge is not defined in the schema.
  38419. func (m *WorkExperienceMutation) ResetEdge(name string) error {
  38420. switch name {
  38421. case workexperience.EdgeEmployee:
  38422. m.ResetEmployee()
  38423. return nil
  38424. }
  38425. return fmt.Errorf("unknown WorkExperience edge %s", name)
  38426. }
  38427. // WpChatroomMutation represents an operation that mutates the WpChatroom nodes in the graph.
  38428. type WpChatroomMutation struct {
  38429. config
  38430. op Op
  38431. typ string
  38432. id *uint64
  38433. created_at *time.Time
  38434. updated_at *time.Time
  38435. status *uint8
  38436. addstatus *int8
  38437. wx_wxid *string
  38438. chatroom_id *string
  38439. nickname *string
  38440. owner *string
  38441. avatar *string
  38442. member_list *[]string
  38443. appendmember_list []string
  38444. clearedFields map[string]struct{}
  38445. done bool
  38446. oldValue func(context.Context) (*WpChatroom, error)
  38447. predicates []predicate.WpChatroom
  38448. }
  38449. var _ ent.Mutation = (*WpChatroomMutation)(nil)
  38450. // wpchatroomOption allows management of the mutation configuration using functional options.
  38451. type wpchatroomOption func(*WpChatroomMutation)
  38452. // newWpChatroomMutation creates new mutation for the WpChatroom entity.
  38453. func newWpChatroomMutation(c config, op Op, opts ...wpchatroomOption) *WpChatroomMutation {
  38454. m := &WpChatroomMutation{
  38455. config: c,
  38456. op: op,
  38457. typ: TypeWpChatroom,
  38458. clearedFields: make(map[string]struct{}),
  38459. }
  38460. for _, opt := range opts {
  38461. opt(m)
  38462. }
  38463. return m
  38464. }
  38465. // withWpChatroomID sets the ID field of the mutation.
  38466. func withWpChatroomID(id uint64) wpchatroomOption {
  38467. return func(m *WpChatroomMutation) {
  38468. var (
  38469. err error
  38470. once sync.Once
  38471. value *WpChatroom
  38472. )
  38473. m.oldValue = func(ctx context.Context) (*WpChatroom, error) {
  38474. once.Do(func() {
  38475. if m.done {
  38476. err = errors.New("querying old values post mutation is not allowed")
  38477. } else {
  38478. value, err = m.Client().WpChatroom.Get(ctx, id)
  38479. }
  38480. })
  38481. return value, err
  38482. }
  38483. m.id = &id
  38484. }
  38485. }
  38486. // withWpChatroom sets the old WpChatroom of the mutation.
  38487. func withWpChatroom(node *WpChatroom) wpchatroomOption {
  38488. return func(m *WpChatroomMutation) {
  38489. m.oldValue = func(context.Context) (*WpChatroom, error) {
  38490. return node, nil
  38491. }
  38492. m.id = &node.ID
  38493. }
  38494. }
  38495. // Client returns a new `ent.Client` from the mutation. If the mutation was
  38496. // executed in a transaction (ent.Tx), a transactional client is returned.
  38497. func (m WpChatroomMutation) Client() *Client {
  38498. client := &Client{config: m.config}
  38499. client.init()
  38500. return client
  38501. }
  38502. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  38503. // it returns an error otherwise.
  38504. func (m WpChatroomMutation) Tx() (*Tx, error) {
  38505. if _, ok := m.driver.(*txDriver); !ok {
  38506. return nil, errors.New("ent: mutation is not running in a transaction")
  38507. }
  38508. tx := &Tx{config: m.config}
  38509. tx.init()
  38510. return tx, nil
  38511. }
  38512. // SetID sets the value of the id field. Note that this
  38513. // operation is only accepted on creation of WpChatroom entities.
  38514. func (m *WpChatroomMutation) SetID(id uint64) {
  38515. m.id = &id
  38516. }
  38517. // ID returns the ID value in the mutation. Note that the ID is only available
  38518. // if it was provided to the builder or after it was returned from the database.
  38519. func (m *WpChatroomMutation) ID() (id uint64, exists bool) {
  38520. if m.id == nil {
  38521. return
  38522. }
  38523. return *m.id, true
  38524. }
  38525. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  38526. // That means, if the mutation is applied within a transaction with an isolation level such
  38527. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  38528. // or updated by the mutation.
  38529. func (m *WpChatroomMutation) IDs(ctx context.Context) ([]uint64, error) {
  38530. switch {
  38531. case m.op.Is(OpUpdateOne | OpDeleteOne):
  38532. id, exists := m.ID()
  38533. if exists {
  38534. return []uint64{id}, nil
  38535. }
  38536. fallthrough
  38537. case m.op.Is(OpUpdate | OpDelete):
  38538. return m.Client().WpChatroom.Query().Where(m.predicates...).IDs(ctx)
  38539. default:
  38540. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  38541. }
  38542. }
  38543. // SetCreatedAt sets the "created_at" field.
  38544. func (m *WpChatroomMutation) SetCreatedAt(t time.Time) {
  38545. m.created_at = &t
  38546. }
  38547. // CreatedAt returns the value of the "created_at" field in the mutation.
  38548. func (m *WpChatroomMutation) CreatedAt() (r time.Time, exists bool) {
  38549. v := m.created_at
  38550. if v == nil {
  38551. return
  38552. }
  38553. return *v, true
  38554. }
  38555. // OldCreatedAt returns the old "created_at" field's value of the WpChatroom entity.
  38556. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  38557. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38558. func (m *WpChatroomMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  38559. if !m.op.Is(OpUpdateOne) {
  38560. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  38561. }
  38562. if m.id == nil || m.oldValue == nil {
  38563. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  38564. }
  38565. oldValue, err := m.oldValue(ctx)
  38566. if err != nil {
  38567. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  38568. }
  38569. return oldValue.CreatedAt, nil
  38570. }
  38571. // ResetCreatedAt resets all changes to the "created_at" field.
  38572. func (m *WpChatroomMutation) ResetCreatedAt() {
  38573. m.created_at = nil
  38574. }
  38575. // SetUpdatedAt sets the "updated_at" field.
  38576. func (m *WpChatroomMutation) SetUpdatedAt(t time.Time) {
  38577. m.updated_at = &t
  38578. }
  38579. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  38580. func (m *WpChatroomMutation) UpdatedAt() (r time.Time, exists bool) {
  38581. v := m.updated_at
  38582. if v == nil {
  38583. return
  38584. }
  38585. return *v, true
  38586. }
  38587. // OldUpdatedAt returns the old "updated_at" field's value of the WpChatroom entity.
  38588. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  38589. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38590. func (m *WpChatroomMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  38591. if !m.op.Is(OpUpdateOne) {
  38592. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  38593. }
  38594. if m.id == nil || m.oldValue == nil {
  38595. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  38596. }
  38597. oldValue, err := m.oldValue(ctx)
  38598. if err != nil {
  38599. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  38600. }
  38601. return oldValue.UpdatedAt, nil
  38602. }
  38603. // ResetUpdatedAt resets all changes to the "updated_at" field.
  38604. func (m *WpChatroomMutation) ResetUpdatedAt() {
  38605. m.updated_at = nil
  38606. }
  38607. // SetStatus sets the "status" field.
  38608. func (m *WpChatroomMutation) SetStatus(u uint8) {
  38609. m.status = &u
  38610. m.addstatus = nil
  38611. }
  38612. // Status returns the value of the "status" field in the mutation.
  38613. func (m *WpChatroomMutation) Status() (r uint8, exists bool) {
  38614. v := m.status
  38615. if v == nil {
  38616. return
  38617. }
  38618. return *v, true
  38619. }
  38620. // OldStatus returns the old "status" field's value of the WpChatroom entity.
  38621. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  38622. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38623. func (m *WpChatroomMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  38624. if !m.op.Is(OpUpdateOne) {
  38625. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  38626. }
  38627. if m.id == nil || m.oldValue == nil {
  38628. return v, errors.New("OldStatus requires an ID field in the mutation")
  38629. }
  38630. oldValue, err := m.oldValue(ctx)
  38631. if err != nil {
  38632. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  38633. }
  38634. return oldValue.Status, nil
  38635. }
  38636. // AddStatus adds u to the "status" field.
  38637. func (m *WpChatroomMutation) AddStatus(u int8) {
  38638. if m.addstatus != nil {
  38639. *m.addstatus += u
  38640. } else {
  38641. m.addstatus = &u
  38642. }
  38643. }
  38644. // AddedStatus returns the value that was added to the "status" field in this mutation.
  38645. func (m *WpChatroomMutation) AddedStatus() (r int8, exists bool) {
  38646. v := m.addstatus
  38647. if v == nil {
  38648. return
  38649. }
  38650. return *v, true
  38651. }
  38652. // ClearStatus clears the value of the "status" field.
  38653. func (m *WpChatroomMutation) ClearStatus() {
  38654. m.status = nil
  38655. m.addstatus = nil
  38656. m.clearedFields[wpchatroom.FieldStatus] = struct{}{}
  38657. }
  38658. // StatusCleared returns if the "status" field was cleared in this mutation.
  38659. func (m *WpChatroomMutation) StatusCleared() bool {
  38660. _, ok := m.clearedFields[wpchatroom.FieldStatus]
  38661. return ok
  38662. }
  38663. // ResetStatus resets all changes to the "status" field.
  38664. func (m *WpChatroomMutation) ResetStatus() {
  38665. m.status = nil
  38666. m.addstatus = nil
  38667. delete(m.clearedFields, wpchatroom.FieldStatus)
  38668. }
  38669. // SetWxWxid sets the "wx_wxid" field.
  38670. func (m *WpChatroomMutation) SetWxWxid(s string) {
  38671. m.wx_wxid = &s
  38672. }
  38673. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  38674. func (m *WpChatroomMutation) WxWxid() (r string, exists bool) {
  38675. v := m.wx_wxid
  38676. if v == nil {
  38677. return
  38678. }
  38679. return *v, true
  38680. }
  38681. // OldWxWxid returns the old "wx_wxid" field's value of the WpChatroom entity.
  38682. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  38683. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38684. func (m *WpChatroomMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  38685. if !m.op.Is(OpUpdateOne) {
  38686. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  38687. }
  38688. if m.id == nil || m.oldValue == nil {
  38689. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  38690. }
  38691. oldValue, err := m.oldValue(ctx)
  38692. if err != nil {
  38693. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  38694. }
  38695. return oldValue.WxWxid, nil
  38696. }
  38697. // ResetWxWxid resets all changes to the "wx_wxid" field.
  38698. func (m *WpChatroomMutation) ResetWxWxid() {
  38699. m.wx_wxid = nil
  38700. }
  38701. // SetChatroomID sets the "chatroom_id" field.
  38702. func (m *WpChatroomMutation) SetChatroomID(s string) {
  38703. m.chatroom_id = &s
  38704. }
  38705. // ChatroomID returns the value of the "chatroom_id" field in the mutation.
  38706. func (m *WpChatroomMutation) ChatroomID() (r string, exists bool) {
  38707. v := m.chatroom_id
  38708. if v == nil {
  38709. return
  38710. }
  38711. return *v, true
  38712. }
  38713. // OldChatroomID returns the old "chatroom_id" field's value of the WpChatroom entity.
  38714. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  38715. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38716. func (m *WpChatroomMutation) OldChatroomID(ctx context.Context) (v string, err error) {
  38717. if !m.op.Is(OpUpdateOne) {
  38718. return v, errors.New("OldChatroomID is only allowed on UpdateOne operations")
  38719. }
  38720. if m.id == nil || m.oldValue == nil {
  38721. return v, errors.New("OldChatroomID requires an ID field in the mutation")
  38722. }
  38723. oldValue, err := m.oldValue(ctx)
  38724. if err != nil {
  38725. return v, fmt.Errorf("querying old value for OldChatroomID: %w", err)
  38726. }
  38727. return oldValue.ChatroomID, nil
  38728. }
  38729. // ResetChatroomID resets all changes to the "chatroom_id" field.
  38730. func (m *WpChatroomMutation) ResetChatroomID() {
  38731. m.chatroom_id = nil
  38732. }
  38733. // SetNickname sets the "nickname" field.
  38734. func (m *WpChatroomMutation) SetNickname(s string) {
  38735. m.nickname = &s
  38736. }
  38737. // Nickname returns the value of the "nickname" field in the mutation.
  38738. func (m *WpChatroomMutation) Nickname() (r string, exists bool) {
  38739. v := m.nickname
  38740. if v == nil {
  38741. return
  38742. }
  38743. return *v, true
  38744. }
  38745. // OldNickname returns the old "nickname" field's value of the WpChatroom entity.
  38746. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  38747. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38748. func (m *WpChatroomMutation) OldNickname(ctx context.Context) (v string, err error) {
  38749. if !m.op.Is(OpUpdateOne) {
  38750. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  38751. }
  38752. if m.id == nil || m.oldValue == nil {
  38753. return v, errors.New("OldNickname requires an ID field in the mutation")
  38754. }
  38755. oldValue, err := m.oldValue(ctx)
  38756. if err != nil {
  38757. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  38758. }
  38759. return oldValue.Nickname, nil
  38760. }
  38761. // ResetNickname resets all changes to the "nickname" field.
  38762. func (m *WpChatroomMutation) ResetNickname() {
  38763. m.nickname = nil
  38764. }
  38765. // SetOwner sets the "owner" field.
  38766. func (m *WpChatroomMutation) SetOwner(s string) {
  38767. m.owner = &s
  38768. }
  38769. // Owner returns the value of the "owner" field in the mutation.
  38770. func (m *WpChatroomMutation) Owner() (r string, exists bool) {
  38771. v := m.owner
  38772. if v == nil {
  38773. return
  38774. }
  38775. return *v, true
  38776. }
  38777. // OldOwner returns the old "owner" field's value of the WpChatroom entity.
  38778. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  38779. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38780. func (m *WpChatroomMutation) OldOwner(ctx context.Context) (v string, err error) {
  38781. if !m.op.Is(OpUpdateOne) {
  38782. return v, errors.New("OldOwner is only allowed on UpdateOne operations")
  38783. }
  38784. if m.id == nil || m.oldValue == nil {
  38785. return v, errors.New("OldOwner requires an ID field in the mutation")
  38786. }
  38787. oldValue, err := m.oldValue(ctx)
  38788. if err != nil {
  38789. return v, fmt.Errorf("querying old value for OldOwner: %w", err)
  38790. }
  38791. return oldValue.Owner, nil
  38792. }
  38793. // ResetOwner resets all changes to the "owner" field.
  38794. func (m *WpChatroomMutation) ResetOwner() {
  38795. m.owner = nil
  38796. }
  38797. // SetAvatar sets the "avatar" field.
  38798. func (m *WpChatroomMutation) SetAvatar(s string) {
  38799. m.avatar = &s
  38800. }
  38801. // Avatar returns the value of the "avatar" field in the mutation.
  38802. func (m *WpChatroomMutation) Avatar() (r string, exists bool) {
  38803. v := m.avatar
  38804. if v == nil {
  38805. return
  38806. }
  38807. return *v, true
  38808. }
  38809. // OldAvatar returns the old "avatar" field's value of the WpChatroom entity.
  38810. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  38811. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38812. func (m *WpChatroomMutation) OldAvatar(ctx context.Context) (v string, err error) {
  38813. if !m.op.Is(OpUpdateOne) {
  38814. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  38815. }
  38816. if m.id == nil || m.oldValue == nil {
  38817. return v, errors.New("OldAvatar requires an ID field in the mutation")
  38818. }
  38819. oldValue, err := m.oldValue(ctx)
  38820. if err != nil {
  38821. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  38822. }
  38823. return oldValue.Avatar, nil
  38824. }
  38825. // ResetAvatar resets all changes to the "avatar" field.
  38826. func (m *WpChatroomMutation) ResetAvatar() {
  38827. m.avatar = nil
  38828. }
  38829. // SetMemberList sets the "member_list" field.
  38830. func (m *WpChatroomMutation) SetMemberList(s []string) {
  38831. m.member_list = &s
  38832. m.appendmember_list = nil
  38833. }
  38834. // MemberList returns the value of the "member_list" field in the mutation.
  38835. func (m *WpChatroomMutation) MemberList() (r []string, exists bool) {
  38836. v := m.member_list
  38837. if v == nil {
  38838. return
  38839. }
  38840. return *v, true
  38841. }
  38842. // OldMemberList returns the old "member_list" field's value of the WpChatroom entity.
  38843. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  38844. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38845. func (m *WpChatroomMutation) OldMemberList(ctx context.Context) (v []string, err error) {
  38846. if !m.op.Is(OpUpdateOne) {
  38847. return v, errors.New("OldMemberList is only allowed on UpdateOne operations")
  38848. }
  38849. if m.id == nil || m.oldValue == nil {
  38850. return v, errors.New("OldMemberList requires an ID field in the mutation")
  38851. }
  38852. oldValue, err := m.oldValue(ctx)
  38853. if err != nil {
  38854. return v, fmt.Errorf("querying old value for OldMemberList: %w", err)
  38855. }
  38856. return oldValue.MemberList, nil
  38857. }
  38858. // AppendMemberList adds s to the "member_list" field.
  38859. func (m *WpChatroomMutation) AppendMemberList(s []string) {
  38860. m.appendmember_list = append(m.appendmember_list, s...)
  38861. }
  38862. // AppendedMemberList returns the list of values that were appended to the "member_list" field in this mutation.
  38863. func (m *WpChatroomMutation) AppendedMemberList() ([]string, bool) {
  38864. if len(m.appendmember_list) == 0 {
  38865. return nil, false
  38866. }
  38867. return m.appendmember_list, true
  38868. }
  38869. // ResetMemberList resets all changes to the "member_list" field.
  38870. func (m *WpChatroomMutation) ResetMemberList() {
  38871. m.member_list = nil
  38872. m.appendmember_list = nil
  38873. }
  38874. // Where appends a list predicates to the WpChatroomMutation builder.
  38875. func (m *WpChatroomMutation) Where(ps ...predicate.WpChatroom) {
  38876. m.predicates = append(m.predicates, ps...)
  38877. }
  38878. // WhereP appends storage-level predicates to the WpChatroomMutation builder. Using this method,
  38879. // users can use type-assertion to append predicates that do not depend on any generated package.
  38880. func (m *WpChatroomMutation) WhereP(ps ...func(*sql.Selector)) {
  38881. p := make([]predicate.WpChatroom, len(ps))
  38882. for i := range ps {
  38883. p[i] = ps[i]
  38884. }
  38885. m.Where(p...)
  38886. }
  38887. // Op returns the operation name.
  38888. func (m *WpChatroomMutation) Op() Op {
  38889. return m.op
  38890. }
  38891. // SetOp allows setting the mutation operation.
  38892. func (m *WpChatroomMutation) SetOp(op Op) {
  38893. m.op = op
  38894. }
  38895. // Type returns the node type of this mutation (WpChatroom).
  38896. func (m *WpChatroomMutation) Type() string {
  38897. return m.typ
  38898. }
  38899. // Fields returns all fields that were changed during this mutation. Note that in
  38900. // order to get all numeric fields that were incremented/decremented, call
  38901. // AddedFields().
  38902. func (m *WpChatroomMutation) Fields() []string {
  38903. fields := make([]string, 0, 9)
  38904. if m.created_at != nil {
  38905. fields = append(fields, wpchatroom.FieldCreatedAt)
  38906. }
  38907. if m.updated_at != nil {
  38908. fields = append(fields, wpchatroom.FieldUpdatedAt)
  38909. }
  38910. if m.status != nil {
  38911. fields = append(fields, wpchatroom.FieldStatus)
  38912. }
  38913. if m.wx_wxid != nil {
  38914. fields = append(fields, wpchatroom.FieldWxWxid)
  38915. }
  38916. if m.chatroom_id != nil {
  38917. fields = append(fields, wpchatroom.FieldChatroomID)
  38918. }
  38919. if m.nickname != nil {
  38920. fields = append(fields, wpchatroom.FieldNickname)
  38921. }
  38922. if m.owner != nil {
  38923. fields = append(fields, wpchatroom.FieldOwner)
  38924. }
  38925. if m.avatar != nil {
  38926. fields = append(fields, wpchatroom.FieldAvatar)
  38927. }
  38928. if m.member_list != nil {
  38929. fields = append(fields, wpchatroom.FieldMemberList)
  38930. }
  38931. return fields
  38932. }
  38933. // Field returns the value of a field with the given name. The second boolean
  38934. // return value indicates that this field was not set, or was not defined in the
  38935. // schema.
  38936. func (m *WpChatroomMutation) Field(name string) (ent.Value, bool) {
  38937. switch name {
  38938. case wpchatroom.FieldCreatedAt:
  38939. return m.CreatedAt()
  38940. case wpchatroom.FieldUpdatedAt:
  38941. return m.UpdatedAt()
  38942. case wpchatroom.FieldStatus:
  38943. return m.Status()
  38944. case wpchatroom.FieldWxWxid:
  38945. return m.WxWxid()
  38946. case wpchatroom.FieldChatroomID:
  38947. return m.ChatroomID()
  38948. case wpchatroom.FieldNickname:
  38949. return m.Nickname()
  38950. case wpchatroom.FieldOwner:
  38951. return m.Owner()
  38952. case wpchatroom.FieldAvatar:
  38953. return m.Avatar()
  38954. case wpchatroom.FieldMemberList:
  38955. return m.MemberList()
  38956. }
  38957. return nil, false
  38958. }
  38959. // OldField returns the old value of the field from the database. An error is
  38960. // returned if the mutation operation is not UpdateOne, or the query to the
  38961. // database failed.
  38962. func (m *WpChatroomMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  38963. switch name {
  38964. case wpchatroom.FieldCreatedAt:
  38965. return m.OldCreatedAt(ctx)
  38966. case wpchatroom.FieldUpdatedAt:
  38967. return m.OldUpdatedAt(ctx)
  38968. case wpchatroom.FieldStatus:
  38969. return m.OldStatus(ctx)
  38970. case wpchatroom.FieldWxWxid:
  38971. return m.OldWxWxid(ctx)
  38972. case wpchatroom.FieldChatroomID:
  38973. return m.OldChatroomID(ctx)
  38974. case wpchatroom.FieldNickname:
  38975. return m.OldNickname(ctx)
  38976. case wpchatroom.FieldOwner:
  38977. return m.OldOwner(ctx)
  38978. case wpchatroom.FieldAvatar:
  38979. return m.OldAvatar(ctx)
  38980. case wpchatroom.FieldMemberList:
  38981. return m.OldMemberList(ctx)
  38982. }
  38983. return nil, fmt.Errorf("unknown WpChatroom field %s", name)
  38984. }
  38985. // SetField sets the value of a field with the given name. It returns an error if
  38986. // the field is not defined in the schema, or if the type mismatched the field
  38987. // type.
  38988. func (m *WpChatroomMutation) SetField(name string, value ent.Value) error {
  38989. switch name {
  38990. case wpchatroom.FieldCreatedAt:
  38991. v, ok := value.(time.Time)
  38992. if !ok {
  38993. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38994. }
  38995. m.SetCreatedAt(v)
  38996. return nil
  38997. case wpchatroom.FieldUpdatedAt:
  38998. v, ok := value.(time.Time)
  38999. if !ok {
  39000. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39001. }
  39002. m.SetUpdatedAt(v)
  39003. return nil
  39004. case wpchatroom.FieldStatus:
  39005. v, ok := value.(uint8)
  39006. if !ok {
  39007. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39008. }
  39009. m.SetStatus(v)
  39010. return nil
  39011. case wpchatroom.FieldWxWxid:
  39012. v, ok := value.(string)
  39013. if !ok {
  39014. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39015. }
  39016. m.SetWxWxid(v)
  39017. return nil
  39018. case wpchatroom.FieldChatroomID:
  39019. v, ok := value.(string)
  39020. if !ok {
  39021. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39022. }
  39023. m.SetChatroomID(v)
  39024. return nil
  39025. case wpchatroom.FieldNickname:
  39026. v, ok := value.(string)
  39027. if !ok {
  39028. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39029. }
  39030. m.SetNickname(v)
  39031. return nil
  39032. case wpchatroom.FieldOwner:
  39033. v, ok := value.(string)
  39034. if !ok {
  39035. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39036. }
  39037. m.SetOwner(v)
  39038. return nil
  39039. case wpchatroom.FieldAvatar:
  39040. v, ok := value.(string)
  39041. if !ok {
  39042. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39043. }
  39044. m.SetAvatar(v)
  39045. return nil
  39046. case wpchatroom.FieldMemberList:
  39047. v, ok := value.([]string)
  39048. if !ok {
  39049. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39050. }
  39051. m.SetMemberList(v)
  39052. return nil
  39053. }
  39054. return fmt.Errorf("unknown WpChatroom field %s", name)
  39055. }
  39056. // AddedFields returns all numeric fields that were incremented/decremented during
  39057. // this mutation.
  39058. func (m *WpChatroomMutation) AddedFields() []string {
  39059. var fields []string
  39060. if m.addstatus != nil {
  39061. fields = append(fields, wpchatroom.FieldStatus)
  39062. }
  39063. return fields
  39064. }
  39065. // AddedField returns the numeric value that was incremented/decremented on a field
  39066. // with the given name. The second boolean return value indicates that this field
  39067. // was not set, or was not defined in the schema.
  39068. func (m *WpChatroomMutation) AddedField(name string) (ent.Value, bool) {
  39069. switch name {
  39070. case wpchatroom.FieldStatus:
  39071. return m.AddedStatus()
  39072. }
  39073. return nil, false
  39074. }
  39075. // AddField adds the value to the field with the given name. It returns an error if
  39076. // the field is not defined in the schema, or if the type mismatched the field
  39077. // type.
  39078. func (m *WpChatroomMutation) AddField(name string, value ent.Value) error {
  39079. switch name {
  39080. case wpchatroom.FieldStatus:
  39081. v, ok := value.(int8)
  39082. if !ok {
  39083. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39084. }
  39085. m.AddStatus(v)
  39086. return nil
  39087. }
  39088. return fmt.Errorf("unknown WpChatroom numeric field %s", name)
  39089. }
  39090. // ClearedFields returns all nullable fields that were cleared during this
  39091. // mutation.
  39092. func (m *WpChatroomMutation) ClearedFields() []string {
  39093. var fields []string
  39094. if m.FieldCleared(wpchatroom.FieldStatus) {
  39095. fields = append(fields, wpchatroom.FieldStatus)
  39096. }
  39097. return fields
  39098. }
  39099. // FieldCleared returns a boolean indicating if a field with the given name was
  39100. // cleared in this mutation.
  39101. func (m *WpChatroomMutation) FieldCleared(name string) bool {
  39102. _, ok := m.clearedFields[name]
  39103. return ok
  39104. }
  39105. // ClearField clears the value of the field with the given name. It returns an
  39106. // error if the field is not defined in the schema.
  39107. func (m *WpChatroomMutation) ClearField(name string) error {
  39108. switch name {
  39109. case wpchatroom.FieldStatus:
  39110. m.ClearStatus()
  39111. return nil
  39112. }
  39113. return fmt.Errorf("unknown WpChatroom nullable field %s", name)
  39114. }
  39115. // ResetField resets all changes in the mutation for the field with the given name.
  39116. // It returns an error if the field is not defined in the schema.
  39117. func (m *WpChatroomMutation) ResetField(name string) error {
  39118. switch name {
  39119. case wpchatroom.FieldCreatedAt:
  39120. m.ResetCreatedAt()
  39121. return nil
  39122. case wpchatroom.FieldUpdatedAt:
  39123. m.ResetUpdatedAt()
  39124. return nil
  39125. case wpchatroom.FieldStatus:
  39126. m.ResetStatus()
  39127. return nil
  39128. case wpchatroom.FieldWxWxid:
  39129. m.ResetWxWxid()
  39130. return nil
  39131. case wpchatroom.FieldChatroomID:
  39132. m.ResetChatroomID()
  39133. return nil
  39134. case wpchatroom.FieldNickname:
  39135. m.ResetNickname()
  39136. return nil
  39137. case wpchatroom.FieldOwner:
  39138. m.ResetOwner()
  39139. return nil
  39140. case wpchatroom.FieldAvatar:
  39141. m.ResetAvatar()
  39142. return nil
  39143. case wpchatroom.FieldMemberList:
  39144. m.ResetMemberList()
  39145. return nil
  39146. }
  39147. return fmt.Errorf("unknown WpChatroom field %s", name)
  39148. }
  39149. // AddedEdges returns all edge names that were set/added in this mutation.
  39150. func (m *WpChatroomMutation) AddedEdges() []string {
  39151. edges := make([]string, 0, 0)
  39152. return edges
  39153. }
  39154. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  39155. // name in this mutation.
  39156. func (m *WpChatroomMutation) AddedIDs(name string) []ent.Value {
  39157. return nil
  39158. }
  39159. // RemovedEdges returns all edge names that were removed in this mutation.
  39160. func (m *WpChatroomMutation) RemovedEdges() []string {
  39161. edges := make([]string, 0, 0)
  39162. return edges
  39163. }
  39164. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  39165. // the given name in this mutation.
  39166. func (m *WpChatroomMutation) RemovedIDs(name string) []ent.Value {
  39167. return nil
  39168. }
  39169. // ClearedEdges returns all edge names that were cleared in this mutation.
  39170. func (m *WpChatroomMutation) ClearedEdges() []string {
  39171. edges := make([]string, 0, 0)
  39172. return edges
  39173. }
  39174. // EdgeCleared returns a boolean which indicates if the edge with the given name
  39175. // was cleared in this mutation.
  39176. func (m *WpChatroomMutation) EdgeCleared(name string) bool {
  39177. return false
  39178. }
  39179. // ClearEdge clears the value of the edge with the given name. It returns an error
  39180. // if that edge is not defined in the schema.
  39181. func (m *WpChatroomMutation) ClearEdge(name string) error {
  39182. return fmt.Errorf("unknown WpChatroom unique edge %s", name)
  39183. }
  39184. // ResetEdge resets all changes to the edge with the given name in this mutation.
  39185. // It returns an error if the edge is not defined in the schema.
  39186. func (m *WpChatroomMutation) ResetEdge(name string) error {
  39187. return fmt.Errorf("unknown WpChatroom edge %s", name)
  39188. }
  39189. // WpChatroomMemberMutation represents an operation that mutates the WpChatroomMember nodes in the graph.
  39190. type WpChatroomMemberMutation struct {
  39191. config
  39192. op Op
  39193. typ string
  39194. id *uint64
  39195. created_at *time.Time
  39196. updated_at *time.Time
  39197. status *uint8
  39198. addstatus *int8
  39199. wx_wxid *string
  39200. wxid *string
  39201. nickname *string
  39202. avatar *string
  39203. clearedFields map[string]struct{}
  39204. done bool
  39205. oldValue func(context.Context) (*WpChatroomMember, error)
  39206. predicates []predicate.WpChatroomMember
  39207. }
  39208. var _ ent.Mutation = (*WpChatroomMemberMutation)(nil)
  39209. // wpchatroommemberOption allows management of the mutation configuration using functional options.
  39210. type wpchatroommemberOption func(*WpChatroomMemberMutation)
  39211. // newWpChatroomMemberMutation creates new mutation for the WpChatroomMember entity.
  39212. func newWpChatroomMemberMutation(c config, op Op, opts ...wpchatroommemberOption) *WpChatroomMemberMutation {
  39213. m := &WpChatroomMemberMutation{
  39214. config: c,
  39215. op: op,
  39216. typ: TypeWpChatroomMember,
  39217. clearedFields: make(map[string]struct{}),
  39218. }
  39219. for _, opt := range opts {
  39220. opt(m)
  39221. }
  39222. return m
  39223. }
  39224. // withWpChatroomMemberID sets the ID field of the mutation.
  39225. func withWpChatroomMemberID(id uint64) wpchatroommemberOption {
  39226. return func(m *WpChatroomMemberMutation) {
  39227. var (
  39228. err error
  39229. once sync.Once
  39230. value *WpChatroomMember
  39231. )
  39232. m.oldValue = func(ctx context.Context) (*WpChatroomMember, error) {
  39233. once.Do(func() {
  39234. if m.done {
  39235. err = errors.New("querying old values post mutation is not allowed")
  39236. } else {
  39237. value, err = m.Client().WpChatroomMember.Get(ctx, id)
  39238. }
  39239. })
  39240. return value, err
  39241. }
  39242. m.id = &id
  39243. }
  39244. }
  39245. // withWpChatroomMember sets the old WpChatroomMember of the mutation.
  39246. func withWpChatroomMember(node *WpChatroomMember) wpchatroommemberOption {
  39247. return func(m *WpChatroomMemberMutation) {
  39248. m.oldValue = func(context.Context) (*WpChatroomMember, error) {
  39249. return node, nil
  39250. }
  39251. m.id = &node.ID
  39252. }
  39253. }
  39254. // Client returns a new `ent.Client` from the mutation. If the mutation was
  39255. // executed in a transaction (ent.Tx), a transactional client is returned.
  39256. func (m WpChatroomMemberMutation) Client() *Client {
  39257. client := &Client{config: m.config}
  39258. client.init()
  39259. return client
  39260. }
  39261. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  39262. // it returns an error otherwise.
  39263. func (m WpChatroomMemberMutation) Tx() (*Tx, error) {
  39264. if _, ok := m.driver.(*txDriver); !ok {
  39265. return nil, errors.New("ent: mutation is not running in a transaction")
  39266. }
  39267. tx := &Tx{config: m.config}
  39268. tx.init()
  39269. return tx, nil
  39270. }
  39271. // SetID sets the value of the id field. Note that this
  39272. // operation is only accepted on creation of WpChatroomMember entities.
  39273. func (m *WpChatroomMemberMutation) SetID(id uint64) {
  39274. m.id = &id
  39275. }
  39276. // ID returns the ID value in the mutation. Note that the ID is only available
  39277. // if it was provided to the builder or after it was returned from the database.
  39278. func (m *WpChatroomMemberMutation) ID() (id uint64, exists bool) {
  39279. if m.id == nil {
  39280. return
  39281. }
  39282. return *m.id, true
  39283. }
  39284. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  39285. // That means, if the mutation is applied within a transaction with an isolation level such
  39286. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  39287. // or updated by the mutation.
  39288. func (m *WpChatroomMemberMutation) IDs(ctx context.Context) ([]uint64, error) {
  39289. switch {
  39290. case m.op.Is(OpUpdateOne | OpDeleteOne):
  39291. id, exists := m.ID()
  39292. if exists {
  39293. return []uint64{id}, nil
  39294. }
  39295. fallthrough
  39296. case m.op.Is(OpUpdate | OpDelete):
  39297. return m.Client().WpChatroomMember.Query().Where(m.predicates...).IDs(ctx)
  39298. default:
  39299. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  39300. }
  39301. }
  39302. // SetCreatedAt sets the "created_at" field.
  39303. func (m *WpChatroomMemberMutation) SetCreatedAt(t time.Time) {
  39304. m.created_at = &t
  39305. }
  39306. // CreatedAt returns the value of the "created_at" field in the mutation.
  39307. func (m *WpChatroomMemberMutation) CreatedAt() (r time.Time, exists bool) {
  39308. v := m.created_at
  39309. if v == nil {
  39310. return
  39311. }
  39312. return *v, true
  39313. }
  39314. // OldCreatedAt returns the old "created_at" field's value of the WpChatroomMember entity.
  39315. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  39316. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39317. func (m *WpChatroomMemberMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  39318. if !m.op.Is(OpUpdateOne) {
  39319. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  39320. }
  39321. if m.id == nil || m.oldValue == nil {
  39322. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  39323. }
  39324. oldValue, err := m.oldValue(ctx)
  39325. if err != nil {
  39326. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  39327. }
  39328. return oldValue.CreatedAt, nil
  39329. }
  39330. // ResetCreatedAt resets all changes to the "created_at" field.
  39331. func (m *WpChatroomMemberMutation) ResetCreatedAt() {
  39332. m.created_at = nil
  39333. }
  39334. // SetUpdatedAt sets the "updated_at" field.
  39335. func (m *WpChatroomMemberMutation) SetUpdatedAt(t time.Time) {
  39336. m.updated_at = &t
  39337. }
  39338. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  39339. func (m *WpChatroomMemberMutation) UpdatedAt() (r time.Time, exists bool) {
  39340. v := m.updated_at
  39341. if v == nil {
  39342. return
  39343. }
  39344. return *v, true
  39345. }
  39346. // OldUpdatedAt returns the old "updated_at" field's value of the WpChatroomMember entity.
  39347. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  39348. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39349. func (m *WpChatroomMemberMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  39350. if !m.op.Is(OpUpdateOne) {
  39351. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  39352. }
  39353. if m.id == nil || m.oldValue == nil {
  39354. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  39355. }
  39356. oldValue, err := m.oldValue(ctx)
  39357. if err != nil {
  39358. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  39359. }
  39360. return oldValue.UpdatedAt, nil
  39361. }
  39362. // ResetUpdatedAt resets all changes to the "updated_at" field.
  39363. func (m *WpChatroomMemberMutation) ResetUpdatedAt() {
  39364. m.updated_at = nil
  39365. }
  39366. // SetStatus sets the "status" field.
  39367. func (m *WpChatroomMemberMutation) SetStatus(u uint8) {
  39368. m.status = &u
  39369. m.addstatus = nil
  39370. }
  39371. // Status returns the value of the "status" field in the mutation.
  39372. func (m *WpChatroomMemberMutation) Status() (r uint8, exists bool) {
  39373. v := m.status
  39374. if v == nil {
  39375. return
  39376. }
  39377. return *v, true
  39378. }
  39379. // OldStatus returns the old "status" field's value of the WpChatroomMember entity.
  39380. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  39381. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39382. func (m *WpChatroomMemberMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  39383. if !m.op.Is(OpUpdateOne) {
  39384. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  39385. }
  39386. if m.id == nil || m.oldValue == nil {
  39387. return v, errors.New("OldStatus requires an ID field in the mutation")
  39388. }
  39389. oldValue, err := m.oldValue(ctx)
  39390. if err != nil {
  39391. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  39392. }
  39393. return oldValue.Status, nil
  39394. }
  39395. // AddStatus adds u to the "status" field.
  39396. func (m *WpChatroomMemberMutation) AddStatus(u int8) {
  39397. if m.addstatus != nil {
  39398. *m.addstatus += u
  39399. } else {
  39400. m.addstatus = &u
  39401. }
  39402. }
  39403. // AddedStatus returns the value that was added to the "status" field in this mutation.
  39404. func (m *WpChatroomMemberMutation) AddedStatus() (r int8, exists bool) {
  39405. v := m.addstatus
  39406. if v == nil {
  39407. return
  39408. }
  39409. return *v, true
  39410. }
  39411. // ClearStatus clears the value of the "status" field.
  39412. func (m *WpChatroomMemberMutation) ClearStatus() {
  39413. m.status = nil
  39414. m.addstatus = nil
  39415. m.clearedFields[wpchatroommember.FieldStatus] = struct{}{}
  39416. }
  39417. // StatusCleared returns if the "status" field was cleared in this mutation.
  39418. func (m *WpChatroomMemberMutation) StatusCleared() bool {
  39419. _, ok := m.clearedFields[wpchatroommember.FieldStatus]
  39420. return ok
  39421. }
  39422. // ResetStatus resets all changes to the "status" field.
  39423. func (m *WpChatroomMemberMutation) ResetStatus() {
  39424. m.status = nil
  39425. m.addstatus = nil
  39426. delete(m.clearedFields, wpchatroommember.FieldStatus)
  39427. }
  39428. // SetWxWxid sets the "wx_wxid" field.
  39429. func (m *WpChatroomMemberMutation) SetWxWxid(s string) {
  39430. m.wx_wxid = &s
  39431. }
  39432. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  39433. func (m *WpChatroomMemberMutation) WxWxid() (r string, exists bool) {
  39434. v := m.wx_wxid
  39435. if v == nil {
  39436. return
  39437. }
  39438. return *v, true
  39439. }
  39440. // OldWxWxid returns the old "wx_wxid" field's value of the WpChatroomMember entity.
  39441. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  39442. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39443. func (m *WpChatroomMemberMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  39444. if !m.op.Is(OpUpdateOne) {
  39445. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  39446. }
  39447. if m.id == nil || m.oldValue == nil {
  39448. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  39449. }
  39450. oldValue, err := m.oldValue(ctx)
  39451. if err != nil {
  39452. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  39453. }
  39454. return oldValue.WxWxid, nil
  39455. }
  39456. // ResetWxWxid resets all changes to the "wx_wxid" field.
  39457. func (m *WpChatroomMemberMutation) ResetWxWxid() {
  39458. m.wx_wxid = nil
  39459. }
  39460. // SetWxid sets the "wxid" field.
  39461. func (m *WpChatroomMemberMutation) SetWxid(s string) {
  39462. m.wxid = &s
  39463. }
  39464. // Wxid returns the value of the "wxid" field in the mutation.
  39465. func (m *WpChatroomMemberMutation) Wxid() (r string, exists bool) {
  39466. v := m.wxid
  39467. if v == nil {
  39468. return
  39469. }
  39470. return *v, true
  39471. }
  39472. // OldWxid returns the old "wxid" field's value of the WpChatroomMember entity.
  39473. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  39474. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39475. func (m *WpChatroomMemberMutation) OldWxid(ctx context.Context) (v string, err error) {
  39476. if !m.op.Is(OpUpdateOne) {
  39477. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  39478. }
  39479. if m.id == nil || m.oldValue == nil {
  39480. return v, errors.New("OldWxid requires an ID field in the mutation")
  39481. }
  39482. oldValue, err := m.oldValue(ctx)
  39483. if err != nil {
  39484. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  39485. }
  39486. return oldValue.Wxid, nil
  39487. }
  39488. // ResetWxid resets all changes to the "wxid" field.
  39489. func (m *WpChatroomMemberMutation) ResetWxid() {
  39490. m.wxid = nil
  39491. }
  39492. // SetNickname sets the "nickname" field.
  39493. func (m *WpChatroomMemberMutation) SetNickname(s string) {
  39494. m.nickname = &s
  39495. }
  39496. // Nickname returns the value of the "nickname" field in the mutation.
  39497. func (m *WpChatroomMemberMutation) Nickname() (r string, exists bool) {
  39498. v := m.nickname
  39499. if v == nil {
  39500. return
  39501. }
  39502. return *v, true
  39503. }
  39504. // OldNickname returns the old "nickname" field's value of the WpChatroomMember entity.
  39505. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  39506. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39507. func (m *WpChatroomMemberMutation) OldNickname(ctx context.Context) (v string, err error) {
  39508. if !m.op.Is(OpUpdateOne) {
  39509. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  39510. }
  39511. if m.id == nil || m.oldValue == nil {
  39512. return v, errors.New("OldNickname requires an ID field in the mutation")
  39513. }
  39514. oldValue, err := m.oldValue(ctx)
  39515. if err != nil {
  39516. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  39517. }
  39518. return oldValue.Nickname, nil
  39519. }
  39520. // ResetNickname resets all changes to the "nickname" field.
  39521. func (m *WpChatroomMemberMutation) ResetNickname() {
  39522. m.nickname = nil
  39523. }
  39524. // SetAvatar sets the "avatar" field.
  39525. func (m *WpChatroomMemberMutation) SetAvatar(s string) {
  39526. m.avatar = &s
  39527. }
  39528. // Avatar returns the value of the "avatar" field in the mutation.
  39529. func (m *WpChatroomMemberMutation) Avatar() (r string, exists bool) {
  39530. v := m.avatar
  39531. if v == nil {
  39532. return
  39533. }
  39534. return *v, true
  39535. }
  39536. // OldAvatar returns the old "avatar" field's value of the WpChatroomMember entity.
  39537. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  39538. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39539. func (m *WpChatroomMemberMutation) OldAvatar(ctx context.Context) (v string, err error) {
  39540. if !m.op.Is(OpUpdateOne) {
  39541. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  39542. }
  39543. if m.id == nil || m.oldValue == nil {
  39544. return v, errors.New("OldAvatar requires an ID field in the mutation")
  39545. }
  39546. oldValue, err := m.oldValue(ctx)
  39547. if err != nil {
  39548. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  39549. }
  39550. return oldValue.Avatar, nil
  39551. }
  39552. // ResetAvatar resets all changes to the "avatar" field.
  39553. func (m *WpChatroomMemberMutation) ResetAvatar() {
  39554. m.avatar = nil
  39555. }
  39556. // Where appends a list predicates to the WpChatroomMemberMutation builder.
  39557. func (m *WpChatroomMemberMutation) Where(ps ...predicate.WpChatroomMember) {
  39558. m.predicates = append(m.predicates, ps...)
  39559. }
  39560. // WhereP appends storage-level predicates to the WpChatroomMemberMutation builder. Using this method,
  39561. // users can use type-assertion to append predicates that do not depend on any generated package.
  39562. func (m *WpChatroomMemberMutation) WhereP(ps ...func(*sql.Selector)) {
  39563. p := make([]predicate.WpChatroomMember, len(ps))
  39564. for i := range ps {
  39565. p[i] = ps[i]
  39566. }
  39567. m.Where(p...)
  39568. }
  39569. // Op returns the operation name.
  39570. func (m *WpChatroomMemberMutation) Op() Op {
  39571. return m.op
  39572. }
  39573. // SetOp allows setting the mutation operation.
  39574. func (m *WpChatroomMemberMutation) SetOp(op Op) {
  39575. m.op = op
  39576. }
  39577. // Type returns the node type of this mutation (WpChatroomMember).
  39578. func (m *WpChatroomMemberMutation) Type() string {
  39579. return m.typ
  39580. }
  39581. // Fields returns all fields that were changed during this mutation. Note that in
  39582. // order to get all numeric fields that were incremented/decremented, call
  39583. // AddedFields().
  39584. func (m *WpChatroomMemberMutation) Fields() []string {
  39585. fields := make([]string, 0, 7)
  39586. if m.created_at != nil {
  39587. fields = append(fields, wpchatroommember.FieldCreatedAt)
  39588. }
  39589. if m.updated_at != nil {
  39590. fields = append(fields, wpchatroommember.FieldUpdatedAt)
  39591. }
  39592. if m.status != nil {
  39593. fields = append(fields, wpchatroommember.FieldStatus)
  39594. }
  39595. if m.wx_wxid != nil {
  39596. fields = append(fields, wpchatroommember.FieldWxWxid)
  39597. }
  39598. if m.wxid != nil {
  39599. fields = append(fields, wpchatroommember.FieldWxid)
  39600. }
  39601. if m.nickname != nil {
  39602. fields = append(fields, wpchatroommember.FieldNickname)
  39603. }
  39604. if m.avatar != nil {
  39605. fields = append(fields, wpchatroommember.FieldAvatar)
  39606. }
  39607. return fields
  39608. }
  39609. // Field returns the value of a field with the given name. The second boolean
  39610. // return value indicates that this field was not set, or was not defined in the
  39611. // schema.
  39612. func (m *WpChatroomMemberMutation) Field(name string) (ent.Value, bool) {
  39613. switch name {
  39614. case wpchatroommember.FieldCreatedAt:
  39615. return m.CreatedAt()
  39616. case wpchatroommember.FieldUpdatedAt:
  39617. return m.UpdatedAt()
  39618. case wpchatroommember.FieldStatus:
  39619. return m.Status()
  39620. case wpchatroommember.FieldWxWxid:
  39621. return m.WxWxid()
  39622. case wpchatroommember.FieldWxid:
  39623. return m.Wxid()
  39624. case wpchatroommember.FieldNickname:
  39625. return m.Nickname()
  39626. case wpchatroommember.FieldAvatar:
  39627. return m.Avatar()
  39628. }
  39629. return nil, false
  39630. }
  39631. // OldField returns the old value of the field from the database. An error is
  39632. // returned if the mutation operation is not UpdateOne, or the query to the
  39633. // database failed.
  39634. func (m *WpChatroomMemberMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  39635. switch name {
  39636. case wpchatroommember.FieldCreatedAt:
  39637. return m.OldCreatedAt(ctx)
  39638. case wpchatroommember.FieldUpdatedAt:
  39639. return m.OldUpdatedAt(ctx)
  39640. case wpchatroommember.FieldStatus:
  39641. return m.OldStatus(ctx)
  39642. case wpchatroommember.FieldWxWxid:
  39643. return m.OldWxWxid(ctx)
  39644. case wpchatroommember.FieldWxid:
  39645. return m.OldWxid(ctx)
  39646. case wpchatroommember.FieldNickname:
  39647. return m.OldNickname(ctx)
  39648. case wpchatroommember.FieldAvatar:
  39649. return m.OldAvatar(ctx)
  39650. }
  39651. return nil, fmt.Errorf("unknown WpChatroomMember field %s", name)
  39652. }
  39653. // SetField sets the value of a field with the given name. It returns an error if
  39654. // the field is not defined in the schema, or if the type mismatched the field
  39655. // type.
  39656. func (m *WpChatroomMemberMutation) SetField(name string, value ent.Value) error {
  39657. switch name {
  39658. case wpchatroommember.FieldCreatedAt:
  39659. v, ok := value.(time.Time)
  39660. if !ok {
  39661. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39662. }
  39663. m.SetCreatedAt(v)
  39664. return nil
  39665. case wpchatroommember.FieldUpdatedAt:
  39666. v, ok := value.(time.Time)
  39667. if !ok {
  39668. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39669. }
  39670. m.SetUpdatedAt(v)
  39671. return nil
  39672. case wpchatroommember.FieldStatus:
  39673. v, ok := value.(uint8)
  39674. if !ok {
  39675. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39676. }
  39677. m.SetStatus(v)
  39678. return nil
  39679. case wpchatroommember.FieldWxWxid:
  39680. v, ok := value.(string)
  39681. if !ok {
  39682. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39683. }
  39684. m.SetWxWxid(v)
  39685. return nil
  39686. case wpchatroommember.FieldWxid:
  39687. v, ok := value.(string)
  39688. if !ok {
  39689. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39690. }
  39691. m.SetWxid(v)
  39692. return nil
  39693. case wpchatroommember.FieldNickname:
  39694. v, ok := value.(string)
  39695. if !ok {
  39696. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39697. }
  39698. m.SetNickname(v)
  39699. return nil
  39700. case wpchatroommember.FieldAvatar:
  39701. v, ok := value.(string)
  39702. if !ok {
  39703. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39704. }
  39705. m.SetAvatar(v)
  39706. return nil
  39707. }
  39708. return fmt.Errorf("unknown WpChatroomMember field %s", name)
  39709. }
  39710. // AddedFields returns all numeric fields that were incremented/decremented during
  39711. // this mutation.
  39712. func (m *WpChatroomMemberMutation) AddedFields() []string {
  39713. var fields []string
  39714. if m.addstatus != nil {
  39715. fields = append(fields, wpchatroommember.FieldStatus)
  39716. }
  39717. return fields
  39718. }
  39719. // AddedField returns the numeric value that was incremented/decremented on a field
  39720. // with the given name. The second boolean return value indicates that this field
  39721. // was not set, or was not defined in the schema.
  39722. func (m *WpChatroomMemberMutation) AddedField(name string) (ent.Value, bool) {
  39723. switch name {
  39724. case wpchatroommember.FieldStatus:
  39725. return m.AddedStatus()
  39726. }
  39727. return nil, false
  39728. }
  39729. // AddField adds the value to the field with the given name. It returns an error if
  39730. // the field is not defined in the schema, or if the type mismatched the field
  39731. // type.
  39732. func (m *WpChatroomMemberMutation) AddField(name string, value ent.Value) error {
  39733. switch name {
  39734. case wpchatroommember.FieldStatus:
  39735. v, ok := value.(int8)
  39736. if !ok {
  39737. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39738. }
  39739. m.AddStatus(v)
  39740. return nil
  39741. }
  39742. return fmt.Errorf("unknown WpChatroomMember numeric field %s", name)
  39743. }
  39744. // ClearedFields returns all nullable fields that were cleared during this
  39745. // mutation.
  39746. func (m *WpChatroomMemberMutation) ClearedFields() []string {
  39747. var fields []string
  39748. if m.FieldCleared(wpchatroommember.FieldStatus) {
  39749. fields = append(fields, wpchatroommember.FieldStatus)
  39750. }
  39751. return fields
  39752. }
  39753. // FieldCleared returns a boolean indicating if a field with the given name was
  39754. // cleared in this mutation.
  39755. func (m *WpChatroomMemberMutation) FieldCleared(name string) bool {
  39756. _, ok := m.clearedFields[name]
  39757. return ok
  39758. }
  39759. // ClearField clears the value of the field with the given name. It returns an
  39760. // error if the field is not defined in the schema.
  39761. func (m *WpChatroomMemberMutation) ClearField(name string) error {
  39762. switch name {
  39763. case wpchatroommember.FieldStatus:
  39764. m.ClearStatus()
  39765. return nil
  39766. }
  39767. return fmt.Errorf("unknown WpChatroomMember nullable field %s", name)
  39768. }
  39769. // ResetField resets all changes in the mutation for the field with the given name.
  39770. // It returns an error if the field is not defined in the schema.
  39771. func (m *WpChatroomMemberMutation) ResetField(name string) error {
  39772. switch name {
  39773. case wpchatroommember.FieldCreatedAt:
  39774. m.ResetCreatedAt()
  39775. return nil
  39776. case wpchatroommember.FieldUpdatedAt:
  39777. m.ResetUpdatedAt()
  39778. return nil
  39779. case wpchatroommember.FieldStatus:
  39780. m.ResetStatus()
  39781. return nil
  39782. case wpchatroommember.FieldWxWxid:
  39783. m.ResetWxWxid()
  39784. return nil
  39785. case wpchatroommember.FieldWxid:
  39786. m.ResetWxid()
  39787. return nil
  39788. case wpchatroommember.FieldNickname:
  39789. m.ResetNickname()
  39790. return nil
  39791. case wpchatroommember.FieldAvatar:
  39792. m.ResetAvatar()
  39793. return nil
  39794. }
  39795. return fmt.Errorf("unknown WpChatroomMember field %s", name)
  39796. }
  39797. // AddedEdges returns all edge names that were set/added in this mutation.
  39798. func (m *WpChatroomMemberMutation) AddedEdges() []string {
  39799. edges := make([]string, 0, 0)
  39800. return edges
  39801. }
  39802. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  39803. // name in this mutation.
  39804. func (m *WpChatroomMemberMutation) AddedIDs(name string) []ent.Value {
  39805. return nil
  39806. }
  39807. // RemovedEdges returns all edge names that were removed in this mutation.
  39808. func (m *WpChatroomMemberMutation) RemovedEdges() []string {
  39809. edges := make([]string, 0, 0)
  39810. return edges
  39811. }
  39812. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  39813. // the given name in this mutation.
  39814. func (m *WpChatroomMemberMutation) RemovedIDs(name string) []ent.Value {
  39815. return nil
  39816. }
  39817. // ClearedEdges returns all edge names that were cleared in this mutation.
  39818. func (m *WpChatroomMemberMutation) ClearedEdges() []string {
  39819. edges := make([]string, 0, 0)
  39820. return edges
  39821. }
  39822. // EdgeCleared returns a boolean which indicates if the edge with the given name
  39823. // was cleared in this mutation.
  39824. func (m *WpChatroomMemberMutation) EdgeCleared(name string) bool {
  39825. return false
  39826. }
  39827. // ClearEdge clears the value of the edge with the given name. It returns an error
  39828. // if that edge is not defined in the schema.
  39829. func (m *WpChatroomMemberMutation) ClearEdge(name string) error {
  39830. return fmt.Errorf("unknown WpChatroomMember unique edge %s", name)
  39831. }
  39832. // ResetEdge resets all changes to the edge with the given name in this mutation.
  39833. // It returns an error if the edge is not defined in the schema.
  39834. func (m *WpChatroomMemberMutation) ResetEdge(name string) error {
  39835. return fmt.Errorf("unknown WpChatroomMember edge %s", name)
  39836. }
  39837. // WxMutation represents an operation that mutates the Wx nodes in the graph.
  39838. type WxMutation struct {
  39839. config
  39840. op Op
  39841. typ string
  39842. id *uint64
  39843. created_at *time.Time
  39844. updated_at *time.Time
  39845. status *uint8
  39846. addstatus *int8
  39847. deleted_at *time.Time
  39848. port *string
  39849. process_id *string
  39850. callback *string
  39851. wxid *string
  39852. account *string
  39853. nickname *string
  39854. tel *string
  39855. head_big *string
  39856. organization_id *uint64
  39857. addorganization_id *int64
  39858. api_base *string
  39859. api_key *string
  39860. allow_list *[]string
  39861. appendallow_list []string
  39862. group_allow_list *[]string
  39863. appendgroup_allow_list []string
  39864. block_list *[]string
  39865. appendblock_list []string
  39866. group_block_list *[]string
  39867. appendgroup_block_list []string
  39868. clearedFields map[string]struct{}
  39869. server *uint64
  39870. clearedserver bool
  39871. agent *uint64
  39872. clearedagent bool
  39873. done bool
  39874. oldValue func(context.Context) (*Wx, error)
  39875. predicates []predicate.Wx
  39876. }
  39877. var _ ent.Mutation = (*WxMutation)(nil)
  39878. // wxOption allows management of the mutation configuration using functional options.
  39879. type wxOption func(*WxMutation)
  39880. // newWxMutation creates new mutation for the Wx entity.
  39881. func newWxMutation(c config, op Op, opts ...wxOption) *WxMutation {
  39882. m := &WxMutation{
  39883. config: c,
  39884. op: op,
  39885. typ: TypeWx,
  39886. clearedFields: make(map[string]struct{}),
  39887. }
  39888. for _, opt := range opts {
  39889. opt(m)
  39890. }
  39891. return m
  39892. }
  39893. // withWxID sets the ID field of the mutation.
  39894. func withWxID(id uint64) wxOption {
  39895. return func(m *WxMutation) {
  39896. var (
  39897. err error
  39898. once sync.Once
  39899. value *Wx
  39900. )
  39901. m.oldValue = func(ctx context.Context) (*Wx, error) {
  39902. once.Do(func() {
  39903. if m.done {
  39904. err = errors.New("querying old values post mutation is not allowed")
  39905. } else {
  39906. value, err = m.Client().Wx.Get(ctx, id)
  39907. }
  39908. })
  39909. return value, err
  39910. }
  39911. m.id = &id
  39912. }
  39913. }
  39914. // withWx sets the old Wx of the mutation.
  39915. func withWx(node *Wx) wxOption {
  39916. return func(m *WxMutation) {
  39917. m.oldValue = func(context.Context) (*Wx, error) {
  39918. return node, nil
  39919. }
  39920. m.id = &node.ID
  39921. }
  39922. }
  39923. // Client returns a new `ent.Client` from the mutation. If the mutation was
  39924. // executed in a transaction (ent.Tx), a transactional client is returned.
  39925. func (m WxMutation) Client() *Client {
  39926. client := &Client{config: m.config}
  39927. client.init()
  39928. return client
  39929. }
  39930. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  39931. // it returns an error otherwise.
  39932. func (m WxMutation) Tx() (*Tx, error) {
  39933. if _, ok := m.driver.(*txDriver); !ok {
  39934. return nil, errors.New("ent: mutation is not running in a transaction")
  39935. }
  39936. tx := &Tx{config: m.config}
  39937. tx.init()
  39938. return tx, nil
  39939. }
  39940. // SetID sets the value of the id field. Note that this
  39941. // operation is only accepted on creation of Wx entities.
  39942. func (m *WxMutation) SetID(id uint64) {
  39943. m.id = &id
  39944. }
  39945. // ID returns the ID value in the mutation. Note that the ID is only available
  39946. // if it was provided to the builder or after it was returned from the database.
  39947. func (m *WxMutation) ID() (id uint64, exists bool) {
  39948. if m.id == nil {
  39949. return
  39950. }
  39951. return *m.id, true
  39952. }
  39953. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  39954. // That means, if the mutation is applied within a transaction with an isolation level such
  39955. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  39956. // or updated by the mutation.
  39957. func (m *WxMutation) IDs(ctx context.Context) ([]uint64, error) {
  39958. switch {
  39959. case m.op.Is(OpUpdateOne | OpDeleteOne):
  39960. id, exists := m.ID()
  39961. if exists {
  39962. return []uint64{id}, nil
  39963. }
  39964. fallthrough
  39965. case m.op.Is(OpUpdate | OpDelete):
  39966. return m.Client().Wx.Query().Where(m.predicates...).IDs(ctx)
  39967. default:
  39968. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  39969. }
  39970. }
  39971. // SetCreatedAt sets the "created_at" field.
  39972. func (m *WxMutation) SetCreatedAt(t time.Time) {
  39973. m.created_at = &t
  39974. }
  39975. // CreatedAt returns the value of the "created_at" field in the mutation.
  39976. func (m *WxMutation) CreatedAt() (r time.Time, exists bool) {
  39977. v := m.created_at
  39978. if v == nil {
  39979. return
  39980. }
  39981. return *v, true
  39982. }
  39983. // OldCreatedAt returns the old "created_at" field's value of the Wx entity.
  39984. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  39985. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39986. func (m *WxMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  39987. if !m.op.Is(OpUpdateOne) {
  39988. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  39989. }
  39990. if m.id == nil || m.oldValue == nil {
  39991. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  39992. }
  39993. oldValue, err := m.oldValue(ctx)
  39994. if err != nil {
  39995. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  39996. }
  39997. return oldValue.CreatedAt, nil
  39998. }
  39999. // ResetCreatedAt resets all changes to the "created_at" field.
  40000. func (m *WxMutation) ResetCreatedAt() {
  40001. m.created_at = nil
  40002. }
  40003. // SetUpdatedAt sets the "updated_at" field.
  40004. func (m *WxMutation) SetUpdatedAt(t time.Time) {
  40005. m.updated_at = &t
  40006. }
  40007. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  40008. func (m *WxMutation) UpdatedAt() (r time.Time, exists bool) {
  40009. v := m.updated_at
  40010. if v == nil {
  40011. return
  40012. }
  40013. return *v, true
  40014. }
  40015. // OldUpdatedAt returns the old "updated_at" field's value of the Wx entity.
  40016. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40017. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40018. func (m *WxMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  40019. if !m.op.Is(OpUpdateOne) {
  40020. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  40021. }
  40022. if m.id == nil || m.oldValue == nil {
  40023. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  40024. }
  40025. oldValue, err := m.oldValue(ctx)
  40026. if err != nil {
  40027. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  40028. }
  40029. return oldValue.UpdatedAt, nil
  40030. }
  40031. // ResetUpdatedAt resets all changes to the "updated_at" field.
  40032. func (m *WxMutation) ResetUpdatedAt() {
  40033. m.updated_at = nil
  40034. }
  40035. // SetStatus sets the "status" field.
  40036. func (m *WxMutation) SetStatus(u uint8) {
  40037. m.status = &u
  40038. m.addstatus = nil
  40039. }
  40040. // Status returns the value of the "status" field in the mutation.
  40041. func (m *WxMutation) Status() (r uint8, exists bool) {
  40042. v := m.status
  40043. if v == nil {
  40044. return
  40045. }
  40046. return *v, true
  40047. }
  40048. // OldStatus returns the old "status" field's value of the Wx entity.
  40049. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40050. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40051. func (m *WxMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  40052. if !m.op.Is(OpUpdateOne) {
  40053. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  40054. }
  40055. if m.id == nil || m.oldValue == nil {
  40056. return v, errors.New("OldStatus requires an ID field in the mutation")
  40057. }
  40058. oldValue, err := m.oldValue(ctx)
  40059. if err != nil {
  40060. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  40061. }
  40062. return oldValue.Status, nil
  40063. }
  40064. // AddStatus adds u to the "status" field.
  40065. func (m *WxMutation) AddStatus(u int8) {
  40066. if m.addstatus != nil {
  40067. *m.addstatus += u
  40068. } else {
  40069. m.addstatus = &u
  40070. }
  40071. }
  40072. // AddedStatus returns the value that was added to the "status" field in this mutation.
  40073. func (m *WxMutation) AddedStatus() (r int8, exists bool) {
  40074. v := m.addstatus
  40075. if v == nil {
  40076. return
  40077. }
  40078. return *v, true
  40079. }
  40080. // ClearStatus clears the value of the "status" field.
  40081. func (m *WxMutation) ClearStatus() {
  40082. m.status = nil
  40083. m.addstatus = nil
  40084. m.clearedFields[wx.FieldStatus] = struct{}{}
  40085. }
  40086. // StatusCleared returns if the "status" field was cleared in this mutation.
  40087. func (m *WxMutation) StatusCleared() bool {
  40088. _, ok := m.clearedFields[wx.FieldStatus]
  40089. return ok
  40090. }
  40091. // ResetStatus resets all changes to the "status" field.
  40092. func (m *WxMutation) ResetStatus() {
  40093. m.status = nil
  40094. m.addstatus = nil
  40095. delete(m.clearedFields, wx.FieldStatus)
  40096. }
  40097. // SetDeletedAt sets the "deleted_at" field.
  40098. func (m *WxMutation) SetDeletedAt(t time.Time) {
  40099. m.deleted_at = &t
  40100. }
  40101. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  40102. func (m *WxMutation) DeletedAt() (r time.Time, exists bool) {
  40103. v := m.deleted_at
  40104. if v == nil {
  40105. return
  40106. }
  40107. return *v, true
  40108. }
  40109. // OldDeletedAt returns the old "deleted_at" field's value of the Wx entity.
  40110. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40111. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40112. func (m *WxMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  40113. if !m.op.Is(OpUpdateOne) {
  40114. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  40115. }
  40116. if m.id == nil || m.oldValue == nil {
  40117. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  40118. }
  40119. oldValue, err := m.oldValue(ctx)
  40120. if err != nil {
  40121. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  40122. }
  40123. return oldValue.DeletedAt, nil
  40124. }
  40125. // ClearDeletedAt clears the value of the "deleted_at" field.
  40126. func (m *WxMutation) ClearDeletedAt() {
  40127. m.deleted_at = nil
  40128. m.clearedFields[wx.FieldDeletedAt] = struct{}{}
  40129. }
  40130. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  40131. func (m *WxMutation) DeletedAtCleared() bool {
  40132. _, ok := m.clearedFields[wx.FieldDeletedAt]
  40133. return ok
  40134. }
  40135. // ResetDeletedAt resets all changes to the "deleted_at" field.
  40136. func (m *WxMutation) ResetDeletedAt() {
  40137. m.deleted_at = nil
  40138. delete(m.clearedFields, wx.FieldDeletedAt)
  40139. }
  40140. // SetServerID sets the "server_id" field.
  40141. func (m *WxMutation) SetServerID(u uint64) {
  40142. m.server = &u
  40143. }
  40144. // ServerID returns the value of the "server_id" field in the mutation.
  40145. func (m *WxMutation) ServerID() (r uint64, exists bool) {
  40146. v := m.server
  40147. if v == nil {
  40148. return
  40149. }
  40150. return *v, true
  40151. }
  40152. // OldServerID returns the old "server_id" field's value of the Wx entity.
  40153. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40154. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40155. func (m *WxMutation) OldServerID(ctx context.Context) (v uint64, err error) {
  40156. if !m.op.Is(OpUpdateOne) {
  40157. return v, errors.New("OldServerID is only allowed on UpdateOne operations")
  40158. }
  40159. if m.id == nil || m.oldValue == nil {
  40160. return v, errors.New("OldServerID requires an ID field in the mutation")
  40161. }
  40162. oldValue, err := m.oldValue(ctx)
  40163. if err != nil {
  40164. return v, fmt.Errorf("querying old value for OldServerID: %w", err)
  40165. }
  40166. return oldValue.ServerID, nil
  40167. }
  40168. // ClearServerID clears the value of the "server_id" field.
  40169. func (m *WxMutation) ClearServerID() {
  40170. m.server = nil
  40171. m.clearedFields[wx.FieldServerID] = struct{}{}
  40172. }
  40173. // ServerIDCleared returns if the "server_id" field was cleared in this mutation.
  40174. func (m *WxMutation) ServerIDCleared() bool {
  40175. _, ok := m.clearedFields[wx.FieldServerID]
  40176. return ok
  40177. }
  40178. // ResetServerID resets all changes to the "server_id" field.
  40179. func (m *WxMutation) ResetServerID() {
  40180. m.server = nil
  40181. delete(m.clearedFields, wx.FieldServerID)
  40182. }
  40183. // SetPort sets the "port" field.
  40184. func (m *WxMutation) SetPort(s string) {
  40185. m.port = &s
  40186. }
  40187. // Port returns the value of the "port" field in the mutation.
  40188. func (m *WxMutation) Port() (r string, exists bool) {
  40189. v := m.port
  40190. if v == nil {
  40191. return
  40192. }
  40193. return *v, true
  40194. }
  40195. // OldPort returns the old "port" field's value of the Wx entity.
  40196. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40197. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40198. func (m *WxMutation) OldPort(ctx context.Context) (v string, err error) {
  40199. if !m.op.Is(OpUpdateOne) {
  40200. return v, errors.New("OldPort is only allowed on UpdateOne operations")
  40201. }
  40202. if m.id == nil || m.oldValue == nil {
  40203. return v, errors.New("OldPort requires an ID field in the mutation")
  40204. }
  40205. oldValue, err := m.oldValue(ctx)
  40206. if err != nil {
  40207. return v, fmt.Errorf("querying old value for OldPort: %w", err)
  40208. }
  40209. return oldValue.Port, nil
  40210. }
  40211. // ResetPort resets all changes to the "port" field.
  40212. func (m *WxMutation) ResetPort() {
  40213. m.port = nil
  40214. }
  40215. // SetProcessID sets the "process_id" field.
  40216. func (m *WxMutation) SetProcessID(s string) {
  40217. m.process_id = &s
  40218. }
  40219. // ProcessID returns the value of the "process_id" field in the mutation.
  40220. func (m *WxMutation) ProcessID() (r string, exists bool) {
  40221. v := m.process_id
  40222. if v == nil {
  40223. return
  40224. }
  40225. return *v, true
  40226. }
  40227. // OldProcessID returns the old "process_id" field's value of the Wx entity.
  40228. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40229. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40230. func (m *WxMutation) OldProcessID(ctx context.Context) (v string, err error) {
  40231. if !m.op.Is(OpUpdateOne) {
  40232. return v, errors.New("OldProcessID is only allowed on UpdateOne operations")
  40233. }
  40234. if m.id == nil || m.oldValue == nil {
  40235. return v, errors.New("OldProcessID requires an ID field in the mutation")
  40236. }
  40237. oldValue, err := m.oldValue(ctx)
  40238. if err != nil {
  40239. return v, fmt.Errorf("querying old value for OldProcessID: %w", err)
  40240. }
  40241. return oldValue.ProcessID, nil
  40242. }
  40243. // ResetProcessID resets all changes to the "process_id" field.
  40244. func (m *WxMutation) ResetProcessID() {
  40245. m.process_id = nil
  40246. }
  40247. // SetCallback sets the "callback" field.
  40248. func (m *WxMutation) SetCallback(s string) {
  40249. m.callback = &s
  40250. }
  40251. // Callback returns the value of the "callback" field in the mutation.
  40252. func (m *WxMutation) Callback() (r string, exists bool) {
  40253. v := m.callback
  40254. if v == nil {
  40255. return
  40256. }
  40257. return *v, true
  40258. }
  40259. // OldCallback returns the old "callback" field's value of the Wx entity.
  40260. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40261. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40262. func (m *WxMutation) OldCallback(ctx context.Context) (v string, err error) {
  40263. if !m.op.Is(OpUpdateOne) {
  40264. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  40265. }
  40266. if m.id == nil || m.oldValue == nil {
  40267. return v, errors.New("OldCallback requires an ID field in the mutation")
  40268. }
  40269. oldValue, err := m.oldValue(ctx)
  40270. if err != nil {
  40271. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  40272. }
  40273. return oldValue.Callback, nil
  40274. }
  40275. // ResetCallback resets all changes to the "callback" field.
  40276. func (m *WxMutation) ResetCallback() {
  40277. m.callback = nil
  40278. }
  40279. // SetWxid sets the "wxid" field.
  40280. func (m *WxMutation) SetWxid(s string) {
  40281. m.wxid = &s
  40282. }
  40283. // Wxid returns the value of the "wxid" field in the mutation.
  40284. func (m *WxMutation) Wxid() (r string, exists bool) {
  40285. v := m.wxid
  40286. if v == nil {
  40287. return
  40288. }
  40289. return *v, true
  40290. }
  40291. // OldWxid returns the old "wxid" field's value of the Wx entity.
  40292. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40293. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40294. func (m *WxMutation) OldWxid(ctx context.Context) (v string, err error) {
  40295. if !m.op.Is(OpUpdateOne) {
  40296. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  40297. }
  40298. if m.id == nil || m.oldValue == nil {
  40299. return v, errors.New("OldWxid requires an ID field in the mutation")
  40300. }
  40301. oldValue, err := m.oldValue(ctx)
  40302. if err != nil {
  40303. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  40304. }
  40305. return oldValue.Wxid, nil
  40306. }
  40307. // ResetWxid resets all changes to the "wxid" field.
  40308. func (m *WxMutation) ResetWxid() {
  40309. m.wxid = nil
  40310. }
  40311. // SetAccount sets the "account" field.
  40312. func (m *WxMutation) SetAccount(s string) {
  40313. m.account = &s
  40314. }
  40315. // Account returns the value of the "account" field in the mutation.
  40316. func (m *WxMutation) Account() (r string, exists bool) {
  40317. v := m.account
  40318. if v == nil {
  40319. return
  40320. }
  40321. return *v, true
  40322. }
  40323. // OldAccount returns the old "account" field's value of the Wx entity.
  40324. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40325. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40326. func (m *WxMutation) OldAccount(ctx context.Context) (v string, err error) {
  40327. if !m.op.Is(OpUpdateOne) {
  40328. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  40329. }
  40330. if m.id == nil || m.oldValue == nil {
  40331. return v, errors.New("OldAccount requires an ID field in the mutation")
  40332. }
  40333. oldValue, err := m.oldValue(ctx)
  40334. if err != nil {
  40335. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  40336. }
  40337. return oldValue.Account, nil
  40338. }
  40339. // ResetAccount resets all changes to the "account" field.
  40340. func (m *WxMutation) ResetAccount() {
  40341. m.account = nil
  40342. }
  40343. // SetNickname sets the "nickname" field.
  40344. func (m *WxMutation) SetNickname(s string) {
  40345. m.nickname = &s
  40346. }
  40347. // Nickname returns the value of the "nickname" field in the mutation.
  40348. func (m *WxMutation) Nickname() (r string, exists bool) {
  40349. v := m.nickname
  40350. if v == nil {
  40351. return
  40352. }
  40353. return *v, true
  40354. }
  40355. // OldNickname returns the old "nickname" field's value of the Wx entity.
  40356. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40357. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40358. func (m *WxMutation) OldNickname(ctx context.Context) (v string, err error) {
  40359. if !m.op.Is(OpUpdateOne) {
  40360. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  40361. }
  40362. if m.id == nil || m.oldValue == nil {
  40363. return v, errors.New("OldNickname requires an ID field in the mutation")
  40364. }
  40365. oldValue, err := m.oldValue(ctx)
  40366. if err != nil {
  40367. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  40368. }
  40369. return oldValue.Nickname, nil
  40370. }
  40371. // ResetNickname resets all changes to the "nickname" field.
  40372. func (m *WxMutation) ResetNickname() {
  40373. m.nickname = nil
  40374. }
  40375. // SetTel sets the "tel" field.
  40376. func (m *WxMutation) SetTel(s string) {
  40377. m.tel = &s
  40378. }
  40379. // Tel returns the value of the "tel" field in the mutation.
  40380. func (m *WxMutation) Tel() (r string, exists bool) {
  40381. v := m.tel
  40382. if v == nil {
  40383. return
  40384. }
  40385. return *v, true
  40386. }
  40387. // OldTel returns the old "tel" 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) OldTel(ctx context.Context) (v string, err error) {
  40391. if !m.op.Is(OpUpdateOne) {
  40392. return v, errors.New("OldTel is only allowed on UpdateOne operations")
  40393. }
  40394. if m.id == nil || m.oldValue == nil {
  40395. return v, errors.New("OldTel 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 OldTel: %w", err)
  40400. }
  40401. return oldValue.Tel, nil
  40402. }
  40403. // ResetTel resets all changes to the "tel" field.
  40404. func (m *WxMutation) ResetTel() {
  40405. m.tel = nil
  40406. }
  40407. // SetHeadBig sets the "head_big" field.
  40408. func (m *WxMutation) SetHeadBig(s string) {
  40409. m.head_big = &s
  40410. }
  40411. // HeadBig returns the value of the "head_big" field in the mutation.
  40412. func (m *WxMutation) HeadBig() (r string, exists bool) {
  40413. v := m.head_big
  40414. if v == nil {
  40415. return
  40416. }
  40417. return *v, true
  40418. }
  40419. // OldHeadBig returns the old "head_big" field's value of the Wx entity.
  40420. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40421. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40422. func (m *WxMutation) OldHeadBig(ctx context.Context) (v string, err error) {
  40423. if !m.op.Is(OpUpdateOne) {
  40424. return v, errors.New("OldHeadBig is only allowed on UpdateOne operations")
  40425. }
  40426. if m.id == nil || m.oldValue == nil {
  40427. return v, errors.New("OldHeadBig requires an ID field in the mutation")
  40428. }
  40429. oldValue, err := m.oldValue(ctx)
  40430. if err != nil {
  40431. return v, fmt.Errorf("querying old value for OldHeadBig: %w", err)
  40432. }
  40433. return oldValue.HeadBig, nil
  40434. }
  40435. // ResetHeadBig resets all changes to the "head_big" field.
  40436. func (m *WxMutation) ResetHeadBig() {
  40437. m.head_big = nil
  40438. }
  40439. // SetOrganizationID sets the "organization_id" field.
  40440. func (m *WxMutation) SetOrganizationID(u uint64) {
  40441. m.organization_id = &u
  40442. m.addorganization_id = nil
  40443. }
  40444. // OrganizationID returns the value of the "organization_id" field in the mutation.
  40445. func (m *WxMutation) OrganizationID() (r uint64, exists bool) {
  40446. v := m.organization_id
  40447. if v == nil {
  40448. return
  40449. }
  40450. return *v, true
  40451. }
  40452. // OldOrganizationID returns the old "organization_id" field's value of the Wx entity.
  40453. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40454. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40455. func (m *WxMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  40456. if !m.op.Is(OpUpdateOne) {
  40457. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  40458. }
  40459. if m.id == nil || m.oldValue == nil {
  40460. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  40461. }
  40462. oldValue, err := m.oldValue(ctx)
  40463. if err != nil {
  40464. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  40465. }
  40466. return oldValue.OrganizationID, nil
  40467. }
  40468. // AddOrganizationID adds u to the "organization_id" field.
  40469. func (m *WxMutation) AddOrganizationID(u int64) {
  40470. if m.addorganization_id != nil {
  40471. *m.addorganization_id += u
  40472. } else {
  40473. m.addorganization_id = &u
  40474. }
  40475. }
  40476. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  40477. func (m *WxMutation) AddedOrganizationID() (r int64, exists bool) {
  40478. v := m.addorganization_id
  40479. if v == nil {
  40480. return
  40481. }
  40482. return *v, true
  40483. }
  40484. // ClearOrganizationID clears the value of the "organization_id" field.
  40485. func (m *WxMutation) ClearOrganizationID() {
  40486. m.organization_id = nil
  40487. m.addorganization_id = nil
  40488. m.clearedFields[wx.FieldOrganizationID] = struct{}{}
  40489. }
  40490. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  40491. func (m *WxMutation) OrganizationIDCleared() bool {
  40492. _, ok := m.clearedFields[wx.FieldOrganizationID]
  40493. return ok
  40494. }
  40495. // ResetOrganizationID resets all changes to the "organization_id" field.
  40496. func (m *WxMutation) ResetOrganizationID() {
  40497. m.organization_id = nil
  40498. m.addorganization_id = nil
  40499. delete(m.clearedFields, wx.FieldOrganizationID)
  40500. }
  40501. // SetAgentID sets the "agent_id" field.
  40502. func (m *WxMutation) SetAgentID(u uint64) {
  40503. m.agent = &u
  40504. }
  40505. // AgentID returns the value of the "agent_id" field in the mutation.
  40506. func (m *WxMutation) AgentID() (r uint64, exists bool) {
  40507. v := m.agent
  40508. if v == nil {
  40509. return
  40510. }
  40511. return *v, true
  40512. }
  40513. // OldAgentID returns the old "agent_id" field's value of the Wx entity.
  40514. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40515. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40516. func (m *WxMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  40517. if !m.op.Is(OpUpdateOne) {
  40518. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  40519. }
  40520. if m.id == nil || m.oldValue == nil {
  40521. return v, errors.New("OldAgentID requires an ID field in the mutation")
  40522. }
  40523. oldValue, err := m.oldValue(ctx)
  40524. if err != nil {
  40525. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  40526. }
  40527. return oldValue.AgentID, nil
  40528. }
  40529. // ResetAgentID resets all changes to the "agent_id" field.
  40530. func (m *WxMutation) ResetAgentID() {
  40531. m.agent = nil
  40532. }
  40533. // SetAPIBase sets the "api_base" field.
  40534. func (m *WxMutation) SetAPIBase(s string) {
  40535. m.api_base = &s
  40536. }
  40537. // APIBase returns the value of the "api_base" field in the mutation.
  40538. func (m *WxMutation) APIBase() (r string, exists bool) {
  40539. v := m.api_base
  40540. if v == nil {
  40541. return
  40542. }
  40543. return *v, true
  40544. }
  40545. // OldAPIBase returns the old "api_base" field's value of the Wx entity.
  40546. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40547. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40548. func (m *WxMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  40549. if !m.op.Is(OpUpdateOne) {
  40550. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  40551. }
  40552. if m.id == nil || m.oldValue == nil {
  40553. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  40554. }
  40555. oldValue, err := m.oldValue(ctx)
  40556. if err != nil {
  40557. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  40558. }
  40559. return oldValue.APIBase, nil
  40560. }
  40561. // ClearAPIBase clears the value of the "api_base" field.
  40562. func (m *WxMutation) ClearAPIBase() {
  40563. m.api_base = nil
  40564. m.clearedFields[wx.FieldAPIBase] = struct{}{}
  40565. }
  40566. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  40567. func (m *WxMutation) APIBaseCleared() bool {
  40568. _, ok := m.clearedFields[wx.FieldAPIBase]
  40569. return ok
  40570. }
  40571. // ResetAPIBase resets all changes to the "api_base" field.
  40572. func (m *WxMutation) ResetAPIBase() {
  40573. m.api_base = nil
  40574. delete(m.clearedFields, wx.FieldAPIBase)
  40575. }
  40576. // SetAPIKey sets the "api_key" field.
  40577. func (m *WxMutation) SetAPIKey(s string) {
  40578. m.api_key = &s
  40579. }
  40580. // APIKey returns the value of the "api_key" field in the mutation.
  40581. func (m *WxMutation) APIKey() (r string, exists bool) {
  40582. v := m.api_key
  40583. if v == nil {
  40584. return
  40585. }
  40586. return *v, true
  40587. }
  40588. // OldAPIKey returns the old "api_key" field's value of the Wx entity.
  40589. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40590. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40591. func (m *WxMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  40592. if !m.op.Is(OpUpdateOne) {
  40593. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  40594. }
  40595. if m.id == nil || m.oldValue == nil {
  40596. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  40597. }
  40598. oldValue, err := m.oldValue(ctx)
  40599. if err != nil {
  40600. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  40601. }
  40602. return oldValue.APIKey, nil
  40603. }
  40604. // ClearAPIKey clears the value of the "api_key" field.
  40605. func (m *WxMutation) ClearAPIKey() {
  40606. m.api_key = nil
  40607. m.clearedFields[wx.FieldAPIKey] = struct{}{}
  40608. }
  40609. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  40610. func (m *WxMutation) APIKeyCleared() bool {
  40611. _, ok := m.clearedFields[wx.FieldAPIKey]
  40612. return ok
  40613. }
  40614. // ResetAPIKey resets all changes to the "api_key" field.
  40615. func (m *WxMutation) ResetAPIKey() {
  40616. m.api_key = nil
  40617. delete(m.clearedFields, wx.FieldAPIKey)
  40618. }
  40619. // SetAllowList sets the "allow_list" field.
  40620. func (m *WxMutation) SetAllowList(s []string) {
  40621. m.allow_list = &s
  40622. m.appendallow_list = nil
  40623. }
  40624. // AllowList returns the value of the "allow_list" field in the mutation.
  40625. func (m *WxMutation) AllowList() (r []string, exists bool) {
  40626. v := m.allow_list
  40627. if v == nil {
  40628. return
  40629. }
  40630. return *v, true
  40631. }
  40632. // OldAllowList returns the old "allow_list" field's value of the Wx entity.
  40633. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40634. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40635. func (m *WxMutation) OldAllowList(ctx context.Context) (v []string, err error) {
  40636. if !m.op.Is(OpUpdateOne) {
  40637. return v, errors.New("OldAllowList is only allowed on UpdateOne operations")
  40638. }
  40639. if m.id == nil || m.oldValue == nil {
  40640. return v, errors.New("OldAllowList requires an ID field in the mutation")
  40641. }
  40642. oldValue, err := m.oldValue(ctx)
  40643. if err != nil {
  40644. return v, fmt.Errorf("querying old value for OldAllowList: %w", err)
  40645. }
  40646. return oldValue.AllowList, nil
  40647. }
  40648. // AppendAllowList adds s to the "allow_list" field.
  40649. func (m *WxMutation) AppendAllowList(s []string) {
  40650. m.appendallow_list = append(m.appendallow_list, s...)
  40651. }
  40652. // AppendedAllowList returns the list of values that were appended to the "allow_list" field in this mutation.
  40653. func (m *WxMutation) AppendedAllowList() ([]string, bool) {
  40654. if len(m.appendallow_list) == 0 {
  40655. return nil, false
  40656. }
  40657. return m.appendallow_list, true
  40658. }
  40659. // ResetAllowList resets all changes to the "allow_list" field.
  40660. func (m *WxMutation) ResetAllowList() {
  40661. m.allow_list = nil
  40662. m.appendallow_list = nil
  40663. }
  40664. // SetGroupAllowList sets the "group_allow_list" field.
  40665. func (m *WxMutation) SetGroupAllowList(s []string) {
  40666. m.group_allow_list = &s
  40667. m.appendgroup_allow_list = nil
  40668. }
  40669. // GroupAllowList returns the value of the "group_allow_list" field in the mutation.
  40670. func (m *WxMutation) GroupAllowList() (r []string, exists bool) {
  40671. v := m.group_allow_list
  40672. if v == nil {
  40673. return
  40674. }
  40675. return *v, true
  40676. }
  40677. // OldGroupAllowList returns the old "group_allow_list" field's value of the Wx entity.
  40678. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40679. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40680. func (m *WxMutation) OldGroupAllowList(ctx context.Context) (v []string, err error) {
  40681. if !m.op.Is(OpUpdateOne) {
  40682. return v, errors.New("OldGroupAllowList is only allowed on UpdateOne operations")
  40683. }
  40684. if m.id == nil || m.oldValue == nil {
  40685. return v, errors.New("OldGroupAllowList requires an ID field in the mutation")
  40686. }
  40687. oldValue, err := m.oldValue(ctx)
  40688. if err != nil {
  40689. return v, fmt.Errorf("querying old value for OldGroupAllowList: %w", err)
  40690. }
  40691. return oldValue.GroupAllowList, nil
  40692. }
  40693. // AppendGroupAllowList adds s to the "group_allow_list" field.
  40694. func (m *WxMutation) AppendGroupAllowList(s []string) {
  40695. m.appendgroup_allow_list = append(m.appendgroup_allow_list, s...)
  40696. }
  40697. // AppendedGroupAllowList returns the list of values that were appended to the "group_allow_list" field in this mutation.
  40698. func (m *WxMutation) AppendedGroupAllowList() ([]string, bool) {
  40699. if len(m.appendgroup_allow_list) == 0 {
  40700. return nil, false
  40701. }
  40702. return m.appendgroup_allow_list, true
  40703. }
  40704. // ResetGroupAllowList resets all changes to the "group_allow_list" field.
  40705. func (m *WxMutation) ResetGroupAllowList() {
  40706. m.group_allow_list = nil
  40707. m.appendgroup_allow_list = nil
  40708. }
  40709. // SetBlockList sets the "block_list" field.
  40710. func (m *WxMutation) SetBlockList(s []string) {
  40711. m.block_list = &s
  40712. m.appendblock_list = nil
  40713. }
  40714. // BlockList returns the value of the "block_list" field in the mutation.
  40715. func (m *WxMutation) BlockList() (r []string, exists bool) {
  40716. v := m.block_list
  40717. if v == nil {
  40718. return
  40719. }
  40720. return *v, true
  40721. }
  40722. // OldBlockList returns the old "block_list" field's value of the Wx entity.
  40723. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40724. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40725. func (m *WxMutation) OldBlockList(ctx context.Context) (v []string, err error) {
  40726. if !m.op.Is(OpUpdateOne) {
  40727. return v, errors.New("OldBlockList is only allowed on UpdateOne operations")
  40728. }
  40729. if m.id == nil || m.oldValue == nil {
  40730. return v, errors.New("OldBlockList requires an ID field in the mutation")
  40731. }
  40732. oldValue, err := m.oldValue(ctx)
  40733. if err != nil {
  40734. return v, fmt.Errorf("querying old value for OldBlockList: %w", err)
  40735. }
  40736. return oldValue.BlockList, nil
  40737. }
  40738. // AppendBlockList adds s to the "block_list" field.
  40739. func (m *WxMutation) AppendBlockList(s []string) {
  40740. m.appendblock_list = append(m.appendblock_list, s...)
  40741. }
  40742. // AppendedBlockList returns the list of values that were appended to the "block_list" field in this mutation.
  40743. func (m *WxMutation) AppendedBlockList() ([]string, bool) {
  40744. if len(m.appendblock_list) == 0 {
  40745. return nil, false
  40746. }
  40747. return m.appendblock_list, true
  40748. }
  40749. // ResetBlockList resets all changes to the "block_list" field.
  40750. func (m *WxMutation) ResetBlockList() {
  40751. m.block_list = nil
  40752. m.appendblock_list = nil
  40753. }
  40754. // SetGroupBlockList sets the "group_block_list" field.
  40755. func (m *WxMutation) SetGroupBlockList(s []string) {
  40756. m.group_block_list = &s
  40757. m.appendgroup_block_list = nil
  40758. }
  40759. // GroupBlockList returns the value of the "group_block_list" field in the mutation.
  40760. func (m *WxMutation) GroupBlockList() (r []string, exists bool) {
  40761. v := m.group_block_list
  40762. if v == nil {
  40763. return
  40764. }
  40765. return *v, true
  40766. }
  40767. // OldGroupBlockList returns the old "group_block_list" field's value of the Wx entity.
  40768. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40769. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40770. func (m *WxMutation) OldGroupBlockList(ctx context.Context) (v []string, err error) {
  40771. if !m.op.Is(OpUpdateOne) {
  40772. return v, errors.New("OldGroupBlockList is only allowed on UpdateOne operations")
  40773. }
  40774. if m.id == nil || m.oldValue == nil {
  40775. return v, errors.New("OldGroupBlockList requires an ID field in the mutation")
  40776. }
  40777. oldValue, err := m.oldValue(ctx)
  40778. if err != nil {
  40779. return v, fmt.Errorf("querying old value for OldGroupBlockList: %w", err)
  40780. }
  40781. return oldValue.GroupBlockList, nil
  40782. }
  40783. // AppendGroupBlockList adds s to the "group_block_list" field.
  40784. func (m *WxMutation) AppendGroupBlockList(s []string) {
  40785. m.appendgroup_block_list = append(m.appendgroup_block_list, s...)
  40786. }
  40787. // AppendedGroupBlockList returns the list of values that were appended to the "group_block_list" field in this mutation.
  40788. func (m *WxMutation) AppendedGroupBlockList() ([]string, bool) {
  40789. if len(m.appendgroup_block_list) == 0 {
  40790. return nil, false
  40791. }
  40792. return m.appendgroup_block_list, true
  40793. }
  40794. // ResetGroupBlockList resets all changes to the "group_block_list" field.
  40795. func (m *WxMutation) ResetGroupBlockList() {
  40796. m.group_block_list = nil
  40797. m.appendgroup_block_list = nil
  40798. }
  40799. // ClearServer clears the "server" edge to the Server entity.
  40800. func (m *WxMutation) ClearServer() {
  40801. m.clearedserver = true
  40802. m.clearedFields[wx.FieldServerID] = struct{}{}
  40803. }
  40804. // ServerCleared reports if the "server" edge to the Server entity was cleared.
  40805. func (m *WxMutation) ServerCleared() bool {
  40806. return m.ServerIDCleared() || m.clearedserver
  40807. }
  40808. // ServerIDs returns the "server" edge IDs in the mutation.
  40809. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  40810. // ServerID instead. It exists only for internal usage by the builders.
  40811. func (m *WxMutation) ServerIDs() (ids []uint64) {
  40812. if id := m.server; id != nil {
  40813. ids = append(ids, *id)
  40814. }
  40815. return
  40816. }
  40817. // ResetServer resets all changes to the "server" edge.
  40818. func (m *WxMutation) ResetServer() {
  40819. m.server = nil
  40820. m.clearedserver = false
  40821. }
  40822. // ClearAgent clears the "agent" edge to the Agent entity.
  40823. func (m *WxMutation) ClearAgent() {
  40824. m.clearedagent = true
  40825. m.clearedFields[wx.FieldAgentID] = struct{}{}
  40826. }
  40827. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  40828. func (m *WxMutation) AgentCleared() bool {
  40829. return m.clearedagent
  40830. }
  40831. // AgentIDs returns the "agent" edge IDs in the mutation.
  40832. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  40833. // AgentID instead. It exists only for internal usage by the builders.
  40834. func (m *WxMutation) AgentIDs() (ids []uint64) {
  40835. if id := m.agent; id != nil {
  40836. ids = append(ids, *id)
  40837. }
  40838. return
  40839. }
  40840. // ResetAgent resets all changes to the "agent" edge.
  40841. func (m *WxMutation) ResetAgent() {
  40842. m.agent = nil
  40843. m.clearedagent = false
  40844. }
  40845. // Where appends a list predicates to the WxMutation builder.
  40846. func (m *WxMutation) Where(ps ...predicate.Wx) {
  40847. m.predicates = append(m.predicates, ps...)
  40848. }
  40849. // WhereP appends storage-level predicates to the WxMutation builder. Using this method,
  40850. // users can use type-assertion to append predicates that do not depend on any generated package.
  40851. func (m *WxMutation) WhereP(ps ...func(*sql.Selector)) {
  40852. p := make([]predicate.Wx, len(ps))
  40853. for i := range ps {
  40854. p[i] = ps[i]
  40855. }
  40856. m.Where(p...)
  40857. }
  40858. // Op returns the operation name.
  40859. func (m *WxMutation) Op() Op {
  40860. return m.op
  40861. }
  40862. // SetOp allows setting the mutation operation.
  40863. func (m *WxMutation) SetOp(op Op) {
  40864. m.op = op
  40865. }
  40866. // Type returns the node type of this mutation (Wx).
  40867. func (m *WxMutation) Type() string {
  40868. return m.typ
  40869. }
  40870. // Fields returns all fields that were changed during this mutation. Note that in
  40871. // order to get all numeric fields that were incremented/decremented, call
  40872. // AddedFields().
  40873. func (m *WxMutation) Fields() []string {
  40874. fields := make([]string, 0, 21)
  40875. if m.created_at != nil {
  40876. fields = append(fields, wx.FieldCreatedAt)
  40877. }
  40878. if m.updated_at != nil {
  40879. fields = append(fields, wx.FieldUpdatedAt)
  40880. }
  40881. if m.status != nil {
  40882. fields = append(fields, wx.FieldStatus)
  40883. }
  40884. if m.deleted_at != nil {
  40885. fields = append(fields, wx.FieldDeletedAt)
  40886. }
  40887. if m.server != nil {
  40888. fields = append(fields, wx.FieldServerID)
  40889. }
  40890. if m.port != nil {
  40891. fields = append(fields, wx.FieldPort)
  40892. }
  40893. if m.process_id != nil {
  40894. fields = append(fields, wx.FieldProcessID)
  40895. }
  40896. if m.callback != nil {
  40897. fields = append(fields, wx.FieldCallback)
  40898. }
  40899. if m.wxid != nil {
  40900. fields = append(fields, wx.FieldWxid)
  40901. }
  40902. if m.account != nil {
  40903. fields = append(fields, wx.FieldAccount)
  40904. }
  40905. if m.nickname != nil {
  40906. fields = append(fields, wx.FieldNickname)
  40907. }
  40908. if m.tel != nil {
  40909. fields = append(fields, wx.FieldTel)
  40910. }
  40911. if m.head_big != nil {
  40912. fields = append(fields, wx.FieldHeadBig)
  40913. }
  40914. if m.organization_id != nil {
  40915. fields = append(fields, wx.FieldOrganizationID)
  40916. }
  40917. if m.agent != nil {
  40918. fields = append(fields, wx.FieldAgentID)
  40919. }
  40920. if m.api_base != nil {
  40921. fields = append(fields, wx.FieldAPIBase)
  40922. }
  40923. if m.api_key != nil {
  40924. fields = append(fields, wx.FieldAPIKey)
  40925. }
  40926. if m.allow_list != nil {
  40927. fields = append(fields, wx.FieldAllowList)
  40928. }
  40929. if m.group_allow_list != nil {
  40930. fields = append(fields, wx.FieldGroupAllowList)
  40931. }
  40932. if m.block_list != nil {
  40933. fields = append(fields, wx.FieldBlockList)
  40934. }
  40935. if m.group_block_list != nil {
  40936. fields = append(fields, wx.FieldGroupBlockList)
  40937. }
  40938. return fields
  40939. }
  40940. // Field returns the value of a field with the given name. The second boolean
  40941. // return value indicates that this field was not set, or was not defined in the
  40942. // schema.
  40943. func (m *WxMutation) Field(name string) (ent.Value, bool) {
  40944. switch name {
  40945. case wx.FieldCreatedAt:
  40946. return m.CreatedAt()
  40947. case wx.FieldUpdatedAt:
  40948. return m.UpdatedAt()
  40949. case wx.FieldStatus:
  40950. return m.Status()
  40951. case wx.FieldDeletedAt:
  40952. return m.DeletedAt()
  40953. case wx.FieldServerID:
  40954. return m.ServerID()
  40955. case wx.FieldPort:
  40956. return m.Port()
  40957. case wx.FieldProcessID:
  40958. return m.ProcessID()
  40959. case wx.FieldCallback:
  40960. return m.Callback()
  40961. case wx.FieldWxid:
  40962. return m.Wxid()
  40963. case wx.FieldAccount:
  40964. return m.Account()
  40965. case wx.FieldNickname:
  40966. return m.Nickname()
  40967. case wx.FieldTel:
  40968. return m.Tel()
  40969. case wx.FieldHeadBig:
  40970. return m.HeadBig()
  40971. case wx.FieldOrganizationID:
  40972. return m.OrganizationID()
  40973. case wx.FieldAgentID:
  40974. return m.AgentID()
  40975. case wx.FieldAPIBase:
  40976. return m.APIBase()
  40977. case wx.FieldAPIKey:
  40978. return m.APIKey()
  40979. case wx.FieldAllowList:
  40980. return m.AllowList()
  40981. case wx.FieldGroupAllowList:
  40982. return m.GroupAllowList()
  40983. case wx.FieldBlockList:
  40984. return m.BlockList()
  40985. case wx.FieldGroupBlockList:
  40986. return m.GroupBlockList()
  40987. }
  40988. return nil, false
  40989. }
  40990. // OldField returns the old value of the field from the database. An error is
  40991. // returned if the mutation operation is not UpdateOne, or the query to the
  40992. // database failed.
  40993. func (m *WxMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  40994. switch name {
  40995. case wx.FieldCreatedAt:
  40996. return m.OldCreatedAt(ctx)
  40997. case wx.FieldUpdatedAt:
  40998. return m.OldUpdatedAt(ctx)
  40999. case wx.FieldStatus:
  41000. return m.OldStatus(ctx)
  41001. case wx.FieldDeletedAt:
  41002. return m.OldDeletedAt(ctx)
  41003. case wx.FieldServerID:
  41004. return m.OldServerID(ctx)
  41005. case wx.FieldPort:
  41006. return m.OldPort(ctx)
  41007. case wx.FieldProcessID:
  41008. return m.OldProcessID(ctx)
  41009. case wx.FieldCallback:
  41010. return m.OldCallback(ctx)
  41011. case wx.FieldWxid:
  41012. return m.OldWxid(ctx)
  41013. case wx.FieldAccount:
  41014. return m.OldAccount(ctx)
  41015. case wx.FieldNickname:
  41016. return m.OldNickname(ctx)
  41017. case wx.FieldTel:
  41018. return m.OldTel(ctx)
  41019. case wx.FieldHeadBig:
  41020. return m.OldHeadBig(ctx)
  41021. case wx.FieldOrganizationID:
  41022. return m.OldOrganizationID(ctx)
  41023. case wx.FieldAgentID:
  41024. return m.OldAgentID(ctx)
  41025. case wx.FieldAPIBase:
  41026. return m.OldAPIBase(ctx)
  41027. case wx.FieldAPIKey:
  41028. return m.OldAPIKey(ctx)
  41029. case wx.FieldAllowList:
  41030. return m.OldAllowList(ctx)
  41031. case wx.FieldGroupAllowList:
  41032. return m.OldGroupAllowList(ctx)
  41033. case wx.FieldBlockList:
  41034. return m.OldBlockList(ctx)
  41035. case wx.FieldGroupBlockList:
  41036. return m.OldGroupBlockList(ctx)
  41037. }
  41038. return nil, fmt.Errorf("unknown Wx field %s", name)
  41039. }
  41040. // SetField sets the value of a field with the given name. It returns an error if
  41041. // the field is not defined in the schema, or if the type mismatched the field
  41042. // type.
  41043. func (m *WxMutation) SetField(name string, value ent.Value) error {
  41044. switch name {
  41045. case wx.FieldCreatedAt:
  41046. v, ok := value.(time.Time)
  41047. if !ok {
  41048. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41049. }
  41050. m.SetCreatedAt(v)
  41051. return nil
  41052. case wx.FieldUpdatedAt:
  41053. v, ok := value.(time.Time)
  41054. if !ok {
  41055. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41056. }
  41057. m.SetUpdatedAt(v)
  41058. return nil
  41059. case wx.FieldStatus:
  41060. v, ok := value.(uint8)
  41061. if !ok {
  41062. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41063. }
  41064. m.SetStatus(v)
  41065. return nil
  41066. case wx.FieldDeletedAt:
  41067. v, ok := value.(time.Time)
  41068. if !ok {
  41069. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41070. }
  41071. m.SetDeletedAt(v)
  41072. return nil
  41073. case wx.FieldServerID:
  41074. v, ok := value.(uint64)
  41075. if !ok {
  41076. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41077. }
  41078. m.SetServerID(v)
  41079. return nil
  41080. case wx.FieldPort:
  41081. v, ok := value.(string)
  41082. if !ok {
  41083. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41084. }
  41085. m.SetPort(v)
  41086. return nil
  41087. case wx.FieldProcessID:
  41088. v, ok := value.(string)
  41089. if !ok {
  41090. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41091. }
  41092. m.SetProcessID(v)
  41093. return nil
  41094. case wx.FieldCallback:
  41095. v, ok := value.(string)
  41096. if !ok {
  41097. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41098. }
  41099. m.SetCallback(v)
  41100. return nil
  41101. case wx.FieldWxid:
  41102. v, ok := value.(string)
  41103. if !ok {
  41104. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41105. }
  41106. m.SetWxid(v)
  41107. return nil
  41108. case wx.FieldAccount:
  41109. v, ok := value.(string)
  41110. if !ok {
  41111. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41112. }
  41113. m.SetAccount(v)
  41114. return nil
  41115. case wx.FieldNickname:
  41116. v, ok := value.(string)
  41117. if !ok {
  41118. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41119. }
  41120. m.SetNickname(v)
  41121. return nil
  41122. case wx.FieldTel:
  41123. v, ok := value.(string)
  41124. if !ok {
  41125. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41126. }
  41127. m.SetTel(v)
  41128. return nil
  41129. case wx.FieldHeadBig:
  41130. v, ok := value.(string)
  41131. if !ok {
  41132. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41133. }
  41134. m.SetHeadBig(v)
  41135. return nil
  41136. case wx.FieldOrganizationID:
  41137. v, ok := value.(uint64)
  41138. if !ok {
  41139. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41140. }
  41141. m.SetOrganizationID(v)
  41142. return nil
  41143. case wx.FieldAgentID:
  41144. v, ok := value.(uint64)
  41145. if !ok {
  41146. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41147. }
  41148. m.SetAgentID(v)
  41149. return nil
  41150. case wx.FieldAPIBase:
  41151. v, ok := value.(string)
  41152. if !ok {
  41153. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41154. }
  41155. m.SetAPIBase(v)
  41156. return nil
  41157. case wx.FieldAPIKey:
  41158. v, ok := value.(string)
  41159. if !ok {
  41160. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41161. }
  41162. m.SetAPIKey(v)
  41163. return nil
  41164. case wx.FieldAllowList:
  41165. v, ok := value.([]string)
  41166. if !ok {
  41167. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41168. }
  41169. m.SetAllowList(v)
  41170. return nil
  41171. case wx.FieldGroupAllowList:
  41172. v, ok := value.([]string)
  41173. if !ok {
  41174. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41175. }
  41176. m.SetGroupAllowList(v)
  41177. return nil
  41178. case wx.FieldBlockList:
  41179. v, ok := value.([]string)
  41180. if !ok {
  41181. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41182. }
  41183. m.SetBlockList(v)
  41184. return nil
  41185. case wx.FieldGroupBlockList:
  41186. v, ok := value.([]string)
  41187. if !ok {
  41188. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41189. }
  41190. m.SetGroupBlockList(v)
  41191. return nil
  41192. }
  41193. return fmt.Errorf("unknown Wx field %s", name)
  41194. }
  41195. // AddedFields returns all numeric fields that were incremented/decremented during
  41196. // this mutation.
  41197. func (m *WxMutation) AddedFields() []string {
  41198. var fields []string
  41199. if m.addstatus != nil {
  41200. fields = append(fields, wx.FieldStatus)
  41201. }
  41202. if m.addorganization_id != nil {
  41203. fields = append(fields, wx.FieldOrganizationID)
  41204. }
  41205. return fields
  41206. }
  41207. // AddedField returns the numeric value that was incremented/decremented on a field
  41208. // with the given name. The second boolean return value indicates that this field
  41209. // was not set, or was not defined in the schema.
  41210. func (m *WxMutation) AddedField(name string) (ent.Value, bool) {
  41211. switch name {
  41212. case wx.FieldStatus:
  41213. return m.AddedStatus()
  41214. case wx.FieldOrganizationID:
  41215. return m.AddedOrganizationID()
  41216. }
  41217. return nil, false
  41218. }
  41219. // AddField adds the value to the field with the given name. It returns an error if
  41220. // the field is not defined in the schema, or if the type mismatched the field
  41221. // type.
  41222. func (m *WxMutation) AddField(name string, value ent.Value) error {
  41223. switch name {
  41224. case wx.FieldStatus:
  41225. v, ok := value.(int8)
  41226. if !ok {
  41227. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41228. }
  41229. m.AddStatus(v)
  41230. return nil
  41231. case wx.FieldOrganizationID:
  41232. v, ok := value.(int64)
  41233. if !ok {
  41234. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41235. }
  41236. m.AddOrganizationID(v)
  41237. return nil
  41238. }
  41239. return fmt.Errorf("unknown Wx numeric field %s", name)
  41240. }
  41241. // ClearedFields returns all nullable fields that were cleared during this
  41242. // mutation.
  41243. func (m *WxMutation) ClearedFields() []string {
  41244. var fields []string
  41245. if m.FieldCleared(wx.FieldStatus) {
  41246. fields = append(fields, wx.FieldStatus)
  41247. }
  41248. if m.FieldCleared(wx.FieldDeletedAt) {
  41249. fields = append(fields, wx.FieldDeletedAt)
  41250. }
  41251. if m.FieldCleared(wx.FieldServerID) {
  41252. fields = append(fields, wx.FieldServerID)
  41253. }
  41254. if m.FieldCleared(wx.FieldOrganizationID) {
  41255. fields = append(fields, wx.FieldOrganizationID)
  41256. }
  41257. if m.FieldCleared(wx.FieldAPIBase) {
  41258. fields = append(fields, wx.FieldAPIBase)
  41259. }
  41260. if m.FieldCleared(wx.FieldAPIKey) {
  41261. fields = append(fields, wx.FieldAPIKey)
  41262. }
  41263. return fields
  41264. }
  41265. // FieldCleared returns a boolean indicating if a field with the given name was
  41266. // cleared in this mutation.
  41267. func (m *WxMutation) FieldCleared(name string) bool {
  41268. _, ok := m.clearedFields[name]
  41269. return ok
  41270. }
  41271. // ClearField clears the value of the field with the given name. It returns an
  41272. // error if the field is not defined in the schema.
  41273. func (m *WxMutation) ClearField(name string) error {
  41274. switch name {
  41275. case wx.FieldStatus:
  41276. m.ClearStatus()
  41277. return nil
  41278. case wx.FieldDeletedAt:
  41279. m.ClearDeletedAt()
  41280. return nil
  41281. case wx.FieldServerID:
  41282. m.ClearServerID()
  41283. return nil
  41284. case wx.FieldOrganizationID:
  41285. m.ClearOrganizationID()
  41286. return nil
  41287. case wx.FieldAPIBase:
  41288. m.ClearAPIBase()
  41289. return nil
  41290. case wx.FieldAPIKey:
  41291. m.ClearAPIKey()
  41292. return nil
  41293. }
  41294. return fmt.Errorf("unknown Wx nullable field %s", name)
  41295. }
  41296. // ResetField resets all changes in the mutation for the field with the given name.
  41297. // It returns an error if the field is not defined in the schema.
  41298. func (m *WxMutation) ResetField(name string) error {
  41299. switch name {
  41300. case wx.FieldCreatedAt:
  41301. m.ResetCreatedAt()
  41302. return nil
  41303. case wx.FieldUpdatedAt:
  41304. m.ResetUpdatedAt()
  41305. return nil
  41306. case wx.FieldStatus:
  41307. m.ResetStatus()
  41308. return nil
  41309. case wx.FieldDeletedAt:
  41310. m.ResetDeletedAt()
  41311. return nil
  41312. case wx.FieldServerID:
  41313. m.ResetServerID()
  41314. return nil
  41315. case wx.FieldPort:
  41316. m.ResetPort()
  41317. return nil
  41318. case wx.FieldProcessID:
  41319. m.ResetProcessID()
  41320. return nil
  41321. case wx.FieldCallback:
  41322. m.ResetCallback()
  41323. return nil
  41324. case wx.FieldWxid:
  41325. m.ResetWxid()
  41326. return nil
  41327. case wx.FieldAccount:
  41328. m.ResetAccount()
  41329. return nil
  41330. case wx.FieldNickname:
  41331. m.ResetNickname()
  41332. return nil
  41333. case wx.FieldTel:
  41334. m.ResetTel()
  41335. return nil
  41336. case wx.FieldHeadBig:
  41337. m.ResetHeadBig()
  41338. return nil
  41339. case wx.FieldOrganizationID:
  41340. m.ResetOrganizationID()
  41341. return nil
  41342. case wx.FieldAgentID:
  41343. m.ResetAgentID()
  41344. return nil
  41345. case wx.FieldAPIBase:
  41346. m.ResetAPIBase()
  41347. return nil
  41348. case wx.FieldAPIKey:
  41349. m.ResetAPIKey()
  41350. return nil
  41351. case wx.FieldAllowList:
  41352. m.ResetAllowList()
  41353. return nil
  41354. case wx.FieldGroupAllowList:
  41355. m.ResetGroupAllowList()
  41356. return nil
  41357. case wx.FieldBlockList:
  41358. m.ResetBlockList()
  41359. return nil
  41360. case wx.FieldGroupBlockList:
  41361. m.ResetGroupBlockList()
  41362. return nil
  41363. }
  41364. return fmt.Errorf("unknown Wx field %s", name)
  41365. }
  41366. // AddedEdges returns all edge names that were set/added in this mutation.
  41367. func (m *WxMutation) AddedEdges() []string {
  41368. edges := make([]string, 0, 2)
  41369. if m.server != nil {
  41370. edges = append(edges, wx.EdgeServer)
  41371. }
  41372. if m.agent != nil {
  41373. edges = append(edges, wx.EdgeAgent)
  41374. }
  41375. return edges
  41376. }
  41377. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  41378. // name in this mutation.
  41379. func (m *WxMutation) AddedIDs(name string) []ent.Value {
  41380. switch name {
  41381. case wx.EdgeServer:
  41382. if id := m.server; id != nil {
  41383. return []ent.Value{*id}
  41384. }
  41385. case wx.EdgeAgent:
  41386. if id := m.agent; id != nil {
  41387. return []ent.Value{*id}
  41388. }
  41389. }
  41390. return nil
  41391. }
  41392. // RemovedEdges returns all edge names that were removed in this mutation.
  41393. func (m *WxMutation) RemovedEdges() []string {
  41394. edges := make([]string, 0, 2)
  41395. return edges
  41396. }
  41397. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  41398. // the given name in this mutation.
  41399. func (m *WxMutation) RemovedIDs(name string) []ent.Value {
  41400. return nil
  41401. }
  41402. // ClearedEdges returns all edge names that were cleared in this mutation.
  41403. func (m *WxMutation) ClearedEdges() []string {
  41404. edges := make([]string, 0, 2)
  41405. if m.clearedserver {
  41406. edges = append(edges, wx.EdgeServer)
  41407. }
  41408. if m.clearedagent {
  41409. edges = append(edges, wx.EdgeAgent)
  41410. }
  41411. return edges
  41412. }
  41413. // EdgeCleared returns a boolean which indicates if the edge with the given name
  41414. // was cleared in this mutation.
  41415. func (m *WxMutation) EdgeCleared(name string) bool {
  41416. switch name {
  41417. case wx.EdgeServer:
  41418. return m.clearedserver
  41419. case wx.EdgeAgent:
  41420. return m.clearedagent
  41421. }
  41422. return false
  41423. }
  41424. // ClearEdge clears the value of the edge with the given name. It returns an error
  41425. // if that edge is not defined in the schema.
  41426. func (m *WxMutation) ClearEdge(name string) error {
  41427. switch name {
  41428. case wx.EdgeServer:
  41429. m.ClearServer()
  41430. return nil
  41431. case wx.EdgeAgent:
  41432. m.ClearAgent()
  41433. return nil
  41434. }
  41435. return fmt.Errorf("unknown Wx unique edge %s", name)
  41436. }
  41437. // ResetEdge resets all changes to the edge with the given name in this mutation.
  41438. // It returns an error if the edge is not defined in the schema.
  41439. func (m *WxMutation) ResetEdge(name string) error {
  41440. switch name {
  41441. case wx.EdgeServer:
  41442. m.ResetServer()
  41443. return nil
  41444. case wx.EdgeAgent:
  41445. m.ResetAgent()
  41446. return nil
  41447. }
  41448. return fmt.Errorf("unknown Wx edge %s", name)
  41449. }
  41450. // WxCardMutation represents an operation that mutates the WxCard nodes in the graph.
  41451. type WxCardMutation struct {
  41452. config
  41453. op Op
  41454. typ string
  41455. id *uint64
  41456. created_at *time.Time
  41457. updated_at *time.Time
  41458. deleted_at *time.Time
  41459. user_id *uint64
  41460. adduser_id *int64
  41461. wx_user_id *uint64
  41462. addwx_user_id *int64
  41463. avatar *string
  41464. logo *string
  41465. name *string
  41466. company *string
  41467. address *string
  41468. phone *string
  41469. official_account *string
  41470. wechat_account *string
  41471. email *string
  41472. api_base *string
  41473. api_key *string
  41474. ai_info *string
  41475. intro *string
  41476. clearedFields map[string]struct{}
  41477. done bool
  41478. oldValue func(context.Context) (*WxCard, error)
  41479. predicates []predicate.WxCard
  41480. }
  41481. var _ ent.Mutation = (*WxCardMutation)(nil)
  41482. // wxcardOption allows management of the mutation configuration using functional options.
  41483. type wxcardOption func(*WxCardMutation)
  41484. // newWxCardMutation creates new mutation for the WxCard entity.
  41485. func newWxCardMutation(c config, op Op, opts ...wxcardOption) *WxCardMutation {
  41486. m := &WxCardMutation{
  41487. config: c,
  41488. op: op,
  41489. typ: TypeWxCard,
  41490. clearedFields: make(map[string]struct{}),
  41491. }
  41492. for _, opt := range opts {
  41493. opt(m)
  41494. }
  41495. return m
  41496. }
  41497. // withWxCardID sets the ID field of the mutation.
  41498. func withWxCardID(id uint64) wxcardOption {
  41499. return func(m *WxCardMutation) {
  41500. var (
  41501. err error
  41502. once sync.Once
  41503. value *WxCard
  41504. )
  41505. m.oldValue = func(ctx context.Context) (*WxCard, error) {
  41506. once.Do(func() {
  41507. if m.done {
  41508. err = errors.New("querying old values post mutation is not allowed")
  41509. } else {
  41510. value, err = m.Client().WxCard.Get(ctx, id)
  41511. }
  41512. })
  41513. return value, err
  41514. }
  41515. m.id = &id
  41516. }
  41517. }
  41518. // withWxCard sets the old WxCard of the mutation.
  41519. func withWxCard(node *WxCard) wxcardOption {
  41520. return func(m *WxCardMutation) {
  41521. m.oldValue = func(context.Context) (*WxCard, error) {
  41522. return node, nil
  41523. }
  41524. m.id = &node.ID
  41525. }
  41526. }
  41527. // Client returns a new `ent.Client` from the mutation. If the mutation was
  41528. // executed in a transaction (ent.Tx), a transactional client is returned.
  41529. func (m WxCardMutation) Client() *Client {
  41530. client := &Client{config: m.config}
  41531. client.init()
  41532. return client
  41533. }
  41534. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  41535. // it returns an error otherwise.
  41536. func (m WxCardMutation) Tx() (*Tx, error) {
  41537. if _, ok := m.driver.(*txDriver); !ok {
  41538. return nil, errors.New("ent: mutation is not running in a transaction")
  41539. }
  41540. tx := &Tx{config: m.config}
  41541. tx.init()
  41542. return tx, nil
  41543. }
  41544. // SetID sets the value of the id field. Note that this
  41545. // operation is only accepted on creation of WxCard entities.
  41546. func (m *WxCardMutation) SetID(id uint64) {
  41547. m.id = &id
  41548. }
  41549. // ID returns the ID value in the mutation. Note that the ID is only available
  41550. // if it was provided to the builder or after it was returned from the database.
  41551. func (m *WxCardMutation) ID() (id uint64, exists bool) {
  41552. if m.id == nil {
  41553. return
  41554. }
  41555. return *m.id, true
  41556. }
  41557. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  41558. // That means, if the mutation is applied within a transaction with an isolation level such
  41559. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  41560. // or updated by the mutation.
  41561. func (m *WxCardMutation) IDs(ctx context.Context) ([]uint64, error) {
  41562. switch {
  41563. case m.op.Is(OpUpdateOne | OpDeleteOne):
  41564. id, exists := m.ID()
  41565. if exists {
  41566. return []uint64{id}, nil
  41567. }
  41568. fallthrough
  41569. case m.op.Is(OpUpdate | OpDelete):
  41570. return m.Client().WxCard.Query().Where(m.predicates...).IDs(ctx)
  41571. default:
  41572. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  41573. }
  41574. }
  41575. // SetCreatedAt sets the "created_at" field.
  41576. func (m *WxCardMutation) SetCreatedAt(t time.Time) {
  41577. m.created_at = &t
  41578. }
  41579. // CreatedAt returns the value of the "created_at" field in the mutation.
  41580. func (m *WxCardMutation) CreatedAt() (r time.Time, exists bool) {
  41581. v := m.created_at
  41582. if v == nil {
  41583. return
  41584. }
  41585. return *v, true
  41586. }
  41587. // OldCreatedAt returns the old "created_at" field's value of the WxCard entity.
  41588. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  41589. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41590. func (m *WxCardMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  41591. if !m.op.Is(OpUpdateOne) {
  41592. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  41593. }
  41594. if m.id == nil || m.oldValue == nil {
  41595. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  41596. }
  41597. oldValue, err := m.oldValue(ctx)
  41598. if err != nil {
  41599. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  41600. }
  41601. return oldValue.CreatedAt, nil
  41602. }
  41603. // ResetCreatedAt resets all changes to the "created_at" field.
  41604. func (m *WxCardMutation) ResetCreatedAt() {
  41605. m.created_at = nil
  41606. }
  41607. // SetUpdatedAt sets the "updated_at" field.
  41608. func (m *WxCardMutation) SetUpdatedAt(t time.Time) {
  41609. m.updated_at = &t
  41610. }
  41611. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  41612. func (m *WxCardMutation) UpdatedAt() (r time.Time, exists bool) {
  41613. v := m.updated_at
  41614. if v == nil {
  41615. return
  41616. }
  41617. return *v, true
  41618. }
  41619. // OldUpdatedAt returns the old "updated_at" field's value of the WxCard entity.
  41620. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  41621. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41622. func (m *WxCardMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  41623. if !m.op.Is(OpUpdateOne) {
  41624. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  41625. }
  41626. if m.id == nil || m.oldValue == nil {
  41627. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  41628. }
  41629. oldValue, err := m.oldValue(ctx)
  41630. if err != nil {
  41631. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  41632. }
  41633. return oldValue.UpdatedAt, nil
  41634. }
  41635. // ResetUpdatedAt resets all changes to the "updated_at" field.
  41636. func (m *WxCardMutation) ResetUpdatedAt() {
  41637. m.updated_at = nil
  41638. }
  41639. // SetDeletedAt sets the "deleted_at" field.
  41640. func (m *WxCardMutation) SetDeletedAt(t time.Time) {
  41641. m.deleted_at = &t
  41642. }
  41643. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  41644. func (m *WxCardMutation) DeletedAt() (r time.Time, exists bool) {
  41645. v := m.deleted_at
  41646. if v == nil {
  41647. return
  41648. }
  41649. return *v, true
  41650. }
  41651. // OldDeletedAt returns the old "deleted_at" field's value of the WxCard entity.
  41652. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  41653. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41654. func (m *WxCardMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  41655. if !m.op.Is(OpUpdateOne) {
  41656. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  41657. }
  41658. if m.id == nil || m.oldValue == nil {
  41659. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  41660. }
  41661. oldValue, err := m.oldValue(ctx)
  41662. if err != nil {
  41663. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  41664. }
  41665. return oldValue.DeletedAt, nil
  41666. }
  41667. // ClearDeletedAt clears the value of the "deleted_at" field.
  41668. func (m *WxCardMutation) ClearDeletedAt() {
  41669. m.deleted_at = nil
  41670. m.clearedFields[wxcard.FieldDeletedAt] = struct{}{}
  41671. }
  41672. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  41673. func (m *WxCardMutation) DeletedAtCleared() bool {
  41674. _, ok := m.clearedFields[wxcard.FieldDeletedAt]
  41675. return ok
  41676. }
  41677. // ResetDeletedAt resets all changes to the "deleted_at" field.
  41678. func (m *WxCardMutation) ResetDeletedAt() {
  41679. m.deleted_at = nil
  41680. delete(m.clearedFields, wxcard.FieldDeletedAt)
  41681. }
  41682. // SetUserID sets the "user_id" field.
  41683. func (m *WxCardMutation) SetUserID(u uint64) {
  41684. m.user_id = &u
  41685. m.adduser_id = nil
  41686. }
  41687. // UserID returns the value of the "user_id" field in the mutation.
  41688. func (m *WxCardMutation) UserID() (r uint64, exists bool) {
  41689. v := m.user_id
  41690. if v == nil {
  41691. return
  41692. }
  41693. return *v, true
  41694. }
  41695. // OldUserID returns the old "user_id" field's value of the WxCard entity.
  41696. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  41697. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41698. func (m *WxCardMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  41699. if !m.op.Is(OpUpdateOne) {
  41700. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  41701. }
  41702. if m.id == nil || m.oldValue == nil {
  41703. return v, errors.New("OldUserID requires an ID field in the mutation")
  41704. }
  41705. oldValue, err := m.oldValue(ctx)
  41706. if err != nil {
  41707. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  41708. }
  41709. return oldValue.UserID, nil
  41710. }
  41711. // AddUserID adds u to the "user_id" field.
  41712. func (m *WxCardMutation) AddUserID(u int64) {
  41713. if m.adduser_id != nil {
  41714. *m.adduser_id += u
  41715. } else {
  41716. m.adduser_id = &u
  41717. }
  41718. }
  41719. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  41720. func (m *WxCardMutation) AddedUserID() (r int64, exists bool) {
  41721. v := m.adduser_id
  41722. if v == nil {
  41723. return
  41724. }
  41725. return *v, true
  41726. }
  41727. // ClearUserID clears the value of the "user_id" field.
  41728. func (m *WxCardMutation) ClearUserID() {
  41729. m.user_id = nil
  41730. m.adduser_id = nil
  41731. m.clearedFields[wxcard.FieldUserID] = struct{}{}
  41732. }
  41733. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  41734. func (m *WxCardMutation) UserIDCleared() bool {
  41735. _, ok := m.clearedFields[wxcard.FieldUserID]
  41736. return ok
  41737. }
  41738. // ResetUserID resets all changes to the "user_id" field.
  41739. func (m *WxCardMutation) ResetUserID() {
  41740. m.user_id = nil
  41741. m.adduser_id = nil
  41742. delete(m.clearedFields, wxcard.FieldUserID)
  41743. }
  41744. // SetWxUserID sets the "wx_user_id" field.
  41745. func (m *WxCardMutation) SetWxUserID(u uint64) {
  41746. m.wx_user_id = &u
  41747. m.addwx_user_id = nil
  41748. }
  41749. // WxUserID returns the value of the "wx_user_id" field in the mutation.
  41750. func (m *WxCardMutation) WxUserID() (r uint64, exists bool) {
  41751. v := m.wx_user_id
  41752. if v == nil {
  41753. return
  41754. }
  41755. return *v, true
  41756. }
  41757. // OldWxUserID returns the old "wx_user_id" field's value of the WxCard entity.
  41758. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  41759. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41760. func (m *WxCardMutation) OldWxUserID(ctx context.Context) (v uint64, err error) {
  41761. if !m.op.Is(OpUpdateOne) {
  41762. return v, errors.New("OldWxUserID is only allowed on UpdateOne operations")
  41763. }
  41764. if m.id == nil || m.oldValue == nil {
  41765. return v, errors.New("OldWxUserID requires an ID field in the mutation")
  41766. }
  41767. oldValue, err := m.oldValue(ctx)
  41768. if err != nil {
  41769. return v, fmt.Errorf("querying old value for OldWxUserID: %w", err)
  41770. }
  41771. return oldValue.WxUserID, nil
  41772. }
  41773. // AddWxUserID adds u to the "wx_user_id" field.
  41774. func (m *WxCardMutation) AddWxUserID(u int64) {
  41775. if m.addwx_user_id != nil {
  41776. *m.addwx_user_id += u
  41777. } else {
  41778. m.addwx_user_id = &u
  41779. }
  41780. }
  41781. // AddedWxUserID returns the value that was added to the "wx_user_id" field in this mutation.
  41782. func (m *WxCardMutation) AddedWxUserID() (r int64, exists bool) {
  41783. v := m.addwx_user_id
  41784. if v == nil {
  41785. return
  41786. }
  41787. return *v, true
  41788. }
  41789. // ClearWxUserID clears the value of the "wx_user_id" field.
  41790. func (m *WxCardMutation) ClearWxUserID() {
  41791. m.wx_user_id = nil
  41792. m.addwx_user_id = nil
  41793. m.clearedFields[wxcard.FieldWxUserID] = struct{}{}
  41794. }
  41795. // WxUserIDCleared returns if the "wx_user_id" field was cleared in this mutation.
  41796. func (m *WxCardMutation) WxUserIDCleared() bool {
  41797. _, ok := m.clearedFields[wxcard.FieldWxUserID]
  41798. return ok
  41799. }
  41800. // ResetWxUserID resets all changes to the "wx_user_id" field.
  41801. func (m *WxCardMutation) ResetWxUserID() {
  41802. m.wx_user_id = nil
  41803. m.addwx_user_id = nil
  41804. delete(m.clearedFields, wxcard.FieldWxUserID)
  41805. }
  41806. // SetAvatar sets the "avatar" field.
  41807. func (m *WxCardMutation) SetAvatar(s string) {
  41808. m.avatar = &s
  41809. }
  41810. // Avatar returns the value of the "avatar" field in the mutation.
  41811. func (m *WxCardMutation) Avatar() (r string, exists bool) {
  41812. v := m.avatar
  41813. if v == nil {
  41814. return
  41815. }
  41816. return *v, true
  41817. }
  41818. // OldAvatar returns the old "avatar" field's value of the WxCard entity.
  41819. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  41820. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41821. func (m *WxCardMutation) OldAvatar(ctx context.Context) (v string, err error) {
  41822. if !m.op.Is(OpUpdateOne) {
  41823. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  41824. }
  41825. if m.id == nil || m.oldValue == nil {
  41826. return v, errors.New("OldAvatar requires an ID field in the mutation")
  41827. }
  41828. oldValue, err := m.oldValue(ctx)
  41829. if err != nil {
  41830. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  41831. }
  41832. return oldValue.Avatar, nil
  41833. }
  41834. // ResetAvatar resets all changes to the "avatar" field.
  41835. func (m *WxCardMutation) ResetAvatar() {
  41836. m.avatar = nil
  41837. }
  41838. // SetLogo sets the "logo" field.
  41839. func (m *WxCardMutation) SetLogo(s string) {
  41840. m.logo = &s
  41841. }
  41842. // Logo returns the value of the "logo" field in the mutation.
  41843. func (m *WxCardMutation) Logo() (r string, exists bool) {
  41844. v := m.logo
  41845. if v == nil {
  41846. return
  41847. }
  41848. return *v, true
  41849. }
  41850. // OldLogo returns the old "logo" field's value of the WxCard entity.
  41851. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  41852. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41853. func (m *WxCardMutation) OldLogo(ctx context.Context) (v string, err error) {
  41854. if !m.op.Is(OpUpdateOne) {
  41855. return v, errors.New("OldLogo is only allowed on UpdateOne operations")
  41856. }
  41857. if m.id == nil || m.oldValue == nil {
  41858. return v, errors.New("OldLogo requires an ID field in the mutation")
  41859. }
  41860. oldValue, err := m.oldValue(ctx)
  41861. if err != nil {
  41862. return v, fmt.Errorf("querying old value for OldLogo: %w", err)
  41863. }
  41864. return oldValue.Logo, nil
  41865. }
  41866. // ResetLogo resets all changes to the "logo" field.
  41867. func (m *WxCardMutation) ResetLogo() {
  41868. m.logo = nil
  41869. }
  41870. // SetName sets the "name" field.
  41871. func (m *WxCardMutation) SetName(s string) {
  41872. m.name = &s
  41873. }
  41874. // Name returns the value of the "name" field in the mutation.
  41875. func (m *WxCardMutation) Name() (r string, exists bool) {
  41876. v := m.name
  41877. if v == nil {
  41878. return
  41879. }
  41880. return *v, true
  41881. }
  41882. // OldName returns the old "name" field's value of the WxCard entity.
  41883. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  41884. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41885. func (m *WxCardMutation) OldName(ctx context.Context) (v string, err error) {
  41886. if !m.op.Is(OpUpdateOne) {
  41887. return v, errors.New("OldName is only allowed on UpdateOne operations")
  41888. }
  41889. if m.id == nil || m.oldValue == nil {
  41890. return v, errors.New("OldName requires an ID field in the mutation")
  41891. }
  41892. oldValue, err := m.oldValue(ctx)
  41893. if err != nil {
  41894. return v, fmt.Errorf("querying old value for OldName: %w", err)
  41895. }
  41896. return oldValue.Name, nil
  41897. }
  41898. // ResetName resets all changes to the "name" field.
  41899. func (m *WxCardMutation) ResetName() {
  41900. m.name = nil
  41901. }
  41902. // SetCompany sets the "company" field.
  41903. func (m *WxCardMutation) SetCompany(s string) {
  41904. m.company = &s
  41905. }
  41906. // Company returns the value of the "company" field in the mutation.
  41907. func (m *WxCardMutation) Company() (r string, exists bool) {
  41908. v := m.company
  41909. if v == nil {
  41910. return
  41911. }
  41912. return *v, true
  41913. }
  41914. // OldCompany returns the old "company" field's value of the WxCard entity.
  41915. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  41916. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41917. func (m *WxCardMutation) OldCompany(ctx context.Context) (v string, err error) {
  41918. if !m.op.Is(OpUpdateOne) {
  41919. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  41920. }
  41921. if m.id == nil || m.oldValue == nil {
  41922. return v, errors.New("OldCompany requires an ID field in the mutation")
  41923. }
  41924. oldValue, err := m.oldValue(ctx)
  41925. if err != nil {
  41926. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  41927. }
  41928. return oldValue.Company, nil
  41929. }
  41930. // ResetCompany resets all changes to the "company" field.
  41931. func (m *WxCardMutation) ResetCompany() {
  41932. m.company = nil
  41933. }
  41934. // SetAddress sets the "address" field.
  41935. func (m *WxCardMutation) SetAddress(s string) {
  41936. m.address = &s
  41937. }
  41938. // Address returns the value of the "address" field in the mutation.
  41939. func (m *WxCardMutation) Address() (r string, exists bool) {
  41940. v := m.address
  41941. if v == nil {
  41942. return
  41943. }
  41944. return *v, true
  41945. }
  41946. // OldAddress returns the old "address" field's value of the WxCard entity.
  41947. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  41948. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41949. func (m *WxCardMutation) OldAddress(ctx context.Context) (v string, err error) {
  41950. if !m.op.Is(OpUpdateOne) {
  41951. return v, errors.New("OldAddress is only allowed on UpdateOne operations")
  41952. }
  41953. if m.id == nil || m.oldValue == nil {
  41954. return v, errors.New("OldAddress requires an ID field in the mutation")
  41955. }
  41956. oldValue, err := m.oldValue(ctx)
  41957. if err != nil {
  41958. return v, fmt.Errorf("querying old value for OldAddress: %w", err)
  41959. }
  41960. return oldValue.Address, nil
  41961. }
  41962. // ResetAddress resets all changes to the "address" field.
  41963. func (m *WxCardMutation) ResetAddress() {
  41964. m.address = nil
  41965. }
  41966. // SetPhone sets the "phone" field.
  41967. func (m *WxCardMutation) SetPhone(s string) {
  41968. m.phone = &s
  41969. }
  41970. // Phone returns the value of the "phone" field in the mutation.
  41971. func (m *WxCardMutation) Phone() (r string, exists bool) {
  41972. v := m.phone
  41973. if v == nil {
  41974. return
  41975. }
  41976. return *v, true
  41977. }
  41978. // OldPhone returns the old "phone" field's value of the WxCard entity.
  41979. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  41980. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41981. func (m *WxCardMutation) OldPhone(ctx context.Context) (v string, err error) {
  41982. if !m.op.Is(OpUpdateOne) {
  41983. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  41984. }
  41985. if m.id == nil || m.oldValue == nil {
  41986. return v, errors.New("OldPhone requires an ID field in the mutation")
  41987. }
  41988. oldValue, err := m.oldValue(ctx)
  41989. if err != nil {
  41990. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  41991. }
  41992. return oldValue.Phone, nil
  41993. }
  41994. // ResetPhone resets all changes to the "phone" field.
  41995. func (m *WxCardMutation) ResetPhone() {
  41996. m.phone = nil
  41997. }
  41998. // SetOfficialAccount sets the "official_account" field.
  41999. func (m *WxCardMutation) SetOfficialAccount(s string) {
  42000. m.official_account = &s
  42001. }
  42002. // OfficialAccount returns the value of the "official_account" field in the mutation.
  42003. func (m *WxCardMutation) OfficialAccount() (r string, exists bool) {
  42004. v := m.official_account
  42005. if v == nil {
  42006. return
  42007. }
  42008. return *v, true
  42009. }
  42010. // OldOfficialAccount returns the old "official_account" field's value of the WxCard entity.
  42011. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  42012. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42013. func (m *WxCardMutation) OldOfficialAccount(ctx context.Context) (v string, err error) {
  42014. if !m.op.Is(OpUpdateOne) {
  42015. return v, errors.New("OldOfficialAccount is only allowed on UpdateOne operations")
  42016. }
  42017. if m.id == nil || m.oldValue == nil {
  42018. return v, errors.New("OldOfficialAccount requires an ID field in the mutation")
  42019. }
  42020. oldValue, err := m.oldValue(ctx)
  42021. if err != nil {
  42022. return v, fmt.Errorf("querying old value for OldOfficialAccount: %w", err)
  42023. }
  42024. return oldValue.OfficialAccount, nil
  42025. }
  42026. // ResetOfficialAccount resets all changes to the "official_account" field.
  42027. func (m *WxCardMutation) ResetOfficialAccount() {
  42028. m.official_account = nil
  42029. }
  42030. // SetWechatAccount sets the "wechat_account" field.
  42031. func (m *WxCardMutation) SetWechatAccount(s string) {
  42032. m.wechat_account = &s
  42033. }
  42034. // WechatAccount returns the value of the "wechat_account" field in the mutation.
  42035. func (m *WxCardMutation) WechatAccount() (r string, exists bool) {
  42036. v := m.wechat_account
  42037. if v == nil {
  42038. return
  42039. }
  42040. return *v, true
  42041. }
  42042. // OldWechatAccount returns the old "wechat_account" field's value of the WxCard entity.
  42043. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  42044. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42045. func (m *WxCardMutation) OldWechatAccount(ctx context.Context) (v string, err error) {
  42046. if !m.op.Is(OpUpdateOne) {
  42047. return v, errors.New("OldWechatAccount is only allowed on UpdateOne operations")
  42048. }
  42049. if m.id == nil || m.oldValue == nil {
  42050. return v, errors.New("OldWechatAccount requires an ID field in the mutation")
  42051. }
  42052. oldValue, err := m.oldValue(ctx)
  42053. if err != nil {
  42054. return v, fmt.Errorf("querying old value for OldWechatAccount: %w", err)
  42055. }
  42056. return oldValue.WechatAccount, nil
  42057. }
  42058. // ResetWechatAccount resets all changes to the "wechat_account" field.
  42059. func (m *WxCardMutation) ResetWechatAccount() {
  42060. m.wechat_account = nil
  42061. }
  42062. // SetEmail sets the "email" field.
  42063. func (m *WxCardMutation) SetEmail(s string) {
  42064. m.email = &s
  42065. }
  42066. // Email returns the value of the "email" field in the mutation.
  42067. func (m *WxCardMutation) Email() (r string, exists bool) {
  42068. v := m.email
  42069. if v == nil {
  42070. return
  42071. }
  42072. return *v, true
  42073. }
  42074. // OldEmail returns the old "email" field's value of the WxCard entity.
  42075. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  42076. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42077. func (m *WxCardMutation) OldEmail(ctx context.Context) (v string, err error) {
  42078. if !m.op.Is(OpUpdateOne) {
  42079. return v, errors.New("OldEmail is only allowed on UpdateOne operations")
  42080. }
  42081. if m.id == nil || m.oldValue == nil {
  42082. return v, errors.New("OldEmail requires an ID field in the mutation")
  42083. }
  42084. oldValue, err := m.oldValue(ctx)
  42085. if err != nil {
  42086. return v, fmt.Errorf("querying old value for OldEmail: %w", err)
  42087. }
  42088. return oldValue.Email, nil
  42089. }
  42090. // ClearEmail clears the value of the "email" field.
  42091. func (m *WxCardMutation) ClearEmail() {
  42092. m.email = nil
  42093. m.clearedFields[wxcard.FieldEmail] = struct{}{}
  42094. }
  42095. // EmailCleared returns if the "email" field was cleared in this mutation.
  42096. func (m *WxCardMutation) EmailCleared() bool {
  42097. _, ok := m.clearedFields[wxcard.FieldEmail]
  42098. return ok
  42099. }
  42100. // ResetEmail resets all changes to the "email" field.
  42101. func (m *WxCardMutation) ResetEmail() {
  42102. m.email = nil
  42103. delete(m.clearedFields, wxcard.FieldEmail)
  42104. }
  42105. // SetAPIBase sets the "api_base" field.
  42106. func (m *WxCardMutation) SetAPIBase(s string) {
  42107. m.api_base = &s
  42108. }
  42109. // APIBase returns the value of the "api_base" field in the mutation.
  42110. func (m *WxCardMutation) APIBase() (r string, exists bool) {
  42111. v := m.api_base
  42112. if v == nil {
  42113. return
  42114. }
  42115. return *v, true
  42116. }
  42117. // OldAPIBase returns the old "api_base" field's value of the WxCard entity.
  42118. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  42119. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42120. func (m *WxCardMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  42121. if !m.op.Is(OpUpdateOne) {
  42122. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  42123. }
  42124. if m.id == nil || m.oldValue == nil {
  42125. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  42126. }
  42127. oldValue, err := m.oldValue(ctx)
  42128. if err != nil {
  42129. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  42130. }
  42131. return oldValue.APIBase, nil
  42132. }
  42133. // ClearAPIBase clears the value of the "api_base" field.
  42134. func (m *WxCardMutation) ClearAPIBase() {
  42135. m.api_base = nil
  42136. m.clearedFields[wxcard.FieldAPIBase] = struct{}{}
  42137. }
  42138. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  42139. func (m *WxCardMutation) APIBaseCleared() bool {
  42140. _, ok := m.clearedFields[wxcard.FieldAPIBase]
  42141. return ok
  42142. }
  42143. // ResetAPIBase resets all changes to the "api_base" field.
  42144. func (m *WxCardMutation) ResetAPIBase() {
  42145. m.api_base = nil
  42146. delete(m.clearedFields, wxcard.FieldAPIBase)
  42147. }
  42148. // SetAPIKey sets the "api_key" field.
  42149. func (m *WxCardMutation) SetAPIKey(s string) {
  42150. m.api_key = &s
  42151. }
  42152. // APIKey returns the value of the "api_key" field in the mutation.
  42153. func (m *WxCardMutation) APIKey() (r string, exists bool) {
  42154. v := m.api_key
  42155. if v == nil {
  42156. return
  42157. }
  42158. return *v, true
  42159. }
  42160. // OldAPIKey returns the old "api_key" field's value of the WxCard entity.
  42161. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  42162. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42163. func (m *WxCardMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  42164. if !m.op.Is(OpUpdateOne) {
  42165. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  42166. }
  42167. if m.id == nil || m.oldValue == nil {
  42168. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  42169. }
  42170. oldValue, err := m.oldValue(ctx)
  42171. if err != nil {
  42172. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  42173. }
  42174. return oldValue.APIKey, nil
  42175. }
  42176. // ClearAPIKey clears the value of the "api_key" field.
  42177. func (m *WxCardMutation) ClearAPIKey() {
  42178. m.api_key = nil
  42179. m.clearedFields[wxcard.FieldAPIKey] = struct{}{}
  42180. }
  42181. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  42182. func (m *WxCardMutation) APIKeyCleared() bool {
  42183. _, ok := m.clearedFields[wxcard.FieldAPIKey]
  42184. return ok
  42185. }
  42186. // ResetAPIKey resets all changes to the "api_key" field.
  42187. func (m *WxCardMutation) ResetAPIKey() {
  42188. m.api_key = nil
  42189. delete(m.clearedFields, wxcard.FieldAPIKey)
  42190. }
  42191. // SetAiInfo sets the "ai_info" field.
  42192. func (m *WxCardMutation) SetAiInfo(s string) {
  42193. m.ai_info = &s
  42194. }
  42195. // AiInfo returns the value of the "ai_info" field in the mutation.
  42196. func (m *WxCardMutation) AiInfo() (r string, exists bool) {
  42197. v := m.ai_info
  42198. if v == nil {
  42199. return
  42200. }
  42201. return *v, true
  42202. }
  42203. // OldAiInfo returns the old "ai_info" field's value of the WxCard entity.
  42204. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  42205. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42206. func (m *WxCardMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  42207. if !m.op.Is(OpUpdateOne) {
  42208. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  42209. }
  42210. if m.id == nil || m.oldValue == nil {
  42211. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  42212. }
  42213. oldValue, err := m.oldValue(ctx)
  42214. if err != nil {
  42215. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  42216. }
  42217. return oldValue.AiInfo, nil
  42218. }
  42219. // ClearAiInfo clears the value of the "ai_info" field.
  42220. func (m *WxCardMutation) ClearAiInfo() {
  42221. m.ai_info = nil
  42222. m.clearedFields[wxcard.FieldAiInfo] = struct{}{}
  42223. }
  42224. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  42225. func (m *WxCardMutation) AiInfoCleared() bool {
  42226. _, ok := m.clearedFields[wxcard.FieldAiInfo]
  42227. return ok
  42228. }
  42229. // ResetAiInfo resets all changes to the "ai_info" field.
  42230. func (m *WxCardMutation) ResetAiInfo() {
  42231. m.ai_info = nil
  42232. delete(m.clearedFields, wxcard.FieldAiInfo)
  42233. }
  42234. // SetIntro sets the "intro" field.
  42235. func (m *WxCardMutation) SetIntro(s string) {
  42236. m.intro = &s
  42237. }
  42238. // Intro returns the value of the "intro" field in the mutation.
  42239. func (m *WxCardMutation) Intro() (r string, exists bool) {
  42240. v := m.intro
  42241. if v == nil {
  42242. return
  42243. }
  42244. return *v, true
  42245. }
  42246. // OldIntro returns the old "intro" field's value of the WxCard entity.
  42247. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  42248. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42249. func (m *WxCardMutation) OldIntro(ctx context.Context) (v string, err error) {
  42250. if !m.op.Is(OpUpdateOne) {
  42251. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  42252. }
  42253. if m.id == nil || m.oldValue == nil {
  42254. return v, errors.New("OldIntro requires an ID field in the mutation")
  42255. }
  42256. oldValue, err := m.oldValue(ctx)
  42257. if err != nil {
  42258. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  42259. }
  42260. return oldValue.Intro, nil
  42261. }
  42262. // ClearIntro clears the value of the "intro" field.
  42263. func (m *WxCardMutation) ClearIntro() {
  42264. m.intro = nil
  42265. m.clearedFields[wxcard.FieldIntro] = struct{}{}
  42266. }
  42267. // IntroCleared returns if the "intro" field was cleared in this mutation.
  42268. func (m *WxCardMutation) IntroCleared() bool {
  42269. _, ok := m.clearedFields[wxcard.FieldIntro]
  42270. return ok
  42271. }
  42272. // ResetIntro resets all changes to the "intro" field.
  42273. func (m *WxCardMutation) ResetIntro() {
  42274. m.intro = nil
  42275. delete(m.clearedFields, wxcard.FieldIntro)
  42276. }
  42277. // Where appends a list predicates to the WxCardMutation builder.
  42278. func (m *WxCardMutation) Where(ps ...predicate.WxCard) {
  42279. m.predicates = append(m.predicates, ps...)
  42280. }
  42281. // WhereP appends storage-level predicates to the WxCardMutation builder. Using this method,
  42282. // users can use type-assertion to append predicates that do not depend on any generated package.
  42283. func (m *WxCardMutation) WhereP(ps ...func(*sql.Selector)) {
  42284. p := make([]predicate.WxCard, len(ps))
  42285. for i := range ps {
  42286. p[i] = ps[i]
  42287. }
  42288. m.Where(p...)
  42289. }
  42290. // Op returns the operation name.
  42291. func (m *WxCardMutation) Op() Op {
  42292. return m.op
  42293. }
  42294. // SetOp allows setting the mutation operation.
  42295. func (m *WxCardMutation) SetOp(op Op) {
  42296. m.op = op
  42297. }
  42298. // Type returns the node type of this mutation (WxCard).
  42299. func (m *WxCardMutation) Type() string {
  42300. return m.typ
  42301. }
  42302. // Fields returns all fields that were changed during this mutation. Note that in
  42303. // order to get all numeric fields that were incremented/decremented, call
  42304. // AddedFields().
  42305. func (m *WxCardMutation) Fields() []string {
  42306. fields := make([]string, 0, 18)
  42307. if m.created_at != nil {
  42308. fields = append(fields, wxcard.FieldCreatedAt)
  42309. }
  42310. if m.updated_at != nil {
  42311. fields = append(fields, wxcard.FieldUpdatedAt)
  42312. }
  42313. if m.deleted_at != nil {
  42314. fields = append(fields, wxcard.FieldDeletedAt)
  42315. }
  42316. if m.user_id != nil {
  42317. fields = append(fields, wxcard.FieldUserID)
  42318. }
  42319. if m.wx_user_id != nil {
  42320. fields = append(fields, wxcard.FieldWxUserID)
  42321. }
  42322. if m.avatar != nil {
  42323. fields = append(fields, wxcard.FieldAvatar)
  42324. }
  42325. if m.logo != nil {
  42326. fields = append(fields, wxcard.FieldLogo)
  42327. }
  42328. if m.name != nil {
  42329. fields = append(fields, wxcard.FieldName)
  42330. }
  42331. if m.company != nil {
  42332. fields = append(fields, wxcard.FieldCompany)
  42333. }
  42334. if m.address != nil {
  42335. fields = append(fields, wxcard.FieldAddress)
  42336. }
  42337. if m.phone != nil {
  42338. fields = append(fields, wxcard.FieldPhone)
  42339. }
  42340. if m.official_account != nil {
  42341. fields = append(fields, wxcard.FieldOfficialAccount)
  42342. }
  42343. if m.wechat_account != nil {
  42344. fields = append(fields, wxcard.FieldWechatAccount)
  42345. }
  42346. if m.email != nil {
  42347. fields = append(fields, wxcard.FieldEmail)
  42348. }
  42349. if m.api_base != nil {
  42350. fields = append(fields, wxcard.FieldAPIBase)
  42351. }
  42352. if m.api_key != nil {
  42353. fields = append(fields, wxcard.FieldAPIKey)
  42354. }
  42355. if m.ai_info != nil {
  42356. fields = append(fields, wxcard.FieldAiInfo)
  42357. }
  42358. if m.intro != nil {
  42359. fields = append(fields, wxcard.FieldIntro)
  42360. }
  42361. return fields
  42362. }
  42363. // Field returns the value of a field with the given name. The second boolean
  42364. // return value indicates that this field was not set, or was not defined in the
  42365. // schema.
  42366. func (m *WxCardMutation) Field(name string) (ent.Value, bool) {
  42367. switch name {
  42368. case wxcard.FieldCreatedAt:
  42369. return m.CreatedAt()
  42370. case wxcard.FieldUpdatedAt:
  42371. return m.UpdatedAt()
  42372. case wxcard.FieldDeletedAt:
  42373. return m.DeletedAt()
  42374. case wxcard.FieldUserID:
  42375. return m.UserID()
  42376. case wxcard.FieldWxUserID:
  42377. return m.WxUserID()
  42378. case wxcard.FieldAvatar:
  42379. return m.Avatar()
  42380. case wxcard.FieldLogo:
  42381. return m.Logo()
  42382. case wxcard.FieldName:
  42383. return m.Name()
  42384. case wxcard.FieldCompany:
  42385. return m.Company()
  42386. case wxcard.FieldAddress:
  42387. return m.Address()
  42388. case wxcard.FieldPhone:
  42389. return m.Phone()
  42390. case wxcard.FieldOfficialAccount:
  42391. return m.OfficialAccount()
  42392. case wxcard.FieldWechatAccount:
  42393. return m.WechatAccount()
  42394. case wxcard.FieldEmail:
  42395. return m.Email()
  42396. case wxcard.FieldAPIBase:
  42397. return m.APIBase()
  42398. case wxcard.FieldAPIKey:
  42399. return m.APIKey()
  42400. case wxcard.FieldAiInfo:
  42401. return m.AiInfo()
  42402. case wxcard.FieldIntro:
  42403. return m.Intro()
  42404. }
  42405. return nil, false
  42406. }
  42407. // OldField returns the old value of the field from the database. An error is
  42408. // returned if the mutation operation is not UpdateOne, or the query to the
  42409. // database failed.
  42410. func (m *WxCardMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  42411. switch name {
  42412. case wxcard.FieldCreatedAt:
  42413. return m.OldCreatedAt(ctx)
  42414. case wxcard.FieldUpdatedAt:
  42415. return m.OldUpdatedAt(ctx)
  42416. case wxcard.FieldDeletedAt:
  42417. return m.OldDeletedAt(ctx)
  42418. case wxcard.FieldUserID:
  42419. return m.OldUserID(ctx)
  42420. case wxcard.FieldWxUserID:
  42421. return m.OldWxUserID(ctx)
  42422. case wxcard.FieldAvatar:
  42423. return m.OldAvatar(ctx)
  42424. case wxcard.FieldLogo:
  42425. return m.OldLogo(ctx)
  42426. case wxcard.FieldName:
  42427. return m.OldName(ctx)
  42428. case wxcard.FieldCompany:
  42429. return m.OldCompany(ctx)
  42430. case wxcard.FieldAddress:
  42431. return m.OldAddress(ctx)
  42432. case wxcard.FieldPhone:
  42433. return m.OldPhone(ctx)
  42434. case wxcard.FieldOfficialAccount:
  42435. return m.OldOfficialAccount(ctx)
  42436. case wxcard.FieldWechatAccount:
  42437. return m.OldWechatAccount(ctx)
  42438. case wxcard.FieldEmail:
  42439. return m.OldEmail(ctx)
  42440. case wxcard.FieldAPIBase:
  42441. return m.OldAPIBase(ctx)
  42442. case wxcard.FieldAPIKey:
  42443. return m.OldAPIKey(ctx)
  42444. case wxcard.FieldAiInfo:
  42445. return m.OldAiInfo(ctx)
  42446. case wxcard.FieldIntro:
  42447. return m.OldIntro(ctx)
  42448. }
  42449. return nil, fmt.Errorf("unknown WxCard field %s", name)
  42450. }
  42451. // SetField sets the value of a field with the given name. It returns an error if
  42452. // the field is not defined in the schema, or if the type mismatched the field
  42453. // type.
  42454. func (m *WxCardMutation) SetField(name string, value ent.Value) error {
  42455. switch name {
  42456. case wxcard.FieldCreatedAt:
  42457. v, ok := value.(time.Time)
  42458. if !ok {
  42459. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42460. }
  42461. m.SetCreatedAt(v)
  42462. return nil
  42463. case wxcard.FieldUpdatedAt:
  42464. v, ok := value.(time.Time)
  42465. if !ok {
  42466. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42467. }
  42468. m.SetUpdatedAt(v)
  42469. return nil
  42470. case wxcard.FieldDeletedAt:
  42471. v, ok := value.(time.Time)
  42472. if !ok {
  42473. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42474. }
  42475. m.SetDeletedAt(v)
  42476. return nil
  42477. case wxcard.FieldUserID:
  42478. v, ok := value.(uint64)
  42479. if !ok {
  42480. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42481. }
  42482. m.SetUserID(v)
  42483. return nil
  42484. case wxcard.FieldWxUserID:
  42485. v, ok := value.(uint64)
  42486. if !ok {
  42487. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42488. }
  42489. m.SetWxUserID(v)
  42490. return nil
  42491. case wxcard.FieldAvatar:
  42492. v, ok := value.(string)
  42493. if !ok {
  42494. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42495. }
  42496. m.SetAvatar(v)
  42497. return nil
  42498. case wxcard.FieldLogo:
  42499. v, ok := value.(string)
  42500. if !ok {
  42501. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42502. }
  42503. m.SetLogo(v)
  42504. return nil
  42505. case wxcard.FieldName:
  42506. v, ok := value.(string)
  42507. if !ok {
  42508. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42509. }
  42510. m.SetName(v)
  42511. return nil
  42512. case wxcard.FieldCompany:
  42513. v, ok := value.(string)
  42514. if !ok {
  42515. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42516. }
  42517. m.SetCompany(v)
  42518. return nil
  42519. case wxcard.FieldAddress:
  42520. v, ok := value.(string)
  42521. if !ok {
  42522. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42523. }
  42524. m.SetAddress(v)
  42525. return nil
  42526. case wxcard.FieldPhone:
  42527. v, ok := value.(string)
  42528. if !ok {
  42529. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42530. }
  42531. m.SetPhone(v)
  42532. return nil
  42533. case wxcard.FieldOfficialAccount:
  42534. v, ok := value.(string)
  42535. if !ok {
  42536. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42537. }
  42538. m.SetOfficialAccount(v)
  42539. return nil
  42540. case wxcard.FieldWechatAccount:
  42541. v, ok := value.(string)
  42542. if !ok {
  42543. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42544. }
  42545. m.SetWechatAccount(v)
  42546. return nil
  42547. case wxcard.FieldEmail:
  42548. v, ok := value.(string)
  42549. if !ok {
  42550. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42551. }
  42552. m.SetEmail(v)
  42553. return nil
  42554. case wxcard.FieldAPIBase:
  42555. v, ok := value.(string)
  42556. if !ok {
  42557. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42558. }
  42559. m.SetAPIBase(v)
  42560. return nil
  42561. case wxcard.FieldAPIKey:
  42562. v, ok := value.(string)
  42563. if !ok {
  42564. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42565. }
  42566. m.SetAPIKey(v)
  42567. return nil
  42568. case wxcard.FieldAiInfo:
  42569. v, ok := value.(string)
  42570. if !ok {
  42571. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42572. }
  42573. m.SetAiInfo(v)
  42574. return nil
  42575. case wxcard.FieldIntro:
  42576. v, ok := value.(string)
  42577. if !ok {
  42578. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42579. }
  42580. m.SetIntro(v)
  42581. return nil
  42582. }
  42583. return fmt.Errorf("unknown WxCard field %s", name)
  42584. }
  42585. // AddedFields returns all numeric fields that were incremented/decremented during
  42586. // this mutation.
  42587. func (m *WxCardMutation) AddedFields() []string {
  42588. var fields []string
  42589. if m.adduser_id != nil {
  42590. fields = append(fields, wxcard.FieldUserID)
  42591. }
  42592. if m.addwx_user_id != nil {
  42593. fields = append(fields, wxcard.FieldWxUserID)
  42594. }
  42595. return fields
  42596. }
  42597. // AddedField returns the numeric value that was incremented/decremented on a field
  42598. // with the given name. The second boolean return value indicates that this field
  42599. // was not set, or was not defined in the schema.
  42600. func (m *WxCardMutation) AddedField(name string) (ent.Value, bool) {
  42601. switch name {
  42602. case wxcard.FieldUserID:
  42603. return m.AddedUserID()
  42604. case wxcard.FieldWxUserID:
  42605. return m.AddedWxUserID()
  42606. }
  42607. return nil, false
  42608. }
  42609. // AddField adds the value to the field with the given name. It returns an error if
  42610. // the field is not defined in the schema, or if the type mismatched the field
  42611. // type.
  42612. func (m *WxCardMutation) AddField(name string, value ent.Value) error {
  42613. switch name {
  42614. case wxcard.FieldUserID:
  42615. v, ok := value.(int64)
  42616. if !ok {
  42617. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42618. }
  42619. m.AddUserID(v)
  42620. return nil
  42621. case wxcard.FieldWxUserID:
  42622. v, ok := value.(int64)
  42623. if !ok {
  42624. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42625. }
  42626. m.AddWxUserID(v)
  42627. return nil
  42628. }
  42629. return fmt.Errorf("unknown WxCard numeric field %s", name)
  42630. }
  42631. // ClearedFields returns all nullable fields that were cleared during this
  42632. // mutation.
  42633. func (m *WxCardMutation) ClearedFields() []string {
  42634. var fields []string
  42635. if m.FieldCleared(wxcard.FieldDeletedAt) {
  42636. fields = append(fields, wxcard.FieldDeletedAt)
  42637. }
  42638. if m.FieldCleared(wxcard.FieldUserID) {
  42639. fields = append(fields, wxcard.FieldUserID)
  42640. }
  42641. if m.FieldCleared(wxcard.FieldWxUserID) {
  42642. fields = append(fields, wxcard.FieldWxUserID)
  42643. }
  42644. if m.FieldCleared(wxcard.FieldEmail) {
  42645. fields = append(fields, wxcard.FieldEmail)
  42646. }
  42647. if m.FieldCleared(wxcard.FieldAPIBase) {
  42648. fields = append(fields, wxcard.FieldAPIBase)
  42649. }
  42650. if m.FieldCleared(wxcard.FieldAPIKey) {
  42651. fields = append(fields, wxcard.FieldAPIKey)
  42652. }
  42653. if m.FieldCleared(wxcard.FieldAiInfo) {
  42654. fields = append(fields, wxcard.FieldAiInfo)
  42655. }
  42656. if m.FieldCleared(wxcard.FieldIntro) {
  42657. fields = append(fields, wxcard.FieldIntro)
  42658. }
  42659. return fields
  42660. }
  42661. // FieldCleared returns a boolean indicating if a field with the given name was
  42662. // cleared in this mutation.
  42663. func (m *WxCardMutation) FieldCleared(name string) bool {
  42664. _, ok := m.clearedFields[name]
  42665. return ok
  42666. }
  42667. // ClearField clears the value of the field with the given name. It returns an
  42668. // error if the field is not defined in the schema.
  42669. func (m *WxCardMutation) ClearField(name string) error {
  42670. switch name {
  42671. case wxcard.FieldDeletedAt:
  42672. m.ClearDeletedAt()
  42673. return nil
  42674. case wxcard.FieldUserID:
  42675. m.ClearUserID()
  42676. return nil
  42677. case wxcard.FieldWxUserID:
  42678. m.ClearWxUserID()
  42679. return nil
  42680. case wxcard.FieldEmail:
  42681. m.ClearEmail()
  42682. return nil
  42683. case wxcard.FieldAPIBase:
  42684. m.ClearAPIBase()
  42685. return nil
  42686. case wxcard.FieldAPIKey:
  42687. m.ClearAPIKey()
  42688. return nil
  42689. case wxcard.FieldAiInfo:
  42690. m.ClearAiInfo()
  42691. return nil
  42692. case wxcard.FieldIntro:
  42693. m.ClearIntro()
  42694. return nil
  42695. }
  42696. return fmt.Errorf("unknown WxCard nullable field %s", name)
  42697. }
  42698. // ResetField resets all changes in the mutation for the field with the given name.
  42699. // It returns an error if the field is not defined in the schema.
  42700. func (m *WxCardMutation) ResetField(name string) error {
  42701. switch name {
  42702. case wxcard.FieldCreatedAt:
  42703. m.ResetCreatedAt()
  42704. return nil
  42705. case wxcard.FieldUpdatedAt:
  42706. m.ResetUpdatedAt()
  42707. return nil
  42708. case wxcard.FieldDeletedAt:
  42709. m.ResetDeletedAt()
  42710. return nil
  42711. case wxcard.FieldUserID:
  42712. m.ResetUserID()
  42713. return nil
  42714. case wxcard.FieldWxUserID:
  42715. m.ResetWxUserID()
  42716. return nil
  42717. case wxcard.FieldAvatar:
  42718. m.ResetAvatar()
  42719. return nil
  42720. case wxcard.FieldLogo:
  42721. m.ResetLogo()
  42722. return nil
  42723. case wxcard.FieldName:
  42724. m.ResetName()
  42725. return nil
  42726. case wxcard.FieldCompany:
  42727. m.ResetCompany()
  42728. return nil
  42729. case wxcard.FieldAddress:
  42730. m.ResetAddress()
  42731. return nil
  42732. case wxcard.FieldPhone:
  42733. m.ResetPhone()
  42734. return nil
  42735. case wxcard.FieldOfficialAccount:
  42736. m.ResetOfficialAccount()
  42737. return nil
  42738. case wxcard.FieldWechatAccount:
  42739. m.ResetWechatAccount()
  42740. return nil
  42741. case wxcard.FieldEmail:
  42742. m.ResetEmail()
  42743. return nil
  42744. case wxcard.FieldAPIBase:
  42745. m.ResetAPIBase()
  42746. return nil
  42747. case wxcard.FieldAPIKey:
  42748. m.ResetAPIKey()
  42749. return nil
  42750. case wxcard.FieldAiInfo:
  42751. m.ResetAiInfo()
  42752. return nil
  42753. case wxcard.FieldIntro:
  42754. m.ResetIntro()
  42755. return nil
  42756. }
  42757. return fmt.Errorf("unknown WxCard field %s", name)
  42758. }
  42759. // AddedEdges returns all edge names that were set/added in this mutation.
  42760. func (m *WxCardMutation) AddedEdges() []string {
  42761. edges := make([]string, 0, 0)
  42762. return edges
  42763. }
  42764. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  42765. // name in this mutation.
  42766. func (m *WxCardMutation) AddedIDs(name string) []ent.Value {
  42767. return nil
  42768. }
  42769. // RemovedEdges returns all edge names that were removed in this mutation.
  42770. func (m *WxCardMutation) RemovedEdges() []string {
  42771. edges := make([]string, 0, 0)
  42772. return edges
  42773. }
  42774. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  42775. // the given name in this mutation.
  42776. func (m *WxCardMutation) RemovedIDs(name string) []ent.Value {
  42777. return nil
  42778. }
  42779. // ClearedEdges returns all edge names that were cleared in this mutation.
  42780. func (m *WxCardMutation) ClearedEdges() []string {
  42781. edges := make([]string, 0, 0)
  42782. return edges
  42783. }
  42784. // EdgeCleared returns a boolean which indicates if the edge with the given name
  42785. // was cleared in this mutation.
  42786. func (m *WxCardMutation) EdgeCleared(name string) bool {
  42787. return false
  42788. }
  42789. // ClearEdge clears the value of the edge with the given name. It returns an error
  42790. // if that edge is not defined in the schema.
  42791. func (m *WxCardMutation) ClearEdge(name string) error {
  42792. return fmt.Errorf("unknown WxCard unique edge %s", name)
  42793. }
  42794. // ResetEdge resets all changes to the edge with the given name in this mutation.
  42795. // It returns an error if the edge is not defined in the schema.
  42796. func (m *WxCardMutation) ResetEdge(name string) error {
  42797. return fmt.Errorf("unknown WxCard edge %s", name)
  42798. }
  42799. // WxCardUserMutation represents an operation that mutates the WxCardUser nodes in the graph.
  42800. type WxCardUserMutation struct {
  42801. config
  42802. op Op
  42803. typ string
  42804. id *uint64
  42805. created_at *time.Time
  42806. updated_at *time.Time
  42807. deleted_at *time.Time
  42808. wxid *string
  42809. account *string
  42810. avatar *string
  42811. nickname *string
  42812. remark *string
  42813. phone *string
  42814. open_id *string
  42815. union_id *string
  42816. session_key *string
  42817. is_vip *int
  42818. addis_vip *int
  42819. clearedFields map[string]struct{}
  42820. done bool
  42821. oldValue func(context.Context) (*WxCardUser, error)
  42822. predicates []predicate.WxCardUser
  42823. }
  42824. var _ ent.Mutation = (*WxCardUserMutation)(nil)
  42825. // wxcarduserOption allows management of the mutation configuration using functional options.
  42826. type wxcarduserOption func(*WxCardUserMutation)
  42827. // newWxCardUserMutation creates new mutation for the WxCardUser entity.
  42828. func newWxCardUserMutation(c config, op Op, opts ...wxcarduserOption) *WxCardUserMutation {
  42829. m := &WxCardUserMutation{
  42830. config: c,
  42831. op: op,
  42832. typ: TypeWxCardUser,
  42833. clearedFields: make(map[string]struct{}),
  42834. }
  42835. for _, opt := range opts {
  42836. opt(m)
  42837. }
  42838. return m
  42839. }
  42840. // withWxCardUserID sets the ID field of the mutation.
  42841. func withWxCardUserID(id uint64) wxcarduserOption {
  42842. return func(m *WxCardUserMutation) {
  42843. var (
  42844. err error
  42845. once sync.Once
  42846. value *WxCardUser
  42847. )
  42848. m.oldValue = func(ctx context.Context) (*WxCardUser, error) {
  42849. once.Do(func() {
  42850. if m.done {
  42851. err = errors.New("querying old values post mutation is not allowed")
  42852. } else {
  42853. value, err = m.Client().WxCardUser.Get(ctx, id)
  42854. }
  42855. })
  42856. return value, err
  42857. }
  42858. m.id = &id
  42859. }
  42860. }
  42861. // withWxCardUser sets the old WxCardUser of the mutation.
  42862. func withWxCardUser(node *WxCardUser) wxcarduserOption {
  42863. return func(m *WxCardUserMutation) {
  42864. m.oldValue = func(context.Context) (*WxCardUser, error) {
  42865. return node, nil
  42866. }
  42867. m.id = &node.ID
  42868. }
  42869. }
  42870. // Client returns a new `ent.Client` from the mutation. If the mutation was
  42871. // executed in a transaction (ent.Tx), a transactional client is returned.
  42872. func (m WxCardUserMutation) Client() *Client {
  42873. client := &Client{config: m.config}
  42874. client.init()
  42875. return client
  42876. }
  42877. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  42878. // it returns an error otherwise.
  42879. func (m WxCardUserMutation) Tx() (*Tx, error) {
  42880. if _, ok := m.driver.(*txDriver); !ok {
  42881. return nil, errors.New("ent: mutation is not running in a transaction")
  42882. }
  42883. tx := &Tx{config: m.config}
  42884. tx.init()
  42885. return tx, nil
  42886. }
  42887. // SetID sets the value of the id field. Note that this
  42888. // operation is only accepted on creation of WxCardUser entities.
  42889. func (m *WxCardUserMutation) SetID(id uint64) {
  42890. m.id = &id
  42891. }
  42892. // ID returns the ID value in the mutation. Note that the ID is only available
  42893. // if it was provided to the builder or after it was returned from the database.
  42894. func (m *WxCardUserMutation) ID() (id uint64, exists bool) {
  42895. if m.id == nil {
  42896. return
  42897. }
  42898. return *m.id, true
  42899. }
  42900. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  42901. // That means, if the mutation is applied within a transaction with an isolation level such
  42902. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  42903. // or updated by the mutation.
  42904. func (m *WxCardUserMutation) IDs(ctx context.Context) ([]uint64, error) {
  42905. switch {
  42906. case m.op.Is(OpUpdateOne | OpDeleteOne):
  42907. id, exists := m.ID()
  42908. if exists {
  42909. return []uint64{id}, nil
  42910. }
  42911. fallthrough
  42912. case m.op.Is(OpUpdate | OpDelete):
  42913. return m.Client().WxCardUser.Query().Where(m.predicates...).IDs(ctx)
  42914. default:
  42915. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  42916. }
  42917. }
  42918. // SetCreatedAt sets the "created_at" field.
  42919. func (m *WxCardUserMutation) SetCreatedAt(t time.Time) {
  42920. m.created_at = &t
  42921. }
  42922. // CreatedAt returns the value of the "created_at" field in the mutation.
  42923. func (m *WxCardUserMutation) CreatedAt() (r time.Time, exists bool) {
  42924. v := m.created_at
  42925. if v == nil {
  42926. return
  42927. }
  42928. return *v, true
  42929. }
  42930. // OldCreatedAt returns the old "created_at" field's value of the WxCardUser entity.
  42931. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  42932. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42933. func (m *WxCardUserMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  42934. if !m.op.Is(OpUpdateOne) {
  42935. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  42936. }
  42937. if m.id == nil || m.oldValue == nil {
  42938. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  42939. }
  42940. oldValue, err := m.oldValue(ctx)
  42941. if err != nil {
  42942. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  42943. }
  42944. return oldValue.CreatedAt, nil
  42945. }
  42946. // ResetCreatedAt resets all changes to the "created_at" field.
  42947. func (m *WxCardUserMutation) ResetCreatedAt() {
  42948. m.created_at = nil
  42949. }
  42950. // SetUpdatedAt sets the "updated_at" field.
  42951. func (m *WxCardUserMutation) SetUpdatedAt(t time.Time) {
  42952. m.updated_at = &t
  42953. }
  42954. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  42955. func (m *WxCardUserMutation) UpdatedAt() (r time.Time, exists bool) {
  42956. v := m.updated_at
  42957. if v == nil {
  42958. return
  42959. }
  42960. return *v, true
  42961. }
  42962. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardUser entity.
  42963. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  42964. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42965. func (m *WxCardUserMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  42966. if !m.op.Is(OpUpdateOne) {
  42967. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  42968. }
  42969. if m.id == nil || m.oldValue == nil {
  42970. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  42971. }
  42972. oldValue, err := m.oldValue(ctx)
  42973. if err != nil {
  42974. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  42975. }
  42976. return oldValue.UpdatedAt, nil
  42977. }
  42978. // ResetUpdatedAt resets all changes to the "updated_at" field.
  42979. func (m *WxCardUserMutation) ResetUpdatedAt() {
  42980. m.updated_at = nil
  42981. }
  42982. // SetDeletedAt sets the "deleted_at" field.
  42983. func (m *WxCardUserMutation) SetDeletedAt(t time.Time) {
  42984. m.deleted_at = &t
  42985. }
  42986. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  42987. func (m *WxCardUserMutation) DeletedAt() (r time.Time, exists bool) {
  42988. v := m.deleted_at
  42989. if v == nil {
  42990. return
  42991. }
  42992. return *v, true
  42993. }
  42994. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardUser entity.
  42995. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  42996. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42997. func (m *WxCardUserMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  42998. if !m.op.Is(OpUpdateOne) {
  42999. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  43000. }
  43001. if m.id == nil || m.oldValue == nil {
  43002. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  43003. }
  43004. oldValue, err := m.oldValue(ctx)
  43005. if err != nil {
  43006. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  43007. }
  43008. return oldValue.DeletedAt, nil
  43009. }
  43010. // ClearDeletedAt clears the value of the "deleted_at" field.
  43011. func (m *WxCardUserMutation) ClearDeletedAt() {
  43012. m.deleted_at = nil
  43013. m.clearedFields[wxcarduser.FieldDeletedAt] = struct{}{}
  43014. }
  43015. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  43016. func (m *WxCardUserMutation) DeletedAtCleared() bool {
  43017. _, ok := m.clearedFields[wxcarduser.FieldDeletedAt]
  43018. return ok
  43019. }
  43020. // ResetDeletedAt resets all changes to the "deleted_at" field.
  43021. func (m *WxCardUserMutation) ResetDeletedAt() {
  43022. m.deleted_at = nil
  43023. delete(m.clearedFields, wxcarduser.FieldDeletedAt)
  43024. }
  43025. // SetWxid sets the "wxid" field.
  43026. func (m *WxCardUserMutation) SetWxid(s string) {
  43027. m.wxid = &s
  43028. }
  43029. // Wxid returns the value of the "wxid" field in the mutation.
  43030. func (m *WxCardUserMutation) Wxid() (r string, exists bool) {
  43031. v := m.wxid
  43032. if v == nil {
  43033. return
  43034. }
  43035. return *v, true
  43036. }
  43037. // OldWxid returns the old "wxid" field's value of the WxCardUser entity.
  43038. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  43039. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43040. func (m *WxCardUserMutation) OldWxid(ctx context.Context) (v string, err error) {
  43041. if !m.op.Is(OpUpdateOne) {
  43042. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  43043. }
  43044. if m.id == nil || m.oldValue == nil {
  43045. return v, errors.New("OldWxid requires an ID field in the mutation")
  43046. }
  43047. oldValue, err := m.oldValue(ctx)
  43048. if err != nil {
  43049. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  43050. }
  43051. return oldValue.Wxid, nil
  43052. }
  43053. // ResetWxid resets all changes to the "wxid" field.
  43054. func (m *WxCardUserMutation) ResetWxid() {
  43055. m.wxid = nil
  43056. }
  43057. // SetAccount sets the "account" field.
  43058. func (m *WxCardUserMutation) SetAccount(s string) {
  43059. m.account = &s
  43060. }
  43061. // Account returns the value of the "account" field in the mutation.
  43062. func (m *WxCardUserMutation) Account() (r string, exists bool) {
  43063. v := m.account
  43064. if v == nil {
  43065. return
  43066. }
  43067. return *v, true
  43068. }
  43069. // OldAccount returns the old "account" field's value of the WxCardUser entity.
  43070. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  43071. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43072. func (m *WxCardUserMutation) OldAccount(ctx context.Context) (v string, err error) {
  43073. if !m.op.Is(OpUpdateOne) {
  43074. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  43075. }
  43076. if m.id == nil || m.oldValue == nil {
  43077. return v, errors.New("OldAccount requires an ID field in the mutation")
  43078. }
  43079. oldValue, err := m.oldValue(ctx)
  43080. if err != nil {
  43081. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  43082. }
  43083. return oldValue.Account, nil
  43084. }
  43085. // ResetAccount resets all changes to the "account" field.
  43086. func (m *WxCardUserMutation) ResetAccount() {
  43087. m.account = nil
  43088. }
  43089. // SetAvatar sets the "avatar" field.
  43090. func (m *WxCardUserMutation) SetAvatar(s string) {
  43091. m.avatar = &s
  43092. }
  43093. // Avatar returns the value of the "avatar" field in the mutation.
  43094. func (m *WxCardUserMutation) Avatar() (r string, exists bool) {
  43095. v := m.avatar
  43096. if v == nil {
  43097. return
  43098. }
  43099. return *v, true
  43100. }
  43101. // OldAvatar returns the old "avatar" field's value of the WxCardUser entity.
  43102. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  43103. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43104. func (m *WxCardUserMutation) OldAvatar(ctx context.Context) (v string, err error) {
  43105. if !m.op.Is(OpUpdateOne) {
  43106. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  43107. }
  43108. if m.id == nil || m.oldValue == nil {
  43109. return v, errors.New("OldAvatar requires an ID field in the mutation")
  43110. }
  43111. oldValue, err := m.oldValue(ctx)
  43112. if err != nil {
  43113. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  43114. }
  43115. return oldValue.Avatar, nil
  43116. }
  43117. // ResetAvatar resets all changes to the "avatar" field.
  43118. func (m *WxCardUserMutation) ResetAvatar() {
  43119. m.avatar = nil
  43120. }
  43121. // SetNickname sets the "nickname" field.
  43122. func (m *WxCardUserMutation) SetNickname(s string) {
  43123. m.nickname = &s
  43124. }
  43125. // Nickname returns the value of the "nickname" field in the mutation.
  43126. func (m *WxCardUserMutation) Nickname() (r string, exists bool) {
  43127. v := m.nickname
  43128. if v == nil {
  43129. return
  43130. }
  43131. return *v, true
  43132. }
  43133. // OldNickname returns the old "nickname" field's value of the WxCardUser entity.
  43134. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  43135. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43136. func (m *WxCardUserMutation) OldNickname(ctx context.Context) (v string, err error) {
  43137. if !m.op.Is(OpUpdateOne) {
  43138. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  43139. }
  43140. if m.id == nil || m.oldValue == nil {
  43141. return v, errors.New("OldNickname requires an ID field in the mutation")
  43142. }
  43143. oldValue, err := m.oldValue(ctx)
  43144. if err != nil {
  43145. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  43146. }
  43147. return oldValue.Nickname, nil
  43148. }
  43149. // ResetNickname resets all changes to the "nickname" field.
  43150. func (m *WxCardUserMutation) ResetNickname() {
  43151. m.nickname = nil
  43152. }
  43153. // SetRemark sets the "remark" field.
  43154. func (m *WxCardUserMutation) SetRemark(s string) {
  43155. m.remark = &s
  43156. }
  43157. // Remark returns the value of the "remark" field in the mutation.
  43158. func (m *WxCardUserMutation) Remark() (r string, exists bool) {
  43159. v := m.remark
  43160. if v == nil {
  43161. return
  43162. }
  43163. return *v, true
  43164. }
  43165. // OldRemark returns the old "remark" field's value of the WxCardUser entity.
  43166. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  43167. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43168. func (m *WxCardUserMutation) OldRemark(ctx context.Context) (v string, err error) {
  43169. if !m.op.Is(OpUpdateOne) {
  43170. return v, errors.New("OldRemark is only allowed on UpdateOne operations")
  43171. }
  43172. if m.id == nil || m.oldValue == nil {
  43173. return v, errors.New("OldRemark requires an ID field in the mutation")
  43174. }
  43175. oldValue, err := m.oldValue(ctx)
  43176. if err != nil {
  43177. return v, fmt.Errorf("querying old value for OldRemark: %w", err)
  43178. }
  43179. return oldValue.Remark, nil
  43180. }
  43181. // ResetRemark resets all changes to the "remark" field.
  43182. func (m *WxCardUserMutation) ResetRemark() {
  43183. m.remark = nil
  43184. }
  43185. // SetPhone sets the "phone" field.
  43186. func (m *WxCardUserMutation) SetPhone(s string) {
  43187. m.phone = &s
  43188. }
  43189. // Phone returns the value of the "phone" field in the mutation.
  43190. func (m *WxCardUserMutation) Phone() (r string, exists bool) {
  43191. v := m.phone
  43192. if v == nil {
  43193. return
  43194. }
  43195. return *v, true
  43196. }
  43197. // OldPhone returns the old "phone" field's value of the WxCardUser entity.
  43198. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  43199. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43200. func (m *WxCardUserMutation) OldPhone(ctx context.Context) (v string, err error) {
  43201. if !m.op.Is(OpUpdateOne) {
  43202. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  43203. }
  43204. if m.id == nil || m.oldValue == nil {
  43205. return v, errors.New("OldPhone requires an ID field in the mutation")
  43206. }
  43207. oldValue, err := m.oldValue(ctx)
  43208. if err != nil {
  43209. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  43210. }
  43211. return oldValue.Phone, nil
  43212. }
  43213. // ResetPhone resets all changes to the "phone" field.
  43214. func (m *WxCardUserMutation) ResetPhone() {
  43215. m.phone = nil
  43216. }
  43217. // SetOpenID sets the "open_id" field.
  43218. func (m *WxCardUserMutation) SetOpenID(s string) {
  43219. m.open_id = &s
  43220. }
  43221. // OpenID returns the value of the "open_id" field in the mutation.
  43222. func (m *WxCardUserMutation) OpenID() (r string, exists bool) {
  43223. v := m.open_id
  43224. if v == nil {
  43225. return
  43226. }
  43227. return *v, true
  43228. }
  43229. // OldOpenID returns the old "open_id" field's value of the WxCardUser entity.
  43230. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  43231. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43232. func (m *WxCardUserMutation) OldOpenID(ctx context.Context) (v string, err error) {
  43233. if !m.op.Is(OpUpdateOne) {
  43234. return v, errors.New("OldOpenID is only allowed on UpdateOne operations")
  43235. }
  43236. if m.id == nil || m.oldValue == nil {
  43237. return v, errors.New("OldOpenID requires an ID field in the mutation")
  43238. }
  43239. oldValue, err := m.oldValue(ctx)
  43240. if err != nil {
  43241. return v, fmt.Errorf("querying old value for OldOpenID: %w", err)
  43242. }
  43243. return oldValue.OpenID, nil
  43244. }
  43245. // ResetOpenID resets all changes to the "open_id" field.
  43246. func (m *WxCardUserMutation) ResetOpenID() {
  43247. m.open_id = nil
  43248. }
  43249. // SetUnionID sets the "union_id" field.
  43250. func (m *WxCardUserMutation) SetUnionID(s string) {
  43251. m.union_id = &s
  43252. }
  43253. // UnionID returns the value of the "union_id" field in the mutation.
  43254. func (m *WxCardUserMutation) UnionID() (r string, exists bool) {
  43255. v := m.union_id
  43256. if v == nil {
  43257. return
  43258. }
  43259. return *v, true
  43260. }
  43261. // OldUnionID returns the old "union_id" field's value of the WxCardUser entity.
  43262. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  43263. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43264. func (m *WxCardUserMutation) OldUnionID(ctx context.Context) (v string, err error) {
  43265. if !m.op.Is(OpUpdateOne) {
  43266. return v, errors.New("OldUnionID is only allowed on UpdateOne operations")
  43267. }
  43268. if m.id == nil || m.oldValue == nil {
  43269. return v, errors.New("OldUnionID requires an ID field in the mutation")
  43270. }
  43271. oldValue, err := m.oldValue(ctx)
  43272. if err != nil {
  43273. return v, fmt.Errorf("querying old value for OldUnionID: %w", err)
  43274. }
  43275. return oldValue.UnionID, nil
  43276. }
  43277. // ResetUnionID resets all changes to the "union_id" field.
  43278. func (m *WxCardUserMutation) ResetUnionID() {
  43279. m.union_id = nil
  43280. }
  43281. // SetSessionKey sets the "session_key" field.
  43282. func (m *WxCardUserMutation) SetSessionKey(s string) {
  43283. m.session_key = &s
  43284. }
  43285. // SessionKey returns the value of the "session_key" field in the mutation.
  43286. func (m *WxCardUserMutation) SessionKey() (r string, exists bool) {
  43287. v := m.session_key
  43288. if v == nil {
  43289. return
  43290. }
  43291. return *v, true
  43292. }
  43293. // OldSessionKey returns the old "session_key" field's value of the WxCardUser entity.
  43294. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  43295. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43296. func (m *WxCardUserMutation) OldSessionKey(ctx context.Context) (v string, err error) {
  43297. if !m.op.Is(OpUpdateOne) {
  43298. return v, errors.New("OldSessionKey is only allowed on UpdateOne operations")
  43299. }
  43300. if m.id == nil || m.oldValue == nil {
  43301. return v, errors.New("OldSessionKey requires an ID field in the mutation")
  43302. }
  43303. oldValue, err := m.oldValue(ctx)
  43304. if err != nil {
  43305. return v, fmt.Errorf("querying old value for OldSessionKey: %w", err)
  43306. }
  43307. return oldValue.SessionKey, nil
  43308. }
  43309. // ResetSessionKey resets all changes to the "session_key" field.
  43310. func (m *WxCardUserMutation) ResetSessionKey() {
  43311. m.session_key = nil
  43312. }
  43313. // SetIsVip sets the "is_vip" field.
  43314. func (m *WxCardUserMutation) SetIsVip(i int) {
  43315. m.is_vip = &i
  43316. m.addis_vip = nil
  43317. }
  43318. // IsVip returns the value of the "is_vip" field in the mutation.
  43319. func (m *WxCardUserMutation) IsVip() (r int, exists bool) {
  43320. v := m.is_vip
  43321. if v == nil {
  43322. return
  43323. }
  43324. return *v, true
  43325. }
  43326. // OldIsVip returns the old "is_vip" field's value of the WxCardUser entity.
  43327. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  43328. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43329. func (m *WxCardUserMutation) OldIsVip(ctx context.Context) (v int, err error) {
  43330. if !m.op.Is(OpUpdateOne) {
  43331. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  43332. }
  43333. if m.id == nil || m.oldValue == nil {
  43334. return v, errors.New("OldIsVip requires an ID field in the mutation")
  43335. }
  43336. oldValue, err := m.oldValue(ctx)
  43337. if err != nil {
  43338. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  43339. }
  43340. return oldValue.IsVip, nil
  43341. }
  43342. // AddIsVip adds i to the "is_vip" field.
  43343. func (m *WxCardUserMutation) AddIsVip(i int) {
  43344. if m.addis_vip != nil {
  43345. *m.addis_vip += i
  43346. } else {
  43347. m.addis_vip = &i
  43348. }
  43349. }
  43350. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  43351. func (m *WxCardUserMutation) AddedIsVip() (r int, exists bool) {
  43352. v := m.addis_vip
  43353. if v == nil {
  43354. return
  43355. }
  43356. return *v, true
  43357. }
  43358. // ResetIsVip resets all changes to the "is_vip" field.
  43359. func (m *WxCardUserMutation) ResetIsVip() {
  43360. m.is_vip = nil
  43361. m.addis_vip = nil
  43362. }
  43363. // Where appends a list predicates to the WxCardUserMutation builder.
  43364. func (m *WxCardUserMutation) Where(ps ...predicate.WxCardUser) {
  43365. m.predicates = append(m.predicates, ps...)
  43366. }
  43367. // WhereP appends storage-level predicates to the WxCardUserMutation builder. Using this method,
  43368. // users can use type-assertion to append predicates that do not depend on any generated package.
  43369. func (m *WxCardUserMutation) WhereP(ps ...func(*sql.Selector)) {
  43370. p := make([]predicate.WxCardUser, len(ps))
  43371. for i := range ps {
  43372. p[i] = ps[i]
  43373. }
  43374. m.Where(p...)
  43375. }
  43376. // Op returns the operation name.
  43377. func (m *WxCardUserMutation) Op() Op {
  43378. return m.op
  43379. }
  43380. // SetOp allows setting the mutation operation.
  43381. func (m *WxCardUserMutation) SetOp(op Op) {
  43382. m.op = op
  43383. }
  43384. // Type returns the node type of this mutation (WxCardUser).
  43385. func (m *WxCardUserMutation) Type() string {
  43386. return m.typ
  43387. }
  43388. // Fields returns all fields that were changed during this mutation. Note that in
  43389. // order to get all numeric fields that were incremented/decremented, call
  43390. // AddedFields().
  43391. func (m *WxCardUserMutation) Fields() []string {
  43392. fields := make([]string, 0, 13)
  43393. if m.created_at != nil {
  43394. fields = append(fields, wxcarduser.FieldCreatedAt)
  43395. }
  43396. if m.updated_at != nil {
  43397. fields = append(fields, wxcarduser.FieldUpdatedAt)
  43398. }
  43399. if m.deleted_at != nil {
  43400. fields = append(fields, wxcarduser.FieldDeletedAt)
  43401. }
  43402. if m.wxid != nil {
  43403. fields = append(fields, wxcarduser.FieldWxid)
  43404. }
  43405. if m.account != nil {
  43406. fields = append(fields, wxcarduser.FieldAccount)
  43407. }
  43408. if m.avatar != nil {
  43409. fields = append(fields, wxcarduser.FieldAvatar)
  43410. }
  43411. if m.nickname != nil {
  43412. fields = append(fields, wxcarduser.FieldNickname)
  43413. }
  43414. if m.remark != nil {
  43415. fields = append(fields, wxcarduser.FieldRemark)
  43416. }
  43417. if m.phone != nil {
  43418. fields = append(fields, wxcarduser.FieldPhone)
  43419. }
  43420. if m.open_id != nil {
  43421. fields = append(fields, wxcarduser.FieldOpenID)
  43422. }
  43423. if m.union_id != nil {
  43424. fields = append(fields, wxcarduser.FieldUnionID)
  43425. }
  43426. if m.session_key != nil {
  43427. fields = append(fields, wxcarduser.FieldSessionKey)
  43428. }
  43429. if m.is_vip != nil {
  43430. fields = append(fields, wxcarduser.FieldIsVip)
  43431. }
  43432. return fields
  43433. }
  43434. // Field returns the value of a field with the given name. The second boolean
  43435. // return value indicates that this field was not set, or was not defined in the
  43436. // schema.
  43437. func (m *WxCardUserMutation) Field(name string) (ent.Value, bool) {
  43438. switch name {
  43439. case wxcarduser.FieldCreatedAt:
  43440. return m.CreatedAt()
  43441. case wxcarduser.FieldUpdatedAt:
  43442. return m.UpdatedAt()
  43443. case wxcarduser.FieldDeletedAt:
  43444. return m.DeletedAt()
  43445. case wxcarduser.FieldWxid:
  43446. return m.Wxid()
  43447. case wxcarduser.FieldAccount:
  43448. return m.Account()
  43449. case wxcarduser.FieldAvatar:
  43450. return m.Avatar()
  43451. case wxcarduser.FieldNickname:
  43452. return m.Nickname()
  43453. case wxcarduser.FieldRemark:
  43454. return m.Remark()
  43455. case wxcarduser.FieldPhone:
  43456. return m.Phone()
  43457. case wxcarduser.FieldOpenID:
  43458. return m.OpenID()
  43459. case wxcarduser.FieldUnionID:
  43460. return m.UnionID()
  43461. case wxcarduser.FieldSessionKey:
  43462. return m.SessionKey()
  43463. case wxcarduser.FieldIsVip:
  43464. return m.IsVip()
  43465. }
  43466. return nil, false
  43467. }
  43468. // OldField returns the old value of the field from the database. An error is
  43469. // returned if the mutation operation is not UpdateOne, or the query to the
  43470. // database failed.
  43471. func (m *WxCardUserMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  43472. switch name {
  43473. case wxcarduser.FieldCreatedAt:
  43474. return m.OldCreatedAt(ctx)
  43475. case wxcarduser.FieldUpdatedAt:
  43476. return m.OldUpdatedAt(ctx)
  43477. case wxcarduser.FieldDeletedAt:
  43478. return m.OldDeletedAt(ctx)
  43479. case wxcarduser.FieldWxid:
  43480. return m.OldWxid(ctx)
  43481. case wxcarduser.FieldAccount:
  43482. return m.OldAccount(ctx)
  43483. case wxcarduser.FieldAvatar:
  43484. return m.OldAvatar(ctx)
  43485. case wxcarduser.FieldNickname:
  43486. return m.OldNickname(ctx)
  43487. case wxcarduser.FieldRemark:
  43488. return m.OldRemark(ctx)
  43489. case wxcarduser.FieldPhone:
  43490. return m.OldPhone(ctx)
  43491. case wxcarduser.FieldOpenID:
  43492. return m.OldOpenID(ctx)
  43493. case wxcarduser.FieldUnionID:
  43494. return m.OldUnionID(ctx)
  43495. case wxcarduser.FieldSessionKey:
  43496. return m.OldSessionKey(ctx)
  43497. case wxcarduser.FieldIsVip:
  43498. return m.OldIsVip(ctx)
  43499. }
  43500. return nil, fmt.Errorf("unknown WxCardUser field %s", name)
  43501. }
  43502. // SetField sets the value of a field with the given name. It returns an error if
  43503. // the field is not defined in the schema, or if the type mismatched the field
  43504. // type.
  43505. func (m *WxCardUserMutation) SetField(name string, value ent.Value) error {
  43506. switch name {
  43507. case wxcarduser.FieldCreatedAt:
  43508. v, ok := value.(time.Time)
  43509. if !ok {
  43510. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43511. }
  43512. m.SetCreatedAt(v)
  43513. return nil
  43514. case wxcarduser.FieldUpdatedAt:
  43515. v, ok := value.(time.Time)
  43516. if !ok {
  43517. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43518. }
  43519. m.SetUpdatedAt(v)
  43520. return nil
  43521. case wxcarduser.FieldDeletedAt:
  43522. v, ok := value.(time.Time)
  43523. if !ok {
  43524. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43525. }
  43526. m.SetDeletedAt(v)
  43527. return nil
  43528. case wxcarduser.FieldWxid:
  43529. v, ok := value.(string)
  43530. if !ok {
  43531. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43532. }
  43533. m.SetWxid(v)
  43534. return nil
  43535. case wxcarduser.FieldAccount:
  43536. v, ok := value.(string)
  43537. if !ok {
  43538. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43539. }
  43540. m.SetAccount(v)
  43541. return nil
  43542. case wxcarduser.FieldAvatar:
  43543. v, ok := value.(string)
  43544. if !ok {
  43545. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43546. }
  43547. m.SetAvatar(v)
  43548. return nil
  43549. case wxcarduser.FieldNickname:
  43550. v, ok := value.(string)
  43551. if !ok {
  43552. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43553. }
  43554. m.SetNickname(v)
  43555. return nil
  43556. case wxcarduser.FieldRemark:
  43557. v, ok := value.(string)
  43558. if !ok {
  43559. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43560. }
  43561. m.SetRemark(v)
  43562. return nil
  43563. case wxcarduser.FieldPhone:
  43564. v, ok := value.(string)
  43565. if !ok {
  43566. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43567. }
  43568. m.SetPhone(v)
  43569. return nil
  43570. case wxcarduser.FieldOpenID:
  43571. v, ok := value.(string)
  43572. if !ok {
  43573. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43574. }
  43575. m.SetOpenID(v)
  43576. return nil
  43577. case wxcarduser.FieldUnionID:
  43578. v, ok := value.(string)
  43579. if !ok {
  43580. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43581. }
  43582. m.SetUnionID(v)
  43583. return nil
  43584. case wxcarduser.FieldSessionKey:
  43585. v, ok := value.(string)
  43586. if !ok {
  43587. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43588. }
  43589. m.SetSessionKey(v)
  43590. return nil
  43591. case wxcarduser.FieldIsVip:
  43592. v, ok := value.(int)
  43593. if !ok {
  43594. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43595. }
  43596. m.SetIsVip(v)
  43597. return nil
  43598. }
  43599. return fmt.Errorf("unknown WxCardUser field %s", name)
  43600. }
  43601. // AddedFields returns all numeric fields that were incremented/decremented during
  43602. // this mutation.
  43603. func (m *WxCardUserMutation) AddedFields() []string {
  43604. var fields []string
  43605. if m.addis_vip != nil {
  43606. fields = append(fields, wxcarduser.FieldIsVip)
  43607. }
  43608. return fields
  43609. }
  43610. // AddedField returns the numeric value that was incremented/decremented on a field
  43611. // with the given name. The second boolean return value indicates that this field
  43612. // was not set, or was not defined in the schema.
  43613. func (m *WxCardUserMutation) AddedField(name string) (ent.Value, bool) {
  43614. switch name {
  43615. case wxcarduser.FieldIsVip:
  43616. return m.AddedIsVip()
  43617. }
  43618. return nil, false
  43619. }
  43620. // AddField adds the value to the field with the given name. It returns an error if
  43621. // the field is not defined in the schema, or if the type mismatched the field
  43622. // type.
  43623. func (m *WxCardUserMutation) AddField(name string, value ent.Value) error {
  43624. switch name {
  43625. case wxcarduser.FieldIsVip:
  43626. v, ok := value.(int)
  43627. if !ok {
  43628. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43629. }
  43630. m.AddIsVip(v)
  43631. return nil
  43632. }
  43633. return fmt.Errorf("unknown WxCardUser numeric field %s", name)
  43634. }
  43635. // ClearedFields returns all nullable fields that were cleared during this
  43636. // mutation.
  43637. func (m *WxCardUserMutation) ClearedFields() []string {
  43638. var fields []string
  43639. if m.FieldCleared(wxcarduser.FieldDeletedAt) {
  43640. fields = append(fields, wxcarduser.FieldDeletedAt)
  43641. }
  43642. return fields
  43643. }
  43644. // FieldCleared returns a boolean indicating if a field with the given name was
  43645. // cleared in this mutation.
  43646. func (m *WxCardUserMutation) FieldCleared(name string) bool {
  43647. _, ok := m.clearedFields[name]
  43648. return ok
  43649. }
  43650. // ClearField clears the value of the field with the given name. It returns an
  43651. // error if the field is not defined in the schema.
  43652. func (m *WxCardUserMutation) ClearField(name string) error {
  43653. switch name {
  43654. case wxcarduser.FieldDeletedAt:
  43655. m.ClearDeletedAt()
  43656. return nil
  43657. }
  43658. return fmt.Errorf("unknown WxCardUser nullable field %s", name)
  43659. }
  43660. // ResetField resets all changes in the mutation for the field with the given name.
  43661. // It returns an error if the field is not defined in the schema.
  43662. func (m *WxCardUserMutation) ResetField(name string) error {
  43663. switch name {
  43664. case wxcarduser.FieldCreatedAt:
  43665. m.ResetCreatedAt()
  43666. return nil
  43667. case wxcarduser.FieldUpdatedAt:
  43668. m.ResetUpdatedAt()
  43669. return nil
  43670. case wxcarduser.FieldDeletedAt:
  43671. m.ResetDeletedAt()
  43672. return nil
  43673. case wxcarduser.FieldWxid:
  43674. m.ResetWxid()
  43675. return nil
  43676. case wxcarduser.FieldAccount:
  43677. m.ResetAccount()
  43678. return nil
  43679. case wxcarduser.FieldAvatar:
  43680. m.ResetAvatar()
  43681. return nil
  43682. case wxcarduser.FieldNickname:
  43683. m.ResetNickname()
  43684. return nil
  43685. case wxcarduser.FieldRemark:
  43686. m.ResetRemark()
  43687. return nil
  43688. case wxcarduser.FieldPhone:
  43689. m.ResetPhone()
  43690. return nil
  43691. case wxcarduser.FieldOpenID:
  43692. m.ResetOpenID()
  43693. return nil
  43694. case wxcarduser.FieldUnionID:
  43695. m.ResetUnionID()
  43696. return nil
  43697. case wxcarduser.FieldSessionKey:
  43698. m.ResetSessionKey()
  43699. return nil
  43700. case wxcarduser.FieldIsVip:
  43701. m.ResetIsVip()
  43702. return nil
  43703. }
  43704. return fmt.Errorf("unknown WxCardUser field %s", name)
  43705. }
  43706. // AddedEdges returns all edge names that were set/added in this mutation.
  43707. func (m *WxCardUserMutation) AddedEdges() []string {
  43708. edges := make([]string, 0, 0)
  43709. return edges
  43710. }
  43711. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  43712. // name in this mutation.
  43713. func (m *WxCardUserMutation) AddedIDs(name string) []ent.Value {
  43714. return nil
  43715. }
  43716. // RemovedEdges returns all edge names that were removed in this mutation.
  43717. func (m *WxCardUserMutation) RemovedEdges() []string {
  43718. edges := make([]string, 0, 0)
  43719. return edges
  43720. }
  43721. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  43722. // the given name in this mutation.
  43723. func (m *WxCardUserMutation) RemovedIDs(name string) []ent.Value {
  43724. return nil
  43725. }
  43726. // ClearedEdges returns all edge names that were cleared in this mutation.
  43727. func (m *WxCardUserMutation) ClearedEdges() []string {
  43728. edges := make([]string, 0, 0)
  43729. return edges
  43730. }
  43731. // EdgeCleared returns a boolean which indicates if the edge with the given name
  43732. // was cleared in this mutation.
  43733. func (m *WxCardUserMutation) EdgeCleared(name string) bool {
  43734. return false
  43735. }
  43736. // ClearEdge clears the value of the edge with the given name. It returns an error
  43737. // if that edge is not defined in the schema.
  43738. func (m *WxCardUserMutation) ClearEdge(name string) error {
  43739. return fmt.Errorf("unknown WxCardUser unique edge %s", name)
  43740. }
  43741. // ResetEdge resets all changes to the edge with the given name in this mutation.
  43742. // It returns an error if the edge is not defined in the schema.
  43743. func (m *WxCardUserMutation) ResetEdge(name string) error {
  43744. return fmt.Errorf("unknown WxCardUser edge %s", name)
  43745. }
  43746. // WxCardVisitMutation represents an operation that mutates the WxCardVisit nodes in the graph.
  43747. type WxCardVisitMutation struct {
  43748. config
  43749. op Op
  43750. typ string
  43751. id *uint64
  43752. created_at *time.Time
  43753. updated_at *time.Time
  43754. deleted_at *time.Time
  43755. user_id *uint64
  43756. adduser_id *int64
  43757. bot_id *uint64
  43758. addbot_id *int64
  43759. bot_type *uint8
  43760. addbot_type *int8
  43761. clearedFields map[string]struct{}
  43762. done bool
  43763. oldValue func(context.Context) (*WxCardVisit, error)
  43764. predicates []predicate.WxCardVisit
  43765. }
  43766. var _ ent.Mutation = (*WxCardVisitMutation)(nil)
  43767. // wxcardvisitOption allows management of the mutation configuration using functional options.
  43768. type wxcardvisitOption func(*WxCardVisitMutation)
  43769. // newWxCardVisitMutation creates new mutation for the WxCardVisit entity.
  43770. func newWxCardVisitMutation(c config, op Op, opts ...wxcardvisitOption) *WxCardVisitMutation {
  43771. m := &WxCardVisitMutation{
  43772. config: c,
  43773. op: op,
  43774. typ: TypeWxCardVisit,
  43775. clearedFields: make(map[string]struct{}),
  43776. }
  43777. for _, opt := range opts {
  43778. opt(m)
  43779. }
  43780. return m
  43781. }
  43782. // withWxCardVisitID sets the ID field of the mutation.
  43783. func withWxCardVisitID(id uint64) wxcardvisitOption {
  43784. return func(m *WxCardVisitMutation) {
  43785. var (
  43786. err error
  43787. once sync.Once
  43788. value *WxCardVisit
  43789. )
  43790. m.oldValue = func(ctx context.Context) (*WxCardVisit, error) {
  43791. once.Do(func() {
  43792. if m.done {
  43793. err = errors.New("querying old values post mutation is not allowed")
  43794. } else {
  43795. value, err = m.Client().WxCardVisit.Get(ctx, id)
  43796. }
  43797. })
  43798. return value, err
  43799. }
  43800. m.id = &id
  43801. }
  43802. }
  43803. // withWxCardVisit sets the old WxCardVisit of the mutation.
  43804. func withWxCardVisit(node *WxCardVisit) wxcardvisitOption {
  43805. return func(m *WxCardVisitMutation) {
  43806. m.oldValue = func(context.Context) (*WxCardVisit, error) {
  43807. return node, nil
  43808. }
  43809. m.id = &node.ID
  43810. }
  43811. }
  43812. // Client returns a new `ent.Client` from the mutation. If the mutation was
  43813. // executed in a transaction (ent.Tx), a transactional client is returned.
  43814. func (m WxCardVisitMutation) Client() *Client {
  43815. client := &Client{config: m.config}
  43816. client.init()
  43817. return client
  43818. }
  43819. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  43820. // it returns an error otherwise.
  43821. func (m WxCardVisitMutation) Tx() (*Tx, error) {
  43822. if _, ok := m.driver.(*txDriver); !ok {
  43823. return nil, errors.New("ent: mutation is not running in a transaction")
  43824. }
  43825. tx := &Tx{config: m.config}
  43826. tx.init()
  43827. return tx, nil
  43828. }
  43829. // SetID sets the value of the id field. Note that this
  43830. // operation is only accepted on creation of WxCardVisit entities.
  43831. func (m *WxCardVisitMutation) SetID(id uint64) {
  43832. m.id = &id
  43833. }
  43834. // ID returns the ID value in the mutation. Note that the ID is only available
  43835. // if it was provided to the builder or after it was returned from the database.
  43836. func (m *WxCardVisitMutation) ID() (id uint64, exists bool) {
  43837. if m.id == nil {
  43838. return
  43839. }
  43840. return *m.id, true
  43841. }
  43842. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  43843. // That means, if the mutation is applied within a transaction with an isolation level such
  43844. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  43845. // or updated by the mutation.
  43846. func (m *WxCardVisitMutation) IDs(ctx context.Context) ([]uint64, error) {
  43847. switch {
  43848. case m.op.Is(OpUpdateOne | OpDeleteOne):
  43849. id, exists := m.ID()
  43850. if exists {
  43851. return []uint64{id}, nil
  43852. }
  43853. fallthrough
  43854. case m.op.Is(OpUpdate | OpDelete):
  43855. return m.Client().WxCardVisit.Query().Where(m.predicates...).IDs(ctx)
  43856. default:
  43857. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  43858. }
  43859. }
  43860. // SetCreatedAt sets the "created_at" field.
  43861. func (m *WxCardVisitMutation) SetCreatedAt(t time.Time) {
  43862. m.created_at = &t
  43863. }
  43864. // CreatedAt returns the value of the "created_at" field in the mutation.
  43865. func (m *WxCardVisitMutation) CreatedAt() (r time.Time, exists bool) {
  43866. v := m.created_at
  43867. if v == nil {
  43868. return
  43869. }
  43870. return *v, true
  43871. }
  43872. // OldCreatedAt returns the old "created_at" field's value of the WxCardVisit entity.
  43873. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  43874. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43875. func (m *WxCardVisitMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  43876. if !m.op.Is(OpUpdateOne) {
  43877. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  43878. }
  43879. if m.id == nil || m.oldValue == nil {
  43880. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  43881. }
  43882. oldValue, err := m.oldValue(ctx)
  43883. if err != nil {
  43884. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  43885. }
  43886. return oldValue.CreatedAt, nil
  43887. }
  43888. // ResetCreatedAt resets all changes to the "created_at" field.
  43889. func (m *WxCardVisitMutation) ResetCreatedAt() {
  43890. m.created_at = nil
  43891. }
  43892. // SetUpdatedAt sets the "updated_at" field.
  43893. func (m *WxCardVisitMutation) SetUpdatedAt(t time.Time) {
  43894. m.updated_at = &t
  43895. }
  43896. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  43897. func (m *WxCardVisitMutation) UpdatedAt() (r time.Time, exists bool) {
  43898. v := m.updated_at
  43899. if v == nil {
  43900. return
  43901. }
  43902. return *v, true
  43903. }
  43904. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardVisit entity.
  43905. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  43906. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43907. func (m *WxCardVisitMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  43908. if !m.op.Is(OpUpdateOne) {
  43909. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  43910. }
  43911. if m.id == nil || m.oldValue == nil {
  43912. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  43913. }
  43914. oldValue, err := m.oldValue(ctx)
  43915. if err != nil {
  43916. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  43917. }
  43918. return oldValue.UpdatedAt, nil
  43919. }
  43920. // ResetUpdatedAt resets all changes to the "updated_at" field.
  43921. func (m *WxCardVisitMutation) ResetUpdatedAt() {
  43922. m.updated_at = nil
  43923. }
  43924. // SetDeletedAt sets the "deleted_at" field.
  43925. func (m *WxCardVisitMutation) SetDeletedAt(t time.Time) {
  43926. m.deleted_at = &t
  43927. }
  43928. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  43929. func (m *WxCardVisitMutation) DeletedAt() (r time.Time, exists bool) {
  43930. v := m.deleted_at
  43931. if v == nil {
  43932. return
  43933. }
  43934. return *v, true
  43935. }
  43936. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardVisit entity.
  43937. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  43938. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43939. func (m *WxCardVisitMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  43940. if !m.op.Is(OpUpdateOne) {
  43941. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  43942. }
  43943. if m.id == nil || m.oldValue == nil {
  43944. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  43945. }
  43946. oldValue, err := m.oldValue(ctx)
  43947. if err != nil {
  43948. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  43949. }
  43950. return oldValue.DeletedAt, nil
  43951. }
  43952. // ClearDeletedAt clears the value of the "deleted_at" field.
  43953. func (m *WxCardVisitMutation) ClearDeletedAt() {
  43954. m.deleted_at = nil
  43955. m.clearedFields[wxcardvisit.FieldDeletedAt] = struct{}{}
  43956. }
  43957. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  43958. func (m *WxCardVisitMutation) DeletedAtCleared() bool {
  43959. _, ok := m.clearedFields[wxcardvisit.FieldDeletedAt]
  43960. return ok
  43961. }
  43962. // ResetDeletedAt resets all changes to the "deleted_at" field.
  43963. func (m *WxCardVisitMutation) ResetDeletedAt() {
  43964. m.deleted_at = nil
  43965. delete(m.clearedFields, wxcardvisit.FieldDeletedAt)
  43966. }
  43967. // SetUserID sets the "user_id" field.
  43968. func (m *WxCardVisitMutation) SetUserID(u uint64) {
  43969. m.user_id = &u
  43970. m.adduser_id = nil
  43971. }
  43972. // UserID returns the value of the "user_id" field in the mutation.
  43973. func (m *WxCardVisitMutation) UserID() (r uint64, exists bool) {
  43974. v := m.user_id
  43975. if v == nil {
  43976. return
  43977. }
  43978. return *v, true
  43979. }
  43980. // OldUserID returns the old "user_id" field's value of the WxCardVisit entity.
  43981. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  43982. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43983. func (m *WxCardVisitMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  43984. if !m.op.Is(OpUpdateOne) {
  43985. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  43986. }
  43987. if m.id == nil || m.oldValue == nil {
  43988. return v, errors.New("OldUserID requires an ID field in the mutation")
  43989. }
  43990. oldValue, err := m.oldValue(ctx)
  43991. if err != nil {
  43992. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  43993. }
  43994. return oldValue.UserID, nil
  43995. }
  43996. // AddUserID adds u to the "user_id" field.
  43997. func (m *WxCardVisitMutation) AddUserID(u int64) {
  43998. if m.adduser_id != nil {
  43999. *m.adduser_id += u
  44000. } else {
  44001. m.adduser_id = &u
  44002. }
  44003. }
  44004. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  44005. func (m *WxCardVisitMutation) AddedUserID() (r int64, exists bool) {
  44006. v := m.adduser_id
  44007. if v == nil {
  44008. return
  44009. }
  44010. return *v, true
  44011. }
  44012. // ClearUserID clears the value of the "user_id" field.
  44013. func (m *WxCardVisitMutation) ClearUserID() {
  44014. m.user_id = nil
  44015. m.adduser_id = nil
  44016. m.clearedFields[wxcardvisit.FieldUserID] = struct{}{}
  44017. }
  44018. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  44019. func (m *WxCardVisitMutation) UserIDCleared() bool {
  44020. _, ok := m.clearedFields[wxcardvisit.FieldUserID]
  44021. return ok
  44022. }
  44023. // ResetUserID resets all changes to the "user_id" field.
  44024. func (m *WxCardVisitMutation) ResetUserID() {
  44025. m.user_id = nil
  44026. m.adduser_id = nil
  44027. delete(m.clearedFields, wxcardvisit.FieldUserID)
  44028. }
  44029. // SetBotID sets the "bot_id" field.
  44030. func (m *WxCardVisitMutation) SetBotID(u uint64) {
  44031. m.bot_id = &u
  44032. m.addbot_id = nil
  44033. }
  44034. // BotID returns the value of the "bot_id" field in the mutation.
  44035. func (m *WxCardVisitMutation) BotID() (r uint64, exists bool) {
  44036. v := m.bot_id
  44037. if v == nil {
  44038. return
  44039. }
  44040. return *v, true
  44041. }
  44042. // OldBotID returns the old "bot_id" field's value of the WxCardVisit entity.
  44043. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  44044. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44045. func (m *WxCardVisitMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  44046. if !m.op.Is(OpUpdateOne) {
  44047. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  44048. }
  44049. if m.id == nil || m.oldValue == nil {
  44050. return v, errors.New("OldBotID requires an ID field in the mutation")
  44051. }
  44052. oldValue, err := m.oldValue(ctx)
  44053. if err != nil {
  44054. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  44055. }
  44056. return oldValue.BotID, nil
  44057. }
  44058. // AddBotID adds u to the "bot_id" field.
  44059. func (m *WxCardVisitMutation) AddBotID(u int64) {
  44060. if m.addbot_id != nil {
  44061. *m.addbot_id += u
  44062. } else {
  44063. m.addbot_id = &u
  44064. }
  44065. }
  44066. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  44067. func (m *WxCardVisitMutation) AddedBotID() (r int64, exists bool) {
  44068. v := m.addbot_id
  44069. if v == nil {
  44070. return
  44071. }
  44072. return *v, true
  44073. }
  44074. // ResetBotID resets all changes to the "bot_id" field.
  44075. func (m *WxCardVisitMutation) ResetBotID() {
  44076. m.bot_id = nil
  44077. m.addbot_id = nil
  44078. }
  44079. // SetBotType sets the "bot_type" field.
  44080. func (m *WxCardVisitMutation) SetBotType(u uint8) {
  44081. m.bot_type = &u
  44082. m.addbot_type = nil
  44083. }
  44084. // BotType returns the value of the "bot_type" field in the mutation.
  44085. func (m *WxCardVisitMutation) BotType() (r uint8, exists bool) {
  44086. v := m.bot_type
  44087. if v == nil {
  44088. return
  44089. }
  44090. return *v, true
  44091. }
  44092. // OldBotType returns the old "bot_type" field's value of the WxCardVisit entity.
  44093. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  44094. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44095. func (m *WxCardVisitMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  44096. if !m.op.Is(OpUpdateOne) {
  44097. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  44098. }
  44099. if m.id == nil || m.oldValue == nil {
  44100. return v, errors.New("OldBotType requires an ID field in the mutation")
  44101. }
  44102. oldValue, err := m.oldValue(ctx)
  44103. if err != nil {
  44104. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  44105. }
  44106. return oldValue.BotType, nil
  44107. }
  44108. // AddBotType adds u to the "bot_type" field.
  44109. func (m *WxCardVisitMutation) AddBotType(u int8) {
  44110. if m.addbot_type != nil {
  44111. *m.addbot_type += u
  44112. } else {
  44113. m.addbot_type = &u
  44114. }
  44115. }
  44116. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  44117. func (m *WxCardVisitMutation) AddedBotType() (r int8, exists bool) {
  44118. v := m.addbot_type
  44119. if v == nil {
  44120. return
  44121. }
  44122. return *v, true
  44123. }
  44124. // ResetBotType resets all changes to the "bot_type" field.
  44125. func (m *WxCardVisitMutation) ResetBotType() {
  44126. m.bot_type = nil
  44127. m.addbot_type = nil
  44128. }
  44129. // Where appends a list predicates to the WxCardVisitMutation builder.
  44130. func (m *WxCardVisitMutation) Where(ps ...predicate.WxCardVisit) {
  44131. m.predicates = append(m.predicates, ps...)
  44132. }
  44133. // WhereP appends storage-level predicates to the WxCardVisitMutation builder. Using this method,
  44134. // users can use type-assertion to append predicates that do not depend on any generated package.
  44135. func (m *WxCardVisitMutation) WhereP(ps ...func(*sql.Selector)) {
  44136. p := make([]predicate.WxCardVisit, len(ps))
  44137. for i := range ps {
  44138. p[i] = ps[i]
  44139. }
  44140. m.Where(p...)
  44141. }
  44142. // Op returns the operation name.
  44143. func (m *WxCardVisitMutation) Op() Op {
  44144. return m.op
  44145. }
  44146. // SetOp allows setting the mutation operation.
  44147. func (m *WxCardVisitMutation) SetOp(op Op) {
  44148. m.op = op
  44149. }
  44150. // Type returns the node type of this mutation (WxCardVisit).
  44151. func (m *WxCardVisitMutation) Type() string {
  44152. return m.typ
  44153. }
  44154. // Fields returns all fields that were changed during this mutation. Note that in
  44155. // order to get all numeric fields that were incremented/decremented, call
  44156. // AddedFields().
  44157. func (m *WxCardVisitMutation) Fields() []string {
  44158. fields := make([]string, 0, 6)
  44159. if m.created_at != nil {
  44160. fields = append(fields, wxcardvisit.FieldCreatedAt)
  44161. }
  44162. if m.updated_at != nil {
  44163. fields = append(fields, wxcardvisit.FieldUpdatedAt)
  44164. }
  44165. if m.deleted_at != nil {
  44166. fields = append(fields, wxcardvisit.FieldDeletedAt)
  44167. }
  44168. if m.user_id != nil {
  44169. fields = append(fields, wxcardvisit.FieldUserID)
  44170. }
  44171. if m.bot_id != nil {
  44172. fields = append(fields, wxcardvisit.FieldBotID)
  44173. }
  44174. if m.bot_type != nil {
  44175. fields = append(fields, wxcardvisit.FieldBotType)
  44176. }
  44177. return fields
  44178. }
  44179. // Field returns the value of a field with the given name. The second boolean
  44180. // return value indicates that this field was not set, or was not defined in the
  44181. // schema.
  44182. func (m *WxCardVisitMutation) Field(name string) (ent.Value, bool) {
  44183. switch name {
  44184. case wxcardvisit.FieldCreatedAt:
  44185. return m.CreatedAt()
  44186. case wxcardvisit.FieldUpdatedAt:
  44187. return m.UpdatedAt()
  44188. case wxcardvisit.FieldDeletedAt:
  44189. return m.DeletedAt()
  44190. case wxcardvisit.FieldUserID:
  44191. return m.UserID()
  44192. case wxcardvisit.FieldBotID:
  44193. return m.BotID()
  44194. case wxcardvisit.FieldBotType:
  44195. return m.BotType()
  44196. }
  44197. return nil, false
  44198. }
  44199. // OldField returns the old value of the field from the database. An error is
  44200. // returned if the mutation operation is not UpdateOne, or the query to the
  44201. // database failed.
  44202. func (m *WxCardVisitMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  44203. switch name {
  44204. case wxcardvisit.FieldCreatedAt:
  44205. return m.OldCreatedAt(ctx)
  44206. case wxcardvisit.FieldUpdatedAt:
  44207. return m.OldUpdatedAt(ctx)
  44208. case wxcardvisit.FieldDeletedAt:
  44209. return m.OldDeletedAt(ctx)
  44210. case wxcardvisit.FieldUserID:
  44211. return m.OldUserID(ctx)
  44212. case wxcardvisit.FieldBotID:
  44213. return m.OldBotID(ctx)
  44214. case wxcardvisit.FieldBotType:
  44215. return m.OldBotType(ctx)
  44216. }
  44217. return nil, fmt.Errorf("unknown WxCardVisit field %s", name)
  44218. }
  44219. // SetField sets the value of a field with the given name. It returns an error if
  44220. // the field is not defined in the schema, or if the type mismatched the field
  44221. // type.
  44222. func (m *WxCardVisitMutation) SetField(name string, value ent.Value) error {
  44223. switch name {
  44224. case wxcardvisit.FieldCreatedAt:
  44225. v, ok := value.(time.Time)
  44226. if !ok {
  44227. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44228. }
  44229. m.SetCreatedAt(v)
  44230. return nil
  44231. case wxcardvisit.FieldUpdatedAt:
  44232. v, ok := value.(time.Time)
  44233. if !ok {
  44234. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44235. }
  44236. m.SetUpdatedAt(v)
  44237. return nil
  44238. case wxcardvisit.FieldDeletedAt:
  44239. v, ok := value.(time.Time)
  44240. if !ok {
  44241. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44242. }
  44243. m.SetDeletedAt(v)
  44244. return nil
  44245. case wxcardvisit.FieldUserID:
  44246. v, ok := value.(uint64)
  44247. if !ok {
  44248. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44249. }
  44250. m.SetUserID(v)
  44251. return nil
  44252. case wxcardvisit.FieldBotID:
  44253. v, ok := value.(uint64)
  44254. if !ok {
  44255. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44256. }
  44257. m.SetBotID(v)
  44258. return nil
  44259. case wxcardvisit.FieldBotType:
  44260. v, ok := value.(uint8)
  44261. if !ok {
  44262. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44263. }
  44264. m.SetBotType(v)
  44265. return nil
  44266. }
  44267. return fmt.Errorf("unknown WxCardVisit field %s", name)
  44268. }
  44269. // AddedFields returns all numeric fields that were incremented/decremented during
  44270. // this mutation.
  44271. func (m *WxCardVisitMutation) AddedFields() []string {
  44272. var fields []string
  44273. if m.adduser_id != nil {
  44274. fields = append(fields, wxcardvisit.FieldUserID)
  44275. }
  44276. if m.addbot_id != nil {
  44277. fields = append(fields, wxcardvisit.FieldBotID)
  44278. }
  44279. if m.addbot_type != nil {
  44280. fields = append(fields, wxcardvisit.FieldBotType)
  44281. }
  44282. return fields
  44283. }
  44284. // AddedField returns the numeric value that was incremented/decremented on a field
  44285. // with the given name. The second boolean return value indicates that this field
  44286. // was not set, or was not defined in the schema.
  44287. func (m *WxCardVisitMutation) AddedField(name string) (ent.Value, bool) {
  44288. switch name {
  44289. case wxcardvisit.FieldUserID:
  44290. return m.AddedUserID()
  44291. case wxcardvisit.FieldBotID:
  44292. return m.AddedBotID()
  44293. case wxcardvisit.FieldBotType:
  44294. return m.AddedBotType()
  44295. }
  44296. return nil, false
  44297. }
  44298. // AddField adds the value to the field with the given name. It returns an error if
  44299. // the field is not defined in the schema, or if the type mismatched the field
  44300. // type.
  44301. func (m *WxCardVisitMutation) AddField(name string, value ent.Value) error {
  44302. switch name {
  44303. case wxcardvisit.FieldUserID:
  44304. v, ok := value.(int64)
  44305. if !ok {
  44306. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44307. }
  44308. m.AddUserID(v)
  44309. return nil
  44310. case wxcardvisit.FieldBotID:
  44311. v, ok := value.(int64)
  44312. if !ok {
  44313. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44314. }
  44315. m.AddBotID(v)
  44316. return nil
  44317. case wxcardvisit.FieldBotType:
  44318. v, ok := value.(int8)
  44319. if !ok {
  44320. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44321. }
  44322. m.AddBotType(v)
  44323. return nil
  44324. }
  44325. return fmt.Errorf("unknown WxCardVisit numeric field %s", name)
  44326. }
  44327. // ClearedFields returns all nullable fields that were cleared during this
  44328. // mutation.
  44329. func (m *WxCardVisitMutation) ClearedFields() []string {
  44330. var fields []string
  44331. if m.FieldCleared(wxcardvisit.FieldDeletedAt) {
  44332. fields = append(fields, wxcardvisit.FieldDeletedAt)
  44333. }
  44334. if m.FieldCleared(wxcardvisit.FieldUserID) {
  44335. fields = append(fields, wxcardvisit.FieldUserID)
  44336. }
  44337. return fields
  44338. }
  44339. // FieldCleared returns a boolean indicating if a field with the given name was
  44340. // cleared in this mutation.
  44341. func (m *WxCardVisitMutation) FieldCleared(name string) bool {
  44342. _, ok := m.clearedFields[name]
  44343. return ok
  44344. }
  44345. // ClearField clears the value of the field with the given name. It returns an
  44346. // error if the field is not defined in the schema.
  44347. func (m *WxCardVisitMutation) ClearField(name string) error {
  44348. switch name {
  44349. case wxcardvisit.FieldDeletedAt:
  44350. m.ClearDeletedAt()
  44351. return nil
  44352. case wxcardvisit.FieldUserID:
  44353. m.ClearUserID()
  44354. return nil
  44355. }
  44356. return fmt.Errorf("unknown WxCardVisit nullable field %s", name)
  44357. }
  44358. // ResetField resets all changes in the mutation for the field with the given name.
  44359. // It returns an error if the field is not defined in the schema.
  44360. func (m *WxCardVisitMutation) ResetField(name string) error {
  44361. switch name {
  44362. case wxcardvisit.FieldCreatedAt:
  44363. m.ResetCreatedAt()
  44364. return nil
  44365. case wxcardvisit.FieldUpdatedAt:
  44366. m.ResetUpdatedAt()
  44367. return nil
  44368. case wxcardvisit.FieldDeletedAt:
  44369. m.ResetDeletedAt()
  44370. return nil
  44371. case wxcardvisit.FieldUserID:
  44372. m.ResetUserID()
  44373. return nil
  44374. case wxcardvisit.FieldBotID:
  44375. m.ResetBotID()
  44376. return nil
  44377. case wxcardvisit.FieldBotType:
  44378. m.ResetBotType()
  44379. return nil
  44380. }
  44381. return fmt.Errorf("unknown WxCardVisit field %s", name)
  44382. }
  44383. // AddedEdges returns all edge names that were set/added in this mutation.
  44384. func (m *WxCardVisitMutation) AddedEdges() []string {
  44385. edges := make([]string, 0, 0)
  44386. return edges
  44387. }
  44388. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  44389. // name in this mutation.
  44390. func (m *WxCardVisitMutation) AddedIDs(name string) []ent.Value {
  44391. return nil
  44392. }
  44393. // RemovedEdges returns all edge names that were removed in this mutation.
  44394. func (m *WxCardVisitMutation) RemovedEdges() []string {
  44395. edges := make([]string, 0, 0)
  44396. return edges
  44397. }
  44398. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  44399. // the given name in this mutation.
  44400. func (m *WxCardVisitMutation) RemovedIDs(name string) []ent.Value {
  44401. return nil
  44402. }
  44403. // ClearedEdges returns all edge names that were cleared in this mutation.
  44404. func (m *WxCardVisitMutation) ClearedEdges() []string {
  44405. edges := make([]string, 0, 0)
  44406. return edges
  44407. }
  44408. // EdgeCleared returns a boolean which indicates if the edge with the given name
  44409. // was cleared in this mutation.
  44410. func (m *WxCardVisitMutation) EdgeCleared(name string) bool {
  44411. return false
  44412. }
  44413. // ClearEdge clears the value of the edge with the given name. It returns an error
  44414. // if that edge is not defined in the schema.
  44415. func (m *WxCardVisitMutation) ClearEdge(name string) error {
  44416. return fmt.Errorf("unknown WxCardVisit unique edge %s", name)
  44417. }
  44418. // ResetEdge resets all changes to the edge with the given name in this mutation.
  44419. // It returns an error if the edge is not defined in the schema.
  44420. func (m *WxCardVisitMutation) ResetEdge(name string) error {
  44421. return fmt.Errorf("unknown WxCardVisit edge %s", name)
  44422. }