mutation.go 1.4 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344
  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. clearedFields map[string]struct{}
  3989. done bool
  3990. oldValue func(context.Context) (*BatchMsg, error)
  3991. predicates []predicate.BatchMsg
  3992. }
  3993. var _ ent.Mutation = (*BatchMsgMutation)(nil)
  3994. // batchmsgOption allows management of the mutation configuration using functional options.
  3995. type batchmsgOption func(*BatchMsgMutation)
  3996. // newBatchMsgMutation creates new mutation for the BatchMsg entity.
  3997. func newBatchMsgMutation(c config, op Op, opts ...batchmsgOption) *BatchMsgMutation {
  3998. m := &BatchMsgMutation{
  3999. config: c,
  4000. op: op,
  4001. typ: TypeBatchMsg,
  4002. clearedFields: make(map[string]struct{}),
  4003. }
  4004. for _, opt := range opts {
  4005. opt(m)
  4006. }
  4007. return m
  4008. }
  4009. // withBatchMsgID sets the ID field of the mutation.
  4010. func withBatchMsgID(id uint64) batchmsgOption {
  4011. return func(m *BatchMsgMutation) {
  4012. var (
  4013. err error
  4014. once sync.Once
  4015. value *BatchMsg
  4016. )
  4017. m.oldValue = func(ctx context.Context) (*BatchMsg, error) {
  4018. once.Do(func() {
  4019. if m.done {
  4020. err = errors.New("querying old values post mutation is not allowed")
  4021. } else {
  4022. value, err = m.Client().BatchMsg.Get(ctx, id)
  4023. }
  4024. })
  4025. return value, err
  4026. }
  4027. m.id = &id
  4028. }
  4029. }
  4030. // withBatchMsg sets the old BatchMsg of the mutation.
  4031. func withBatchMsg(node *BatchMsg) batchmsgOption {
  4032. return func(m *BatchMsgMutation) {
  4033. m.oldValue = func(context.Context) (*BatchMsg, error) {
  4034. return node, nil
  4035. }
  4036. m.id = &node.ID
  4037. }
  4038. }
  4039. // Client returns a new `ent.Client` from the mutation. If the mutation was
  4040. // executed in a transaction (ent.Tx), a transactional client is returned.
  4041. func (m BatchMsgMutation) Client() *Client {
  4042. client := &Client{config: m.config}
  4043. client.init()
  4044. return client
  4045. }
  4046. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  4047. // it returns an error otherwise.
  4048. func (m BatchMsgMutation) Tx() (*Tx, error) {
  4049. if _, ok := m.driver.(*txDriver); !ok {
  4050. return nil, errors.New("ent: mutation is not running in a transaction")
  4051. }
  4052. tx := &Tx{config: m.config}
  4053. tx.init()
  4054. return tx, nil
  4055. }
  4056. // SetID sets the value of the id field. Note that this
  4057. // operation is only accepted on creation of BatchMsg entities.
  4058. func (m *BatchMsgMutation) SetID(id uint64) {
  4059. m.id = &id
  4060. }
  4061. // ID returns the ID value in the mutation. Note that the ID is only available
  4062. // if it was provided to the builder or after it was returned from the database.
  4063. func (m *BatchMsgMutation) ID() (id uint64, exists bool) {
  4064. if m.id == nil {
  4065. return
  4066. }
  4067. return *m.id, true
  4068. }
  4069. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  4070. // That means, if the mutation is applied within a transaction with an isolation level such
  4071. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  4072. // or updated by the mutation.
  4073. func (m *BatchMsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  4074. switch {
  4075. case m.op.Is(OpUpdateOne | OpDeleteOne):
  4076. id, exists := m.ID()
  4077. if exists {
  4078. return []uint64{id}, nil
  4079. }
  4080. fallthrough
  4081. case m.op.Is(OpUpdate | OpDelete):
  4082. return m.Client().BatchMsg.Query().Where(m.predicates...).IDs(ctx)
  4083. default:
  4084. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  4085. }
  4086. }
  4087. // SetCreatedAt sets the "created_at" field.
  4088. func (m *BatchMsgMutation) SetCreatedAt(t time.Time) {
  4089. m.created_at = &t
  4090. }
  4091. // CreatedAt returns the value of the "created_at" field in the mutation.
  4092. func (m *BatchMsgMutation) CreatedAt() (r time.Time, exists bool) {
  4093. v := m.created_at
  4094. if v == nil {
  4095. return
  4096. }
  4097. return *v, true
  4098. }
  4099. // OldCreatedAt returns the old "created_at" field's value of the BatchMsg entity.
  4100. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4101. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4102. func (m *BatchMsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  4103. if !m.op.Is(OpUpdateOne) {
  4104. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  4105. }
  4106. if m.id == nil || m.oldValue == nil {
  4107. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  4108. }
  4109. oldValue, err := m.oldValue(ctx)
  4110. if err != nil {
  4111. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  4112. }
  4113. return oldValue.CreatedAt, nil
  4114. }
  4115. // ResetCreatedAt resets all changes to the "created_at" field.
  4116. func (m *BatchMsgMutation) ResetCreatedAt() {
  4117. m.created_at = nil
  4118. }
  4119. // SetUpdatedAt sets the "updated_at" field.
  4120. func (m *BatchMsgMutation) SetUpdatedAt(t time.Time) {
  4121. m.updated_at = &t
  4122. }
  4123. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  4124. func (m *BatchMsgMutation) UpdatedAt() (r time.Time, exists bool) {
  4125. v := m.updated_at
  4126. if v == nil {
  4127. return
  4128. }
  4129. return *v, true
  4130. }
  4131. // OldUpdatedAt returns the old "updated_at" field's value of the BatchMsg entity.
  4132. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4133. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4134. func (m *BatchMsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  4135. if !m.op.Is(OpUpdateOne) {
  4136. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  4137. }
  4138. if m.id == nil || m.oldValue == nil {
  4139. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  4140. }
  4141. oldValue, err := m.oldValue(ctx)
  4142. if err != nil {
  4143. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  4144. }
  4145. return oldValue.UpdatedAt, nil
  4146. }
  4147. // ResetUpdatedAt resets all changes to the "updated_at" field.
  4148. func (m *BatchMsgMutation) ResetUpdatedAt() {
  4149. m.updated_at = nil
  4150. }
  4151. // SetDeletedAt sets the "deleted_at" field.
  4152. func (m *BatchMsgMutation) SetDeletedAt(t time.Time) {
  4153. m.deleted_at = &t
  4154. }
  4155. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  4156. func (m *BatchMsgMutation) DeletedAt() (r time.Time, exists bool) {
  4157. v := m.deleted_at
  4158. if v == nil {
  4159. return
  4160. }
  4161. return *v, true
  4162. }
  4163. // OldDeletedAt returns the old "deleted_at" field's value of the BatchMsg entity.
  4164. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4165. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4166. func (m *BatchMsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  4167. if !m.op.Is(OpUpdateOne) {
  4168. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  4169. }
  4170. if m.id == nil || m.oldValue == nil {
  4171. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  4172. }
  4173. oldValue, err := m.oldValue(ctx)
  4174. if err != nil {
  4175. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  4176. }
  4177. return oldValue.DeletedAt, nil
  4178. }
  4179. // ClearDeletedAt clears the value of the "deleted_at" field.
  4180. func (m *BatchMsgMutation) ClearDeletedAt() {
  4181. m.deleted_at = nil
  4182. m.clearedFields[batchmsg.FieldDeletedAt] = struct{}{}
  4183. }
  4184. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  4185. func (m *BatchMsgMutation) DeletedAtCleared() bool {
  4186. _, ok := m.clearedFields[batchmsg.FieldDeletedAt]
  4187. return ok
  4188. }
  4189. // ResetDeletedAt resets all changes to the "deleted_at" field.
  4190. func (m *BatchMsgMutation) ResetDeletedAt() {
  4191. m.deleted_at = nil
  4192. delete(m.clearedFields, batchmsg.FieldDeletedAt)
  4193. }
  4194. // SetStatus sets the "status" field.
  4195. func (m *BatchMsgMutation) SetStatus(u uint8) {
  4196. m.status = &u
  4197. m.addstatus = nil
  4198. }
  4199. // Status returns the value of the "status" field in the mutation.
  4200. func (m *BatchMsgMutation) Status() (r uint8, exists bool) {
  4201. v := m.status
  4202. if v == nil {
  4203. return
  4204. }
  4205. return *v, true
  4206. }
  4207. // OldStatus returns the old "status" field's value of the BatchMsg entity.
  4208. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4209. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4210. func (m *BatchMsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  4211. if !m.op.Is(OpUpdateOne) {
  4212. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  4213. }
  4214. if m.id == nil || m.oldValue == nil {
  4215. return v, errors.New("OldStatus requires an ID field in the mutation")
  4216. }
  4217. oldValue, err := m.oldValue(ctx)
  4218. if err != nil {
  4219. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  4220. }
  4221. return oldValue.Status, nil
  4222. }
  4223. // AddStatus adds u to the "status" field.
  4224. func (m *BatchMsgMutation) AddStatus(u int8) {
  4225. if m.addstatus != nil {
  4226. *m.addstatus += u
  4227. } else {
  4228. m.addstatus = &u
  4229. }
  4230. }
  4231. // AddedStatus returns the value that was added to the "status" field in this mutation.
  4232. func (m *BatchMsgMutation) AddedStatus() (r int8, exists bool) {
  4233. v := m.addstatus
  4234. if v == nil {
  4235. return
  4236. }
  4237. return *v, true
  4238. }
  4239. // ClearStatus clears the value of the "status" field.
  4240. func (m *BatchMsgMutation) ClearStatus() {
  4241. m.status = nil
  4242. m.addstatus = nil
  4243. m.clearedFields[batchmsg.FieldStatus] = struct{}{}
  4244. }
  4245. // StatusCleared returns if the "status" field was cleared in this mutation.
  4246. func (m *BatchMsgMutation) StatusCleared() bool {
  4247. _, ok := m.clearedFields[batchmsg.FieldStatus]
  4248. return ok
  4249. }
  4250. // ResetStatus resets all changes to the "status" field.
  4251. func (m *BatchMsgMutation) ResetStatus() {
  4252. m.status = nil
  4253. m.addstatus = nil
  4254. delete(m.clearedFields, batchmsg.FieldStatus)
  4255. }
  4256. // SetBatchNo sets the "batch_no" field.
  4257. func (m *BatchMsgMutation) SetBatchNo(s string) {
  4258. m.batch_no = &s
  4259. }
  4260. // BatchNo returns the value of the "batch_no" field in the mutation.
  4261. func (m *BatchMsgMutation) BatchNo() (r string, exists bool) {
  4262. v := m.batch_no
  4263. if v == nil {
  4264. return
  4265. }
  4266. return *v, true
  4267. }
  4268. // OldBatchNo returns the old "batch_no" field's value of the BatchMsg entity.
  4269. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4270. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4271. func (m *BatchMsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  4272. if !m.op.Is(OpUpdateOne) {
  4273. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  4274. }
  4275. if m.id == nil || m.oldValue == nil {
  4276. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  4277. }
  4278. oldValue, err := m.oldValue(ctx)
  4279. if err != nil {
  4280. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  4281. }
  4282. return oldValue.BatchNo, nil
  4283. }
  4284. // ClearBatchNo clears the value of the "batch_no" field.
  4285. func (m *BatchMsgMutation) ClearBatchNo() {
  4286. m.batch_no = nil
  4287. m.clearedFields[batchmsg.FieldBatchNo] = struct{}{}
  4288. }
  4289. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  4290. func (m *BatchMsgMutation) BatchNoCleared() bool {
  4291. _, ok := m.clearedFields[batchmsg.FieldBatchNo]
  4292. return ok
  4293. }
  4294. // ResetBatchNo resets all changes to the "batch_no" field.
  4295. func (m *BatchMsgMutation) ResetBatchNo() {
  4296. m.batch_no = nil
  4297. delete(m.clearedFields, batchmsg.FieldBatchNo)
  4298. }
  4299. // SetTaskName sets the "task_name" field.
  4300. func (m *BatchMsgMutation) SetTaskName(s string) {
  4301. m.task_name = &s
  4302. }
  4303. // TaskName returns the value of the "task_name" field in the mutation.
  4304. func (m *BatchMsgMutation) TaskName() (r string, exists bool) {
  4305. v := m.task_name
  4306. if v == nil {
  4307. return
  4308. }
  4309. return *v, true
  4310. }
  4311. // OldTaskName returns the old "task_name" field's value of the BatchMsg entity.
  4312. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4313. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4314. func (m *BatchMsgMutation) OldTaskName(ctx context.Context) (v string, err error) {
  4315. if !m.op.Is(OpUpdateOne) {
  4316. return v, errors.New("OldTaskName is only allowed on UpdateOne operations")
  4317. }
  4318. if m.id == nil || m.oldValue == nil {
  4319. return v, errors.New("OldTaskName requires an ID field in the mutation")
  4320. }
  4321. oldValue, err := m.oldValue(ctx)
  4322. if err != nil {
  4323. return v, fmt.Errorf("querying old value for OldTaskName: %w", err)
  4324. }
  4325. return oldValue.TaskName, nil
  4326. }
  4327. // ClearTaskName clears the value of the "task_name" field.
  4328. func (m *BatchMsgMutation) ClearTaskName() {
  4329. m.task_name = nil
  4330. m.clearedFields[batchmsg.FieldTaskName] = struct{}{}
  4331. }
  4332. // TaskNameCleared returns if the "task_name" field was cleared in this mutation.
  4333. func (m *BatchMsgMutation) TaskNameCleared() bool {
  4334. _, ok := m.clearedFields[batchmsg.FieldTaskName]
  4335. return ok
  4336. }
  4337. // ResetTaskName resets all changes to the "task_name" field.
  4338. func (m *BatchMsgMutation) ResetTaskName() {
  4339. m.task_name = nil
  4340. delete(m.clearedFields, batchmsg.FieldTaskName)
  4341. }
  4342. // SetFromwxid sets the "fromwxid" field.
  4343. func (m *BatchMsgMutation) SetFromwxid(s string) {
  4344. m.fromwxid = &s
  4345. }
  4346. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  4347. func (m *BatchMsgMutation) Fromwxid() (r string, exists bool) {
  4348. v := m.fromwxid
  4349. if v == nil {
  4350. return
  4351. }
  4352. return *v, true
  4353. }
  4354. // OldFromwxid returns the old "fromwxid" field's value of the BatchMsg entity.
  4355. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4356. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4357. func (m *BatchMsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  4358. if !m.op.Is(OpUpdateOne) {
  4359. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  4360. }
  4361. if m.id == nil || m.oldValue == nil {
  4362. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  4363. }
  4364. oldValue, err := m.oldValue(ctx)
  4365. if err != nil {
  4366. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  4367. }
  4368. return oldValue.Fromwxid, nil
  4369. }
  4370. // ClearFromwxid clears the value of the "fromwxid" field.
  4371. func (m *BatchMsgMutation) ClearFromwxid() {
  4372. m.fromwxid = nil
  4373. m.clearedFields[batchmsg.FieldFromwxid] = struct{}{}
  4374. }
  4375. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  4376. func (m *BatchMsgMutation) FromwxidCleared() bool {
  4377. _, ok := m.clearedFields[batchmsg.FieldFromwxid]
  4378. return ok
  4379. }
  4380. // ResetFromwxid resets all changes to the "fromwxid" field.
  4381. func (m *BatchMsgMutation) ResetFromwxid() {
  4382. m.fromwxid = nil
  4383. delete(m.clearedFields, batchmsg.FieldFromwxid)
  4384. }
  4385. // SetMsg sets the "msg" field.
  4386. func (m *BatchMsgMutation) SetMsg(s string) {
  4387. m.msg = &s
  4388. }
  4389. // Msg returns the value of the "msg" field in the mutation.
  4390. func (m *BatchMsgMutation) Msg() (r string, exists bool) {
  4391. v := m.msg
  4392. if v == nil {
  4393. return
  4394. }
  4395. return *v, true
  4396. }
  4397. // OldMsg returns the old "msg" field's value of the BatchMsg entity.
  4398. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4399. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4400. func (m *BatchMsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  4401. if !m.op.Is(OpUpdateOne) {
  4402. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  4403. }
  4404. if m.id == nil || m.oldValue == nil {
  4405. return v, errors.New("OldMsg requires an ID field in the mutation")
  4406. }
  4407. oldValue, err := m.oldValue(ctx)
  4408. if err != nil {
  4409. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  4410. }
  4411. return oldValue.Msg, nil
  4412. }
  4413. // ClearMsg clears the value of the "msg" field.
  4414. func (m *BatchMsgMutation) ClearMsg() {
  4415. m.msg = nil
  4416. m.clearedFields[batchmsg.FieldMsg] = struct{}{}
  4417. }
  4418. // MsgCleared returns if the "msg" field was cleared in this mutation.
  4419. func (m *BatchMsgMutation) MsgCleared() bool {
  4420. _, ok := m.clearedFields[batchmsg.FieldMsg]
  4421. return ok
  4422. }
  4423. // ResetMsg resets all changes to the "msg" field.
  4424. func (m *BatchMsgMutation) ResetMsg() {
  4425. m.msg = nil
  4426. delete(m.clearedFields, batchmsg.FieldMsg)
  4427. }
  4428. // SetTag sets the "tag" field.
  4429. func (m *BatchMsgMutation) SetTag(s string) {
  4430. m.tag = &s
  4431. }
  4432. // Tag returns the value of the "tag" field in the mutation.
  4433. func (m *BatchMsgMutation) Tag() (r string, exists bool) {
  4434. v := m.tag
  4435. if v == nil {
  4436. return
  4437. }
  4438. return *v, true
  4439. }
  4440. // OldTag returns the old "tag" field's value of the BatchMsg entity.
  4441. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4442. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4443. func (m *BatchMsgMutation) OldTag(ctx context.Context) (v string, err error) {
  4444. if !m.op.Is(OpUpdateOne) {
  4445. return v, errors.New("OldTag is only allowed on UpdateOne operations")
  4446. }
  4447. if m.id == nil || m.oldValue == nil {
  4448. return v, errors.New("OldTag requires an ID field in the mutation")
  4449. }
  4450. oldValue, err := m.oldValue(ctx)
  4451. if err != nil {
  4452. return v, fmt.Errorf("querying old value for OldTag: %w", err)
  4453. }
  4454. return oldValue.Tag, nil
  4455. }
  4456. // ClearTag clears the value of the "tag" field.
  4457. func (m *BatchMsgMutation) ClearTag() {
  4458. m.tag = nil
  4459. m.clearedFields[batchmsg.FieldTag] = struct{}{}
  4460. }
  4461. // TagCleared returns if the "tag" field was cleared in this mutation.
  4462. func (m *BatchMsgMutation) TagCleared() bool {
  4463. _, ok := m.clearedFields[batchmsg.FieldTag]
  4464. return ok
  4465. }
  4466. // ResetTag resets all changes to the "tag" field.
  4467. func (m *BatchMsgMutation) ResetTag() {
  4468. m.tag = nil
  4469. delete(m.clearedFields, batchmsg.FieldTag)
  4470. }
  4471. // SetTagids sets the "tagids" field.
  4472. func (m *BatchMsgMutation) SetTagids(s string) {
  4473. m.tagids = &s
  4474. }
  4475. // Tagids returns the value of the "tagids" field in the mutation.
  4476. func (m *BatchMsgMutation) Tagids() (r string, exists bool) {
  4477. v := m.tagids
  4478. if v == nil {
  4479. return
  4480. }
  4481. return *v, true
  4482. }
  4483. // OldTagids returns the old "tagids" field's value of the BatchMsg entity.
  4484. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4485. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4486. func (m *BatchMsgMutation) OldTagids(ctx context.Context) (v string, err error) {
  4487. if !m.op.Is(OpUpdateOne) {
  4488. return v, errors.New("OldTagids is only allowed on UpdateOne operations")
  4489. }
  4490. if m.id == nil || m.oldValue == nil {
  4491. return v, errors.New("OldTagids requires an ID field in the mutation")
  4492. }
  4493. oldValue, err := m.oldValue(ctx)
  4494. if err != nil {
  4495. return v, fmt.Errorf("querying old value for OldTagids: %w", err)
  4496. }
  4497. return oldValue.Tagids, nil
  4498. }
  4499. // ClearTagids clears the value of the "tagids" field.
  4500. func (m *BatchMsgMutation) ClearTagids() {
  4501. m.tagids = nil
  4502. m.clearedFields[batchmsg.FieldTagids] = struct{}{}
  4503. }
  4504. // TagidsCleared returns if the "tagids" field was cleared in this mutation.
  4505. func (m *BatchMsgMutation) TagidsCleared() bool {
  4506. _, ok := m.clearedFields[batchmsg.FieldTagids]
  4507. return ok
  4508. }
  4509. // ResetTagids resets all changes to the "tagids" field.
  4510. func (m *BatchMsgMutation) ResetTagids() {
  4511. m.tagids = nil
  4512. delete(m.clearedFields, batchmsg.FieldTagids)
  4513. }
  4514. // SetTotal sets the "total" field.
  4515. func (m *BatchMsgMutation) SetTotal(i int32) {
  4516. m.total = &i
  4517. m.addtotal = nil
  4518. }
  4519. // Total returns the value of the "total" field in the mutation.
  4520. func (m *BatchMsgMutation) Total() (r int32, exists bool) {
  4521. v := m.total
  4522. if v == nil {
  4523. return
  4524. }
  4525. return *v, true
  4526. }
  4527. // OldTotal returns the old "total" field's value of the BatchMsg entity.
  4528. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4529. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4530. func (m *BatchMsgMutation) OldTotal(ctx context.Context) (v int32, err error) {
  4531. if !m.op.Is(OpUpdateOne) {
  4532. return v, errors.New("OldTotal is only allowed on UpdateOne operations")
  4533. }
  4534. if m.id == nil || m.oldValue == nil {
  4535. return v, errors.New("OldTotal requires an ID field in the mutation")
  4536. }
  4537. oldValue, err := m.oldValue(ctx)
  4538. if err != nil {
  4539. return v, fmt.Errorf("querying old value for OldTotal: %w", err)
  4540. }
  4541. return oldValue.Total, nil
  4542. }
  4543. // AddTotal adds i to the "total" field.
  4544. func (m *BatchMsgMutation) AddTotal(i int32) {
  4545. if m.addtotal != nil {
  4546. *m.addtotal += i
  4547. } else {
  4548. m.addtotal = &i
  4549. }
  4550. }
  4551. // AddedTotal returns the value that was added to the "total" field in this mutation.
  4552. func (m *BatchMsgMutation) AddedTotal() (r int32, exists bool) {
  4553. v := m.addtotal
  4554. if v == nil {
  4555. return
  4556. }
  4557. return *v, true
  4558. }
  4559. // ClearTotal clears the value of the "total" field.
  4560. func (m *BatchMsgMutation) ClearTotal() {
  4561. m.total = nil
  4562. m.addtotal = nil
  4563. m.clearedFields[batchmsg.FieldTotal] = struct{}{}
  4564. }
  4565. // TotalCleared returns if the "total" field was cleared in this mutation.
  4566. func (m *BatchMsgMutation) TotalCleared() bool {
  4567. _, ok := m.clearedFields[batchmsg.FieldTotal]
  4568. return ok
  4569. }
  4570. // ResetTotal resets all changes to the "total" field.
  4571. func (m *BatchMsgMutation) ResetTotal() {
  4572. m.total = nil
  4573. m.addtotal = nil
  4574. delete(m.clearedFields, batchmsg.FieldTotal)
  4575. }
  4576. // SetSuccess sets the "success" field.
  4577. func (m *BatchMsgMutation) SetSuccess(i int32) {
  4578. m.success = &i
  4579. m.addsuccess = nil
  4580. }
  4581. // Success returns the value of the "success" field in the mutation.
  4582. func (m *BatchMsgMutation) Success() (r int32, exists bool) {
  4583. v := m.success
  4584. if v == nil {
  4585. return
  4586. }
  4587. return *v, true
  4588. }
  4589. // OldSuccess returns the old "success" field's value of the BatchMsg entity.
  4590. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4591. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4592. func (m *BatchMsgMutation) OldSuccess(ctx context.Context) (v int32, err error) {
  4593. if !m.op.Is(OpUpdateOne) {
  4594. return v, errors.New("OldSuccess is only allowed on UpdateOne operations")
  4595. }
  4596. if m.id == nil || m.oldValue == nil {
  4597. return v, errors.New("OldSuccess requires an ID field in the mutation")
  4598. }
  4599. oldValue, err := m.oldValue(ctx)
  4600. if err != nil {
  4601. return v, fmt.Errorf("querying old value for OldSuccess: %w", err)
  4602. }
  4603. return oldValue.Success, nil
  4604. }
  4605. // AddSuccess adds i to the "success" field.
  4606. func (m *BatchMsgMutation) AddSuccess(i int32) {
  4607. if m.addsuccess != nil {
  4608. *m.addsuccess += i
  4609. } else {
  4610. m.addsuccess = &i
  4611. }
  4612. }
  4613. // AddedSuccess returns the value that was added to the "success" field in this mutation.
  4614. func (m *BatchMsgMutation) AddedSuccess() (r int32, exists bool) {
  4615. v := m.addsuccess
  4616. if v == nil {
  4617. return
  4618. }
  4619. return *v, true
  4620. }
  4621. // ClearSuccess clears the value of the "success" field.
  4622. func (m *BatchMsgMutation) ClearSuccess() {
  4623. m.success = nil
  4624. m.addsuccess = nil
  4625. m.clearedFields[batchmsg.FieldSuccess] = struct{}{}
  4626. }
  4627. // SuccessCleared returns if the "success" field was cleared in this mutation.
  4628. func (m *BatchMsgMutation) SuccessCleared() bool {
  4629. _, ok := m.clearedFields[batchmsg.FieldSuccess]
  4630. return ok
  4631. }
  4632. // ResetSuccess resets all changes to the "success" field.
  4633. func (m *BatchMsgMutation) ResetSuccess() {
  4634. m.success = nil
  4635. m.addsuccess = nil
  4636. delete(m.clearedFields, batchmsg.FieldSuccess)
  4637. }
  4638. // SetFail sets the "fail" field.
  4639. func (m *BatchMsgMutation) SetFail(i int32) {
  4640. m.fail = &i
  4641. m.addfail = nil
  4642. }
  4643. // Fail returns the value of the "fail" field in the mutation.
  4644. func (m *BatchMsgMutation) Fail() (r int32, exists bool) {
  4645. v := m.fail
  4646. if v == nil {
  4647. return
  4648. }
  4649. return *v, true
  4650. }
  4651. // OldFail returns the old "fail" field's value of the BatchMsg entity.
  4652. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4653. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4654. func (m *BatchMsgMutation) OldFail(ctx context.Context) (v int32, err error) {
  4655. if !m.op.Is(OpUpdateOne) {
  4656. return v, errors.New("OldFail is only allowed on UpdateOne operations")
  4657. }
  4658. if m.id == nil || m.oldValue == nil {
  4659. return v, errors.New("OldFail requires an ID field in the mutation")
  4660. }
  4661. oldValue, err := m.oldValue(ctx)
  4662. if err != nil {
  4663. return v, fmt.Errorf("querying old value for OldFail: %w", err)
  4664. }
  4665. return oldValue.Fail, nil
  4666. }
  4667. // AddFail adds i to the "fail" field.
  4668. func (m *BatchMsgMutation) AddFail(i int32) {
  4669. if m.addfail != nil {
  4670. *m.addfail += i
  4671. } else {
  4672. m.addfail = &i
  4673. }
  4674. }
  4675. // AddedFail returns the value that was added to the "fail" field in this mutation.
  4676. func (m *BatchMsgMutation) AddedFail() (r int32, exists bool) {
  4677. v := m.addfail
  4678. if v == nil {
  4679. return
  4680. }
  4681. return *v, true
  4682. }
  4683. // ClearFail clears the value of the "fail" field.
  4684. func (m *BatchMsgMutation) ClearFail() {
  4685. m.fail = nil
  4686. m.addfail = nil
  4687. m.clearedFields[batchmsg.FieldFail] = struct{}{}
  4688. }
  4689. // FailCleared returns if the "fail" field was cleared in this mutation.
  4690. func (m *BatchMsgMutation) FailCleared() bool {
  4691. _, ok := m.clearedFields[batchmsg.FieldFail]
  4692. return ok
  4693. }
  4694. // ResetFail resets all changes to the "fail" field.
  4695. func (m *BatchMsgMutation) ResetFail() {
  4696. m.fail = nil
  4697. m.addfail = nil
  4698. delete(m.clearedFields, batchmsg.FieldFail)
  4699. }
  4700. // SetStartTime sets the "start_time" field.
  4701. func (m *BatchMsgMutation) SetStartTime(t time.Time) {
  4702. m.start_time = &t
  4703. }
  4704. // StartTime returns the value of the "start_time" field in the mutation.
  4705. func (m *BatchMsgMutation) StartTime() (r time.Time, exists bool) {
  4706. v := m.start_time
  4707. if v == nil {
  4708. return
  4709. }
  4710. return *v, true
  4711. }
  4712. // OldStartTime returns the old "start_time" field's value of the BatchMsg entity.
  4713. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4714. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4715. func (m *BatchMsgMutation) OldStartTime(ctx context.Context) (v time.Time, err error) {
  4716. if !m.op.Is(OpUpdateOne) {
  4717. return v, errors.New("OldStartTime is only allowed on UpdateOne operations")
  4718. }
  4719. if m.id == nil || m.oldValue == nil {
  4720. return v, errors.New("OldStartTime requires an ID field in the mutation")
  4721. }
  4722. oldValue, err := m.oldValue(ctx)
  4723. if err != nil {
  4724. return v, fmt.Errorf("querying old value for OldStartTime: %w", err)
  4725. }
  4726. return oldValue.StartTime, nil
  4727. }
  4728. // ClearStartTime clears the value of the "start_time" field.
  4729. func (m *BatchMsgMutation) ClearStartTime() {
  4730. m.start_time = nil
  4731. m.clearedFields[batchmsg.FieldStartTime] = struct{}{}
  4732. }
  4733. // StartTimeCleared returns if the "start_time" field was cleared in this mutation.
  4734. func (m *BatchMsgMutation) StartTimeCleared() bool {
  4735. _, ok := m.clearedFields[batchmsg.FieldStartTime]
  4736. return ok
  4737. }
  4738. // ResetStartTime resets all changes to the "start_time" field.
  4739. func (m *BatchMsgMutation) ResetStartTime() {
  4740. m.start_time = nil
  4741. delete(m.clearedFields, batchmsg.FieldStartTime)
  4742. }
  4743. // SetStopTime sets the "stop_time" field.
  4744. func (m *BatchMsgMutation) SetStopTime(t time.Time) {
  4745. m.stop_time = &t
  4746. }
  4747. // StopTime returns the value of the "stop_time" field in the mutation.
  4748. func (m *BatchMsgMutation) StopTime() (r time.Time, exists bool) {
  4749. v := m.stop_time
  4750. if v == nil {
  4751. return
  4752. }
  4753. return *v, true
  4754. }
  4755. // OldStopTime returns the old "stop_time" field's value of the BatchMsg entity.
  4756. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4757. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4758. func (m *BatchMsgMutation) OldStopTime(ctx context.Context) (v time.Time, err error) {
  4759. if !m.op.Is(OpUpdateOne) {
  4760. return v, errors.New("OldStopTime is only allowed on UpdateOne operations")
  4761. }
  4762. if m.id == nil || m.oldValue == nil {
  4763. return v, errors.New("OldStopTime requires an ID field in the mutation")
  4764. }
  4765. oldValue, err := m.oldValue(ctx)
  4766. if err != nil {
  4767. return v, fmt.Errorf("querying old value for OldStopTime: %w", err)
  4768. }
  4769. return oldValue.StopTime, nil
  4770. }
  4771. // ClearStopTime clears the value of the "stop_time" field.
  4772. func (m *BatchMsgMutation) ClearStopTime() {
  4773. m.stop_time = nil
  4774. m.clearedFields[batchmsg.FieldStopTime] = struct{}{}
  4775. }
  4776. // StopTimeCleared returns if the "stop_time" field was cleared in this mutation.
  4777. func (m *BatchMsgMutation) StopTimeCleared() bool {
  4778. _, ok := m.clearedFields[batchmsg.FieldStopTime]
  4779. return ok
  4780. }
  4781. // ResetStopTime resets all changes to the "stop_time" field.
  4782. func (m *BatchMsgMutation) ResetStopTime() {
  4783. m.stop_time = nil
  4784. delete(m.clearedFields, batchmsg.FieldStopTime)
  4785. }
  4786. // SetSendTime sets the "send_time" field.
  4787. func (m *BatchMsgMutation) SetSendTime(t time.Time) {
  4788. m.send_time = &t
  4789. }
  4790. // SendTime returns the value of the "send_time" field in the mutation.
  4791. func (m *BatchMsgMutation) SendTime() (r time.Time, exists bool) {
  4792. v := m.send_time
  4793. if v == nil {
  4794. return
  4795. }
  4796. return *v, true
  4797. }
  4798. // OldSendTime returns the old "send_time" field's value of the BatchMsg entity.
  4799. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4800. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4801. func (m *BatchMsgMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  4802. if !m.op.Is(OpUpdateOne) {
  4803. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  4804. }
  4805. if m.id == nil || m.oldValue == nil {
  4806. return v, errors.New("OldSendTime requires an ID field in the mutation")
  4807. }
  4808. oldValue, err := m.oldValue(ctx)
  4809. if err != nil {
  4810. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  4811. }
  4812. return oldValue.SendTime, nil
  4813. }
  4814. // ClearSendTime clears the value of the "send_time" field.
  4815. func (m *BatchMsgMutation) ClearSendTime() {
  4816. m.send_time = nil
  4817. m.clearedFields[batchmsg.FieldSendTime] = struct{}{}
  4818. }
  4819. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  4820. func (m *BatchMsgMutation) SendTimeCleared() bool {
  4821. _, ok := m.clearedFields[batchmsg.FieldSendTime]
  4822. return ok
  4823. }
  4824. // ResetSendTime resets all changes to the "send_time" field.
  4825. func (m *BatchMsgMutation) ResetSendTime() {
  4826. m.send_time = nil
  4827. delete(m.clearedFields, batchmsg.FieldSendTime)
  4828. }
  4829. // SetType sets the "type" field.
  4830. func (m *BatchMsgMutation) SetType(i int32) {
  4831. m._type = &i
  4832. m.add_type = nil
  4833. }
  4834. // GetType returns the value of the "type" field in the mutation.
  4835. func (m *BatchMsgMutation) GetType() (r int32, exists bool) {
  4836. v := m._type
  4837. if v == nil {
  4838. return
  4839. }
  4840. return *v, true
  4841. }
  4842. // OldType returns the old "type" field's value of the BatchMsg entity.
  4843. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4844. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4845. func (m *BatchMsgMutation) OldType(ctx context.Context) (v int32, err error) {
  4846. if !m.op.Is(OpUpdateOne) {
  4847. return v, errors.New("OldType is only allowed on UpdateOne operations")
  4848. }
  4849. if m.id == nil || m.oldValue == nil {
  4850. return v, errors.New("OldType requires an ID field in the mutation")
  4851. }
  4852. oldValue, err := m.oldValue(ctx)
  4853. if err != nil {
  4854. return v, fmt.Errorf("querying old value for OldType: %w", err)
  4855. }
  4856. return oldValue.Type, nil
  4857. }
  4858. // AddType adds i to the "type" field.
  4859. func (m *BatchMsgMutation) AddType(i int32) {
  4860. if m.add_type != nil {
  4861. *m.add_type += i
  4862. } else {
  4863. m.add_type = &i
  4864. }
  4865. }
  4866. // AddedType returns the value that was added to the "type" field in this mutation.
  4867. func (m *BatchMsgMutation) AddedType() (r int32, exists bool) {
  4868. v := m.add_type
  4869. if v == nil {
  4870. return
  4871. }
  4872. return *v, true
  4873. }
  4874. // ClearType clears the value of the "type" field.
  4875. func (m *BatchMsgMutation) ClearType() {
  4876. m._type = nil
  4877. m.add_type = nil
  4878. m.clearedFields[batchmsg.FieldType] = struct{}{}
  4879. }
  4880. // TypeCleared returns if the "type" field was cleared in this mutation.
  4881. func (m *BatchMsgMutation) TypeCleared() bool {
  4882. _, ok := m.clearedFields[batchmsg.FieldType]
  4883. return ok
  4884. }
  4885. // ResetType resets all changes to the "type" field.
  4886. func (m *BatchMsgMutation) ResetType() {
  4887. m._type = nil
  4888. m.add_type = nil
  4889. delete(m.clearedFields, batchmsg.FieldType)
  4890. }
  4891. // SetOrganizationID sets the "organization_id" field.
  4892. func (m *BatchMsgMutation) SetOrganizationID(u uint64) {
  4893. m.organization_id = &u
  4894. m.addorganization_id = nil
  4895. }
  4896. // OrganizationID returns the value of the "organization_id" field in the mutation.
  4897. func (m *BatchMsgMutation) OrganizationID() (r uint64, exists bool) {
  4898. v := m.organization_id
  4899. if v == nil {
  4900. return
  4901. }
  4902. return *v, true
  4903. }
  4904. // OldOrganizationID returns the old "organization_id" field's value of the BatchMsg entity.
  4905. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4906. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4907. func (m *BatchMsgMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  4908. if !m.op.Is(OpUpdateOne) {
  4909. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  4910. }
  4911. if m.id == nil || m.oldValue == nil {
  4912. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  4913. }
  4914. oldValue, err := m.oldValue(ctx)
  4915. if err != nil {
  4916. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  4917. }
  4918. return oldValue.OrganizationID, nil
  4919. }
  4920. // AddOrganizationID adds u to the "organization_id" field.
  4921. func (m *BatchMsgMutation) AddOrganizationID(u int64) {
  4922. if m.addorganization_id != nil {
  4923. *m.addorganization_id += u
  4924. } else {
  4925. m.addorganization_id = &u
  4926. }
  4927. }
  4928. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  4929. func (m *BatchMsgMutation) AddedOrganizationID() (r int64, exists bool) {
  4930. v := m.addorganization_id
  4931. if v == nil {
  4932. return
  4933. }
  4934. return *v, true
  4935. }
  4936. // ResetOrganizationID resets all changes to the "organization_id" field.
  4937. func (m *BatchMsgMutation) ResetOrganizationID() {
  4938. m.organization_id = nil
  4939. m.addorganization_id = nil
  4940. }
  4941. // Where appends a list predicates to the BatchMsgMutation builder.
  4942. func (m *BatchMsgMutation) Where(ps ...predicate.BatchMsg) {
  4943. m.predicates = append(m.predicates, ps...)
  4944. }
  4945. // WhereP appends storage-level predicates to the BatchMsgMutation builder. Using this method,
  4946. // users can use type-assertion to append predicates that do not depend on any generated package.
  4947. func (m *BatchMsgMutation) WhereP(ps ...func(*sql.Selector)) {
  4948. p := make([]predicate.BatchMsg, len(ps))
  4949. for i := range ps {
  4950. p[i] = ps[i]
  4951. }
  4952. m.Where(p...)
  4953. }
  4954. // Op returns the operation name.
  4955. func (m *BatchMsgMutation) Op() Op {
  4956. return m.op
  4957. }
  4958. // SetOp allows setting the mutation operation.
  4959. func (m *BatchMsgMutation) SetOp(op Op) {
  4960. m.op = op
  4961. }
  4962. // Type returns the node type of this mutation (BatchMsg).
  4963. func (m *BatchMsgMutation) Type() string {
  4964. return m.typ
  4965. }
  4966. // Fields returns all fields that were changed during this mutation. Note that in
  4967. // order to get all numeric fields that were incremented/decremented, call
  4968. // AddedFields().
  4969. func (m *BatchMsgMutation) Fields() []string {
  4970. fields := make([]string, 0, 18)
  4971. if m.created_at != nil {
  4972. fields = append(fields, batchmsg.FieldCreatedAt)
  4973. }
  4974. if m.updated_at != nil {
  4975. fields = append(fields, batchmsg.FieldUpdatedAt)
  4976. }
  4977. if m.deleted_at != nil {
  4978. fields = append(fields, batchmsg.FieldDeletedAt)
  4979. }
  4980. if m.status != nil {
  4981. fields = append(fields, batchmsg.FieldStatus)
  4982. }
  4983. if m.batch_no != nil {
  4984. fields = append(fields, batchmsg.FieldBatchNo)
  4985. }
  4986. if m.task_name != nil {
  4987. fields = append(fields, batchmsg.FieldTaskName)
  4988. }
  4989. if m.fromwxid != nil {
  4990. fields = append(fields, batchmsg.FieldFromwxid)
  4991. }
  4992. if m.msg != nil {
  4993. fields = append(fields, batchmsg.FieldMsg)
  4994. }
  4995. if m.tag != nil {
  4996. fields = append(fields, batchmsg.FieldTag)
  4997. }
  4998. if m.tagids != nil {
  4999. fields = append(fields, batchmsg.FieldTagids)
  5000. }
  5001. if m.total != nil {
  5002. fields = append(fields, batchmsg.FieldTotal)
  5003. }
  5004. if m.success != nil {
  5005. fields = append(fields, batchmsg.FieldSuccess)
  5006. }
  5007. if m.fail != nil {
  5008. fields = append(fields, batchmsg.FieldFail)
  5009. }
  5010. if m.start_time != nil {
  5011. fields = append(fields, batchmsg.FieldStartTime)
  5012. }
  5013. if m.stop_time != nil {
  5014. fields = append(fields, batchmsg.FieldStopTime)
  5015. }
  5016. if m.send_time != nil {
  5017. fields = append(fields, batchmsg.FieldSendTime)
  5018. }
  5019. if m._type != nil {
  5020. fields = append(fields, batchmsg.FieldType)
  5021. }
  5022. if m.organization_id != nil {
  5023. fields = append(fields, batchmsg.FieldOrganizationID)
  5024. }
  5025. return fields
  5026. }
  5027. // Field returns the value of a field with the given name. The second boolean
  5028. // return value indicates that this field was not set, or was not defined in the
  5029. // schema.
  5030. func (m *BatchMsgMutation) Field(name string) (ent.Value, bool) {
  5031. switch name {
  5032. case batchmsg.FieldCreatedAt:
  5033. return m.CreatedAt()
  5034. case batchmsg.FieldUpdatedAt:
  5035. return m.UpdatedAt()
  5036. case batchmsg.FieldDeletedAt:
  5037. return m.DeletedAt()
  5038. case batchmsg.FieldStatus:
  5039. return m.Status()
  5040. case batchmsg.FieldBatchNo:
  5041. return m.BatchNo()
  5042. case batchmsg.FieldTaskName:
  5043. return m.TaskName()
  5044. case batchmsg.FieldFromwxid:
  5045. return m.Fromwxid()
  5046. case batchmsg.FieldMsg:
  5047. return m.Msg()
  5048. case batchmsg.FieldTag:
  5049. return m.Tag()
  5050. case batchmsg.FieldTagids:
  5051. return m.Tagids()
  5052. case batchmsg.FieldTotal:
  5053. return m.Total()
  5054. case batchmsg.FieldSuccess:
  5055. return m.Success()
  5056. case batchmsg.FieldFail:
  5057. return m.Fail()
  5058. case batchmsg.FieldStartTime:
  5059. return m.StartTime()
  5060. case batchmsg.FieldStopTime:
  5061. return m.StopTime()
  5062. case batchmsg.FieldSendTime:
  5063. return m.SendTime()
  5064. case batchmsg.FieldType:
  5065. return m.GetType()
  5066. case batchmsg.FieldOrganizationID:
  5067. return m.OrganizationID()
  5068. }
  5069. return nil, false
  5070. }
  5071. // OldField returns the old value of the field from the database. An error is
  5072. // returned if the mutation operation is not UpdateOne, or the query to the
  5073. // database failed.
  5074. func (m *BatchMsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  5075. switch name {
  5076. case batchmsg.FieldCreatedAt:
  5077. return m.OldCreatedAt(ctx)
  5078. case batchmsg.FieldUpdatedAt:
  5079. return m.OldUpdatedAt(ctx)
  5080. case batchmsg.FieldDeletedAt:
  5081. return m.OldDeletedAt(ctx)
  5082. case batchmsg.FieldStatus:
  5083. return m.OldStatus(ctx)
  5084. case batchmsg.FieldBatchNo:
  5085. return m.OldBatchNo(ctx)
  5086. case batchmsg.FieldTaskName:
  5087. return m.OldTaskName(ctx)
  5088. case batchmsg.FieldFromwxid:
  5089. return m.OldFromwxid(ctx)
  5090. case batchmsg.FieldMsg:
  5091. return m.OldMsg(ctx)
  5092. case batchmsg.FieldTag:
  5093. return m.OldTag(ctx)
  5094. case batchmsg.FieldTagids:
  5095. return m.OldTagids(ctx)
  5096. case batchmsg.FieldTotal:
  5097. return m.OldTotal(ctx)
  5098. case batchmsg.FieldSuccess:
  5099. return m.OldSuccess(ctx)
  5100. case batchmsg.FieldFail:
  5101. return m.OldFail(ctx)
  5102. case batchmsg.FieldStartTime:
  5103. return m.OldStartTime(ctx)
  5104. case batchmsg.FieldStopTime:
  5105. return m.OldStopTime(ctx)
  5106. case batchmsg.FieldSendTime:
  5107. return m.OldSendTime(ctx)
  5108. case batchmsg.FieldType:
  5109. return m.OldType(ctx)
  5110. case batchmsg.FieldOrganizationID:
  5111. return m.OldOrganizationID(ctx)
  5112. }
  5113. return nil, fmt.Errorf("unknown BatchMsg field %s", name)
  5114. }
  5115. // SetField sets the value of a field with the given name. It returns an error if
  5116. // the field is not defined in the schema, or if the type mismatched the field
  5117. // type.
  5118. func (m *BatchMsgMutation) SetField(name string, value ent.Value) error {
  5119. switch name {
  5120. case batchmsg.FieldCreatedAt:
  5121. v, ok := value.(time.Time)
  5122. if !ok {
  5123. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5124. }
  5125. m.SetCreatedAt(v)
  5126. return nil
  5127. case batchmsg.FieldUpdatedAt:
  5128. v, ok := value.(time.Time)
  5129. if !ok {
  5130. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5131. }
  5132. m.SetUpdatedAt(v)
  5133. return nil
  5134. case batchmsg.FieldDeletedAt:
  5135. v, ok := value.(time.Time)
  5136. if !ok {
  5137. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5138. }
  5139. m.SetDeletedAt(v)
  5140. return nil
  5141. case batchmsg.FieldStatus:
  5142. v, ok := value.(uint8)
  5143. if !ok {
  5144. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5145. }
  5146. m.SetStatus(v)
  5147. return nil
  5148. case batchmsg.FieldBatchNo:
  5149. v, ok := value.(string)
  5150. if !ok {
  5151. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5152. }
  5153. m.SetBatchNo(v)
  5154. return nil
  5155. case batchmsg.FieldTaskName:
  5156. v, ok := value.(string)
  5157. if !ok {
  5158. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5159. }
  5160. m.SetTaskName(v)
  5161. return nil
  5162. case batchmsg.FieldFromwxid:
  5163. v, ok := value.(string)
  5164. if !ok {
  5165. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5166. }
  5167. m.SetFromwxid(v)
  5168. return nil
  5169. case batchmsg.FieldMsg:
  5170. v, ok := value.(string)
  5171. if !ok {
  5172. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5173. }
  5174. m.SetMsg(v)
  5175. return nil
  5176. case batchmsg.FieldTag:
  5177. v, ok := value.(string)
  5178. if !ok {
  5179. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5180. }
  5181. m.SetTag(v)
  5182. return nil
  5183. case batchmsg.FieldTagids:
  5184. v, ok := value.(string)
  5185. if !ok {
  5186. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5187. }
  5188. m.SetTagids(v)
  5189. return nil
  5190. case batchmsg.FieldTotal:
  5191. v, ok := value.(int32)
  5192. if !ok {
  5193. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5194. }
  5195. m.SetTotal(v)
  5196. return nil
  5197. case batchmsg.FieldSuccess:
  5198. v, ok := value.(int32)
  5199. if !ok {
  5200. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5201. }
  5202. m.SetSuccess(v)
  5203. return nil
  5204. case batchmsg.FieldFail:
  5205. v, ok := value.(int32)
  5206. if !ok {
  5207. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5208. }
  5209. m.SetFail(v)
  5210. return nil
  5211. case batchmsg.FieldStartTime:
  5212. v, ok := value.(time.Time)
  5213. if !ok {
  5214. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5215. }
  5216. m.SetStartTime(v)
  5217. return nil
  5218. case batchmsg.FieldStopTime:
  5219. v, ok := value.(time.Time)
  5220. if !ok {
  5221. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5222. }
  5223. m.SetStopTime(v)
  5224. return nil
  5225. case batchmsg.FieldSendTime:
  5226. v, ok := value.(time.Time)
  5227. if !ok {
  5228. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5229. }
  5230. m.SetSendTime(v)
  5231. return nil
  5232. case batchmsg.FieldType:
  5233. v, ok := value.(int32)
  5234. if !ok {
  5235. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5236. }
  5237. m.SetType(v)
  5238. return nil
  5239. case batchmsg.FieldOrganizationID:
  5240. v, ok := value.(uint64)
  5241. if !ok {
  5242. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5243. }
  5244. m.SetOrganizationID(v)
  5245. return nil
  5246. }
  5247. return fmt.Errorf("unknown BatchMsg field %s", name)
  5248. }
  5249. // AddedFields returns all numeric fields that were incremented/decremented during
  5250. // this mutation.
  5251. func (m *BatchMsgMutation) AddedFields() []string {
  5252. var fields []string
  5253. if m.addstatus != nil {
  5254. fields = append(fields, batchmsg.FieldStatus)
  5255. }
  5256. if m.addtotal != nil {
  5257. fields = append(fields, batchmsg.FieldTotal)
  5258. }
  5259. if m.addsuccess != nil {
  5260. fields = append(fields, batchmsg.FieldSuccess)
  5261. }
  5262. if m.addfail != nil {
  5263. fields = append(fields, batchmsg.FieldFail)
  5264. }
  5265. if m.add_type != nil {
  5266. fields = append(fields, batchmsg.FieldType)
  5267. }
  5268. if m.addorganization_id != nil {
  5269. fields = append(fields, batchmsg.FieldOrganizationID)
  5270. }
  5271. return fields
  5272. }
  5273. // AddedField returns the numeric value that was incremented/decremented on a field
  5274. // with the given name. The second boolean return value indicates that this field
  5275. // was not set, or was not defined in the schema.
  5276. func (m *BatchMsgMutation) AddedField(name string) (ent.Value, bool) {
  5277. switch name {
  5278. case batchmsg.FieldStatus:
  5279. return m.AddedStatus()
  5280. case batchmsg.FieldTotal:
  5281. return m.AddedTotal()
  5282. case batchmsg.FieldSuccess:
  5283. return m.AddedSuccess()
  5284. case batchmsg.FieldFail:
  5285. return m.AddedFail()
  5286. case batchmsg.FieldType:
  5287. return m.AddedType()
  5288. case batchmsg.FieldOrganizationID:
  5289. return m.AddedOrganizationID()
  5290. }
  5291. return nil, false
  5292. }
  5293. // AddField adds the value to the field with the given name. It returns an error if
  5294. // the field is not defined in the schema, or if the type mismatched the field
  5295. // type.
  5296. func (m *BatchMsgMutation) AddField(name string, value ent.Value) error {
  5297. switch name {
  5298. case batchmsg.FieldStatus:
  5299. v, ok := value.(int8)
  5300. if !ok {
  5301. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5302. }
  5303. m.AddStatus(v)
  5304. return nil
  5305. case batchmsg.FieldTotal:
  5306. v, ok := value.(int32)
  5307. if !ok {
  5308. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5309. }
  5310. m.AddTotal(v)
  5311. return nil
  5312. case batchmsg.FieldSuccess:
  5313. v, ok := value.(int32)
  5314. if !ok {
  5315. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5316. }
  5317. m.AddSuccess(v)
  5318. return nil
  5319. case batchmsg.FieldFail:
  5320. v, ok := value.(int32)
  5321. if !ok {
  5322. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5323. }
  5324. m.AddFail(v)
  5325. return nil
  5326. case batchmsg.FieldType:
  5327. v, ok := value.(int32)
  5328. if !ok {
  5329. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5330. }
  5331. m.AddType(v)
  5332. return nil
  5333. case batchmsg.FieldOrganizationID:
  5334. v, ok := value.(int64)
  5335. if !ok {
  5336. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5337. }
  5338. m.AddOrganizationID(v)
  5339. return nil
  5340. }
  5341. return fmt.Errorf("unknown BatchMsg numeric field %s", name)
  5342. }
  5343. // ClearedFields returns all nullable fields that were cleared during this
  5344. // mutation.
  5345. func (m *BatchMsgMutation) ClearedFields() []string {
  5346. var fields []string
  5347. if m.FieldCleared(batchmsg.FieldDeletedAt) {
  5348. fields = append(fields, batchmsg.FieldDeletedAt)
  5349. }
  5350. if m.FieldCleared(batchmsg.FieldStatus) {
  5351. fields = append(fields, batchmsg.FieldStatus)
  5352. }
  5353. if m.FieldCleared(batchmsg.FieldBatchNo) {
  5354. fields = append(fields, batchmsg.FieldBatchNo)
  5355. }
  5356. if m.FieldCleared(batchmsg.FieldTaskName) {
  5357. fields = append(fields, batchmsg.FieldTaskName)
  5358. }
  5359. if m.FieldCleared(batchmsg.FieldFromwxid) {
  5360. fields = append(fields, batchmsg.FieldFromwxid)
  5361. }
  5362. if m.FieldCleared(batchmsg.FieldMsg) {
  5363. fields = append(fields, batchmsg.FieldMsg)
  5364. }
  5365. if m.FieldCleared(batchmsg.FieldTag) {
  5366. fields = append(fields, batchmsg.FieldTag)
  5367. }
  5368. if m.FieldCleared(batchmsg.FieldTagids) {
  5369. fields = append(fields, batchmsg.FieldTagids)
  5370. }
  5371. if m.FieldCleared(batchmsg.FieldTotal) {
  5372. fields = append(fields, batchmsg.FieldTotal)
  5373. }
  5374. if m.FieldCleared(batchmsg.FieldSuccess) {
  5375. fields = append(fields, batchmsg.FieldSuccess)
  5376. }
  5377. if m.FieldCleared(batchmsg.FieldFail) {
  5378. fields = append(fields, batchmsg.FieldFail)
  5379. }
  5380. if m.FieldCleared(batchmsg.FieldStartTime) {
  5381. fields = append(fields, batchmsg.FieldStartTime)
  5382. }
  5383. if m.FieldCleared(batchmsg.FieldStopTime) {
  5384. fields = append(fields, batchmsg.FieldStopTime)
  5385. }
  5386. if m.FieldCleared(batchmsg.FieldSendTime) {
  5387. fields = append(fields, batchmsg.FieldSendTime)
  5388. }
  5389. if m.FieldCleared(batchmsg.FieldType) {
  5390. fields = append(fields, batchmsg.FieldType)
  5391. }
  5392. return fields
  5393. }
  5394. // FieldCleared returns a boolean indicating if a field with the given name was
  5395. // cleared in this mutation.
  5396. func (m *BatchMsgMutation) FieldCleared(name string) bool {
  5397. _, ok := m.clearedFields[name]
  5398. return ok
  5399. }
  5400. // ClearField clears the value of the field with the given name. It returns an
  5401. // error if the field is not defined in the schema.
  5402. func (m *BatchMsgMutation) ClearField(name string) error {
  5403. switch name {
  5404. case batchmsg.FieldDeletedAt:
  5405. m.ClearDeletedAt()
  5406. return nil
  5407. case batchmsg.FieldStatus:
  5408. m.ClearStatus()
  5409. return nil
  5410. case batchmsg.FieldBatchNo:
  5411. m.ClearBatchNo()
  5412. return nil
  5413. case batchmsg.FieldTaskName:
  5414. m.ClearTaskName()
  5415. return nil
  5416. case batchmsg.FieldFromwxid:
  5417. m.ClearFromwxid()
  5418. return nil
  5419. case batchmsg.FieldMsg:
  5420. m.ClearMsg()
  5421. return nil
  5422. case batchmsg.FieldTag:
  5423. m.ClearTag()
  5424. return nil
  5425. case batchmsg.FieldTagids:
  5426. m.ClearTagids()
  5427. return nil
  5428. case batchmsg.FieldTotal:
  5429. m.ClearTotal()
  5430. return nil
  5431. case batchmsg.FieldSuccess:
  5432. m.ClearSuccess()
  5433. return nil
  5434. case batchmsg.FieldFail:
  5435. m.ClearFail()
  5436. return nil
  5437. case batchmsg.FieldStartTime:
  5438. m.ClearStartTime()
  5439. return nil
  5440. case batchmsg.FieldStopTime:
  5441. m.ClearStopTime()
  5442. return nil
  5443. case batchmsg.FieldSendTime:
  5444. m.ClearSendTime()
  5445. return nil
  5446. case batchmsg.FieldType:
  5447. m.ClearType()
  5448. return nil
  5449. }
  5450. return fmt.Errorf("unknown BatchMsg nullable field %s", name)
  5451. }
  5452. // ResetField resets all changes in the mutation for the field with the given name.
  5453. // It returns an error if the field is not defined in the schema.
  5454. func (m *BatchMsgMutation) ResetField(name string) error {
  5455. switch name {
  5456. case batchmsg.FieldCreatedAt:
  5457. m.ResetCreatedAt()
  5458. return nil
  5459. case batchmsg.FieldUpdatedAt:
  5460. m.ResetUpdatedAt()
  5461. return nil
  5462. case batchmsg.FieldDeletedAt:
  5463. m.ResetDeletedAt()
  5464. return nil
  5465. case batchmsg.FieldStatus:
  5466. m.ResetStatus()
  5467. return nil
  5468. case batchmsg.FieldBatchNo:
  5469. m.ResetBatchNo()
  5470. return nil
  5471. case batchmsg.FieldTaskName:
  5472. m.ResetTaskName()
  5473. return nil
  5474. case batchmsg.FieldFromwxid:
  5475. m.ResetFromwxid()
  5476. return nil
  5477. case batchmsg.FieldMsg:
  5478. m.ResetMsg()
  5479. return nil
  5480. case batchmsg.FieldTag:
  5481. m.ResetTag()
  5482. return nil
  5483. case batchmsg.FieldTagids:
  5484. m.ResetTagids()
  5485. return nil
  5486. case batchmsg.FieldTotal:
  5487. m.ResetTotal()
  5488. return nil
  5489. case batchmsg.FieldSuccess:
  5490. m.ResetSuccess()
  5491. return nil
  5492. case batchmsg.FieldFail:
  5493. m.ResetFail()
  5494. return nil
  5495. case batchmsg.FieldStartTime:
  5496. m.ResetStartTime()
  5497. return nil
  5498. case batchmsg.FieldStopTime:
  5499. m.ResetStopTime()
  5500. return nil
  5501. case batchmsg.FieldSendTime:
  5502. m.ResetSendTime()
  5503. return nil
  5504. case batchmsg.FieldType:
  5505. m.ResetType()
  5506. return nil
  5507. case batchmsg.FieldOrganizationID:
  5508. m.ResetOrganizationID()
  5509. return nil
  5510. }
  5511. return fmt.Errorf("unknown BatchMsg field %s", name)
  5512. }
  5513. // AddedEdges returns all edge names that were set/added in this mutation.
  5514. func (m *BatchMsgMutation) AddedEdges() []string {
  5515. edges := make([]string, 0, 0)
  5516. return edges
  5517. }
  5518. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  5519. // name in this mutation.
  5520. func (m *BatchMsgMutation) AddedIDs(name string) []ent.Value {
  5521. return nil
  5522. }
  5523. // RemovedEdges returns all edge names that were removed in this mutation.
  5524. func (m *BatchMsgMutation) RemovedEdges() []string {
  5525. edges := make([]string, 0, 0)
  5526. return edges
  5527. }
  5528. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  5529. // the given name in this mutation.
  5530. func (m *BatchMsgMutation) RemovedIDs(name string) []ent.Value {
  5531. return nil
  5532. }
  5533. // ClearedEdges returns all edge names that were cleared in this mutation.
  5534. func (m *BatchMsgMutation) ClearedEdges() []string {
  5535. edges := make([]string, 0, 0)
  5536. return edges
  5537. }
  5538. // EdgeCleared returns a boolean which indicates if the edge with the given name
  5539. // was cleared in this mutation.
  5540. func (m *BatchMsgMutation) EdgeCleared(name string) bool {
  5541. return false
  5542. }
  5543. // ClearEdge clears the value of the edge with the given name. It returns an error
  5544. // if that edge is not defined in the schema.
  5545. func (m *BatchMsgMutation) ClearEdge(name string) error {
  5546. return fmt.Errorf("unknown BatchMsg unique edge %s", name)
  5547. }
  5548. // ResetEdge resets all changes to the edge with the given name in this mutation.
  5549. // It returns an error if the edge is not defined in the schema.
  5550. func (m *BatchMsgMutation) ResetEdge(name string) error {
  5551. return fmt.Errorf("unknown BatchMsg edge %s", name)
  5552. }
  5553. // CategoryMutation represents an operation that mutates the Category nodes in the graph.
  5554. type CategoryMutation struct {
  5555. config
  5556. op Op
  5557. typ string
  5558. id *uint64
  5559. created_at *time.Time
  5560. updated_at *time.Time
  5561. deleted_at *time.Time
  5562. name *string
  5563. organization_id *uint64
  5564. addorganization_id *int64
  5565. clearedFields map[string]struct{}
  5566. done bool
  5567. oldValue func(context.Context) (*Category, error)
  5568. predicates []predicate.Category
  5569. }
  5570. var _ ent.Mutation = (*CategoryMutation)(nil)
  5571. // categoryOption allows management of the mutation configuration using functional options.
  5572. type categoryOption func(*CategoryMutation)
  5573. // newCategoryMutation creates new mutation for the Category entity.
  5574. func newCategoryMutation(c config, op Op, opts ...categoryOption) *CategoryMutation {
  5575. m := &CategoryMutation{
  5576. config: c,
  5577. op: op,
  5578. typ: TypeCategory,
  5579. clearedFields: make(map[string]struct{}),
  5580. }
  5581. for _, opt := range opts {
  5582. opt(m)
  5583. }
  5584. return m
  5585. }
  5586. // withCategoryID sets the ID field of the mutation.
  5587. func withCategoryID(id uint64) categoryOption {
  5588. return func(m *CategoryMutation) {
  5589. var (
  5590. err error
  5591. once sync.Once
  5592. value *Category
  5593. )
  5594. m.oldValue = func(ctx context.Context) (*Category, error) {
  5595. once.Do(func() {
  5596. if m.done {
  5597. err = errors.New("querying old values post mutation is not allowed")
  5598. } else {
  5599. value, err = m.Client().Category.Get(ctx, id)
  5600. }
  5601. })
  5602. return value, err
  5603. }
  5604. m.id = &id
  5605. }
  5606. }
  5607. // withCategory sets the old Category of the mutation.
  5608. func withCategory(node *Category) categoryOption {
  5609. return func(m *CategoryMutation) {
  5610. m.oldValue = func(context.Context) (*Category, error) {
  5611. return node, nil
  5612. }
  5613. m.id = &node.ID
  5614. }
  5615. }
  5616. // Client returns a new `ent.Client` from the mutation. If the mutation was
  5617. // executed in a transaction (ent.Tx), a transactional client is returned.
  5618. func (m CategoryMutation) Client() *Client {
  5619. client := &Client{config: m.config}
  5620. client.init()
  5621. return client
  5622. }
  5623. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  5624. // it returns an error otherwise.
  5625. func (m CategoryMutation) Tx() (*Tx, error) {
  5626. if _, ok := m.driver.(*txDriver); !ok {
  5627. return nil, errors.New("ent: mutation is not running in a transaction")
  5628. }
  5629. tx := &Tx{config: m.config}
  5630. tx.init()
  5631. return tx, nil
  5632. }
  5633. // SetID sets the value of the id field. Note that this
  5634. // operation is only accepted on creation of Category entities.
  5635. func (m *CategoryMutation) SetID(id uint64) {
  5636. m.id = &id
  5637. }
  5638. // ID returns the ID value in the mutation. Note that the ID is only available
  5639. // if it was provided to the builder or after it was returned from the database.
  5640. func (m *CategoryMutation) ID() (id uint64, exists bool) {
  5641. if m.id == nil {
  5642. return
  5643. }
  5644. return *m.id, true
  5645. }
  5646. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  5647. // That means, if the mutation is applied within a transaction with an isolation level such
  5648. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  5649. // or updated by the mutation.
  5650. func (m *CategoryMutation) IDs(ctx context.Context) ([]uint64, error) {
  5651. switch {
  5652. case m.op.Is(OpUpdateOne | OpDeleteOne):
  5653. id, exists := m.ID()
  5654. if exists {
  5655. return []uint64{id}, nil
  5656. }
  5657. fallthrough
  5658. case m.op.Is(OpUpdate | OpDelete):
  5659. return m.Client().Category.Query().Where(m.predicates...).IDs(ctx)
  5660. default:
  5661. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  5662. }
  5663. }
  5664. // SetCreatedAt sets the "created_at" field.
  5665. func (m *CategoryMutation) SetCreatedAt(t time.Time) {
  5666. m.created_at = &t
  5667. }
  5668. // CreatedAt returns the value of the "created_at" field in the mutation.
  5669. func (m *CategoryMutation) CreatedAt() (r time.Time, exists bool) {
  5670. v := m.created_at
  5671. if v == nil {
  5672. return
  5673. }
  5674. return *v, true
  5675. }
  5676. // OldCreatedAt returns the old "created_at" field's value of the Category entity.
  5677. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  5678. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5679. func (m *CategoryMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  5680. if !m.op.Is(OpUpdateOne) {
  5681. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  5682. }
  5683. if m.id == nil || m.oldValue == nil {
  5684. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  5685. }
  5686. oldValue, err := m.oldValue(ctx)
  5687. if err != nil {
  5688. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  5689. }
  5690. return oldValue.CreatedAt, nil
  5691. }
  5692. // ResetCreatedAt resets all changes to the "created_at" field.
  5693. func (m *CategoryMutation) ResetCreatedAt() {
  5694. m.created_at = nil
  5695. }
  5696. // SetUpdatedAt sets the "updated_at" field.
  5697. func (m *CategoryMutation) SetUpdatedAt(t time.Time) {
  5698. m.updated_at = &t
  5699. }
  5700. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  5701. func (m *CategoryMutation) UpdatedAt() (r time.Time, exists bool) {
  5702. v := m.updated_at
  5703. if v == nil {
  5704. return
  5705. }
  5706. return *v, true
  5707. }
  5708. // OldUpdatedAt returns the old "updated_at" field's value of the Category entity.
  5709. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  5710. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5711. func (m *CategoryMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  5712. if !m.op.Is(OpUpdateOne) {
  5713. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  5714. }
  5715. if m.id == nil || m.oldValue == nil {
  5716. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  5717. }
  5718. oldValue, err := m.oldValue(ctx)
  5719. if err != nil {
  5720. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  5721. }
  5722. return oldValue.UpdatedAt, nil
  5723. }
  5724. // ResetUpdatedAt resets all changes to the "updated_at" field.
  5725. func (m *CategoryMutation) ResetUpdatedAt() {
  5726. m.updated_at = nil
  5727. }
  5728. // SetDeletedAt sets the "deleted_at" field.
  5729. func (m *CategoryMutation) SetDeletedAt(t time.Time) {
  5730. m.deleted_at = &t
  5731. }
  5732. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  5733. func (m *CategoryMutation) DeletedAt() (r time.Time, exists bool) {
  5734. v := m.deleted_at
  5735. if v == nil {
  5736. return
  5737. }
  5738. return *v, true
  5739. }
  5740. // OldDeletedAt returns the old "deleted_at" field's value of the Category entity.
  5741. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  5742. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5743. func (m *CategoryMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  5744. if !m.op.Is(OpUpdateOne) {
  5745. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  5746. }
  5747. if m.id == nil || m.oldValue == nil {
  5748. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  5749. }
  5750. oldValue, err := m.oldValue(ctx)
  5751. if err != nil {
  5752. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  5753. }
  5754. return oldValue.DeletedAt, nil
  5755. }
  5756. // ClearDeletedAt clears the value of the "deleted_at" field.
  5757. func (m *CategoryMutation) ClearDeletedAt() {
  5758. m.deleted_at = nil
  5759. m.clearedFields[category.FieldDeletedAt] = struct{}{}
  5760. }
  5761. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  5762. func (m *CategoryMutation) DeletedAtCleared() bool {
  5763. _, ok := m.clearedFields[category.FieldDeletedAt]
  5764. return ok
  5765. }
  5766. // ResetDeletedAt resets all changes to the "deleted_at" field.
  5767. func (m *CategoryMutation) ResetDeletedAt() {
  5768. m.deleted_at = nil
  5769. delete(m.clearedFields, category.FieldDeletedAt)
  5770. }
  5771. // SetName sets the "name" field.
  5772. func (m *CategoryMutation) SetName(s string) {
  5773. m.name = &s
  5774. }
  5775. // Name returns the value of the "name" field in the mutation.
  5776. func (m *CategoryMutation) Name() (r string, exists bool) {
  5777. v := m.name
  5778. if v == nil {
  5779. return
  5780. }
  5781. return *v, true
  5782. }
  5783. // OldName returns the old "name" field's value of the Category entity.
  5784. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  5785. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5786. func (m *CategoryMutation) OldName(ctx context.Context) (v string, err error) {
  5787. if !m.op.Is(OpUpdateOne) {
  5788. return v, errors.New("OldName is only allowed on UpdateOne operations")
  5789. }
  5790. if m.id == nil || m.oldValue == nil {
  5791. return v, errors.New("OldName requires an ID field in the mutation")
  5792. }
  5793. oldValue, err := m.oldValue(ctx)
  5794. if err != nil {
  5795. return v, fmt.Errorf("querying old value for OldName: %w", err)
  5796. }
  5797. return oldValue.Name, nil
  5798. }
  5799. // ResetName resets all changes to the "name" field.
  5800. func (m *CategoryMutation) ResetName() {
  5801. m.name = nil
  5802. }
  5803. // SetOrganizationID sets the "organization_id" field.
  5804. func (m *CategoryMutation) SetOrganizationID(u uint64) {
  5805. m.organization_id = &u
  5806. m.addorganization_id = nil
  5807. }
  5808. // OrganizationID returns the value of the "organization_id" field in the mutation.
  5809. func (m *CategoryMutation) OrganizationID() (r uint64, exists bool) {
  5810. v := m.organization_id
  5811. if v == nil {
  5812. return
  5813. }
  5814. return *v, true
  5815. }
  5816. // OldOrganizationID returns the old "organization_id" field's value of the Category entity.
  5817. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  5818. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5819. func (m *CategoryMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  5820. if !m.op.Is(OpUpdateOne) {
  5821. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  5822. }
  5823. if m.id == nil || m.oldValue == nil {
  5824. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  5825. }
  5826. oldValue, err := m.oldValue(ctx)
  5827. if err != nil {
  5828. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  5829. }
  5830. return oldValue.OrganizationID, nil
  5831. }
  5832. // AddOrganizationID adds u to the "organization_id" field.
  5833. func (m *CategoryMutation) AddOrganizationID(u int64) {
  5834. if m.addorganization_id != nil {
  5835. *m.addorganization_id += u
  5836. } else {
  5837. m.addorganization_id = &u
  5838. }
  5839. }
  5840. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  5841. func (m *CategoryMutation) AddedOrganizationID() (r int64, exists bool) {
  5842. v := m.addorganization_id
  5843. if v == nil {
  5844. return
  5845. }
  5846. return *v, true
  5847. }
  5848. // ResetOrganizationID resets all changes to the "organization_id" field.
  5849. func (m *CategoryMutation) ResetOrganizationID() {
  5850. m.organization_id = nil
  5851. m.addorganization_id = nil
  5852. }
  5853. // Where appends a list predicates to the CategoryMutation builder.
  5854. func (m *CategoryMutation) Where(ps ...predicate.Category) {
  5855. m.predicates = append(m.predicates, ps...)
  5856. }
  5857. // WhereP appends storage-level predicates to the CategoryMutation builder. Using this method,
  5858. // users can use type-assertion to append predicates that do not depend on any generated package.
  5859. func (m *CategoryMutation) WhereP(ps ...func(*sql.Selector)) {
  5860. p := make([]predicate.Category, len(ps))
  5861. for i := range ps {
  5862. p[i] = ps[i]
  5863. }
  5864. m.Where(p...)
  5865. }
  5866. // Op returns the operation name.
  5867. func (m *CategoryMutation) Op() Op {
  5868. return m.op
  5869. }
  5870. // SetOp allows setting the mutation operation.
  5871. func (m *CategoryMutation) SetOp(op Op) {
  5872. m.op = op
  5873. }
  5874. // Type returns the node type of this mutation (Category).
  5875. func (m *CategoryMutation) Type() string {
  5876. return m.typ
  5877. }
  5878. // Fields returns all fields that were changed during this mutation. Note that in
  5879. // order to get all numeric fields that were incremented/decremented, call
  5880. // AddedFields().
  5881. func (m *CategoryMutation) Fields() []string {
  5882. fields := make([]string, 0, 5)
  5883. if m.created_at != nil {
  5884. fields = append(fields, category.FieldCreatedAt)
  5885. }
  5886. if m.updated_at != nil {
  5887. fields = append(fields, category.FieldUpdatedAt)
  5888. }
  5889. if m.deleted_at != nil {
  5890. fields = append(fields, category.FieldDeletedAt)
  5891. }
  5892. if m.name != nil {
  5893. fields = append(fields, category.FieldName)
  5894. }
  5895. if m.organization_id != nil {
  5896. fields = append(fields, category.FieldOrganizationID)
  5897. }
  5898. return fields
  5899. }
  5900. // Field returns the value of a field with the given name. The second boolean
  5901. // return value indicates that this field was not set, or was not defined in the
  5902. // schema.
  5903. func (m *CategoryMutation) Field(name string) (ent.Value, bool) {
  5904. switch name {
  5905. case category.FieldCreatedAt:
  5906. return m.CreatedAt()
  5907. case category.FieldUpdatedAt:
  5908. return m.UpdatedAt()
  5909. case category.FieldDeletedAt:
  5910. return m.DeletedAt()
  5911. case category.FieldName:
  5912. return m.Name()
  5913. case category.FieldOrganizationID:
  5914. return m.OrganizationID()
  5915. }
  5916. return nil, false
  5917. }
  5918. // OldField returns the old value of the field from the database. An error is
  5919. // returned if the mutation operation is not UpdateOne, or the query to the
  5920. // database failed.
  5921. func (m *CategoryMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  5922. switch name {
  5923. case category.FieldCreatedAt:
  5924. return m.OldCreatedAt(ctx)
  5925. case category.FieldUpdatedAt:
  5926. return m.OldUpdatedAt(ctx)
  5927. case category.FieldDeletedAt:
  5928. return m.OldDeletedAt(ctx)
  5929. case category.FieldName:
  5930. return m.OldName(ctx)
  5931. case category.FieldOrganizationID:
  5932. return m.OldOrganizationID(ctx)
  5933. }
  5934. return nil, fmt.Errorf("unknown Category field %s", name)
  5935. }
  5936. // SetField sets the value of a field with the given name. It returns an error if
  5937. // the field is not defined in the schema, or if the type mismatched the field
  5938. // type.
  5939. func (m *CategoryMutation) SetField(name string, value ent.Value) error {
  5940. switch name {
  5941. case category.FieldCreatedAt:
  5942. v, ok := value.(time.Time)
  5943. if !ok {
  5944. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5945. }
  5946. m.SetCreatedAt(v)
  5947. return nil
  5948. case category.FieldUpdatedAt:
  5949. v, ok := value.(time.Time)
  5950. if !ok {
  5951. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5952. }
  5953. m.SetUpdatedAt(v)
  5954. return nil
  5955. case category.FieldDeletedAt:
  5956. v, ok := value.(time.Time)
  5957. if !ok {
  5958. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5959. }
  5960. m.SetDeletedAt(v)
  5961. return nil
  5962. case category.FieldName:
  5963. v, ok := value.(string)
  5964. if !ok {
  5965. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5966. }
  5967. m.SetName(v)
  5968. return nil
  5969. case category.FieldOrganizationID:
  5970. v, ok := value.(uint64)
  5971. if !ok {
  5972. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5973. }
  5974. m.SetOrganizationID(v)
  5975. return nil
  5976. }
  5977. return fmt.Errorf("unknown Category field %s", name)
  5978. }
  5979. // AddedFields returns all numeric fields that were incremented/decremented during
  5980. // this mutation.
  5981. func (m *CategoryMutation) AddedFields() []string {
  5982. var fields []string
  5983. if m.addorganization_id != nil {
  5984. fields = append(fields, category.FieldOrganizationID)
  5985. }
  5986. return fields
  5987. }
  5988. // AddedField returns the numeric value that was incremented/decremented on a field
  5989. // with the given name. The second boolean return value indicates that this field
  5990. // was not set, or was not defined in the schema.
  5991. func (m *CategoryMutation) AddedField(name string) (ent.Value, bool) {
  5992. switch name {
  5993. case category.FieldOrganizationID:
  5994. return m.AddedOrganizationID()
  5995. }
  5996. return nil, false
  5997. }
  5998. // AddField adds the value to the field with the given name. It returns an error if
  5999. // the field is not defined in the schema, or if the type mismatched the field
  6000. // type.
  6001. func (m *CategoryMutation) AddField(name string, value ent.Value) error {
  6002. switch name {
  6003. case category.FieldOrganizationID:
  6004. v, ok := value.(int64)
  6005. if !ok {
  6006. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6007. }
  6008. m.AddOrganizationID(v)
  6009. return nil
  6010. }
  6011. return fmt.Errorf("unknown Category numeric field %s", name)
  6012. }
  6013. // ClearedFields returns all nullable fields that were cleared during this
  6014. // mutation.
  6015. func (m *CategoryMutation) ClearedFields() []string {
  6016. var fields []string
  6017. if m.FieldCleared(category.FieldDeletedAt) {
  6018. fields = append(fields, category.FieldDeletedAt)
  6019. }
  6020. return fields
  6021. }
  6022. // FieldCleared returns a boolean indicating if a field with the given name was
  6023. // cleared in this mutation.
  6024. func (m *CategoryMutation) FieldCleared(name string) bool {
  6025. _, ok := m.clearedFields[name]
  6026. return ok
  6027. }
  6028. // ClearField clears the value of the field with the given name. It returns an
  6029. // error if the field is not defined in the schema.
  6030. func (m *CategoryMutation) ClearField(name string) error {
  6031. switch name {
  6032. case category.FieldDeletedAt:
  6033. m.ClearDeletedAt()
  6034. return nil
  6035. }
  6036. return fmt.Errorf("unknown Category nullable field %s", name)
  6037. }
  6038. // ResetField resets all changes in the mutation for the field with the given name.
  6039. // It returns an error if the field is not defined in the schema.
  6040. func (m *CategoryMutation) ResetField(name string) error {
  6041. switch name {
  6042. case category.FieldCreatedAt:
  6043. m.ResetCreatedAt()
  6044. return nil
  6045. case category.FieldUpdatedAt:
  6046. m.ResetUpdatedAt()
  6047. return nil
  6048. case category.FieldDeletedAt:
  6049. m.ResetDeletedAt()
  6050. return nil
  6051. case category.FieldName:
  6052. m.ResetName()
  6053. return nil
  6054. case category.FieldOrganizationID:
  6055. m.ResetOrganizationID()
  6056. return nil
  6057. }
  6058. return fmt.Errorf("unknown Category field %s", name)
  6059. }
  6060. // AddedEdges returns all edge names that were set/added in this mutation.
  6061. func (m *CategoryMutation) AddedEdges() []string {
  6062. edges := make([]string, 0, 0)
  6063. return edges
  6064. }
  6065. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  6066. // name in this mutation.
  6067. func (m *CategoryMutation) AddedIDs(name string) []ent.Value {
  6068. return nil
  6069. }
  6070. // RemovedEdges returns all edge names that were removed in this mutation.
  6071. func (m *CategoryMutation) RemovedEdges() []string {
  6072. edges := make([]string, 0, 0)
  6073. return edges
  6074. }
  6075. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  6076. // the given name in this mutation.
  6077. func (m *CategoryMutation) RemovedIDs(name string) []ent.Value {
  6078. return nil
  6079. }
  6080. // ClearedEdges returns all edge names that were cleared in this mutation.
  6081. func (m *CategoryMutation) ClearedEdges() []string {
  6082. edges := make([]string, 0, 0)
  6083. return edges
  6084. }
  6085. // EdgeCleared returns a boolean which indicates if the edge with the given name
  6086. // was cleared in this mutation.
  6087. func (m *CategoryMutation) EdgeCleared(name string) bool {
  6088. return false
  6089. }
  6090. // ClearEdge clears the value of the edge with the given name. It returns an error
  6091. // if that edge is not defined in the schema.
  6092. func (m *CategoryMutation) ClearEdge(name string) error {
  6093. return fmt.Errorf("unknown Category unique edge %s", name)
  6094. }
  6095. // ResetEdge resets all changes to the edge with the given name in this mutation.
  6096. // It returns an error if the edge is not defined in the schema.
  6097. func (m *CategoryMutation) ResetEdge(name string) error {
  6098. return fmt.Errorf("unknown Category edge %s", name)
  6099. }
  6100. // ChatRecordsMutation represents an operation that mutates the ChatRecords nodes in the graph.
  6101. type ChatRecordsMutation struct {
  6102. config
  6103. op Op
  6104. typ string
  6105. id *uint64
  6106. created_at *time.Time
  6107. updated_at *time.Time
  6108. deleted_at *time.Time
  6109. content *string
  6110. content_type *uint8
  6111. addcontent_type *int8
  6112. session_id *uint64
  6113. addsession_id *int64
  6114. user_id *uint64
  6115. adduser_id *int64
  6116. bot_id *uint64
  6117. addbot_id *int64
  6118. bot_type *uint8
  6119. addbot_type *int8
  6120. clearedFields map[string]struct{}
  6121. done bool
  6122. oldValue func(context.Context) (*ChatRecords, error)
  6123. predicates []predicate.ChatRecords
  6124. }
  6125. var _ ent.Mutation = (*ChatRecordsMutation)(nil)
  6126. // chatrecordsOption allows management of the mutation configuration using functional options.
  6127. type chatrecordsOption func(*ChatRecordsMutation)
  6128. // newChatRecordsMutation creates new mutation for the ChatRecords entity.
  6129. func newChatRecordsMutation(c config, op Op, opts ...chatrecordsOption) *ChatRecordsMutation {
  6130. m := &ChatRecordsMutation{
  6131. config: c,
  6132. op: op,
  6133. typ: TypeChatRecords,
  6134. clearedFields: make(map[string]struct{}),
  6135. }
  6136. for _, opt := range opts {
  6137. opt(m)
  6138. }
  6139. return m
  6140. }
  6141. // withChatRecordsID sets the ID field of the mutation.
  6142. func withChatRecordsID(id uint64) chatrecordsOption {
  6143. return func(m *ChatRecordsMutation) {
  6144. var (
  6145. err error
  6146. once sync.Once
  6147. value *ChatRecords
  6148. )
  6149. m.oldValue = func(ctx context.Context) (*ChatRecords, error) {
  6150. once.Do(func() {
  6151. if m.done {
  6152. err = errors.New("querying old values post mutation is not allowed")
  6153. } else {
  6154. value, err = m.Client().ChatRecords.Get(ctx, id)
  6155. }
  6156. })
  6157. return value, err
  6158. }
  6159. m.id = &id
  6160. }
  6161. }
  6162. // withChatRecords sets the old ChatRecords of the mutation.
  6163. func withChatRecords(node *ChatRecords) chatrecordsOption {
  6164. return func(m *ChatRecordsMutation) {
  6165. m.oldValue = func(context.Context) (*ChatRecords, error) {
  6166. return node, nil
  6167. }
  6168. m.id = &node.ID
  6169. }
  6170. }
  6171. // Client returns a new `ent.Client` from the mutation. If the mutation was
  6172. // executed in a transaction (ent.Tx), a transactional client is returned.
  6173. func (m ChatRecordsMutation) Client() *Client {
  6174. client := &Client{config: m.config}
  6175. client.init()
  6176. return client
  6177. }
  6178. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  6179. // it returns an error otherwise.
  6180. func (m ChatRecordsMutation) Tx() (*Tx, error) {
  6181. if _, ok := m.driver.(*txDriver); !ok {
  6182. return nil, errors.New("ent: mutation is not running in a transaction")
  6183. }
  6184. tx := &Tx{config: m.config}
  6185. tx.init()
  6186. return tx, nil
  6187. }
  6188. // SetID sets the value of the id field. Note that this
  6189. // operation is only accepted on creation of ChatRecords entities.
  6190. func (m *ChatRecordsMutation) SetID(id uint64) {
  6191. m.id = &id
  6192. }
  6193. // ID returns the ID value in the mutation. Note that the ID is only available
  6194. // if it was provided to the builder or after it was returned from the database.
  6195. func (m *ChatRecordsMutation) ID() (id uint64, exists bool) {
  6196. if m.id == nil {
  6197. return
  6198. }
  6199. return *m.id, true
  6200. }
  6201. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  6202. // That means, if the mutation is applied within a transaction with an isolation level such
  6203. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  6204. // or updated by the mutation.
  6205. func (m *ChatRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  6206. switch {
  6207. case m.op.Is(OpUpdateOne | OpDeleteOne):
  6208. id, exists := m.ID()
  6209. if exists {
  6210. return []uint64{id}, nil
  6211. }
  6212. fallthrough
  6213. case m.op.Is(OpUpdate | OpDelete):
  6214. return m.Client().ChatRecords.Query().Where(m.predicates...).IDs(ctx)
  6215. default:
  6216. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  6217. }
  6218. }
  6219. // SetCreatedAt sets the "created_at" field.
  6220. func (m *ChatRecordsMutation) SetCreatedAt(t time.Time) {
  6221. m.created_at = &t
  6222. }
  6223. // CreatedAt returns the value of the "created_at" field in the mutation.
  6224. func (m *ChatRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  6225. v := m.created_at
  6226. if v == nil {
  6227. return
  6228. }
  6229. return *v, true
  6230. }
  6231. // OldCreatedAt returns the old "created_at" field's value of the ChatRecords entity.
  6232. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6233. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6234. func (m *ChatRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  6235. if !m.op.Is(OpUpdateOne) {
  6236. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  6237. }
  6238. if m.id == nil || m.oldValue == nil {
  6239. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  6240. }
  6241. oldValue, err := m.oldValue(ctx)
  6242. if err != nil {
  6243. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  6244. }
  6245. return oldValue.CreatedAt, nil
  6246. }
  6247. // ResetCreatedAt resets all changes to the "created_at" field.
  6248. func (m *ChatRecordsMutation) ResetCreatedAt() {
  6249. m.created_at = nil
  6250. }
  6251. // SetUpdatedAt sets the "updated_at" field.
  6252. func (m *ChatRecordsMutation) SetUpdatedAt(t time.Time) {
  6253. m.updated_at = &t
  6254. }
  6255. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  6256. func (m *ChatRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  6257. v := m.updated_at
  6258. if v == nil {
  6259. return
  6260. }
  6261. return *v, true
  6262. }
  6263. // OldUpdatedAt returns the old "updated_at" field's value of the ChatRecords entity.
  6264. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6265. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6266. func (m *ChatRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  6267. if !m.op.Is(OpUpdateOne) {
  6268. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  6269. }
  6270. if m.id == nil || m.oldValue == nil {
  6271. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  6272. }
  6273. oldValue, err := m.oldValue(ctx)
  6274. if err != nil {
  6275. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  6276. }
  6277. return oldValue.UpdatedAt, nil
  6278. }
  6279. // ResetUpdatedAt resets all changes to the "updated_at" field.
  6280. func (m *ChatRecordsMutation) ResetUpdatedAt() {
  6281. m.updated_at = nil
  6282. }
  6283. // SetDeletedAt sets the "deleted_at" field.
  6284. func (m *ChatRecordsMutation) SetDeletedAt(t time.Time) {
  6285. m.deleted_at = &t
  6286. }
  6287. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  6288. func (m *ChatRecordsMutation) DeletedAt() (r time.Time, exists bool) {
  6289. v := m.deleted_at
  6290. if v == nil {
  6291. return
  6292. }
  6293. return *v, true
  6294. }
  6295. // OldDeletedAt returns the old "deleted_at" field's value of the ChatRecords entity.
  6296. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6297. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6298. func (m *ChatRecordsMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  6299. if !m.op.Is(OpUpdateOne) {
  6300. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  6301. }
  6302. if m.id == nil || m.oldValue == nil {
  6303. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  6304. }
  6305. oldValue, err := m.oldValue(ctx)
  6306. if err != nil {
  6307. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  6308. }
  6309. return oldValue.DeletedAt, nil
  6310. }
  6311. // ClearDeletedAt clears the value of the "deleted_at" field.
  6312. func (m *ChatRecordsMutation) ClearDeletedAt() {
  6313. m.deleted_at = nil
  6314. m.clearedFields[chatrecords.FieldDeletedAt] = struct{}{}
  6315. }
  6316. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  6317. func (m *ChatRecordsMutation) DeletedAtCleared() bool {
  6318. _, ok := m.clearedFields[chatrecords.FieldDeletedAt]
  6319. return ok
  6320. }
  6321. // ResetDeletedAt resets all changes to the "deleted_at" field.
  6322. func (m *ChatRecordsMutation) ResetDeletedAt() {
  6323. m.deleted_at = nil
  6324. delete(m.clearedFields, chatrecords.FieldDeletedAt)
  6325. }
  6326. // SetContent sets the "content" field.
  6327. func (m *ChatRecordsMutation) SetContent(s string) {
  6328. m.content = &s
  6329. }
  6330. // Content returns the value of the "content" field in the mutation.
  6331. func (m *ChatRecordsMutation) Content() (r string, exists bool) {
  6332. v := m.content
  6333. if v == nil {
  6334. return
  6335. }
  6336. return *v, true
  6337. }
  6338. // OldContent returns the old "content" field's value of the ChatRecords entity.
  6339. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6340. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6341. func (m *ChatRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  6342. if !m.op.Is(OpUpdateOne) {
  6343. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  6344. }
  6345. if m.id == nil || m.oldValue == nil {
  6346. return v, errors.New("OldContent requires an ID field in the mutation")
  6347. }
  6348. oldValue, err := m.oldValue(ctx)
  6349. if err != nil {
  6350. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  6351. }
  6352. return oldValue.Content, nil
  6353. }
  6354. // ResetContent resets all changes to the "content" field.
  6355. func (m *ChatRecordsMutation) ResetContent() {
  6356. m.content = nil
  6357. }
  6358. // SetContentType sets the "content_type" field.
  6359. func (m *ChatRecordsMutation) SetContentType(u uint8) {
  6360. m.content_type = &u
  6361. m.addcontent_type = nil
  6362. }
  6363. // ContentType returns the value of the "content_type" field in the mutation.
  6364. func (m *ChatRecordsMutation) ContentType() (r uint8, exists bool) {
  6365. v := m.content_type
  6366. if v == nil {
  6367. return
  6368. }
  6369. return *v, true
  6370. }
  6371. // OldContentType returns the old "content_type" field's value of the ChatRecords entity.
  6372. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6373. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6374. func (m *ChatRecordsMutation) OldContentType(ctx context.Context) (v uint8, err error) {
  6375. if !m.op.Is(OpUpdateOne) {
  6376. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  6377. }
  6378. if m.id == nil || m.oldValue == nil {
  6379. return v, errors.New("OldContentType requires an ID field in the mutation")
  6380. }
  6381. oldValue, err := m.oldValue(ctx)
  6382. if err != nil {
  6383. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  6384. }
  6385. return oldValue.ContentType, nil
  6386. }
  6387. // AddContentType adds u to the "content_type" field.
  6388. func (m *ChatRecordsMutation) AddContentType(u int8) {
  6389. if m.addcontent_type != nil {
  6390. *m.addcontent_type += u
  6391. } else {
  6392. m.addcontent_type = &u
  6393. }
  6394. }
  6395. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  6396. func (m *ChatRecordsMutation) AddedContentType() (r int8, exists bool) {
  6397. v := m.addcontent_type
  6398. if v == nil {
  6399. return
  6400. }
  6401. return *v, true
  6402. }
  6403. // ResetContentType resets all changes to the "content_type" field.
  6404. func (m *ChatRecordsMutation) ResetContentType() {
  6405. m.content_type = nil
  6406. m.addcontent_type = nil
  6407. }
  6408. // SetSessionID sets the "session_id" field.
  6409. func (m *ChatRecordsMutation) SetSessionID(u uint64) {
  6410. m.session_id = &u
  6411. m.addsession_id = nil
  6412. }
  6413. // SessionID returns the value of the "session_id" field in the mutation.
  6414. func (m *ChatRecordsMutation) SessionID() (r uint64, exists bool) {
  6415. v := m.session_id
  6416. if v == nil {
  6417. return
  6418. }
  6419. return *v, true
  6420. }
  6421. // OldSessionID returns the old "session_id" field's value of the ChatRecords entity.
  6422. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6423. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6424. func (m *ChatRecordsMutation) OldSessionID(ctx context.Context) (v uint64, err error) {
  6425. if !m.op.Is(OpUpdateOne) {
  6426. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  6427. }
  6428. if m.id == nil || m.oldValue == nil {
  6429. return v, errors.New("OldSessionID requires an ID field in the mutation")
  6430. }
  6431. oldValue, err := m.oldValue(ctx)
  6432. if err != nil {
  6433. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  6434. }
  6435. return oldValue.SessionID, nil
  6436. }
  6437. // AddSessionID adds u to the "session_id" field.
  6438. func (m *ChatRecordsMutation) AddSessionID(u int64) {
  6439. if m.addsession_id != nil {
  6440. *m.addsession_id += u
  6441. } else {
  6442. m.addsession_id = &u
  6443. }
  6444. }
  6445. // AddedSessionID returns the value that was added to the "session_id" field in this mutation.
  6446. func (m *ChatRecordsMutation) AddedSessionID() (r int64, exists bool) {
  6447. v := m.addsession_id
  6448. if v == nil {
  6449. return
  6450. }
  6451. return *v, true
  6452. }
  6453. // ResetSessionID resets all changes to the "session_id" field.
  6454. func (m *ChatRecordsMutation) ResetSessionID() {
  6455. m.session_id = nil
  6456. m.addsession_id = nil
  6457. }
  6458. // SetUserID sets the "user_id" field.
  6459. func (m *ChatRecordsMutation) SetUserID(u uint64) {
  6460. m.user_id = &u
  6461. m.adduser_id = nil
  6462. }
  6463. // UserID returns the value of the "user_id" field in the mutation.
  6464. func (m *ChatRecordsMutation) UserID() (r uint64, exists bool) {
  6465. v := m.user_id
  6466. if v == nil {
  6467. return
  6468. }
  6469. return *v, true
  6470. }
  6471. // OldUserID returns the old "user_id" field's value of the ChatRecords entity.
  6472. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6473. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6474. func (m *ChatRecordsMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  6475. if !m.op.Is(OpUpdateOne) {
  6476. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  6477. }
  6478. if m.id == nil || m.oldValue == nil {
  6479. return v, errors.New("OldUserID requires an ID field in the mutation")
  6480. }
  6481. oldValue, err := m.oldValue(ctx)
  6482. if err != nil {
  6483. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  6484. }
  6485. return oldValue.UserID, nil
  6486. }
  6487. // AddUserID adds u to the "user_id" field.
  6488. func (m *ChatRecordsMutation) AddUserID(u int64) {
  6489. if m.adduser_id != nil {
  6490. *m.adduser_id += u
  6491. } else {
  6492. m.adduser_id = &u
  6493. }
  6494. }
  6495. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  6496. func (m *ChatRecordsMutation) AddedUserID() (r int64, exists bool) {
  6497. v := m.adduser_id
  6498. if v == nil {
  6499. return
  6500. }
  6501. return *v, true
  6502. }
  6503. // ResetUserID resets all changes to the "user_id" field.
  6504. func (m *ChatRecordsMutation) ResetUserID() {
  6505. m.user_id = nil
  6506. m.adduser_id = nil
  6507. }
  6508. // SetBotID sets the "bot_id" field.
  6509. func (m *ChatRecordsMutation) SetBotID(u uint64) {
  6510. m.bot_id = &u
  6511. m.addbot_id = nil
  6512. }
  6513. // BotID returns the value of the "bot_id" field in the mutation.
  6514. func (m *ChatRecordsMutation) BotID() (r uint64, exists bool) {
  6515. v := m.bot_id
  6516. if v == nil {
  6517. return
  6518. }
  6519. return *v, true
  6520. }
  6521. // OldBotID returns the old "bot_id" field's value of the ChatRecords entity.
  6522. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6523. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6524. func (m *ChatRecordsMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  6525. if !m.op.Is(OpUpdateOne) {
  6526. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  6527. }
  6528. if m.id == nil || m.oldValue == nil {
  6529. return v, errors.New("OldBotID requires an ID field in the mutation")
  6530. }
  6531. oldValue, err := m.oldValue(ctx)
  6532. if err != nil {
  6533. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  6534. }
  6535. return oldValue.BotID, nil
  6536. }
  6537. // AddBotID adds u to the "bot_id" field.
  6538. func (m *ChatRecordsMutation) AddBotID(u int64) {
  6539. if m.addbot_id != nil {
  6540. *m.addbot_id += u
  6541. } else {
  6542. m.addbot_id = &u
  6543. }
  6544. }
  6545. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  6546. func (m *ChatRecordsMutation) AddedBotID() (r int64, exists bool) {
  6547. v := m.addbot_id
  6548. if v == nil {
  6549. return
  6550. }
  6551. return *v, true
  6552. }
  6553. // ResetBotID resets all changes to the "bot_id" field.
  6554. func (m *ChatRecordsMutation) ResetBotID() {
  6555. m.bot_id = nil
  6556. m.addbot_id = nil
  6557. }
  6558. // SetBotType sets the "bot_type" field.
  6559. func (m *ChatRecordsMutation) SetBotType(u uint8) {
  6560. m.bot_type = &u
  6561. m.addbot_type = nil
  6562. }
  6563. // BotType returns the value of the "bot_type" field in the mutation.
  6564. func (m *ChatRecordsMutation) BotType() (r uint8, exists bool) {
  6565. v := m.bot_type
  6566. if v == nil {
  6567. return
  6568. }
  6569. return *v, true
  6570. }
  6571. // OldBotType returns the old "bot_type" field's value of the ChatRecords entity.
  6572. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6573. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6574. func (m *ChatRecordsMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  6575. if !m.op.Is(OpUpdateOne) {
  6576. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  6577. }
  6578. if m.id == nil || m.oldValue == nil {
  6579. return v, errors.New("OldBotType requires an ID field in the mutation")
  6580. }
  6581. oldValue, err := m.oldValue(ctx)
  6582. if err != nil {
  6583. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  6584. }
  6585. return oldValue.BotType, nil
  6586. }
  6587. // AddBotType adds u to the "bot_type" field.
  6588. func (m *ChatRecordsMutation) AddBotType(u int8) {
  6589. if m.addbot_type != nil {
  6590. *m.addbot_type += u
  6591. } else {
  6592. m.addbot_type = &u
  6593. }
  6594. }
  6595. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  6596. func (m *ChatRecordsMutation) AddedBotType() (r int8, exists bool) {
  6597. v := m.addbot_type
  6598. if v == nil {
  6599. return
  6600. }
  6601. return *v, true
  6602. }
  6603. // ResetBotType resets all changes to the "bot_type" field.
  6604. func (m *ChatRecordsMutation) ResetBotType() {
  6605. m.bot_type = nil
  6606. m.addbot_type = nil
  6607. }
  6608. // Where appends a list predicates to the ChatRecordsMutation builder.
  6609. func (m *ChatRecordsMutation) Where(ps ...predicate.ChatRecords) {
  6610. m.predicates = append(m.predicates, ps...)
  6611. }
  6612. // WhereP appends storage-level predicates to the ChatRecordsMutation builder. Using this method,
  6613. // users can use type-assertion to append predicates that do not depend on any generated package.
  6614. func (m *ChatRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  6615. p := make([]predicate.ChatRecords, len(ps))
  6616. for i := range ps {
  6617. p[i] = ps[i]
  6618. }
  6619. m.Where(p...)
  6620. }
  6621. // Op returns the operation name.
  6622. func (m *ChatRecordsMutation) Op() Op {
  6623. return m.op
  6624. }
  6625. // SetOp allows setting the mutation operation.
  6626. func (m *ChatRecordsMutation) SetOp(op Op) {
  6627. m.op = op
  6628. }
  6629. // Type returns the node type of this mutation (ChatRecords).
  6630. func (m *ChatRecordsMutation) Type() string {
  6631. return m.typ
  6632. }
  6633. // Fields returns all fields that were changed during this mutation. Note that in
  6634. // order to get all numeric fields that were incremented/decremented, call
  6635. // AddedFields().
  6636. func (m *ChatRecordsMutation) Fields() []string {
  6637. fields := make([]string, 0, 9)
  6638. if m.created_at != nil {
  6639. fields = append(fields, chatrecords.FieldCreatedAt)
  6640. }
  6641. if m.updated_at != nil {
  6642. fields = append(fields, chatrecords.FieldUpdatedAt)
  6643. }
  6644. if m.deleted_at != nil {
  6645. fields = append(fields, chatrecords.FieldDeletedAt)
  6646. }
  6647. if m.content != nil {
  6648. fields = append(fields, chatrecords.FieldContent)
  6649. }
  6650. if m.content_type != nil {
  6651. fields = append(fields, chatrecords.FieldContentType)
  6652. }
  6653. if m.session_id != nil {
  6654. fields = append(fields, chatrecords.FieldSessionID)
  6655. }
  6656. if m.user_id != nil {
  6657. fields = append(fields, chatrecords.FieldUserID)
  6658. }
  6659. if m.bot_id != nil {
  6660. fields = append(fields, chatrecords.FieldBotID)
  6661. }
  6662. if m.bot_type != nil {
  6663. fields = append(fields, chatrecords.FieldBotType)
  6664. }
  6665. return fields
  6666. }
  6667. // Field returns the value of a field with the given name. The second boolean
  6668. // return value indicates that this field was not set, or was not defined in the
  6669. // schema.
  6670. func (m *ChatRecordsMutation) Field(name string) (ent.Value, bool) {
  6671. switch name {
  6672. case chatrecords.FieldCreatedAt:
  6673. return m.CreatedAt()
  6674. case chatrecords.FieldUpdatedAt:
  6675. return m.UpdatedAt()
  6676. case chatrecords.FieldDeletedAt:
  6677. return m.DeletedAt()
  6678. case chatrecords.FieldContent:
  6679. return m.Content()
  6680. case chatrecords.FieldContentType:
  6681. return m.ContentType()
  6682. case chatrecords.FieldSessionID:
  6683. return m.SessionID()
  6684. case chatrecords.FieldUserID:
  6685. return m.UserID()
  6686. case chatrecords.FieldBotID:
  6687. return m.BotID()
  6688. case chatrecords.FieldBotType:
  6689. return m.BotType()
  6690. }
  6691. return nil, false
  6692. }
  6693. // OldField returns the old value of the field from the database. An error is
  6694. // returned if the mutation operation is not UpdateOne, or the query to the
  6695. // database failed.
  6696. func (m *ChatRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  6697. switch name {
  6698. case chatrecords.FieldCreatedAt:
  6699. return m.OldCreatedAt(ctx)
  6700. case chatrecords.FieldUpdatedAt:
  6701. return m.OldUpdatedAt(ctx)
  6702. case chatrecords.FieldDeletedAt:
  6703. return m.OldDeletedAt(ctx)
  6704. case chatrecords.FieldContent:
  6705. return m.OldContent(ctx)
  6706. case chatrecords.FieldContentType:
  6707. return m.OldContentType(ctx)
  6708. case chatrecords.FieldSessionID:
  6709. return m.OldSessionID(ctx)
  6710. case chatrecords.FieldUserID:
  6711. return m.OldUserID(ctx)
  6712. case chatrecords.FieldBotID:
  6713. return m.OldBotID(ctx)
  6714. case chatrecords.FieldBotType:
  6715. return m.OldBotType(ctx)
  6716. }
  6717. return nil, fmt.Errorf("unknown ChatRecords field %s", name)
  6718. }
  6719. // SetField sets the value of a field with the given name. It returns an error if
  6720. // the field is not defined in the schema, or if the type mismatched the field
  6721. // type.
  6722. func (m *ChatRecordsMutation) SetField(name string, value ent.Value) error {
  6723. switch name {
  6724. case chatrecords.FieldCreatedAt:
  6725. v, ok := value.(time.Time)
  6726. if !ok {
  6727. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6728. }
  6729. m.SetCreatedAt(v)
  6730. return nil
  6731. case chatrecords.FieldUpdatedAt:
  6732. v, ok := value.(time.Time)
  6733. if !ok {
  6734. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6735. }
  6736. m.SetUpdatedAt(v)
  6737. return nil
  6738. case chatrecords.FieldDeletedAt:
  6739. v, ok := value.(time.Time)
  6740. if !ok {
  6741. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6742. }
  6743. m.SetDeletedAt(v)
  6744. return nil
  6745. case chatrecords.FieldContent:
  6746. v, ok := value.(string)
  6747. if !ok {
  6748. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6749. }
  6750. m.SetContent(v)
  6751. return nil
  6752. case chatrecords.FieldContentType:
  6753. v, ok := value.(uint8)
  6754. if !ok {
  6755. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6756. }
  6757. m.SetContentType(v)
  6758. return nil
  6759. case chatrecords.FieldSessionID:
  6760. v, ok := value.(uint64)
  6761. if !ok {
  6762. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6763. }
  6764. m.SetSessionID(v)
  6765. return nil
  6766. case chatrecords.FieldUserID:
  6767. v, ok := value.(uint64)
  6768. if !ok {
  6769. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6770. }
  6771. m.SetUserID(v)
  6772. return nil
  6773. case chatrecords.FieldBotID:
  6774. v, ok := value.(uint64)
  6775. if !ok {
  6776. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6777. }
  6778. m.SetBotID(v)
  6779. return nil
  6780. case chatrecords.FieldBotType:
  6781. v, ok := value.(uint8)
  6782. if !ok {
  6783. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6784. }
  6785. m.SetBotType(v)
  6786. return nil
  6787. }
  6788. return fmt.Errorf("unknown ChatRecords field %s", name)
  6789. }
  6790. // AddedFields returns all numeric fields that were incremented/decremented during
  6791. // this mutation.
  6792. func (m *ChatRecordsMutation) AddedFields() []string {
  6793. var fields []string
  6794. if m.addcontent_type != nil {
  6795. fields = append(fields, chatrecords.FieldContentType)
  6796. }
  6797. if m.addsession_id != nil {
  6798. fields = append(fields, chatrecords.FieldSessionID)
  6799. }
  6800. if m.adduser_id != nil {
  6801. fields = append(fields, chatrecords.FieldUserID)
  6802. }
  6803. if m.addbot_id != nil {
  6804. fields = append(fields, chatrecords.FieldBotID)
  6805. }
  6806. if m.addbot_type != nil {
  6807. fields = append(fields, chatrecords.FieldBotType)
  6808. }
  6809. return fields
  6810. }
  6811. // AddedField returns the numeric value that was incremented/decremented on a field
  6812. // with the given name. The second boolean return value indicates that this field
  6813. // was not set, or was not defined in the schema.
  6814. func (m *ChatRecordsMutation) AddedField(name string) (ent.Value, bool) {
  6815. switch name {
  6816. case chatrecords.FieldContentType:
  6817. return m.AddedContentType()
  6818. case chatrecords.FieldSessionID:
  6819. return m.AddedSessionID()
  6820. case chatrecords.FieldUserID:
  6821. return m.AddedUserID()
  6822. case chatrecords.FieldBotID:
  6823. return m.AddedBotID()
  6824. case chatrecords.FieldBotType:
  6825. return m.AddedBotType()
  6826. }
  6827. return nil, false
  6828. }
  6829. // AddField adds the value to the field with the given name. It returns an error if
  6830. // the field is not defined in the schema, or if the type mismatched the field
  6831. // type.
  6832. func (m *ChatRecordsMutation) AddField(name string, value ent.Value) error {
  6833. switch name {
  6834. case chatrecords.FieldContentType:
  6835. v, ok := value.(int8)
  6836. if !ok {
  6837. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6838. }
  6839. m.AddContentType(v)
  6840. return nil
  6841. case chatrecords.FieldSessionID:
  6842. v, ok := value.(int64)
  6843. if !ok {
  6844. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6845. }
  6846. m.AddSessionID(v)
  6847. return nil
  6848. case chatrecords.FieldUserID:
  6849. v, ok := value.(int64)
  6850. if !ok {
  6851. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6852. }
  6853. m.AddUserID(v)
  6854. return nil
  6855. case chatrecords.FieldBotID:
  6856. v, ok := value.(int64)
  6857. if !ok {
  6858. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6859. }
  6860. m.AddBotID(v)
  6861. return nil
  6862. case chatrecords.FieldBotType:
  6863. v, ok := value.(int8)
  6864. if !ok {
  6865. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6866. }
  6867. m.AddBotType(v)
  6868. return nil
  6869. }
  6870. return fmt.Errorf("unknown ChatRecords numeric field %s", name)
  6871. }
  6872. // ClearedFields returns all nullable fields that were cleared during this
  6873. // mutation.
  6874. func (m *ChatRecordsMutation) ClearedFields() []string {
  6875. var fields []string
  6876. if m.FieldCleared(chatrecords.FieldDeletedAt) {
  6877. fields = append(fields, chatrecords.FieldDeletedAt)
  6878. }
  6879. return fields
  6880. }
  6881. // FieldCleared returns a boolean indicating if a field with the given name was
  6882. // cleared in this mutation.
  6883. func (m *ChatRecordsMutation) FieldCleared(name string) bool {
  6884. _, ok := m.clearedFields[name]
  6885. return ok
  6886. }
  6887. // ClearField clears the value of the field with the given name. It returns an
  6888. // error if the field is not defined in the schema.
  6889. func (m *ChatRecordsMutation) ClearField(name string) error {
  6890. switch name {
  6891. case chatrecords.FieldDeletedAt:
  6892. m.ClearDeletedAt()
  6893. return nil
  6894. }
  6895. return fmt.Errorf("unknown ChatRecords nullable field %s", name)
  6896. }
  6897. // ResetField resets all changes in the mutation for the field with the given name.
  6898. // It returns an error if the field is not defined in the schema.
  6899. func (m *ChatRecordsMutation) ResetField(name string) error {
  6900. switch name {
  6901. case chatrecords.FieldCreatedAt:
  6902. m.ResetCreatedAt()
  6903. return nil
  6904. case chatrecords.FieldUpdatedAt:
  6905. m.ResetUpdatedAt()
  6906. return nil
  6907. case chatrecords.FieldDeletedAt:
  6908. m.ResetDeletedAt()
  6909. return nil
  6910. case chatrecords.FieldContent:
  6911. m.ResetContent()
  6912. return nil
  6913. case chatrecords.FieldContentType:
  6914. m.ResetContentType()
  6915. return nil
  6916. case chatrecords.FieldSessionID:
  6917. m.ResetSessionID()
  6918. return nil
  6919. case chatrecords.FieldUserID:
  6920. m.ResetUserID()
  6921. return nil
  6922. case chatrecords.FieldBotID:
  6923. m.ResetBotID()
  6924. return nil
  6925. case chatrecords.FieldBotType:
  6926. m.ResetBotType()
  6927. return nil
  6928. }
  6929. return fmt.Errorf("unknown ChatRecords field %s", name)
  6930. }
  6931. // AddedEdges returns all edge names that were set/added in this mutation.
  6932. func (m *ChatRecordsMutation) AddedEdges() []string {
  6933. edges := make([]string, 0, 0)
  6934. return edges
  6935. }
  6936. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  6937. // name in this mutation.
  6938. func (m *ChatRecordsMutation) AddedIDs(name string) []ent.Value {
  6939. return nil
  6940. }
  6941. // RemovedEdges returns all edge names that were removed in this mutation.
  6942. func (m *ChatRecordsMutation) RemovedEdges() []string {
  6943. edges := make([]string, 0, 0)
  6944. return edges
  6945. }
  6946. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  6947. // the given name in this mutation.
  6948. func (m *ChatRecordsMutation) RemovedIDs(name string) []ent.Value {
  6949. return nil
  6950. }
  6951. // ClearedEdges returns all edge names that were cleared in this mutation.
  6952. func (m *ChatRecordsMutation) ClearedEdges() []string {
  6953. edges := make([]string, 0, 0)
  6954. return edges
  6955. }
  6956. // EdgeCleared returns a boolean which indicates if the edge with the given name
  6957. // was cleared in this mutation.
  6958. func (m *ChatRecordsMutation) EdgeCleared(name string) bool {
  6959. return false
  6960. }
  6961. // ClearEdge clears the value of the edge with the given name. It returns an error
  6962. // if that edge is not defined in the schema.
  6963. func (m *ChatRecordsMutation) ClearEdge(name string) error {
  6964. return fmt.Errorf("unknown ChatRecords unique edge %s", name)
  6965. }
  6966. // ResetEdge resets all changes to the edge with the given name in this mutation.
  6967. // It returns an error if the edge is not defined in the schema.
  6968. func (m *ChatRecordsMutation) ResetEdge(name string) error {
  6969. return fmt.Errorf("unknown ChatRecords edge %s", name)
  6970. }
  6971. // ChatSessionMutation represents an operation that mutates the ChatSession nodes in the graph.
  6972. type ChatSessionMutation struct {
  6973. config
  6974. op Op
  6975. typ string
  6976. id *uint64
  6977. created_at *time.Time
  6978. updated_at *time.Time
  6979. deleted_at *time.Time
  6980. name *string
  6981. user_id *uint64
  6982. adduser_id *int64
  6983. bot_id *uint64
  6984. addbot_id *int64
  6985. bot_type *uint8
  6986. addbot_type *int8
  6987. clearedFields map[string]struct{}
  6988. done bool
  6989. oldValue func(context.Context) (*ChatSession, error)
  6990. predicates []predicate.ChatSession
  6991. }
  6992. var _ ent.Mutation = (*ChatSessionMutation)(nil)
  6993. // chatsessionOption allows management of the mutation configuration using functional options.
  6994. type chatsessionOption func(*ChatSessionMutation)
  6995. // newChatSessionMutation creates new mutation for the ChatSession entity.
  6996. func newChatSessionMutation(c config, op Op, opts ...chatsessionOption) *ChatSessionMutation {
  6997. m := &ChatSessionMutation{
  6998. config: c,
  6999. op: op,
  7000. typ: TypeChatSession,
  7001. clearedFields: make(map[string]struct{}),
  7002. }
  7003. for _, opt := range opts {
  7004. opt(m)
  7005. }
  7006. return m
  7007. }
  7008. // withChatSessionID sets the ID field of the mutation.
  7009. func withChatSessionID(id uint64) chatsessionOption {
  7010. return func(m *ChatSessionMutation) {
  7011. var (
  7012. err error
  7013. once sync.Once
  7014. value *ChatSession
  7015. )
  7016. m.oldValue = func(ctx context.Context) (*ChatSession, error) {
  7017. once.Do(func() {
  7018. if m.done {
  7019. err = errors.New("querying old values post mutation is not allowed")
  7020. } else {
  7021. value, err = m.Client().ChatSession.Get(ctx, id)
  7022. }
  7023. })
  7024. return value, err
  7025. }
  7026. m.id = &id
  7027. }
  7028. }
  7029. // withChatSession sets the old ChatSession of the mutation.
  7030. func withChatSession(node *ChatSession) chatsessionOption {
  7031. return func(m *ChatSessionMutation) {
  7032. m.oldValue = func(context.Context) (*ChatSession, error) {
  7033. return node, nil
  7034. }
  7035. m.id = &node.ID
  7036. }
  7037. }
  7038. // Client returns a new `ent.Client` from the mutation. If the mutation was
  7039. // executed in a transaction (ent.Tx), a transactional client is returned.
  7040. func (m ChatSessionMutation) Client() *Client {
  7041. client := &Client{config: m.config}
  7042. client.init()
  7043. return client
  7044. }
  7045. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  7046. // it returns an error otherwise.
  7047. func (m ChatSessionMutation) Tx() (*Tx, error) {
  7048. if _, ok := m.driver.(*txDriver); !ok {
  7049. return nil, errors.New("ent: mutation is not running in a transaction")
  7050. }
  7051. tx := &Tx{config: m.config}
  7052. tx.init()
  7053. return tx, nil
  7054. }
  7055. // SetID sets the value of the id field. Note that this
  7056. // operation is only accepted on creation of ChatSession entities.
  7057. func (m *ChatSessionMutation) SetID(id uint64) {
  7058. m.id = &id
  7059. }
  7060. // ID returns the ID value in the mutation. Note that the ID is only available
  7061. // if it was provided to the builder or after it was returned from the database.
  7062. func (m *ChatSessionMutation) ID() (id uint64, exists bool) {
  7063. if m.id == nil {
  7064. return
  7065. }
  7066. return *m.id, true
  7067. }
  7068. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  7069. // That means, if the mutation is applied within a transaction with an isolation level such
  7070. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  7071. // or updated by the mutation.
  7072. func (m *ChatSessionMutation) IDs(ctx context.Context) ([]uint64, error) {
  7073. switch {
  7074. case m.op.Is(OpUpdateOne | OpDeleteOne):
  7075. id, exists := m.ID()
  7076. if exists {
  7077. return []uint64{id}, nil
  7078. }
  7079. fallthrough
  7080. case m.op.Is(OpUpdate | OpDelete):
  7081. return m.Client().ChatSession.Query().Where(m.predicates...).IDs(ctx)
  7082. default:
  7083. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  7084. }
  7085. }
  7086. // SetCreatedAt sets the "created_at" field.
  7087. func (m *ChatSessionMutation) SetCreatedAt(t time.Time) {
  7088. m.created_at = &t
  7089. }
  7090. // CreatedAt returns the value of the "created_at" field in the mutation.
  7091. func (m *ChatSessionMutation) CreatedAt() (r time.Time, exists bool) {
  7092. v := m.created_at
  7093. if v == nil {
  7094. return
  7095. }
  7096. return *v, true
  7097. }
  7098. // OldCreatedAt returns the old "created_at" field's value of the ChatSession entity.
  7099. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7100. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7101. func (m *ChatSessionMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  7102. if !m.op.Is(OpUpdateOne) {
  7103. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  7104. }
  7105. if m.id == nil || m.oldValue == nil {
  7106. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  7107. }
  7108. oldValue, err := m.oldValue(ctx)
  7109. if err != nil {
  7110. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  7111. }
  7112. return oldValue.CreatedAt, nil
  7113. }
  7114. // ResetCreatedAt resets all changes to the "created_at" field.
  7115. func (m *ChatSessionMutation) ResetCreatedAt() {
  7116. m.created_at = nil
  7117. }
  7118. // SetUpdatedAt sets the "updated_at" field.
  7119. func (m *ChatSessionMutation) SetUpdatedAt(t time.Time) {
  7120. m.updated_at = &t
  7121. }
  7122. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  7123. func (m *ChatSessionMutation) UpdatedAt() (r time.Time, exists bool) {
  7124. v := m.updated_at
  7125. if v == nil {
  7126. return
  7127. }
  7128. return *v, true
  7129. }
  7130. // OldUpdatedAt returns the old "updated_at" field's value of the ChatSession entity.
  7131. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7132. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7133. func (m *ChatSessionMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  7134. if !m.op.Is(OpUpdateOne) {
  7135. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  7136. }
  7137. if m.id == nil || m.oldValue == nil {
  7138. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  7139. }
  7140. oldValue, err := m.oldValue(ctx)
  7141. if err != nil {
  7142. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  7143. }
  7144. return oldValue.UpdatedAt, nil
  7145. }
  7146. // ResetUpdatedAt resets all changes to the "updated_at" field.
  7147. func (m *ChatSessionMutation) ResetUpdatedAt() {
  7148. m.updated_at = nil
  7149. }
  7150. // SetDeletedAt sets the "deleted_at" field.
  7151. func (m *ChatSessionMutation) SetDeletedAt(t time.Time) {
  7152. m.deleted_at = &t
  7153. }
  7154. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  7155. func (m *ChatSessionMutation) DeletedAt() (r time.Time, exists bool) {
  7156. v := m.deleted_at
  7157. if v == nil {
  7158. return
  7159. }
  7160. return *v, true
  7161. }
  7162. // OldDeletedAt returns the old "deleted_at" field's value of the ChatSession entity.
  7163. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7164. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7165. func (m *ChatSessionMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  7166. if !m.op.Is(OpUpdateOne) {
  7167. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  7168. }
  7169. if m.id == nil || m.oldValue == nil {
  7170. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  7171. }
  7172. oldValue, err := m.oldValue(ctx)
  7173. if err != nil {
  7174. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  7175. }
  7176. return oldValue.DeletedAt, nil
  7177. }
  7178. // ClearDeletedAt clears the value of the "deleted_at" field.
  7179. func (m *ChatSessionMutation) ClearDeletedAt() {
  7180. m.deleted_at = nil
  7181. m.clearedFields[chatsession.FieldDeletedAt] = struct{}{}
  7182. }
  7183. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  7184. func (m *ChatSessionMutation) DeletedAtCleared() bool {
  7185. _, ok := m.clearedFields[chatsession.FieldDeletedAt]
  7186. return ok
  7187. }
  7188. // ResetDeletedAt resets all changes to the "deleted_at" field.
  7189. func (m *ChatSessionMutation) ResetDeletedAt() {
  7190. m.deleted_at = nil
  7191. delete(m.clearedFields, chatsession.FieldDeletedAt)
  7192. }
  7193. // SetName sets the "name" field.
  7194. func (m *ChatSessionMutation) SetName(s string) {
  7195. m.name = &s
  7196. }
  7197. // Name returns the value of the "name" field in the mutation.
  7198. func (m *ChatSessionMutation) Name() (r string, exists bool) {
  7199. v := m.name
  7200. if v == nil {
  7201. return
  7202. }
  7203. return *v, true
  7204. }
  7205. // OldName returns the old "name" field's value of the ChatSession entity.
  7206. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7207. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7208. func (m *ChatSessionMutation) OldName(ctx context.Context) (v string, err error) {
  7209. if !m.op.Is(OpUpdateOne) {
  7210. return v, errors.New("OldName is only allowed on UpdateOne operations")
  7211. }
  7212. if m.id == nil || m.oldValue == nil {
  7213. return v, errors.New("OldName requires an ID field in the mutation")
  7214. }
  7215. oldValue, err := m.oldValue(ctx)
  7216. if err != nil {
  7217. return v, fmt.Errorf("querying old value for OldName: %w", err)
  7218. }
  7219. return oldValue.Name, nil
  7220. }
  7221. // ResetName resets all changes to the "name" field.
  7222. func (m *ChatSessionMutation) ResetName() {
  7223. m.name = nil
  7224. }
  7225. // SetUserID sets the "user_id" field.
  7226. func (m *ChatSessionMutation) SetUserID(u uint64) {
  7227. m.user_id = &u
  7228. m.adduser_id = nil
  7229. }
  7230. // UserID returns the value of the "user_id" field in the mutation.
  7231. func (m *ChatSessionMutation) UserID() (r uint64, exists bool) {
  7232. v := m.user_id
  7233. if v == nil {
  7234. return
  7235. }
  7236. return *v, true
  7237. }
  7238. // OldUserID returns the old "user_id" field's value of the ChatSession entity.
  7239. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7240. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7241. func (m *ChatSessionMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  7242. if !m.op.Is(OpUpdateOne) {
  7243. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  7244. }
  7245. if m.id == nil || m.oldValue == nil {
  7246. return v, errors.New("OldUserID requires an ID field in the mutation")
  7247. }
  7248. oldValue, err := m.oldValue(ctx)
  7249. if err != nil {
  7250. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  7251. }
  7252. return oldValue.UserID, nil
  7253. }
  7254. // AddUserID adds u to the "user_id" field.
  7255. func (m *ChatSessionMutation) AddUserID(u int64) {
  7256. if m.adduser_id != nil {
  7257. *m.adduser_id += u
  7258. } else {
  7259. m.adduser_id = &u
  7260. }
  7261. }
  7262. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  7263. func (m *ChatSessionMutation) AddedUserID() (r int64, exists bool) {
  7264. v := m.adduser_id
  7265. if v == nil {
  7266. return
  7267. }
  7268. return *v, true
  7269. }
  7270. // ResetUserID resets all changes to the "user_id" field.
  7271. func (m *ChatSessionMutation) ResetUserID() {
  7272. m.user_id = nil
  7273. m.adduser_id = nil
  7274. }
  7275. // SetBotID sets the "bot_id" field.
  7276. func (m *ChatSessionMutation) SetBotID(u uint64) {
  7277. m.bot_id = &u
  7278. m.addbot_id = nil
  7279. }
  7280. // BotID returns the value of the "bot_id" field in the mutation.
  7281. func (m *ChatSessionMutation) BotID() (r uint64, exists bool) {
  7282. v := m.bot_id
  7283. if v == nil {
  7284. return
  7285. }
  7286. return *v, true
  7287. }
  7288. // OldBotID returns the old "bot_id" field's value of the ChatSession entity.
  7289. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7290. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7291. func (m *ChatSessionMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  7292. if !m.op.Is(OpUpdateOne) {
  7293. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  7294. }
  7295. if m.id == nil || m.oldValue == nil {
  7296. return v, errors.New("OldBotID requires an ID field in the mutation")
  7297. }
  7298. oldValue, err := m.oldValue(ctx)
  7299. if err != nil {
  7300. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  7301. }
  7302. return oldValue.BotID, nil
  7303. }
  7304. // AddBotID adds u to the "bot_id" field.
  7305. func (m *ChatSessionMutation) AddBotID(u int64) {
  7306. if m.addbot_id != nil {
  7307. *m.addbot_id += u
  7308. } else {
  7309. m.addbot_id = &u
  7310. }
  7311. }
  7312. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  7313. func (m *ChatSessionMutation) AddedBotID() (r int64, exists bool) {
  7314. v := m.addbot_id
  7315. if v == nil {
  7316. return
  7317. }
  7318. return *v, true
  7319. }
  7320. // ResetBotID resets all changes to the "bot_id" field.
  7321. func (m *ChatSessionMutation) ResetBotID() {
  7322. m.bot_id = nil
  7323. m.addbot_id = nil
  7324. }
  7325. // SetBotType sets the "bot_type" field.
  7326. func (m *ChatSessionMutation) SetBotType(u uint8) {
  7327. m.bot_type = &u
  7328. m.addbot_type = nil
  7329. }
  7330. // BotType returns the value of the "bot_type" field in the mutation.
  7331. func (m *ChatSessionMutation) BotType() (r uint8, exists bool) {
  7332. v := m.bot_type
  7333. if v == nil {
  7334. return
  7335. }
  7336. return *v, true
  7337. }
  7338. // OldBotType returns the old "bot_type" field's value of the ChatSession entity.
  7339. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7340. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7341. func (m *ChatSessionMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  7342. if !m.op.Is(OpUpdateOne) {
  7343. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  7344. }
  7345. if m.id == nil || m.oldValue == nil {
  7346. return v, errors.New("OldBotType requires an ID field in the mutation")
  7347. }
  7348. oldValue, err := m.oldValue(ctx)
  7349. if err != nil {
  7350. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  7351. }
  7352. return oldValue.BotType, nil
  7353. }
  7354. // AddBotType adds u to the "bot_type" field.
  7355. func (m *ChatSessionMutation) AddBotType(u int8) {
  7356. if m.addbot_type != nil {
  7357. *m.addbot_type += u
  7358. } else {
  7359. m.addbot_type = &u
  7360. }
  7361. }
  7362. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  7363. func (m *ChatSessionMutation) AddedBotType() (r int8, exists bool) {
  7364. v := m.addbot_type
  7365. if v == nil {
  7366. return
  7367. }
  7368. return *v, true
  7369. }
  7370. // ResetBotType resets all changes to the "bot_type" field.
  7371. func (m *ChatSessionMutation) ResetBotType() {
  7372. m.bot_type = nil
  7373. m.addbot_type = nil
  7374. }
  7375. // Where appends a list predicates to the ChatSessionMutation builder.
  7376. func (m *ChatSessionMutation) Where(ps ...predicate.ChatSession) {
  7377. m.predicates = append(m.predicates, ps...)
  7378. }
  7379. // WhereP appends storage-level predicates to the ChatSessionMutation builder. Using this method,
  7380. // users can use type-assertion to append predicates that do not depend on any generated package.
  7381. func (m *ChatSessionMutation) WhereP(ps ...func(*sql.Selector)) {
  7382. p := make([]predicate.ChatSession, len(ps))
  7383. for i := range ps {
  7384. p[i] = ps[i]
  7385. }
  7386. m.Where(p...)
  7387. }
  7388. // Op returns the operation name.
  7389. func (m *ChatSessionMutation) Op() Op {
  7390. return m.op
  7391. }
  7392. // SetOp allows setting the mutation operation.
  7393. func (m *ChatSessionMutation) SetOp(op Op) {
  7394. m.op = op
  7395. }
  7396. // Type returns the node type of this mutation (ChatSession).
  7397. func (m *ChatSessionMutation) Type() string {
  7398. return m.typ
  7399. }
  7400. // Fields returns all fields that were changed during this mutation. Note that in
  7401. // order to get all numeric fields that were incremented/decremented, call
  7402. // AddedFields().
  7403. func (m *ChatSessionMutation) Fields() []string {
  7404. fields := make([]string, 0, 7)
  7405. if m.created_at != nil {
  7406. fields = append(fields, chatsession.FieldCreatedAt)
  7407. }
  7408. if m.updated_at != nil {
  7409. fields = append(fields, chatsession.FieldUpdatedAt)
  7410. }
  7411. if m.deleted_at != nil {
  7412. fields = append(fields, chatsession.FieldDeletedAt)
  7413. }
  7414. if m.name != nil {
  7415. fields = append(fields, chatsession.FieldName)
  7416. }
  7417. if m.user_id != nil {
  7418. fields = append(fields, chatsession.FieldUserID)
  7419. }
  7420. if m.bot_id != nil {
  7421. fields = append(fields, chatsession.FieldBotID)
  7422. }
  7423. if m.bot_type != nil {
  7424. fields = append(fields, chatsession.FieldBotType)
  7425. }
  7426. return fields
  7427. }
  7428. // Field returns the value of a field with the given name. The second boolean
  7429. // return value indicates that this field was not set, or was not defined in the
  7430. // schema.
  7431. func (m *ChatSessionMutation) Field(name string) (ent.Value, bool) {
  7432. switch name {
  7433. case chatsession.FieldCreatedAt:
  7434. return m.CreatedAt()
  7435. case chatsession.FieldUpdatedAt:
  7436. return m.UpdatedAt()
  7437. case chatsession.FieldDeletedAt:
  7438. return m.DeletedAt()
  7439. case chatsession.FieldName:
  7440. return m.Name()
  7441. case chatsession.FieldUserID:
  7442. return m.UserID()
  7443. case chatsession.FieldBotID:
  7444. return m.BotID()
  7445. case chatsession.FieldBotType:
  7446. return m.BotType()
  7447. }
  7448. return nil, false
  7449. }
  7450. // OldField returns the old value of the field from the database. An error is
  7451. // returned if the mutation operation is not UpdateOne, or the query to the
  7452. // database failed.
  7453. func (m *ChatSessionMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  7454. switch name {
  7455. case chatsession.FieldCreatedAt:
  7456. return m.OldCreatedAt(ctx)
  7457. case chatsession.FieldUpdatedAt:
  7458. return m.OldUpdatedAt(ctx)
  7459. case chatsession.FieldDeletedAt:
  7460. return m.OldDeletedAt(ctx)
  7461. case chatsession.FieldName:
  7462. return m.OldName(ctx)
  7463. case chatsession.FieldUserID:
  7464. return m.OldUserID(ctx)
  7465. case chatsession.FieldBotID:
  7466. return m.OldBotID(ctx)
  7467. case chatsession.FieldBotType:
  7468. return m.OldBotType(ctx)
  7469. }
  7470. return nil, fmt.Errorf("unknown ChatSession field %s", name)
  7471. }
  7472. // SetField sets the value of a field with the given name. It returns an error if
  7473. // the field is not defined in the schema, or if the type mismatched the field
  7474. // type.
  7475. func (m *ChatSessionMutation) SetField(name string, value ent.Value) error {
  7476. switch name {
  7477. case chatsession.FieldCreatedAt:
  7478. v, ok := value.(time.Time)
  7479. if !ok {
  7480. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7481. }
  7482. m.SetCreatedAt(v)
  7483. return nil
  7484. case chatsession.FieldUpdatedAt:
  7485. v, ok := value.(time.Time)
  7486. if !ok {
  7487. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7488. }
  7489. m.SetUpdatedAt(v)
  7490. return nil
  7491. case chatsession.FieldDeletedAt:
  7492. v, ok := value.(time.Time)
  7493. if !ok {
  7494. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7495. }
  7496. m.SetDeletedAt(v)
  7497. return nil
  7498. case chatsession.FieldName:
  7499. v, ok := value.(string)
  7500. if !ok {
  7501. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7502. }
  7503. m.SetName(v)
  7504. return nil
  7505. case chatsession.FieldUserID:
  7506. v, ok := value.(uint64)
  7507. if !ok {
  7508. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7509. }
  7510. m.SetUserID(v)
  7511. return nil
  7512. case chatsession.FieldBotID:
  7513. v, ok := value.(uint64)
  7514. if !ok {
  7515. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7516. }
  7517. m.SetBotID(v)
  7518. return nil
  7519. case chatsession.FieldBotType:
  7520. v, ok := value.(uint8)
  7521. if !ok {
  7522. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7523. }
  7524. m.SetBotType(v)
  7525. return nil
  7526. }
  7527. return fmt.Errorf("unknown ChatSession field %s", name)
  7528. }
  7529. // AddedFields returns all numeric fields that were incremented/decremented during
  7530. // this mutation.
  7531. func (m *ChatSessionMutation) AddedFields() []string {
  7532. var fields []string
  7533. if m.adduser_id != nil {
  7534. fields = append(fields, chatsession.FieldUserID)
  7535. }
  7536. if m.addbot_id != nil {
  7537. fields = append(fields, chatsession.FieldBotID)
  7538. }
  7539. if m.addbot_type != nil {
  7540. fields = append(fields, chatsession.FieldBotType)
  7541. }
  7542. return fields
  7543. }
  7544. // AddedField returns the numeric value that was incremented/decremented on a field
  7545. // with the given name. The second boolean return value indicates that this field
  7546. // was not set, or was not defined in the schema.
  7547. func (m *ChatSessionMutation) AddedField(name string) (ent.Value, bool) {
  7548. switch name {
  7549. case chatsession.FieldUserID:
  7550. return m.AddedUserID()
  7551. case chatsession.FieldBotID:
  7552. return m.AddedBotID()
  7553. case chatsession.FieldBotType:
  7554. return m.AddedBotType()
  7555. }
  7556. return nil, false
  7557. }
  7558. // AddField adds the value to the field with the given name. It returns an error if
  7559. // the field is not defined in the schema, or if the type mismatched the field
  7560. // type.
  7561. func (m *ChatSessionMutation) AddField(name string, value ent.Value) error {
  7562. switch name {
  7563. case chatsession.FieldUserID:
  7564. v, ok := value.(int64)
  7565. if !ok {
  7566. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7567. }
  7568. m.AddUserID(v)
  7569. return nil
  7570. case chatsession.FieldBotID:
  7571. v, ok := value.(int64)
  7572. if !ok {
  7573. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7574. }
  7575. m.AddBotID(v)
  7576. return nil
  7577. case chatsession.FieldBotType:
  7578. v, ok := value.(int8)
  7579. if !ok {
  7580. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7581. }
  7582. m.AddBotType(v)
  7583. return nil
  7584. }
  7585. return fmt.Errorf("unknown ChatSession numeric field %s", name)
  7586. }
  7587. // ClearedFields returns all nullable fields that were cleared during this
  7588. // mutation.
  7589. func (m *ChatSessionMutation) ClearedFields() []string {
  7590. var fields []string
  7591. if m.FieldCleared(chatsession.FieldDeletedAt) {
  7592. fields = append(fields, chatsession.FieldDeletedAt)
  7593. }
  7594. return fields
  7595. }
  7596. // FieldCleared returns a boolean indicating if a field with the given name was
  7597. // cleared in this mutation.
  7598. func (m *ChatSessionMutation) FieldCleared(name string) bool {
  7599. _, ok := m.clearedFields[name]
  7600. return ok
  7601. }
  7602. // ClearField clears the value of the field with the given name. It returns an
  7603. // error if the field is not defined in the schema.
  7604. func (m *ChatSessionMutation) ClearField(name string) error {
  7605. switch name {
  7606. case chatsession.FieldDeletedAt:
  7607. m.ClearDeletedAt()
  7608. return nil
  7609. }
  7610. return fmt.Errorf("unknown ChatSession nullable field %s", name)
  7611. }
  7612. // ResetField resets all changes in the mutation for the field with the given name.
  7613. // It returns an error if the field is not defined in the schema.
  7614. func (m *ChatSessionMutation) ResetField(name string) error {
  7615. switch name {
  7616. case chatsession.FieldCreatedAt:
  7617. m.ResetCreatedAt()
  7618. return nil
  7619. case chatsession.FieldUpdatedAt:
  7620. m.ResetUpdatedAt()
  7621. return nil
  7622. case chatsession.FieldDeletedAt:
  7623. m.ResetDeletedAt()
  7624. return nil
  7625. case chatsession.FieldName:
  7626. m.ResetName()
  7627. return nil
  7628. case chatsession.FieldUserID:
  7629. m.ResetUserID()
  7630. return nil
  7631. case chatsession.FieldBotID:
  7632. m.ResetBotID()
  7633. return nil
  7634. case chatsession.FieldBotType:
  7635. m.ResetBotType()
  7636. return nil
  7637. }
  7638. return fmt.Errorf("unknown ChatSession field %s", name)
  7639. }
  7640. // AddedEdges returns all edge names that were set/added in this mutation.
  7641. func (m *ChatSessionMutation) AddedEdges() []string {
  7642. edges := make([]string, 0, 0)
  7643. return edges
  7644. }
  7645. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  7646. // name in this mutation.
  7647. func (m *ChatSessionMutation) AddedIDs(name string) []ent.Value {
  7648. return nil
  7649. }
  7650. // RemovedEdges returns all edge names that were removed in this mutation.
  7651. func (m *ChatSessionMutation) RemovedEdges() []string {
  7652. edges := make([]string, 0, 0)
  7653. return edges
  7654. }
  7655. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  7656. // the given name in this mutation.
  7657. func (m *ChatSessionMutation) RemovedIDs(name string) []ent.Value {
  7658. return nil
  7659. }
  7660. // ClearedEdges returns all edge names that were cleared in this mutation.
  7661. func (m *ChatSessionMutation) ClearedEdges() []string {
  7662. edges := make([]string, 0, 0)
  7663. return edges
  7664. }
  7665. // EdgeCleared returns a boolean which indicates if the edge with the given name
  7666. // was cleared in this mutation.
  7667. func (m *ChatSessionMutation) EdgeCleared(name string) bool {
  7668. return false
  7669. }
  7670. // ClearEdge clears the value of the edge with the given name. It returns an error
  7671. // if that edge is not defined in the schema.
  7672. func (m *ChatSessionMutation) ClearEdge(name string) error {
  7673. return fmt.Errorf("unknown ChatSession unique edge %s", name)
  7674. }
  7675. // ResetEdge resets all changes to the edge with the given name in this mutation.
  7676. // It returns an error if the edge is not defined in the schema.
  7677. func (m *ChatSessionMutation) ResetEdge(name string) error {
  7678. return fmt.Errorf("unknown ChatSession edge %s", name)
  7679. }
  7680. // ContactMutation represents an operation that mutates the Contact nodes in the graph.
  7681. type ContactMutation struct {
  7682. config
  7683. op Op
  7684. typ string
  7685. id *uint64
  7686. created_at *time.Time
  7687. updated_at *time.Time
  7688. status *uint8
  7689. addstatus *int8
  7690. deleted_at *time.Time
  7691. wx_wxid *string
  7692. _type *int
  7693. add_type *int
  7694. wxid *string
  7695. account *string
  7696. nickname *string
  7697. markname *string
  7698. headimg *string
  7699. sex *int
  7700. addsex *int
  7701. starrole *string
  7702. dontseeit *int
  7703. adddontseeit *int
  7704. dontseeme *int
  7705. adddontseeme *int
  7706. lag *string
  7707. gid *string
  7708. gname *string
  7709. v3 *string
  7710. organization_id *uint64
  7711. addorganization_id *int64
  7712. clearedFields map[string]struct{}
  7713. contact_relationships map[uint64]struct{}
  7714. removedcontact_relationships map[uint64]struct{}
  7715. clearedcontact_relationships bool
  7716. contact_messages map[uint64]struct{}
  7717. removedcontact_messages map[uint64]struct{}
  7718. clearedcontact_messages bool
  7719. done bool
  7720. oldValue func(context.Context) (*Contact, error)
  7721. predicates []predicate.Contact
  7722. }
  7723. var _ ent.Mutation = (*ContactMutation)(nil)
  7724. // contactOption allows management of the mutation configuration using functional options.
  7725. type contactOption func(*ContactMutation)
  7726. // newContactMutation creates new mutation for the Contact entity.
  7727. func newContactMutation(c config, op Op, opts ...contactOption) *ContactMutation {
  7728. m := &ContactMutation{
  7729. config: c,
  7730. op: op,
  7731. typ: TypeContact,
  7732. clearedFields: make(map[string]struct{}),
  7733. }
  7734. for _, opt := range opts {
  7735. opt(m)
  7736. }
  7737. return m
  7738. }
  7739. // withContactID sets the ID field of the mutation.
  7740. func withContactID(id uint64) contactOption {
  7741. return func(m *ContactMutation) {
  7742. var (
  7743. err error
  7744. once sync.Once
  7745. value *Contact
  7746. )
  7747. m.oldValue = func(ctx context.Context) (*Contact, error) {
  7748. once.Do(func() {
  7749. if m.done {
  7750. err = errors.New("querying old values post mutation is not allowed")
  7751. } else {
  7752. value, err = m.Client().Contact.Get(ctx, id)
  7753. }
  7754. })
  7755. return value, err
  7756. }
  7757. m.id = &id
  7758. }
  7759. }
  7760. // withContact sets the old Contact of the mutation.
  7761. func withContact(node *Contact) contactOption {
  7762. return func(m *ContactMutation) {
  7763. m.oldValue = func(context.Context) (*Contact, error) {
  7764. return node, nil
  7765. }
  7766. m.id = &node.ID
  7767. }
  7768. }
  7769. // Client returns a new `ent.Client` from the mutation. If the mutation was
  7770. // executed in a transaction (ent.Tx), a transactional client is returned.
  7771. func (m ContactMutation) Client() *Client {
  7772. client := &Client{config: m.config}
  7773. client.init()
  7774. return client
  7775. }
  7776. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  7777. // it returns an error otherwise.
  7778. func (m ContactMutation) Tx() (*Tx, error) {
  7779. if _, ok := m.driver.(*txDriver); !ok {
  7780. return nil, errors.New("ent: mutation is not running in a transaction")
  7781. }
  7782. tx := &Tx{config: m.config}
  7783. tx.init()
  7784. return tx, nil
  7785. }
  7786. // SetID sets the value of the id field. Note that this
  7787. // operation is only accepted on creation of Contact entities.
  7788. func (m *ContactMutation) SetID(id uint64) {
  7789. m.id = &id
  7790. }
  7791. // ID returns the ID value in the mutation. Note that the ID is only available
  7792. // if it was provided to the builder or after it was returned from the database.
  7793. func (m *ContactMutation) ID() (id uint64, exists bool) {
  7794. if m.id == nil {
  7795. return
  7796. }
  7797. return *m.id, true
  7798. }
  7799. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  7800. // That means, if the mutation is applied within a transaction with an isolation level such
  7801. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  7802. // or updated by the mutation.
  7803. func (m *ContactMutation) IDs(ctx context.Context) ([]uint64, error) {
  7804. switch {
  7805. case m.op.Is(OpUpdateOne | OpDeleteOne):
  7806. id, exists := m.ID()
  7807. if exists {
  7808. return []uint64{id}, nil
  7809. }
  7810. fallthrough
  7811. case m.op.Is(OpUpdate | OpDelete):
  7812. return m.Client().Contact.Query().Where(m.predicates...).IDs(ctx)
  7813. default:
  7814. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  7815. }
  7816. }
  7817. // SetCreatedAt sets the "created_at" field.
  7818. func (m *ContactMutation) SetCreatedAt(t time.Time) {
  7819. m.created_at = &t
  7820. }
  7821. // CreatedAt returns the value of the "created_at" field in the mutation.
  7822. func (m *ContactMutation) CreatedAt() (r time.Time, exists bool) {
  7823. v := m.created_at
  7824. if v == nil {
  7825. return
  7826. }
  7827. return *v, true
  7828. }
  7829. // OldCreatedAt returns the old "created_at" field's value of the Contact entity.
  7830. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7831. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7832. func (m *ContactMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  7833. if !m.op.Is(OpUpdateOne) {
  7834. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  7835. }
  7836. if m.id == nil || m.oldValue == nil {
  7837. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  7838. }
  7839. oldValue, err := m.oldValue(ctx)
  7840. if err != nil {
  7841. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  7842. }
  7843. return oldValue.CreatedAt, nil
  7844. }
  7845. // ResetCreatedAt resets all changes to the "created_at" field.
  7846. func (m *ContactMutation) ResetCreatedAt() {
  7847. m.created_at = nil
  7848. }
  7849. // SetUpdatedAt sets the "updated_at" field.
  7850. func (m *ContactMutation) SetUpdatedAt(t time.Time) {
  7851. m.updated_at = &t
  7852. }
  7853. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  7854. func (m *ContactMutation) UpdatedAt() (r time.Time, exists bool) {
  7855. v := m.updated_at
  7856. if v == nil {
  7857. return
  7858. }
  7859. return *v, true
  7860. }
  7861. // OldUpdatedAt returns the old "updated_at" field's value of the Contact entity.
  7862. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7863. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7864. func (m *ContactMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  7865. if !m.op.Is(OpUpdateOne) {
  7866. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  7867. }
  7868. if m.id == nil || m.oldValue == nil {
  7869. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  7870. }
  7871. oldValue, err := m.oldValue(ctx)
  7872. if err != nil {
  7873. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  7874. }
  7875. return oldValue.UpdatedAt, nil
  7876. }
  7877. // ResetUpdatedAt resets all changes to the "updated_at" field.
  7878. func (m *ContactMutation) ResetUpdatedAt() {
  7879. m.updated_at = nil
  7880. }
  7881. // SetStatus sets the "status" field.
  7882. func (m *ContactMutation) SetStatus(u uint8) {
  7883. m.status = &u
  7884. m.addstatus = nil
  7885. }
  7886. // Status returns the value of the "status" field in the mutation.
  7887. func (m *ContactMutation) Status() (r uint8, exists bool) {
  7888. v := m.status
  7889. if v == nil {
  7890. return
  7891. }
  7892. return *v, true
  7893. }
  7894. // OldStatus returns the old "status" field's value of the Contact entity.
  7895. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7896. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7897. func (m *ContactMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  7898. if !m.op.Is(OpUpdateOne) {
  7899. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  7900. }
  7901. if m.id == nil || m.oldValue == nil {
  7902. return v, errors.New("OldStatus requires an ID field in the mutation")
  7903. }
  7904. oldValue, err := m.oldValue(ctx)
  7905. if err != nil {
  7906. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  7907. }
  7908. return oldValue.Status, nil
  7909. }
  7910. // AddStatus adds u to the "status" field.
  7911. func (m *ContactMutation) AddStatus(u int8) {
  7912. if m.addstatus != nil {
  7913. *m.addstatus += u
  7914. } else {
  7915. m.addstatus = &u
  7916. }
  7917. }
  7918. // AddedStatus returns the value that was added to the "status" field in this mutation.
  7919. func (m *ContactMutation) AddedStatus() (r int8, exists bool) {
  7920. v := m.addstatus
  7921. if v == nil {
  7922. return
  7923. }
  7924. return *v, true
  7925. }
  7926. // ClearStatus clears the value of the "status" field.
  7927. func (m *ContactMutation) ClearStatus() {
  7928. m.status = nil
  7929. m.addstatus = nil
  7930. m.clearedFields[contact.FieldStatus] = struct{}{}
  7931. }
  7932. // StatusCleared returns if the "status" field was cleared in this mutation.
  7933. func (m *ContactMutation) StatusCleared() bool {
  7934. _, ok := m.clearedFields[contact.FieldStatus]
  7935. return ok
  7936. }
  7937. // ResetStatus resets all changes to the "status" field.
  7938. func (m *ContactMutation) ResetStatus() {
  7939. m.status = nil
  7940. m.addstatus = nil
  7941. delete(m.clearedFields, contact.FieldStatus)
  7942. }
  7943. // SetDeletedAt sets the "deleted_at" field.
  7944. func (m *ContactMutation) SetDeletedAt(t time.Time) {
  7945. m.deleted_at = &t
  7946. }
  7947. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  7948. func (m *ContactMutation) DeletedAt() (r time.Time, exists bool) {
  7949. v := m.deleted_at
  7950. if v == nil {
  7951. return
  7952. }
  7953. return *v, true
  7954. }
  7955. // OldDeletedAt returns the old "deleted_at" field's value of the Contact entity.
  7956. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7957. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7958. func (m *ContactMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  7959. if !m.op.Is(OpUpdateOne) {
  7960. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  7961. }
  7962. if m.id == nil || m.oldValue == nil {
  7963. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  7964. }
  7965. oldValue, err := m.oldValue(ctx)
  7966. if err != nil {
  7967. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  7968. }
  7969. return oldValue.DeletedAt, nil
  7970. }
  7971. // ClearDeletedAt clears the value of the "deleted_at" field.
  7972. func (m *ContactMutation) ClearDeletedAt() {
  7973. m.deleted_at = nil
  7974. m.clearedFields[contact.FieldDeletedAt] = struct{}{}
  7975. }
  7976. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  7977. func (m *ContactMutation) DeletedAtCleared() bool {
  7978. _, ok := m.clearedFields[contact.FieldDeletedAt]
  7979. return ok
  7980. }
  7981. // ResetDeletedAt resets all changes to the "deleted_at" field.
  7982. func (m *ContactMutation) ResetDeletedAt() {
  7983. m.deleted_at = nil
  7984. delete(m.clearedFields, contact.FieldDeletedAt)
  7985. }
  7986. // SetWxWxid sets the "wx_wxid" field.
  7987. func (m *ContactMutation) SetWxWxid(s string) {
  7988. m.wx_wxid = &s
  7989. }
  7990. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  7991. func (m *ContactMutation) WxWxid() (r string, exists bool) {
  7992. v := m.wx_wxid
  7993. if v == nil {
  7994. return
  7995. }
  7996. return *v, true
  7997. }
  7998. // OldWxWxid returns the old "wx_wxid" field's value of the Contact entity.
  7999. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8000. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8001. func (m *ContactMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  8002. if !m.op.Is(OpUpdateOne) {
  8003. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  8004. }
  8005. if m.id == nil || m.oldValue == nil {
  8006. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  8007. }
  8008. oldValue, err := m.oldValue(ctx)
  8009. if err != nil {
  8010. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  8011. }
  8012. return oldValue.WxWxid, nil
  8013. }
  8014. // ResetWxWxid resets all changes to the "wx_wxid" field.
  8015. func (m *ContactMutation) ResetWxWxid() {
  8016. m.wx_wxid = nil
  8017. }
  8018. // SetType sets the "type" field.
  8019. func (m *ContactMutation) SetType(i int) {
  8020. m._type = &i
  8021. m.add_type = nil
  8022. }
  8023. // GetType returns the value of the "type" field in the mutation.
  8024. func (m *ContactMutation) GetType() (r int, exists bool) {
  8025. v := m._type
  8026. if v == nil {
  8027. return
  8028. }
  8029. return *v, true
  8030. }
  8031. // OldType returns the old "type" field's value of the Contact entity.
  8032. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8033. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8034. func (m *ContactMutation) OldType(ctx context.Context) (v int, err error) {
  8035. if !m.op.Is(OpUpdateOne) {
  8036. return v, errors.New("OldType is only allowed on UpdateOne operations")
  8037. }
  8038. if m.id == nil || m.oldValue == nil {
  8039. return v, errors.New("OldType requires an ID field in the mutation")
  8040. }
  8041. oldValue, err := m.oldValue(ctx)
  8042. if err != nil {
  8043. return v, fmt.Errorf("querying old value for OldType: %w", err)
  8044. }
  8045. return oldValue.Type, nil
  8046. }
  8047. // AddType adds i to the "type" field.
  8048. func (m *ContactMutation) AddType(i int) {
  8049. if m.add_type != nil {
  8050. *m.add_type += i
  8051. } else {
  8052. m.add_type = &i
  8053. }
  8054. }
  8055. // AddedType returns the value that was added to the "type" field in this mutation.
  8056. func (m *ContactMutation) AddedType() (r int, exists bool) {
  8057. v := m.add_type
  8058. if v == nil {
  8059. return
  8060. }
  8061. return *v, true
  8062. }
  8063. // ClearType clears the value of the "type" field.
  8064. func (m *ContactMutation) ClearType() {
  8065. m._type = nil
  8066. m.add_type = nil
  8067. m.clearedFields[contact.FieldType] = struct{}{}
  8068. }
  8069. // TypeCleared returns if the "type" field was cleared in this mutation.
  8070. func (m *ContactMutation) TypeCleared() bool {
  8071. _, ok := m.clearedFields[contact.FieldType]
  8072. return ok
  8073. }
  8074. // ResetType resets all changes to the "type" field.
  8075. func (m *ContactMutation) ResetType() {
  8076. m._type = nil
  8077. m.add_type = nil
  8078. delete(m.clearedFields, contact.FieldType)
  8079. }
  8080. // SetWxid sets the "wxid" field.
  8081. func (m *ContactMutation) SetWxid(s string) {
  8082. m.wxid = &s
  8083. }
  8084. // Wxid returns the value of the "wxid" field in the mutation.
  8085. func (m *ContactMutation) Wxid() (r string, exists bool) {
  8086. v := m.wxid
  8087. if v == nil {
  8088. return
  8089. }
  8090. return *v, true
  8091. }
  8092. // OldWxid returns the old "wxid" field's value of the Contact entity.
  8093. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8094. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8095. func (m *ContactMutation) OldWxid(ctx context.Context) (v string, err error) {
  8096. if !m.op.Is(OpUpdateOne) {
  8097. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  8098. }
  8099. if m.id == nil || m.oldValue == nil {
  8100. return v, errors.New("OldWxid requires an ID field in the mutation")
  8101. }
  8102. oldValue, err := m.oldValue(ctx)
  8103. if err != nil {
  8104. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  8105. }
  8106. return oldValue.Wxid, nil
  8107. }
  8108. // ResetWxid resets all changes to the "wxid" field.
  8109. func (m *ContactMutation) ResetWxid() {
  8110. m.wxid = nil
  8111. }
  8112. // SetAccount sets the "account" field.
  8113. func (m *ContactMutation) SetAccount(s string) {
  8114. m.account = &s
  8115. }
  8116. // Account returns the value of the "account" field in the mutation.
  8117. func (m *ContactMutation) Account() (r string, exists bool) {
  8118. v := m.account
  8119. if v == nil {
  8120. return
  8121. }
  8122. return *v, true
  8123. }
  8124. // OldAccount returns the old "account" field's value of the Contact entity.
  8125. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8126. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8127. func (m *ContactMutation) OldAccount(ctx context.Context) (v string, err error) {
  8128. if !m.op.Is(OpUpdateOne) {
  8129. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  8130. }
  8131. if m.id == nil || m.oldValue == nil {
  8132. return v, errors.New("OldAccount requires an ID field in the mutation")
  8133. }
  8134. oldValue, err := m.oldValue(ctx)
  8135. if err != nil {
  8136. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  8137. }
  8138. return oldValue.Account, nil
  8139. }
  8140. // ResetAccount resets all changes to the "account" field.
  8141. func (m *ContactMutation) ResetAccount() {
  8142. m.account = nil
  8143. }
  8144. // SetNickname sets the "nickname" field.
  8145. func (m *ContactMutation) SetNickname(s string) {
  8146. m.nickname = &s
  8147. }
  8148. // Nickname returns the value of the "nickname" field in the mutation.
  8149. func (m *ContactMutation) Nickname() (r string, exists bool) {
  8150. v := m.nickname
  8151. if v == nil {
  8152. return
  8153. }
  8154. return *v, true
  8155. }
  8156. // OldNickname returns the old "nickname" field's value of the Contact entity.
  8157. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8158. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8159. func (m *ContactMutation) OldNickname(ctx context.Context) (v string, err error) {
  8160. if !m.op.Is(OpUpdateOne) {
  8161. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  8162. }
  8163. if m.id == nil || m.oldValue == nil {
  8164. return v, errors.New("OldNickname requires an ID field in the mutation")
  8165. }
  8166. oldValue, err := m.oldValue(ctx)
  8167. if err != nil {
  8168. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  8169. }
  8170. return oldValue.Nickname, nil
  8171. }
  8172. // ResetNickname resets all changes to the "nickname" field.
  8173. func (m *ContactMutation) ResetNickname() {
  8174. m.nickname = nil
  8175. }
  8176. // SetMarkname sets the "markname" field.
  8177. func (m *ContactMutation) SetMarkname(s string) {
  8178. m.markname = &s
  8179. }
  8180. // Markname returns the value of the "markname" field in the mutation.
  8181. func (m *ContactMutation) Markname() (r string, exists bool) {
  8182. v := m.markname
  8183. if v == nil {
  8184. return
  8185. }
  8186. return *v, true
  8187. }
  8188. // OldMarkname returns the old "markname" field's value of the Contact entity.
  8189. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8190. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8191. func (m *ContactMutation) OldMarkname(ctx context.Context) (v string, err error) {
  8192. if !m.op.Is(OpUpdateOne) {
  8193. return v, errors.New("OldMarkname is only allowed on UpdateOne operations")
  8194. }
  8195. if m.id == nil || m.oldValue == nil {
  8196. return v, errors.New("OldMarkname requires an ID field in the mutation")
  8197. }
  8198. oldValue, err := m.oldValue(ctx)
  8199. if err != nil {
  8200. return v, fmt.Errorf("querying old value for OldMarkname: %w", err)
  8201. }
  8202. return oldValue.Markname, nil
  8203. }
  8204. // ResetMarkname resets all changes to the "markname" field.
  8205. func (m *ContactMutation) ResetMarkname() {
  8206. m.markname = nil
  8207. }
  8208. // SetHeadimg sets the "headimg" field.
  8209. func (m *ContactMutation) SetHeadimg(s string) {
  8210. m.headimg = &s
  8211. }
  8212. // Headimg returns the value of the "headimg" field in the mutation.
  8213. func (m *ContactMutation) Headimg() (r string, exists bool) {
  8214. v := m.headimg
  8215. if v == nil {
  8216. return
  8217. }
  8218. return *v, true
  8219. }
  8220. // OldHeadimg returns the old "headimg" field's value of the Contact entity.
  8221. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8222. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8223. func (m *ContactMutation) OldHeadimg(ctx context.Context) (v string, err error) {
  8224. if !m.op.Is(OpUpdateOne) {
  8225. return v, errors.New("OldHeadimg is only allowed on UpdateOne operations")
  8226. }
  8227. if m.id == nil || m.oldValue == nil {
  8228. return v, errors.New("OldHeadimg requires an ID field in the mutation")
  8229. }
  8230. oldValue, err := m.oldValue(ctx)
  8231. if err != nil {
  8232. return v, fmt.Errorf("querying old value for OldHeadimg: %w", err)
  8233. }
  8234. return oldValue.Headimg, nil
  8235. }
  8236. // ResetHeadimg resets all changes to the "headimg" field.
  8237. func (m *ContactMutation) ResetHeadimg() {
  8238. m.headimg = nil
  8239. }
  8240. // SetSex sets the "sex" field.
  8241. func (m *ContactMutation) SetSex(i int) {
  8242. m.sex = &i
  8243. m.addsex = nil
  8244. }
  8245. // Sex returns the value of the "sex" field in the mutation.
  8246. func (m *ContactMutation) Sex() (r int, exists bool) {
  8247. v := m.sex
  8248. if v == nil {
  8249. return
  8250. }
  8251. return *v, true
  8252. }
  8253. // OldSex returns the old "sex" field's value of the Contact entity.
  8254. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8255. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8256. func (m *ContactMutation) OldSex(ctx context.Context) (v int, err error) {
  8257. if !m.op.Is(OpUpdateOne) {
  8258. return v, errors.New("OldSex is only allowed on UpdateOne operations")
  8259. }
  8260. if m.id == nil || m.oldValue == nil {
  8261. return v, errors.New("OldSex requires an ID field in the mutation")
  8262. }
  8263. oldValue, err := m.oldValue(ctx)
  8264. if err != nil {
  8265. return v, fmt.Errorf("querying old value for OldSex: %w", err)
  8266. }
  8267. return oldValue.Sex, nil
  8268. }
  8269. // AddSex adds i to the "sex" field.
  8270. func (m *ContactMutation) AddSex(i int) {
  8271. if m.addsex != nil {
  8272. *m.addsex += i
  8273. } else {
  8274. m.addsex = &i
  8275. }
  8276. }
  8277. // AddedSex returns the value that was added to the "sex" field in this mutation.
  8278. func (m *ContactMutation) AddedSex() (r int, exists bool) {
  8279. v := m.addsex
  8280. if v == nil {
  8281. return
  8282. }
  8283. return *v, true
  8284. }
  8285. // ResetSex resets all changes to the "sex" field.
  8286. func (m *ContactMutation) ResetSex() {
  8287. m.sex = nil
  8288. m.addsex = nil
  8289. }
  8290. // SetStarrole sets the "starrole" field.
  8291. func (m *ContactMutation) SetStarrole(s string) {
  8292. m.starrole = &s
  8293. }
  8294. // Starrole returns the value of the "starrole" field in the mutation.
  8295. func (m *ContactMutation) Starrole() (r string, exists bool) {
  8296. v := m.starrole
  8297. if v == nil {
  8298. return
  8299. }
  8300. return *v, true
  8301. }
  8302. // OldStarrole returns the old "starrole" field's value of the Contact entity.
  8303. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8304. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8305. func (m *ContactMutation) OldStarrole(ctx context.Context) (v string, err error) {
  8306. if !m.op.Is(OpUpdateOne) {
  8307. return v, errors.New("OldStarrole is only allowed on UpdateOne operations")
  8308. }
  8309. if m.id == nil || m.oldValue == nil {
  8310. return v, errors.New("OldStarrole requires an ID field in the mutation")
  8311. }
  8312. oldValue, err := m.oldValue(ctx)
  8313. if err != nil {
  8314. return v, fmt.Errorf("querying old value for OldStarrole: %w", err)
  8315. }
  8316. return oldValue.Starrole, nil
  8317. }
  8318. // ResetStarrole resets all changes to the "starrole" field.
  8319. func (m *ContactMutation) ResetStarrole() {
  8320. m.starrole = nil
  8321. }
  8322. // SetDontseeit sets the "dontseeit" field.
  8323. func (m *ContactMutation) SetDontseeit(i int) {
  8324. m.dontseeit = &i
  8325. m.adddontseeit = nil
  8326. }
  8327. // Dontseeit returns the value of the "dontseeit" field in the mutation.
  8328. func (m *ContactMutation) Dontseeit() (r int, exists bool) {
  8329. v := m.dontseeit
  8330. if v == nil {
  8331. return
  8332. }
  8333. return *v, true
  8334. }
  8335. // OldDontseeit returns the old "dontseeit" field's value of the Contact entity.
  8336. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8337. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8338. func (m *ContactMutation) OldDontseeit(ctx context.Context) (v int, err error) {
  8339. if !m.op.Is(OpUpdateOne) {
  8340. return v, errors.New("OldDontseeit is only allowed on UpdateOne operations")
  8341. }
  8342. if m.id == nil || m.oldValue == nil {
  8343. return v, errors.New("OldDontseeit requires an ID field in the mutation")
  8344. }
  8345. oldValue, err := m.oldValue(ctx)
  8346. if err != nil {
  8347. return v, fmt.Errorf("querying old value for OldDontseeit: %w", err)
  8348. }
  8349. return oldValue.Dontseeit, nil
  8350. }
  8351. // AddDontseeit adds i to the "dontseeit" field.
  8352. func (m *ContactMutation) AddDontseeit(i int) {
  8353. if m.adddontseeit != nil {
  8354. *m.adddontseeit += i
  8355. } else {
  8356. m.adddontseeit = &i
  8357. }
  8358. }
  8359. // AddedDontseeit returns the value that was added to the "dontseeit" field in this mutation.
  8360. func (m *ContactMutation) AddedDontseeit() (r int, exists bool) {
  8361. v := m.adddontseeit
  8362. if v == nil {
  8363. return
  8364. }
  8365. return *v, true
  8366. }
  8367. // ResetDontseeit resets all changes to the "dontseeit" field.
  8368. func (m *ContactMutation) ResetDontseeit() {
  8369. m.dontseeit = nil
  8370. m.adddontseeit = nil
  8371. }
  8372. // SetDontseeme sets the "dontseeme" field.
  8373. func (m *ContactMutation) SetDontseeme(i int) {
  8374. m.dontseeme = &i
  8375. m.adddontseeme = nil
  8376. }
  8377. // Dontseeme returns the value of the "dontseeme" field in the mutation.
  8378. func (m *ContactMutation) Dontseeme() (r int, exists bool) {
  8379. v := m.dontseeme
  8380. if v == nil {
  8381. return
  8382. }
  8383. return *v, true
  8384. }
  8385. // OldDontseeme returns the old "dontseeme" field's value of the Contact entity.
  8386. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8387. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8388. func (m *ContactMutation) OldDontseeme(ctx context.Context) (v int, err error) {
  8389. if !m.op.Is(OpUpdateOne) {
  8390. return v, errors.New("OldDontseeme is only allowed on UpdateOne operations")
  8391. }
  8392. if m.id == nil || m.oldValue == nil {
  8393. return v, errors.New("OldDontseeme requires an ID field in the mutation")
  8394. }
  8395. oldValue, err := m.oldValue(ctx)
  8396. if err != nil {
  8397. return v, fmt.Errorf("querying old value for OldDontseeme: %w", err)
  8398. }
  8399. return oldValue.Dontseeme, nil
  8400. }
  8401. // AddDontseeme adds i to the "dontseeme" field.
  8402. func (m *ContactMutation) AddDontseeme(i int) {
  8403. if m.adddontseeme != nil {
  8404. *m.adddontseeme += i
  8405. } else {
  8406. m.adddontseeme = &i
  8407. }
  8408. }
  8409. // AddedDontseeme returns the value that was added to the "dontseeme" field in this mutation.
  8410. func (m *ContactMutation) AddedDontseeme() (r int, exists bool) {
  8411. v := m.adddontseeme
  8412. if v == nil {
  8413. return
  8414. }
  8415. return *v, true
  8416. }
  8417. // ResetDontseeme resets all changes to the "dontseeme" field.
  8418. func (m *ContactMutation) ResetDontseeme() {
  8419. m.dontseeme = nil
  8420. m.adddontseeme = nil
  8421. }
  8422. // SetLag sets the "lag" field.
  8423. func (m *ContactMutation) SetLag(s string) {
  8424. m.lag = &s
  8425. }
  8426. // Lag returns the value of the "lag" field in the mutation.
  8427. func (m *ContactMutation) Lag() (r string, exists bool) {
  8428. v := m.lag
  8429. if v == nil {
  8430. return
  8431. }
  8432. return *v, true
  8433. }
  8434. // OldLag returns the old "lag" field's value of the Contact entity.
  8435. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8436. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8437. func (m *ContactMutation) OldLag(ctx context.Context) (v string, err error) {
  8438. if !m.op.Is(OpUpdateOne) {
  8439. return v, errors.New("OldLag is only allowed on UpdateOne operations")
  8440. }
  8441. if m.id == nil || m.oldValue == nil {
  8442. return v, errors.New("OldLag requires an ID field in the mutation")
  8443. }
  8444. oldValue, err := m.oldValue(ctx)
  8445. if err != nil {
  8446. return v, fmt.Errorf("querying old value for OldLag: %w", err)
  8447. }
  8448. return oldValue.Lag, nil
  8449. }
  8450. // ResetLag resets all changes to the "lag" field.
  8451. func (m *ContactMutation) ResetLag() {
  8452. m.lag = nil
  8453. }
  8454. // SetGid sets the "gid" field.
  8455. func (m *ContactMutation) SetGid(s string) {
  8456. m.gid = &s
  8457. }
  8458. // Gid returns the value of the "gid" field in the mutation.
  8459. func (m *ContactMutation) Gid() (r string, exists bool) {
  8460. v := m.gid
  8461. if v == nil {
  8462. return
  8463. }
  8464. return *v, true
  8465. }
  8466. // OldGid returns the old "gid" field's value of the Contact entity.
  8467. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8468. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8469. func (m *ContactMutation) OldGid(ctx context.Context) (v string, err error) {
  8470. if !m.op.Is(OpUpdateOne) {
  8471. return v, errors.New("OldGid is only allowed on UpdateOne operations")
  8472. }
  8473. if m.id == nil || m.oldValue == nil {
  8474. return v, errors.New("OldGid requires an ID field in the mutation")
  8475. }
  8476. oldValue, err := m.oldValue(ctx)
  8477. if err != nil {
  8478. return v, fmt.Errorf("querying old value for OldGid: %w", err)
  8479. }
  8480. return oldValue.Gid, nil
  8481. }
  8482. // ResetGid resets all changes to the "gid" field.
  8483. func (m *ContactMutation) ResetGid() {
  8484. m.gid = nil
  8485. }
  8486. // SetGname sets the "gname" field.
  8487. func (m *ContactMutation) SetGname(s string) {
  8488. m.gname = &s
  8489. }
  8490. // Gname returns the value of the "gname" field in the mutation.
  8491. func (m *ContactMutation) Gname() (r string, exists bool) {
  8492. v := m.gname
  8493. if v == nil {
  8494. return
  8495. }
  8496. return *v, true
  8497. }
  8498. // OldGname returns the old "gname" field's value of the Contact entity.
  8499. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8500. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8501. func (m *ContactMutation) OldGname(ctx context.Context) (v string, err error) {
  8502. if !m.op.Is(OpUpdateOne) {
  8503. return v, errors.New("OldGname is only allowed on UpdateOne operations")
  8504. }
  8505. if m.id == nil || m.oldValue == nil {
  8506. return v, errors.New("OldGname requires an ID field in the mutation")
  8507. }
  8508. oldValue, err := m.oldValue(ctx)
  8509. if err != nil {
  8510. return v, fmt.Errorf("querying old value for OldGname: %w", err)
  8511. }
  8512. return oldValue.Gname, nil
  8513. }
  8514. // ResetGname resets all changes to the "gname" field.
  8515. func (m *ContactMutation) ResetGname() {
  8516. m.gname = nil
  8517. }
  8518. // SetV3 sets the "v3" field.
  8519. func (m *ContactMutation) SetV3(s string) {
  8520. m.v3 = &s
  8521. }
  8522. // V3 returns the value of the "v3" field in the mutation.
  8523. func (m *ContactMutation) V3() (r string, exists bool) {
  8524. v := m.v3
  8525. if v == nil {
  8526. return
  8527. }
  8528. return *v, true
  8529. }
  8530. // OldV3 returns the old "v3" field's value of the Contact entity.
  8531. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8532. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8533. func (m *ContactMutation) OldV3(ctx context.Context) (v string, err error) {
  8534. if !m.op.Is(OpUpdateOne) {
  8535. return v, errors.New("OldV3 is only allowed on UpdateOne operations")
  8536. }
  8537. if m.id == nil || m.oldValue == nil {
  8538. return v, errors.New("OldV3 requires an ID field in the mutation")
  8539. }
  8540. oldValue, err := m.oldValue(ctx)
  8541. if err != nil {
  8542. return v, fmt.Errorf("querying old value for OldV3: %w", err)
  8543. }
  8544. return oldValue.V3, nil
  8545. }
  8546. // ResetV3 resets all changes to the "v3" field.
  8547. func (m *ContactMutation) ResetV3() {
  8548. m.v3 = nil
  8549. }
  8550. // SetOrganizationID sets the "organization_id" field.
  8551. func (m *ContactMutation) SetOrganizationID(u uint64) {
  8552. m.organization_id = &u
  8553. m.addorganization_id = nil
  8554. }
  8555. // OrganizationID returns the value of the "organization_id" field in the mutation.
  8556. func (m *ContactMutation) OrganizationID() (r uint64, exists bool) {
  8557. v := m.organization_id
  8558. if v == nil {
  8559. return
  8560. }
  8561. return *v, true
  8562. }
  8563. // OldOrganizationID returns the old "organization_id" field's value of the Contact entity.
  8564. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8565. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8566. func (m *ContactMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  8567. if !m.op.Is(OpUpdateOne) {
  8568. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  8569. }
  8570. if m.id == nil || m.oldValue == nil {
  8571. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  8572. }
  8573. oldValue, err := m.oldValue(ctx)
  8574. if err != nil {
  8575. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  8576. }
  8577. return oldValue.OrganizationID, nil
  8578. }
  8579. // AddOrganizationID adds u to the "organization_id" field.
  8580. func (m *ContactMutation) AddOrganizationID(u int64) {
  8581. if m.addorganization_id != nil {
  8582. *m.addorganization_id += u
  8583. } else {
  8584. m.addorganization_id = &u
  8585. }
  8586. }
  8587. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  8588. func (m *ContactMutation) AddedOrganizationID() (r int64, exists bool) {
  8589. v := m.addorganization_id
  8590. if v == nil {
  8591. return
  8592. }
  8593. return *v, true
  8594. }
  8595. // ClearOrganizationID clears the value of the "organization_id" field.
  8596. func (m *ContactMutation) ClearOrganizationID() {
  8597. m.organization_id = nil
  8598. m.addorganization_id = nil
  8599. m.clearedFields[contact.FieldOrganizationID] = struct{}{}
  8600. }
  8601. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  8602. func (m *ContactMutation) OrganizationIDCleared() bool {
  8603. _, ok := m.clearedFields[contact.FieldOrganizationID]
  8604. return ok
  8605. }
  8606. // ResetOrganizationID resets all changes to the "organization_id" field.
  8607. func (m *ContactMutation) ResetOrganizationID() {
  8608. m.organization_id = nil
  8609. m.addorganization_id = nil
  8610. delete(m.clearedFields, contact.FieldOrganizationID)
  8611. }
  8612. // AddContactRelationshipIDs adds the "contact_relationships" edge to the LabelRelationship entity by ids.
  8613. func (m *ContactMutation) AddContactRelationshipIDs(ids ...uint64) {
  8614. if m.contact_relationships == nil {
  8615. m.contact_relationships = make(map[uint64]struct{})
  8616. }
  8617. for i := range ids {
  8618. m.contact_relationships[ids[i]] = struct{}{}
  8619. }
  8620. }
  8621. // ClearContactRelationships clears the "contact_relationships" edge to the LabelRelationship entity.
  8622. func (m *ContactMutation) ClearContactRelationships() {
  8623. m.clearedcontact_relationships = true
  8624. }
  8625. // ContactRelationshipsCleared reports if the "contact_relationships" edge to the LabelRelationship entity was cleared.
  8626. func (m *ContactMutation) ContactRelationshipsCleared() bool {
  8627. return m.clearedcontact_relationships
  8628. }
  8629. // RemoveContactRelationshipIDs removes the "contact_relationships" edge to the LabelRelationship entity by IDs.
  8630. func (m *ContactMutation) RemoveContactRelationshipIDs(ids ...uint64) {
  8631. if m.removedcontact_relationships == nil {
  8632. m.removedcontact_relationships = make(map[uint64]struct{})
  8633. }
  8634. for i := range ids {
  8635. delete(m.contact_relationships, ids[i])
  8636. m.removedcontact_relationships[ids[i]] = struct{}{}
  8637. }
  8638. }
  8639. // RemovedContactRelationships returns the removed IDs of the "contact_relationships" edge to the LabelRelationship entity.
  8640. func (m *ContactMutation) RemovedContactRelationshipsIDs() (ids []uint64) {
  8641. for id := range m.removedcontact_relationships {
  8642. ids = append(ids, id)
  8643. }
  8644. return
  8645. }
  8646. // ContactRelationshipsIDs returns the "contact_relationships" edge IDs in the mutation.
  8647. func (m *ContactMutation) ContactRelationshipsIDs() (ids []uint64) {
  8648. for id := range m.contact_relationships {
  8649. ids = append(ids, id)
  8650. }
  8651. return
  8652. }
  8653. // ResetContactRelationships resets all changes to the "contact_relationships" edge.
  8654. func (m *ContactMutation) ResetContactRelationships() {
  8655. m.contact_relationships = nil
  8656. m.clearedcontact_relationships = false
  8657. m.removedcontact_relationships = nil
  8658. }
  8659. // AddContactMessageIDs adds the "contact_messages" edge to the MessageRecords entity by ids.
  8660. func (m *ContactMutation) AddContactMessageIDs(ids ...uint64) {
  8661. if m.contact_messages == nil {
  8662. m.contact_messages = make(map[uint64]struct{})
  8663. }
  8664. for i := range ids {
  8665. m.contact_messages[ids[i]] = struct{}{}
  8666. }
  8667. }
  8668. // ClearContactMessages clears the "contact_messages" edge to the MessageRecords entity.
  8669. func (m *ContactMutation) ClearContactMessages() {
  8670. m.clearedcontact_messages = true
  8671. }
  8672. // ContactMessagesCleared reports if the "contact_messages" edge to the MessageRecords entity was cleared.
  8673. func (m *ContactMutation) ContactMessagesCleared() bool {
  8674. return m.clearedcontact_messages
  8675. }
  8676. // RemoveContactMessageIDs removes the "contact_messages" edge to the MessageRecords entity by IDs.
  8677. func (m *ContactMutation) RemoveContactMessageIDs(ids ...uint64) {
  8678. if m.removedcontact_messages == nil {
  8679. m.removedcontact_messages = make(map[uint64]struct{})
  8680. }
  8681. for i := range ids {
  8682. delete(m.contact_messages, ids[i])
  8683. m.removedcontact_messages[ids[i]] = struct{}{}
  8684. }
  8685. }
  8686. // RemovedContactMessages returns the removed IDs of the "contact_messages" edge to the MessageRecords entity.
  8687. func (m *ContactMutation) RemovedContactMessagesIDs() (ids []uint64) {
  8688. for id := range m.removedcontact_messages {
  8689. ids = append(ids, id)
  8690. }
  8691. return
  8692. }
  8693. // ContactMessagesIDs returns the "contact_messages" edge IDs in the mutation.
  8694. func (m *ContactMutation) ContactMessagesIDs() (ids []uint64) {
  8695. for id := range m.contact_messages {
  8696. ids = append(ids, id)
  8697. }
  8698. return
  8699. }
  8700. // ResetContactMessages resets all changes to the "contact_messages" edge.
  8701. func (m *ContactMutation) ResetContactMessages() {
  8702. m.contact_messages = nil
  8703. m.clearedcontact_messages = false
  8704. m.removedcontact_messages = nil
  8705. }
  8706. // Where appends a list predicates to the ContactMutation builder.
  8707. func (m *ContactMutation) Where(ps ...predicate.Contact) {
  8708. m.predicates = append(m.predicates, ps...)
  8709. }
  8710. // WhereP appends storage-level predicates to the ContactMutation builder. Using this method,
  8711. // users can use type-assertion to append predicates that do not depend on any generated package.
  8712. func (m *ContactMutation) WhereP(ps ...func(*sql.Selector)) {
  8713. p := make([]predicate.Contact, len(ps))
  8714. for i := range ps {
  8715. p[i] = ps[i]
  8716. }
  8717. m.Where(p...)
  8718. }
  8719. // Op returns the operation name.
  8720. func (m *ContactMutation) Op() Op {
  8721. return m.op
  8722. }
  8723. // SetOp allows setting the mutation operation.
  8724. func (m *ContactMutation) SetOp(op Op) {
  8725. m.op = op
  8726. }
  8727. // Type returns the node type of this mutation (Contact).
  8728. func (m *ContactMutation) Type() string {
  8729. return m.typ
  8730. }
  8731. // Fields returns all fields that were changed during this mutation. Note that in
  8732. // order to get all numeric fields that were incremented/decremented, call
  8733. // AddedFields().
  8734. func (m *ContactMutation) Fields() []string {
  8735. fields := make([]string, 0, 20)
  8736. if m.created_at != nil {
  8737. fields = append(fields, contact.FieldCreatedAt)
  8738. }
  8739. if m.updated_at != nil {
  8740. fields = append(fields, contact.FieldUpdatedAt)
  8741. }
  8742. if m.status != nil {
  8743. fields = append(fields, contact.FieldStatus)
  8744. }
  8745. if m.deleted_at != nil {
  8746. fields = append(fields, contact.FieldDeletedAt)
  8747. }
  8748. if m.wx_wxid != nil {
  8749. fields = append(fields, contact.FieldWxWxid)
  8750. }
  8751. if m._type != nil {
  8752. fields = append(fields, contact.FieldType)
  8753. }
  8754. if m.wxid != nil {
  8755. fields = append(fields, contact.FieldWxid)
  8756. }
  8757. if m.account != nil {
  8758. fields = append(fields, contact.FieldAccount)
  8759. }
  8760. if m.nickname != nil {
  8761. fields = append(fields, contact.FieldNickname)
  8762. }
  8763. if m.markname != nil {
  8764. fields = append(fields, contact.FieldMarkname)
  8765. }
  8766. if m.headimg != nil {
  8767. fields = append(fields, contact.FieldHeadimg)
  8768. }
  8769. if m.sex != nil {
  8770. fields = append(fields, contact.FieldSex)
  8771. }
  8772. if m.starrole != nil {
  8773. fields = append(fields, contact.FieldStarrole)
  8774. }
  8775. if m.dontseeit != nil {
  8776. fields = append(fields, contact.FieldDontseeit)
  8777. }
  8778. if m.dontseeme != nil {
  8779. fields = append(fields, contact.FieldDontseeme)
  8780. }
  8781. if m.lag != nil {
  8782. fields = append(fields, contact.FieldLag)
  8783. }
  8784. if m.gid != nil {
  8785. fields = append(fields, contact.FieldGid)
  8786. }
  8787. if m.gname != nil {
  8788. fields = append(fields, contact.FieldGname)
  8789. }
  8790. if m.v3 != nil {
  8791. fields = append(fields, contact.FieldV3)
  8792. }
  8793. if m.organization_id != nil {
  8794. fields = append(fields, contact.FieldOrganizationID)
  8795. }
  8796. return fields
  8797. }
  8798. // Field returns the value of a field with the given name. The second boolean
  8799. // return value indicates that this field was not set, or was not defined in the
  8800. // schema.
  8801. func (m *ContactMutation) Field(name string) (ent.Value, bool) {
  8802. switch name {
  8803. case contact.FieldCreatedAt:
  8804. return m.CreatedAt()
  8805. case contact.FieldUpdatedAt:
  8806. return m.UpdatedAt()
  8807. case contact.FieldStatus:
  8808. return m.Status()
  8809. case contact.FieldDeletedAt:
  8810. return m.DeletedAt()
  8811. case contact.FieldWxWxid:
  8812. return m.WxWxid()
  8813. case contact.FieldType:
  8814. return m.GetType()
  8815. case contact.FieldWxid:
  8816. return m.Wxid()
  8817. case contact.FieldAccount:
  8818. return m.Account()
  8819. case contact.FieldNickname:
  8820. return m.Nickname()
  8821. case contact.FieldMarkname:
  8822. return m.Markname()
  8823. case contact.FieldHeadimg:
  8824. return m.Headimg()
  8825. case contact.FieldSex:
  8826. return m.Sex()
  8827. case contact.FieldStarrole:
  8828. return m.Starrole()
  8829. case contact.FieldDontseeit:
  8830. return m.Dontseeit()
  8831. case contact.FieldDontseeme:
  8832. return m.Dontseeme()
  8833. case contact.FieldLag:
  8834. return m.Lag()
  8835. case contact.FieldGid:
  8836. return m.Gid()
  8837. case contact.FieldGname:
  8838. return m.Gname()
  8839. case contact.FieldV3:
  8840. return m.V3()
  8841. case contact.FieldOrganizationID:
  8842. return m.OrganizationID()
  8843. }
  8844. return nil, false
  8845. }
  8846. // OldField returns the old value of the field from the database. An error is
  8847. // returned if the mutation operation is not UpdateOne, or the query to the
  8848. // database failed.
  8849. func (m *ContactMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  8850. switch name {
  8851. case contact.FieldCreatedAt:
  8852. return m.OldCreatedAt(ctx)
  8853. case contact.FieldUpdatedAt:
  8854. return m.OldUpdatedAt(ctx)
  8855. case contact.FieldStatus:
  8856. return m.OldStatus(ctx)
  8857. case contact.FieldDeletedAt:
  8858. return m.OldDeletedAt(ctx)
  8859. case contact.FieldWxWxid:
  8860. return m.OldWxWxid(ctx)
  8861. case contact.FieldType:
  8862. return m.OldType(ctx)
  8863. case contact.FieldWxid:
  8864. return m.OldWxid(ctx)
  8865. case contact.FieldAccount:
  8866. return m.OldAccount(ctx)
  8867. case contact.FieldNickname:
  8868. return m.OldNickname(ctx)
  8869. case contact.FieldMarkname:
  8870. return m.OldMarkname(ctx)
  8871. case contact.FieldHeadimg:
  8872. return m.OldHeadimg(ctx)
  8873. case contact.FieldSex:
  8874. return m.OldSex(ctx)
  8875. case contact.FieldStarrole:
  8876. return m.OldStarrole(ctx)
  8877. case contact.FieldDontseeit:
  8878. return m.OldDontseeit(ctx)
  8879. case contact.FieldDontseeme:
  8880. return m.OldDontseeme(ctx)
  8881. case contact.FieldLag:
  8882. return m.OldLag(ctx)
  8883. case contact.FieldGid:
  8884. return m.OldGid(ctx)
  8885. case contact.FieldGname:
  8886. return m.OldGname(ctx)
  8887. case contact.FieldV3:
  8888. return m.OldV3(ctx)
  8889. case contact.FieldOrganizationID:
  8890. return m.OldOrganizationID(ctx)
  8891. }
  8892. return nil, fmt.Errorf("unknown Contact field %s", name)
  8893. }
  8894. // SetField sets the value of a field with the given name. It returns an error if
  8895. // the field is not defined in the schema, or if the type mismatched the field
  8896. // type.
  8897. func (m *ContactMutation) SetField(name string, value ent.Value) error {
  8898. switch name {
  8899. case contact.FieldCreatedAt:
  8900. v, ok := value.(time.Time)
  8901. if !ok {
  8902. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8903. }
  8904. m.SetCreatedAt(v)
  8905. return nil
  8906. case contact.FieldUpdatedAt:
  8907. v, ok := value.(time.Time)
  8908. if !ok {
  8909. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8910. }
  8911. m.SetUpdatedAt(v)
  8912. return nil
  8913. case contact.FieldStatus:
  8914. v, ok := value.(uint8)
  8915. if !ok {
  8916. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8917. }
  8918. m.SetStatus(v)
  8919. return nil
  8920. case contact.FieldDeletedAt:
  8921. v, ok := value.(time.Time)
  8922. if !ok {
  8923. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8924. }
  8925. m.SetDeletedAt(v)
  8926. return nil
  8927. case contact.FieldWxWxid:
  8928. v, ok := value.(string)
  8929. if !ok {
  8930. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8931. }
  8932. m.SetWxWxid(v)
  8933. return nil
  8934. case contact.FieldType:
  8935. v, ok := value.(int)
  8936. if !ok {
  8937. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8938. }
  8939. m.SetType(v)
  8940. return nil
  8941. case contact.FieldWxid:
  8942. v, ok := value.(string)
  8943. if !ok {
  8944. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8945. }
  8946. m.SetWxid(v)
  8947. return nil
  8948. case contact.FieldAccount:
  8949. v, ok := value.(string)
  8950. if !ok {
  8951. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8952. }
  8953. m.SetAccount(v)
  8954. return nil
  8955. case contact.FieldNickname:
  8956. v, ok := value.(string)
  8957. if !ok {
  8958. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8959. }
  8960. m.SetNickname(v)
  8961. return nil
  8962. case contact.FieldMarkname:
  8963. v, ok := value.(string)
  8964. if !ok {
  8965. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8966. }
  8967. m.SetMarkname(v)
  8968. return nil
  8969. case contact.FieldHeadimg:
  8970. v, ok := value.(string)
  8971. if !ok {
  8972. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8973. }
  8974. m.SetHeadimg(v)
  8975. return nil
  8976. case contact.FieldSex:
  8977. v, ok := value.(int)
  8978. if !ok {
  8979. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8980. }
  8981. m.SetSex(v)
  8982. return nil
  8983. case contact.FieldStarrole:
  8984. v, ok := value.(string)
  8985. if !ok {
  8986. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8987. }
  8988. m.SetStarrole(v)
  8989. return nil
  8990. case contact.FieldDontseeit:
  8991. v, ok := value.(int)
  8992. if !ok {
  8993. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8994. }
  8995. m.SetDontseeit(v)
  8996. return nil
  8997. case contact.FieldDontseeme:
  8998. v, ok := value.(int)
  8999. if !ok {
  9000. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9001. }
  9002. m.SetDontseeme(v)
  9003. return nil
  9004. case contact.FieldLag:
  9005. v, ok := value.(string)
  9006. if !ok {
  9007. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9008. }
  9009. m.SetLag(v)
  9010. return nil
  9011. case contact.FieldGid:
  9012. v, ok := value.(string)
  9013. if !ok {
  9014. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9015. }
  9016. m.SetGid(v)
  9017. return nil
  9018. case contact.FieldGname:
  9019. v, ok := value.(string)
  9020. if !ok {
  9021. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9022. }
  9023. m.SetGname(v)
  9024. return nil
  9025. case contact.FieldV3:
  9026. v, ok := value.(string)
  9027. if !ok {
  9028. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9029. }
  9030. m.SetV3(v)
  9031. return nil
  9032. case contact.FieldOrganizationID:
  9033. v, ok := value.(uint64)
  9034. if !ok {
  9035. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9036. }
  9037. m.SetOrganizationID(v)
  9038. return nil
  9039. }
  9040. return fmt.Errorf("unknown Contact field %s", name)
  9041. }
  9042. // AddedFields returns all numeric fields that were incremented/decremented during
  9043. // this mutation.
  9044. func (m *ContactMutation) AddedFields() []string {
  9045. var fields []string
  9046. if m.addstatus != nil {
  9047. fields = append(fields, contact.FieldStatus)
  9048. }
  9049. if m.add_type != nil {
  9050. fields = append(fields, contact.FieldType)
  9051. }
  9052. if m.addsex != nil {
  9053. fields = append(fields, contact.FieldSex)
  9054. }
  9055. if m.adddontseeit != nil {
  9056. fields = append(fields, contact.FieldDontseeit)
  9057. }
  9058. if m.adddontseeme != nil {
  9059. fields = append(fields, contact.FieldDontseeme)
  9060. }
  9061. if m.addorganization_id != nil {
  9062. fields = append(fields, contact.FieldOrganizationID)
  9063. }
  9064. return fields
  9065. }
  9066. // AddedField returns the numeric value that was incremented/decremented on a field
  9067. // with the given name. The second boolean return value indicates that this field
  9068. // was not set, or was not defined in the schema.
  9069. func (m *ContactMutation) AddedField(name string) (ent.Value, bool) {
  9070. switch name {
  9071. case contact.FieldStatus:
  9072. return m.AddedStatus()
  9073. case contact.FieldType:
  9074. return m.AddedType()
  9075. case contact.FieldSex:
  9076. return m.AddedSex()
  9077. case contact.FieldDontseeit:
  9078. return m.AddedDontseeit()
  9079. case contact.FieldDontseeme:
  9080. return m.AddedDontseeme()
  9081. case contact.FieldOrganizationID:
  9082. return m.AddedOrganizationID()
  9083. }
  9084. return nil, false
  9085. }
  9086. // AddField adds the value to the field with the given name. It returns an error if
  9087. // the field is not defined in the schema, or if the type mismatched the field
  9088. // type.
  9089. func (m *ContactMutation) AddField(name string, value ent.Value) error {
  9090. switch name {
  9091. case contact.FieldStatus:
  9092. v, ok := value.(int8)
  9093. if !ok {
  9094. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9095. }
  9096. m.AddStatus(v)
  9097. return nil
  9098. case contact.FieldType:
  9099. v, ok := value.(int)
  9100. if !ok {
  9101. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9102. }
  9103. m.AddType(v)
  9104. return nil
  9105. case contact.FieldSex:
  9106. v, ok := value.(int)
  9107. if !ok {
  9108. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9109. }
  9110. m.AddSex(v)
  9111. return nil
  9112. case contact.FieldDontseeit:
  9113. v, ok := value.(int)
  9114. if !ok {
  9115. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9116. }
  9117. m.AddDontseeit(v)
  9118. return nil
  9119. case contact.FieldDontseeme:
  9120. v, ok := value.(int)
  9121. if !ok {
  9122. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9123. }
  9124. m.AddDontseeme(v)
  9125. return nil
  9126. case contact.FieldOrganizationID:
  9127. v, ok := value.(int64)
  9128. if !ok {
  9129. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9130. }
  9131. m.AddOrganizationID(v)
  9132. return nil
  9133. }
  9134. return fmt.Errorf("unknown Contact numeric field %s", name)
  9135. }
  9136. // ClearedFields returns all nullable fields that were cleared during this
  9137. // mutation.
  9138. func (m *ContactMutation) ClearedFields() []string {
  9139. var fields []string
  9140. if m.FieldCleared(contact.FieldStatus) {
  9141. fields = append(fields, contact.FieldStatus)
  9142. }
  9143. if m.FieldCleared(contact.FieldDeletedAt) {
  9144. fields = append(fields, contact.FieldDeletedAt)
  9145. }
  9146. if m.FieldCleared(contact.FieldType) {
  9147. fields = append(fields, contact.FieldType)
  9148. }
  9149. if m.FieldCleared(contact.FieldOrganizationID) {
  9150. fields = append(fields, contact.FieldOrganizationID)
  9151. }
  9152. return fields
  9153. }
  9154. // FieldCleared returns a boolean indicating if a field with the given name was
  9155. // cleared in this mutation.
  9156. func (m *ContactMutation) FieldCleared(name string) bool {
  9157. _, ok := m.clearedFields[name]
  9158. return ok
  9159. }
  9160. // ClearField clears the value of the field with the given name. It returns an
  9161. // error if the field is not defined in the schema.
  9162. func (m *ContactMutation) ClearField(name string) error {
  9163. switch name {
  9164. case contact.FieldStatus:
  9165. m.ClearStatus()
  9166. return nil
  9167. case contact.FieldDeletedAt:
  9168. m.ClearDeletedAt()
  9169. return nil
  9170. case contact.FieldType:
  9171. m.ClearType()
  9172. return nil
  9173. case contact.FieldOrganizationID:
  9174. m.ClearOrganizationID()
  9175. return nil
  9176. }
  9177. return fmt.Errorf("unknown Contact nullable field %s", name)
  9178. }
  9179. // ResetField resets all changes in the mutation for the field with the given name.
  9180. // It returns an error if the field is not defined in the schema.
  9181. func (m *ContactMutation) ResetField(name string) error {
  9182. switch name {
  9183. case contact.FieldCreatedAt:
  9184. m.ResetCreatedAt()
  9185. return nil
  9186. case contact.FieldUpdatedAt:
  9187. m.ResetUpdatedAt()
  9188. return nil
  9189. case contact.FieldStatus:
  9190. m.ResetStatus()
  9191. return nil
  9192. case contact.FieldDeletedAt:
  9193. m.ResetDeletedAt()
  9194. return nil
  9195. case contact.FieldWxWxid:
  9196. m.ResetWxWxid()
  9197. return nil
  9198. case contact.FieldType:
  9199. m.ResetType()
  9200. return nil
  9201. case contact.FieldWxid:
  9202. m.ResetWxid()
  9203. return nil
  9204. case contact.FieldAccount:
  9205. m.ResetAccount()
  9206. return nil
  9207. case contact.FieldNickname:
  9208. m.ResetNickname()
  9209. return nil
  9210. case contact.FieldMarkname:
  9211. m.ResetMarkname()
  9212. return nil
  9213. case contact.FieldHeadimg:
  9214. m.ResetHeadimg()
  9215. return nil
  9216. case contact.FieldSex:
  9217. m.ResetSex()
  9218. return nil
  9219. case contact.FieldStarrole:
  9220. m.ResetStarrole()
  9221. return nil
  9222. case contact.FieldDontseeit:
  9223. m.ResetDontseeit()
  9224. return nil
  9225. case contact.FieldDontseeme:
  9226. m.ResetDontseeme()
  9227. return nil
  9228. case contact.FieldLag:
  9229. m.ResetLag()
  9230. return nil
  9231. case contact.FieldGid:
  9232. m.ResetGid()
  9233. return nil
  9234. case contact.FieldGname:
  9235. m.ResetGname()
  9236. return nil
  9237. case contact.FieldV3:
  9238. m.ResetV3()
  9239. return nil
  9240. case contact.FieldOrganizationID:
  9241. m.ResetOrganizationID()
  9242. return nil
  9243. }
  9244. return fmt.Errorf("unknown Contact field %s", name)
  9245. }
  9246. // AddedEdges returns all edge names that were set/added in this mutation.
  9247. func (m *ContactMutation) AddedEdges() []string {
  9248. edges := make([]string, 0, 2)
  9249. if m.contact_relationships != nil {
  9250. edges = append(edges, contact.EdgeContactRelationships)
  9251. }
  9252. if m.contact_messages != nil {
  9253. edges = append(edges, contact.EdgeContactMessages)
  9254. }
  9255. return edges
  9256. }
  9257. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  9258. // name in this mutation.
  9259. func (m *ContactMutation) AddedIDs(name string) []ent.Value {
  9260. switch name {
  9261. case contact.EdgeContactRelationships:
  9262. ids := make([]ent.Value, 0, len(m.contact_relationships))
  9263. for id := range m.contact_relationships {
  9264. ids = append(ids, id)
  9265. }
  9266. return ids
  9267. case contact.EdgeContactMessages:
  9268. ids := make([]ent.Value, 0, len(m.contact_messages))
  9269. for id := range m.contact_messages {
  9270. ids = append(ids, id)
  9271. }
  9272. return ids
  9273. }
  9274. return nil
  9275. }
  9276. // RemovedEdges returns all edge names that were removed in this mutation.
  9277. func (m *ContactMutation) RemovedEdges() []string {
  9278. edges := make([]string, 0, 2)
  9279. if m.removedcontact_relationships != nil {
  9280. edges = append(edges, contact.EdgeContactRelationships)
  9281. }
  9282. if m.removedcontact_messages != nil {
  9283. edges = append(edges, contact.EdgeContactMessages)
  9284. }
  9285. return edges
  9286. }
  9287. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  9288. // the given name in this mutation.
  9289. func (m *ContactMutation) RemovedIDs(name string) []ent.Value {
  9290. switch name {
  9291. case contact.EdgeContactRelationships:
  9292. ids := make([]ent.Value, 0, len(m.removedcontact_relationships))
  9293. for id := range m.removedcontact_relationships {
  9294. ids = append(ids, id)
  9295. }
  9296. return ids
  9297. case contact.EdgeContactMessages:
  9298. ids := make([]ent.Value, 0, len(m.removedcontact_messages))
  9299. for id := range m.removedcontact_messages {
  9300. ids = append(ids, id)
  9301. }
  9302. return ids
  9303. }
  9304. return nil
  9305. }
  9306. // ClearedEdges returns all edge names that were cleared in this mutation.
  9307. func (m *ContactMutation) ClearedEdges() []string {
  9308. edges := make([]string, 0, 2)
  9309. if m.clearedcontact_relationships {
  9310. edges = append(edges, contact.EdgeContactRelationships)
  9311. }
  9312. if m.clearedcontact_messages {
  9313. edges = append(edges, contact.EdgeContactMessages)
  9314. }
  9315. return edges
  9316. }
  9317. // EdgeCleared returns a boolean which indicates if the edge with the given name
  9318. // was cleared in this mutation.
  9319. func (m *ContactMutation) EdgeCleared(name string) bool {
  9320. switch name {
  9321. case contact.EdgeContactRelationships:
  9322. return m.clearedcontact_relationships
  9323. case contact.EdgeContactMessages:
  9324. return m.clearedcontact_messages
  9325. }
  9326. return false
  9327. }
  9328. // ClearEdge clears the value of the edge with the given name. It returns an error
  9329. // if that edge is not defined in the schema.
  9330. func (m *ContactMutation) ClearEdge(name string) error {
  9331. switch name {
  9332. }
  9333. return fmt.Errorf("unknown Contact unique edge %s", name)
  9334. }
  9335. // ResetEdge resets all changes to the edge with the given name in this mutation.
  9336. // It returns an error if the edge is not defined in the schema.
  9337. func (m *ContactMutation) ResetEdge(name string) error {
  9338. switch name {
  9339. case contact.EdgeContactRelationships:
  9340. m.ResetContactRelationships()
  9341. return nil
  9342. case contact.EdgeContactMessages:
  9343. m.ResetContactMessages()
  9344. return nil
  9345. }
  9346. return fmt.Errorf("unknown Contact edge %s", name)
  9347. }
  9348. // CreditBalanceMutation represents an operation that mutates the CreditBalance nodes in the graph.
  9349. type CreditBalanceMutation struct {
  9350. config
  9351. op Op
  9352. typ string
  9353. id *uint64
  9354. created_at *time.Time
  9355. updated_at *time.Time
  9356. deleted_at *time.Time
  9357. user_id *string
  9358. balance *float32
  9359. addbalance *float32
  9360. status *int
  9361. addstatus *int
  9362. organization_id *uint64
  9363. addorganization_id *int64
  9364. clearedFields map[string]struct{}
  9365. done bool
  9366. oldValue func(context.Context) (*CreditBalance, error)
  9367. predicates []predicate.CreditBalance
  9368. }
  9369. var _ ent.Mutation = (*CreditBalanceMutation)(nil)
  9370. // creditbalanceOption allows management of the mutation configuration using functional options.
  9371. type creditbalanceOption func(*CreditBalanceMutation)
  9372. // newCreditBalanceMutation creates new mutation for the CreditBalance entity.
  9373. func newCreditBalanceMutation(c config, op Op, opts ...creditbalanceOption) *CreditBalanceMutation {
  9374. m := &CreditBalanceMutation{
  9375. config: c,
  9376. op: op,
  9377. typ: TypeCreditBalance,
  9378. clearedFields: make(map[string]struct{}),
  9379. }
  9380. for _, opt := range opts {
  9381. opt(m)
  9382. }
  9383. return m
  9384. }
  9385. // withCreditBalanceID sets the ID field of the mutation.
  9386. func withCreditBalanceID(id uint64) creditbalanceOption {
  9387. return func(m *CreditBalanceMutation) {
  9388. var (
  9389. err error
  9390. once sync.Once
  9391. value *CreditBalance
  9392. )
  9393. m.oldValue = func(ctx context.Context) (*CreditBalance, error) {
  9394. once.Do(func() {
  9395. if m.done {
  9396. err = errors.New("querying old values post mutation is not allowed")
  9397. } else {
  9398. value, err = m.Client().CreditBalance.Get(ctx, id)
  9399. }
  9400. })
  9401. return value, err
  9402. }
  9403. m.id = &id
  9404. }
  9405. }
  9406. // withCreditBalance sets the old CreditBalance of the mutation.
  9407. func withCreditBalance(node *CreditBalance) creditbalanceOption {
  9408. return func(m *CreditBalanceMutation) {
  9409. m.oldValue = func(context.Context) (*CreditBalance, error) {
  9410. return node, nil
  9411. }
  9412. m.id = &node.ID
  9413. }
  9414. }
  9415. // Client returns a new `ent.Client` from the mutation. If the mutation was
  9416. // executed in a transaction (ent.Tx), a transactional client is returned.
  9417. func (m CreditBalanceMutation) Client() *Client {
  9418. client := &Client{config: m.config}
  9419. client.init()
  9420. return client
  9421. }
  9422. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  9423. // it returns an error otherwise.
  9424. func (m CreditBalanceMutation) Tx() (*Tx, error) {
  9425. if _, ok := m.driver.(*txDriver); !ok {
  9426. return nil, errors.New("ent: mutation is not running in a transaction")
  9427. }
  9428. tx := &Tx{config: m.config}
  9429. tx.init()
  9430. return tx, nil
  9431. }
  9432. // SetID sets the value of the id field. Note that this
  9433. // operation is only accepted on creation of CreditBalance entities.
  9434. func (m *CreditBalanceMutation) SetID(id uint64) {
  9435. m.id = &id
  9436. }
  9437. // ID returns the ID value in the mutation. Note that the ID is only available
  9438. // if it was provided to the builder or after it was returned from the database.
  9439. func (m *CreditBalanceMutation) ID() (id uint64, exists bool) {
  9440. if m.id == nil {
  9441. return
  9442. }
  9443. return *m.id, true
  9444. }
  9445. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  9446. // That means, if the mutation is applied within a transaction with an isolation level such
  9447. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  9448. // or updated by the mutation.
  9449. func (m *CreditBalanceMutation) IDs(ctx context.Context) ([]uint64, error) {
  9450. switch {
  9451. case m.op.Is(OpUpdateOne | OpDeleteOne):
  9452. id, exists := m.ID()
  9453. if exists {
  9454. return []uint64{id}, nil
  9455. }
  9456. fallthrough
  9457. case m.op.Is(OpUpdate | OpDelete):
  9458. return m.Client().CreditBalance.Query().Where(m.predicates...).IDs(ctx)
  9459. default:
  9460. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  9461. }
  9462. }
  9463. // SetCreatedAt sets the "created_at" field.
  9464. func (m *CreditBalanceMutation) SetCreatedAt(t time.Time) {
  9465. m.created_at = &t
  9466. }
  9467. // CreatedAt returns the value of the "created_at" field in the mutation.
  9468. func (m *CreditBalanceMutation) CreatedAt() (r time.Time, exists bool) {
  9469. v := m.created_at
  9470. if v == nil {
  9471. return
  9472. }
  9473. return *v, true
  9474. }
  9475. // OldCreatedAt returns the old "created_at" field's value of the CreditBalance entity.
  9476. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  9477. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9478. func (m *CreditBalanceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  9479. if !m.op.Is(OpUpdateOne) {
  9480. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  9481. }
  9482. if m.id == nil || m.oldValue == nil {
  9483. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  9484. }
  9485. oldValue, err := m.oldValue(ctx)
  9486. if err != nil {
  9487. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  9488. }
  9489. return oldValue.CreatedAt, nil
  9490. }
  9491. // ResetCreatedAt resets all changes to the "created_at" field.
  9492. func (m *CreditBalanceMutation) ResetCreatedAt() {
  9493. m.created_at = nil
  9494. }
  9495. // SetUpdatedAt sets the "updated_at" field.
  9496. func (m *CreditBalanceMutation) SetUpdatedAt(t time.Time) {
  9497. m.updated_at = &t
  9498. }
  9499. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  9500. func (m *CreditBalanceMutation) UpdatedAt() (r time.Time, exists bool) {
  9501. v := m.updated_at
  9502. if v == nil {
  9503. return
  9504. }
  9505. return *v, true
  9506. }
  9507. // OldUpdatedAt returns the old "updated_at" field's value of the CreditBalance entity.
  9508. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  9509. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9510. func (m *CreditBalanceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  9511. if !m.op.Is(OpUpdateOne) {
  9512. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  9513. }
  9514. if m.id == nil || m.oldValue == nil {
  9515. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  9516. }
  9517. oldValue, err := m.oldValue(ctx)
  9518. if err != nil {
  9519. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  9520. }
  9521. return oldValue.UpdatedAt, nil
  9522. }
  9523. // ResetUpdatedAt resets all changes to the "updated_at" field.
  9524. func (m *CreditBalanceMutation) ResetUpdatedAt() {
  9525. m.updated_at = nil
  9526. }
  9527. // SetDeletedAt sets the "deleted_at" field.
  9528. func (m *CreditBalanceMutation) SetDeletedAt(t time.Time) {
  9529. m.deleted_at = &t
  9530. }
  9531. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  9532. func (m *CreditBalanceMutation) DeletedAt() (r time.Time, exists bool) {
  9533. v := m.deleted_at
  9534. if v == nil {
  9535. return
  9536. }
  9537. return *v, true
  9538. }
  9539. // OldDeletedAt returns the old "deleted_at" field's value of the CreditBalance entity.
  9540. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  9541. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9542. func (m *CreditBalanceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  9543. if !m.op.Is(OpUpdateOne) {
  9544. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  9545. }
  9546. if m.id == nil || m.oldValue == nil {
  9547. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  9548. }
  9549. oldValue, err := m.oldValue(ctx)
  9550. if err != nil {
  9551. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  9552. }
  9553. return oldValue.DeletedAt, nil
  9554. }
  9555. // ClearDeletedAt clears the value of the "deleted_at" field.
  9556. func (m *CreditBalanceMutation) ClearDeletedAt() {
  9557. m.deleted_at = nil
  9558. m.clearedFields[creditbalance.FieldDeletedAt] = struct{}{}
  9559. }
  9560. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  9561. func (m *CreditBalanceMutation) DeletedAtCleared() bool {
  9562. _, ok := m.clearedFields[creditbalance.FieldDeletedAt]
  9563. return ok
  9564. }
  9565. // ResetDeletedAt resets all changes to the "deleted_at" field.
  9566. func (m *CreditBalanceMutation) ResetDeletedAt() {
  9567. m.deleted_at = nil
  9568. delete(m.clearedFields, creditbalance.FieldDeletedAt)
  9569. }
  9570. // SetUserID sets the "user_id" field.
  9571. func (m *CreditBalanceMutation) SetUserID(s string) {
  9572. m.user_id = &s
  9573. }
  9574. // UserID returns the value of the "user_id" field in the mutation.
  9575. func (m *CreditBalanceMutation) UserID() (r string, exists bool) {
  9576. v := m.user_id
  9577. if v == nil {
  9578. return
  9579. }
  9580. return *v, true
  9581. }
  9582. // OldUserID returns the old "user_id" field's value of the CreditBalance entity.
  9583. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  9584. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9585. func (m *CreditBalanceMutation) OldUserID(ctx context.Context) (v string, err error) {
  9586. if !m.op.Is(OpUpdateOne) {
  9587. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  9588. }
  9589. if m.id == nil || m.oldValue == nil {
  9590. return v, errors.New("OldUserID requires an ID field in the mutation")
  9591. }
  9592. oldValue, err := m.oldValue(ctx)
  9593. if err != nil {
  9594. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  9595. }
  9596. return oldValue.UserID, nil
  9597. }
  9598. // ClearUserID clears the value of the "user_id" field.
  9599. func (m *CreditBalanceMutation) ClearUserID() {
  9600. m.user_id = nil
  9601. m.clearedFields[creditbalance.FieldUserID] = struct{}{}
  9602. }
  9603. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  9604. func (m *CreditBalanceMutation) UserIDCleared() bool {
  9605. _, ok := m.clearedFields[creditbalance.FieldUserID]
  9606. return ok
  9607. }
  9608. // ResetUserID resets all changes to the "user_id" field.
  9609. func (m *CreditBalanceMutation) ResetUserID() {
  9610. m.user_id = nil
  9611. delete(m.clearedFields, creditbalance.FieldUserID)
  9612. }
  9613. // SetBalance sets the "balance" field.
  9614. func (m *CreditBalanceMutation) SetBalance(f float32) {
  9615. m.balance = &f
  9616. m.addbalance = nil
  9617. }
  9618. // Balance returns the value of the "balance" field in the mutation.
  9619. func (m *CreditBalanceMutation) Balance() (r float32, exists bool) {
  9620. v := m.balance
  9621. if v == nil {
  9622. return
  9623. }
  9624. return *v, true
  9625. }
  9626. // OldBalance returns the old "balance" field's value of the CreditBalance entity.
  9627. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  9628. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9629. func (m *CreditBalanceMutation) OldBalance(ctx context.Context) (v float32, err error) {
  9630. if !m.op.Is(OpUpdateOne) {
  9631. return v, errors.New("OldBalance is only allowed on UpdateOne operations")
  9632. }
  9633. if m.id == nil || m.oldValue == nil {
  9634. return v, errors.New("OldBalance requires an ID field in the mutation")
  9635. }
  9636. oldValue, err := m.oldValue(ctx)
  9637. if err != nil {
  9638. return v, fmt.Errorf("querying old value for OldBalance: %w", err)
  9639. }
  9640. return oldValue.Balance, nil
  9641. }
  9642. // AddBalance adds f to the "balance" field.
  9643. func (m *CreditBalanceMutation) AddBalance(f float32) {
  9644. if m.addbalance != nil {
  9645. *m.addbalance += f
  9646. } else {
  9647. m.addbalance = &f
  9648. }
  9649. }
  9650. // AddedBalance returns the value that was added to the "balance" field in this mutation.
  9651. func (m *CreditBalanceMutation) AddedBalance() (r float32, exists bool) {
  9652. v := m.addbalance
  9653. if v == nil {
  9654. return
  9655. }
  9656. return *v, true
  9657. }
  9658. // ResetBalance resets all changes to the "balance" field.
  9659. func (m *CreditBalanceMutation) ResetBalance() {
  9660. m.balance = nil
  9661. m.addbalance = nil
  9662. }
  9663. // SetStatus sets the "status" field.
  9664. func (m *CreditBalanceMutation) SetStatus(i int) {
  9665. m.status = &i
  9666. m.addstatus = nil
  9667. }
  9668. // Status returns the value of the "status" field in the mutation.
  9669. func (m *CreditBalanceMutation) Status() (r int, exists bool) {
  9670. v := m.status
  9671. if v == nil {
  9672. return
  9673. }
  9674. return *v, true
  9675. }
  9676. // OldStatus returns the old "status" field's value of the CreditBalance entity.
  9677. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  9678. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9679. func (m *CreditBalanceMutation) OldStatus(ctx context.Context) (v int, err error) {
  9680. if !m.op.Is(OpUpdateOne) {
  9681. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  9682. }
  9683. if m.id == nil || m.oldValue == nil {
  9684. return v, errors.New("OldStatus requires an ID field in the mutation")
  9685. }
  9686. oldValue, err := m.oldValue(ctx)
  9687. if err != nil {
  9688. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  9689. }
  9690. return oldValue.Status, nil
  9691. }
  9692. // AddStatus adds i to the "status" field.
  9693. func (m *CreditBalanceMutation) AddStatus(i int) {
  9694. if m.addstatus != nil {
  9695. *m.addstatus += i
  9696. } else {
  9697. m.addstatus = &i
  9698. }
  9699. }
  9700. // AddedStatus returns the value that was added to the "status" field in this mutation.
  9701. func (m *CreditBalanceMutation) AddedStatus() (r int, exists bool) {
  9702. v := m.addstatus
  9703. if v == nil {
  9704. return
  9705. }
  9706. return *v, true
  9707. }
  9708. // ClearStatus clears the value of the "status" field.
  9709. func (m *CreditBalanceMutation) ClearStatus() {
  9710. m.status = nil
  9711. m.addstatus = nil
  9712. m.clearedFields[creditbalance.FieldStatus] = struct{}{}
  9713. }
  9714. // StatusCleared returns if the "status" field was cleared in this mutation.
  9715. func (m *CreditBalanceMutation) StatusCleared() bool {
  9716. _, ok := m.clearedFields[creditbalance.FieldStatus]
  9717. return ok
  9718. }
  9719. // ResetStatus resets all changes to the "status" field.
  9720. func (m *CreditBalanceMutation) ResetStatus() {
  9721. m.status = nil
  9722. m.addstatus = nil
  9723. delete(m.clearedFields, creditbalance.FieldStatus)
  9724. }
  9725. // SetOrganizationID sets the "organization_id" field.
  9726. func (m *CreditBalanceMutation) SetOrganizationID(u uint64) {
  9727. m.organization_id = &u
  9728. m.addorganization_id = nil
  9729. }
  9730. // OrganizationID returns the value of the "organization_id" field in the mutation.
  9731. func (m *CreditBalanceMutation) OrganizationID() (r uint64, exists bool) {
  9732. v := m.organization_id
  9733. if v == nil {
  9734. return
  9735. }
  9736. return *v, true
  9737. }
  9738. // OldOrganizationID returns the old "organization_id" field's value of the CreditBalance entity.
  9739. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  9740. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9741. func (m *CreditBalanceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  9742. if !m.op.Is(OpUpdateOne) {
  9743. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  9744. }
  9745. if m.id == nil || m.oldValue == nil {
  9746. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  9747. }
  9748. oldValue, err := m.oldValue(ctx)
  9749. if err != nil {
  9750. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  9751. }
  9752. return oldValue.OrganizationID, nil
  9753. }
  9754. // AddOrganizationID adds u to the "organization_id" field.
  9755. func (m *CreditBalanceMutation) AddOrganizationID(u int64) {
  9756. if m.addorganization_id != nil {
  9757. *m.addorganization_id += u
  9758. } else {
  9759. m.addorganization_id = &u
  9760. }
  9761. }
  9762. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  9763. func (m *CreditBalanceMutation) AddedOrganizationID() (r int64, exists bool) {
  9764. v := m.addorganization_id
  9765. if v == nil {
  9766. return
  9767. }
  9768. return *v, true
  9769. }
  9770. // ClearOrganizationID clears the value of the "organization_id" field.
  9771. func (m *CreditBalanceMutation) ClearOrganizationID() {
  9772. m.organization_id = nil
  9773. m.addorganization_id = nil
  9774. m.clearedFields[creditbalance.FieldOrganizationID] = struct{}{}
  9775. }
  9776. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  9777. func (m *CreditBalanceMutation) OrganizationIDCleared() bool {
  9778. _, ok := m.clearedFields[creditbalance.FieldOrganizationID]
  9779. return ok
  9780. }
  9781. // ResetOrganizationID resets all changes to the "organization_id" field.
  9782. func (m *CreditBalanceMutation) ResetOrganizationID() {
  9783. m.organization_id = nil
  9784. m.addorganization_id = nil
  9785. delete(m.clearedFields, creditbalance.FieldOrganizationID)
  9786. }
  9787. // Where appends a list predicates to the CreditBalanceMutation builder.
  9788. func (m *CreditBalanceMutation) Where(ps ...predicate.CreditBalance) {
  9789. m.predicates = append(m.predicates, ps...)
  9790. }
  9791. // WhereP appends storage-level predicates to the CreditBalanceMutation builder. Using this method,
  9792. // users can use type-assertion to append predicates that do not depend on any generated package.
  9793. func (m *CreditBalanceMutation) WhereP(ps ...func(*sql.Selector)) {
  9794. p := make([]predicate.CreditBalance, len(ps))
  9795. for i := range ps {
  9796. p[i] = ps[i]
  9797. }
  9798. m.Where(p...)
  9799. }
  9800. // Op returns the operation name.
  9801. func (m *CreditBalanceMutation) Op() Op {
  9802. return m.op
  9803. }
  9804. // SetOp allows setting the mutation operation.
  9805. func (m *CreditBalanceMutation) SetOp(op Op) {
  9806. m.op = op
  9807. }
  9808. // Type returns the node type of this mutation (CreditBalance).
  9809. func (m *CreditBalanceMutation) Type() string {
  9810. return m.typ
  9811. }
  9812. // Fields returns all fields that were changed during this mutation. Note that in
  9813. // order to get all numeric fields that were incremented/decremented, call
  9814. // AddedFields().
  9815. func (m *CreditBalanceMutation) Fields() []string {
  9816. fields := make([]string, 0, 7)
  9817. if m.created_at != nil {
  9818. fields = append(fields, creditbalance.FieldCreatedAt)
  9819. }
  9820. if m.updated_at != nil {
  9821. fields = append(fields, creditbalance.FieldUpdatedAt)
  9822. }
  9823. if m.deleted_at != nil {
  9824. fields = append(fields, creditbalance.FieldDeletedAt)
  9825. }
  9826. if m.user_id != nil {
  9827. fields = append(fields, creditbalance.FieldUserID)
  9828. }
  9829. if m.balance != nil {
  9830. fields = append(fields, creditbalance.FieldBalance)
  9831. }
  9832. if m.status != nil {
  9833. fields = append(fields, creditbalance.FieldStatus)
  9834. }
  9835. if m.organization_id != nil {
  9836. fields = append(fields, creditbalance.FieldOrganizationID)
  9837. }
  9838. return fields
  9839. }
  9840. // Field returns the value of a field with the given name. The second boolean
  9841. // return value indicates that this field was not set, or was not defined in the
  9842. // schema.
  9843. func (m *CreditBalanceMutation) Field(name string) (ent.Value, bool) {
  9844. switch name {
  9845. case creditbalance.FieldCreatedAt:
  9846. return m.CreatedAt()
  9847. case creditbalance.FieldUpdatedAt:
  9848. return m.UpdatedAt()
  9849. case creditbalance.FieldDeletedAt:
  9850. return m.DeletedAt()
  9851. case creditbalance.FieldUserID:
  9852. return m.UserID()
  9853. case creditbalance.FieldBalance:
  9854. return m.Balance()
  9855. case creditbalance.FieldStatus:
  9856. return m.Status()
  9857. case creditbalance.FieldOrganizationID:
  9858. return m.OrganizationID()
  9859. }
  9860. return nil, false
  9861. }
  9862. // OldField returns the old value of the field from the database. An error is
  9863. // returned if the mutation operation is not UpdateOne, or the query to the
  9864. // database failed.
  9865. func (m *CreditBalanceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  9866. switch name {
  9867. case creditbalance.FieldCreatedAt:
  9868. return m.OldCreatedAt(ctx)
  9869. case creditbalance.FieldUpdatedAt:
  9870. return m.OldUpdatedAt(ctx)
  9871. case creditbalance.FieldDeletedAt:
  9872. return m.OldDeletedAt(ctx)
  9873. case creditbalance.FieldUserID:
  9874. return m.OldUserID(ctx)
  9875. case creditbalance.FieldBalance:
  9876. return m.OldBalance(ctx)
  9877. case creditbalance.FieldStatus:
  9878. return m.OldStatus(ctx)
  9879. case creditbalance.FieldOrganizationID:
  9880. return m.OldOrganizationID(ctx)
  9881. }
  9882. return nil, fmt.Errorf("unknown CreditBalance field %s", name)
  9883. }
  9884. // SetField sets the value of a field with the given name. It returns an error if
  9885. // the field is not defined in the schema, or if the type mismatched the field
  9886. // type.
  9887. func (m *CreditBalanceMutation) SetField(name string, value ent.Value) error {
  9888. switch name {
  9889. case creditbalance.FieldCreatedAt:
  9890. v, ok := value.(time.Time)
  9891. if !ok {
  9892. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9893. }
  9894. m.SetCreatedAt(v)
  9895. return nil
  9896. case creditbalance.FieldUpdatedAt:
  9897. v, ok := value.(time.Time)
  9898. if !ok {
  9899. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9900. }
  9901. m.SetUpdatedAt(v)
  9902. return nil
  9903. case creditbalance.FieldDeletedAt:
  9904. v, ok := value.(time.Time)
  9905. if !ok {
  9906. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9907. }
  9908. m.SetDeletedAt(v)
  9909. return nil
  9910. case creditbalance.FieldUserID:
  9911. v, ok := value.(string)
  9912. if !ok {
  9913. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9914. }
  9915. m.SetUserID(v)
  9916. return nil
  9917. case creditbalance.FieldBalance:
  9918. v, ok := value.(float32)
  9919. if !ok {
  9920. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9921. }
  9922. m.SetBalance(v)
  9923. return nil
  9924. case creditbalance.FieldStatus:
  9925. v, ok := value.(int)
  9926. if !ok {
  9927. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9928. }
  9929. m.SetStatus(v)
  9930. return nil
  9931. case creditbalance.FieldOrganizationID:
  9932. v, ok := value.(uint64)
  9933. if !ok {
  9934. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9935. }
  9936. m.SetOrganizationID(v)
  9937. return nil
  9938. }
  9939. return fmt.Errorf("unknown CreditBalance field %s", name)
  9940. }
  9941. // AddedFields returns all numeric fields that were incremented/decremented during
  9942. // this mutation.
  9943. func (m *CreditBalanceMutation) AddedFields() []string {
  9944. var fields []string
  9945. if m.addbalance != nil {
  9946. fields = append(fields, creditbalance.FieldBalance)
  9947. }
  9948. if m.addstatus != nil {
  9949. fields = append(fields, creditbalance.FieldStatus)
  9950. }
  9951. if m.addorganization_id != nil {
  9952. fields = append(fields, creditbalance.FieldOrganizationID)
  9953. }
  9954. return fields
  9955. }
  9956. // AddedField returns the numeric value that was incremented/decremented on a field
  9957. // with the given name. The second boolean return value indicates that this field
  9958. // was not set, or was not defined in the schema.
  9959. func (m *CreditBalanceMutation) AddedField(name string) (ent.Value, bool) {
  9960. switch name {
  9961. case creditbalance.FieldBalance:
  9962. return m.AddedBalance()
  9963. case creditbalance.FieldStatus:
  9964. return m.AddedStatus()
  9965. case creditbalance.FieldOrganizationID:
  9966. return m.AddedOrganizationID()
  9967. }
  9968. return nil, false
  9969. }
  9970. // AddField adds the value to the field with the given name. It returns an error if
  9971. // the field is not defined in the schema, or if the type mismatched the field
  9972. // type.
  9973. func (m *CreditBalanceMutation) AddField(name string, value ent.Value) error {
  9974. switch name {
  9975. case creditbalance.FieldBalance:
  9976. v, ok := value.(float32)
  9977. if !ok {
  9978. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9979. }
  9980. m.AddBalance(v)
  9981. return nil
  9982. case creditbalance.FieldStatus:
  9983. v, ok := value.(int)
  9984. if !ok {
  9985. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9986. }
  9987. m.AddStatus(v)
  9988. return nil
  9989. case creditbalance.FieldOrganizationID:
  9990. v, ok := value.(int64)
  9991. if !ok {
  9992. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9993. }
  9994. m.AddOrganizationID(v)
  9995. return nil
  9996. }
  9997. return fmt.Errorf("unknown CreditBalance numeric field %s", name)
  9998. }
  9999. // ClearedFields returns all nullable fields that were cleared during this
  10000. // mutation.
  10001. func (m *CreditBalanceMutation) ClearedFields() []string {
  10002. var fields []string
  10003. if m.FieldCleared(creditbalance.FieldDeletedAt) {
  10004. fields = append(fields, creditbalance.FieldDeletedAt)
  10005. }
  10006. if m.FieldCleared(creditbalance.FieldUserID) {
  10007. fields = append(fields, creditbalance.FieldUserID)
  10008. }
  10009. if m.FieldCleared(creditbalance.FieldStatus) {
  10010. fields = append(fields, creditbalance.FieldStatus)
  10011. }
  10012. if m.FieldCleared(creditbalance.FieldOrganizationID) {
  10013. fields = append(fields, creditbalance.FieldOrganizationID)
  10014. }
  10015. return fields
  10016. }
  10017. // FieldCleared returns a boolean indicating if a field with the given name was
  10018. // cleared in this mutation.
  10019. func (m *CreditBalanceMutation) FieldCleared(name string) bool {
  10020. _, ok := m.clearedFields[name]
  10021. return ok
  10022. }
  10023. // ClearField clears the value of the field with the given name. It returns an
  10024. // error if the field is not defined in the schema.
  10025. func (m *CreditBalanceMutation) ClearField(name string) error {
  10026. switch name {
  10027. case creditbalance.FieldDeletedAt:
  10028. m.ClearDeletedAt()
  10029. return nil
  10030. case creditbalance.FieldUserID:
  10031. m.ClearUserID()
  10032. return nil
  10033. case creditbalance.FieldStatus:
  10034. m.ClearStatus()
  10035. return nil
  10036. case creditbalance.FieldOrganizationID:
  10037. m.ClearOrganizationID()
  10038. return nil
  10039. }
  10040. return fmt.Errorf("unknown CreditBalance nullable field %s", name)
  10041. }
  10042. // ResetField resets all changes in the mutation for the field with the given name.
  10043. // It returns an error if the field is not defined in the schema.
  10044. func (m *CreditBalanceMutation) ResetField(name string) error {
  10045. switch name {
  10046. case creditbalance.FieldCreatedAt:
  10047. m.ResetCreatedAt()
  10048. return nil
  10049. case creditbalance.FieldUpdatedAt:
  10050. m.ResetUpdatedAt()
  10051. return nil
  10052. case creditbalance.FieldDeletedAt:
  10053. m.ResetDeletedAt()
  10054. return nil
  10055. case creditbalance.FieldUserID:
  10056. m.ResetUserID()
  10057. return nil
  10058. case creditbalance.FieldBalance:
  10059. m.ResetBalance()
  10060. return nil
  10061. case creditbalance.FieldStatus:
  10062. m.ResetStatus()
  10063. return nil
  10064. case creditbalance.FieldOrganizationID:
  10065. m.ResetOrganizationID()
  10066. return nil
  10067. }
  10068. return fmt.Errorf("unknown CreditBalance field %s", name)
  10069. }
  10070. // AddedEdges returns all edge names that were set/added in this mutation.
  10071. func (m *CreditBalanceMutation) AddedEdges() []string {
  10072. edges := make([]string, 0, 0)
  10073. return edges
  10074. }
  10075. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  10076. // name in this mutation.
  10077. func (m *CreditBalanceMutation) AddedIDs(name string) []ent.Value {
  10078. return nil
  10079. }
  10080. // RemovedEdges returns all edge names that were removed in this mutation.
  10081. func (m *CreditBalanceMutation) RemovedEdges() []string {
  10082. edges := make([]string, 0, 0)
  10083. return edges
  10084. }
  10085. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  10086. // the given name in this mutation.
  10087. func (m *CreditBalanceMutation) RemovedIDs(name string) []ent.Value {
  10088. return nil
  10089. }
  10090. // ClearedEdges returns all edge names that were cleared in this mutation.
  10091. func (m *CreditBalanceMutation) ClearedEdges() []string {
  10092. edges := make([]string, 0, 0)
  10093. return edges
  10094. }
  10095. // EdgeCleared returns a boolean which indicates if the edge with the given name
  10096. // was cleared in this mutation.
  10097. func (m *CreditBalanceMutation) EdgeCleared(name string) bool {
  10098. return false
  10099. }
  10100. // ClearEdge clears the value of the edge with the given name. It returns an error
  10101. // if that edge is not defined in the schema.
  10102. func (m *CreditBalanceMutation) ClearEdge(name string) error {
  10103. return fmt.Errorf("unknown CreditBalance unique edge %s", name)
  10104. }
  10105. // ResetEdge resets all changes to the edge with the given name in this mutation.
  10106. // It returns an error if the edge is not defined in the schema.
  10107. func (m *CreditBalanceMutation) ResetEdge(name string) error {
  10108. return fmt.Errorf("unknown CreditBalance edge %s", name)
  10109. }
  10110. // CreditUsageMutation represents an operation that mutates the CreditUsage nodes in the graph.
  10111. type CreditUsageMutation struct {
  10112. config
  10113. op Op
  10114. typ string
  10115. id *uint64
  10116. created_at *time.Time
  10117. updated_at *time.Time
  10118. deleted_at *time.Time
  10119. user_id *string
  10120. number *float32
  10121. addnumber *float32
  10122. status *int
  10123. addstatus *int
  10124. ntype *int
  10125. addntype *int
  10126. table *string
  10127. organization_id *uint64
  10128. addorganization_id *int64
  10129. nid *uint64
  10130. addnid *int64
  10131. reason *string
  10132. operator *string
  10133. clearedFields map[string]struct{}
  10134. done bool
  10135. oldValue func(context.Context) (*CreditUsage, error)
  10136. predicates []predicate.CreditUsage
  10137. }
  10138. var _ ent.Mutation = (*CreditUsageMutation)(nil)
  10139. // creditusageOption allows management of the mutation configuration using functional options.
  10140. type creditusageOption func(*CreditUsageMutation)
  10141. // newCreditUsageMutation creates new mutation for the CreditUsage entity.
  10142. func newCreditUsageMutation(c config, op Op, opts ...creditusageOption) *CreditUsageMutation {
  10143. m := &CreditUsageMutation{
  10144. config: c,
  10145. op: op,
  10146. typ: TypeCreditUsage,
  10147. clearedFields: make(map[string]struct{}),
  10148. }
  10149. for _, opt := range opts {
  10150. opt(m)
  10151. }
  10152. return m
  10153. }
  10154. // withCreditUsageID sets the ID field of the mutation.
  10155. func withCreditUsageID(id uint64) creditusageOption {
  10156. return func(m *CreditUsageMutation) {
  10157. var (
  10158. err error
  10159. once sync.Once
  10160. value *CreditUsage
  10161. )
  10162. m.oldValue = func(ctx context.Context) (*CreditUsage, error) {
  10163. once.Do(func() {
  10164. if m.done {
  10165. err = errors.New("querying old values post mutation is not allowed")
  10166. } else {
  10167. value, err = m.Client().CreditUsage.Get(ctx, id)
  10168. }
  10169. })
  10170. return value, err
  10171. }
  10172. m.id = &id
  10173. }
  10174. }
  10175. // withCreditUsage sets the old CreditUsage of the mutation.
  10176. func withCreditUsage(node *CreditUsage) creditusageOption {
  10177. return func(m *CreditUsageMutation) {
  10178. m.oldValue = func(context.Context) (*CreditUsage, error) {
  10179. return node, nil
  10180. }
  10181. m.id = &node.ID
  10182. }
  10183. }
  10184. // Client returns a new `ent.Client` from the mutation. If the mutation was
  10185. // executed in a transaction (ent.Tx), a transactional client is returned.
  10186. func (m CreditUsageMutation) Client() *Client {
  10187. client := &Client{config: m.config}
  10188. client.init()
  10189. return client
  10190. }
  10191. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  10192. // it returns an error otherwise.
  10193. func (m CreditUsageMutation) Tx() (*Tx, error) {
  10194. if _, ok := m.driver.(*txDriver); !ok {
  10195. return nil, errors.New("ent: mutation is not running in a transaction")
  10196. }
  10197. tx := &Tx{config: m.config}
  10198. tx.init()
  10199. return tx, nil
  10200. }
  10201. // SetID sets the value of the id field. Note that this
  10202. // operation is only accepted on creation of CreditUsage entities.
  10203. func (m *CreditUsageMutation) SetID(id uint64) {
  10204. m.id = &id
  10205. }
  10206. // ID returns the ID value in the mutation. Note that the ID is only available
  10207. // if it was provided to the builder or after it was returned from the database.
  10208. func (m *CreditUsageMutation) ID() (id uint64, exists bool) {
  10209. if m.id == nil {
  10210. return
  10211. }
  10212. return *m.id, true
  10213. }
  10214. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  10215. // That means, if the mutation is applied within a transaction with an isolation level such
  10216. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  10217. // or updated by the mutation.
  10218. func (m *CreditUsageMutation) IDs(ctx context.Context) ([]uint64, error) {
  10219. switch {
  10220. case m.op.Is(OpUpdateOne | OpDeleteOne):
  10221. id, exists := m.ID()
  10222. if exists {
  10223. return []uint64{id}, nil
  10224. }
  10225. fallthrough
  10226. case m.op.Is(OpUpdate | OpDelete):
  10227. return m.Client().CreditUsage.Query().Where(m.predicates...).IDs(ctx)
  10228. default:
  10229. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  10230. }
  10231. }
  10232. // SetCreatedAt sets the "created_at" field.
  10233. func (m *CreditUsageMutation) SetCreatedAt(t time.Time) {
  10234. m.created_at = &t
  10235. }
  10236. // CreatedAt returns the value of the "created_at" field in the mutation.
  10237. func (m *CreditUsageMutation) CreatedAt() (r time.Time, exists bool) {
  10238. v := m.created_at
  10239. if v == nil {
  10240. return
  10241. }
  10242. return *v, true
  10243. }
  10244. // OldCreatedAt returns the old "created_at" field's value of the CreditUsage entity.
  10245. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10246. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10247. func (m *CreditUsageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  10248. if !m.op.Is(OpUpdateOne) {
  10249. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  10250. }
  10251. if m.id == nil || m.oldValue == nil {
  10252. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  10253. }
  10254. oldValue, err := m.oldValue(ctx)
  10255. if err != nil {
  10256. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  10257. }
  10258. return oldValue.CreatedAt, nil
  10259. }
  10260. // ResetCreatedAt resets all changes to the "created_at" field.
  10261. func (m *CreditUsageMutation) ResetCreatedAt() {
  10262. m.created_at = nil
  10263. }
  10264. // SetUpdatedAt sets the "updated_at" field.
  10265. func (m *CreditUsageMutation) SetUpdatedAt(t time.Time) {
  10266. m.updated_at = &t
  10267. }
  10268. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  10269. func (m *CreditUsageMutation) UpdatedAt() (r time.Time, exists bool) {
  10270. v := m.updated_at
  10271. if v == nil {
  10272. return
  10273. }
  10274. return *v, true
  10275. }
  10276. // OldUpdatedAt returns the old "updated_at" field's value of the CreditUsage entity.
  10277. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10278. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10279. func (m *CreditUsageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  10280. if !m.op.Is(OpUpdateOne) {
  10281. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  10282. }
  10283. if m.id == nil || m.oldValue == nil {
  10284. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  10285. }
  10286. oldValue, err := m.oldValue(ctx)
  10287. if err != nil {
  10288. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  10289. }
  10290. return oldValue.UpdatedAt, nil
  10291. }
  10292. // ResetUpdatedAt resets all changes to the "updated_at" field.
  10293. func (m *CreditUsageMutation) ResetUpdatedAt() {
  10294. m.updated_at = nil
  10295. }
  10296. // SetDeletedAt sets the "deleted_at" field.
  10297. func (m *CreditUsageMutation) SetDeletedAt(t time.Time) {
  10298. m.deleted_at = &t
  10299. }
  10300. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  10301. func (m *CreditUsageMutation) DeletedAt() (r time.Time, exists bool) {
  10302. v := m.deleted_at
  10303. if v == nil {
  10304. return
  10305. }
  10306. return *v, true
  10307. }
  10308. // OldDeletedAt returns the old "deleted_at" field's value of the CreditUsage entity.
  10309. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10310. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10311. func (m *CreditUsageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  10312. if !m.op.Is(OpUpdateOne) {
  10313. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  10314. }
  10315. if m.id == nil || m.oldValue == nil {
  10316. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  10317. }
  10318. oldValue, err := m.oldValue(ctx)
  10319. if err != nil {
  10320. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  10321. }
  10322. return oldValue.DeletedAt, nil
  10323. }
  10324. // ClearDeletedAt clears the value of the "deleted_at" field.
  10325. func (m *CreditUsageMutation) ClearDeletedAt() {
  10326. m.deleted_at = nil
  10327. m.clearedFields[creditusage.FieldDeletedAt] = struct{}{}
  10328. }
  10329. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  10330. func (m *CreditUsageMutation) DeletedAtCleared() bool {
  10331. _, ok := m.clearedFields[creditusage.FieldDeletedAt]
  10332. return ok
  10333. }
  10334. // ResetDeletedAt resets all changes to the "deleted_at" field.
  10335. func (m *CreditUsageMutation) ResetDeletedAt() {
  10336. m.deleted_at = nil
  10337. delete(m.clearedFields, creditusage.FieldDeletedAt)
  10338. }
  10339. // SetUserID sets the "user_id" field.
  10340. func (m *CreditUsageMutation) SetUserID(s string) {
  10341. m.user_id = &s
  10342. }
  10343. // UserID returns the value of the "user_id" field in the mutation.
  10344. func (m *CreditUsageMutation) UserID() (r string, exists bool) {
  10345. v := m.user_id
  10346. if v == nil {
  10347. return
  10348. }
  10349. return *v, true
  10350. }
  10351. // OldUserID returns the old "user_id" field's value of the CreditUsage entity.
  10352. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10353. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10354. func (m *CreditUsageMutation) OldUserID(ctx context.Context) (v string, err error) {
  10355. if !m.op.Is(OpUpdateOne) {
  10356. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  10357. }
  10358. if m.id == nil || m.oldValue == nil {
  10359. return v, errors.New("OldUserID requires an ID field in the mutation")
  10360. }
  10361. oldValue, err := m.oldValue(ctx)
  10362. if err != nil {
  10363. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  10364. }
  10365. return oldValue.UserID, nil
  10366. }
  10367. // ResetUserID resets all changes to the "user_id" field.
  10368. func (m *CreditUsageMutation) ResetUserID() {
  10369. m.user_id = nil
  10370. }
  10371. // SetNumber sets the "number" field.
  10372. func (m *CreditUsageMutation) SetNumber(f float32) {
  10373. m.number = &f
  10374. m.addnumber = nil
  10375. }
  10376. // Number returns the value of the "number" field in the mutation.
  10377. func (m *CreditUsageMutation) Number() (r float32, exists bool) {
  10378. v := m.number
  10379. if v == nil {
  10380. return
  10381. }
  10382. return *v, true
  10383. }
  10384. // OldNumber returns the old "number" field's value of the CreditUsage entity.
  10385. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10386. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10387. func (m *CreditUsageMutation) OldNumber(ctx context.Context) (v float32, err error) {
  10388. if !m.op.Is(OpUpdateOne) {
  10389. return v, errors.New("OldNumber is only allowed on UpdateOne operations")
  10390. }
  10391. if m.id == nil || m.oldValue == nil {
  10392. return v, errors.New("OldNumber requires an ID field in the mutation")
  10393. }
  10394. oldValue, err := m.oldValue(ctx)
  10395. if err != nil {
  10396. return v, fmt.Errorf("querying old value for OldNumber: %w", err)
  10397. }
  10398. return oldValue.Number, nil
  10399. }
  10400. // AddNumber adds f to the "number" field.
  10401. func (m *CreditUsageMutation) AddNumber(f float32) {
  10402. if m.addnumber != nil {
  10403. *m.addnumber += f
  10404. } else {
  10405. m.addnumber = &f
  10406. }
  10407. }
  10408. // AddedNumber returns the value that was added to the "number" field in this mutation.
  10409. func (m *CreditUsageMutation) AddedNumber() (r float32, exists bool) {
  10410. v := m.addnumber
  10411. if v == nil {
  10412. return
  10413. }
  10414. return *v, true
  10415. }
  10416. // ResetNumber resets all changes to the "number" field.
  10417. func (m *CreditUsageMutation) ResetNumber() {
  10418. m.number = nil
  10419. m.addnumber = nil
  10420. }
  10421. // SetStatus sets the "status" field.
  10422. func (m *CreditUsageMutation) SetStatus(i int) {
  10423. m.status = &i
  10424. m.addstatus = nil
  10425. }
  10426. // Status returns the value of the "status" field in the mutation.
  10427. func (m *CreditUsageMutation) Status() (r int, exists bool) {
  10428. v := m.status
  10429. if v == nil {
  10430. return
  10431. }
  10432. return *v, true
  10433. }
  10434. // OldStatus returns the old "status" field's value of the CreditUsage entity.
  10435. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10436. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10437. func (m *CreditUsageMutation) OldStatus(ctx context.Context) (v int, err error) {
  10438. if !m.op.Is(OpUpdateOne) {
  10439. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  10440. }
  10441. if m.id == nil || m.oldValue == nil {
  10442. return v, errors.New("OldStatus requires an ID field in the mutation")
  10443. }
  10444. oldValue, err := m.oldValue(ctx)
  10445. if err != nil {
  10446. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  10447. }
  10448. return oldValue.Status, nil
  10449. }
  10450. // AddStatus adds i to the "status" field.
  10451. func (m *CreditUsageMutation) AddStatus(i int) {
  10452. if m.addstatus != nil {
  10453. *m.addstatus += i
  10454. } else {
  10455. m.addstatus = &i
  10456. }
  10457. }
  10458. // AddedStatus returns the value that was added to the "status" field in this mutation.
  10459. func (m *CreditUsageMutation) AddedStatus() (r int, exists bool) {
  10460. v := m.addstatus
  10461. if v == nil {
  10462. return
  10463. }
  10464. return *v, true
  10465. }
  10466. // ClearStatus clears the value of the "status" field.
  10467. func (m *CreditUsageMutation) ClearStatus() {
  10468. m.status = nil
  10469. m.addstatus = nil
  10470. m.clearedFields[creditusage.FieldStatus] = struct{}{}
  10471. }
  10472. // StatusCleared returns if the "status" field was cleared in this mutation.
  10473. func (m *CreditUsageMutation) StatusCleared() bool {
  10474. _, ok := m.clearedFields[creditusage.FieldStatus]
  10475. return ok
  10476. }
  10477. // ResetStatus resets all changes to the "status" field.
  10478. func (m *CreditUsageMutation) ResetStatus() {
  10479. m.status = nil
  10480. m.addstatus = nil
  10481. delete(m.clearedFields, creditusage.FieldStatus)
  10482. }
  10483. // SetNtype sets the "ntype" field.
  10484. func (m *CreditUsageMutation) SetNtype(i int) {
  10485. m.ntype = &i
  10486. m.addntype = nil
  10487. }
  10488. // Ntype returns the value of the "ntype" field in the mutation.
  10489. func (m *CreditUsageMutation) Ntype() (r int, exists bool) {
  10490. v := m.ntype
  10491. if v == nil {
  10492. return
  10493. }
  10494. return *v, true
  10495. }
  10496. // OldNtype returns the old "ntype" field's value of the CreditUsage entity.
  10497. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10498. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10499. func (m *CreditUsageMutation) OldNtype(ctx context.Context) (v int, err error) {
  10500. if !m.op.Is(OpUpdateOne) {
  10501. return v, errors.New("OldNtype is only allowed on UpdateOne operations")
  10502. }
  10503. if m.id == nil || m.oldValue == nil {
  10504. return v, errors.New("OldNtype requires an ID field in the mutation")
  10505. }
  10506. oldValue, err := m.oldValue(ctx)
  10507. if err != nil {
  10508. return v, fmt.Errorf("querying old value for OldNtype: %w", err)
  10509. }
  10510. return oldValue.Ntype, nil
  10511. }
  10512. // AddNtype adds i to the "ntype" field.
  10513. func (m *CreditUsageMutation) AddNtype(i int) {
  10514. if m.addntype != nil {
  10515. *m.addntype += i
  10516. } else {
  10517. m.addntype = &i
  10518. }
  10519. }
  10520. // AddedNtype returns the value that was added to the "ntype" field in this mutation.
  10521. func (m *CreditUsageMutation) AddedNtype() (r int, exists bool) {
  10522. v := m.addntype
  10523. if v == nil {
  10524. return
  10525. }
  10526. return *v, true
  10527. }
  10528. // ResetNtype resets all changes to the "ntype" field.
  10529. func (m *CreditUsageMutation) ResetNtype() {
  10530. m.ntype = nil
  10531. m.addntype = nil
  10532. }
  10533. // SetTable sets the "table" field.
  10534. func (m *CreditUsageMutation) SetTable(s string) {
  10535. m.table = &s
  10536. }
  10537. // Table returns the value of the "table" field in the mutation.
  10538. func (m *CreditUsageMutation) Table() (r string, exists bool) {
  10539. v := m.table
  10540. if v == nil {
  10541. return
  10542. }
  10543. return *v, true
  10544. }
  10545. // OldTable returns the old "table" field's value of the CreditUsage entity.
  10546. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10547. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10548. func (m *CreditUsageMutation) OldTable(ctx context.Context) (v string, err error) {
  10549. if !m.op.Is(OpUpdateOne) {
  10550. return v, errors.New("OldTable is only allowed on UpdateOne operations")
  10551. }
  10552. if m.id == nil || m.oldValue == nil {
  10553. return v, errors.New("OldTable requires an ID field in the mutation")
  10554. }
  10555. oldValue, err := m.oldValue(ctx)
  10556. if err != nil {
  10557. return v, fmt.Errorf("querying old value for OldTable: %w", err)
  10558. }
  10559. return oldValue.Table, nil
  10560. }
  10561. // ResetTable resets all changes to the "table" field.
  10562. func (m *CreditUsageMutation) ResetTable() {
  10563. m.table = nil
  10564. }
  10565. // SetOrganizationID sets the "organization_id" field.
  10566. func (m *CreditUsageMutation) SetOrganizationID(u uint64) {
  10567. m.organization_id = &u
  10568. m.addorganization_id = nil
  10569. }
  10570. // OrganizationID returns the value of the "organization_id" field in the mutation.
  10571. func (m *CreditUsageMutation) OrganizationID() (r uint64, exists bool) {
  10572. v := m.organization_id
  10573. if v == nil {
  10574. return
  10575. }
  10576. return *v, true
  10577. }
  10578. // OldOrganizationID returns the old "organization_id" field's value of the CreditUsage entity.
  10579. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10580. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10581. func (m *CreditUsageMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  10582. if !m.op.Is(OpUpdateOne) {
  10583. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  10584. }
  10585. if m.id == nil || m.oldValue == nil {
  10586. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  10587. }
  10588. oldValue, err := m.oldValue(ctx)
  10589. if err != nil {
  10590. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  10591. }
  10592. return oldValue.OrganizationID, nil
  10593. }
  10594. // AddOrganizationID adds u to the "organization_id" field.
  10595. func (m *CreditUsageMutation) AddOrganizationID(u int64) {
  10596. if m.addorganization_id != nil {
  10597. *m.addorganization_id += u
  10598. } else {
  10599. m.addorganization_id = &u
  10600. }
  10601. }
  10602. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  10603. func (m *CreditUsageMutation) AddedOrganizationID() (r int64, exists bool) {
  10604. v := m.addorganization_id
  10605. if v == nil {
  10606. return
  10607. }
  10608. return *v, true
  10609. }
  10610. // ClearOrganizationID clears the value of the "organization_id" field.
  10611. func (m *CreditUsageMutation) ClearOrganizationID() {
  10612. m.organization_id = nil
  10613. m.addorganization_id = nil
  10614. m.clearedFields[creditusage.FieldOrganizationID] = struct{}{}
  10615. }
  10616. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  10617. func (m *CreditUsageMutation) OrganizationIDCleared() bool {
  10618. _, ok := m.clearedFields[creditusage.FieldOrganizationID]
  10619. return ok
  10620. }
  10621. // ResetOrganizationID resets all changes to the "organization_id" field.
  10622. func (m *CreditUsageMutation) ResetOrganizationID() {
  10623. m.organization_id = nil
  10624. m.addorganization_id = nil
  10625. delete(m.clearedFields, creditusage.FieldOrganizationID)
  10626. }
  10627. // SetNid sets the "nid" field.
  10628. func (m *CreditUsageMutation) SetNid(u uint64) {
  10629. m.nid = &u
  10630. m.addnid = nil
  10631. }
  10632. // Nid returns the value of the "nid" field in the mutation.
  10633. func (m *CreditUsageMutation) Nid() (r uint64, exists bool) {
  10634. v := m.nid
  10635. if v == nil {
  10636. return
  10637. }
  10638. return *v, true
  10639. }
  10640. // OldNid returns the old "nid" field's value of the CreditUsage entity.
  10641. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10642. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10643. func (m *CreditUsageMutation) OldNid(ctx context.Context) (v uint64, err error) {
  10644. if !m.op.Is(OpUpdateOne) {
  10645. return v, errors.New("OldNid is only allowed on UpdateOne operations")
  10646. }
  10647. if m.id == nil || m.oldValue == nil {
  10648. return v, errors.New("OldNid requires an ID field in the mutation")
  10649. }
  10650. oldValue, err := m.oldValue(ctx)
  10651. if err != nil {
  10652. return v, fmt.Errorf("querying old value for OldNid: %w", err)
  10653. }
  10654. return oldValue.Nid, nil
  10655. }
  10656. // AddNid adds u to the "nid" field.
  10657. func (m *CreditUsageMutation) AddNid(u int64) {
  10658. if m.addnid != nil {
  10659. *m.addnid += u
  10660. } else {
  10661. m.addnid = &u
  10662. }
  10663. }
  10664. // AddedNid returns the value that was added to the "nid" field in this mutation.
  10665. func (m *CreditUsageMutation) AddedNid() (r int64, exists bool) {
  10666. v := m.addnid
  10667. if v == nil {
  10668. return
  10669. }
  10670. return *v, true
  10671. }
  10672. // ResetNid resets all changes to the "nid" field.
  10673. func (m *CreditUsageMutation) ResetNid() {
  10674. m.nid = nil
  10675. m.addnid = nil
  10676. }
  10677. // SetReason sets the "reason" field.
  10678. func (m *CreditUsageMutation) SetReason(s string) {
  10679. m.reason = &s
  10680. }
  10681. // Reason returns the value of the "reason" field in the mutation.
  10682. func (m *CreditUsageMutation) Reason() (r string, exists bool) {
  10683. v := m.reason
  10684. if v == nil {
  10685. return
  10686. }
  10687. return *v, true
  10688. }
  10689. // OldReason returns the old "reason" field's value of the CreditUsage entity.
  10690. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10691. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10692. func (m *CreditUsageMutation) OldReason(ctx context.Context) (v string, err error) {
  10693. if !m.op.Is(OpUpdateOne) {
  10694. return v, errors.New("OldReason is only allowed on UpdateOne operations")
  10695. }
  10696. if m.id == nil || m.oldValue == nil {
  10697. return v, errors.New("OldReason requires an ID field in the mutation")
  10698. }
  10699. oldValue, err := m.oldValue(ctx)
  10700. if err != nil {
  10701. return v, fmt.Errorf("querying old value for OldReason: %w", err)
  10702. }
  10703. return oldValue.Reason, nil
  10704. }
  10705. // ResetReason resets all changes to the "reason" field.
  10706. func (m *CreditUsageMutation) ResetReason() {
  10707. m.reason = nil
  10708. }
  10709. // SetOperator sets the "operator" field.
  10710. func (m *CreditUsageMutation) SetOperator(s string) {
  10711. m.operator = &s
  10712. }
  10713. // Operator returns the value of the "operator" field in the mutation.
  10714. func (m *CreditUsageMutation) Operator() (r string, exists bool) {
  10715. v := m.operator
  10716. if v == nil {
  10717. return
  10718. }
  10719. return *v, true
  10720. }
  10721. // OldOperator returns the old "operator" field's value of the CreditUsage entity.
  10722. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10723. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10724. func (m *CreditUsageMutation) OldOperator(ctx context.Context) (v string, err error) {
  10725. if !m.op.Is(OpUpdateOne) {
  10726. return v, errors.New("OldOperator is only allowed on UpdateOne operations")
  10727. }
  10728. if m.id == nil || m.oldValue == nil {
  10729. return v, errors.New("OldOperator requires an ID field in the mutation")
  10730. }
  10731. oldValue, err := m.oldValue(ctx)
  10732. if err != nil {
  10733. return v, fmt.Errorf("querying old value for OldOperator: %w", err)
  10734. }
  10735. return oldValue.Operator, nil
  10736. }
  10737. // ResetOperator resets all changes to the "operator" field.
  10738. func (m *CreditUsageMutation) ResetOperator() {
  10739. m.operator = nil
  10740. }
  10741. // Where appends a list predicates to the CreditUsageMutation builder.
  10742. func (m *CreditUsageMutation) Where(ps ...predicate.CreditUsage) {
  10743. m.predicates = append(m.predicates, ps...)
  10744. }
  10745. // WhereP appends storage-level predicates to the CreditUsageMutation builder. Using this method,
  10746. // users can use type-assertion to append predicates that do not depend on any generated package.
  10747. func (m *CreditUsageMutation) WhereP(ps ...func(*sql.Selector)) {
  10748. p := make([]predicate.CreditUsage, len(ps))
  10749. for i := range ps {
  10750. p[i] = ps[i]
  10751. }
  10752. m.Where(p...)
  10753. }
  10754. // Op returns the operation name.
  10755. func (m *CreditUsageMutation) Op() Op {
  10756. return m.op
  10757. }
  10758. // SetOp allows setting the mutation operation.
  10759. func (m *CreditUsageMutation) SetOp(op Op) {
  10760. m.op = op
  10761. }
  10762. // Type returns the node type of this mutation (CreditUsage).
  10763. func (m *CreditUsageMutation) Type() string {
  10764. return m.typ
  10765. }
  10766. // Fields returns all fields that were changed during this mutation. Note that in
  10767. // order to get all numeric fields that were incremented/decremented, call
  10768. // AddedFields().
  10769. func (m *CreditUsageMutation) Fields() []string {
  10770. fields := make([]string, 0, 12)
  10771. if m.created_at != nil {
  10772. fields = append(fields, creditusage.FieldCreatedAt)
  10773. }
  10774. if m.updated_at != nil {
  10775. fields = append(fields, creditusage.FieldUpdatedAt)
  10776. }
  10777. if m.deleted_at != nil {
  10778. fields = append(fields, creditusage.FieldDeletedAt)
  10779. }
  10780. if m.user_id != nil {
  10781. fields = append(fields, creditusage.FieldUserID)
  10782. }
  10783. if m.number != nil {
  10784. fields = append(fields, creditusage.FieldNumber)
  10785. }
  10786. if m.status != nil {
  10787. fields = append(fields, creditusage.FieldStatus)
  10788. }
  10789. if m.ntype != nil {
  10790. fields = append(fields, creditusage.FieldNtype)
  10791. }
  10792. if m.table != nil {
  10793. fields = append(fields, creditusage.FieldTable)
  10794. }
  10795. if m.organization_id != nil {
  10796. fields = append(fields, creditusage.FieldOrganizationID)
  10797. }
  10798. if m.nid != nil {
  10799. fields = append(fields, creditusage.FieldNid)
  10800. }
  10801. if m.reason != nil {
  10802. fields = append(fields, creditusage.FieldReason)
  10803. }
  10804. if m.operator != nil {
  10805. fields = append(fields, creditusage.FieldOperator)
  10806. }
  10807. return fields
  10808. }
  10809. // Field returns the value of a field with the given name. The second boolean
  10810. // return value indicates that this field was not set, or was not defined in the
  10811. // schema.
  10812. func (m *CreditUsageMutation) Field(name string) (ent.Value, bool) {
  10813. switch name {
  10814. case creditusage.FieldCreatedAt:
  10815. return m.CreatedAt()
  10816. case creditusage.FieldUpdatedAt:
  10817. return m.UpdatedAt()
  10818. case creditusage.FieldDeletedAt:
  10819. return m.DeletedAt()
  10820. case creditusage.FieldUserID:
  10821. return m.UserID()
  10822. case creditusage.FieldNumber:
  10823. return m.Number()
  10824. case creditusage.FieldStatus:
  10825. return m.Status()
  10826. case creditusage.FieldNtype:
  10827. return m.Ntype()
  10828. case creditusage.FieldTable:
  10829. return m.Table()
  10830. case creditusage.FieldOrganizationID:
  10831. return m.OrganizationID()
  10832. case creditusage.FieldNid:
  10833. return m.Nid()
  10834. case creditusage.FieldReason:
  10835. return m.Reason()
  10836. case creditusage.FieldOperator:
  10837. return m.Operator()
  10838. }
  10839. return nil, false
  10840. }
  10841. // OldField returns the old value of the field from the database. An error is
  10842. // returned if the mutation operation is not UpdateOne, or the query to the
  10843. // database failed.
  10844. func (m *CreditUsageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  10845. switch name {
  10846. case creditusage.FieldCreatedAt:
  10847. return m.OldCreatedAt(ctx)
  10848. case creditusage.FieldUpdatedAt:
  10849. return m.OldUpdatedAt(ctx)
  10850. case creditusage.FieldDeletedAt:
  10851. return m.OldDeletedAt(ctx)
  10852. case creditusage.FieldUserID:
  10853. return m.OldUserID(ctx)
  10854. case creditusage.FieldNumber:
  10855. return m.OldNumber(ctx)
  10856. case creditusage.FieldStatus:
  10857. return m.OldStatus(ctx)
  10858. case creditusage.FieldNtype:
  10859. return m.OldNtype(ctx)
  10860. case creditusage.FieldTable:
  10861. return m.OldTable(ctx)
  10862. case creditusage.FieldOrganizationID:
  10863. return m.OldOrganizationID(ctx)
  10864. case creditusage.FieldNid:
  10865. return m.OldNid(ctx)
  10866. case creditusage.FieldReason:
  10867. return m.OldReason(ctx)
  10868. case creditusage.FieldOperator:
  10869. return m.OldOperator(ctx)
  10870. }
  10871. return nil, fmt.Errorf("unknown CreditUsage field %s", name)
  10872. }
  10873. // SetField sets the value of a field with the given name. It returns an error if
  10874. // the field is not defined in the schema, or if the type mismatched the field
  10875. // type.
  10876. func (m *CreditUsageMutation) SetField(name string, value ent.Value) error {
  10877. switch name {
  10878. case creditusage.FieldCreatedAt:
  10879. v, ok := value.(time.Time)
  10880. if !ok {
  10881. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10882. }
  10883. m.SetCreatedAt(v)
  10884. return nil
  10885. case creditusage.FieldUpdatedAt:
  10886. v, ok := value.(time.Time)
  10887. if !ok {
  10888. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10889. }
  10890. m.SetUpdatedAt(v)
  10891. return nil
  10892. case creditusage.FieldDeletedAt:
  10893. v, ok := value.(time.Time)
  10894. if !ok {
  10895. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10896. }
  10897. m.SetDeletedAt(v)
  10898. return nil
  10899. case creditusage.FieldUserID:
  10900. v, ok := value.(string)
  10901. if !ok {
  10902. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10903. }
  10904. m.SetUserID(v)
  10905. return nil
  10906. case creditusage.FieldNumber:
  10907. v, ok := value.(float32)
  10908. if !ok {
  10909. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10910. }
  10911. m.SetNumber(v)
  10912. return nil
  10913. case creditusage.FieldStatus:
  10914. v, ok := value.(int)
  10915. if !ok {
  10916. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10917. }
  10918. m.SetStatus(v)
  10919. return nil
  10920. case creditusage.FieldNtype:
  10921. v, ok := value.(int)
  10922. if !ok {
  10923. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10924. }
  10925. m.SetNtype(v)
  10926. return nil
  10927. case creditusage.FieldTable:
  10928. v, ok := value.(string)
  10929. if !ok {
  10930. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10931. }
  10932. m.SetTable(v)
  10933. return nil
  10934. case creditusage.FieldOrganizationID:
  10935. v, ok := value.(uint64)
  10936. if !ok {
  10937. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10938. }
  10939. m.SetOrganizationID(v)
  10940. return nil
  10941. case creditusage.FieldNid:
  10942. v, ok := value.(uint64)
  10943. if !ok {
  10944. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10945. }
  10946. m.SetNid(v)
  10947. return nil
  10948. case creditusage.FieldReason:
  10949. v, ok := value.(string)
  10950. if !ok {
  10951. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10952. }
  10953. m.SetReason(v)
  10954. return nil
  10955. case creditusage.FieldOperator:
  10956. v, ok := value.(string)
  10957. if !ok {
  10958. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10959. }
  10960. m.SetOperator(v)
  10961. return nil
  10962. }
  10963. return fmt.Errorf("unknown CreditUsage field %s", name)
  10964. }
  10965. // AddedFields returns all numeric fields that were incremented/decremented during
  10966. // this mutation.
  10967. func (m *CreditUsageMutation) AddedFields() []string {
  10968. var fields []string
  10969. if m.addnumber != nil {
  10970. fields = append(fields, creditusage.FieldNumber)
  10971. }
  10972. if m.addstatus != nil {
  10973. fields = append(fields, creditusage.FieldStatus)
  10974. }
  10975. if m.addntype != nil {
  10976. fields = append(fields, creditusage.FieldNtype)
  10977. }
  10978. if m.addorganization_id != nil {
  10979. fields = append(fields, creditusage.FieldOrganizationID)
  10980. }
  10981. if m.addnid != nil {
  10982. fields = append(fields, creditusage.FieldNid)
  10983. }
  10984. return fields
  10985. }
  10986. // AddedField returns the numeric value that was incremented/decremented on a field
  10987. // with the given name. The second boolean return value indicates that this field
  10988. // was not set, or was not defined in the schema.
  10989. func (m *CreditUsageMutation) AddedField(name string) (ent.Value, bool) {
  10990. switch name {
  10991. case creditusage.FieldNumber:
  10992. return m.AddedNumber()
  10993. case creditusage.FieldStatus:
  10994. return m.AddedStatus()
  10995. case creditusage.FieldNtype:
  10996. return m.AddedNtype()
  10997. case creditusage.FieldOrganizationID:
  10998. return m.AddedOrganizationID()
  10999. case creditusage.FieldNid:
  11000. return m.AddedNid()
  11001. }
  11002. return nil, false
  11003. }
  11004. // AddField adds the value to the field with the given name. It returns an error if
  11005. // the field is not defined in the schema, or if the type mismatched the field
  11006. // type.
  11007. func (m *CreditUsageMutation) AddField(name string, value ent.Value) error {
  11008. switch name {
  11009. case creditusage.FieldNumber:
  11010. v, ok := value.(float32)
  11011. if !ok {
  11012. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11013. }
  11014. m.AddNumber(v)
  11015. return nil
  11016. case creditusage.FieldStatus:
  11017. v, ok := value.(int)
  11018. if !ok {
  11019. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11020. }
  11021. m.AddStatus(v)
  11022. return nil
  11023. case creditusage.FieldNtype:
  11024. v, ok := value.(int)
  11025. if !ok {
  11026. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11027. }
  11028. m.AddNtype(v)
  11029. return nil
  11030. case creditusage.FieldOrganizationID:
  11031. v, ok := value.(int64)
  11032. if !ok {
  11033. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11034. }
  11035. m.AddOrganizationID(v)
  11036. return nil
  11037. case creditusage.FieldNid:
  11038. v, ok := value.(int64)
  11039. if !ok {
  11040. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11041. }
  11042. m.AddNid(v)
  11043. return nil
  11044. }
  11045. return fmt.Errorf("unknown CreditUsage numeric field %s", name)
  11046. }
  11047. // ClearedFields returns all nullable fields that were cleared during this
  11048. // mutation.
  11049. func (m *CreditUsageMutation) ClearedFields() []string {
  11050. var fields []string
  11051. if m.FieldCleared(creditusage.FieldDeletedAt) {
  11052. fields = append(fields, creditusage.FieldDeletedAt)
  11053. }
  11054. if m.FieldCleared(creditusage.FieldStatus) {
  11055. fields = append(fields, creditusage.FieldStatus)
  11056. }
  11057. if m.FieldCleared(creditusage.FieldOrganizationID) {
  11058. fields = append(fields, creditusage.FieldOrganizationID)
  11059. }
  11060. return fields
  11061. }
  11062. // FieldCleared returns a boolean indicating if a field with the given name was
  11063. // cleared in this mutation.
  11064. func (m *CreditUsageMutation) FieldCleared(name string) bool {
  11065. _, ok := m.clearedFields[name]
  11066. return ok
  11067. }
  11068. // ClearField clears the value of the field with the given name. It returns an
  11069. // error if the field is not defined in the schema.
  11070. func (m *CreditUsageMutation) ClearField(name string) error {
  11071. switch name {
  11072. case creditusage.FieldDeletedAt:
  11073. m.ClearDeletedAt()
  11074. return nil
  11075. case creditusage.FieldStatus:
  11076. m.ClearStatus()
  11077. return nil
  11078. case creditusage.FieldOrganizationID:
  11079. m.ClearOrganizationID()
  11080. return nil
  11081. }
  11082. return fmt.Errorf("unknown CreditUsage nullable field %s", name)
  11083. }
  11084. // ResetField resets all changes in the mutation for the field with the given name.
  11085. // It returns an error if the field is not defined in the schema.
  11086. func (m *CreditUsageMutation) ResetField(name string) error {
  11087. switch name {
  11088. case creditusage.FieldCreatedAt:
  11089. m.ResetCreatedAt()
  11090. return nil
  11091. case creditusage.FieldUpdatedAt:
  11092. m.ResetUpdatedAt()
  11093. return nil
  11094. case creditusage.FieldDeletedAt:
  11095. m.ResetDeletedAt()
  11096. return nil
  11097. case creditusage.FieldUserID:
  11098. m.ResetUserID()
  11099. return nil
  11100. case creditusage.FieldNumber:
  11101. m.ResetNumber()
  11102. return nil
  11103. case creditusage.FieldStatus:
  11104. m.ResetStatus()
  11105. return nil
  11106. case creditusage.FieldNtype:
  11107. m.ResetNtype()
  11108. return nil
  11109. case creditusage.FieldTable:
  11110. m.ResetTable()
  11111. return nil
  11112. case creditusage.FieldOrganizationID:
  11113. m.ResetOrganizationID()
  11114. return nil
  11115. case creditusage.FieldNid:
  11116. m.ResetNid()
  11117. return nil
  11118. case creditusage.FieldReason:
  11119. m.ResetReason()
  11120. return nil
  11121. case creditusage.FieldOperator:
  11122. m.ResetOperator()
  11123. return nil
  11124. }
  11125. return fmt.Errorf("unknown CreditUsage field %s", name)
  11126. }
  11127. // AddedEdges returns all edge names that were set/added in this mutation.
  11128. func (m *CreditUsageMutation) AddedEdges() []string {
  11129. edges := make([]string, 0, 0)
  11130. return edges
  11131. }
  11132. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  11133. // name in this mutation.
  11134. func (m *CreditUsageMutation) AddedIDs(name string) []ent.Value {
  11135. return nil
  11136. }
  11137. // RemovedEdges returns all edge names that were removed in this mutation.
  11138. func (m *CreditUsageMutation) RemovedEdges() []string {
  11139. edges := make([]string, 0, 0)
  11140. return edges
  11141. }
  11142. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  11143. // the given name in this mutation.
  11144. func (m *CreditUsageMutation) RemovedIDs(name string) []ent.Value {
  11145. return nil
  11146. }
  11147. // ClearedEdges returns all edge names that were cleared in this mutation.
  11148. func (m *CreditUsageMutation) ClearedEdges() []string {
  11149. edges := make([]string, 0, 0)
  11150. return edges
  11151. }
  11152. // EdgeCleared returns a boolean which indicates if the edge with the given name
  11153. // was cleared in this mutation.
  11154. func (m *CreditUsageMutation) EdgeCleared(name string) bool {
  11155. return false
  11156. }
  11157. // ClearEdge clears the value of the edge with the given name. It returns an error
  11158. // if that edge is not defined in the schema.
  11159. func (m *CreditUsageMutation) ClearEdge(name string) error {
  11160. return fmt.Errorf("unknown CreditUsage unique edge %s", name)
  11161. }
  11162. // ResetEdge resets all changes to the edge with the given name in this mutation.
  11163. // It returns an error if the edge is not defined in the schema.
  11164. func (m *CreditUsageMutation) ResetEdge(name string) error {
  11165. return fmt.Errorf("unknown CreditUsage edge %s", name)
  11166. }
  11167. // EmployeeMutation represents an operation that mutates the Employee nodes in the graph.
  11168. type EmployeeMutation struct {
  11169. config
  11170. op Op
  11171. typ string
  11172. id *uint64
  11173. created_at *time.Time
  11174. updated_at *time.Time
  11175. deleted_at *time.Time
  11176. title *string
  11177. avatar *string
  11178. tags *string
  11179. hire_count *int
  11180. addhire_count *int
  11181. service_count *int
  11182. addservice_count *int
  11183. achievement_count *int
  11184. addachievement_count *int
  11185. intro *string
  11186. estimate *string
  11187. skill *string
  11188. ability_type *string
  11189. scene *string
  11190. switch_in *string
  11191. video_url *string
  11192. organization_id *uint64
  11193. addorganization_id *int64
  11194. category_id *uint64
  11195. addcategory_id *int64
  11196. api_base *string
  11197. api_key *string
  11198. ai_info *string
  11199. is_vip *int
  11200. addis_vip *int
  11201. chat_url *string
  11202. clearedFields map[string]struct{}
  11203. em_work_experiences map[uint64]struct{}
  11204. removedem_work_experiences map[uint64]struct{}
  11205. clearedem_work_experiences bool
  11206. em_tutorial map[uint64]struct{}
  11207. removedem_tutorial map[uint64]struct{}
  11208. clearedem_tutorial bool
  11209. done bool
  11210. oldValue func(context.Context) (*Employee, error)
  11211. predicates []predicate.Employee
  11212. }
  11213. var _ ent.Mutation = (*EmployeeMutation)(nil)
  11214. // employeeOption allows management of the mutation configuration using functional options.
  11215. type employeeOption func(*EmployeeMutation)
  11216. // newEmployeeMutation creates new mutation for the Employee entity.
  11217. func newEmployeeMutation(c config, op Op, opts ...employeeOption) *EmployeeMutation {
  11218. m := &EmployeeMutation{
  11219. config: c,
  11220. op: op,
  11221. typ: TypeEmployee,
  11222. clearedFields: make(map[string]struct{}),
  11223. }
  11224. for _, opt := range opts {
  11225. opt(m)
  11226. }
  11227. return m
  11228. }
  11229. // withEmployeeID sets the ID field of the mutation.
  11230. func withEmployeeID(id uint64) employeeOption {
  11231. return func(m *EmployeeMutation) {
  11232. var (
  11233. err error
  11234. once sync.Once
  11235. value *Employee
  11236. )
  11237. m.oldValue = func(ctx context.Context) (*Employee, error) {
  11238. once.Do(func() {
  11239. if m.done {
  11240. err = errors.New("querying old values post mutation is not allowed")
  11241. } else {
  11242. value, err = m.Client().Employee.Get(ctx, id)
  11243. }
  11244. })
  11245. return value, err
  11246. }
  11247. m.id = &id
  11248. }
  11249. }
  11250. // withEmployee sets the old Employee of the mutation.
  11251. func withEmployee(node *Employee) employeeOption {
  11252. return func(m *EmployeeMutation) {
  11253. m.oldValue = func(context.Context) (*Employee, error) {
  11254. return node, nil
  11255. }
  11256. m.id = &node.ID
  11257. }
  11258. }
  11259. // Client returns a new `ent.Client` from the mutation. If the mutation was
  11260. // executed in a transaction (ent.Tx), a transactional client is returned.
  11261. func (m EmployeeMutation) Client() *Client {
  11262. client := &Client{config: m.config}
  11263. client.init()
  11264. return client
  11265. }
  11266. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  11267. // it returns an error otherwise.
  11268. func (m EmployeeMutation) Tx() (*Tx, error) {
  11269. if _, ok := m.driver.(*txDriver); !ok {
  11270. return nil, errors.New("ent: mutation is not running in a transaction")
  11271. }
  11272. tx := &Tx{config: m.config}
  11273. tx.init()
  11274. return tx, nil
  11275. }
  11276. // SetID sets the value of the id field. Note that this
  11277. // operation is only accepted on creation of Employee entities.
  11278. func (m *EmployeeMutation) SetID(id uint64) {
  11279. m.id = &id
  11280. }
  11281. // ID returns the ID value in the mutation. Note that the ID is only available
  11282. // if it was provided to the builder or after it was returned from the database.
  11283. func (m *EmployeeMutation) ID() (id uint64, exists bool) {
  11284. if m.id == nil {
  11285. return
  11286. }
  11287. return *m.id, true
  11288. }
  11289. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  11290. // That means, if the mutation is applied within a transaction with an isolation level such
  11291. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  11292. // or updated by the mutation.
  11293. func (m *EmployeeMutation) IDs(ctx context.Context) ([]uint64, error) {
  11294. switch {
  11295. case m.op.Is(OpUpdateOne | OpDeleteOne):
  11296. id, exists := m.ID()
  11297. if exists {
  11298. return []uint64{id}, nil
  11299. }
  11300. fallthrough
  11301. case m.op.Is(OpUpdate | OpDelete):
  11302. return m.Client().Employee.Query().Where(m.predicates...).IDs(ctx)
  11303. default:
  11304. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  11305. }
  11306. }
  11307. // SetCreatedAt sets the "created_at" field.
  11308. func (m *EmployeeMutation) SetCreatedAt(t time.Time) {
  11309. m.created_at = &t
  11310. }
  11311. // CreatedAt returns the value of the "created_at" field in the mutation.
  11312. func (m *EmployeeMutation) CreatedAt() (r time.Time, exists bool) {
  11313. v := m.created_at
  11314. if v == nil {
  11315. return
  11316. }
  11317. return *v, true
  11318. }
  11319. // OldCreatedAt returns the old "created_at" field's value of the Employee entity.
  11320. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11321. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11322. func (m *EmployeeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  11323. if !m.op.Is(OpUpdateOne) {
  11324. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  11325. }
  11326. if m.id == nil || m.oldValue == nil {
  11327. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  11328. }
  11329. oldValue, err := m.oldValue(ctx)
  11330. if err != nil {
  11331. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  11332. }
  11333. return oldValue.CreatedAt, nil
  11334. }
  11335. // ResetCreatedAt resets all changes to the "created_at" field.
  11336. func (m *EmployeeMutation) ResetCreatedAt() {
  11337. m.created_at = nil
  11338. }
  11339. // SetUpdatedAt sets the "updated_at" field.
  11340. func (m *EmployeeMutation) SetUpdatedAt(t time.Time) {
  11341. m.updated_at = &t
  11342. }
  11343. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  11344. func (m *EmployeeMutation) UpdatedAt() (r time.Time, exists bool) {
  11345. v := m.updated_at
  11346. if v == nil {
  11347. return
  11348. }
  11349. return *v, true
  11350. }
  11351. // OldUpdatedAt returns the old "updated_at" field's value of the Employee entity.
  11352. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11353. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11354. func (m *EmployeeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  11355. if !m.op.Is(OpUpdateOne) {
  11356. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  11357. }
  11358. if m.id == nil || m.oldValue == nil {
  11359. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  11360. }
  11361. oldValue, err := m.oldValue(ctx)
  11362. if err != nil {
  11363. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  11364. }
  11365. return oldValue.UpdatedAt, nil
  11366. }
  11367. // ResetUpdatedAt resets all changes to the "updated_at" field.
  11368. func (m *EmployeeMutation) ResetUpdatedAt() {
  11369. m.updated_at = nil
  11370. }
  11371. // SetDeletedAt sets the "deleted_at" field.
  11372. func (m *EmployeeMutation) SetDeletedAt(t time.Time) {
  11373. m.deleted_at = &t
  11374. }
  11375. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  11376. func (m *EmployeeMutation) DeletedAt() (r time.Time, exists bool) {
  11377. v := m.deleted_at
  11378. if v == nil {
  11379. return
  11380. }
  11381. return *v, true
  11382. }
  11383. // OldDeletedAt returns the old "deleted_at" field's value of the Employee entity.
  11384. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11385. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11386. func (m *EmployeeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  11387. if !m.op.Is(OpUpdateOne) {
  11388. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  11389. }
  11390. if m.id == nil || m.oldValue == nil {
  11391. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  11392. }
  11393. oldValue, err := m.oldValue(ctx)
  11394. if err != nil {
  11395. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  11396. }
  11397. return oldValue.DeletedAt, nil
  11398. }
  11399. // ClearDeletedAt clears the value of the "deleted_at" field.
  11400. func (m *EmployeeMutation) ClearDeletedAt() {
  11401. m.deleted_at = nil
  11402. m.clearedFields[employee.FieldDeletedAt] = struct{}{}
  11403. }
  11404. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  11405. func (m *EmployeeMutation) DeletedAtCleared() bool {
  11406. _, ok := m.clearedFields[employee.FieldDeletedAt]
  11407. return ok
  11408. }
  11409. // ResetDeletedAt resets all changes to the "deleted_at" field.
  11410. func (m *EmployeeMutation) ResetDeletedAt() {
  11411. m.deleted_at = nil
  11412. delete(m.clearedFields, employee.FieldDeletedAt)
  11413. }
  11414. // SetTitle sets the "title" field.
  11415. func (m *EmployeeMutation) SetTitle(s string) {
  11416. m.title = &s
  11417. }
  11418. // Title returns the value of the "title" field in the mutation.
  11419. func (m *EmployeeMutation) Title() (r string, exists bool) {
  11420. v := m.title
  11421. if v == nil {
  11422. return
  11423. }
  11424. return *v, true
  11425. }
  11426. // OldTitle returns the old "title" field's value of the Employee entity.
  11427. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11428. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11429. func (m *EmployeeMutation) OldTitle(ctx context.Context) (v string, err error) {
  11430. if !m.op.Is(OpUpdateOne) {
  11431. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  11432. }
  11433. if m.id == nil || m.oldValue == nil {
  11434. return v, errors.New("OldTitle requires an ID field in the mutation")
  11435. }
  11436. oldValue, err := m.oldValue(ctx)
  11437. if err != nil {
  11438. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  11439. }
  11440. return oldValue.Title, nil
  11441. }
  11442. // ResetTitle resets all changes to the "title" field.
  11443. func (m *EmployeeMutation) ResetTitle() {
  11444. m.title = nil
  11445. }
  11446. // SetAvatar sets the "avatar" field.
  11447. func (m *EmployeeMutation) SetAvatar(s string) {
  11448. m.avatar = &s
  11449. }
  11450. // Avatar returns the value of the "avatar" field in the mutation.
  11451. func (m *EmployeeMutation) Avatar() (r string, exists bool) {
  11452. v := m.avatar
  11453. if v == nil {
  11454. return
  11455. }
  11456. return *v, true
  11457. }
  11458. // OldAvatar returns the old "avatar" field's value of the Employee entity.
  11459. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11460. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11461. func (m *EmployeeMutation) OldAvatar(ctx context.Context) (v string, err error) {
  11462. if !m.op.Is(OpUpdateOne) {
  11463. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  11464. }
  11465. if m.id == nil || m.oldValue == nil {
  11466. return v, errors.New("OldAvatar requires an ID field in the mutation")
  11467. }
  11468. oldValue, err := m.oldValue(ctx)
  11469. if err != nil {
  11470. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  11471. }
  11472. return oldValue.Avatar, nil
  11473. }
  11474. // ResetAvatar resets all changes to the "avatar" field.
  11475. func (m *EmployeeMutation) ResetAvatar() {
  11476. m.avatar = nil
  11477. }
  11478. // SetTags sets the "tags" field.
  11479. func (m *EmployeeMutation) SetTags(s string) {
  11480. m.tags = &s
  11481. }
  11482. // Tags returns the value of the "tags" field in the mutation.
  11483. func (m *EmployeeMutation) Tags() (r string, exists bool) {
  11484. v := m.tags
  11485. if v == nil {
  11486. return
  11487. }
  11488. return *v, true
  11489. }
  11490. // OldTags returns the old "tags" field's value of the Employee entity.
  11491. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11492. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11493. func (m *EmployeeMutation) OldTags(ctx context.Context) (v string, err error) {
  11494. if !m.op.Is(OpUpdateOne) {
  11495. return v, errors.New("OldTags is only allowed on UpdateOne operations")
  11496. }
  11497. if m.id == nil || m.oldValue == nil {
  11498. return v, errors.New("OldTags requires an ID field in the mutation")
  11499. }
  11500. oldValue, err := m.oldValue(ctx)
  11501. if err != nil {
  11502. return v, fmt.Errorf("querying old value for OldTags: %w", err)
  11503. }
  11504. return oldValue.Tags, nil
  11505. }
  11506. // ResetTags resets all changes to the "tags" field.
  11507. func (m *EmployeeMutation) ResetTags() {
  11508. m.tags = nil
  11509. }
  11510. // SetHireCount sets the "hire_count" field.
  11511. func (m *EmployeeMutation) SetHireCount(i int) {
  11512. m.hire_count = &i
  11513. m.addhire_count = nil
  11514. }
  11515. // HireCount returns the value of the "hire_count" field in the mutation.
  11516. func (m *EmployeeMutation) HireCount() (r int, exists bool) {
  11517. v := m.hire_count
  11518. if v == nil {
  11519. return
  11520. }
  11521. return *v, true
  11522. }
  11523. // OldHireCount returns the old "hire_count" field's value of the Employee entity.
  11524. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11525. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11526. func (m *EmployeeMutation) OldHireCount(ctx context.Context) (v int, err error) {
  11527. if !m.op.Is(OpUpdateOne) {
  11528. return v, errors.New("OldHireCount is only allowed on UpdateOne operations")
  11529. }
  11530. if m.id == nil || m.oldValue == nil {
  11531. return v, errors.New("OldHireCount requires an ID field in the mutation")
  11532. }
  11533. oldValue, err := m.oldValue(ctx)
  11534. if err != nil {
  11535. return v, fmt.Errorf("querying old value for OldHireCount: %w", err)
  11536. }
  11537. return oldValue.HireCount, nil
  11538. }
  11539. // AddHireCount adds i to the "hire_count" field.
  11540. func (m *EmployeeMutation) AddHireCount(i int) {
  11541. if m.addhire_count != nil {
  11542. *m.addhire_count += i
  11543. } else {
  11544. m.addhire_count = &i
  11545. }
  11546. }
  11547. // AddedHireCount returns the value that was added to the "hire_count" field in this mutation.
  11548. func (m *EmployeeMutation) AddedHireCount() (r int, exists bool) {
  11549. v := m.addhire_count
  11550. if v == nil {
  11551. return
  11552. }
  11553. return *v, true
  11554. }
  11555. // ResetHireCount resets all changes to the "hire_count" field.
  11556. func (m *EmployeeMutation) ResetHireCount() {
  11557. m.hire_count = nil
  11558. m.addhire_count = nil
  11559. }
  11560. // SetServiceCount sets the "service_count" field.
  11561. func (m *EmployeeMutation) SetServiceCount(i int) {
  11562. m.service_count = &i
  11563. m.addservice_count = nil
  11564. }
  11565. // ServiceCount returns the value of the "service_count" field in the mutation.
  11566. func (m *EmployeeMutation) ServiceCount() (r int, exists bool) {
  11567. v := m.service_count
  11568. if v == nil {
  11569. return
  11570. }
  11571. return *v, true
  11572. }
  11573. // OldServiceCount returns the old "service_count" field's value of the Employee entity.
  11574. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11575. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11576. func (m *EmployeeMutation) OldServiceCount(ctx context.Context) (v int, err error) {
  11577. if !m.op.Is(OpUpdateOne) {
  11578. return v, errors.New("OldServiceCount is only allowed on UpdateOne operations")
  11579. }
  11580. if m.id == nil || m.oldValue == nil {
  11581. return v, errors.New("OldServiceCount requires an ID field in the mutation")
  11582. }
  11583. oldValue, err := m.oldValue(ctx)
  11584. if err != nil {
  11585. return v, fmt.Errorf("querying old value for OldServiceCount: %w", err)
  11586. }
  11587. return oldValue.ServiceCount, nil
  11588. }
  11589. // AddServiceCount adds i to the "service_count" field.
  11590. func (m *EmployeeMutation) AddServiceCount(i int) {
  11591. if m.addservice_count != nil {
  11592. *m.addservice_count += i
  11593. } else {
  11594. m.addservice_count = &i
  11595. }
  11596. }
  11597. // AddedServiceCount returns the value that was added to the "service_count" field in this mutation.
  11598. func (m *EmployeeMutation) AddedServiceCount() (r int, exists bool) {
  11599. v := m.addservice_count
  11600. if v == nil {
  11601. return
  11602. }
  11603. return *v, true
  11604. }
  11605. // ResetServiceCount resets all changes to the "service_count" field.
  11606. func (m *EmployeeMutation) ResetServiceCount() {
  11607. m.service_count = nil
  11608. m.addservice_count = nil
  11609. }
  11610. // SetAchievementCount sets the "achievement_count" field.
  11611. func (m *EmployeeMutation) SetAchievementCount(i int) {
  11612. m.achievement_count = &i
  11613. m.addachievement_count = nil
  11614. }
  11615. // AchievementCount returns the value of the "achievement_count" field in the mutation.
  11616. func (m *EmployeeMutation) AchievementCount() (r int, exists bool) {
  11617. v := m.achievement_count
  11618. if v == nil {
  11619. return
  11620. }
  11621. return *v, true
  11622. }
  11623. // OldAchievementCount returns the old "achievement_count" field's value of the Employee entity.
  11624. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11625. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11626. func (m *EmployeeMutation) OldAchievementCount(ctx context.Context) (v int, err error) {
  11627. if !m.op.Is(OpUpdateOne) {
  11628. return v, errors.New("OldAchievementCount is only allowed on UpdateOne operations")
  11629. }
  11630. if m.id == nil || m.oldValue == nil {
  11631. return v, errors.New("OldAchievementCount requires an ID field in the mutation")
  11632. }
  11633. oldValue, err := m.oldValue(ctx)
  11634. if err != nil {
  11635. return v, fmt.Errorf("querying old value for OldAchievementCount: %w", err)
  11636. }
  11637. return oldValue.AchievementCount, nil
  11638. }
  11639. // AddAchievementCount adds i to the "achievement_count" field.
  11640. func (m *EmployeeMutation) AddAchievementCount(i int) {
  11641. if m.addachievement_count != nil {
  11642. *m.addachievement_count += i
  11643. } else {
  11644. m.addachievement_count = &i
  11645. }
  11646. }
  11647. // AddedAchievementCount returns the value that was added to the "achievement_count" field in this mutation.
  11648. func (m *EmployeeMutation) AddedAchievementCount() (r int, exists bool) {
  11649. v := m.addachievement_count
  11650. if v == nil {
  11651. return
  11652. }
  11653. return *v, true
  11654. }
  11655. // ResetAchievementCount resets all changes to the "achievement_count" field.
  11656. func (m *EmployeeMutation) ResetAchievementCount() {
  11657. m.achievement_count = nil
  11658. m.addachievement_count = nil
  11659. }
  11660. // SetIntro sets the "intro" field.
  11661. func (m *EmployeeMutation) SetIntro(s string) {
  11662. m.intro = &s
  11663. }
  11664. // Intro returns the value of the "intro" field in the mutation.
  11665. func (m *EmployeeMutation) Intro() (r string, exists bool) {
  11666. v := m.intro
  11667. if v == nil {
  11668. return
  11669. }
  11670. return *v, true
  11671. }
  11672. // OldIntro returns the old "intro" field's value of the Employee entity.
  11673. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11674. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11675. func (m *EmployeeMutation) OldIntro(ctx context.Context) (v string, err error) {
  11676. if !m.op.Is(OpUpdateOne) {
  11677. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  11678. }
  11679. if m.id == nil || m.oldValue == nil {
  11680. return v, errors.New("OldIntro requires an ID field in the mutation")
  11681. }
  11682. oldValue, err := m.oldValue(ctx)
  11683. if err != nil {
  11684. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  11685. }
  11686. return oldValue.Intro, nil
  11687. }
  11688. // ResetIntro resets all changes to the "intro" field.
  11689. func (m *EmployeeMutation) ResetIntro() {
  11690. m.intro = nil
  11691. }
  11692. // SetEstimate sets the "estimate" field.
  11693. func (m *EmployeeMutation) SetEstimate(s string) {
  11694. m.estimate = &s
  11695. }
  11696. // Estimate returns the value of the "estimate" field in the mutation.
  11697. func (m *EmployeeMutation) Estimate() (r string, exists bool) {
  11698. v := m.estimate
  11699. if v == nil {
  11700. return
  11701. }
  11702. return *v, true
  11703. }
  11704. // OldEstimate returns the old "estimate" field's value of the Employee entity.
  11705. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11706. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11707. func (m *EmployeeMutation) OldEstimate(ctx context.Context) (v string, err error) {
  11708. if !m.op.Is(OpUpdateOne) {
  11709. return v, errors.New("OldEstimate is only allowed on UpdateOne operations")
  11710. }
  11711. if m.id == nil || m.oldValue == nil {
  11712. return v, errors.New("OldEstimate requires an ID field in the mutation")
  11713. }
  11714. oldValue, err := m.oldValue(ctx)
  11715. if err != nil {
  11716. return v, fmt.Errorf("querying old value for OldEstimate: %w", err)
  11717. }
  11718. return oldValue.Estimate, nil
  11719. }
  11720. // ResetEstimate resets all changes to the "estimate" field.
  11721. func (m *EmployeeMutation) ResetEstimate() {
  11722. m.estimate = nil
  11723. }
  11724. // SetSkill sets the "skill" field.
  11725. func (m *EmployeeMutation) SetSkill(s string) {
  11726. m.skill = &s
  11727. }
  11728. // Skill returns the value of the "skill" field in the mutation.
  11729. func (m *EmployeeMutation) Skill() (r string, exists bool) {
  11730. v := m.skill
  11731. if v == nil {
  11732. return
  11733. }
  11734. return *v, true
  11735. }
  11736. // OldSkill returns the old "skill" field's value of the Employee entity.
  11737. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11738. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11739. func (m *EmployeeMutation) OldSkill(ctx context.Context) (v string, err error) {
  11740. if !m.op.Is(OpUpdateOne) {
  11741. return v, errors.New("OldSkill is only allowed on UpdateOne operations")
  11742. }
  11743. if m.id == nil || m.oldValue == nil {
  11744. return v, errors.New("OldSkill requires an ID field in the mutation")
  11745. }
  11746. oldValue, err := m.oldValue(ctx)
  11747. if err != nil {
  11748. return v, fmt.Errorf("querying old value for OldSkill: %w", err)
  11749. }
  11750. return oldValue.Skill, nil
  11751. }
  11752. // ResetSkill resets all changes to the "skill" field.
  11753. func (m *EmployeeMutation) ResetSkill() {
  11754. m.skill = nil
  11755. }
  11756. // SetAbilityType sets the "ability_type" field.
  11757. func (m *EmployeeMutation) SetAbilityType(s string) {
  11758. m.ability_type = &s
  11759. }
  11760. // AbilityType returns the value of the "ability_type" field in the mutation.
  11761. func (m *EmployeeMutation) AbilityType() (r string, exists bool) {
  11762. v := m.ability_type
  11763. if v == nil {
  11764. return
  11765. }
  11766. return *v, true
  11767. }
  11768. // OldAbilityType returns the old "ability_type" field's value of the Employee entity.
  11769. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11770. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11771. func (m *EmployeeMutation) OldAbilityType(ctx context.Context) (v string, err error) {
  11772. if !m.op.Is(OpUpdateOne) {
  11773. return v, errors.New("OldAbilityType is only allowed on UpdateOne operations")
  11774. }
  11775. if m.id == nil || m.oldValue == nil {
  11776. return v, errors.New("OldAbilityType requires an ID field in the mutation")
  11777. }
  11778. oldValue, err := m.oldValue(ctx)
  11779. if err != nil {
  11780. return v, fmt.Errorf("querying old value for OldAbilityType: %w", err)
  11781. }
  11782. return oldValue.AbilityType, nil
  11783. }
  11784. // ResetAbilityType resets all changes to the "ability_type" field.
  11785. func (m *EmployeeMutation) ResetAbilityType() {
  11786. m.ability_type = nil
  11787. }
  11788. // SetScene sets the "scene" field.
  11789. func (m *EmployeeMutation) SetScene(s string) {
  11790. m.scene = &s
  11791. }
  11792. // Scene returns the value of the "scene" field in the mutation.
  11793. func (m *EmployeeMutation) Scene() (r string, exists bool) {
  11794. v := m.scene
  11795. if v == nil {
  11796. return
  11797. }
  11798. return *v, true
  11799. }
  11800. // OldScene returns the old "scene" field's value of the Employee entity.
  11801. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11802. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11803. func (m *EmployeeMutation) OldScene(ctx context.Context) (v string, err error) {
  11804. if !m.op.Is(OpUpdateOne) {
  11805. return v, errors.New("OldScene is only allowed on UpdateOne operations")
  11806. }
  11807. if m.id == nil || m.oldValue == nil {
  11808. return v, errors.New("OldScene requires an ID field in the mutation")
  11809. }
  11810. oldValue, err := m.oldValue(ctx)
  11811. if err != nil {
  11812. return v, fmt.Errorf("querying old value for OldScene: %w", err)
  11813. }
  11814. return oldValue.Scene, nil
  11815. }
  11816. // ResetScene resets all changes to the "scene" field.
  11817. func (m *EmployeeMutation) ResetScene() {
  11818. m.scene = nil
  11819. }
  11820. // SetSwitchIn sets the "switch_in" field.
  11821. func (m *EmployeeMutation) SetSwitchIn(s string) {
  11822. m.switch_in = &s
  11823. }
  11824. // SwitchIn returns the value of the "switch_in" field in the mutation.
  11825. func (m *EmployeeMutation) SwitchIn() (r string, exists bool) {
  11826. v := m.switch_in
  11827. if v == nil {
  11828. return
  11829. }
  11830. return *v, true
  11831. }
  11832. // OldSwitchIn returns the old "switch_in" field's value of the Employee entity.
  11833. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11834. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11835. func (m *EmployeeMutation) OldSwitchIn(ctx context.Context) (v string, err error) {
  11836. if !m.op.Is(OpUpdateOne) {
  11837. return v, errors.New("OldSwitchIn is only allowed on UpdateOne operations")
  11838. }
  11839. if m.id == nil || m.oldValue == nil {
  11840. return v, errors.New("OldSwitchIn requires an ID field in the mutation")
  11841. }
  11842. oldValue, err := m.oldValue(ctx)
  11843. if err != nil {
  11844. return v, fmt.Errorf("querying old value for OldSwitchIn: %w", err)
  11845. }
  11846. return oldValue.SwitchIn, nil
  11847. }
  11848. // ResetSwitchIn resets all changes to the "switch_in" field.
  11849. func (m *EmployeeMutation) ResetSwitchIn() {
  11850. m.switch_in = nil
  11851. }
  11852. // SetVideoURL sets the "video_url" field.
  11853. func (m *EmployeeMutation) SetVideoURL(s string) {
  11854. m.video_url = &s
  11855. }
  11856. // VideoURL returns the value of the "video_url" field in the mutation.
  11857. func (m *EmployeeMutation) VideoURL() (r string, exists bool) {
  11858. v := m.video_url
  11859. if v == nil {
  11860. return
  11861. }
  11862. return *v, true
  11863. }
  11864. // OldVideoURL returns the old "video_url" field's value of the Employee entity.
  11865. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11866. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11867. func (m *EmployeeMutation) OldVideoURL(ctx context.Context) (v string, err error) {
  11868. if !m.op.Is(OpUpdateOne) {
  11869. return v, errors.New("OldVideoURL is only allowed on UpdateOne operations")
  11870. }
  11871. if m.id == nil || m.oldValue == nil {
  11872. return v, errors.New("OldVideoURL requires an ID field in the mutation")
  11873. }
  11874. oldValue, err := m.oldValue(ctx)
  11875. if err != nil {
  11876. return v, fmt.Errorf("querying old value for OldVideoURL: %w", err)
  11877. }
  11878. return oldValue.VideoURL, nil
  11879. }
  11880. // ResetVideoURL resets all changes to the "video_url" field.
  11881. func (m *EmployeeMutation) ResetVideoURL() {
  11882. m.video_url = nil
  11883. }
  11884. // SetOrganizationID sets the "organization_id" field.
  11885. func (m *EmployeeMutation) SetOrganizationID(u uint64) {
  11886. m.organization_id = &u
  11887. m.addorganization_id = nil
  11888. }
  11889. // OrganizationID returns the value of the "organization_id" field in the mutation.
  11890. func (m *EmployeeMutation) OrganizationID() (r uint64, exists bool) {
  11891. v := m.organization_id
  11892. if v == nil {
  11893. return
  11894. }
  11895. return *v, true
  11896. }
  11897. // OldOrganizationID returns the old "organization_id" field's value of the Employee entity.
  11898. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11899. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11900. func (m *EmployeeMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  11901. if !m.op.Is(OpUpdateOne) {
  11902. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  11903. }
  11904. if m.id == nil || m.oldValue == nil {
  11905. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  11906. }
  11907. oldValue, err := m.oldValue(ctx)
  11908. if err != nil {
  11909. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  11910. }
  11911. return oldValue.OrganizationID, nil
  11912. }
  11913. // AddOrganizationID adds u to the "organization_id" field.
  11914. func (m *EmployeeMutation) AddOrganizationID(u int64) {
  11915. if m.addorganization_id != nil {
  11916. *m.addorganization_id += u
  11917. } else {
  11918. m.addorganization_id = &u
  11919. }
  11920. }
  11921. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  11922. func (m *EmployeeMutation) AddedOrganizationID() (r int64, exists bool) {
  11923. v := m.addorganization_id
  11924. if v == nil {
  11925. return
  11926. }
  11927. return *v, true
  11928. }
  11929. // ResetOrganizationID resets all changes to the "organization_id" field.
  11930. func (m *EmployeeMutation) ResetOrganizationID() {
  11931. m.organization_id = nil
  11932. m.addorganization_id = nil
  11933. }
  11934. // SetCategoryID sets the "category_id" field.
  11935. func (m *EmployeeMutation) SetCategoryID(u uint64) {
  11936. m.category_id = &u
  11937. m.addcategory_id = nil
  11938. }
  11939. // CategoryID returns the value of the "category_id" field in the mutation.
  11940. func (m *EmployeeMutation) CategoryID() (r uint64, exists bool) {
  11941. v := m.category_id
  11942. if v == nil {
  11943. return
  11944. }
  11945. return *v, true
  11946. }
  11947. // OldCategoryID returns the old "category_id" field's value of the Employee entity.
  11948. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11949. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11950. func (m *EmployeeMutation) OldCategoryID(ctx context.Context) (v uint64, err error) {
  11951. if !m.op.Is(OpUpdateOne) {
  11952. return v, errors.New("OldCategoryID is only allowed on UpdateOne operations")
  11953. }
  11954. if m.id == nil || m.oldValue == nil {
  11955. return v, errors.New("OldCategoryID requires an ID field in the mutation")
  11956. }
  11957. oldValue, err := m.oldValue(ctx)
  11958. if err != nil {
  11959. return v, fmt.Errorf("querying old value for OldCategoryID: %w", err)
  11960. }
  11961. return oldValue.CategoryID, nil
  11962. }
  11963. // AddCategoryID adds u to the "category_id" field.
  11964. func (m *EmployeeMutation) AddCategoryID(u int64) {
  11965. if m.addcategory_id != nil {
  11966. *m.addcategory_id += u
  11967. } else {
  11968. m.addcategory_id = &u
  11969. }
  11970. }
  11971. // AddedCategoryID returns the value that was added to the "category_id" field in this mutation.
  11972. func (m *EmployeeMutation) AddedCategoryID() (r int64, exists bool) {
  11973. v := m.addcategory_id
  11974. if v == nil {
  11975. return
  11976. }
  11977. return *v, true
  11978. }
  11979. // ResetCategoryID resets all changes to the "category_id" field.
  11980. func (m *EmployeeMutation) ResetCategoryID() {
  11981. m.category_id = nil
  11982. m.addcategory_id = nil
  11983. }
  11984. // SetAPIBase sets the "api_base" field.
  11985. func (m *EmployeeMutation) SetAPIBase(s string) {
  11986. m.api_base = &s
  11987. }
  11988. // APIBase returns the value of the "api_base" field in the mutation.
  11989. func (m *EmployeeMutation) APIBase() (r string, exists bool) {
  11990. v := m.api_base
  11991. if v == nil {
  11992. return
  11993. }
  11994. return *v, true
  11995. }
  11996. // OldAPIBase returns the old "api_base" field's value of the Employee entity.
  11997. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11998. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11999. func (m *EmployeeMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  12000. if !m.op.Is(OpUpdateOne) {
  12001. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  12002. }
  12003. if m.id == nil || m.oldValue == nil {
  12004. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  12005. }
  12006. oldValue, err := m.oldValue(ctx)
  12007. if err != nil {
  12008. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  12009. }
  12010. return oldValue.APIBase, nil
  12011. }
  12012. // ResetAPIBase resets all changes to the "api_base" field.
  12013. func (m *EmployeeMutation) ResetAPIBase() {
  12014. m.api_base = nil
  12015. }
  12016. // SetAPIKey sets the "api_key" field.
  12017. func (m *EmployeeMutation) SetAPIKey(s string) {
  12018. m.api_key = &s
  12019. }
  12020. // APIKey returns the value of the "api_key" field in the mutation.
  12021. func (m *EmployeeMutation) APIKey() (r string, exists bool) {
  12022. v := m.api_key
  12023. if v == nil {
  12024. return
  12025. }
  12026. return *v, true
  12027. }
  12028. // OldAPIKey returns the old "api_key" field's value of the Employee entity.
  12029. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12030. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12031. func (m *EmployeeMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  12032. if !m.op.Is(OpUpdateOne) {
  12033. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  12034. }
  12035. if m.id == nil || m.oldValue == nil {
  12036. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  12037. }
  12038. oldValue, err := m.oldValue(ctx)
  12039. if err != nil {
  12040. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  12041. }
  12042. return oldValue.APIKey, nil
  12043. }
  12044. // ResetAPIKey resets all changes to the "api_key" field.
  12045. func (m *EmployeeMutation) ResetAPIKey() {
  12046. m.api_key = nil
  12047. }
  12048. // SetAiInfo sets the "ai_info" field.
  12049. func (m *EmployeeMutation) SetAiInfo(s string) {
  12050. m.ai_info = &s
  12051. }
  12052. // AiInfo returns the value of the "ai_info" field in the mutation.
  12053. func (m *EmployeeMutation) AiInfo() (r string, exists bool) {
  12054. v := m.ai_info
  12055. if v == nil {
  12056. return
  12057. }
  12058. return *v, true
  12059. }
  12060. // OldAiInfo returns the old "ai_info" field's value of the Employee entity.
  12061. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12062. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12063. func (m *EmployeeMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  12064. if !m.op.Is(OpUpdateOne) {
  12065. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  12066. }
  12067. if m.id == nil || m.oldValue == nil {
  12068. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  12069. }
  12070. oldValue, err := m.oldValue(ctx)
  12071. if err != nil {
  12072. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  12073. }
  12074. return oldValue.AiInfo, nil
  12075. }
  12076. // ClearAiInfo clears the value of the "ai_info" field.
  12077. func (m *EmployeeMutation) ClearAiInfo() {
  12078. m.ai_info = nil
  12079. m.clearedFields[employee.FieldAiInfo] = struct{}{}
  12080. }
  12081. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  12082. func (m *EmployeeMutation) AiInfoCleared() bool {
  12083. _, ok := m.clearedFields[employee.FieldAiInfo]
  12084. return ok
  12085. }
  12086. // ResetAiInfo resets all changes to the "ai_info" field.
  12087. func (m *EmployeeMutation) ResetAiInfo() {
  12088. m.ai_info = nil
  12089. delete(m.clearedFields, employee.FieldAiInfo)
  12090. }
  12091. // SetIsVip sets the "is_vip" field.
  12092. func (m *EmployeeMutation) SetIsVip(i int) {
  12093. m.is_vip = &i
  12094. m.addis_vip = nil
  12095. }
  12096. // IsVip returns the value of the "is_vip" field in the mutation.
  12097. func (m *EmployeeMutation) IsVip() (r int, exists bool) {
  12098. v := m.is_vip
  12099. if v == nil {
  12100. return
  12101. }
  12102. return *v, true
  12103. }
  12104. // OldIsVip returns the old "is_vip" field's value of the Employee entity.
  12105. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12106. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12107. func (m *EmployeeMutation) OldIsVip(ctx context.Context) (v int, err error) {
  12108. if !m.op.Is(OpUpdateOne) {
  12109. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  12110. }
  12111. if m.id == nil || m.oldValue == nil {
  12112. return v, errors.New("OldIsVip requires an ID field in the mutation")
  12113. }
  12114. oldValue, err := m.oldValue(ctx)
  12115. if err != nil {
  12116. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  12117. }
  12118. return oldValue.IsVip, nil
  12119. }
  12120. // AddIsVip adds i to the "is_vip" field.
  12121. func (m *EmployeeMutation) AddIsVip(i int) {
  12122. if m.addis_vip != nil {
  12123. *m.addis_vip += i
  12124. } else {
  12125. m.addis_vip = &i
  12126. }
  12127. }
  12128. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  12129. func (m *EmployeeMutation) AddedIsVip() (r int, exists bool) {
  12130. v := m.addis_vip
  12131. if v == nil {
  12132. return
  12133. }
  12134. return *v, true
  12135. }
  12136. // ResetIsVip resets all changes to the "is_vip" field.
  12137. func (m *EmployeeMutation) ResetIsVip() {
  12138. m.is_vip = nil
  12139. m.addis_vip = nil
  12140. }
  12141. // SetChatURL sets the "chat_url" field.
  12142. func (m *EmployeeMutation) SetChatURL(s string) {
  12143. m.chat_url = &s
  12144. }
  12145. // ChatURL returns the value of the "chat_url" field in the mutation.
  12146. func (m *EmployeeMutation) ChatURL() (r string, exists bool) {
  12147. v := m.chat_url
  12148. if v == nil {
  12149. return
  12150. }
  12151. return *v, true
  12152. }
  12153. // OldChatURL returns the old "chat_url" field's value of the Employee entity.
  12154. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12155. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12156. func (m *EmployeeMutation) OldChatURL(ctx context.Context) (v string, err error) {
  12157. if !m.op.Is(OpUpdateOne) {
  12158. return v, errors.New("OldChatURL is only allowed on UpdateOne operations")
  12159. }
  12160. if m.id == nil || m.oldValue == nil {
  12161. return v, errors.New("OldChatURL requires an ID field in the mutation")
  12162. }
  12163. oldValue, err := m.oldValue(ctx)
  12164. if err != nil {
  12165. return v, fmt.Errorf("querying old value for OldChatURL: %w", err)
  12166. }
  12167. return oldValue.ChatURL, nil
  12168. }
  12169. // ResetChatURL resets all changes to the "chat_url" field.
  12170. func (m *EmployeeMutation) ResetChatURL() {
  12171. m.chat_url = nil
  12172. }
  12173. // AddEmWorkExperienceIDs adds the "em_work_experiences" edge to the WorkExperience entity by ids.
  12174. func (m *EmployeeMutation) AddEmWorkExperienceIDs(ids ...uint64) {
  12175. if m.em_work_experiences == nil {
  12176. m.em_work_experiences = make(map[uint64]struct{})
  12177. }
  12178. for i := range ids {
  12179. m.em_work_experiences[ids[i]] = struct{}{}
  12180. }
  12181. }
  12182. // ClearEmWorkExperiences clears the "em_work_experiences" edge to the WorkExperience entity.
  12183. func (m *EmployeeMutation) ClearEmWorkExperiences() {
  12184. m.clearedem_work_experiences = true
  12185. }
  12186. // EmWorkExperiencesCleared reports if the "em_work_experiences" edge to the WorkExperience entity was cleared.
  12187. func (m *EmployeeMutation) EmWorkExperiencesCleared() bool {
  12188. return m.clearedem_work_experiences
  12189. }
  12190. // RemoveEmWorkExperienceIDs removes the "em_work_experiences" edge to the WorkExperience entity by IDs.
  12191. func (m *EmployeeMutation) RemoveEmWorkExperienceIDs(ids ...uint64) {
  12192. if m.removedem_work_experiences == nil {
  12193. m.removedem_work_experiences = make(map[uint64]struct{})
  12194. }
  12195. for i := range ids {
  12196. delete(m.em_work_experiences, ids[i])
  12197. m.removedem_work_experiences[ids[i]] = struct{}{}
  12198. }
  12199. }
  12200. // RemovedEmWorkExperiences returns the removed IDs of the "em_work_experiences" edge to the WorkExperience entity.
  12201. func (m *EmployeeMutation) RemovedEmWorkExperiencesIDs() (ids []uint64) {
  12202. for id := range m.removedem_work_experiences {
  12203. ids = append(ids, id)
  12204. }
  12205. return
  12206. }
  12207. // EmWorkExperiencesIDs returns the "em_work_experiences" edge IDs in the mutation.
  12208. func (m *EmployeeMutation) EmWorkExperiencesIDs() (ids []uint64) {
  12209. for id := range m.em_work_experiences {
  12210. ids = append(ids, id)
  12211. }
  12212. return
  12213. }
  12214. // ResetEmWorkExperiences resets all changes to the "em_work_experiences" edge.
  12215. func (m *EmployeeMutation) ResetEmWorkExperiences() {
  12216. m.em_work_experiences = nil
  12217. m.clearedem_work_experiences = false
  12218. m.removedem_work_experiences = nil
  12219. }
  12220. // AddEmTutorialIDs adds the "em_tutorial" edge to the Tutorial entity by ids.
  12221. func (m *EmployeeMutation) AddEmTutorialIDs(ids ...uint64) {
  12222. if m.em_tutorial == nil {
  12223. m.em_tutorial = make(map[uint64]struct{})
  12224. }
  12225. for i := range ids {
  12226. m.em_tutorial[ids[i]] = struct{}{}
  12227. }
  12228. }
  12229. // ClearEmTutorial clears the "em_tutorial" edge to the Tutorial entity.
  12230. func (m *EmployeeMutation) ClearEmTutorial() {
  12231. m.clearedem_tutorial = true
  12232. }
  12233. // EmTutorialCleared reports if the "em_tutorial" edge to the Tutorial entity was cleared.
  12234. func (m *EmployeeMutation) EmTutorialCleared() bool {
  12235. return m.clearedem_tutorial
  12236. }
  12237. // RemoveEmTutorialIDs removes the "em_tutorial" edge to the Tutorial entity by IDs.
  12238. func (m *EmployeeMutation) RemoveEmTutorialIDs(ids ...uint64) {
  12239. if m.removedem_tutorial == nil {
  12240. m.removedem_tutorial = make(map[uint64]struct{})
  12241. }
  12242. for i := range ids {
  12243. delete(m.em_tutorial, ids[i])
  12244. m.removedem_tutorial[ids[i]] = struct{}{}
  12245. }
  12246. }
  12247. // RemovedEmTutorial returns the removed IDs of the "em_tutorial" edge to the Tutorial entity.
  12248. func (m *EmployeeMutation) RemovedEmTutorialIDs() (ids []uint64) {
  12249. for id := range m.removedem_tutorial {
  12250. ids = append(ids, id)
  12251. }
  12252. return
  12253. }
  12254. // EmTutorialIDs returns the "em_tutorial" edge IDs in the mutation.
  12255. func (m *EmployeeMutation) EmTutorialIDs() (ids []uint64) {
  12256. for id := range m.em_tutorial {
  12257. ids = append(ids, id)
  12258. }
  12259. return
  12260. }
  12261. // ResetEmTutorial resets all changes to the "em_tutorial" edge.
  12262. func (m *EmployeeMutation) ResetEmTutorial() {
  12263. m.em_tutorial = nil
  12264. m.clearedem_tutorial = false
  12265. m.removedem_tutorial = nil
  12266. }
  12267. // Where appends a list predicates to the EmployeeMutation builder.
  12268. func (m *EmployeeMutation) Where(ps ...predicate.Employee) {
  12269. m.predicates = append(m.predicates, ps...)
  12270. }
  12271. // WhereP appends storage-level predicates to the EmployeeMutation builder. Using this method,
  12272. // users can use type-assertion to append predicates that do not depend on any generated package.
  12273. func (m *EmployeeMutation) WhereP(ps ...func(*sql.Selector)) {
  12274. p := make([]predicate.Employee, len(ps))
  12275. for i := range ps {
  12276. p[i] = ps[i]
  12277. }
  12278. m.Where(p...)
  12279. }
  12280. // Op returns the operation name.
  12281. func (m *EmployeeMutation) Op() Op {
  12282. return m.op
  12283. }
  12284. // SetOp allows setting the mutation operation.
  12285. func (m *EmployeeMutation) SetOp(op Op) {
  12286. m.op = op
  12287. }
  12288. // Type returns the node type of this mutation (Employee).
  12289. func (m *EmployeeMutation) Type() string {
  12290. return m.typ
  12291. }
  12292. // Fields returns all fields that were changed during this mutation. Note that in
  12293. // order to get all numeric fields that were incremented/decremented, call
  12294. // AddedFields().
  12295. func (m *EmployeeMutation) Fields() []string {
  12296. fields := make([]string, 0, 23)
  12297. if m.created_at != nil {
  12298. fields = append(fields, employee.FieldCreatedAt)
  12299. }
  12300. if m.updated_at != nil {
  12301. fields = append(fields, employee.FieldUpdatedAt)
  12302. }
  12303. if m.deleted_at != nil {
  12304. fields = append(fields, employee.FieldDeletedAt)
  12305. }
  12306. if m.title != nil {
  12307. fields = append(fields, employee.FieldTitle)
  12308. }
  12309. if m.avatar != nil {
  12310. fields = append(fields, employee.FieldAvatar)
  12311. }
  12312. if m.tags != nil {
  12313. fields = append(fields, employee.FieldTags)
  12314. }
  12315. if m.hire_count != nil {
  12316. fields = append(fields, employee.FieldHireCount)
  12317. }
  12318. if m.service_count != nil {
  12319. fields = append(fields, employee.FieldServiceCount)
  12320. }
  12321. if m.achievement_count != nil {
  12322. fields = append(fields, employee.FieldAchievementCount)
  12323. }
  12324. if m.intro != nil {
  12325. fields = append(fields, employee.FieldIntro)
  12326. }
  12327. if m.estimate != nil {
  12328. fields = append(fields, employee.FieldEstimate)
  12329. }
  12330. if m.skill != nil {
  12331. fields = append(fields, employee.FieldSkill)
  12332. }
  12333. if m.ability_type != nil {
  12334. fields = append(fields, employee.FieldAbilityType)
  12335. }
  12336. if m.scene != nil {
  12337. fields = append(fields, employee.FieldScene)
  12338. }
  12339. if m.switch_in != nil {
  12340. fields = append(fields, employee.FieldSwitchIn)
  12341. }
  12342. if m.video_url != nil {
  12343. fields = append(fields, employee.FieldVideoURL)
  12344. }
  12345. if m.organization_id != nil {
  12346. fields = append(fields, employee.FieldOrganizationID)
  12347. }
  12348. if m.category_id != nil {
  12349. fields = append(fields, employee.FieldCategoryID)
  12350. }
  12351. if m.api_base != nil {
  12352. fields = append(fields, employee.FieldAPIBase)
  12353. }
  12354. if m.api_key != nil {
  12355. fields = append(fields, employee.FieldAPIKey)
  12356. }
  12357. if m.ai_info != nil {
  12358. fields = append(fields, employee.FieldAiInfo)
  12359. }
  12360. if m.is_vip != nil {
  12361. fields = append(fields, employee.FieldIsVip)
  12362. }
  12363. if m.chat_url != nil {
  12364. fields = append(fields, employee.FieldChatURL)
  12365. }
  12366. return fields
  12367. }
  12368. // Field returns the value of a field with the given name. The second boolean
  12369. // return value indicates that this field was not set, or was not defined in the
  12370. // schema.
  12371. func (m *EmployeeMutation) Field(name string) (ent.Value, bool) {
  12372. switch name {
  12373. case employee.FieldCreatedAt:
  12374. return m.CreatedAt()
  12375. case employee.FieldUpdatedAt:
  12376. return m.UpdatedAt()
  12377. case employee.FieldDeletedAt:
  12378. return m.DeletedAt()
  12379. case employee.FieldTitle:
  12380. return m.Title()
  12381. case employee.FieldAvatar:
  12382. return m.Avatar()
  12383. case employee.FieldTags:
  12384. return m.Tags()
  12385. case employee.FieldHireCount:
  12386. return m.HireCount()
  12387. case employee.FieldServiceCount:
  12388. return m.ServiceCount()
  12389. case employee.FieldAchievementCount:
  12390. return m.AchievementCount()
  12391. case employee.FieldIntro:
  12392. return m.Intro()
  12393. case employee.FieldEstimate:
  12394. return m.Estimate()
  12395. case employee.FieldSkill:
  12396. return m.Skill()
  12397. case employee.FieldAbilityType:
  12398. return m.AbilityType()
  12399. case employee.FieldScene:
  12400. return m.Scene()
  12401. case employee.FieldSwitchIn:
  12402. return m.SwitchIn()
  12403. case employee.FieldVideoURL:
  12404. return m.VideoURL()
  12405. case employee.FieldOrganizationID:
  12406. return m.OrganizationID()
  12407. case employee.FieldCategoryID:
  12408. return m.CategoryID()
  12409. case employee.FieldAPIBase:
  12410. return m.APIBase()
  12411. case employee.FieldAPIKey:
  12412. return m.APIKey()
  12413. case employee.FieldAiInfo:
  12414. return m.AiInfo()
  12415. case employee.FieldIsVip:
  12416. return m.IsVip()
  12417. case employee.FieldChatURL:
  12418. return m.ChatURL()
  12419. }
  12420. return nil, false
  12421. }
  12422. // OldField returns the old value of the field from the database. An error is
  12423. // returned if the mutation operation is not UpdateOne, or the query to the
  12424. // database failed.
  12425. func (m *EmployeeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  12426. switch name {
  12427. case employee.FieldCreatedAt:
  12428. return m.OldCreatedAt(ctx)
  12429. case employee.FieldUpdatedAt:
  12430. return m.OldUpdatedAt(ctx)
  12431. case employee.FieldDeletedAt:
  12432. return m.OldDeletedAt(ctx)
  12433. case employee.FieldTitle:
  12434. return m.OldTitle(ctx)
  12435. case employee.FieldAvatar:
  12436. return m.OldAvatar(ctx)
  12437. case employee.FieldTags:
  12438. return m.OldTags(ctx)
  12439. case employee.FieldHireCount:
  12440. return m.OldHireCount(ctx)
  12441. case employee.FieldServiceCount:
  12442. return m.OldServiceCount(ctx)
  12443. case employee.FieldAchievementCount:
  12444. return m.OldAchievementCount(ctx)
  12445. case employee.FieldIntro:
  12446. return m.OldIntro(ctx)
  12447. case employee.FieldEstimate:
  12448. return m.OldEstimate(ctx)
  12449. case employee.FieldSkill:
  12450. return m.OldSkill(ctx)
  12451. case employee.FieldAbilityType:
  12452. return m.OldAbilityType(ctx)
  12453. case employee.FieldScene:
  12454. return m.OldScene(ctx)
  12455. case employee.FieldSwitchIn:
  12456. return m.OldSwitchIn(ctx)
  12457. case employee.FieldVideoURL:
  12458. return m.OldVideoURL(ctx)
  12459. case employee.FieldOrganizationID:
  12460. return m.OldOrganizationID(ctx)
  12461. case employee.FieldCategoryID:
  12462. return m.OldCategoryID(ctx)
  12463. case employee.FieldAPIBase:
  12464. return m.OldAPIBase(ctx)
  12465. case employee.FieldAPIKey:
  12466. return m.OldAPIKey(ctx)
  12467. case employee.FieldAiInfo:
  12468. return m.OldAiInfo(ctx)
  12469. case employee.FieldIsVip:
  12470. return m.OldIsVip(ctx)
  12471. case employee.FieldChatURL:
  12472. return m.OldChatURL(ctx)
  12473. }
  12474. return nil, fmt.Errorf("unknown Employee field %s", name)
  12475. }
  12476. // SetField sets the value of a field with the given name. It returns an error if
  12477. // the field is not defined in the schema, or if the type mismatched the field
  12478. // type.
  12479. func (m *EmployeeMutation) SetField(name string, value ent.Value) error {
  12480. switch name {
  12481. case employee.FieldCreatedAt:
  12482. v, ok := value.(time.Time)
  12483. if !ok {
  12484. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12485. }
  12486. m.SetCreatedAt(v)
  12487. return nil
  12488. case employee.FieldUpdatedAt:
  12489. v, ok := value.(time.Time)
  12490. if !ok {
  12491. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12492. }
  12493. m.SetUpdatedAt(v)
  12494. return nil
  12495. case employee.FieldDeletedAt:
  12496. v, ok := value.(time.Time)
  12497. if !ok {
  12498. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12499. }
  12500. m.SetDeletedAt(v)
  12501. return nil
  12502. case employee.FieldTitle:
  12503. v, ok := value.(string)
  12504. if !ok {
  12505. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12506. }
  12507. m.SetTitle(v)
  12508. return nil
  12509. case employee.FieldAvatar:
  12510. v, ok := value.(string)
  12511. if !ok {
  12512. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12513. }
  12514. m.SetAvatar(v)
  12515. return nil
  12516. case employee.FieldTags:
  12517. v, ok := value.(string)
  12518. if !ok {
  12519. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12520. }
  12521. m.SetTags(v)
  12522. return nil
  12523. case employee.FieldHireCount:
  12524. v, ok := value.(int)
  12525. if !ok {
  12526. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12527. }
  12528. m.SetHireCount(v)
  12529. return nil
  12530. case employee.FieldServiceCount:
  12531. v, ok := value.(int)
  12532. if !ok {
  12533. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12534. }
  12535. m.SetServiceCount(v)
  12536. return nil
  12537. case employee.FieldAchievementCount:
  12538. v, ok := value.(int)
  12539. if !ok {
  12540. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12541. }
  12542. m.SetAchievementCount(v)
  12543. return nil
  12544. case employee.FieldIntro:
  12545. v, ok := value.(string)
  12546. if !ok {
  12547. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12548. }
  12549. m.SetIntro(v)
  12550. return nil
  12551. case employee.FieldEstimate:
  12552. v, ok := value.(string)
  12553. if !ok {
  12554. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12555. }
  12556. m.SetEstimate(v)
  12557. return nil
  12558. case employee.FieldSkill:
  12559. v, ok := value.(string)
  12560. if !ok {
  12561. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12562. }
  12563. m.SetSkill(v)
  12564. return nil
  12565. case employee.FieldAbilityType:
  12566. v, ok := value.(string)
  12567. if !ok {
  12568. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12569. }
  12570. m.SetAbilityType(v)
  12571. return nil
  12572. case employee.FieldScene:
  12573. v, ok := value.(string)
  12574. if !ok {
  12575. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12576. }
  12577. m.SetScene(v)
  12578. return nil
  12579. case employee.FieldSwitchIn:
  12580. v, ok := value.(string)
  12581. if !ok {
  12582. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12583. }
  12584. m.SetSwitchIn(v)
  12585. return nil
  12586. case employee.FieldVideoURL:
  12587. v, ok := value.(string)
  12588. if !ok {
  12589. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12590. }
  12591. m.SetVideoURL(v)
  12592. return nil
  12593. case employee.FieldOrganizationID:
  12594. v, ok := value.(uint64)
  12595. if !ok {
  12596. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12597. }
  12598. m.SetOrganizationID(v)
  12599. return nil
  12600. case employee.FieldCategoryID:
  12601. v, ok := value.(uint64)
  12602. if !ok {
  12603. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12604. }
  12605. m.SetCategoryID(v)
  12606. return nil
  12607. case employee.FieldAPIBase:
  12608. v, ok := value.(string)
  12609. if !ok {
  12610. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12611. }
  12612. m.SetAPIBase(v)
  12613. return nil
  12614. case employee.FieldAPIKey:
  12615. v, ok := value.(string)
  12616. if !ok {
  12617. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12618. }
  12619. m.SetAPIKey(v)
  12620. return nil
  12621. case employee.FieldAiInfo:
  12622. v, ok := value.(string)
  12623. if !ok {
  12624. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12625. }
  12626. m.SetAiInfo(v)
  12627. return nil
  12628. case employee.FieldIsVip:
  12629. v, ok := value.(int)
  12630. if !ok {
  12631. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12632. }
  12633. m.SetIsVip(v)
  12634. return nil
  12635. case employee.FieldChatURL:
  12636. v, ok := value.(string)
  12637. if !ok {
  12638. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12639. }
  12640. m.SetChatURL(v)
  12641. return nil
  12642. }
  12643. return fmt.Errorf("unknown Employee field %s", name)
  12644. }
  12645. // AddedFields returns all numeric fields that were incremented/decremented during
  12646. // this mutation.
  12647. func (m *EmployeeMutation) AddedFields() []string {
  12648. var fields []string
  12649. if m.addhire_count != nil {
  12650. fields = append(fields, employee.FieldHireCount)
  12651. }
  12652. if m.addservice_count != nil {
  12653. fields = append(fields, employee.FieldServiceCount)
  12654. }
  12655. if m.addachievement_count != nil {
  12656. fields = append(fields, employee.FieldAchievementCount)
  12657. }
  12658. if m.addorganization_id != nil {
  12659. fields = append(fields, employee.FieldOrganizationID)
  12660. }
  12661. if m.addcategory_id != nil {
  12662. fields = append(fields, employee.FieldCategoryID)
  12663. }
  12664. if m.addis_vip != nil {
  12665. fields = append(fields, employee.FieldIsVip)
  12666. }
  12667. return fields
  12668. }
  12669. // AddedField returns the numeric value that was incremented/decremented on a field
  12670. // with the given name. The second boolean return value indicates that this field
  12671. // was not set, or was not defined in the schema.
  12672. func (m *EmployeeMutation) AddedField(name string) (ent.Value, bool) {
  12673. switch name {
  12674. case employee.FieldHireCount:
  12675. return m.AddedHireCount()
  12676. case employee.FieldServiceCount:
  12677. return m.AddedServiceCount()
  12678. case employee.FieldAchievementCount:
  12679. return m.AddedAchievementCount()
  12680. case employee.FieldOrganizationID:
  12681. return m.AddedOrganizationID()
  12682. case employee.FieldCategoryID:
  12683. return m.AddedCategoryID()
  12684. case employee.FieldIsVip:
  12685. return m.AddedIsVip()
  12686. }
  12687. return nil, false
  12688. }
  12689. // AddField adds the value to the field with the given name. It returns an error if
  12690. // the field is not defined in the schema, or if the type mismatched the field
  12691. // type.
  12692. func (m *EmployeeMutation) AddField(name string, value ent.Value) error {
  12693. switch name {
  12694. case employee.FieldHireCount:
  12695. v, ok := value.(int)
  12696. if !ok {
  12697. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12698. }
  12699. m.AddHireCount(v)
  12700. return nil
  12701. case employee.FieldServiceCount:
  12702. v, ok := value.(int)
  12703. if !ok {
  12704. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12705. }
  12706. m.AddServiceCount(v)
  12707. return nil
  12708. case employee.FieldAchievementCount:
  12709. v, ok := value.(int)
  12710. if !ok {
  12711. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12712. }
  12713. m.AddAchievementCount(v)
  12714. return nil
  12715. case employee.FieldOrganizationID:
  12716. v, ok := value.(int64)
  12717. if !ok {
  12718. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12719. }
  12720. m.AddOrganizationID(v)
  12721. return nil
  12722. case employee.FieldCategoryID:
  12723. v, ok := value.(int64)
  12724. if !ok {
  12725. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12726. }
  12727. m.AddCategoryID(v)
  12728. return nil
  12729. case employee.FieldIsVip:
  12730. v, ok := value.(int)
  12731. if !ok {
  12732. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12733. }
  12734. m.AddIsVip(v)
  12735. return nil
  12736. }
  12737. return fmt.Errorf("unknown Employee numeric field %s", name)
  12738. }
  12739. // ClearedFields returns all nullable fields that were cleared during this
  12740. // mutation.
  12741. func (m *EmployeeMutation) ClearedFields() []string {
  12742. var fields []string
  12743. if m.FieldCleared(employee.FieldDeletedAt) {
  12744. fields = append(fields, employee.FieldDeletedAt)
  12745. }
  12746. if m.FieldCleared(employee.FieldAiInfo) {
  12747. fields = append(fields, employee.FieldAiInfo)
  12748. }
  12749. return fields
  12750. }
  12751. // FieldCleared returns a boolean indicating if a field with the given name was
  12752. // cleared in this mutation.
  12753. func (m *EmployeeMutation) FieldCleared(name string) bool {
  12754. _, ok := m.clearedFields[name]
  12755. return ok
  12756. }
  12757. // ClearField clears the value of the field with the given name. It returns an
  12758. // error if the field is not defined in the schema.
  12759. func (m *EmployeeMutation) ClearField(name string) error {
  12760. switch name {
  12761. case employee.FieldDeletedAt:
  12762. m.ClearDeletedAt()
  12763. return nil
  12764. case employee.FieldAiInfo:
  12765. m.ClearAiInfo()
  12766. return nil
  12767. }
  12768. return fmt.Errorf("unknown Employee nullable field %s", name)
  12769. }
  12770. // ResetField resets all changes in the mutation for the field with the given name.
  12771. // It returns an error if the field is not defined in the schema.
  12772. func (m *EmployeeMutation) ResetField(name string) error {
  12773. switch name {
  12774. case employee.FieldCreatedAt:
  12775. m.ResetCreatedAt()
  12776. return nil
  12777. case employee.FieldUpdatedAt:
  12778. m.ResetUpdatedAt()
  12779. return nil
  12780. case employee.FieldDeletedAt:
  12781. m.ResetDeletedAt()
  12782. return nil
  12783. case employee.FieldTitle:
  12784. m.ResetTitle()
  12785. return nil
  12786. case employee.FieldAvatar:
  12787. m.ResetAvatar()
  12788. return nil
  12789. case employee.FieldTags:
  12790. m.ResetTags()
  12791. return nil
  12792. case employee.FieldHireCount:
  12793. m.ResetHireCount()
  12794. return nil
  12795. case employee.FieldServiceCount:
  12796. m.ResetServiceCount()
  12797. return nil
  12798. case employee.FieldAchievementCount:
  12799. m.ResetAchievementCount()
  12800. return nil
  12801. case employee.FieldIntro:
  12802. m.ResetIntro()
  12803. return nil
  12804. case employee.FieldEstimate:
  12805. m.ResetEstimate()
  12806. return nil
  12807. case employee.FieldSkill:
  12808. m.ResetSkill()
  12809. return nil
  12810. case employee.FieldAbilityType:
  12811. m.ResetAbilityType()
  12812. return nil
  12813. case employee.FieldScene:
  12814. m.ResetScene()
  12815. return nil
  12816. case employee.FieldSwitchIn:
  12817. m.ResetSwitchIn()
  12818. return nil
  12819. case employee.FieldVideoURL:
  12820. m.ResetVideoURL()
  12821. return nil
  12822. case employee.FieldOrganizationID:
  12823. m.ResetOrganizationID()
  12824. return nil
  12825. case employee.FieldCategoryID:
  12826. m.ResetCategoryID()
  12827. return nil
  12828. case employee.FieldAPIBase:
  12829. m.ResetAPIBase()
  12830. return nil
  12831. case employee.FieldAPIKey:
  12832. m.ResetAPIKey()
  12833. return nil
  12834. case employee.FieldAiInfo:
  12835. m.ResetAiInfo()
  12836. return nil
  12837. case employee.FieldIsVip:
  12838. m.ResetIsVip()
  12839. return nil
  12840. case employee.FieldChatURL:
  12841. m.ResetChatURL()
  12842. return nil
  12843. }
  12844. return fmt.Errorf("unknown Employee field %s", name)
  12845. }
  12846. // AddedEdges returns all edge names that were set/added in this mutation.
  12847. func (m *EmployeeMutation) AddedEdges() []string {
  12848. edges := make([]string, 0, 2)
  12849. if m.em_work_experiences != nil {
  12850. edges = append(edges, employee.EdgeEmWorkExperiences)
  12851. }
  12852. if m.em_tutorial != nil {
  12853. edges = append(edges, employee.EdgeEmTutorial)
  12854. }
  12855. return edges
  12856. }
  12857. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  12858. // name in this mutation.
  12859. func (m *EmployeeMutation) AddedIDs(name string) []ent.Value {
  12860. switch name {
  12861. case employee.EdgeEmWorkExperiences:
  12862. ids := make([]ent.Value, 0, len(m.em_work_experiences))
  12863. for id := range m.em_work_experiences {
  12864. ids = append(ids, id)
  12865. }
  12866. return ids
  12867. case employee.EdgeEmTutorial:
  12868. ids := make([]ent.Value, 0, len(m.em_tutorial))
  12869. for id := range m.em_tutorial {
  12870. ids = append(ids, id)
  12871. }
  12872. return ids
  12873. }
  12874. return nil
  12875. }
  12876. // RemovedEdges returns all edge names that were removed in this mutation.
  12877. func (m *EmployeeMutation) RemovedEdges() []string {
  12878. edges := make([]string, 0, 2)
  12879. if m.removedem_work_experiences != nil {
  12880. edges = append(edges, employee.EdgeEmWorkExperiences)
  12881. }
  12882. if m.removedem_tutorial != nil {
  12883. edges = append(edges, employee.EdgeEmTutorial)
  12884. }
  12885. return edges
  12886. }
  12887. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  12888. // the given name in this mutation.
  12889. func (m *EmployeeMutation) RemovedIDs(name string) []ent.Value {
  12890. switch name {
  12891. case employee.EdgeEmWorkExperiences:
  12892. ids := make([]ent.Value, 0, len(m.removedem_work_experiences))
  12893. for id := range m.removedem_work_experiences {
  12894. ids = append(ids, id)
  12895. }
  12896. return ids
  12897. case employee.EdgeEmTutorial:
  12898. ids := make([]ent.Value, 0, len(m.removedem_tutorial))
  12899. for id := range m.removedem_tutorial {
  12900. ids = append(ids, id)
  12901. }
  12902. return ids
  12903. }
  12904. return nil
  12905. }
  12906. // ClearedEdges returns all edge names that were cleared in this mutation.
  12907. func (m *EmployeeMutation) ClearedEdges() []string {
  12908. edges := make([]string, 0, 2)
  12909. if m.clearedem_work_experiences {
  12910. edges = append(edges, employee.EdgeEmWorkExperiences)
  12911. }
  12912. if m.clearedem_tutorial {
  12913. edges = append(edges, employee.EdgeEmTutorial)
  12914. }
  12915. return edges
  12916. }
  12917. // EdgeCleared returns a boolean which indicates if the edge with the given name
  12918. // was cleared in this mutation.
  12919. func (m *EmployeeMutation) EdgeCleared(name string) bool {
  12920. switch name {
  12921. case employee.EdgeEmWorkExperiences:
  12922. return m.clearedem_work_experiences
  12923. case employee.EdgeEmTutorial:
  12924. return m.clearedem_tutorial
  12925. }
  12926. return false
  12927. }
  12928. // ClearEdge clears the value of the edge with the given name. It returns an error
  12929. // if that edge is not defined in the schema.
  12930. func (m *EmployeeMutation) ClearEdge(name string) error {
  12931. switch name {
  12932. }
  12933. return fmt.Errorf("unknown Employee unique edge %s", name)
  12934. }
  12935. // ResetEdge resets all changes to the edge with the given name in this mutation.
  12936. // It returns an error if the edge is not defined in the schema.
  12937. func (m *EmployeeMutation) ResetEdge(name string) error {
  12938. switch name {
  12939. case employee.EdgeEmWorkExperiences:
  12940. m.ResetEmWorkExperiences()
  12941. return nil
  12942. case employee.EdgeEmTutorial:
  12943. m.ResetEmTutorial()
  12944. return nil
  12945. }
  12946. return fmt.Errorf("unknown Employee edge %s", name)
  12947. }
  12948. // EmployeeConfigMutation represents an operation that mutates the EmployeeConfig nodes in the graph.
  12949. type EmployeeConfigMutation struct {
  12950. config
  12951. op Op
  12952. typ string
  12953. id *uint64
  12954. created_at *time.Time
  12955. updated_at *time.Time
  12956. deleted_at *time.Time
  12957. stype *string
  12958. title *string
  12959. photo *string
  12960. organization_id *uint64
  12961. addorganization_id *int64
  12962. clearedFields map[string]struct{}
  12963. done bool
  12964. oldValue func(context.Context) (*EmployeeConfig, error)
  12965. predicates []predicate.EmployeeConfig
  12966. }
  12967. var _ ent.Mutation = (*EmployeeConfigMutation)(nil)
  12968. // employeeconfigOption allows management of the mutation configuration using functional options.
  12969. type employeeconfigOption func(*EmployeeConfigMutation)
  12970. // newEmployeeConfigMutation creates new mutation for the EmployeeConfig entity.
  12971. func newEmployeeConfigMutation(c config, op Op, opts ...employeeconfigOption) *EmployeeConfigMutation {
  12972. m := &EmployeeConfigMutation{
  12973. config: c,
  12974. op: op,
  12975. typ: TypeEmployeeConfig,
  12976. clearedFields: make(map[string]struct{}),
  12977. }
  12978. for _, opt := range opts {
  12979. opt(m)
  12980. }
  12981. return m
  12982. }
  12983. // withEmployeeConfigID sets the ID field of the mutation.
  12984. func withEmployeeConfigID(id uint64) employeeconfigOption {
  12985. return func(m *EmployeeConfigMutation) {
  12986. var (
  12987. err error
  12988. once sync.Once
  12989. value *EmployeeConfig
  12990. )
  12991. m.oldValue = func(ctx context.Context) (*EmployeeConfig, error) {
  12992. once.Do(func() {
  12993. if m.done {
  12994. err = errors.New("querying old values post mutation is not allowed")
  12995. } else {
  12996. value, err = m.Client().EmployeeConfig.Get(ctx, id)
  12997. }
  12998. })
  12999. return value, err
  13000. }
  13001. m.id = &id
  13002. }
  13003. }
  13004. // withEmployeeConfig sets the old EmployeeConfig of the mutation.
  13005. func withEmployeeConfig(node *EmployeeConfig) employeeconfigOption {
  13006. return func(m *EmployeeConfigMutation) {
  13007. m.oldValue = func(context.Context) (*EmployeeConfig, error) {
  13008. return node, nil
  13009. }
  13010. m.id = &node.ID
  13011. }
  13012. }
  13013. // Client returns a new `ent.Client` from the mutation. If the mutation was
  13014. // executed in a transaction (ent.Tx), a transactional client is returned.
  13015. func (m EmployeeConfigMutation) Client() *Client {
  13016. client := &Client{config: m.config}
  13017. client.init()
  13018. return client
  13019. }
  13020. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  13021. // it returns an error otherwise.
  13022. func (m EmployeeConfigMutation) Tx() (*Tx, error) {
  13023. if _, ok := m.driver.(*txDriver); !ok {
  13024. return nil, errors.New("ent: mutation is not running in a transaction")
  13025. }
  13026. tx := &Tx{config: m.config}
  13027. tx.init()
  13028. return tx, nil
  13029. }
  13030. // SetID sets the value of the id field. Note that this
  13031. // operation is only accepted on creation of EmployeeConfig entities.
  13032. func (m *EmployeeConfigMutation) SetID(id uint64) {
  13033. m.id = &id
  13034. }
  13035. // ID returns the ID value in the mutation. Note that the ID is only available
  13036. // if it was provided to the builder or after it was returned from the database.
  13037. func (m *EmployeeConfigMutation) ID() (id uint64, exists bool) {
  13038. if m.id == nil {
  13039. return
  13040. }
  13041. return *m.id, true
  13042. }
  13043. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  13044. // That means, if the mutation is applied within a transaction with an isolation level such
  13045. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  13046. // or updated by the mutation.
  13047. func (m *EmployeeConfigMutation) IDs(ctx context.Context) ([]uint64, error) {
  13048. switch {
  13049. case m.op.Is(OpUpdateOne | OpDeleteOne):
  13050. id, exists := m.ID()
  13051. if exists {
  13052. return []uint64{id}, nil
  13053. }
  13054. fallthrough
  13055. case m.op.Is(OpUpdate | OpDelete):
  13056. return m.Client().EmployeeConfig.Query().Where(m.predicates...).IDs(ctx)
  13057. default:
  13058. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  13059. }
  13060. }
  13061. // SetCreatedAt sets the "created_at" field.
  13062. func (m *EmployeeConfigMutation) SetCreatedAt(t time.Time) {
  13063. m.created_at = &t
  13064. }
  13065. // CreatedAt returns the value of the "created_at" field in the mutation.
  13066. func (m *EmployeeConfigMutation) CreatedAt() (r time.Time, exists bool) {
  13067. v := m.created_at
  13068. if v == nil {
  13069. return
  13070. }
  13071. return *v, true
  13072. }
  13073. // OldCreatedAt returns the old "created_at" field's value of the EmployeeConfig entity.
  13074. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  13075. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13076. func (m *EmployeeConfigMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  13077. if !m.op.Is(OpUpdateOne) {
  13078. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  13079. }
  13080. if m.id == nil || m.oldValue == nil {
  13081. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  13082. }
  13083. oldValue, err := m.oldValue(ctx)
  13084. if err != nil {
  13085. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  13086. }
  13087. return oldValue.CreatedAt, nil
  13088. }
  13089. // ResetCreatedAt resets all changes to the "created_at" field.
  13090. func (m *EmployeeConfigMutation) ResetCreatedAt() {
  13091. m.created_at = nil
  13092. }
  13093. // SetUpdatedAt sets the "updated_at" field.
  13094. func (m *EmployeeConfigMutation) SetUpdatedAt(t time.Time) {
  13095. m.updated_at = &t
  13096. }
  13097. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  13098. func (m *EmployeeConfigMutation) UpdatedAt() (r time.Time, exists bool) {
  13099. v := m.updated_at
  13100. if v == nil {
  13101. return
  13102. }
  13103. return *v, true
  13104. }
  13105. // OldUpdatedAt returns the old "updated_at" field's value of the EmployeeConfig entity.
  13106. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  13107. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13108. func (m *EmployeeConfigMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  13109. if !m.op.Is(OpUpdateOne) {
  13110. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  13111. }
  13112. if m.id == nil || m.oldValue == nil {
  13113. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  13114. }
  13115. oldValue, err := m.oldValue(ctx)
  13116. if err != nil {
  13117. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  13118. }
  13119. return oldValue.UpdatedAt, nil
  13120. }
  13121. // ResetUpdatedAt resets all changes to the "updated_at" field.
  13122. func (m *EmployeeConfigMutation) ResetUpdatedAt() {
  13123. m.updated_at = nil
  13124. }
  13125. // SetDeletedAt sets the "deleted_at" field.
  13126. func (m *EmployeeConfigMutation) SetDeletedAt(t time.Time) {
  13127. m.deleted_at = &t
  13128. }
  13129. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  13130. func (m *EmployeeConfigMutation) DeletedAt() (r time.Time, exists bool) {
  13131. v := m.deleted_at
  13132. if v == nil {
  13133. return
  13134. }
  13135. return *v, true
  13136. }
  13137. // OldDeletedAt returns the old "deleted_at" field's value of the EmployeeConfig entity.
  13138. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  13139. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13140. func (m *EmployeeConfigMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  13141. if !m.op.Is(OpUpdateOne) {
  13142. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  13143. }
  13144. if m.id == nil || m.oldValue == nil {
  13145. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  13146. }
  13147. oldValue, err := m.oldValue(ctx)
  13148. if err != nil {
  13149. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  13150. }
  13151. return oldValue.DeletedAt, nil
  13152. }
  13153. // ClearDeletedAt clears the value of the "deleted_at" field.
  13154. func (m *EmployeeConfigMutation) ClearDeletedAt() {
  13155. m.deleted_at = nil
  13156. m.clearedFields[employeeconfig.FieldDeletedAt] = struct{}{}
  13157. }
  13158. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  13159. func (m *EmployeeConfigMutation) DeletedAtCleared() bool {
  13160. _, ok := m.clearedFields[employeeconfig.FieldDeletedAt]
  13161. return ok
  13162. }
  13163. // ResetDeletedAt resets all changes to the "deleted_at" field.
  13164. func (m *EmployeeConfigMutation) ResetDeletedAt() {
  13165. m.deleted_at = nil
  13166. delete(m.clearedFields, employeeconfig.FieldDeletedAt)
  13167. }
  13168. // SetStype sets the "stype" field.
  13169. func (m *EmployeeConfigMutation) SetStype(s string) {
  13170. m.stype = &s
  13171. }
  13172. // Stype returns the value of the "stype" field in the mutation.
  13173. func (m *EmployeeConfigMutation) Stype() (r string, exists bool) {
  13174. v := m.stype
  13175. if v == nil {
  13176. return
  13177. }
  13178. return *v, true
  13179. }
  13180. // OldStype returns the old "stype" field's value of the EmployeeConfig entity.
  13181. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  13182. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13183. func (m *EmployeeConfigMutation) OldStype(ctx context.Context) (v string, err error) {
  13184. if !m.op.Is(OpUpdateOne) {
  13185. return v, errors.New("OldStype is only allowed on UpdateOne operations")
  13186. }
  13187. if m.id == nil || m.oldValue == nil {
  13188. return v, errors.New("OldStype requires an ID field in the mutation")
  13189. }
  13190. oldValue, err := m.oldValue(ctx)
  13191. if err != nil {
  13192. return v, fmt.Errorf("querying old value for OldStype: %w", err)
  13193. }
  13194. return oldValue.Stype, nil
  13195. }
  13196. // ResetStype resets all changes to the "stype" field.
  13197. func (m *EmployeeConfigMutation) ResetStype() {
  13198. m.stype = nil
  13199. }
  13200. // SetTitle sets the "title" field.
  13201. func (m *EmployeeConfigMutation) SetTitle(s string) {
  13202. m.title = &s
  13203. }
  13204. // Title returns the value of the "title" field in the mutation.
  13205. func (m *EmployeeConfigMutation) Title() (r string, exists bool) {
  13206. v := m.title
  13207. if v == nil {
  13208. return
  13209. }
  13210. return *v, true
  13211. }
  13212. // OldTitle returns the old "title" field's value of the EmployeeConfig entity.
  13213. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  13214. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13215. func (m *EmployeeConfigMutation) OldTitle(ctx context.Context) (v string, err error) {
  13216. if !m.op.Is(OpUpdateOne) {
  13217. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  13218. }
  13219. if m.id == nil || m.oldValue == nil {
  13220. return v, errors.New("OldTitle requires an ID field in the mutation")
  13221. }
  13222. oldValue, err := m.oldValue(ctx)
  13223. if err != nil {
  13224. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  13225. }
  13226. return oldValue.Title, nil
  13227. }
  13228. // ResetTitle resets all changes to the "title" field.
  13229. func (m *EmployeeConfigMutation) ResetTitle() {
  13230. m.title = nil
  13231. }
  13232. // SetPhoto sets the "photo" field.
  13233. func (m *EmployeeConfigMutation) SetPhoto(s string) {
  13234. m.photo = &s
  13235. }
  13236. // Photo returns the value of the "photo" field in the mutation.
  13237. func (m *EmployeeConfigMutation) Photo() (r string, exists bool) {
  13238. v := m.photo
  13239. if v == nil {
  13240. return
  13241. }
  13242. return *v, true
  13243. }
  13244. // OldPhoto returns the old "photo" field's value of the EmployeeConfig entity.
  13245. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  13246. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13247. func (m *EmployeeConfigMutation) OldPhoto(ctx context.Context) (v string, err error) {
  13248. if !m.op.Is(OpUpdateOne) {
  13249. return v, errors.New("OldPhoto is only allowed on UpdateOne operations")
  13250. }
  13251. if m.id == nil || m.oldValue == nil {
  13252. return v, errors.New("OldPhoto requires an ID field in the mutation")
  13253. }
  13254. oldValue, err := m.oldValue(ctx)
  13255. if err != nil {
  13256. return v, fmt.Errorf("querying old value for OldPhoto: %w", err)
  13257. }
  13258. return oldValue.Photo, nil
  13259. }
  13260. // ResetPhoto resets all changes to the "photo" field.
  13261. func (m *EmployeeConfigMutation) ResetPhoto() {
  13262. m.photo = nil
  13263. }
  13264. // SetOrganizationID sets the "organization_id" field.
  13265. func (m *EmployeeConfigMutation) SetOrganizationID(u uint64) {
  13266. m.organization_id = &u
  13267. m.addorganization_id = nil
  13268. }
  13269. // OrganizationID returns the value of the "organization_id" field in the mutation.
  13270. func (m *EmployeeConfigMutation) OrganizationID() (r uint64, exists bool) {
  13271. v := m.organization_id
  13272. if v == nil {
  13273. return
  13274. }
  13275. return *v, true
  13276. }
  13277. // OldOrganizationID returns the old "organization_id" field's value of the EmployeeConfig entity.
  13278. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  13279. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13280. func (m *EmployeeConfigMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  13281. if !m.op.Is(OpUpdateOne) {
  13282. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  13283. }
  13284. if m.id == nil || m.oldValue == nil {
  13285. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  13286. }
  13287. oldValue, err := m.oldValue(ctx)
  13288. if err != nil {
  13289. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  13290. }
  13291. return oldValue.OrganizationID, nil
  13292. }
  13293. // AddOrganizationID adds u to the "organization_id" field.
  13294. func (m *EmployeeConfigMutation) AddOrganizationID(u int64) {
  13295. if m.addorganization_id != nil {
  13296. *m.addorganization_id += u
  13297. } else {
  13298. m.addorganization_id = &u
  13299. }
  13300. }
  13301. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  13302. func (m *EmployeeConfigMutation) AddedOrganizationID() (r int64, exists bool) {
  13303. v := m.addorganization_id
  13304. if v == nil {
  13305. return
  13306. }
  13307. return *v, true
  13308. }
  13309. // ClearOrganizationID clears the value of the "organization_id" field.
  13310. func (m *EmployeeConfigMutation) ClearOrganizationID() {
  13311. m.organization_id = nil
  13312. m.addorganization_id = nil
  13313. m.clearedFields[employeeconfig.FieldOrganizationID] = struct{}{}
  13314. }
  13315. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  13316. func (m *EmployeeConfigMutation) OrganizationIDCleared() bool {
  13317. _, ok := m.clearedFields[employeeconfig.FieldOrganizationID]
  13318. return ok
  13319. }
  13320. // ResetOrganizationID resets all changes to the "organization_id" field.
  13321. func (m *EmployeeConfigMutation) ResetOrganizationID() {
  13322. m.organization_id = nil
  13323. m.addorganization_id = nil
  13324. delete(m.clearedFields, employeeconfig.FieldOrganizationID)
  13325. }
  13326. // Where appends a list predicates to the EmployeeConfigMutation builder.
  13327. func (m *EmployeeConfigMutation) Where(ps ...predicate.EmployeeConfig) {
  13328. m.predicates = append(m.predicates, ps...)
  13329. }
  13330. // WhereP appends storage-level predicates to the EmployeeConfigMutation builder. Using this method,
  13331. // users can use type-assertion to append predicates that do not depend on any generated package.
  13332. func (m *EmployeeConfigMutation) WhereP(ps ...func(*sql.Selector)) {
  13333. p := make([]predicate.EmployeeConfig, len(ps))
  13334. for i := range ps {
  13335. p[i] = ps[i]
  13336. }
  13337. m.Where(p...)
  13338. }
  13339. // Op returns the operation name.
  13340. func (m *EmployeeConfigMutation) Op() Op {
  13341. return m.op
  13342. }
  13343. // SetOp allows setting the mutation operation.
  13344. func (m *EmployeeConfigMutation) SetOp(op Op) {
  13345. m.op = op
  13346. }
  13347. // Type returns the node type of this mutation (EmployeeConfig).
  13348. func (m *EmployeeConfigMutation) Type() string {
  13349. return m.typ
  13350. }
  13351. // Fields returns all fields that were changed during this mutation. Note that in
  13352. // order to get all numeric fields that were incremented/decremented, call
  13353. // AddedFields().
  13354. func (m *EmployeeConfigMutation) Fields() []string {
  13355. fields := make([]string, 0, 7)
  13356. if m.created_at != nil {
  13357. fields = append(fields, employeeconfig.FieldCreatedAt)
  13358. }
  13359. if m.updated_at != nil {
  13360. fields = append(fields, employeeconfig.FieldUpdatedAt)
  13361. }
  13362. if m.deleted_at != nil {
  13363. fields = append(fields, employeeconfig.FieldDeletedAt)
  13364. }
  13365. if m.stype != nil {
  13366. fields = append(fields, employeeconfig.FieldStype)
  13367. }
  13368. if m.title != nil {
  13369. fields = append(fields, employeeconfig.FieldTitle)
  13370. }
  13371. if m.photo != nil {
  13372. fields = append(fields, employeeconfig.FieldPhoto)
  13373. }
  13374. if m.organization_id != nil {
  13375. fields = append(fields, employeeconfig.FieldOrganizationID)
  13376. }
  13377. return fields
  13378. }
  13379. // Field returns the value of a field with the given name. The second boolean
  13380. // return value indicates that this field was not set, or was not defined in the
  13381. // schema.
  13382. func (m *EmployeeConfigMutation) Field(name string) (ent.Value, bool) {
  13383. switch name {
  13384. case employeeconfig.FieldCreatedAt:
  13385. return m.CreatedAt()
  13386. case employeeconfig.FieldUpdatedAt:
  13387. return m.UpdatedAt()
  13388. case employeeconfig.FieldDeletedAt:
  13389. return m.DeletedAt()
  13390. case employeeconfig.FieldStype:
  13391. return m.Stype()
  13392. case employeeconfig.FieldTitle:
  13393. return m.Title()
  13394. case employeeconfig.FieldPhoto:
  13395. return m.Photo()
  13396. case employeeconfig.FieldOrganizationID:
  13397. return m.OrganizationID()
  13398. }
  13399. return nil, false
  13400. }
  13401. // OldField returns the old value of the field from the database. An error is
  13402. // returned if the mutation operation is not UpdateOne, or the query to the
  13403. // database failed.
  13404. func (m *EmployeeConfigMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  13405. switch name {
  13406. case employeeconfig.FieldCreatedAt:
  13407. return m.OldCreatedAt(ctx)
  13408. case employeeconfig.FieldUpdatedAt:
  13409. return m.OldUpdatedAt(ctx)
  13410. case employeeconfig.FieldDeletedAt:
  13411. return m.OldDeletedAt(ctx)
  13412. case employeeconfig.FieldStype:
  13413. return m.OldStype(ctx)
  13414. case employeeconfig.FieldTitle:
  13415. return m.OldTitle(ctx)
  13416. case employeeconfig.FieldPhoto:
  13417. return m.OldPhoto(ctx)
  13418. case employeeconfig.FieldOrganizationID:
  13419. return m.OldOrganizationID(ctx)
  13420. }
  13421. return nil, fmt.Errorf("unknown EmployeeConfig field %s", name)
  13422. }
  13423. // SetField sets the value of a field with the given name. It returns an error if
  13424. // the field is not defined in the schema, or if the type mismatched the field
  13425. // type.
  13426. func (m *EmployeeConfigMutation) SetField(name string, value ent.Value) error {
  13427. switch name {
  13428. case employeeconfig.FieldCreatedAt:
  13429. v, ok := value.(time.Time)
  13430. if !ok {
  13431. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13432. }
  13433. m.SetCreatedAt(v)
  13434. return nil
  13435. case employeeconfig.FieldUpdatedAt:
  13436. v, ok := value.(time.Time)
  13437. if !ok {
  13438. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13439. }
  13440. m.SetUpdatedAt(v)
  13441. return nil
  13442. case employeeconfig.FieldDeletedAt:
  13443. v, ok := value.(time.Time)
  13444. if !ok {
  13445. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13446. }
  13447. m.SetDeletedAt(v)
  13448. return nil
  13449. case employeeconfig.FieldStype:
  13450. v, ok := value.(string)
  13451. if !ok {
  13452. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13453. }
  13454. m.SetStype(v)
  13455. return nil
  13456. case employeeconfig.FieldTitle:
  13457. v, ok := value.(string)
  13458. if !ok {
  13459. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13460. }
  13461. m.SetTitle(v)
  13462. return nil
  13463. case employeeconfig.FieldPhoto:
  13464. v, ok := value.(string)
  13465. if !ok {
  13466. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13467. }
  13468. m.SetPhoto(v)
  13469. return nil
  13470. case employeeconfig.FieldOrganizationID:
  13471. v, ok := value.(uint64)
  13472. if !ok {
  13473. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13474. }
  13475. m.SetOrganizationID(v)
  13476. return nil
  13477. }
  13478. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  13479. }
  13480. // AddedFields returns all numeric fields that were incremented/decremented during
  13481. // this mutation.
  13482. func (m *EmployeeConfigMutation) AddedFields() []string {
  13483. var fields []string
  13484. if m.addorganization_id != nil {
  13485. fields = append(fields, employeeconfig.FieldOrganizationID)
  13486. }
  13487. return fields
  13488. }
  13489. // AddedField returns the numeric value that was incremented/decremented on a field
  13490. // with the given name. The second boolean return value indicates that this field
  13491. // was not set, or was not defined in the schema.
  13492. func (m *EmployeeConfigMutation) AddedField(name string) (ent.Value, bool) {
  13493. switch name {
  13494. case employeeconfig.FieldOrganizationID:
  13495. return m.AddedOrganizationID()
  13496. }
  13497. return nil, false
  13498. }
  13499. // AddField adds the value to the field with the given name. It returns an error if
  13500. // the field is not defined in the schema, or if the type mismatched the field
  13501. // type.
  13502. func (m *EmployeeConfigMutation) AddField(name string, value ent.Value) error {
  13503. switch name {
  13504. case employeeconfig.FieldOrganizationID:
  13505. v, ok := value.(int64)
  13506. if !ok {
  13507. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13508. }
  13509. m.AddOrganizationID(v)
  13510. return nil
  13511. }
  13512. return fmt.Errorf("unknown EmployeeConfig numeric field %s", name)
  13513. }
  13514. // ClearedFields returns all nullable fields that were cleared during this
  13515. // mutation.
  13516. func (m *EmployeeConfigMutation) ClearedFields() []string {
  13517. var fields []string
  13518. if m.FieldCleared(employeeconfig.FieldDeletedAt) {
  13519. fields = append(fields, employeeconfig.FieldDeletedAt)
  13520. }
  13521. if m.FieldCleared(employeeconfig.FieldOrganizationID) {
  13522. fields = append(fields, employeeconfig.FieldOrganizationID)
  13523. }
  13524. return fields
  13525. }
  13526. // FieldCleared returns a boolean indicating if a field with the given name was
  13527. // cleared in this mutation.
  13528. func (m *EmployeeConfigMutation) FieldCleared(name string) bool {
  13529. _, ok := m.clearedFields[name]
  13530. return ok
  13531. }
  13532. // ClearField clears the value of the field with the given name. It returns an
  13533. // error if the field is not defined in the schema.
  13534. func (m *EmployeeConfigMutation) ClearField(name string) error {
  13535. switch name {
  13536. case employeeconfig.FieldDeletedAt:
  13537. m.ClearDeletedAt()
  13538. return nil
  13539. case employeeconfig.FieldOrganizationID:
  13540. m.ClearOrganizationID()
  13541. return nil
  13542. }
  13543. return fmt.Errorf("unknown EmployeeConfig nullable field %s", name)
  13544. }
  13545. // ResetField resets all changes in the mutation for the field with the given name.
  13546. // It returns an error if the field is not defined in the schema.
  13547. func (m *EmployeeConfigMutation) ResetField(name string) error {
  13548. switch name {
  13549. case employeeconfig.FieldCreatedAt:
  13550. m.ResetCreatedAt()
  13551. return nil
  13552. case employeeconfig.FieldUpdatedAt:
  13553. m.ResetUpdatedAt()
  13554. return nil
  13555. case employeeconfig.FieldDeletedAt:
  13556. m.ResetDeletedAt()
  13557. return nil
  13558. case employeeconfig.FieldStype:
  13559. m.ResetStype()
  13560. return nil
  13561. case employeeconfig.FieldTitle:
  13562. m.ResetTitle()
  13563. return nil
  13564. case employeeconfig.FieldPhoto:
  13565. m.ResetPhoto()
  13566. return nil
  13567. case employeeconfig.FieldOrganizationID:
  13568. m.ResetOrganizationID()
  13569. return nil
  13570. }
  13571. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  13572. }
  13573. // AddedEdges returns all edge names that were set/added in this mutation.
  13574. func (m *EmployeeConfigMutation) AddedEdges() []string {
  13575. edges := make([]string, 0, 0)
  13576. return edges
  13577. }
  13578. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  13579. // name in this mutation.
  13580. func (m *EmployeeConfigMutation) AddedIDs(name string) []ent.Value {
  13581. return nil
  13582. }
  13583. // RemovedEdges returns all edge names that were removed in this mutation.
  13584. func (m *EmployeeConfigMutation) RemovedEdges() []string {
  13585. edges := make([]string, 0, 0)
  13586. return edges
  13587. }
  13588. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  13589. // the given name in this mutation.
  13590. func (m *EmployeeConfigMutation) RemovedIDs(name string) []ent.Value {
  13591. return nil
  13592. }
  13593. // ClearedEdges returns all edge names that were cleared in this mutation.
  13594. func (m *EmployeeConfigMutation) ClearedEdges() []string {
  13595. edges := make([]string, 0, 0)
  13596. return edges
  13597. }
  13598. // EdgeCleared returns a boolean which indicates if the edge with the given name
  13599. // was cleared in this mutation.
  13600. func (m *EmployeeConfigMutation) EdgeCleared(name string) bool {
  13601. return false
  13602. }
  13603. // ClearEdge clears the value of the edge with the given name. It returns an error
  13604. // if that edge is not defined in the schema.
  13605. func (m *EmployeeConfigMutation) ClearEdge(name string) error {
  13606. return fmt.Errorf("unknown EmployeeConfig unique edge %s", name)
  13607. }
  13608. // ResetEdge resets all changes to the edge with the given name in this mutation.
  13609. // It returns an error if the edge is not defined in the schema.
  13610. func (m *EmployeeConfigMutation) ResetEdge(name string) error {
  13611. return fmt.Errorf("unknown EmployeeConfig edge %s", name)
  13612. }
  13613. // LabelMutation represents an operation that mutates the Label nodes in the graph.
  13614. type LabelMutation struct {
  13615. config
  13616. op Op
  13617. typ string
  13618. id *uint64
  13619. created_at *time.Time
  13620. updated_at *time.Time
  13621. status *uint8
  13622. addstatus *int8
  13623. _type *int
  13624. add_type *int
  13625. name *string
  13626. from *int
  13627. addfrom *int
  13628. mode *int
  13629. addmode *int
  13630. conditions *string
  13631. organization_id *uint64
  13632. addorganization_id *int64
  13633. clearedFields map[string]struct{}
  13634. label_relationships map[uint64]struct{}
  13635. removedlabel_relationships map[uint64]struct{}
  13636. clearedlabel_relationships bool
  13637. done bool
  13638. oldValue func(context.Context) (*Label, error)
  13639. predicates []predicate.Label
  13640. }
  13641. var _ ent.Mutation = (*LabelMutation)(nil)
  13642. // labelOption allows management of the mutation configuration using functional options.
  13643. type labelOption func(*LabelMutation)
  13644. // newLabelMutation creates new mutation for the Label entity.
  13645. func newLabelMutation(c config, op Op, opts ...labelOption) *LabelMutation {
  13646. m := &LabelMutation{
  13647. config: c,
  13648. op: op,
  13649. typ: TypeLabel,
  13650. clearedFields: make(map[string]struct{}),
  13651. }
  13652. for _, opt := range opts {
  13653. opt(m)
  13654. }
  13655. return m
  13656. }
  13657. // withLabelID sets the ID field of the mutation.
  13658. func withLabelID(id uint64) labelOption {
  13659. return func(m *LabelMutation) {
  13660. var (
  13661. err error
  13662. once sync.Once
  13663. value *Label
  13664. )
  13665. m.oldValue = func(ctx context.Context) (*Label, error) {
  13666. once.Do(func() {
  13667. if m.done {
  13668. err = errors.New("querying old values post mutation is not allowed")
  13669. } else {
  13670. value, err = m.Client().Label.Get(ctx, id)
  13671. }
  13672. })
  13673. return value, err
  13674. }
  13675. m.id = &id
  13676. }
  13677. }
  13678. // withLabel sets the old Label of the mutation.
  13679. func withLabel(node *Label) labelOption {
  13680. return func(m *LabelMutation) {
  13681. m.oldValue = func(context.Context) (*Label, error) {
  13682. return node, nil
  13683. }
  13684. m.id = &node.ID
  13685. }
  13686. }
  13687. // Client returns a new `ent.Client` from the mutation. If the mutation was
  13688. // executed in a transaction (ent.Tx), a transactional client is returned.
  13689. func (m LabelMutation) Client() *Client {
  13690. client := &Client{config: m.config}
  13691. client.init()
  13692. return client
  13693. }
  13694. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  13695. // it returns an error otherwise.
  13696. func (m LabelMutation) Tx() (*Tx, error) {
  13697. if _, ok := m.driver.(*txDriver); !ok {
  13698. return nil, errors.New("ent: mutation is not running in a transaction")
  13699. }
  13700. tx := &Tx{config: m.config}
  13701. tx.init()
  13702. return tx, nil
  13703. }
  13704. // SetID sets the value of the id field. Note that this
  13705. // operation is only accepted on creation of Label entities.
  13706. func (m *LabelMutation) SetID(id uint64) {
  13707. m.id = &id
  13708. }
  13709. // ID returns the ID value in the mutation. Note that the ID is only available
  13710. // if it was provided to the builder or after it was returned from the database.
  13711. func (m *LabelMutation) ID() (id uint64, exists bool) {
  13712. if m.id == nil {
  13713. return
  13714. }
  13715. return *m.id, true
  13716. }
  13717. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  13718. // That means, if the mutation is applied within a transaction with an isolation level such
  13719. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  13720. // or updated by the mutation.
  13721. func (m *LabelMutation) IDs(ctx context.Context) ([]uint64, error) {
  13722. switch {
  13723. case m.op.Is(OpUpdateOne | OpDeleteOne):
  13724. id, exists := m.ID()
  13725. if exists {
  13726. return []uint64{id}, nil
  13727. }
  13728. fallthrough
  13729. case m.op.Is(OpUpdate | OpDelete):
  13730. return m.Client().Label.Query().Where(m.predicates...).IDs(ctx)
  13731. default:
  13732. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  13733. }
  13734. }
  13735. // SetCreatedAt sets the "created_at" field.
  13736. func (m *LabelMutation) SetCreatedAt(t time.Time) {
  13737. m.created_at = &t
  13738. }
  13739. // CreatedAt returns the value of the "created_at" field in the mutation.
  13740. func (m *LabelMutation) CreatedAt() (r time.Time, exists bool) {
  13741. v := m.created_at
  13742. if v == nil {
  13743. return
  13744. }
  13745. return *v, true
  13746. }
  13747. // OldCreatedAt returns the old "created_at" field's value of the Label entity.
  13748. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  13749. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13750. func (m *LabelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  13751. if !m.op.Is(OpUpdateOne) {
  13752. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  13753. }
  13754. if m.id == nil || m.oldValue == nil {
  13755. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  13756. }
  13757. oldValue, err := m.oldValue(ctx)
  13758. if err != nil {
  13759. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  13760. }
  13761. return oldValue.CreatedAt, nil
  13762. }
  13763. // ResetCreatedAt resets all changes to the "created_at" field.
  13764. func (m *LabelMutation) ResetCreatedAt() {
  13765. m.created_at = nil
  13766. }
  13767. // SetUpdatedAt sets the "updated_at" field.
  13768. func (m *LabelMutation) SetUpdatedAt(t time.Time) {
  13769. m.updated_at = &t
  13770. }
  13771. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  13772. func (m *LabelMutation) UpdatedAt() (r time.Time, exists bool) {
  13773. v := m.updated_at
  13774. if v == nil {
  13775. return
  13776. }
  13777. return *v, true
  13778. }
  13779. // OldUpdatedAt returns the old "updated_at" field's value of the Label entity.
  13780. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  13781. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13782. func (m *LabelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  13783. if !m.op.Is(OpUpdateOne) {
  13784. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  13785. }
  13786. if m.id == nil || m.oldValue == nil {
  13787. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  13788. }
  13789. oldValue, err := m.oldValue(ctx)
  13790. if err != nil {
  13791. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  13792. }
  13793. return oldValue.UpdatedAt, nil
  13794. }
  13795. // ResetUpdatedAt resets all changes to the "updated_at" field.
  13796. func (m *LabelMutation) ResetUpdatedAt() {
  13797. m.updated_at = nil
  13798. }
  13799. // SetStatus sets the "status" field.
  13800. func (m *LabelMutation) SetStatus(u uint8) {
  13801. m.status = &u
  13802. m.addstatus = nil
  13803. }
  13804. // Status returns the value of the "status" field in the mutation.
  13805. func (m *LabelMutation) Status() (r uint8, exists bool) {
  13806. v := m.status
  13807. if v == nil {
  13808. return
  13809. }
  13810. return *v, true
  13811. }
  13812. // OldStatus returns the old "status" field's value of the Label entity.
  13813. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  13814. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13815. func (m *LabelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  13816. if !m.op.Is(OpUpdateOne) {
  13817. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  13818. }
  13819. if m.id == nil || m.oldValue == nil {
  13820. return v, errors.New("OldStatus requires an ID field in the mutation")
  13821. }
  13822. oldValue, err := m.oldValue(ctx)
  13823. if err != nil {
  13824. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  13825. }
  13826. return oldValue.Status, nil
  13827. }
  13828. // AddStatus adds u to the "status" field.
  13829. func (m *LabelMutation) AddStatus(u int8) {
  13830. if m.addstatus != nil {
  13831. *m.addstatus += u
  13832. } else {
  13833. m.addstatus = &u
  13834. }
  13835. }
  13836. // AddedStatus returns the value that was added to the "status" field in this mutation.
  13837. func (m *LabelMutation) AddedStatus() (r int8, exists bool) {
  13838. v := m.addstatus
  13839. if v == nil {
  13840. return
  13841. }
  13842. return *v, true
  13843. }
  13844. // ClearStatus clears the value of the "status" field.
  13845. func (m *LabelMutation) ClearStatus() {
  13846. m.status = nil
  13847. m.addstatus = nil
  13848. m.clearedFields[label.FieldStatus] = struct{}{}
  13849. }
  13850. // StatusCleared returns if the "status" field was cleared in this mutation.
  13851. func (m *LabelMutation) StatusCleared() bool {
  13852. _, ok := m.clearedFields[label.FieldStatus]
  13853. return ok
  13854. }
  13855. // ResetStatus resets all changes to the "status" field.
  13856. func (m *LabelMutation) ResetStatus() {
  13857. m.status = nil
  13858. m.addstatus = nil
  13859. delete(m.clearedFields, label.FieldStatus)
  13860. }
  13861. // SetType sets the "type" field.
  13862. func (m *LabelMutation) SetType(i int) {
  13863. m._type = &i
  13864. m.add_type = nil
  13865. }
  13866. // GetType returns the value of the "type" field in the mutation.
  13867. func (m *LabelMutation) GetType() (r int, exists bool) {
  13868. v := m._type
  13869. if v == nil {
  13870. return
  13871. }
  13872. return *v, true
  13873. }
  13874. // OldType returns the old "type" field's value of the Label entity.
  13875. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  13876. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13877. func (m *LabelMutation) OldType(ctx context.Context) (v int, err error) {
  13878. if !m.op.Is(OpUpdateOne) {
  13879. return v, errors.New("OldType is only allowed on UpdateOne operations")
  13880. }
  13881. if m.id == nil || m.oldValue == nil {
  13882. return v, errors.New("OldType requires an ID field in the mutation")
  13883. }
  13884. oldValue, err := m.oldValue(ctx)
  13885. if err != nil {
  13886. return v, fmt.Errorf("querying old value for OldType: %w", err)
  13887. }
  13888. return oldValue.Type, nil
  13889. }
  13890. // AddType adds i to the "type" field.
  13891. func (m *LabelMutation) AddType(i int) {
  13892. if m.add_type != nil {
  13893. *m.add_type += i
  13894. } else {
  13895. m.add_type = &i
  13896. }
  13897. }
  13898. // AddedType returns the value that was added to the "type" field in this mutation.
  13899. func (m *LabelMutation) AddedType() (r int, exists bool) {
  13900. v := m.add_type
  13901. if v == nil {
  13902. return
  13903. }
  13904. return *v, true
  13905. }
  13906. // ResetType resets all changes to the "type" field.
  13907. func (m *LabelMutation) ResetType() {
  13908. m._type = nil
  13909. m.add_type = nil
  13910. }
  13911. // SetName sets the "name" field.
  13912. func (m *LabelMutation) SetName(s string) {
  13913. m.name = &s
  13914. }
  13915. // Name returns the value of the "name" field in the mutation.
  13916. func (m *LabelMutation) Name() (r string, exists bool) {
  13917. v := m.name
  13918. if v == nil {
  13919. return
  13920. }
  13921. return *v, true
  13922. }
  13923. // OldName returns the old "name" field's value of the Label entity.
  13924. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  13925. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13926. func (m *LabelMutation) OldName(ctx context.Context) (v string, err error) {
  13927. if !m.op.Is(OpUpdateOne) {
  13928. return v, errors.New("OldName is only allowed on UpdateOne operations")
  13929. }
  13930. if m.id == nil || m.oldValue == nil {
  13931. return v, errors.New("OldName requires an ID field in the mutation")
  13932. }
  13933. oldValue, err := m.oldValue(ctx)
  13934. if err != nil {
  13935. return v, fmt.Errorf("querying old value for OldName: %w", err)
  13936. }
  13937. return oldValue.Name, nil
  13938. }
  13939. // ResetName resets all changes to the "name" field.
  13940. func (m *LabelMutation) ResetName() {
  13941. m.name = nil
  13942. }
  13943. // SetFrom sets the "from" field.
  13944. func (m *LabelMutation) SetFrom(i int) {
  13945. m.from = &i
  13946. m.addfrom = nil
  13947. }
  13948. // From returns the value of the "from" field in the mutation.
  13949. func (m *LabelMutation) From() (r int, exists bool) {
  13950. v := m.from
  13951. if v == nil {
  13952. return
  13953. }
  13954. return *v, true
  13955. }
  13956. // OldFrom returns the old "from" field's value of the Label entity.
  13957. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  13958. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13959. func (m *LabelMutation) OldFrom(ctx context.Context) (v int, err error) {
  13960. if !m.op.Is(OpUpdateOne) {
  13961. return v, errors.New("OldFrom is only allowed on UpdateOne operations")
  13962. }
  13963. if m.id == nil || m.oldValue == nil {
  13964. return v, errors.New("OldFrom requires an ID field in the mutation")
  13965. }
  13966. oldValue, err := m.oldValue(ctx)
  13967. if err != nil {
  13968. return v, fmt.Errorf("querying old value for OldFrom: %w", err)
  13969. }
  13970. return oldValue.From, nil
  13971. }
  13972. // AddFrom adds i to the "from" field.
  13973. func (m *LabelMutation) AddFrom(i int) {
  13974. if m.addfrom != nil {
  13975. *m.addfrom += i
  13976. } else {
  13977. m.addfrom = &i
  13978. }
  13979. }
  13980. // AddedFrom returns the value that was added to the "from" field in this mutation.
  13981. func (m *LabelMutation) AddedFrom() (r int, exists bool) {
  13982. v := m.addfrom
  13983. if v == nil {
  13984. return
  13985. }
  13986. return *v, true
  13987. }
  13988. // ResetFrom resets all changes to the "from" field.
  13989. func (m *LabelMutation) ResetFrom() {
  13990. m.from = nil
  13991. m.addfrom = nil
  13992. }
  13993. // SetMode sets the "mode" field.
  13994. func (m *LabelMutation) SetMode(i int) {
  13995. m.mode = &i
  13996. m.addmode = nil
  13997. }
  13998. // Mode returns the value of the "mode" field in the mutation.
  13999. func (m *LabelMutation) Mode() (r int, exists bool) {
  14000. v := m.mode
  14001. if v == nil {
  14002. return
  14003. }
  14004. return *v, true
  14005. }
  14006. // OldMode returns the old "mode" field's value of the Label entity.
  14007. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  14008. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14009. func (m *LabelMutation) OldMode(ctx context.Context) (v int, err error) {
  14010. if !m.op.Is(OpUpdateOne) {
  14011. return v, errors.New("OldMode is only allowed on UpdateOne operations")
  14012. }
  14013. if m.id == nil || m.oldValue == nil {
  14014. return v, errors.New("OldMode requires an ID field in the mutation")
  14015. }
  14016. oldValue, err := m.oldValue(ctx)
  14017. if err != nil {
  14018. return v, fmt.Errorf("querying old value for OldMode: %w", err)
  14019. }
  14020. return oldValue.Mode, nil
  14021. }
  14022. // AddMode adds i to the "mode" field.
  14023. func (m *LabelMutation) AddMode(i int) {
  14024. if m.addmode != nil {
  14025. *m.addmode += i
  14026. } else {
  14027. m.addmode = &i
  14028. }
  14029. }
  14030. // AddedMode returns the value that was added to the "mode" field in this mutation.
  14031. func (m *LabelMutation) AddedMode() (r int, exists bool) {
  14032. v := m.addmode
  14033. if v == nil {
  14034. return
  14035. }
  14036. return *v, true
  14037. }
  14038. // ResetMode resets all changes to the "mode" field.
  14039. func (m *LabelMutation) ResetMode() {
  14040. m.mode = nil
  14041. m.addmode = nil
  14042. }
  14043. // SetConditions sets the "conditions" field.
  14044. func (m *LabelMutation) SetConditions(s string) {
  14045. m.conditions = &s
  14046. }
  14047. // Conditions returns the value of the "conditions" field in the mutation.
  14048. func (m *LabelMutation) Conditions() (r string, exists bool) {
  14049. v := m.conditions
  14050. if v == nil {
  14051. return
  14052. }
  14053. return *v, true
  14054. }
  14055. // OldConditions returns the old "conditions" field's value of the Label entity.
  14056. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  14057. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14058. func (m *LabelMutation) OldConditions(ctx context.Context) (v string, err error) {
  14059. if !m.op.Is(OpUpdateOne) {
  14060. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  14061. }
  14062. if m.id == nil || m.oldValue == nil {
  14063. return v, errors.New("OldConditions requires an ID field in the mutation")
  14064. }
  14065. oldValue, err := m.oldValue(ctx)
  14066. if err != nil {
  14067. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  14068. }
  14069. return oldValue.Conditions, nil
  14070. }
  14071. // ClearConditions clears the value of the "conditions" field.
  14072. func (m *LabelMutation) ClearConditions() {
  14073. m.conditions = nil
  14074. m.clearedFields[label.FieldConditions] = struct{}{}
  14075. }
  14076. // ConditionsCleared returns if the "conditions" field was cleared in this mutation.
  14077. func (m *LabelMutation) ConditionsCleared() bool {
  14078. _, ok := m.clearedFields[label.FieldConditions]
  14079. return ok
  14080. }
  14081. // ResetConditions resets all changes to the "conditions" field.
  14082. func (m *LabelMutation) ResetConditions() {
  14083. m.conditions = nil
  14084. delete(m.clearedFields, label.FieldConditions)
  14085. }
  14086. // SetOrganizationID sets the "organization_id" field.
  14087. func (m *LabelMutation) SetOrganizationID(u uint64) {
  14088. m.organization_id = &u
  14089. m.addorganization_id = nil
  14090. }
  14091. // OrganizationID returns the value of the "organization_id" field in the mutation.
  14092. func (m *LabelMutation) OrganizationID() (r uint64, exists bool) {
  14093. v := m.organization_id
  14094. if v == nil {
  14095. return
  14096. }
  14097. return *v, true
  14098. }
  14099. // OldOrganizationID returns the old "organization_id" field's value of the Label entity.
  14100. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  14101. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14102. func (m *LabelMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  14103. if !m.op.Is(OpUpdateOne) {
  14104. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  14105. }
  14106. if m.id == nil || m.oldValue == nil {
  14107. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  14108. }
  14109. oldValue, err := m.oldValue(ctx)
  14110. if err != nil {
  14111. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  14112. }
  14113. return oldValue.OrganizationID, nil
  14114. }
  14115. // AddOrganizationID adds u to the "organization_id" field.
  14116. func (m *LabelMutation) AddOrganizationID(u int64) {
  14117. if m.addorganization_id != nil {
  14118. *m.addorganization_id += u
  14119. } else {
  14120. m.addorganization_id = &u
  14121. }
  14122. }
  14123. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  14124. func (m *LabelMutation) AddedOrganizationID() (r int64, exists bool) {
  14125. v := m.addorganization_id
  14126. if v == nil {
  14127. return
  14128. }
  14129. return *v, true
  14130. }
  14131. // ClearOrganizationID clears the value of the "organization_id" field.
  14132. func (m *LabelMutation) ClearOrganizationID() {
  14133. m.organization_id = nil
  14134. m.addorganization_id = nil
  14135. m.clearedFields[label.FieldOrganizationID] = struct{}{}
  14136. }
  14137. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  14138. func (m *LabelMutation) OrganizationIDCleared() bool {
  14139. _, ok := m.clearedFields[label.FieldOrganizationID]
  14140. return ok
  14141. }
  14142. // ResetOrganizationID resets all changes to the "organization_id" field.
  14143. func (m *LabelMutation) ResetOrganizationID() {
  14144. m.organization_id = nil
  14145. m.addorganization_id = nil
  14146. delete(m.clearedFields, label.FieldOrganizationID)
  14147. }
  14148. // AddLabelRelationshipIDs adds the "label_relationships" edge to the LabelRelationship entity by ids.
  14149. func (m *LabelMutation) AddLabelRelationshipIDs(ids ...uint64) {
  14150. if m.label_relationships == nil {
  14151. m.label_relationships = make(map[uint64]struct{})
  14152. }
  14153. for i := range ids {
  14154. m.label_relationships[ids[i]] = struct{}{}
  14155. }
  14156. }
  14157. // ClearLabelRelationships clears the "label_relationships" edge to the LabelRelationship entity.
  14158. func (m *LabelMutation) ClearLabelRelationships() {
  14159. m.clearedlabel_relationships = true
  14160. }
  14161. // LabelRelationshipsCleared reports if the "label_relationships" edge to the LabelRelationship entity was cleared.
  14162. func (m *LabelMutation) LabelRelationshipsCleared() bool {
  14163. return m.clearedlabel_relationships
  14164. }
  14165. // RemoveLabelRelationshipIDs removes the "label_relationships" edge to the LabelRelationship entity by IDs.
  14166. func (m *LabelMutation) RemoveLabelRelationshipIDs(ids ...uint64) {
  14167. if m.removedlabel_relationships == nil {
  14168. m.removedlabel_relationships = make(map[uint64]struct{})
  14169. }
  14170. for i := range ids {
  14171. delete(m.label_relationships, ids[i])
  14172. m.removedlabel_relationships[ids[i]] = struct{}{}
  14173. }
  14174. }
  14175. // RemovedLabelRelationships returns the removed IDs of the "label_relationships" edge to the LabelRelationship entity.
  14176. func (m *LabelMutation) RemovedLabelRelationshipsIDs() (ids []uint64) {
  14177. for id := range m.removedlabel_relationships {
  14178. ids = append(ids, id)
  14179. }
  14180. return
  14181. }
  14182. // LabelRelationshipsIDs returns the "label_relationships" edge IDs in the mutation.
  14183. func (m *LabelMutation) LabelRelationshipsIDs() (ids []uint64) {
  14184. for id := range m.label_relationships {
  14185. ids = append(ids, id)
  14186. }
  14187. return
  14188. }
  14189. // ResetLabelRelationships resets all changes to the "label_relationships" edge.
  14190. func (m *LabelMutation) ResetLabelRelationships() {
  14191. m.label_relationships = nil
  14192. m.clearedlabel_relationships = false
  14193. m.removedlabel_relationships = nil
  14194. }
  14195. // Where appends a list predicates to the LabelMutation builder.
  14196. func (m *LabelMutation) Where(ps ...predicate.Label) {
  14197. m.predicates = append(m.predicates, ps...)
  14198. }
  14199. // WhereP appends storage-level predicates to the LabelMutation builder. Using this method,
  14200. // users can use type-assertion to append predicates that do not depend on any generated package.
  14201. func (m *LabelMutation) WhereP(ps ...func(*sql.Selector)) {
  14202. p := make([]predicate.Label, len(ps))
  14203. for i := range ps {
  14204. p[i] = ps[i]
  14205. }
  14206. m.Where(p...)
  14207. }
  14208. // Op returns the operation name.
  14209. func (m *LabelMutation) Op() Op {
  14210. return m.op
  14211. }
  14212. // SetOp allows setting the mutation operation.
  14213. func (m *LabelMutation) SetOp(op Op) {
  14214. m.op = op
  14215. }
  14216. // Type returns the node type of this mutation (Label).
  14217. func (m *LabelMutation) Type() string {
  14218. return m.typ
  14219. }
  14220. // Fields returns all fields that were changed during this mutation. Note that in
  14221. // order to get all numeric fields that were incremented/decremented, call
  14222. // AddedFields().
  14223. func (m *LabelMutation) Fields() []string {
  14224. fields := make([]string, 0, 9)
  14225. if m.created_at != nil {
  14226. fields = append(fields, label.FieldCreatedAt)
  14227. }
  14228. if m.updated_at != nil {
  14229. fields = append(fields, label.FieldUpdatedAt)
  14230. }
  14231. if m.status != nil {
  14232. fields = append(fields, label.FieldStatus)
  14233. }
  14234. if m._type != nil {
  14235. fields = append(fields, label.FieldType)
  14236. }
  14237. if m.name != nil {
  14238. fields = append(fields, label.FieldName)
  14239. }
  14240. if m.from != nil {
  14241. fields = append(fields, label.FieldFrom)
  14242. }
  14243. if m.mode != nil {
  14244. fields = append(fields, label.FieldMode)
  14245. }
  14246. if m.conditions != nil {
  14247. fields = append(fields, label.FieldConditions)
  14248. }
  14249. if m.organization_id != nil {
  14250. fields = append(fields, label.FieldOrganizationID)
  14251. }
  14252. return fields
  14253. }
  14254. // Field returns the value of a field with the given name. The second boolean
  14255. // return value indicates that this field was not set, or was not defined in the
  14256. // schema.
  14257. func (m *LabelMutation) Field(name string) (ent.Value, bool) {
  14258. switch name {
  14259. case label.FieldCreatedAt:
  14260. return m.CreatedAt()
  14261. case label.FieldUpdatedAt:
  14262. return m.UpdatedAt()
  14263. case label.FieldStatus:
  14264. return m.Status()
  14265. case label.FieldType:
  14266. return m.GetType()
  14267. case label.FieldName:
  14268. return m.Name()
  14269. case label.FieldFrom:
  14270. return m.From()
  14271. case label.FieldMode:
  14272. return m.Mode()
  14273. case label.FieldConditions:
  14274. return m.Conditions()
  14275. case label.FieldOrganizationID:
  14276. return m.OrganizationID()
  14277. }
  14278. return nil, false
  14279. }
  14280. // OldField returns the old value of the field from the database. An error is
  14281. // returned if the mutation operation is not UpdateOne, or the query to the
  14282. // database failed.
  14283. func (m *LabelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  14284. switch name {
  14285. case label.FieldCreatedAt:
  14286. return m.OldCreatedAt(ctx)
  14287. case label.FieldUpdatedAt:
  14288. return m.OldUpdatedAt(ctx)
  14289. case label.FieldStatus:
  14290. return m.OldStatus(ctx)
  14291. case label.FieldType:
  14292. return m.OldType(ctx)
  14293. case label.FieldName:
  14294. return m.OldName(ctx)
  14295. case label.FieldFrom:
  14296. return m.OldFrom(ctx)
  14297. case label.FieldMode:
  14298. return m.OldMode(ctx)
  14299. case label.FieldConditions:
  14300. return m.OldConditions(ctx)
  14301. case label.FieldOrganizationID:
  14302. return m.OldOrganizationID(ctx)
  14303. }
  14304. return nil, fmt.Errorf("unknown Label field %s", name)
  14305. }
  14306. // SetField sets the value of a field with the given name. It returns an error if
  14307. // the field is not defined in the schema, or if the type mismatched the field
  14308. // type.
  14309. func (m *LabelMutation) SetField(name string, value ent.Value) error {
  14310. switch name {
  14311. case label.FieldCreatedAt:
  14312. v, ok := value.(time.Time)
  14313. if !ok {
  14314. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14315. }
  14316. m.SetCreatedAt(v)
  14317. return nil
  14318. case label.FieldUpdatedAt:
  14319. v, ok := value.(time.Time)
  14320. if !ok {
  14321. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14322. }
  14323. m.SetUpdatedAt(v)
  14324. return nil
  14325. case label.FieldStatus:
  14326. v, ok := value.(uint8)
  14327. if !ok {
  14328. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14329. }
  14330. m.SetStatus(v)
  14331. return nil
  14332. case label.FieldType:
  14333. v, ok := value.(int)
  14334. if !ok {
  14335. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14336. }
  14337. m.SetType(v)
  14338. return nil
  14339. case label.FieldName:
  14340. v, ok := value.(string)
  14341. if !ok {
  14342. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14343. }
  14344. m.SetName(v)
  14345. return nil
  14346. case label.FieldFrom:
  14347. v, ok := value.(int)
  14348. if !ok {
  14349. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14350. }
  14351. m.SetFrom(v)
  14352. return nil
  14353. case label.FieldMode:
  14354. v, ok := value.(int)
  14355. if !ok {
  14356. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14357. }
  14358. m.SetMode(v)
  14359. return nil
  14360. case label.FieldConditions:
  14361. v, ok := value.(string)
  14362. if !ok {
  14363. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14364. }
  14365. m.SetConditions(v)
  14366. return nil
  14367. case label.FieldOrganizationID:
  14368. v, ok := value.(uint64)
  14369. if !ok {
  14370. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14371. }
  14372. m.SetOrganizationID(v)
  14373. return nil
  14374. }
  14375. return fmt.Errorf("unknown Label field %s", name)
  14376. }
  14377. // AddedFields returns all numeric fields that were incremented/decremented during
  14378. // this mutation.
  14379. func (m *LabelMutation) AddedFields() []string {
  14380. var fields []string
  14381. if m.addstatus != nil {
  14382. fields = append(fields, label.FieldStatus)
  14383. }
  14384. if m.add_type != nil {
  14385. fields = append(fields, label.FieldType)
  14386. }
  14387. if m.addfrom != nil {
  14388. fields = append(fields, label.FieldFrom)
  14389. }
  14390. if m.addmode != nil {
  14391. fields = append(fields, label.FieldMode)
  14392. }
  14393. if m.addorganization_id != nil {
  14394. fields = append(fields, label.FieldOrganizationID)
  14395. }
  14396. return fields
  14397. }
  14398. // AddedField returns the numeric value that was incremented/decremented on a field
  14399. // with the given name. The second boolean return value indicates that this field
  14400. // was not set, or was not defined in the schema.
  14401. func (m *LabelMutation) AddedField(name string) (ent.Value, bool) {
  14402. switch name {
  14403. case label.FieldStatus:
  14404. return m.AddedStatus()
  14405. case label.FieldType:
  14406. return m.AddedType()
  14407. case label.FieldFrom:
  14408. return m.AddedFrom()
  14409. case label.FieldMode:
  14410. return m.AddedMode()
  14411. case label.FieldOrganizationID:
  14412. return m.AddedOrganizationID()
  14413. }
  14414. return nil, false
  14415. }
  14416. // AddField adds the value to the field with the given name. It returns an error if
  14417. // the field is not defined in the schema, or if the type mismatched the field
  14418. // type.
  14419. func (m *LabelMutation) AddField(name string, value ent.Value) error {
  14420. switch name {
  14421. case label.FieldStatus:
  14422. v, ok := value.(int8)
  14423. if !ok {
  14424. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14425. }
  14426. m.AddStatus(v)
  14427. return nil
  14428. case label.FieldType:
  14429. v, ok := value.(int)
  14430. if !ok {
  14431. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14432. }
  14433. m.AddType(v)
  14434. return nil
  14435. case label.FieldFrom:
  14436. v, ok := value.(int)
  14437. if !ok {
  14438. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14439. }
  14440. m.AddFrom(v)
  14441. return nil
  14442. case label.FieldMode:
  14443. v, ok := value.(int)
  14444. if !ok {
  14445. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14446. }
  14447. m.AddMode(v)
  14448. return nil
  14449. case label.FieldOrganizationID:
  14450. v, ok := value.(int64)
  14451. if !ok {
  14452. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14453. }
  14454. m.AddOrganizationID(v)
  14455. return nil
  14456. }
  14457. return fmt.Errorf("unknown Label numeric field %s", name)
  14458. }
  14459. // ClearedFields returns all nullable fields that were cleared during this
  14460. // mutation.
  14461. func (m *LabelMutation) ClearedFields() []string {
  14462. var fields []string
  14463. if m.FieldCleared(label.FieldStatus) {
  14464. fields = append(fields, label.FieldStatus)
  14465. }
  14466. if m.FieldCleared(label.FieldConditions) {
  14467. fields = append(fields, label.FieldConditions)
  14468. }
  14469. if m.FieldCleared(label.FieldOrganizationID) {
  14470. fields = append(fields, label.FieldOrganizationID)
  14471. }
  14472. return fields
  14473. }
  14474. // FieldCleared returns a boolean indicating if a field with the given name was
  14475. // cleared in this mutation.
  14476. func (m *LabelMutation) FieldCleared(name string) bool {
  14477. _, ok := m.clearedFields[name]
  14478. return ok
  14479. }
  14480. // ClearField clears the value of the field with the given name. It returns an
  14481. // error if the field is not defined in the schema.
  14482. func (m *LabelMutation) ClearField(name string) error {
  14483. switch name {
  14484. case label.FieldStatus:
  14485. m.ClearStatus()
  14486. return nil
  14487. case label.FieldConditions:
  14488. m.ClearConditions()
  14489. return nil
  14490. case label.FieldOrganizationID:
  14491. m.ClearOrganizationID()
  14492. return nil
  14493. }
  14494. return fmt.Errorf("unknown Label nullable field %s", name)
  14495. }
  14496. // ResetField resets all changes in the mutation for the field with the given name.
  14497. // It returns an error if the field is not defined in the schema.
  14498. func (m *LabelMutation) ResetField(name string) error {
  14499. switch name {
  14500. case label.FieldCreatedAt:
  14501. m.ResetCreatedAt()
  14502. return nil
  14503. case label.FieldUpdatedAt:
  14504. m.ResetUpdatedAt()
  14505. return nil
  14506. case label.FieldStatus:
  14507. m.ResetStatus()
  14508. return nil
  14509. case label.FieldType:
  14510. m.ResetType()
  14511. return nil
  14512. case label.FieldName:
  14513. m.ResetName()
  14514. return nil
  14515. case label.FieldFrom:
  14516. m.ResetFrom()
  14517. return nil
  14518. case label.FieldMode:
  14519. m.ResetMode()
  14520. return nil
  14521. case label.FieldConditions:
  14522. m.ResetConditions()
  14523. return nil
  14524. case label.FieldOrganizationID:
  14525. m.ResetOrganizationID()
  14526. return nil
  14527. }
  14528. return fmt.Errorf("unknown Label field %s", name)
  14529. }
  14530. // AddedEdges returns all edge names that were set/added in this mutation.
  14531. func (m *LabelMutation) AddedEdges() []string {
  14532. edges := make([]string, 0, 1)
  14533. if m.label_relationships != nil {
  14534. edges = append(edges, label.EdgeLabelRelationships)
  14535. }
  14536. return edges
  14537. }
  14538. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  14539. // name in this mutation.
  14540. func (m *LabelMutation) AddedIDs(name string) []ent.Value {
  14541. switch name {
  14542. case label.EdgeLabelRelationships:
  14543. ids := make([]ent.Value, 0, len(m.label_relationships))
  14544. for id := range m.label_relationships {
  14545. ids = append(ids, id)
  14546. }
  14547. return ids
  14548. }
  14549. return nil
  14550. }
  14551. // RemovedEdges returns all edge names that were removed in this mutation.
  14552. func (m *LabelMutation) RemovedEdges() []string {
  14553. edges := make([]string, 0, 1)
  14554. if m.removedlabel_relationships != nil {
  14555. edges = append(edges, label.EdgeLabelRelationships)
  14556. }
  14557. return edges
  14558. }
  14559. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  14560. // the given name in this mutation.
  14561. func (m *LabelMutation) RemovedIDs(name string) []ent.Value {
  14562. switch name {
  14563. case label.EdgeLabelRelationships:
  14564. ids := make([]ent.Value, 0, len(m.removedlabel_relationships))
  14565. for id := range m.removedlabel_relationships {
  14566. ids = append(ids, id)
  14567. }
  14568. return ids
  14569. }
  14570. return nil
  14571. }
  14572. // ClearedEdges returns all edge names that were cleared in this mutation.
  14573. func (m *LabelMutation) ClearedEdges() []string {
  14574. edges := make([]string, 0, 1)
  14575. if m.clearedlabel_relationships {
  14576. edges = append(edges, label.EdgeLabelRelationships)
  14577. }
  14578. return edges
  14579. }
  14580. // EdgeCleared returns a boolean which indicates if the edge with the given name
  14581. // was cleared in this mutation.
  14582. func (m *LabelMutation) EdgeCleared(name string) bool {
  14583. switch name {
  14584. case label.EdgeLabelRelationships:
  14585. return m.clearedlabel_relationships
  14586. }
  14587. return false
  14588. }
  14589. // ClearEdge clears the value of the edge with the given name. It returns an error
  14590. // if that edge is not defined in the schema.
  14591. func (m *LabelMutation) ClearEdge(name string) error {
  14592. switch name {
  14593. }
  14594. return fmt.Errorf("unknown Label unique edge %s", name)
  14595. }
  14596. // ResetEdge resets all changes to the edge with the given name in this mutation.
  14597. // It returns an error if the edge is not defined in the schema.
  14598. func (m *LabelMutation) ResetEdge(name string) error {
  14599. switch name {
  14600. case label.EdgeLabelRelationships:
  14601. m.ResetLabelRelationships()
  14602. return nil
  14603. }
  14604. return fmt.Errorf("unknown Label edge %s", name)
  14605. }
  14606. // LabelRelationshipMutation represents an operation that mutates the LabelRelationship nodes in the graph.
  14607. type LabelRelationshipMutation struct {
  14608. config
  14609. op Op
  14610. typ string
  14611. id *uint64
  14612. created_at *time.Time
  14613. updated_at *time.Time
  14614. status *uint8
  14615. addstatus *int8
  14616. organization_id *uint64
  14617. addorganization_id *int64
  14618. clearedFields map[string]struct{}
  14619. contacts *uint64
  14620. clearedcontacts bool
  14621. labels *uint64
  14622. clearedlabels bool
  14623. done bool
  14624. oldValue func(context.Context) (*LabelRelationship, error)
  14625. predicates []predicate.LabelRelationship
  14626. }
  14627. var _ ent.Mutation = (*LabelRelationshipMutation)(nil)
  14628. // labelrelationshipOption allows management of the mutation configuration using functional options.
  14629. type labelrelationshipOption func(*LabelRelationshipMutation)
  14630. // newLabelRelationshipMutation creates new mutation for the LabelRelationship entity.
  14631. func newLabelRelationshipMutation(c config, op Op, opts ...labelrelationshipOption) *LabelRelationshipMutation {
  14632. m := &LabelRelationshipMutation{
  14633. config: c,
  14634. op: op,
  14635. typ: TypeLabelRelationship,
  14636. clearedFields: make(map[string]struct{}),
  14637. }
  14638. for _, opt := range opts {
  14639. opt(m)
  14640. }
  14641. return m
  14642. }
  14643. // withLabelRelationshipID sets the ID field of the mutation.
  14644. func withLabelRelationshipID(id uint64) labelrelationshipOption {
  14645. return func(m *LabelRelationshipMutation) {
  14646. var (
  14647. err error
  14648. once sync.Once
  14649. value *LabelRelationship
  14650. )
  14651. m.oldValue = func(ctx context.Context) (*LabelRelationship, error) {
  14652. once.Do(func() {
  14653. if m.done {
  14654. err = errors.New("querying old values post mutation is not allowed")
  14655. } else {
  14656. value, err = m.Client().LabelRelationship.Get(ctx, id)
  14657. }
  14658. })
  14659. return value, err
  14660. }
  14661. m.id = &id
  14662. }
  14663. }
  14664. // withLabelRelationship sets the old LabelRelationship of the mutation.
  14665. func withLabelRelationship(node *LabelRelationship) labelrelationshipOption {
  14666. return func(m *LabelRelationshipMutation) {
  14667. m.oldValue = func(context.Context) (*LabelRelationship, error) {
  14668. return node, nil
  14669. }
  14670. m.id = &node.ID
  14671. }
  14672. }
  14673. // Client returns a new `ent.Client` from the mutation. If the mutation was
  14674. // executed in a transaction (ent.Tx), a transactional client is returned.
  14675. func (m LabelRelationshipMutation) Client() *Client {
  14676. client := &Client{config: m.config}
  14677. client.init()
  14678. return client
  14679. }
  14680. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  14681. // it returns an error otherwise.
  14682. func (m LabelRelationshipMutation) Tx() (*Tx, error) {
  14683. if _, ok := m.driver.(*txDriver); !ok {
  14684. return nil, errors.New("ent: mutation is not running in a transaction")
  14685. }
  14686. tx := &Tx{config: m.config}
  14687. tx.init()
  14688. return tx, nil
  14689. }
  14690. // SetID sets the value of the id field. Note that this
  14691. // operation is only accepted on creation of LabelRelationship entities.
  14692. func (m *LabelRelationshipMutation) SetID(id uint64) {
  14693. m.id = &id
  14694. }
  14695. // ID returns the ID value in the mutation. Note that the ID is only available
  14696. // if it was provided to the builder or after it was returned from the database.
  14697. func (m *LabelRelationshipMutation) ID() (id uint64, exists bool) {
  14698. if m.id == nil {
  14699. return
  14700. }
  14701. return *m.id, true
  14702. }
  14703. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  14704. // That means, if the mutation is applied within a transaction with an isolation level such
  14705. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  14706. // or updated by the mutation.
  14707. func (m *LabelRelationshipMutation) IDs(ctx context.Context) ([]uint64, error) {
  14708. switch {
  14709. case m.op.Is(OpUpdateOne | OpDeleteOne):
  14710. id, exists := m.ID()
  14711. if exists {
  14712. return []uint64{id}, nil
  14713. }
  14714. fallthrough
  14715. case m.op.Is(OpUpdate | OpDelete):
  14716. return m.Client().LabelRelationship.Query().Where(m.predicates...).IDs(ctx)
  14717. default:
  14718. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  14719. }
  14720. }
  14721. // SetCreatedAt sets the "created_at" field.
  14722. func (m *LabelRelationshipMutation) SetCreatedAt(t time.Time) {
  14723. m.created_at = &t
  14724. }
  14725. // CreatedAt returns the value of the "created_at" field in the mutation.
  14726. func (m *LabelRelationshipMutation) CreatedAt() (r time.Time, exists bool) {
  14727. v := m.created_at
  14728. if v == nil {
  14729. return
  14730. }
  14731. return *v, true
  14732. }
  14733. // OldCreatedAt returns the old "created_at" field's value of the LabelRelationship entity.
  14734. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  14735. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14736. func (m *LabelRelationshipMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  14737. if !m.op.Is(OpUpdateOne) {
  14738. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  14739. }
  14740. if m.id == nil || m.oldValue == nil {
  14741. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  14742. }
  14743. oldValue, err := m.oldValue(ctx)
  14744. if err != nil {
  14745. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  14746. }
  14747. return oldValue.CreatedAt, nil
  14748. }
  14749. // ResetCreatedAt resets all changes to the "created_at" field.
  14750. func (m *LabelRelationshipMutation) ResetCreatedAt() {
  14751. m.created_at = nil
  14752. }
  14753. // SetUpdatedAt sets the "updated_at" field.
  14754. func (m *LabelRelationshipMutation) SetUpdatedAt(t time.Time) {
  14755. m.updated_at = &t
  14756. }
  14757. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  14758. func (m *LabelRelationshipMutation) UpdatedAt() (r time.Time, exists bool) {
  14759. v := m.updated_at
  14760. if v == nil {
  14761. return
  14762. }
  14763. return *v, true
  14764. }
  14765. // OldUpdatedAt returns the old "updated_at" field's value of the LabelRelationship entity.
  14766. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  14767. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14768. func (m *LabelRelationshipMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  14769. if !m.op.Is(OpUpdateOne) {
  14770. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  14771. }
  14772. if m.id == nil || m.oldValue == nil {
  14773. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  14774. }
  14775. oldValue, err := m.oldValue(ctx)
  14776. if err != nil {
  14777. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  14778. }
  14779. return oldValue.UpdatedAt, nil
  14780. }
  14781. // ResetUpdatedAt resets all changes to the "updated_at" field.
  14782. func (m *LabelRelationshipMutation) ResetUpdatedAt() {
  14783. m.updated_at = nil
  14784. }
  14785. // SetStatus sets the "status" field.
  14786. func (m *LabelRelationshipMutation) SetStatus(u uint8) {
  14787. m.status = &u
  14788. m.addstatus = nil
  14789. }
  14790. // Status returns the value of the "status" field in the mutation.
  14791. func (m *LabelRelationshipMutation) Status() (r uint8, exists bool) {
  14792. v := m.status
  14793. if v == nil {
  14794. return
  14795. }
  14796. return *v, true
  14797. }
  14798. // OldStatus returns the old "status" field's value of the LabelRelationship entity.
  14799. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  14800. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14801. func (m *LabelRelationshipMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  14802. if !m.op.Is(OpUpdateOne) {
  14803. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  14804. }
  14805. if m.id == nil || m.oldValue == nil {
  14806. return v, errors.New("OldStatus requires an ID field in the mutation")
  14807. }
  14808. oldValue, err := m.oldValue(ctx)
  14809. if err != nil {
  14810. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  14811. }
  14812. return oldValue.Status, nil
  14813. }
  14814. // AddStatus adds u to the "status" field.
  14815. func (m *LabelRelationshipMutation) AddStatus(u int8) {
  14816. if m.addstatus != nil {
  14817. *m.addstatus += u
  14818. } else {
  14819. m.addstatus = &u
  14820. }
  14821. }
  14822. // AddedStatus returns the value that was added to the "status" field in this mutation.
  14823. func (m *LabelRelationshipMutation) AddedStatus() (r int8, exists bool) {
  14824. v := m.addstatus
  14825. if v == nil {
  14826. return
  14827. }
  14828. return *v, true
  14829. }
  14830. // ClearStatus clears the value of the "status" field.
  14831. func (m *LabelRelationshipMutation) ClearStatus() {
  14832. m.status = nil
  14833. m.addstatus = nil
  14834. m.clearedFields[labelrelationship.FieldStatus] = struct{}{}
  14835. }
  14836. // StatusCleared returns if the "status" field was cleared in this mutation.
  14837. func (m *LabelRelationshipMutation) StatusCleared() bool {
  14838. _, ok := m.clearedFields[labelrelationship.FieldStatus]
  14839. return ok
  14840. }
  14841. // ResetStatus resets all changes to the "status" field.
  14842. func (m *LabelRelationshipMutation) ResetStatus() {
  14843. m.status = nil
  14844. m.addstatus = nil
  14845. delete(m.clearedFields, labelrelationship.FieldStatus)
  14846. }
  14847. // SetLabelID sets the "label_id" field.
  14848. func (m *LabelRelationshipMutation) SetLabelID(u uint64) {
  14849. m.labels = &u
  14850. }
  14851. // LabelID returns the value of the "label_id" field in the mutation.
  14852. func (m *LabelRelationshipMutation) LabelID() (r uint64, exists bool) {
  14853. v := m.labels
  14854. if v == nil {
  14855. return
  14856. }
  14857. return *v, true
  14858. }
  14859. // OldLabelID returns the old "label_id" field's value of the LabelRelationship entity.
  14860. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  14861. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14862. func (m *LabelRelationshipMutation) OldLabelID(ctx context.Context) (v uint64, err error) {
  14863. if !m.op.Is(OpUpdateOne) {
  14864. return v, errors.New("OldLabelID is only allowed on UpdateOne operations")
  14865. }
  14866. if m.id == nil || m.oldValue == nil {
  14867. return v, errors.New("OldLabelID requires an ID field in the mutation")
  14868. }
  14869. oldValue, err := m.oldValue(ctx)
  14870. if err != nil {
  14871. return v, fmt.Errorf("querying old value for OldLabelID: %w", err)
  14872. }
  14873. return oldValue.LabelID, nil
  14874. }
  14875. // ResetLabelID resets all changes to the "label_id" field.
  14876. func (m *LabelRelationshipMutation) ResetLabelID() {
  14877. m.labels = nil
  14878. }
  14879. // SetContactID sets the "contact_id" field.
  14880. func (m *LabelRelationshipMutation) SetContactID(u uint64) {
  14881. m.contacts = &u
  14882. }
  14883. // ContactID returns the value of the "contact_id" field in the mutation.
  14884. func (m *LabelRelationshipMutation) ContactID() (r uint64, exists bool) {
  14885. v := m.contacts
  14886. if v == nil {
  14887. return
  14888. }
  14889. return *v, true
  14890. }
  14891. // OldContactID returns the old "contact_id" field's value of the LabelRelationship entity.
  14892. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  14893. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14894. func (m *LabelRelationshipMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  14895. if !m.op.Is(OpUpdateOne) {
  14896. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  14897. }
  14898. if m.id == nil || m.oldValue == nil {
  14899. return v, errors.New("OldContactID requires an ID field in the mutation")
  14900. }
  14901. oldValue, err := m.oldValue(ctx)
  14902. if err != nil {
  14903. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  14904. }
  14905. return oldValue.ContactID, nil
  14906. }
  14907. // ResetContactID resets all changes to the "contact_id" field.
  14908. func (m *LabelRelationshipMutation) ResetContactID() {
  14909. m.contacts = nil
  14910. }
  14911. // SetOrganizationID sets the "organization_id" field.
  14912. func (m *LabelRelationshipMutation) SetOrganizationID(u uint64) {
  14913. m.organization_id = &u
  14914. m.addorganization_id = nil
  14915. }
  14916. // OrganizationID returns the value of the "organization_id" field in the mutation.
  14917. func (m *LabelRelationshipMutation) OrganizationID() (r uint64, exists bool) {
  14918. v := m.organization_id
  14919. if v == nil {
  14920. return
  14921. }
  14922. return *v, true
  14923. }
  14924. // OldOrganizationID returns the old "organization_id" field's value of the LabelRelationship entity.
  14925. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  14926. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14927. func (m *LabelRelationshipMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  14928. if !m.op.Is(OpUpdateOne) {
  14929. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  14930. }
  14931. if m.id == nil || m.oldValue == nil {
  14932. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  14933. }
  14934. oldValue, err := m.oldValue(ctx)
  14935. if err != nil {
  14936. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  14937. }
  14938. return oldValue.OrganizationID, nil
  14939. }
  14940. // AddOrganizationID adds u to the "organization_id" field.
  14941. func (m *LabelRelationshipMutation) AddOrganizationID(u int64) {
  14942. if m.addorganization_id != nil {
  14943. *m.addorganization_id += u
  14944. } else {
  14945. m.addorganization_id = &u
  14946. }
  14947. }
  14948. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  14949. func (m *LabelRelationshipMutation) AddedOrganizationID() (r int64, exists bool) {
  14950. v := m.addorganization_id
  14951. if v == nil {
  14952. return
  14953. }
  14954. return *v, true
  14955. }
  14956. // ClearOrganizationID clears the value of the "organization_id" field.
  14957. func (m *LabelRelationshipMutation) ClearOrganizationID() {
  14958. m.organization_id = nil
  14959. m.addorganization_id = nil
  14960. m.clearedFields[labelrelationship.FieldOrganizationID] = struct{}{}
  14961. }
  14962. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  14963. func (m *LabelRelationshipMutation) OrganizationIDCleared() bool {
  14964. _, ok := m.clearedFields[labelrelationship.FieldOrganizationID]
  14965. return ok
  14966. }
  14967. // ResetOrganizationID resets all changes to the "organization_id" field.
  14968. func (m *LabelRelationshipMutation) ResetOrganizationID() {
  14969. m.organization_id = nil
  14970. m.addorganization_id = nil
  14971. delete(m.clearedFields, labelrelationship.FieldOrganizationID)
  14972. }
  14973. // SetContactsID sets the "contacts" edge to the Contact entity by id.
  14974. func (m *LabelRelationshipMutation) SetContactsID(id uint64) {
  14975. m.contacts = &id
  14976. }
  14977. // ClearContacts clears the "contacts" edge to the Contact entity.
  14978. func (m *LabelRelationshipMutation) ClearContacts() {
  14979. m.clearedcontacts = true
  14980. m.clearedFields[labelrelationship.FieldContactID] = struct{}{}
  14981. }
  14982. // ContactsCleared reports if the "contacts" edge to the Contact entity was cleared.
  14983. func (m *LabelRelationshipMutation) ContactsCleared() bool {
  14984. return m.clearedcontacts
  14985. }
  14986. // ContactsID returns the "contacts" edge ID in the mutation.
  14987. func (m *LabelRelationshipMutation) ContactsID() (id uint64, exists bool) {
  14988. if m.contacts != nil {
  14989. return *m.contacts, true
  14990. }
  14991. return
  14992. }
  14993. // ContactsIDs returns the "contacts" edge IDs in the mutation.
  14994. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  14995. // ContactsID instead. It exists only for internal usage by the builders.
  14996. func (m *LabelRelationshipMutation) ContactsIDs() (ids []uint64) {
  14997. if id := m.contacts; id != nil {
  14998. ids = append(ids, *id)
  14999. }
  15000. return
  15001. }
  15002. // ResetContacts resets all changes to the "contacts" edge.
  15003. func (m *LabelRelationshipMutation) ResetContacts() {
  15004. m.contacts = nil
  15005. m.clearedcontacts = false
  15006. }
  15007. // SetLabelsID sets the "labels" edge to the Label entity by id.
  15008. func (m *LabelRelationshipMutation) SetLabelsID(id uint64) {
  15009. m.labels = &id
  15010. }
  15011. // ClearLabels clears the "labels" edge to the Label entity.
  15012. func (m *LabelRelationshipMutation) ClearLabels() {
  15013. m.clearedlabels = true
  15014. m.clearedFields[labelrelationship.FieldLabelID] = struct{}{}
  15015. }
  15016. // LabelsCleared reports if the "labels" edge to the Label entity was cleared.
  15017. func (m *LabelRelationshipMutation) LabelsCleared() bool {
  15018. return m.clearedlabels
  15019. }
  15020. // LabelsID returns the "labels" edge ID in the mutation.
  15021. func (m *LabelRelationshipMutation) LabelsID() (id uint64, exists bool) {
  15022. if m.labels != nil {
  15023. return *m.labels, true
  15024. }
  15025. return
  15026. }
  15027. // LabelsIDs returns the "labels" edge IDs in the mutation.
  15028. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  15029. // LabelsID instead. It exists only for internal usage by the builders.
  15030. func (m *LabelRelationshipMutation) LabelsIDs() (ids []uint64) {
  15031. if id := m.labels; id != nil {
  15032. ids = append(ids, *id)
  15033. }
  15034. return
  15035. }
  15036. // ResetLabels resets all changes to the "labels" edge.
  15037. func (m *LabelRelationshipMutation) ResetLabels() {
  15038. m.labels = nil
  15039. m.clearedlabels = false
  15040. }
  15041. // Where appends a list predicates to the LabelRelationshipMutation builder.
  15042. func (m *LabelRelationshipMutation) Where(ps ...predicate.LabelRelationship) {
  15043. m.predicates = append(m.predicates, ps...)
  15044. }
  15045. // WhereP appends storage-level predicates to the LabelRelationshipMutation builder. Using this method,
  15046. // users can use type-assertion to append predicates that do not depend on any generated package.
  15047. func (m *LabelRelationshipMutation) WhereP(ps ...func(*sql.Selector)) {
  15048. p := make([]predicate.LabelRelationship, len(ps))
  15049. for i := range ps {
  15050. p[i] = ps[i]
  15051. }
  15052. m.Where(p...)
  15053. }
  15054. // Op returns the operation name.
  15055. func (m *LabelRelationshipMutation) Op() Op {
  15056. return m.op
  15057. }
  15058. // SetOp allows setting the mutation operation.
  15059. func (m *LabelRelationshipMutation) SetOp(op Op) {
  15060. m.op = op
  15061. }
  15062. // Type returns the node type of this mutation (LabelRelationship).
  15063. func (m *LabelRelationshipMutation) Type() string {
  15064. return m.typ
  15065. }
  15066. // Fields returns all fields that were changed during this mutation. Note that in
  15067. // order to get all numeric fields that were incremented/decremented, call
  15068. // AddedFields().
  15069. func (m *LabelRelationshipMutation) Fields() []string {
  15070. fields := make([]string, 0, 6)
  15071. if m.created_at != nil {
  15072. fields = append(fields, labelrelationship.FieldCreatedAt)
  15073. }
  15074. if m.updated_at != nil {
  15075. fields = append(fields, labelrelationship.FieldUpdatedAt)
  15076. }
  15077. if m.status != nil {
  15078. fields = append(fields, labelrelationship.FieldStatus)
  15079. }
  15080. if m.labels != nil {
  15081. fields = append(fields, labelrelationship.FieldLabelID)
  15082. }
  15083. if m.contacts != nil {
  15084. fields = append(fields, labelrelationship.FieldContactID)
  15085. }
  15086. if m.organization_id != nil {
  15087. fields = append(fields, labelrelationship.FieldOrganizationID)
  15088. }
  15089. return fields
  15090. }
  15091. // Field returns the value of a field with the given name. The second boolean
  15092. // return value indicates that this field was not set, or was not defined in the
  15093. // schema.
  15094. func (m *LabelRelationshipMutation) Field(name string) (ent.Value, bool) {
  15095. switch name {
  15096. case labelrelationship.FieldCreatedAt:
  15097. return m.CreatedAt()
  15098. case labelrelationship.FieldUpdatedAt:
  15099. return m.UpdatedAt()
  15100. case labelrelationship.FieldStatus:
  15101. return m.Status()
  15102. case labelrelationship.FieldLabelID:
  15103. return m.LabelID()
  15104. case labelrelationship.FieldContactID:
  15105. return m.ContactID()
  15106. case labelrelationship.FieldOrganizationID:
  15107. return m.OrganizationID()
  15108. }
  15109. return nil, false
  15110. }
  15111. // OldField returns the old value of the field from the database. An error is
  15112. // returned if the mutation operation is not UpdateOne, or the query to the
  15113. // database failed.
  15114. func (m *LabelRelationshipMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  15115. switch name {
  15116. case labelrelationship.FieldCreatedAt:
  15117. return m.OldCreatedAt(ctx)
  15118. case labelrelationship.FieldUpdatedAt:
  15119. return m.OldUpdatedAt(ctx)
  15120. case labelrelationship.FieldStatus:
  15121. return m.OldStatus(ctx)
  15122. case labelrelationship.FieldLabelID:
  15123. return m.OldLabelID(ctx)
  15124. case labelrelationship.FieldContactID:
  15125. return m.OldContactID(ctx)
  15126. case labelrelationship.FieldOrganizationID:
  15127. return m.OldOrganizationID(ctx)
  15128. }
  15129. return nil, fmt.Errorf("unknown LabelRelationship field %s", name)
  15130. }
  15131. // SetField sets the value of a field with the given name. It returns an error if
  15132. // the field is not defined in the schema, or if the type mismatched the field
  15133. // type.
  15134. func (m *LabelRelationshipMutation) SetField(name string, value ent.Value) error {
  15135. switch name {
  15136. case labelrelationship.FieldCreatedAt:
  15137. v, ok := value.(time.Time)
  15138. if !ok {
  15139. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15140. }
  15141. m.SetCreatedAt(v)
  15142. return nil
  15143. case labelrelationship.FieldUpdatedAt:
  15144. v, ok := value.(time.Time)
  15145. if !ok {
  15146. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15147. }
  15148. m.SetUpdatedAt(v)
  15149. return nil
  15150. case labelrelationship.FieldStatus:
  15151. v, ok := value.(uint8)
  15152. if !ok {
  15153. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15154. }
  15155. m.SetStatus(v)
  15156. return nil
  15157. case labelrelationship.FieldLabelID:
  15158. v, ok := value.(uint64)
  15159. if !ok {
  15160. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15161. }
  15162. m.SetLabelID(v)
  15163. return nil
  15164. case labelrelationship.FieldContactID:
  15165. v, ok := value.(uint64)
  15166. if !ok {
  15167. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15168. }
  15169. m.SetContactID(v)
  15170. return nil
  15171. case labelrelationship.FieldOrganizationID:
  15172. v, ok := value.(uint64)
  15173. if !ok {
  15174. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15175. }
  15176. m.SetOrganizationID(v)
  15177. return nil
  15178. }
  15179. return fmt.Errorf("unknown LabelRelationship field %s", name)
  15180. }
  15181. // AddedFields returns all numeric fields that were incremented/decremented during
  15182. // this mutation.
  15183. func (m *LabelRelationshipMutation) AddedFields() []string {
  15184. var fields []string
  15185. if m.addstatus != nil {
  15186. fields = append(fields, labelrelationship.FieldStatus)
  15187. }
  15188. if m.addorganization_id != nil {
  15189. fields = append(fields, labelrelationship.FieldOrganizationID)
  15190. }
  15191. return fields
  15192. }
  15193. // AddedField returns the numeric value that was incremented/decremented on a field
  15194. // with the given name. The second boolean return value indicates that this field
  15195. // was not set, or was not defined in the schema.
  15196. func (m *LabelRelationshipMutation) AddedField(name string) (ent.Value, bool) {
  15197. switch name {
  15198. case labelrelationship.FieldStatus:
  15199. return m.AddedStatus()
  15200. case labelrelationship.FieldOrganizationID:
  15201. return m.AddedOrganizationID()
  15202. }
  15203. return nil, false
  15204. }
  15205. // AddField adds the value to the field with the given name. It returns an error if
  15206. // the field is not defined in the schema, or if the type mismatched the field
  15207. // type.
  15208. func (m *LabelRelationshipMutation) AddField(name string, value ent.Value) error {
  15209. switch name {
  15210. case labelrelationship.FieldStatus:
  15211. v, ok := value.(int8)
  15212. if !ok {
  15213. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15214. }
  15215. m.AddStatus(v)
  15216. return nil
  15217. case labelrelationship.FieldOrganizationID:
  15218. v, ok := value.(int64)
  15219. if !ok {
  15220. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15221. }
  15222. m.AddOrganizationID(v)
  15223. return nil
  15224. }
  15225. return fmt.Errorf("unknown LabelRelationship numeric field %s", name)
  15226. }
  15227. // ClearedFields returns all nullable fields that were cleared during this
  15228. // mutation.
  15229. func (m *LabelRelationshipMutation) ClearedFields() []string {
  15230. var fields []string
  15231. if m.FieldCleared(labelrelationship.FieldStatus) {
  15232. fields = append(fields, labelrelationship.FieldStatus)
  15233. }
  15234. if m.FieldCleared(labelrelationship.FieldOrganizationID) {
  15235. fields = append(fields, labelrelationship.FieldOrganizationID)
  15236. }
  15237. return fields
  15238. }
  15239. // FieldCleared returns a boolean indicating if a field with the given name was
  15240. // cleared in this mutation.
  15241. func (m *LabelRelationshipMutation) FieldCleared(name string) bool {
  15242. _, ok := m.clearedFields[name]
  15243. return ok
  15244. }
  15245. // ClearField clears the value of the field with the given name. It returns an
  15246. // error if the field is not defined in the schema.
  15247. func (m *LabelRelationshipMutation) ClearField(name string) error {
  15248. switch name {
  15249. case labelrelationship.FieldStatus:
  15250. m.ClearStatus()
  15251. return nil
  15252. case labelrelationship.FieldOrganizationID:
  15253. m.ClearOrganizationID()
  15254. return nil
  15255. }
  15256. return fmt.Errorf("unknown LabelRelationship nullable field %s", name)
  15257. }
  15258. // ResetField resets all changes in the mutation for the field with the given name.
  15259. // It returns an error if the field is not defined in the schema.
  15260. func (m *LabelRelationshipMutation) ResetField(name string) error {
  15261. switch name {
  15262. case labelrelationship.FieldCreatedAt:
  15263. m.ResetCreatedAt()
  15264. return nil
  15265. case labelrelationship.FieldUpdatedAt:
  15266. m.ResetUpdatedAt()
  15267. return nil
  15268. case labelrelationship.FieldStatus:
  15269. m.ResetStatus()
  15270. return nil
  15271. case labelrelationship.FieldLabelID:
  15272. m.ResetLabelID()
  15273. return nil
  15274. case labelrelationship.FieldContactID:
  15275. m.ResetContactID()
  15276. return nil
  15277. case labelrelationship.FieldOrganizationID:
  15278. m.ResetOrganizationID()
  15279. return nil
  15280. }
  15281. return fmt.Errorf("unknown LabelRelationship field %s", name)
  15282. }
  15283. // AddedEdges returns all edge names that were set/added in this mutation.
  15284. func (m *LabelRelationshipMutation) AddedEdges() []string {
  15285. edges := make([]string, 0, 2)
  15286. if m.contacts != nil {
  15287. edges = append(edges, labelrelationship.EdgeContacts)
  15288. }
  15289. if m.labels != nil {
  15290. edges = append(edges, labelrelationship.EdgeLabels)
  15291. }
  15292. return edges
  15293. }
  15294. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  15295. // name in this mutation.
  15296. func (m *LabelRelationshipMutation) AddedIDs(name string) []ent.Value {
  15297. switch name {
  15298. case labelrelationship.EdgeContacts:
  15299. if id := m.contacts; id != nil {
  15300. return []ent.Value{*id}
  15301. }
  15302. case labelrelationship.EdgeLabels:
  15303. if id := m.labels; id != nil {
  15304. return []ent.Value{*id}
  15305. }
  15306. }
  15307. return nil
  15308. }
  15309. // RemovedEdges returns all edge names that were removed in this mutation.
  15310. func (m *LabelRelationshipMutation) RemovedEdges() []string {
  15311. edges := make([]string, 0, 2)
  15312. return edges
  15313. }
  15314. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  15315. // the given name in this mutation.
  15316. func (m *LabelRelationshipMutation) RemovedIDs(name string) []ent.Value {
  15317. return nil
  15318. }
  15319. // ClearedEdges returns all edge names that were cleared in this mutation.
  15320. func (m *LabelRelationshipMutation) ClearedEdges() []string {
  15321. edges := make([]string, 0, 2)
  15322. if m.clearedcontacts {
  15323. edges = append(edges, labelrelationship.EdgeContacts)
  15324. }
  15325. if m.clearedlabels {
  15326. edges = append(edges, labelrelationship.EdgeLabels)
  15327. }
  15328. return edges
  15329. }
  15330. // EdgeCleared returns a boolean which indicates if the edge with the given name
  15331. // was cleared in this mutation.
  15332. func (m *LabelRelationshipMutation) EdgeCleared(name string) bool {
  15333. switch name {
  15334. case labelrelationship.EdgeContacts:
  15335. return m.clearedcontacts
  15336. case labelrelationship.EdgeLabels:
  15337. return m.clearedlabels
  15338. }
  15339. return false
  15340. }
  15341. // ClearEdge clears the value of the edge with the given name. It returns an error
  15342. // if that edge is not defined in the schema.
  15343. func (m *LabelRelationshipMutation) ClearEdge(name string) error {
  15344. switch name {
  15345. case labelrelationship.EdgeContacts:
  15346. m.ClearContacts()
  15347. return nil
  15348. case labelrelationship.EdgeLabels:
  15349. m.ClearLabels()
  15350. return nil
  15351. }
  15352. return fmt.Errorf("unknown LabelRelationship unique edge %s", name)
  15353. }
  15354. // ResetEdge resets all changes to the edge with the given name in this mutation.
  15355. // It returns an error if the edge is not defined in the schema.
  15356. func (m *LabelRelationshipMutation) ResetEdge(name string) error {
  15357. switch name {
  15358. case labelrelationship.EdgeContacts:
  15359. m.ResetContacts()
  15360. return nil
  15361. case labelrelationship.EdgeLabels:
  15362. m.ResetLabels()
  15363. return nil
  15364. }
  15365. return fmt.Errorf("unknown LabelRelationship edge %s", name)
  15366. }
  15367. // LabelTaggingMutation represents an operation that mutates the LabelTagging nodes in the graph.
  15368. type LabelTaggingMutation struct {
  15369. config
  15370. op Op
  15371. typ string
  15372. id *uint64
  15373. created_at *time.Time
  15374. updated_at *time.Time
  15375. status *uint8
  15376. addstatus *int8
  15377. deleted_at *time.Time
  15378. organization_id *uint64
  15379. addorganization_id *int64
  15380. _type *int
  15381. add_type *int
  15382. conditions *string
  15383. action_label_add *[]uint64
  15384. appendaction_label_add []uint64
  15385. action_label_del *[]uint64
  15386. appendaction_label_del []uint64
  15387. clearedFields map[string]struct{}
  15388. done bool
  15389. oldValue func(context.Context) (*LabelTagging, error)
  15390. predicates []predicate.LabelTagging
  15391. }
  15392. var _ ent.Mutation = (*LabelTaggingMutation)(nil)
  15393. // labeltaggingOption allows management of the mutation configuration using functional options.
  15394. type labeltaggingOption func(*LabelTaggingMutation)
  15395. // newLabelTaggingMutation creates new mutation for the LabelTagging entity.
  15396. func newLabelTaggingMutation(c config, op Op, opts ...labeltaggingOption) *LabelTaggingMutation {
  15397. m := &LabelTaggingMutation{
  15398. config: c,
  15399. op: op,
  15400. typ: TypeLabelTagging,
  15401. clearedFields: make(map[string]struct{}),
  15402. }
  15403. for _, opt := range opts {
  15404. opt(m)
  15405. }
  15406. return m
  15407. }
  15408. // withLabelTaggingID sets the ID field of the mutation.
  15409. func withLabelTaggingID(id uint64) labeltaggingOption {
  15410. return func(m *LabelTaggingMutation) {
  15411. var (
  15412. err error
  15413. once sync.Once
  15414. value *LabelTagging
  15415. )
  15416. m.oldValue = func(ctx context.Context) (*LabelTagging, error) {
  15417. once.Do(func() {
  15418. if m.done {
  15419. err = errors.New("querying old values post mutation is not allowed")
  15420. } else {
  15421. value, err = m.Client().LabelTagging.Get(ctx, id)
  15422. }
  15423. })
  15424. return value, err
  15425. }
  15426. m.id = &id
  15427. }
  15428. }
  15429. // withLabelTagging sets the old LabelTagging of the mutation.
  15430. func withLabelTagging(node *LabelTagging) labeltaggingOption {
  15431. return func(m *LabelTaggingMutation) {
  15432. m.oldValue = func(context.Context) (*LabelTagging, error) {
  15433. return node, nil
  15434. }
  15435. m.id = &node.ID
  15436. }
  15437. }
  15438. // Client returns a new `ent.Client` from the mutation. If the mutation was
  15439. // executed in a transaction (ent.Tx), a transactional client is returned.
  15440. func (m LabelTaggingMutation) Client() *Client {
  15441. client := &Client{config: m.config}
  15442. client.init()
  15443. return client
  15444. }
  15445. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  15446. // it returns an error otherwise.
  15447. func (m LabelTaggingMutation) Tx() (*Tx, error) {
  15448. if _, ok := m.driver.(*txDriver); !ok {
  15449. return nil, errors.New("ent: mutation is not running in a transaction")
  15450. }
  15451. tx := &Tx{config: m.config}
  15452. tx.init()
  15453. return tx, nil
  15454. }
  15455. // SetID sets the value of the id field. Note that this
  15456. // operation is only accepted on creation of LabelTagging entities.
  15457. func (m *LabelTaggingMutation) SetID(id uint64) {
  15458. m.id = &id
  15459. }
  15460. // ID returns the ID value in the mutation. Note that the ID is only available
  15461. // if it was provided to the builder or after it was returned from the database.
  15462. func (m *LabelTaggingMutation) ID() (id uint64, exists bool) {
  15463. if m.id == nil {
  15464. return
  15465. }
  15466. return *m.id, true
  15467. }
  15468. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  15469. // That means, if the mutation is applied within a transaction with an isolation level such
  15470. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  15471. // or updated by the mutation.
  15472. func (m *LabelTaggingMutation) IDs(ctx context.Context) ([]uint64, error) {
  15473. switch {
  15474. case m.op.Is(OpUpdateOne | OpDeleteOne):
  15475. id, exists := m.ID()
  15476. if exists {
  15477. return []uint64{id}, nil
  15478. }
  15479. fallthrough
  15480. case m.op.Is(OpUpdate | OpDelete):
  15481. return m.Client().LabelTagging.Query().Where(m.predicates...).IDs(ctx)
  15482. default:
  15483. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  15484. }
  15485. }
  15486. // SetCreatedAt sets the "created_at" field.
  15487. func (m *LabelTaggingMutation) SetCreatedAt(t time.Time) {
  15488. m.created_at = &t
  15489. }
  15490. // CreatedAt returns the value of the "created_at" field in the mutation.
  15491. func (m *LabelTaggingMutation) CreatedAt() (r time.Time, exists bool) {
  15492. v := m.created_at
  15493. if v == nil {
  15494. return
  15495. }
  15496. return *v, true
  15497. }
  15498. // OldCreatedAt returns the old "created_at" field's value of the LabelTagging entity.
  15499. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  15500. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15501. func (m *LabelTaggingMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  15502. if !m.op.Is(OpUpdateOne) {
  15503. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  15504. }
  15505. if m.id == nil || m.oldValue == nil {
  15506. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  15507. }
  15508. oldValue, err := m.oldValue(ctx)
  15509. if err != nil {
  15510. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  15511. }
  15512. return oldValue.CreatedAt, nil
  15513. }
  15514. // ResetCreatedAt resets all changes to the "created_at" field.
  15515. func (m *LabelTaggingMutation) ResetCreatedAt() {
  15516. m.created_at = nil
  15517. }
  15518. // SetUpdatedAt sets the "updated_at" field.
  15519. func (m *LabelTaggingMutation) SetUpdatedAt(t time.Time) {
  15520. m.updated_at = &t
  15521. }
  15522. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  15523. func (m *LabelTaggingMutation) UpdatedAt() (r time.Time, exists bool) {
  15524. v := m.updated_at
  15525. if v == nil {
  15526. return
  15527. }
  15528. return *v, true
  15529. }
  15530. // OldUpdatedAt returns the old "updated_at" field's value of the LabelTagging entity.
  15531. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  15532. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15533. func (m *LabelTaggingMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  15534. if !m.op.Is(OpUpdateOne) {
  15535. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  15536. }
  15537. if m.id == nil || m.oldValue == nil {
  15538. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  15539. }
  15540. oldValue, err := m.oldValue(ctx)
  15541. if err != nil {
  15542. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  15543. }
  15544. return oldValue.UpdatedAt, nil
  15545. }
  15546. // ResetUpdatedAt resets all changes to the "updated_at" field.
  15547. func (m *LabelTaggingMutation) ResetUpdatedAt() {
  15548. m.updated_at = nil
  15549. }
  15550. // SetStatus sets the "status" field.
  15551. func (m *LabelTaggingMutation) SetStatus(u uint8) {
  15552. m.status = &u
  15553. m.addstatus = nil
  15554. }
  15555. // Status returns the value of the "status" field in the mutation.
  15556. func (m *LabelTaggingMutation) Status() (r uint8, exists bool) {
  15557. v := m.status
  15558. if v == nil {
  15559. return
  15560. }
  15561. return *v, true
  15562. }
  15563. // OldStatus returns the old "status" field's value of the LabelTagging entity.
  15564. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  15565. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15566. func (m *LabelTaggingMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  15567. if !m.op.Is(OpUpdateOne) {
  15568. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  15569. }
  15570. if m.id == nil || m.oldValue == nil {
  15571. return v, errors.New("OldStatus requires an ID field in the mutation")
  15572. }
  15573. oldValue, err := m.oldValue(ctx)
  15574. if err != nil {
  15575. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  15576. }
  15577. return oldValue.Status, nil
  15578. }
  15579. // AddStatus adds u to the "status" field.
  15580. func (m *LabelTaggingMutation) AddStatus(u int8) {
  15581. if m.addstatus != nil {
  15582. *m.addstatus += u
  15583. } else {
  15584. m.addstatus = &u
  15585. }
  15586. }
  15587. // AddedStatus returns the value that was added to the "status" field in this mutation.
  15588. func (m *LabelTaggingMutation) AddedStatus() (r int8, exists bool) {
  15589. v := m.addstatus
  15590. if v == nil {
  15591. return
  15592. }
  15593. return *v, true
  15594. }
  15595. // ClearStatus clears the value of the "status" field.
  15596. func (m *LabelTaggingMutation) ClearStatus() {
  15597. m.status = nil
  15598. m.addstatus = nil
  15599. m.clearedFields[labeltagging.FieldStatus] = struct{}{}
  15600. }
  15601. // StatusCleared returns if the "status" field was cleared in this mutation.
  15602. func (m *LabelTaggingMutation) StatusCleared() bool {
  15603. _, ok := m.clearedFields[labeltagging.FieldStatus]
  15604. return ok
  15605. }
  15606. // ResetStatus resets all changes to the "status" field.
  15607. func (m *LabelTaggingMutation) ResetStatus() {
  15608. m.status = nil
  15609. m.addstatus = nil
  15610. delete(m.clearedFields, labeltagging.FieldStatus)
  15611. }
  15612. // SetDeletedAt sets the "deleted_at" field.
  15613. func (m *LabelTaggingMutation) SetDeletedAt(t time.Time) {
  15614. m.deleted_at = &t
  15615. }
  15616. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  15617. func (m *LabelTaggingMutation) DeletedAt() (r time.Time, exists bool) {
  15618. v := m.deleted_at
  15619. if v == nil {
  15620. return
  15621. }
  15622. return *v, true
  15623. }
  15624. // OldDeletedAt returns the old "deleted_at" field's value of the LabelTagging entity.
  15625. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  15626. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15627. func (m *LabelTaggingMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  15628. if !m.op.Is(OpUpdateOne) {
  15629. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  15630. }
  15631. if m.id == nil || m.oldValue == nil {
  15632. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  15633. }
  15634. oldValue, err := m.oldValue(ctx)
  15635. if err != nil {
  15636. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  15637. }
  15638. return oldValue.DeletedAt, nil
  15639. }
  15640. // ClearDeletedAt clears the value of the "deleted_at" field.
  15641. func (m *LabelTaggingMutation) ClearDeletedAt() {
  15642. m.deleted_at = nil
  15643. m.clearedFields[labeltagging.FieldDeletedAt] = struct{}{}
  15644. }
  15645. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  15646. func (m *LabelTaggingMutation) DeletedAtCleared() bool {
  15647. _, ok := m.clearedFields[labeltagging.FieldDeletedAt]
  15648. return ok
  15649. }
  15650. // ResetDeletedAt resets all changes to the "deleted_at" field.
  15651. func (m *LabelTaggingMutation) ResetDeletedAt() {
  15652. m.deleted_at = nil
  15653. delete(m.clearedFields, labeltagging.FieldDeletedAt)
  15654. }
  15655. // SetOrganizationID sets the "organization_id" field.
  15656. func (m *LabelTaggingMutation) SetOrganizationID(u uint64) {
  15657. m.organization_id = &u
  15658. m.addorganization_id = nil
  15659. }
  15660. // OrganizationID returns the value of the "organization_id" field in the mutation.
  15661. func (m *LabelTaggingMutation) OrganizationID() (r uint64, exists bool) {
  15662. v := m.organization_id
  15663. if v == nil {
  15664. return
  15665. }
  15666. return *v, true
  15667. }
  15668. // OldOrganizationID returns the old "organization_id" field's value of the LabelTagging entity.
  15669. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  15670. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15671. func (m *LabelTaggingMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  15672. if !m.op.Is(OpUpdateOne) {
  15673. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  15674. }
  15675. if m.id == nil || m.oldValue == nil {
  15676. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  15677. }
  15678. oldValue, err := m.oldValue(ctx)
  15679. if err != nil {
  15680. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  15681. }
  15682. return oldValue.OrganizationID, nil
  15683. }
  15684. // AddOrganizationID adds u to the "organization_id" field.
  15685. func (m *LabelTaggingMutation) AddOrganizationID(u int64) {
  15686. if m.addorganization_id != nil {
  15687. *m.addorganization_id += u
  15688. } else {
  15689. m.addorganization_id = &u
  15690. }
  15691. }
  15692. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  15693. func (m *LabelTaggingMutation) AddedOrganizationID() (r int64, exists bool) {
  15694. v := m.addorganization_id
  15695. if v == nil {
  15696. return
  15697. }
  15698. return *v, true
  15699. }
  15700. // ResetOrganizationID resets all changes to the "organization_id" field.
  15701. func (m *LabelTaggingMutation) ResetOrganizationID() {
  15702. m.organization_id = nil
  15703. m.addorganization_id = nil
  15704. }
  15705. // SetType sets the "type" field.
  15706. func (m *LabelTaggingMutation) SetType(i int) {
  15707. m._type = &i
  15708. m.add_type = nil
  15709. }
  15710. // GetType returns the value of the "type" field in the mutation.
  15711. func (m *LabelTaggingMutation) GetType() (r int, exists bool) {
  15712. v := m._type
  15713. if v == nil {
  15714. return
  15715. }
  15716. return *v, true
  15717. }
  15718. // OldType returns the old "type" field's value of the LabelTagging entity.
  15719. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  15720. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15721. func (m *LabelTaggingMutation) OldType(ctx context.Context) (v int, err error) {
  15722. if !m.op.Is(OpUpdateOne) {
  15723. return v, errors.New("OldType is only allowed on UpdateOne operations")
  15724. }
  15725. if m.id == nil || m.oldValue == nil {
  15726. return v, errors.New("OldType requires an ID field in the mutation")
  15727. }
  15728. oldValue, err := m.oldValue(ctx)
  15729. if err != nil {
  15730. return v, fmt.Errorf("querying old value for OldType: %w", err)
  15731. }
  15732. return oldValue.Type, nil
  15733. }
  15734. // AddType adds i to the "type" field.
  15735. func (m *LabelTaggingMutation) AddType(i int) {
  15736. if m.add_type != nil {
  15737. *m.add_type += i
  15738. } else {
  15739. m.add_type = &i
  15740. }
  15741. }
  15742. // AddedType returns the value that was added to the "type" field in this mutation.
  15743. func (m *LabelTaggingMutation) AddedType() (r int, exists bool) {
  15744. v := m.add_type
  15745. if v == nil {
  15746. return
  15747. }
  15748. return *v, true
  15749. }
  15750. // ResetType resets all changes to the "type" field.
  15751. func (m *LabelTaggingMutation) ResetType() {
  15752. m._type = nil
  15753. m.add_type = nil
  15754. }
  15755. // SetConditions sets the "conditions" field.
  15756. func (m *LabelTaggingMutation) SetConditions(s string) {
  15757. m.conditions = &s
  15758. }
  15759. // Conditions returns the value of the "conditions" field in the mutation.
  15760. func (m *LabelTaggingMutation) Conditions() (r string, exists bool) {
  15761. v := m.conditions
  15762. if v == nil {
  15763. return
  15764. }
  15765. return *v, true
  15766. }
  15767. // OldConditions returns the old "conditions" field's value of the LabelTagging entity.
  15768. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  15769. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15770. func (m *LabelTaggingMutation) OldConditions(ctx context.Context) (v string, err error) {
  15771. if !m.op.Is(OpUpdateOne) {
  15772. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  15773. }
  15774. if m.id == nil || m.oldValue == nil {
  15775. return v, errors.New("OldConditions requires an ID field in the mutation")
  15776. }
  15777. oldValue, err := m.oldValue(ctx)
  15778. if err != nil {
  15779. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  15780. }
  15781. return oldValue.Conditions, nil
  15782. }
  15783. // ResetConditions resets all changes to the "conditions" field.
  15784. func (m *LabelTaggingMutation) ResetConditions() {
  15785. m.conditions = nil
  15786. }
  15787. // SetActionLabelAdd sets the "action_label_add" field.
  15788. func (m *LabelTaggingMutation) SetActionLabelAdd(u []uint64) {
  15789. m.action_label_add = &u
  15790. m.appendaction_label_add = nil
  15791. }
  15792. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  15793. func (m *LabelTaggingMutation) ActionLabelAdd() (r []uint64, exists bool) {
  15794. v := m.action_label_add
  15795. if v == nil {
  15796. return
  15797. }
  15798. return *v, true
  15799. }
  15800. // OldActionLabelAdd returns the old "action_label_add" field's value of the LabelTagging entity.
  15801. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  15802. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15803. func (m *LabelTaggingMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  15804. if !m.op.Is(OpUpdateOne) {
  15805. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  15806. }
  15807. if m.id == nil || m.oldValue == nil {
  15808. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  15809. }
  15810. oldValue, err := m.oldValue(ctx)
  15811. if err != nil {
  15812. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  15813. }
  15814. return oldValue.ActionLabelAdd, nil
  15815. }
  15816. // AppendActionLabelAdd adds u to the "action_label_add" field.
  15817. func (m *LabelTaggingMutation) AppendActionLabelAdd(u []uint64) {
  15818. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  15819. }
  15820. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  15821. func (m *LabelTaggingMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  15822. if len(m.appendaction_label_add) == 0 {
  15823. return nil, false
  15824. }
  15825. return m.appendaction_label_add, true
  15826. }
  15827. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  15828. func (m *LabelTaggingMutation) ClearActionLabelAdd() {
  15829. m.action_label_add = nil
  15830. m.appendaction_label_add = nil
  15831. m.clearedFields[labeltagging.FieldActionLabelAdd] = struct{}{}
  15832. }
  15833. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  15834. func (m *LabelTaggingMutation) ActionLabelAddCleared() bool {
  15835. _, ok := m.clearedFields[labeltagging.FieldActionLabelAdd]
  15836. return ok
  15837. }
  15838. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  15839. func (m *LabelTaggingMutation) ResetActionLabelAdd() {
  15840. m.action_label_add = nil
  15841. m.appendaction_label_add = nil
  15842. delete(m.clearedFields, labeltagging.FieldActionLabelAdd)
  15843. }
  15844. // SetActionLabelDel sets the "action_label_del" field.
  15845. func (m *LabelTaggingMutation) SetActionLabelDel(u []uint64) {
  15846. m.action_label_del = &u
  15847. m.appendaction_label_del = nil
  15848. }
  15849. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  15850. func (m *LabelTaggingMutation) ActionLabelDel() (r []uint64, exists bool) {
  15851. v := m.action_label_del
  15852. if v == nil {
  15853. return
  15854. }
  15855. return *v, true
  15856. }
  15857. // OldActionLabelDel returns the old "action_label_del" field's value of the LabelTagging entity.
  15858. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  15859. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15860. func (m *LabelTaggingMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  15861. if !m.op.Is(OpUpdateOne) {
  15862. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  15863. }
  15864. if m.id == nil || m.oldValue == nil {
  15865. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  15866. }
  15867. oldValue, err := m.oldValue(ctx)
  15868. if err != nil {
  15869. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  15870. }
  15871. return oldValue.ActionLabelDel, nil
  15872. }
  15873. // AppendActionLabelDel adds u to the "action_label_del" field.
  15874. func (m *LabelTaggingMutation) AppendActionLabelDel(u []uint64) {
  15875. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  15876. }
  15877. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  15878. func (m *LabelTaggingMutation) AppendedActionLabelDel() ([]uint64, bool) {
  15879. if len(m.appendaction_label_del) == 0 {
  15880. return nil, false
  15881. }
  15882. return m.appendaction_label_del, true
  15883. }
  15884. // ClearActionLabelDel clears the value of the "action_label_del" field.
  15885. func (m *LabelTaggingMutation) ClearActionLabelDel() {
  15886. m.action_label_del = nil
  15887. m.appendaction_label_del = nil
  15888. m.clearedFields[labeltagging.FieldActionLabelDel] = struct{}{}
  15889. }
  15890. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  15891. func (m *LabelTaggingMutation) ActionLabelDelCleared() bool {
  15892. _, ok := m.clearedFields[labeltagging.FieldActionLabelDel]
  15893. return ok
  15894. }
  15895. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  15896. func (m *LabelTaggingMutation) ResetActionLabelDel() {
  15897. m.action_label_del = nil
  15898. m.appendaction_label_del = nil
  15899. delete(m.clearedFields, labeltagging.FieldActionLabelDel)
  15900. }
  15901. // Where appends a list predicates to the LabelTaggingMutation builder.
  15902. func (m *LabelTaggingMutation) Where(ps ...predicate.LabelTagging) {
  15903. m.predicates = append(m.predicates, ps...)
  15904. }
  15905. // WhereP appends storage-level predicates to the LabelTaggingMutation builder. Using this method,
  15906. // users can use type-assertion to append predicates that do not depend on any generated package.
  15907. func (m *LabelTaggingMutation) WhereP(ps ...func(*sql.Selector)) {
  15908. p := make([]predicate.LabelTagging, len(ps))
  15909. for i := range ps {
  15910. p[i] = ps[i]
  15911. }
  15912. m.Where(p...)
  15913. }
  15914. // Op returns the operation name.
  15915. func (m *LabelTaggingMutation) Op() Op {
  15916. return m.op
  15917. }
  15918. // SetOp allows setting the mutation operation.
  15919. func (m *LabelTaggingMutation) SetOp(op Op) {
  15920. m.op = op
  15921. }
  15922. // Type returns the node type of this mutation (LabelTagging).
  15923. func (m *LabelTaggingMutation) Type() string {
  15924. return m.typ
  15925. }
  15926. // Fields returns all fields that were changed during this mutation. Note that in
  15927. // order to get all numeric fields that were incremented/decremented, call
  15928. // AddedFields().
  15929. func (m *LabelTaggingMutation) Fields() []string {
  15930. fields := make([]string, 0, 9)
  15931. if m.created_at != nil {
  15932. fields = append(fields, labeltagging.FieldCreatedAt)
  15933. }
  15934. if m.updated_at != nil {
  15935. fields = append(fields, labeltagging.FieldUpdatedAt)
  15936. }
  15937. if m.status != nil {
  15938. fields = append(fields, labeltagging.FieldStatus)
  15939. }
  15940. if m.deleted_at != nil {
  15941. fields = append(fields, labeltagging.FieldDeletedAt)
  15942. }
  15943. if m.organization_id != nil {
  15944. fields = append(fields, labeltagging.FieldOrganizationID)
  15945. }
  15946. if m._type != nil {
  15947. fields = append(fields, labeltagging.FieldType)
  15948. }
  15949. if m.conditions != nil {
  15950. fields = append(fields, labeltagging.FieldConditions)
  15951. }
  15952. if m.action_label_add != nil {
  15953. fields = append(fields, labeltagging.FieldActionLabelAdd)
  15954. }
  15955. if m.action_label_del != nil {
  15956. fields = append(fields, labeltagging.FieldActionLabelDel)
  15957. }
  15958. return fields
  15959. }
  15960. // Field returns the value of a field with the given name. The second boolean
  15961. // return value indicates that this field was not set, or was not defined in the
  15962. // schema.
  15963. func (m *LabelTaggingMutation) Field(name string) (ent.Value, bool) {
  15964. switch name {
  15965. case labeltagging.FieldCreatedAt:
  15966. return m.CreatedAt()
  15967. case labeltagging.FieldUpdatedAt:
  15968. return m.UpdatedAt()
  15969. case labeltagging.FieldStatus:
  15970. return m.Status()
  15971. case labeltagging.FieldDeletedAt:
  15972. return m.DeletedAt()
  15973. case labeltagging.FieldOrganizationID:
  15974. return m.OrganizationID()
  15975. case labeltagging.FieldType:
  15976. return m.GetType()
  15977. case labeltagging.FieldConditions:
  15978. return m.Conditions()
  15979. case labeltagging.FieldActionLabelAdd:
  15980. return m.ActionLabelAdd()
  15981. case labeltagging.FieldActionLabelDel:
  15982. return m.ActionLabelDel()
  15983. }
  15984. return nil, false
  15985. }
  15986. // OldField returns the old value of the field from the database. An error is
  15987. // returned if the mutation operation is not UpdateOne, or the query to the
  15988. // database failed.
  15989. func (m *LabelTaggingMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  15990. switch name {
  15991. case labeltagging.FieldCreatedAt:
  15992. return m.OldCreatedAt(ctx)
  15993. case labeltagging.FieldUpdatedAt:
  15994. return m.OldUpdatedAt(ctx)
  15995. case labeltagging.FieldStatus:
  15996. return m.OldStatus(ctx)
  15997. case labeltagging.FieldDeletedAt:
  15998. return m.OldDeletedAt(ctx)
  15999. case labeltagging.FieldOrganizationID:
  16000. return m.OldOrganizationID(ctx)
  16001. case labeltagging.FieldType:
  16002. return m.OldType(ctx)
  16003. case labeltagging.FieldConditions:
  16004. return m.OldConditions(ctx)
  16005. case labeltagging.FieldActionLabelAdd:
  16006. return m.OldActionLabelAdd(ctx)
  16007. case labeltagging.FieldActionLabelDel:
  16008. return m.OldActionLabelDel(ctx)
  16009. }
  16010. return nil, fmt.Errorf("unknown LabelTagging field %s", name)
  16011. }
  16012. // SetField sets the value of a field with the given name. It returns an error if
  16013. // the field is not defined in the schema, or if the type mismatched the field
  16014. // type.
  16015. func (m *LabelTaggingMutation) SetField(name string, value ent.Value) error {
  16016. switch name {
  16017. case labeltagging.FieldCreatedAt:
  16018. v, ok := value.(time.Time)
  16019. if !ok {
  16020. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16021. }
  16022. m.SetCreatedAt(v)
  16023. return nil
  16024. case labeltagging.FieldUpdatedAt:
  16025. v, ok := value.(time.Time)
  16026. if !ok {
  16027. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16028. }
  16029. m.SetUpdatedAt(v)
  16030. return nil
  16031. case labeltagging.FieldStatus:
  16032. v, ok := value.(uint8)
  16033. if !ok {
  16034. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16035. }
  16036. m.SetStatus(v)
  16037. return nil
  16038. case labeltagging.FieldDeletedAt:
  16039. v, ok := value.(time.Time)
  16040. if !ok {
  16041. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16042. }
  16043. m.SetDeletedAt(v)
  16044. return nil
  16045. case labeltagging.FieldOrganizationID:
  16046. v, ok := value.(uint64)
  16047. if !ok {
  16048. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16049. }
  16050. m.SetOrganizationID(v)
  16051. return nil
  16052. case labeltagging.FieldType:
  16053. v, ok := value.(int)
  16054. if !ok {
  16055. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16056. }
  16057. m.SetType(v)
  16058. return nil
  16059. case labeltagging.FieldConditions:
  16060. v, ok := value.(string)
  16061. if !ok {
  16062. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16063. }
  16064. m.SetConditions(v)
  16065. return nil
  16066. case labeltagging.FieldActionLabelAdd:
  16067. v, ok := value.([]uint64)
  16068. if !ok {
  16069. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16070. }
  16071. m.SetActionLabelAdd(v)
  16072. return nil
  16073. case labeltagging.FieldActionLabelDel:
  16074. v, ok := value.([]uint64)
  16075. if !ok {
  16076. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16077. }
  16078. m.SetActionLabelDel(v)
  16079. return nil
  16080. }
  16081. return fmt.Errorf("unknown LabelTagging field %s", name)
  16082. }
  16083. // AddedFields returns all numeric fields that were incremented/decremented during
  16084. // this mutation.
  16085. func (m *LabelTaggingMutation) AddedFields() []string {
  16086. var fields []string
  16087. if m.addstatus != nil {
  16088. fields = append(fields, labeltagging.FieldStatus)
  16089. }
  16090. if m.addorganization_id != nil {
  16091. fields = append(fields, labeltagging.FieldOrganizationID)
  16092. }
  16093. if m.add_type != nil {
  16094. fields = append(fields, labeltagging.FieldType)
  16095. }
  16096. return fields
  16097. }
  16098. // AddedField returns the numeric value that was incremented/decremented on a field
  16099. // with the given name. The second boolean return value indicates that this field
  16100. // was not set, or was not defined in the schema.
  16101. func (m *LabelTaggingMutation) AddedField(name string) (ent.Value, bool) {
  16102. switch name {
  16103. case labeltagging.FieldStatus:
  16104. return m.AddedStatus()
  16105. case labeltagging.FieldOrganizationID:
  16106. return m.AddedOrganizationID()
  16107. case labeltagging.FieldType:
  16108. return m.AddedType()
  16109. }
  16110. return nil, false
  16111. }
  16112. // AddField adds the value to the field with the given name. It returns an error if
  16113. // the field is not defined in the schema, or if the type mismatched the field
  16114. // type.
  16115. func (m *LabelTaggingMutation) AddField(name string, value ent.Value) error {
  16116. switch name {
  16117. case labeltagging.FieldStatus:
  16118. v, ok := value.(int8)
  16119. if !ok {
  16120. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16121. }
  16122. m.AddStatus(v)
  16123. return nil
  16124. case labeltagging.FieldOrganizationID:
  16125. v, ok := value.(int64)
  16126. if !ok {
  16127. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16128. }
  16129. m.AddOrganizationID(v)
  16130. return nil
  16131. case labeltagging.FieldType:
  16132. v, ok := value.(int)
  16133. if !ok {
  16134. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16135. }
  16136. m.AddType(v)
  16137. return nil
  16138. }
  16139. return fmt.Errorf("unknown LabelTagging numeric field %s", name)
  16140. }
  16141. // ClearedFields returns all nullable fields that were cleared during this
  16142. // mutation.
  16143. func (m *LabelTaggingMutation) ClearedFields() []string {
  16144. var fields []string
  16145. if m.FieldCleared(labeltagging.FieldStatus) {
  16146. fields = append(fields, labeltagging.FieldStatus)
  16147. }
  16148. if m.FieldCleared(labeltagging.FieldDeletedAt) {
  16149. fields = append(fields, labeltagging.FieldDeletedAt)
  16150. }
  16151. if m.FieldCleared(labeltagging.FieldActionLabelAdd) {
  16152. fields = append(fields, labeltagging.FieldActionLabelAdd)
  16153. }
  16154. if m.FieldCleared(labeltagging.FieldActionLabelDel) {
  16155. fields = append(fields, labeltagging.FieldActionLabelDel)
  16156. }
  16157. return fields
  16158. }
  16159. // FieldCleared returns a boolean indicating if a field with the given name was
  16160. // cleared in this mutation.
  16161. func (m *LabelTaggingMutation) FieldCleared(name string) bool {
  16162. _, ok := m.clearedFields[name]
  16163. return ok
  16164. }
  16165. // ClearField clears the value of the field with the given name. It returns an
  16166. // error if the field is not defined in the schema.
  16167. func (m *LabelTaggingMutation) ClearField(name string) error {
  16168. switch name {
  16169. case labeltagging.FieldStatus:
  16170. m.ClearStatus()
  16171. return nil
  16172. case labeltagging.FieldDeletedAt:
  16173. m.ClearDeletedAt()
  16174. return nil
  16175. case labeltagging.FieldActionLabelAdd:
  16176. m.ClearActionLabelAdd()
  16177. return nil
  16178. case labeltagging.FieldActionLabelDel:
  16179. m.ClearActionLabelDel()
  16180. return nil
  16181. }
  16182. return fmt.Errorf("unknown LabelTagging nullable field %s", name)
  16183. }
  16184. // ResetField resets all changes in the mutation for the field with the given name.
  16185. // It returns an error if the field is not defined in the schema.
  16186. func (m *LabelTaggingMutation) ResetField(name string) error {
  16187. switch name {
  16188. case labeltagging.FieldCreatedAt:
  16189. m.ResetCreatedAt()
  16190. return nil
  16191. case labeltagging.FieldUpdatedAt:
  16192. m.ResetUpdatedAt()
  16193. return nil
  16194. case labeltagging.FieldStatus:
  16195. m.ResetStatus()
  16196. return nil
  16197. case labeltagging.FieldDeletedAt:
  16198. m.ResetDeletedAt()
  16199. return nil
  16200. case labeltagging.FieldOrganizationID:
  16201. m.ResetOrganizationID()
  16202. return nil
  16203. case labeltagging.FieldType:
  16204. m.ResetType()
  16205. return nil
  16206. case labeltagging.FieldConditions:
  16207. m.ResetConditions()
  16208. return nil
  16209. case labeltagging.FieldActionLabelAdd:
  16210. m.ResetActionLabelAdd()
  16211. return nil
  16212. case labeltagging.FieldActionLabelDel:
  16213. m.ResetActionLabelDel()
  16214. return nil
  16215. }
  16216. return fmt.Errorf("unknown LabelTagging field %s", name)
  16217. }
  16218. // AddedEdges returns all edge names that were set/added in this mutation.
  16219. func (m *LabelTaggingMutation) AddedEdges() []string {
  16220. edges := make([]string, 0, 0)
  16221. return edges
  16222. }
  16223. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  16224. // name in this mutation.
  16225. func (m *LabelTaggingMutation) AddedIDs(name string) []ent.Value {
  16226. return nil
  16227. }
  16228. // RemovedEdges returns all edge names that were removed in this mutation.
  16229. func (m *LabelTaggingMutation) RemovedEdges() []string {
  16230. edges := make([]string, 0, 0)
  16231. return edges
  16232. }
  16233. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  16234. // the given name in this mutation.
  16235. func (m *LabelTaggingMutation) RemovedIDs(name string) []ent.Value {
  16236. return nil
  16237. }
  16238. // ClearedEdges returns all edge names that were cleared in this mutation.
  16239. func (m *LabelTaggingMutation) ClearedEdges() []string {
  16240. edges := make([]string, 0, 0)
  16241. return edges
  16242. }
  16243. // EdgeCleared returns a boolean which indicates if the edge with the given name
  16244. // was cleared in this mutation.
  16245. func (m *LabelTaggingMutation) EdgeCleared(name string) bool {
  16246. return false
  16247. }
  16248. // ClearEdge clears the value of the edge with the given name. It returns an error
  16249. // if that edge is not defined in the schema.
  16250. func (m *LabelTaggingMutation) ClearEdge(name string) error {
  16251. return fmt.Errorf("unknown LabelTagging unique edge %s", name)
  16252. }
  16253. // ResetEdge resets all changes to the edge with the given name in this mutation.
  16254. // It returns an error if the edge is not defined in the schema.
  16255. func (m *LabelTaggingMutation) ResetEdge(name string) error {
  16256. return fmt.Errorf("unknown LabelTagging edge %s", name)
  16257. }
  16258. // MessageMutation represents an operation that mutates the Message nodes in the graph.
  16259. type MessageMutation struct {
  16260. config
  16261. op Op
  16262. typ string
  16263. id *int
  16264. wx_wxid *string
  16265. wxid *string
  16266. content *string
  16267. clearedFields map[string]struct{}
  16268. done bool
  16269. oldValue func(context.Context) (*Message, error)
  16270. predicates []predicate.Message
  16271. }
  16272. var _ ent.Mutation = (*MessageMutation)(nil)
  16273. // messageOption allows management of the mutation configuration using functional options.
  16274. type messageOption func(*MessageMutation)
  16275. // newMessageMutation creates new mutation for the Message entity.
  16276. func newMessageMutation(c config, op Op, opts ...messageOption) *MessageMutation {
  16277. m := &MessageMutation{
  16278. config: c,
  16279. op: op,
  16280. typ: TypeMessage,
  16281. clearedFields: make(map[string]struct{}),
  16282. }
  16283. for _, opt := range opts {
  16284. opt(m)
  16285. }
  16286. return m
  16287. }
  16288. // withMessageID sets the ID field of the mutation.
  16289. func withMessageID(id int) messageOption {
  16290. return func(m *MessageMutation) {
  16291. var (
  16292. err error
  16293. once sync.Once
  16294. value *Message
  16295. )
  16296. m.oldValue = func(ctx context.Context) (*Message, error) {
  16297. once.Do(func() {
  16298. if m.done {
  16299. err = errors.New("querying old values post mutation is not allowed")
  16300. } else {
  16301. value, err = m.Client().Message.Get(ctx, id)
  16302. }
  16303. })
  16304. return value, err
  16305. }
  16306. m.id = &id
  16307. }
  16308. }
  16309. // withMessage sets the old Message of the mutation.
  16310. func withMessage(node *Message) messageOption {
  16311. return func(m *MessageMutation) {
  16312. m.oldValue = func(context.Context) (*Message, error) {
  16313. return node, nil
  16314. }
  16315. m.id = &node.ID
  16316. }
  16317. }
  16318. // Client returns a new `ent.Client` from the mutation. If the mutation was
  16319. // executed in a transaction (ent.Tx), a transactional client is returned.
  16320. func (m MessageMutation) Client() *Client {
  16321. client := &Client{config: m.config}
  16322. client.init()
  16323. return client
  16324. }
  16325. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  16326. // it returns an error otherwise.
  16327. func (m MessageMutation) Tx() (*Tx, error) {
  16328. if _, ok := m.driver.(*txDriver); !ok {
  16329. return nil, errors.New("ent: mutation is not running in a transaction")
  16330. }
  16331. tx := &Tx{config: m.config}
  16332. tx.init()
  16333. return tx, nil
  16334. }
  16335. // ID returns the ID value in the mutation. Note that the ID is only available
  16336. // if it was provided to the builder or after it was returned from the database.
  16337. func (m *MessageMutation) ID() (id int, exists bool) {
  16338. if m.id == nil {
  16339. return
  16340. }
  16341. return *m.id, true
  16342. }
  16343. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  16344. // That means, if the mutation is applied within a transaction with an isolation level such
  16345. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  16346. // or updated by the mutation.
  16347. func (m *MessageMutation) IDs(ctx context.Context) ([]int, error) {
  16348. switch {
  16349. case m.op.Is(OpUpdateOne | OpDeleteOne):
  16350. id, exists := m.ID()
  16351. if exists {
  16352. return []int{id}, nil
  16353. }
  16354. fallthrough
  16355. case m.op.Is(OpUpdate | OpDelete):
  16356. return m.Client().Message.Query().Where(m.predicates...).IDs(ctx)
  16357. default:
  16358. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  16359. }
  16360. }
  16361. // SetWxWxid sets the "wx_wxid" field.
  16362. func (m *MessageMutation) SetWxWxid(s string) {
  16363. m.wx_wxid = &s
  16364. }
  16365. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  16366. func (m *MessageMutation) WxWxid() (r string, exists bool) {
  16367. v := m.wx_wxid
  16368. if v == nil {
  16369. return
  16370. }
  16371. return *v, true
  16372. }
  16373. // OldWxWxid returns the old "wx_wxid" field's value of the Message entity.
  16374. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  16375. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16376. func (m *MessageMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  16377. if !m.op.Is(OpUpdateOne) {
  16378. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  16379. }
  16380. if m.id == nil || m.oldValue == nil {
  16381. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  16382. }
  16383. oldValue, err := m.oldValue(ctx)
  16384. if err != nil {
  16385. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  16386. }
  16387. return oldValue.WxWxid, nil
  16388. }
  16389. // ClearWxWxid clears the value of the "wx_wxid" field.
  16390. func (m *MessageMutation) ClearWxWxid() {
  16391. m.wx_wxid = nil
  16392. m.clearedFields[message.FieldWxWxid] = struct{}{}
  16393. }
  16394. // WxWxidCleared returns if the "wx_wxid" field was cleared in this mutation.
  16395. func (m *MessageMutation) WxWxidCleared() bool {
  16396. _, ok := m.clearedFields[message.FieldWxWxid]
  16397. return ok
  16398. }
  16399. // ResetWxWxid resets all changes to the "wx_wxid" field.
  16400. func (m *MessageMutation) ResetWxWxid() {
  16401. m.wx_wxid = nil
  16402. delete(m.clearedFields, message.FieldWxWxid)
  16403. }
  16404. // SetWxid sets the "wxid" field.
  16405. func (m *MessageMutation) SetWxid(s string) {
  16406. m.wxid = &s
  16407. }
  16408. // Wxid returns the value of the "wxid" field in the mutation.
  16409. func (m *MessageMutation) Wxid() (r string, exists bool) {
  16410. v := m.wxid
  16411. if v == nil {
  16412. return
  16413. }
  16414. return *v, true
  16415. }
  16416. // OldWxid returns the old "wxid" field's value of the Message entity.
  16417. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  16418. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16419. func (m *MessageMutation) OldWxid(ctx context.Context) (v string, err error) {
  16420. if !m.op.Is(OpUpdateOne) {
  16421. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  16422. }
  16423. if m.id == nil || m.oldValue == nil {
  16424. return v, errors.New("OldWxid requires an ID field in the mutation")
  16425. }
  16426. oldValue, err := m.oldValue(ctx)
  16427. if err != nil {
  16428. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  16429. }
  16430. return oldValue.Wxid, nil
  16431. }
  16432. // ResetWxid resets all changes to the "wxid" field.
  16433. func (m *MessageMutation) ResetWxid() {
  16434. m.wxid = nil
  16435. }
  16436. // SetContent sets the "content" field.
  16437. func (m *MessageMutation) SetContent(s string) {
  16438. m.content = &s
  16439. }
  16440. // Content returns the value of the "content" field in the mutation.
  16441. func (m *MessageMutation) Content() (r string, exists bool) {
  16442. v := m.content
  16443. if v == nil {
  16444. return
  16445. }
  16446. return *v, true
  16447. }
  16448. // OldContent returns the old "content" field's value of the Message entity.
  16449. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  16450. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16451. func (m *MessageMutation) OldContent(ctx context.Context) (v string, err error) {
  16452. if !m.op.Is(OpUpdateOne) {
  16453. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  16454. }
  16455. if m.id == nil || m.oldValue == nil {
  16456. return v, errors.New("OldContent requires an ID field in the mutation")
  16457. }
  16458. oldValue, err := m.oldValue(ctx)
  16459. if err != nil {
  16460. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  16461. }
  16462. return oldValue.Content, nil
  16463. }
  16464. // ResetContent resets all changes to the "content" field.
  16465. func (m *MessageMutation) ResetContent() {
  16466. m.content = nil
  16467. }
  16468. // Where appends a list predicates to the MessageMutation builder.
  16469. func (m *MessageMutation) Where(ps ...predicate.Message) {
  16470. m.predicates = append(m.predicates, ps...)
  16471. }
  16472. // WhereP appends storage-level predicates to the MessageMutation builder. Using this method,
  16473. // users can use type-assertion to append predicates that do not depend on any generated package.
  16474. func (m *MessageMutation) WhereP(ps ...func(*sql.Selector)) {
  16475. p := make([]predicate.Message, len(ps))
  16476. for i := range ps {
  16477. p[i] = ps[i]
  16478. }
  16479. m.Where(p...)
  16480. }
  16481. // Op returns the operation name.
  16482. func (m *MessageMutation) Op() Op {
  16483. return m.op
  16484. }
  16485. // SetOp allows setting the mutation operation.
  16486. func (m *MessageMutation) SetOp(op Op) {
  16487. m.op = op
  16488. }
  16489. // Type returns the node type of this mutation (Message).
  16490. func (m *MessageMutation) Type() string {
  16491. return m.typ
  16492. }
  16493. // Fields returns all fields that were changed during this mutation. Note that in
  16494. // order to get all numeric fields that were incremented/decremented, call
  16495. // AddedFields().
  16496. func (m *MessageMutation) Fields() []string {
  16497. fields := make([]string, 0, 3)
  16498. if m.wx_wxid != nil {
  16499. fields = append(fields, message.FieldWxWxid)
  16500. }
  16501. if m.wxid != nil {
  16502. fields = append(fields, message.FieldWxid)
  16503. }
  16504. if m.content != nil {
  16505. fields = append(fields, message.FieldContent)
  16506. }
  16507. return fields
  16508. }
  16509. // Field returns the value of a field with the given name. The second boolean
  16510. // return value indicates that this field was not set, or was not defined in the
  16511. // schema.
  16512. func (m *MessageMutation) Field(name string) (ent.Value, bool) {
  16513. switch name {
  16514. case message.FieldWxWxid:
  16515. return m.WxWxid()
  16516. case message.FieldWxid:
  16517. return m.Wxid()
  16518. case message.FieldContent:
  16519. return m.Content()
  16520. }
  16521. return nil, false
  16522. }
  16523. // OldField returns the old value of the field from the database. An error is
  16524. // returned if the mutation operation is not UpdateOne, or the query to the
  16525. // database failed.
  16526. func (m *MessageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  16527. switch name {
  16528. case message.FieldWxWxid:
  16529. return m.OldWxWxid(ctx)
  16530. case message.FieldWxid:
  16531. return m.OldWxid(ctx)
  16532. case message.FieldContent:
  16533. return m.OldContent(ctx)
  16534. }
  16535. return nil, fmt.Errorf("unknown Message field %s", name)
  16536. }
  16537. // SetField sets the value of a field with the given name. It returns an error if
  16538. // the field is not defined in the schema, or if the type mismatched the field
  16539. // type.
  16540. func (m *MessageMutation) SetField(name string, value ent.Value) error {
  16541. switch name {
  16542. case message.FieldWxWxid:
  16543. v, ok := value.(string)
  16544. if !ok {
  16545. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16546. }
  16547. m.SetWxWxid(v)
  16548. return nil
  16549. case message.FieldWxid:
  16550. v, ok := value.(string)
  16551. if !ok {
  16552. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16553. }
  16554. m.SetWxid(v)
  16555. return nil
  16556. case message.FieldContent:
  16557. v, ok := value.(string)
  16558. if !ok {
  16559. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16560. }
  16561. m.SetContent(v)
  16562. return nil
  16563. }
  16564. return fmt.Errorf("unknown Message field %s", name)
  16565. }
  16566. // AddedFields returns all numeric fields that were incremented/decremented during
  16567. // this mutation.
  16568. func (m *MessageMutation) AddedFields() []string {
  16569. return nil
  16570. }
  16571. // AddedField returns the numeric value that was incremented/decremented on a field
  16572. // with the given name. The second boolean return value indicates that this field
  16573. // was not set, or was not defined in the schema.
  16574. func (m *MessageMutation) AddedField(name string) (ent.Value, bool) {
  16575. return nil, false
  16576. }
  16577. // AddField adds the value to the field with the given name. It returns an error if
  16578. // the field is not defined in the schema, or if the type mismatched the field
  16579. // type.
  16580. func (m *MessageMutation) AddField(name string, value ent.Value) error {
  16581. switch name {
  16582. }
  16583. return fmt.Errorf("unknown Message numeric field %s", name)
  16584. }
  16585. // ClearedFields returns all nullable fields that were cleared during this
  16586. // mutation.
  16587. func (m *MessageMutation) ClearedFields() []string {
  16588. var fields []string
  16589. if m.FieldCleared(message.FieldWxWxid) {
  16590. fields = append(fields, message.FieldWxWxid)
  16591. }
  16592. return fields
  16593. }
  16594. // FieldCleared returns a boolean indicating if a field with the given name was
  16595. // cleared in this mutation.
  16596. func (m *MessageMutation) FieldCleared(name string) bool {
  16597. _, ok := m.clearedFields[name]
  16598. return ok
  16599. }
  16600. // ClearField clears the value of the field with the given name. It returns an
  16601. // error if the field is not defined in the schema.
  16602. func (m *MessageMutation) ClearField(name string) error {
  16603. switch name {
  16604. case message.FieldWxWxid:
  16605. m.ClearWxWxid()
  16606. return nil
  16607. }
  16608. return fmt.Errorf("unknown Message nullable field %s", name)
  16609. }
  16610. // ResetField resets all changes in the mutation for the field with the given name.
  16611. // It returns an error if the field is not defined in the schema.
  16612. func (m *MessageMutation) ResetField(name string) error {
  16613. switch name {
  16614. case message.FieldWxWxid:
  16615. m.ResetWxWxid()
  16616. return nil
  16617. case message.FieldWxid:
  16618. m.ResetWxid()
  16619. return nil
  16620. case message.FieldContent:
  16621. m.ResetContent()
  16622. return nil
  16623. }
  16624. return fmt.Errorf("unknown Message field %s", name)
  16625. }
  16626. // AddedEdges returns all edge names that were set/added in this mutation.
  16627. func (m *MessageMutation) AddedEdges() []string {
  16628. edges := make([]string, 0, 0)
  16629. return edges
  16630. }
  16631. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  16632. // name in this mutation.
  16633. func (m *MessageMutation) AddedIDs(name string) []ent.Value {
  16634. return nil
  16635. }
  16636. // RemovedEdges returns all edge names that were removed in this mutation.
  16637. func (m *MessageMutation) RemovedEdges() []string {
  16638. edges := make([]string, 0, 0)
  16639. return edges
  16640. }
  16641. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  16642. // the given name in this mutation.
  16643. func (m *MessageMutation) RemovedIDs(name string) []ent.Value {
  16644. return nil
  16645. }
  16646. // ClearedEdges returns all edge names that were cleared in this mutation.
  16647. func (m *MessageMutation) ClearedEdges() []string {
  16648. edges := make([]string, 0, 0)
  16649. return edges
  16650. }
  16651. // EdgeCleared returns a boolean which indicates if the edge with the given name
  16652. // was cleared in this mutation.
  16653. func (m *MessageMutation) EdgeCleared(name string) bool {
  16654. return false
  16655. }
  16656. // ClearEdge clears the value of the edge with the given name. It returns an error
  16657. // if that edge is not defined in the schema.
  16658. func (m *MessageMutation) ClearEdge(name string) error {
  16659. return fmt.Errorf("unknown Message unique edge %s", name)
  16660. }
  16661. // ResetEdge resets all changes to the edge with the given name in this mutation.
  16662. // It returns an error if the edge is not defined in the schema.
  16663. func (m *MessageMutation) ResetEdge(name string) error {
  16664. return fmt.Errorf("unknown Message edge %s", name)
  16665. }
  16666. // MessageRecordsMutation represents an operation that mutates the MessageRecords nodes in the graph.
  16667. type MessageRecordsMutation struct {
  16668. config
  16669. op Op
  16670. typ string
  16671. id *uint64
  16672. created_at *time.Time
  16673. updated_at *time.Time
  16674. status *uint8
  16675. addstatus *int8
  16676. bot_wxid *string
  16677. contact_type *int
  16678. addcontact_type *int
  16679. contact_wxid *string
  16680. content_type *int
  16681. addcontent_type *int
  16682. content *string
  16683. meta *custom_types.Meta
  16684. error_detail *string
  16685. send_time *time.Time
  16686. source_type *int
  16687. addsource_type *int
  16688. organization_id *uint64
  16689. addorganization_id *int64
  16690. clearedFields map[string]struct{}
  16691. sop_stage *uint64
  16692. clearedsop_stage bool
  16693. sop_node *uint64
  16694. clearedsop_node bool
  16695. message_contact *uint64
  16696. clearedmessage_contact bool
  16697. done bool
  16698. oldValue func(context.Context) (*MessageRecords, error)
  16699. predicates []predicate.MessageRecords
  16700. }
  16701. var _ ent.Mutation = (*MessageRecordsMutation)(nil)
  16702. // messagerecordsOption allows management of the mutation configuration using functional options.
  16703. type messagerecordsOption func(*MessageRecordsMutation)
  16704. // newMessageRecordsMutation creates new mutation for the MessageRecords entity.
  16705. func newMessageRecordsMutation(c config, op Op, opts ...messagerecordsOption) *MessageRecordsMutation {
  16706. m := &MessageRecordsMutation{
  16707. config: c,
  16708. op: op,
  16709. typ: TypeMessageRecords,
  16710. clearedFields: make(map[string]struct{}),
  16711. }
  16712. for _, opt := range opts {
  16713. opt(m)
  16714. }
  16715. return m
  16716. }
  16717. // withMessageRecordsID sets the ID field of the mutation.
  16718. func withMessageRecordsID(id uint64) messagerecordsOption {
  16719. return func(m *MessageRecordsMutation) {
  16720. var (
  16721. err error
  16722. once sync.Once
  16723. value *MessageRecords
  16724. )
  16725. m.oldValue = func(ctx context.Context) (*MessageRecords, error) {
  16726. once.Do(func() {
  16727. if m.done {
  16728. err = errors.New("querying old values post mutation is not allowed")
  16729. } else {
  16730. value, err = m.Client().MessageRecords.Get(ctx, id)
  16731. }
  16732. })
  16733. return value, err
  16734. }
  16735. m.id = &id
  16736. }
  16737. }
  16738. // withMessageRecords sets the old MessageRecords of the mutation.
  16739. func withMessageRecords(node *MessageRecords) messagerecordsOption {
  16740. return func(m *MessageRecordsMutation) {
  16741. m.oldValue = func(context.Context) (*MessageRecords, error) {
  16742. return node, nil
  16743. }
  16744. m.id = &node.ID
  16745. }
  16746. }
  16747. // Client returns a new `ent.Client` from the mutation. If the mutation was
  16748. // executed in a transaction (ent.Tx), a transactional client is returned.
  16749. func (m MessageRecordsMutation) Client() *Client {
  16750. client := &Client{config: m.config}
  16751. client.init()
  16752. return client
  16753. }
  16754. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  16755. // it returns an error otherwise.
  16756. func (m MessageRecordsMutation) Tx() (*Tx, error) {
  16757. if _, ok := m.driver.(*txDriver); !ok {
  16758. return nil, errors.New("ent: mutation is not running in a transaction")
  16759. }
  16760. tx := &Tx{config: m.config}
  16761. tx.init()
  16762. return tx, nil
  16763. }
  16764. // SetID sets the value of the id field. Note that this
  16765. // operation is only accepted on creation of MessageRecords entities.
  16766. func (m *MessageRecordsMutation) SetID(id uint64) {
  16767. m.id = &id
  16768. }
  16769. // ID returns the ID value in the mutation. Note that the ID is only available
  16770. // if it was provided to the builder or after it was returned from the database.
  16771. func (m *MessageRecordsMutation) ID() (id uint64, exists bool) {
  16772. if m.id == nil {
  16773. return
  16774. }
  16775. return *m.id, true
  16776. }
  16777. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  16778. // That means, if the mutation is applied within a transaction with an isolation level such
  16779. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  16780. // or updated by the mutation.
  16781. func (m *MessageRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  16782. switch {
  16783. case m.op.Is(OpUpdateOne | OpDeleteOne):
  16784. id, exists := m.ID()
  16785. if exists {
  16786. return []uint64{id}, nil
  16787. }
  16788. fallthrough
  16789. case m.op.Is(OpUpdate | OpDelete):
  16790. return m.Client().MessageRecords.Query().Where(m.predicates...).IDs(ctx)
  16791. default:
  16792. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  16793. }
  16794. }
  16795. // SetCreatedAt sets the "created_at" field.
  16796. func (m *MessageRecordsMutation) SetCreatedAt(t time.Time) {
  16797. m.created_at = &t
  16798. }
  16799. // CreatedAt returns the value of the "created_at" field in the mutation.
  16800. func (m *MessageRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  16801. v := m.created_at
  16802. if v == nil {
  16803. return
  16804. }
  16805. return *v, true
  16806. }
  16807. // OldCreatedAt returns the old "created_at" field's value of the MessageRecords entity.
  16808. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  16809. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16810. func (m *MessageRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  16811. if !m.op.Is(OpUpdateOne) {
  16812. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  16813. }
  16814. if m.id == nil || m.oldValue == nil {
  16815. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  16816. }
  16817. oldValue, err := m.oldValue(ctx)
  16818. if err != nil {
  16819. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  16820. }
  16821. return oldValue.CreatedAt, nil
  16822. }
  16823. // ResetCreatedAt resets all changes to the "created_at" field.
  16824. func (m *MessageRecordsMutation) ResetCreatedAt() {
  16825. m.created_at = nil
  16826. }
  16827. // SetUpdatedAt sets the "updated_at" field.
  16828. func (m *MessageRecordsMutation) SetUpdatedAt(t time.Time) {
  16829. m.updated_at = &t
  16830. }
  16831. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  16832. func (m *MessageRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  16833. v := m.updated_at
  16834. if v == nil {
  16835. return
  16836. }
  16837. return *v, true
  16838. }
  16839. // OldUpdatedAt returns the old "updated_at" field's value of the MessageRecords entity.
  16840. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  16841. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16842. func (m *MessageRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  16843. if !m.op.Is(OpUpdateOne) {
  16844. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  16845. }
  16846. if m.id == nil || m.oldValue == nil {
  16847. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  16848. }
  16849. oldValue, err := m.oldValue(ctx)
  16850. if err != nil {
  16851. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  16852. }
  16853. return oldValue.UpdatedAt, nil
  16854. }
  16855. // ResetUpdatedAt resets all changes to the "updated_at" field.
  16856. func (m *MessageRecordsMutation) ResetUpdatedAt() {
  16857. m.updated_at = nil
  16858. }
  16859. // SetStatus sets the "status" field.
  16860. func (m *MessageRecordsMutation) SetStatus(u uint8) {
  16861. m.status = &u
  16862. m.addstatus = nil
  16863. }
  16864. // Status returns the value of the "status" field in the mutation.
  16865. func (m *MessageRecordsMutation) Status() (r uint8, exists bool) {
  16866. v := m.status
  16867. if v == nil {
  16868. return
  16869. }
  16870. return *v, true
  16871. }
  16872. // OldStatus returns the old "status" field's value of the MessageRecords entity.
  16873. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  16874. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16875. func (m *MessageRecordsMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  16876. if !m.op.Is(OpUpdateOne) {
  16877. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  16878. }
  16879. if m.id == nil || m.oldValue == nil {
  16880. return v, errors.New("OldStatus requires an ID field in the mutation")
  16881. }
  16882. oldValue, err := m.oldValue(ctx)
  16883. if err != nil {
  16884. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  16885. }
  16886. return oldValue.Status, nil
  16887. }
  16888. // AddStatus adds u to the "status" field.
  16889. func (m *MessageRecordsMutation) AddStatus(u int8) {
  16890. if m.addstatus != nil {
  16891. *m.addstatus += u
  16892. } else {
  16893. m.addstatus = &u
  16894. }
  16895. }
  16896. // AddedStatus returns the value that was added to the "status" field in this mutation.
  16897. func (m *MessageRecordsMutation) AddedStatus() (r int8, exists bool) {
  16898. v := m.addstatus
  16899. if v == nil {
  16900. return
  16901. }
  16902. return *v, true
  16903. }
  16904. // ClearStatus clears the value of the "status" field.
  16905. func (m *MessageRecordsMutation) ClearStatus() {
  16906. m.status = nil
  16907. m.addstatus = nil
  16908. m.clearedFields[messagerecords.FieldStatus] = struct{}{}
  16909. }
  16910. // StatusCleared returns if the "status" field was cleared in this mutation.
  16911. func (m *MessageRecordsMutation) StatusCleared() bool {
  16912. _, ok := m.clearedFields[messagerecords.FieldStatus]
  16913. return ok
  16914. }
  16915. // ResetStatus resets all changes to the "status" field.
  16916. func (m *MessageRecordsMutation) ResetStatus() {
  16917. m.status = nil
  16918. m.addstatus = nil
  16919. delete(m.clearedFields, messagerecords.FieldStatus)
  16920. }
  16921. // SetBotWxid sets the "bot_wxid" field.
  16922. func (m *MessageRecordsMutation) SetBotWxid(s string) {
  16923. m.bot_wxid = &s
  16924. }
  16925. // BotWxid returns the value of the "bot_wxid" field in the mutation.
  16926. func (m *MessageRecordsMutation) BotWxid() (r string, exists bool) {
  16927. v := m.bot_wxid
  16928. if v == nil {
  16929. return
  16930. }
  16931. return *v, true
  16932. }
  16933. // OldBotWxid returns the old "bot_wxid" field's value of the MessageRecords entity.
  16934. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  16935. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16936. func (m *MessageRecordsMutation) OldBotWxid(ctx context.Context) (v string, err error) {
  16937. if !m.op.Is(OpUpdateOne) {
  16938. return v, errors.New("OldBotWxid is only allowed on UpdateOne operations")
  16939. }
  16940. if m.id == nil || m.oldValue == nil {
  16941. return v, errors.New("OldBotWxid requires an ID field in the mutation")
  16942. }
  16943. oldValue, err := m.oldValue(ctx)
  16944. if err != nil {
  16945. return v, fmt.Errorf("querying old value for OldBotWxid: %w", err)
  16946. }
  16947. return oldValue.BotWxid, nil
  16948. }
  16949. // ResetBotWxid resets all changes to the "bot_wxid" field.
  16950. func (m *MessageRecordsMutation) ResetBotWxid() {
  16951. m.bot_wxid = nil
  16952. }
  16953. // SetContactID sets the "contact_id" field.
  16954. func (m *MessageRecordsMutation) SetContactID(u uint64) {
  16955. m.message_contact = &u
  16956. }
  16957. // ContactID returns the value of the "contact_id" field in the mutation.
  16958. func (m *MessageRecordsMutation) ContactID() (r uint64, exists bool) {
  16959. v := m.message_contact
  16960. if v == nil {
  16961. return
  16962. }
  16963. return *v, true
  16964. }
  16965. // OldContactID returns the old "contact_id" field's value of the MessageRecords entity.
  16966. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  16967. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16968. func (m *MessageRecordsMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  16969. if !m.op.Is(OpUpdateOne) {
  16970. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  16971. }
  16972. if m.id == nil || m.oldValue == nil {
  16973. return v, errors.New("OldContactID requires an ID field in the mutation")
  16974. }
  16975. oldValue, err := m.oldValue(ctx)
  16976. if err != nil {
  16977. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  16978. }
  16979. return oldValue.ContactID, nil
  16980. }
  16981. // ClearContactID clears the value of the "contact_id" field.
  16982. func (m *MessageRecordsMutation) ClearContactID() {
  16983. m.message_contact = nil
  16984. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  16985. }
  16986. // ContactIDCleared returns if the "contact_id" field was cleared in this mutation.
  16987. func (m *MessageRecordsMutation) ContactIDCleared() bool {
  16988. _, ok := m.clearedFields[messagerecords.FieldContactID]
  16989. return ok
  16990. }
  16991. // ResetContactID resets all changes to the "contact_id" field.
  16992. func (m *MessageRecordsMutation) ResetContactID() {
  16993. m.message_contact = nil
  16994. delete(m.clearedFields, messagerecords.FieldContactID)
  16995. }
  16996. // SetContactType sets the "contact_type" field.
  16997. func (m *MessageRecordsMutation) SetContactType(i int) {
  16998. m.contact_type = &i
  16999. m.addcontact_type = nil
  17000. }
  17001. // ContactType returns the value of the "contact_type" field in the mutation.
  17002. func (m *MessageRecordsMutation) ContactType() (r int, exists bool) {
  17003. v := m.contact_type
  17004. if v == nil {
  17005. return
  17006. }
  17007. return *v, true
  17008. }
  17009. // OldContactType returns the old "contact_type" field's value of the MessageRecords entity.
  17010. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17011. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17012. func (m *MessageRecordsMutation) OldContactType(ctx context.Context) (v int, err error) {
  17013. if !m.op.Is(OpUpdateOne) {
  17014. return v, errors.New("OldContactType is only allowed on UpdateOne operations")
  17015. }
  17016. if m.id == nil || m.oldValue == nil {
  17017. return v, errors.New("OldContactType requires an ID field in the mutation")
  17018. }
  17019. oldValue, err := m.oldValue(ctx)
  17020. if err != nil {
  17021. return v, fmt.Errorf("querying old value for OldContactType: %w", err)
  17022. }
  17023. return oldValue.ContactType, nil
  17024. }
  17025. // AddContactType adds i to the "contact_type" field.
  17026. func (m *MessageRecordsMutation) AddContactType(i int) {
  17027. if m.addcontact_type != nil {
  17028. *m.addcontact_type += i
  17029. } else {
  17030. m.addcontact_type = &i
  17031. }
  17032. }
  17033. // AddedContactType returns the value that was added to the "contact_type" field in this mutation.
  17034. func (m *MessageRecordsMutation) AddedContactType() (r int, exists bool) {
  17035. v := m.addcontact_type
  17036. if v == nil {
  17037. return
  17038. }
  17039. return *v, true
  17040. }
  17041. // ResetContactType resets all changes to the "contact_type" field.
  17042. func (m *MessageRecordsMutation) ResetContactType() {
  17043. m.contact_type = nil
  17044. m.addcontact_type = nil
  17045. }
  17046. // SetContactWxid sets the "contact_wxid" field.
  17047. func (m *MessageRecordsMutation) SetContactWxid(s string) {
  17048. m.contact_wxid = &s
  17049. }
  17050. // ContactWxid returns the value of the "contact_wxid" field in the mutation.
  17051. func (m *MessageRecordsMutation) ContactWxid() (r string, exists bool) {
  17052. v := m.contact_wxid
  17053. if v == nil {
  17054. return
  17055. }
  17056. return *v, true
  17057. }
  17058. // OldContactWxid returns the old "contact_wxid" field's value of the MessageRecords entity.
  17059. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17060. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17061. func (m *MessageRecordsMutation) OldContactWxid(ctx context.Context) (v string, err error) {
  17062. if !m.op.Is(OpUpdateOne) {
  17063. return v, errors.New("OldContactWxid is only allowed on UpdateOne operations")
  17064. }
  17065. if m.id == nil || m.oldValue == nil {
  17066. return v, errors.New("OldContactWxid requires an ID field in the mutation")
  17067. }
  17068. oldValue, err := m.oldValue(ctx)
  17069. if err != nil {
  17070. return v, fmt.Errorf("querying old value for OldContactWxid: %w", err)
  17071. }
  17072. return oldValue.ContactWxid, nil
  17073. }
  17074. // ResetContactWxid resets all changes to the "contact_wxid" field.
  17075. func (m *MessageRecordsMutation) ResetContactWxid() {
  17076. m.contact_wxid = nil
  17077. }
  17078. // SetContentType sets the "content_type" field.
  17079. func (m *MessageRecordsMutation) SetContentType(i int) {
  17080. m.content_type = &i
  17081. m.addcontent_type = nil
  17082. }
  17083. // ContentType returns the value of the "content_type" field in the mutation.
  17084. func (m *MessageRecordsMutation) ContentType() (r int, exists bool) {
  17085. v := m.content_type
  17086. if v == nil {
  17087. return
  17088. }
  17089. return *v, true
  17090. }
  17091. // OldContentType returns the old "content_type" field's value of the MessageRecords entity.
  17092. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17093. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17094. func (m *MessageRecordsMutation) OldContentType(ctx context.Context) (v int, err error) {
  17095. if !m.op.Is(OpUpdateOne) {
  17096. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  17097. }
  17098. if m.id == nil || m.oldValue == nil {
  17099. return v, errors.New("OldContentType requires an ID field in the mutation")
  17100. }
  17101. oldValue, err := m.oldValue(ctx)
  17102. if err != nil {
  17103. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  17104. }
  17105. return oldValue.ContentType, nil
  17106. }
  17107. // AddContentType adds i to the "content_type" field.
  17108. func (m *MessageRecordsMutation) AddContentType(i int) {
  17109. if m.addcontent_type != nil {
  17110. *m.addcontent_type += i
  17111. } else {
  17112. m.addcontent_type = &i
  17113. }
  17114. }
  17115. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  17116. func (m *MessageRecordsMutation) AddedContentType() (r int, exists bool) {
  17117. v := m.addcontent_type
  17118. if v == nil {
  17119. return
  17120. }
  17121. return *v, true
  17122. }
  17123. // ResetContentType resets all changes to the "content_type" field.
  17124. func (m *MessageRecordsMutation) ResetContentType() {
  17125. m.content_type = nil
  17126. m.addcontent_type = nil
  17127. }
  17128. // SetContent sets the "content" field.
  17129. func (m *MessageRecordsMutation) SetContent(s string) {
  17130. m.content = &s
  17131. }
  17132. // Content returns the value of the "content" field in the mutation.
  17133. func (m *MessageRecordsMutation) Content() (r string, exists bool) {
  17134. v := m.content
  17135. if v == nil {
  17136. return
  17137. }
  17138. return *v, true
  17139. }
  17140. // OldContent returns the old "content" field's value of the MessageRecords entity.
  17141. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17142. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17143. func (m *MessageRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  17144. if !m.op.Is(OpUpdateOne) {
  17145. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  17146. }
  17147. if m.id == nil || m.oldValue == nil {
  17148. return v, errors.New("OldContent requires an ID field in the mutation")
  17149. }
  17150. oldValue, err := m.oldValue(ctx)
  17151. if err != nil {
  17152. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  17153. }
  17154. return oldValue.Content, nil
  17155. }
  17156. // ResetContent resets all changes to the "content" field.
  17157. func (m *MessageRecordsMutation) ResetContent() {
  17158. m.content = nil
  17159. }
  17160. // SetMeta sets the "meta" field.
  17161. func (m *MessageRecordsMutation) SetMeta(ct custom_types.Meta) {
  17162. m.meta = &ct
  17163. }
  17164. // Meta returns the value of the "meta" field in the mutation.
  17165. func (m *MessageRecordsMutation) Meta() (r custom_types.Meta, exists bool) {
  17166. v := m.meta
  17167. if v == nil {
  17168. return
  17169. }
  17170. return *v, true
  17171. }
  17172. // OldMeta returns the old "meta" field's value of the MessageRecords entity.
  17173. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17174. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17175. func (m *MessageRecordsMutation) OldMeta(ctx context.Context) (v custom_types.Meta, err error) {
  17176. if !m.op.Is(OpUpdateOne) {
  17177. return v, errors.New("OldMeta is only allowed on UpdateOne operations")
  17178. }
  17179. if m.id == nil || m.oldValue == nil {
  17180. return v, errors.New("OldMeta requires an ID field in the mutation")
  17181. }
  17182. oldValue, err := m.oldValue(ctx)
  17183. if err != nil {
  17184. return v, fmt.Errorf("querying old value for OldMeta: %w", err)
  17185. }
  17186. return oldValue.Meta, nil
  17187. }
  17188. // ClearMeta clears the value of the "meta" field.
  17189. func (m *MessageRecordsMutation) ClearMeta() {
  17190. m.meta = nil
  17191. m.clearedFields[messagerecords.FieldMeta] = struct{}{}
  17192. }
  17193. // MetaCleared returns if the "meta" field was cleared in this mutation.
  17194. func (m *MessageRecordsMutation) MetaCleared() bool {
  17195. _, ok := m.clearedFields[messagerecords.FieldMeta]
  17196. return ok
  17197. }
  17198. // ResetMeta resets all changes to the "meta" field.
  17199. func (m *MessageRecordsMutation) ResetMeta() {
  17200. m.meta = nil
  17201. delete(m.clearedFields, messagerecords.FieldMeta)
  17202. }
  17203. // SetErrorDetail sets the "error_detail" field.
  17204. func (m *MessageRecordsMutation) SetErrorDetail(s string) {
  17205. m.error_detail = &s
  17206. }
  17207. // ErrorDetail returns the value of the "error_detail" field in the mutation.
  17208. func (m *MessageRecordsMutation) ErrorDetail() (r string, exists bool) {
  17209. v := m.error_detail
  17210. if v == nil {
  17211. return
  17212. }
  17213. return *v, true
  17214. }
  17215. // OldErrorDetail returns the old "error_detail" field's value of the MessageRecords entity.
  17216. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17217. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17218. func (m *MessageRecordsMutation) OldErrorDetail(ctx context.Context) (v string, err error) {
  17219. if !m.op.Is(OpUpdateOne) {
  17220. return v, errors.New("OldErrorDetail is only allowed on UpdateOne operations")
  17221. }
  17222. if m.id == nil || m.oldValue == nil {
  17223. return v, errors.New("OldErrorDetail requires an ID field in the mutation")
  17224. }
  17225. oldValue, err := m.oldValue(ctx)
  17226. if err != nil {
  17227. return v, fmt.Errorf("querying old value for OldErrorDetail: %w", err)
  17228. }
  17229. return oldValue.ErrorDetail, nil
  17230. }
  17231. // ResetErrorDetail resets all changes to the "error_detail" field.
  17232. func (m *MessageRecordsMutation) ResetErrorDetail() {
  17233. m.error_detail = nil
  17234. }
  17235. // SetSendTime sets the "send_time" field.
  17236. func (m *MessageRecordsMutation) SetSendTime(t time.Time) {
  17237. m.send_time = &t
  17238. }
  17239. // SendTime returns the value of the "send_time" field in the mutation.
  17240. func (m *MessageRecordsMutation) SendTime() (r time.Time, exists bool) {
  17241. v := m.send_time
  17242. if v == nil {
  17243. return
  17244. }
  17245. return *v, true
  17246. }
  17247. // OldSendTime returns the old "send_time" field's value of the MessageRecords entity.
  17248. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17249. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17250. func (m *MessageRecordsMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  17251. if !m.op.Is(OpUpdateOne) {
  17252. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  17253. }
  17254. if m.id == nil || m.oldValue == nil {
  17255. return v, errors.New("OldSendTime requires an ID field in the mutation")
  17256. }
  17257. oldValue, err := m.oldValue(ctx)
  17258. if err != nil {
  17259. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  17260. }
  17261. return oldValue.SendTime, nil
  17262. }
  17263. // ClearSendTime clears the value of the "send_time" field.
  17264. func (m *MessageRecordsMutation) ClearSendTime() {
  17265. m.send_time = nil
  17266. m.clearedFields[messagerecords.FieldSendTime] = struct{}{}
  17267. }
  17268. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  17269. func (m *MessageRecordsMutation) SendTimeCleared() bool {
  17270. _, ok := m.clearedFields[messagerecords.FieldSendTime]
  17271. return ok
  17272. }
  17273. // ResetSendTime resets all changes to the "send_time" field.
  17274. func (m *MessageRecordsMutation) ResetSendTime() {
  17275. m.send_time = nil
  17276. delete(m.clearedFields, messagerecords.FieldSendTime)
  17277. }
  17278. // SetSourceType sets the "source_type" field.
  17279. func (m *MessageRecordsMutation) SetSourceType(i int) {
  17280. m.source_type = &i
  17281. m.addsource_type = nil
  17282. }
  17283. // SourceType returns the value of the "source_type" field in the mutation.
  17284. func (m *MessageRecordsMutation) SourceType() (r int, exists bool) {
  17285. v := m.source_type
  17286. if v == nil {
  17287. return
  17288. }
  17289. return *v, true
  17290. }
  17291. // OldSourceType returns the old "source_type" field's value of the MessageRecords entity.
  17292. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17293. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17294. func (m *MessageRecordsMutation) OldSourceType(ctx context.Context) (v int, err error) {
  17295. if !m.op.Is(OpUpdateOne) {
  17296. return v, errors.New("OldSourceType is only allowed on UpdateOne operations")
  17297. }
  17298. if m.id == nil || m.oldValue == nil {
  17299. return v, errors.New("OldSourceType requires an ID field in the mutation")
  17300. }
  17301. oldValue, err := m.oldValue(ctx)
  17302. if err != nil {
  17303. return v, fmt.Errorf("querying old value for OldSourceType: %w", err)
  17304. }
  17305. return oldValue.SourceType, nil
  17306. }
  17307. // AddSourceType adds i to the "source_type" field.
  17308. func (m *MessageRecordsMutation) AddSourceType(i int) {
  17309. if m.addsource_type != nil {
  17310. *m.addsource_type += i
  17311. } else {
  17312. m.addsource_type = &i
  17313. }
  17314. }
  17315. // AddedSourceType returns the value that was added to the "source_type" field in this mutation.
  17316. func (m *MessageRecordsMutation) AddedSourceType() (r int, exists bool) {
  17317. v := m.addsource_type
  17318. if v == nil {
  17319. return
  17320. }
  17321. return *v, true
  17322. }
  17323. // ResetSourceType resets all changes to the "source_type" field.
  17324. func (m *MessageRecordsMutation) ResetSourceType() {
  17325. m.source_type = nil
  17326. m.addsource_type = nil
  17327. }
  17328. // SetSourceID sets the "source_id" field.
  17329. func (m *MessageRecordsMutation) SetSourceID(u uint64) {
  17330. m.sop_stage = &u
  17331. }
  17332. // SourceID returns the value of the "source_id" field in the mutation.
  17333. func (m *MessageRecordsMutation) SourceID() (r uint64, exists bool) {
  17334. v := m.sop_stage
  17335. if v == nil {
  17336. return
  17337. }
  17338. return *v, true
  17339. }
  17340. // OldSourceID returns the old "source_id" field's value of the MessageRecords entity.
  17341. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17342. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17343. func (m *MessageRecordsMutation) OldSourceID(ctx context.Context) (v uint64, err error) {
  17344. if !m.op.Is(OpUpdateOne) {
  17345. return v, errors.New("OldSourceID is only allowed on UpdateOne operations")
  17346. }
  17347. if m.id == nil || m.oldValue == nil {
  17348. return v, errors.New("OldSourceID requires an ID field in the mutation")
  17349. }
  17350. oldValue, err := m.oldValue(ctx)
  17351. if err != nil {
  17352. return v, fmt.Errorf("querying old value for OldSourceID: %w", err)
  17353. }
  17354. return oldValue.SourceID, nil
  17355. }
  17356. // ClearSourceID clears the value of the "source_id" field.
  17357. func (m *MessageRecordsMutation) ClearSourceID() {
  17358. m.sop_stage = nil
  17359. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  17360. }
  17361. // SourceIDCleared returns if the "source_id" field was cleared in this mutation.
  17362. func (m *MessageRecordsMutation) SourceIDCleared() bool {
  17363. _, ok := m.clearedFields[messagerecords.FieldSourceID]
  17364. return ok
  17365. }
  17366. // ResetSourceID resets all changes to the "source_id" field.
  17367. func (m *MessageRecordsMutation) ResetSourceID() {
  17368. m.sop_stage = nil
  17369. delete(m.clearedFields, messagerecords.FieldSourceID)
  17370. }
  17371. // SetSubSourceID sets the "sub_source_id" field.
  17372. func (m *MessageRecordsMutation) SetSubSourceID(u uint64) {
  17373. m.sop_node = &u
  17374. }
  17375. // SubSourceID returns the value of the "sub_source_id" field in the mutation.
  17376. func (m *MessageRecordsMutation) SubSourceID() (r uint64, exists bool) {
  17377. v := m.sop_node
  17378. if v == nil {
  17379. return
  17380. }
  17381. return *v, true
  17382. }
  17383. // OldSubSourceID returns the old "sub_source_id" field's value of the MessageRecords entity.
  17384. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17385. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17386. func (m *MessageRecordsMutation) OldSubSourceID(ctx context.Context) (v uint64, err error) {
  17387. if !m.op.Is(OpUpdateOne) {
  17388. return v, errors.New("OldSubSourceID is only allowed on UpdateOne operations")
  17389. }
  17390. if m.id == nil || m.oldValue == nil {
  17391. return v, errors.New("OldSubSourceID requires an ID field in the mutation")
  17392. }
  17393. oldValue, err := m.oldValue(ctx)
  17394. if err != nil {
  17395. return v, fmt.Errorf("querying old value for OldSubSourceID: %w", err)
  17396. }
  17397. return oldValue.SubSourceID, nil
  17398. }
  17399. // ClearSubSourceID clears the value of the "sub_source_id" field.
  17400. func (m *MessageRecordsMutation) ClearSubSourceID() {
  17401. m.sop_node = nil
  17402. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  17403. }
  17404. // SubSourceIDCleared returns if the "sub_source_id" field was cleared in this mutation.
  17405. func (m *MessageRecordsMutation) SubSourceIDCleared() bool {
  17406. _, ok := m.clearedFields[messagerecords.FieldSubSourceID]
  17407. return ok
  17408. }
  17409. // ResetSubSourceID resets all changes to the "sub_source_id" field.
  17410. func (m *MessageRecordsMutation) ResetSubSourceID() {
  17411. m.sop_node = nil
  17412. delete(m.clearedFields, messagerecords.FieldSubSourceID)
  17413. }
  17414. // SetOrganizationID sets the "organization_id" field.
  17415. func (m *MessageRecordsMutation) SetOrganizationID(u uint64) {
  17416. m.organization_id = &u
  17417. m.addorganization_id = nil
  17418. }
  17419. // OrganizationID returns the value of the "organization_id" field in the mutation.
  17420. func (m *MessageRecordsMutation) OrganizationID() (r uint64, exists bool) {
  17421. v := m.organization_id
  17422. if v == nil {
  17423. return
  17424. }
  17425. return *v, true
  17426. }
  17427. // OldOrganizationID returns the old "organization_id" field's value of the MessageRecords entity.
  17428. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17429. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17430. func (m *MessageRecordsMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  17431. if !m.op.Is(OpUpdateOne) {
  17432. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  17433. }
  17434. if m.id == nil || m.oldValue == nil {
  17435. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  17436. }
  17437. oldValue, err := m.oldValue(ctx)
  17438. if err != nil {
  17439. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  17440. }
  17441. return oldValue.OrganizationID, nil
  17442. }
  17443. // AddOrganizationID adds u to the "organization_id" field.
  17444. func (m *MessageRecordsMutation) AddOrganizationID(u int64) {
  17445. if m.addorganization_id != nil {
  17446. *m.addorganization_id += u
  17447. } else {
  17448. m.addorganization_id = &u
  17449. }
  17450. }
  17451. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  17452. func (m *MessageRecordsMutation) AddedOrganizationID() (r int64, exists bool) {
  17453. v := m.addorganization_id
  17454. if v == nil {
  17455. return
  17456. }
  17457. return *v, true
  17458. }
  17459. // ClearOrganizationID clears the value of the "organization_id" field.
  17460. func (m *MessageRecordsMutation) ClearOrganizationID() {
  17461. m.organization_id = nil
  17462. m.addorganization_id = nil
  17463. m.clearedFields[messagerecords.FieldOrganizationID] = struct{}{}
  17464. }
  17465. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  17466. func (m *MessageRecordsMutation) OrganizationIDCleared() bool {
  17467. _, ok := m.clearedFields[messagerecords.FieldOrganizationID]
  17468. return ok
  17469. }
  17470. // ResetOrganizationID resets all changes to the "organization_id" field.
  17471. func (m *MessageRecordsMutation) ResetOrganizationID() {
  17472. m.organization_id = nil
  17473. m.addorganization_id = nil
  17474. delete(m.clearedFields, messagerecords.FieldOrganizationID)
  17475. }
  17476. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  17477. func (m *MessageRecordsMutation) SetSopStageID(id uint64) {
  17478. m.sop_stage = &id
  17479. }
  17480. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  17481. func (m *MessageRecordsMutation) ClearSopStage() {
  17482. m.clearedsop_stage = true
  17483. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  17484. }
  17485. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  17486. func (m *MessageRecordsMutation) SopStageCleared() bool {
  17487. return m.SourceIDCleared() || m.clearedsop_stage
  17488. }
  17489. // SopStageID returns the "sop_stage" edge ID in the mutation.
  17490. func (m *MessageRecordsMutation) SopStageID() (id uint64, exists bool) {
  17491. if m.sop_stage != nil {
  17492. return *m.sop_stage, true
  17493. }
  17494. return
  17495. }
  17496. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  17497. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  17498. // SopStageID instead. It exists only for internal usage by the builders.
  17499. func (m *MessageRecordsMutation) SopStageIDs() (ids []uint64) {
  17500. if id := m.sop_stage; id != nil {
  17501. ids = append(ids, *id)
  17502. }
  17503. return
  17504. }
  17505. // ResetSopStage resets all changes to the "sop_stage" edge.
  17506. func (m *MessageRecordsMutation) ResetSopStage() {
  17507. m.sop_stage = nil
  17508. m.clearedsop_stage = false
  17509. }
  17510. // SetSopNodeID sets the "sop_node" edge to the SopNode entity by id.
  17511. func (m *MessageRecordsMutation) SetSopNodeID(id uint64) {
  17512. m.sop_node = &id
  17513. }
  17514. // ClearSopNode clears the "sop_node" edge to the SopNode entity.
  17515. func (m *MessageRecordsMutation) ClearSopNode() {
  17516. m.clearedsop_node = true
  17517. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  17518. }
  17519. // SopNodeCleared reports if the "sop_node" edge to the SopNode entity was cleared.
  17520. func (m *MessageRecordsMutation) SopNodeCleared() bool {
  17521. return m.SubSourceIDCleared() || m.clearedsop_node
  17522. }
  17523. // SopNodeID returns the "sop_node" edge ID in the mutation.
  17524. func (m *MessageRecordsMutation) SopNodeID() (id uint64, exists bool) {
  17525. if m.sop_node != nil {
  17526. return *m.sop_node, true
  17527. }
  17528. return
  17529. }
  17530. // SopNodeIDs returns the "sop_node" edge IDs in the mutation.
  17531. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  17532. // SopNodeID instead. It exists only for internal usage by the builders.
  17533. func (m *MessageRecordsMutation) SopNodeIDs() (ids []uint64) {
  17534. if id := m.sop_node; id != nil {
  17535. ids = append(ids, *id)
  17536. }
  17537. return
  17538. }
  17539. // ResetSopNode resets all changes to the "sop_node" edge.
  17540. func (m *MessageRecordsMutation) ResetSopNode() {
  17541. m.sop_node = nil
  17542. m.clearedsop_node = false
  17543. }
  17544. // SetMessageContactID sets the "message_contact" edge to the Contact entity by id.
  17545. func (m *MessageRecordsMutation) SetMessageContactID(id uint64) {
  17546. m.message_contact = &id
  17547. }
  17548. // ClearMessageContact clears the "message_contact" edge to the Contact entity.
  17549. func (m *MessageRecordsMutation) ClearMessageContact() {
  17550. m.clearedmessage_contact = true
  17551. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  17552. }
  17553. // MessageContactCleared reports if the "message_contact" edge to the Contact entity was cleared.
  17554. func (m *MessageRecordsMutation) MessageContactCleared() bool {
  17555. return m.ContactIDCleared() || m.clearedmessage_contact
  17556. }
  17557. // MessageContactID returns the "message_contact" edge ID in the mutation.
  17558. func (m *MessageRecordsMutation) MessageContactID() (id uint64, exists bool) {
  17559. if m.message_contact != nil {
  17560. return *m.message_contact, true
  17561. }
  17562. return
  17563. }
  17564. // MessageContactIDs returns the "message_contact" edge IDs in the mutation.
  17565. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  17566. // MessageContactID instead. It exists only for internal usage by the builders.
  17567. func (m *MessageRecordsMutation) MessageContactIDs() (ids []uint64) {
  17568. if id := m.message_contact; id != nil {
  17569. ids = append(ids, *id)
  17570. }
  17571. return
  17572. }
  17573. // ResetMessageContact resets all changes to the "message_contact" edge.
  17574. func (m *MessageRecordsMutation) ResetMessageContact() {
  17575. m.message_contact = nil
  17576. m.clearedmessage_contact = false
  17577. }
  17578. // Where appends a list predicates to the MessageRecordsMutation builder.
  17579. func (m *MessageRecordsMutation) Where(ps ...predicate.MessageRecords) {
  17580. m.predicates = append(m.predicates, ps...)
  17581. }
  17582. // WhereP appends storage-level predicates to the MessageRecordsMutation builder. Using this method,
  17583. // users can use type-assertion to append predicates that do not depend on any generated package.
  17584. func (m *MessageRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  17585. p := make([]predicate.MessageRecords, len(ps))
  17586. for i := range ps {
  17587. p[i] = ps[i]
  17588. }
  17589. m.Where(p...)
  17590. }
  17591. // Op returns the operation name.
  17592. func (m *MessageRecordsMutation) Op() Op {
  17593. return m.op
  17594. }
  17595. // SetOp allows setting the mutation operation.
  17596. func (m *MessageRecordsMutation) SetOp(op Op) {
  17597. m.op = op
  17598. }
  17599. // Type returns the node type of this mutation (MessageRecords).
  17600. func (m *MessageRecordsMutation) Type() string {
  17601. return m.typ
  17602. }
  17603. // Fields returns all fields that were changed during this mutation. Note that in
  17604. // order to get all numeric fields that were incremented/decremented, call
  17605. // AddedFields().
  17606. func (m *MessageRecordsMutation) Fields() []string {
  17607. fields := make([]string, 0, 16)
  17608. if m.created_at != nil {
  17609. fields = append(fields, messagerecords.FieldCreatedAt)
  17610. }
  17611. if m.updated_at != nil {
  17612. fields = append(fields, messagerecords.FieldUpdatedAt)
  17613. }
  17614. if m.status != nil {
  17615. fields = append(fields, messagerecords.FieldStatus)
  17616. }
  17617. if m.bot_wxid != nil {
  17618. fields = append(fields, messagerecords.FieldBotWxid)
  17619. }
  17620. if m.message_contact != nil {
  17621. fields = append(fields, messagerecords.FieldContactID)
  17622. }
  17623. if m.contact_type != nil {
  17624. fields = append(fields, messagerecords.FieldContactType)
  17625. }
  17626. if m.contact_wxid != nil {
  17627. fields = append(fields, messagerecords.FieldContactWxid)
  17628. }
  17629. if m.content_type != nil {
  17630. fields = append(fields, messagerecords.FieldContentType)
  17631. }
  17632. if m.content != nil {
  17633. fields = append(fields, messagerecords.FieldContent)
  17634. }
  17635. if m.meta != nil {
  17636. fields = append(fields, messagerecords.FieldMeta)
  17637. }
  17638. if m.error_detail != nil {
  17639. fields = append(fields, messagerecords.FieldErrorDetail)
  17640. }
  17641. if m.send_time != nil {
  17642. fields = append(fields, messagerecords.FieldSendTime)
  17643. }
  17644. if m.source_type != nil {
  17645. fields = append(fields, messagerecords.FieldSourceType)
  17646. }
  17647. if m.sop_stage != nil {
  17648. fields = append(fields, messagerecords.FieldSourceID)
  17649. }
  17650. if m.sop_node != nil {
  17651. fields = append(fields, messagerecords.FieldSubSourceID)
  17652. }
  17653. if m.organization_id != nil {
  17654. fields = append(fields, messagerecords.FieldOrganizationID)
  17655. }
  17656. return fields
  17657. }
  17658. // Field returns the value of a field with the given name. The second boolean
  17659. // return value indicates that this field was not set, or was not defined in the
  17660. // schema.
  17661. func (m *MessageRecordsMutation) Field(name string) (ent.Value, bool) {
  17662. switch name {
  17663. case messagerecords.FieldCreatedAt:
  17664. return m.CreatedAt()
  17665. case messagerecords.FieldUpdatedAt:
  17666. return m.UpdatedAt()
  17667. case messagerecords.FieldStatus:
  17668. return m.Status()
  17669. case messagerecords.FieldBotWxid:
  17670. return m.BotWxid()
  17671. case messagerecords.FieldContactID:
  17672. return m.ContactID()
  17673. case messagerecords.FieldContactType:
  17674. return m.ContactType()
  17675. case messagerecords.FieldContactWxid:
  17676. return m.ContactWxid()
  17677. case messagerecords.FieldContentType:
  17678. return m.ContentType()
  17679. case messagerecords.FieldContent:
  17680. return m.Content()
  17681. case messagerecords.FieldMeta:
  17682. return m.Meta()
  17683. case messagerecords.FieldErrorDetail:
  17684. return m.ErrorDetail()
  17685. case messagerecords.FieldSendTime:
  17686. return m.SendTime()
  17687. case messagerecords.FieldSourceType:
  17688. return m.SourceType()
  17689. case messagerecords.FieldSourceID:
  17690. return m.SourceID()
  17691. case messagerecords.FieldSubSourceID:
  17692. return m.SubSourceID()
  17693. case messagerecords.FieldOrganizationID:
  17694. return m.OrganizationID()
  17695. }
  17696. return nil, false
  17697. }
  17698. // OldField returns the old value of the field from the database. An error is
  17699. // returned if the mutation operation is not UpdateOne, or the query to the
  17700. // database failed.
  17701. func (m *MessageRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  17702. switch name {
  17703. case messagerecords.FieldCreatedAt:
  17704. return m.OldCreatedAt(ctx)
  17705. case messagerecords.FieldUpdatedAt:
  17706. return m.OldUpdatedAt(ctx)
  17707. case messagerecords.FieldStatus:
  17708. return m.OldStatus(ctx)
  17709. case messagerecords.FieldBotWxid:
  17710. return m.OldBotWxid(ctx)
  17711. case messagerecords.FieldContactID:
  17712. return m.OldContactID(ctx)
  17713. case messagerecords.FieldContactType:
  17714. return m.OldContactType(ctx)
  17715. case messagerecords.FieldContactWxid:
  17716. return m.OldContactWxid(ctx)
  17717. case messagerecords.FieldContentType:
  17718. return m.OldContentType(ctx)
  17719. case messagerecords.FieldContent:
  17720. return m.OldContent(ctx)
  17721. case messagerecords.FieldMeta:
  17722. return m.OldMeta(ctx)
  17723. case messagerecords.FieldErrorDetail:
  17724. return m.OldErrorDetail(ctx)
  17725. case messagerecords.FieldSendTime:
  17726. return m.OldSendTime(ctx)
  17727. case messagerecords.FieldSourceType:
  17728. return m.OldSourceType(ctx)
  17729. case messagerecords.FieldSourceID:
  17730. return m.OldSourceID(ctx)
  17731. case messagerecords.FieldSubSourceID:
  17732. return m.OldSubSourceID(ctx)
  17733. case messagerecords.FieldOrganizationID:
  17734. return m.OldOrganizationID(ctx)
  17735. }
  17736. return nil, fmt.Errorf("unknown MessageRecords field %s", name)
  17737. }
  17738. // SetField sets the value of a field with the given name. It returns an error if
  17739. // the field is not defined in the schema, or if the type mismatched the field
  17740. // type.
  17741. func (m *MessageRecordsMutation) SetField(name string, value ent.Value) error {
  17742. switch name {
  17743. case messagerecords.FieldCreatedAt:
  17744. v, ok := value.(time.Time)
  17745. if !ok {
  17746. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17747. }
  17748. m.SetCreatedAt(v)
  17749. return nil
  17750. case messagerecords.FieldUpdatedAt:
  17751. v, ok := value.(time.Time)
  17752. if !ok {
  17753. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17754. }
  17755. m.SetUpdatedAt(v)
  17756. return nil
  17757. case messagerecords.FieldStatus:
  17758. v, ok := value.(uint8)
  17759. if !ok {
  17760. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17761. }
  17762. m.SetStatus(v)
  17763. return nil
  17764. case messagerecords.FieldBotWxid:
  17765. v, ok := value.(string)
  17766. if !ok {
  17767. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17768. }
  17769. m.SetBotWxid(v)
  17770. return nil
  17771. case messagerecords.FieldContactID:
  17772. v, ok := value.(uint64)
  17773. if !ok {
  17774. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17775. }
  17776. m.SetContactID(v)
  17777. return nil
  17778. case messagerecords.FieldContactType:
  17779. v, ok := value.(int)
  17780. if !ok {
  17781. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17782. }
  17783. m.SetContactType(v)
  17784. return nil
  17785. case messagerecords.FieldContactWxid:
  17786. v, ok := value.(string)
  17787. if !ok {
  17788. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17789. }
  17790. m.SetContactWxid(v)
  17791. return nil
  17792. case messagerecords.FieldContentType:
  17793. v, ok := value.(int)
  17794. if !ok {
  17795. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17796. }
  17797. m.SetContentType(v)
  17798. return nil
  17799. case messagerecords.FieldContent:
  17800. v, ok := value.(string)
  17801. if !ok {
  17802. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17803. }
  17804. m.SetContent(v)
  17805. return nil
  17806. case messagerecords.FieldMeta:
  17807. v, ok := value.(custom_types.Meta)
  17808. if !ok {
  17809. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17810. }
  17811. m.SetMeta(v)
  17812. return nil
  17813. case messagerecords.FieldErrorDetail:
  17814. v, ok := value.(string)
  17815. if !ok {
  17816. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17817. }
  17818. m.SetErrorDetail(v)
  17819. return nil
  17820. case messagerecords.FieldSendTime:
  17821. v, ok := value.(time.Time)
  17822. if !ok {
  17823. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17824. }
  17825. m.SetSendTime(v)
  17826. return nil
  17827. case messagerecords.FieldSourceType:
  17828. v, ok := value.(int)
  17829. if !ok {
  17830. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17831. }
  17832. m.SetSourceType(v)
  17833. return nil
  17834. case messagerecords.FieldSourceID:
  17835. v, ok := value.(uint64)
  17836. if !ok {
  17837. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17838. }
  17839. m.SetSourceID(v)
  17840. return nil
  17841. case messagerecords.FieldSubSourceID:
  17842. v, ok := value.(uint64)
  17843. if !ok {
  17844. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17845. }
  17846. m.SetSubSourceID(v)
  17847. return nil
  17848. case messagerecords.FieldOrganizationID:
  17849. v, ok := value.(uint64)
  17850. if !ok {
  17851. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17852. }
  17853. m.SetOrganizationID(v)
  17854. return nil
  17855. }
  17856. return fmt.Errorf("unknown MessageRecords field %s", name)
  17857. }
  17858. // AddedFields returns all numeric fields that were incremented/decremented during
  17859. // this mutation.
  17860. func (m *MessageRecordsMutation) AddedFields() []string {
  17861. var fields []string
  17862. if m.addstatus != nil {
  17863. fields = append(fields, messagerecords.FieldStatus)
  17864. }
  17865. if m.addcontact_type != nil {
  17866. fields = append(fields, messagerecords.FieldContactType)
  17867. }
  17868. if m.addcontent_type != nil {
  17869. fields = append(fields, messagerecords.FieldContentType)
  17870. }
  17871. if m.addsource_type != nil {
  17872. fields = append(fields, messagerecords.FieldSourceType)
  17873. }
  17874. if m.addorganization_id != nil {
  17875. fields = append(fields, messagerecords.FieldOrganizationID)
  17876. }
  17877. return fields
  17878. }
  17879. // AddedField returns the numeric value that was incremented/decremented on a field
  17880. // with the given name. The second boolean return value indicates that this field
  17881. // was not set, or was not defined in the schema.
  17882. func (m *MessageRecordsMutation) AddedField(name string) (ent.Value, bool) {
  17883. switch name {
  17884. case messagerecords.FieldStatus:
  17885. return m.AddedStatus()
  17886. case messagerecords.FieldContactType:
  17887. return m.AddedContactType()
  17888. case messagerecords.FieldContentType:
  17889. return m.AddedContentType()
  17890. case messagerecords.FieldSourceType:
  17891. return m.AddedSourceType()
  17892. case messagerecords.FieldOrganizationID:
  17893. return m.AddedOrganizationID()
  17894. }
  17895. return nil, false
  17896. }
  17897. // AddField adds the value to the field with the given name. It returns an error if
  17898. // the field is not defined in the schema, or if the type mismatched the field
  17899. // type.
  17900. func (m *MessageRecordsMutation) AddField(name string, value ent.Value) error {
  17901. switch name {
  17902. case messagerecords.FieldStatus:
  17903. v, ok := value.(int8)
  17904. if !ok {
  17905. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17906. }
  17907. m.AddStatus(v)
  17908. return nil
  17909. case messagerecords.FieldContactType:
  17910. v, ok := value.(int)
  17911. if !ok {
  17912. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17913. }
  17914. m.AddContactType(v)
  17915. return nil
  17916. case messagerecords.FieldContentType:
  17917. v, ok := value.(int)
  17918. if !ok {
  17919. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17920. }
  17921. m.AddContentType(v)
  17922. return nil
  17923. case messagerecords.FieldSourceType:
  17924. v, ok := value.(int)
  17925. if !ok {
  17926. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17927. }
  17928. m.AddSourceType(v)
  17929. return nil
  17930. case messagerecords.FieldOrganizationID:
  17931. v, ok := value.(int64)
  17932. if !ok {
  17933. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17934. }
  17935. m.AddOrganizationID(v)
  17936. return nil
  17937. }
  17938. return fmt.Errorf("unknown MessageRecords numeric field %s", name)
  17939. }
  17940. // ClearedFields returns all nullable fields that were cleared during this
  17941. // mutation.
  17942. func (m *MessageRecordsMutation) ClearedFields() []string {
  17943. var fields []string
  17944. if m.FieldCleared(messagerecords.FieldStatus) {
  17945. fields = append(fields, messagerecords.FieldStatus)
  17946. }
  17947. if m.FieldCleared(messagerecords.FieldContactID) {
  17948. fields = append(fields, messagerecords.FieldContactID)
  17949. }
  17950. if m.FieldCleared(messagerecords.FieldMeta) {
  17951. fields = append(fields, messagerecords.FieldMeta)
  17952. }
  17953. if m.FieldCleared(messagerecords.FieldSendTime) {
  17954. fields = append(fields, messagerecords.FieldSendTime)
  17955. }
  17956. if m.FieldCleared(messagerecords.FieldSourceID) {
  17957. fields = append(fields, messagerecords.FieldSourceID)
  17958. }
  17959. if m.FieldCleared(messagerecords.FieldSubSourceID) {
  17960. fields = append(fields, messagerecords.FieldSubSourceID)
  17961. }
  17962. if m.FieldCleared(messagerecords.FieldOrganizationID) {
  17963. fields = append(fields, messagerecords.FieldOrganizationID)
  17964. }
  17965. return fields
  17966. }
  17967. // FieldCleared returns a boolean indicating if a field with the given name was
  17968. // cleared in this mutation.
  17969. func (m *MessageRecordsMutation) FieldCleared(name string) bool {
  17970. _, ok := m.clearedFields[name]
  17971. return ok
  17972. }
  17973. // ClearField clears the value of the field with the given name. It returns an
  17974. // error if the field is not defined in the schema.
  17975. func (m *MessageRecordsMutation) ClearField(name string) error {
  17976. switch name {
  17977. case messagerecords.FieldStatus:
  17978. m.ClearStatus()
  17979. return nil
  17980. case messagerecords.FieldContactID:
  17981. m.ClearContactID()
  17982. return nil
  17983. case messagerecords.FieldMeta:
  17984. m.ClearMeta()
  17985. return nil
  17986. case messagerecords.FieldSendTime:
  17987. m.ClearSendTime()
  17988. return nil
  17989. case messagerecords.FieldSourceID:
  17990. m.ClearSourceID()
  17991. return nil
  17992. case messagerecords.FieldSubSourceID:
  17993. m.ClearSubSourceID()
  17994. return nil
  17995. case messagerecords.FieldOrganizationID:
  17996. m.ClearOrganizationID()
  17997. return nil
  17998. }
  17999. return fmt.Errorf("unknown MessageRecords nullable field %s", name)
  18000. }
  18001. // ResetField resets all changes in the mutation for the field with the given name.
  18002. // It returns an error if the field is not defined in the schema.
  18003. func (m *MessageRecordsMutation) ResetField(name string) error {
  18004. switch name {
  18005. case messagerecords.FieldCreatedAt:
  18006. m.ResetCreatedAt()
  18007. return nil
  18008. case messagerecords.FieldUpdatedAt:
  18009. m.ResetUpdatedAt()
  18010. return nil
  18011. case messagerecords.FieldStatus:
  18012. m.ResetStatus()
  18013. return nil
  18014. case messagerecords.FieldBotWxid:
  18015. m.ResetBotWxid()
  18016. return nil
  18017. case messagerecords.FieldContactID:
  18018. m.ResetContactID()
  18019. return nil
  18020. case messagerecords.FieldContactType:
  18021. m.ResetContactType()
  18022. return nil
  18023. case messagerecords.FieldContactWxid:
  18024. m.ResetContactWxid()
  18025. return nil
  18026. case messagerecords.FieldContentType:
  18027. m.ResetContentType()
  18028. return nil
  18029. case messagerecords.FieldContent:
  18030. m.ResetContent()
  18031. return nil
  18032. case messagerecords.FieldMeta:
  18033. m.ResetMeta()
  18034. return nil
  18035. case messagerecords.FieldErrorDetail:
  18036. m.ResetErrorDetail()
  18037. return nil
  18038. case messagerecords.FieldSendTime:
  18039. m.ResetSendTime()
  18040. return nil
  18041. case messagerecords.FieldSourceType:
  18042. m.ResetSourceType()
  18043. return nil
  18044. case messagerecords.FieldSourceID:
  18045. m.ResetSourceID()
  18046. return nil
  18047. case messagerecords.FieldSubSourceID:
  18048. m.ResetSubSourceID()
  18049. return nil
  18050. case messagerecords.FieldOrganizationID:
  18051. m.ResetOrganizationID()
  18052. return nil
  18053. }
  18054. return fmt.Errorf("unknown MessageRecords field %s", name)
  18055. }
  18056. // AddedEdges returns all edge names that were set/added in this mutation.
  18057. func (m *MessageRecordsMutation) AddedEdges() []string {
  18058. edges := make([]string, 0, 3)
  18059. if m.sop_stage != nil {
  18060. edges = append(edges, messagerecords.EdgeSopStage)
  18061. }
  18062. if m.sop_node != nil {
  18063. edges = append(edges, messagerecords.EdgeSopNode)
  18064. }
  18065. if m.message_contact != nil {
  18066. edges = append(edges, messagerecords.EdgeMessageContact)
  18067. }
  18068. return edges
  18069. }
  18070. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  18071. // name in this mutation.
  18072. func (m *MessageRecordsMutation) AddedIDs(name string) []ent.Value {
  18073. switch name {
  18074. case messagerecords.EdgeSopStage:
  18075. if id := m.sop_stage; id != nil {
  18076. return []ent.Value{*id}
  18077. }
  18078. case messagerecords.EdgeSopNode:
  18079. if id := m.sop_node; id != nil {
  18080. return []ent.Value{*id}
  18081. }
  18082. case messagerecords.EdgeMessageContact:
  18083. if id := m.message_contact; id != nil {
  18084. return []ent.Value{*id}
  18085. }
  18086. }
  18087. return nil
  18088. }
  18089. // RemovedEdges returns all edge names that were removed in this mutation.
  18090. func (m *MessageRecordsMutation) RemovedEdges() []string {
  18091. edges := make([]string, 0, 3)
  18092. return edges
  18093. }
  18094. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  18095. // the given name in this mutation.
  18096. func (m *MessageRecordsMutation) RemovedIDs(name string) []ent.Value {
  18097. return nil
  18098. }
  18099. // ClearedEdges returns all edge names that were cleared in this mutation.
  18100. func (m *MessageRecordsMutation) ClearedEdges() []string {
  18101. edges := make([]string, 0, 3)
  18102. if m.clearedsop_stage {
  18103. edges = append(edges, messagerecords.EdgeSopStage)
  18104. }
  18105. if m.clearedsop_node {
  18106. edges = append(edges, messagerecords.EdgeSopNode)
  18107. }
  18108. if m.clearedmessage_contact {
  18109. edges = append(edges, messagerecords.EdgeMessageContact)
  18110. }
  18111. return edges
  18112. }
  18113. // EdgeCleared returns a boolean which indicates if the edge with the given name
  18114. // was cleared in this mutation.
  18115. func (m *MessageRecordsMutation) EdgeCleared(name string) bool {
  18116. switch name {
  18117. case messagerecords.EdgeSopStage:
  18118. return m.clearedsop_stage
  18119. case messagerecords.EdgeSopNode:
  18120. return m.clearedsop_node
  18121. case messagerecords.EdgeMessageContact:
  18122. return m.clearedmessage_contact
  18123. }
  18124. return false
  18125. }
  18126. // ClearEdge clears the value of the edge with the given name. It returns an error
  18127. // if that edge is not defined in the schema.
  18128. func (m *MessageRecordsMutation) ClearEdge(name string) error {
  18129. switch name {
  18130. case messagerecords.EdgeSopStage:
  18131. m.ClearSopStage()
  18132. return nil
  18133. case messagerecords.EdgeSopNode:
  18134. m.ClearSopNode()
  18135. return nil
  18136. case messagerecords.EdgeMessageContact:
  18137. m.ClearMessageContact()
  18138. return nil
  18139. }
  18140. return fmt.Errorf("unknown MessageRecords unique edge %s", name)
  18141. }
  18142. // ResetEdge resets all changes to the edge with the given name in this mutation.
  18143. // It returns an error if the edge is not defined in the schema.
  18144. func (m *MessageRecordsMutation) ResetEdge(name string) error {
  18145. switch name {
  18146. case messagerecords.EdgeSopStage:
  18147. m.ResetSopStage()
  18148. return nil
  18149. case messagerecords.EdgeSopNode:
  18150. m.ResetSopNode()
  18151. return nil
  18152. case messagerecords.EdgeMessageContact:
  18153. m.ResetMessageContact()
  18154. return nil
  18155. }
  18156. return fmt.Errorf("unknown MessageRecords edge %s", name)
  18157. }
  18158. // MsgMutation represents an operation that mutates the Msg nodes in the graph.
  18159. type MsgMutation struct {
  18160. config
  18161. op Op
  18162. typ string
  18163. id *uint64
  18164. created_at *time.Time
  18165. updated_at *time.Time
  18166. deleted_at *time.Time
  18167. status *uint8
  18168. addstatus *int8
  18169. fromwxid *string
  18170. toid *string
  18171. msgtype *int32
  18172. addmsgtype *int32
  18173. msg *string
  18174. batch_no *string
  18175. clearedFields map[string]struct{}
  18176. done bool
  18177. oldValue func(context.Context) (*Msg, error)
  18178. predicates []predicate.Msg
  18179. }
  18180. var _ ent.Mutation = (*MsgMutation)(nil)
  18181. // msgOption allows management of the mutation configuration using functional options.
  18182. type msgOption func(*MsgMutation)
  18183. // newMsgMutation creates new mutation for the Msg entity.
  18184. func newMsgMutation(c config, op Op, opts ...msgOption) *MsgMutation {
  18185. m := &MsgMutation{
  18186. config: c,
  18187. op: op,
  18188. typ: TypeMsg,
  18189. clearedFields: make(map[string]struct{}),
  18190. }
  18191. for _, opt := range opts {
  18192. opt(m)
  18193. }
  18194. return m
  18195. }
  18196. // withMsgID sets the ID field of the mutation.
  18197. func withMsgID(id uint64) msgOption {
  18198. return func(m *MsgMutation) {
  18199. var (
  18200. err error
  18201. once sync.Once
  18202. value *Msg
  18203. )
  18204. m.oldValue = func(ctx context.Context) (*Msg, error) {
  18205. once.Do(func() {
  18206. if m.done {
  18207. err = errors.New("querying old values post mutation is not allowed")
  18208. } else {
  18209. value, err = m.Client().Msg.Get(ctx, id)
  18210. }
  18211. })
  18212. return value, err
  18213. }
  18214. m.id = &id
  18215. }
  18216. }
  18217. // withMsg sets the old Msg of the mutation.
  18218. func withMsg(node *Msg) msgOption {
  18219. return func(m *MsgMutation) {
  18220. m.oldValue = func(context.Context) (*Msg, error) {
  18221. return node, nil
  18222. }
  18223. m.id = &node.ID
  18224. }
  18225. }
  18226. // Client returns a new `ent.Client` from the mutation. If the mutation was
  18227. // executed in a transaction (ent.Tx), a transactional client is returned.
  18228. func (m MsgMutation) Client() *Client {
  18229. client := &Client{config: m.config}
  18230. client.init()
  18231. return client
  18232. }
  18233. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  18234. // it returns an error otherwise.
  18235. func (m MsgMutation) Tx() (*Tx, error) {
  18236. if _, ok := m.driver.(*txDriver); !ok {
  18237. return nil, errors.New("ent: mutation is not running in a transaction")
  18238. }
  18239. tx := &Tx{config: m.config}
  18240. tx.init()
  18241. return tx, nil
  18242. }
  18243. // SetID sets the value of the id field. Note that this
  18244. // operation is only accepted on creation of Msg entities.
  18245. func (m *MsgMutation) SetID(id uint64) {
  18246. m.id = &id
  18247. }
  18248. // ID returns the ID value in the mutation. Note that the ID is only available
  18249. // if it was provided to the builder or after it was returned from the database.
  18250. func (m *MsgMutation) ID() (id uint64, exists bool) {
  18251. if m.id == nil {
  18252. return
  18253. }
  18254. return *m.id, true
  18255. }
  18256. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  18257. // That means, if the mutation is applied within a transaction with an isolation level such
  18258. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  18259. // or updated by the mutation.
  18260. func (m *MsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  18261. switch {
  18262. case m.op.Is(OpUpdateOne | OpDeleteOne):
  18263. id, exists := m.ID()
  18264. if exists {
  18265. return []uint64{id}, nil
  18266. }
  18267. fallthrough
  18268. case m.op.Is(OpUpdate | OpDelete):
  18269. return m.Client().Msg.Query().Where(m.predicates...).IDs(ctx)
  18270. default:
  18271. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  18272. }
  18273. }
  18274. // SetCreatedAt sets the "created_at" field.
  18275. func (m *MsgMutation) SetCreatedAt(t time.Time) {
  18276. m.created_at = &t
  18277. }
  18278. // CreatedAt returns the value of the "created_at" field in the mutation.
  18279. func (m *MsgMutation) CreatedAt() (r time.Time, exists bool) {
  18280. v := m.created_at
  18281. if v == nil {
  18282. return
  18283. }
  18284. return *v, true
  18285. }
  18286. // OldCreatedAt returns the old "created_at" field's value of the Msg entity.
  18287. // If the Msg 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 *MsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  18290. if !m.op.Is(OpUpdateOne) {
  18291. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  18292. }
  18293. if m.id == nil || m.oldValue == nil {
  18294. return v, errors.New("OldCreatedAt 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 OldCreatedAt: %w", err)
  18299. }
  18300. return oldValue.CreatedAt, nil
  18301. }
  18302. // ResetCreatedAt resets all changes to the "created_at" field.
  18303. func (m *MsgMutation) ResetCreatedAt() {
  18304. m.created_at = nil
  18305. }
  18306. // SetUpdatedAt sets the "updated_at" field.
  18307. func (m *MsgMutation) SetUpdatedAt(t time.Time) {
  18308. m.updated_at = &t
  18309. }
  18310. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  18311. func (m *MsgMutation) UpdatedAt() (r time.Time, exists bool) {
  18312. v := m.updated_at
  18313. if v == nil {
  18314. return
  18315. }
  18316. return *v, true
  18317. }
  18318. // OldUpdatedAt returns the old "updated_at" field's value of the Msg entity.
  18319. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  18320. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18321. func (m *MsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  18322. if !m.op.Is(OpUpdateOne) {
  18323. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  18324. }
  18325. if m.id == nil || m.oldValue == nil {
  18326. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  18327. }
  18328. oldValue, err := m.oldValue(ctx)
  18329. if err != nil {
  18330. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  18331. }
  18332. return oldValue.UpdatedAt, nil
  18333. }
  18334. // ResetUpdatedAt resets all changes to the "updated_at" field.
  18335. func (m *MsgMutation) ResetUpdatedAt() {
  18336. m.updated_at = nil
  18337. }
  18338. // SetDeletedAt sets the "deleted_at" field.
  18339. func (m *MsgMutation) SetDeletedAt(t time.Time) {
  18340. m.deleted_at = &t
  18341. }
  18342. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  18343. func (m *MsgMutation) DeletedAt() (r time.Time, exists bool) {
  18344. v := m.deleted_at
  18345. if v == nil {
  18346. return
  18347. }
  18348. return *v, true
  18349. }
  18350. // OldDeletedAt returns the old "deleted_at" field's value of the Msg entity.
  18351. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  18352. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18353. func (m *MsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  18354. if !m.op.Is(OpUpdateOne) {
  18355. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  18356. }
  18357. if m.id == nil || m.oldValue == nil {
  18358. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  18359. }
  18360. oldValue, err := m.oldValue(ctx)
  18361. if err != nil {
  18362. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  18363. }
  18364. return oldValue.DeletedAt, nil
  18365. }
  18366. // ClearDeletedAt clears the value of the "deleted_at" field.
  18367. func (m *MsgMutation) ClearDeletedAt() {
  18368. m.deleted_at = nil
  18369. m.clearedFields[msg.FieldDeletedAt] = struct{}{}
  18370. }
  18371. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  18372. func (m *MsgMutation) DeletedAtCleared() bool {
  18373. _, ok := m.clearedFields[msg.FieldDeletedAt]
  18374. return ok
  18375. }
  18376. // ResetDeletedAt resets all changes to the "deleted_at" field.
  18377. func (m *MsgMutation) ResetDeletedAt() {
  18378. m.deleted_at = nil
  18379. delete(m.clearedFields, msg.FieldDeletedAt)
  18380. }
  18381. // SetStatus sets the "status" field.
  18382. func (m *MsgMutation) SetStatus(u uint8) {
  18383. m.status = &u
  18384. m.addstatus = nil
  18385. }
  18386. // Status returns the value of the "status" field in the mutation.
  18387. func (m *MsgMutation) Status() (r uint8, exists bool) {
  18388. v := m.status
  18389. if v == nil {
  18390. return
  18391. }
  18392. return *v, true
  18393. }
  18394. // OldStatus returns the old "status" field's value of the Msg entity.
  18395. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  18396. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18397. func (m *MsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  18398. if !m.op.Is(OpUpdateOne) {
  18399. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  18400. }
  18401. if m.id == nil || m.oldValue == nil {
  18402. return v, errors.New("OldStatus requires an ID field in the mutation")
  18403. }
  18404. oldValue, err := m.oldValue(ctx)
  18405. if err != nil {
  18406. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  18407. }
  18408. return oldValue.Status, nil
  18409. }
  18410. // AddStatus adds u to the "status" field.
  18411. func (m *MsgMutation) AddStatus(u int8) {
  18412. if m.addstatus != nil {
  18413. *m.addstatus += u
  18414. } else {
  18415. m.addstatus = &u
  18416. }
  18417. }
  18418. // AddedStatus returns the value that was added to the "status" field in this mutation.
  18419. func (m *MsgMutation) AddedStatus() (r int8, exists bool) {
  18420. v := m.addstatus
  18421. if v == nil {
  18422. return
  18423. }
  18424. return *v, true
  18425. }
  18426. // ClearStatus clears the value of the "status" field.
  18427. func (m *MsgMutation) ClearStatus() {
  18428. m.status = nil
  18429. m.addstatus = nil
  18430. m.clearedFields[msg.FieldStatus] = struct{}{}
  18431. }
  18432. // StatusCleared returns if the "status" field was cleared in this mutation.
  18433. func (m *MsgMutation) StatusCleared() bool {
  18434. _, ok := m.clearedFields[msg.FieldStatus]
  18435. return ok
  18436. }
  18437. // ResetStatus resets all changes to the "status" field.
  18438. func (m *MsgMutation) ResetStatus() {
  18439. m.status = nil
  18440. m.addstatus = nil
  18441. delete(m.clearedFields, msg.FieldStatus)
  18442. }
  18443. // SetFromwxid sets the "fromwxid" field.
  18444. func (m *MsgMutation) SetFromwxid(s string) {
  18445. m.fromwxid = &s
  18446. }
  18447. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  18448. func (m *MsgMutation) Fromwxid() (r string, exists bool) {
  18449. v := m.fromwxid
  18450. if v == nil {
  18451. return
  18452. }
  18453. return *v, true
  18454. }
  18455. // OldFromwxid returns the old "fromwxid" field's value of the Msg entity.
  18456. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  18457. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18458. func (m *MsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  18459. if !m.op.Is(OpUpdateOne) {
  18460. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  18461. }
  18462. if m.id == nil || m.oldValue == nil {
  18463. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  18464. }
  18465. oldValue, err := m.oldValue(ctx)
  18466. if err != nil {
  18467. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  18468. }
  18469. return oldValue.Fromwxid, nil
  18470. }
  18471. // ClearFromwxid clears the value of the "fromwxid" field.
  18472. func (m *MsgMutation) ClearFromwxid() {
  18473. m.fromwxid = nil
  18474. m.clearedFields[msg.FieldFromwxid] = struct{}{}
  18475. }
  18476. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  18477. func (m *MsgMutation) FromwxidCleared() bool {
  18478. _, ok := m.clearedFields[msg.FieldFromwxid]
  18479. return ok
  18480. }
  18481. // ResetFromwxid resets all changes to the "fromwxid" field.
  18482. func (m *MsgMutation) ResetFromwxid() {
  18483. m.fromwxid = nil
  18484. delete(m.clearedFields, msg.FieldFromwxid)
  18485. }
  18486. // SetToid sets the "toid" field.
  18487. func (m *MsgMutation) SetToid(s string) {
  18488. m.toid = &s
  18489. }
  18490. // Toid returns the value of the "toid" field in the mutation.
  18491. func (m *MsgMutation) Toid() (r string, exists bool) {
  18492. v := m.toid
  18493. if v == nil {
  18494. return
  18495. }
  18496. return *v, true
  18497. }
  18498. // OldToid returns the old "toid" field's value of the Msg entity.
  18499. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  18500. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18501. func (m *MsgMutation) OldToid(ctx context.Context) (v string, err error) {
  18502. if !m.op.Is(OpUpdateOne) {
  18503. return v, errors.New("OldToid is only allowed on UpdateOne operations")
  18504. }
  18505. if m.id == nil || m.oldValue == nil {
  18506. return v, errors.New("OldToid requires an ID field in the mutation")
  18507. }
  18508. oldValue, err := m.oldValue(ctx)
  18509. if err != nil {
  18510. return v, fmt.Errorf("querying old value for OldToid: %w", err)
  18511. }
  18512. return oldValue.Toid, nil
  18513. }
  18514. // ClearToid clears the value of the "toid" field.
  18515. func (m *MsgMutation) ClearToid() {
  18516. m.toid = nil
  18517. m.clearedFields[msg.FieldToid] = struct{}{}
  18518. }
  18519. // ToidCleared returns if the "toid" field was cleared in this mutation.
  18520. func (m *MsgMutation) ToidCleared() bool {
  18521. _, ok := m.clearedFields[msg.FieldToid]
  18522. return ok
  18523. }
  18524. // ResetToid resets all changes to the "toid" field.
  18525. func (m *MsgMutation) ResetToid() {
  18526. m.toid = nil
  18527. delete(m.clearedFields, msg.FieldToid)
  18528. }
  18529. // SetMsgtype sets the "msgtype" field.
  18530. func (m *MsgMutation) SetMsgtype(i int32) {
  18531. m.msgtype = &i
  18532. m.addmsgtype = nil
  18533. }
  18534. // Msgtype returns the value of the "msgtype" field in the mutation.
  18535. func (m *MsgMutation) Msgtype() (r int32, exists bool) {
  18536. v := m.msgtype
  18537. if v == nil {
  18538. return
  18539. }
  18540. return *v, true
  18541. }
  18542. // OldMsgtype returns the old "msgtype" field's value of the Msg entity.
  18543. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  18544. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18545. func (m *MsgMutation) OldMsgtype(ctx context.Context) (v int32, err error) {
  18546. if !m.op.Is(OpUpdateOne) {
  18547. return v, errors.New("OldMsgtype is only allowed on UpdateOne operations")
  18548. }
  18549. if m.id == nil || m.oldValue == nil {
  18550. return v, errors.New("OldMsgtype requires an ID field in the mutation")
  18551. }
  18552. oldValue, err := m.oldValue(ctx)
  18553. if err != nil {
  18554. return v, fmt.Errorf("querying old value for OldMsgtype: %w", err)
  18555. }
  18556. return oldValue.Msgtype, nil
  18557. }
  18558. // AddMsgtype adds i to the "msgtype" field.
  18559. func (m *MsgMutation) AddMsgtype(i int32) {
  18560. if m.addmsgtype != nil {
  18561. *m.addmsgtype += i
  18562. } else {
  18563. m.addmsgtype = &i
  18564. }
  18565. }
  18566. // AddedMsgtype returns the value that was added to the "msgtype" field in this mutation.
  18567. func (m *MsgMutation) AddedMsgtype() (r int32, exists bool) {
  18568. v := m.addmsgtype
  18569. if v == nil {
  18570. return
  18571. }
  18572. return *v, true
  18573. }
  18574. // ClearMsgtype clears the value of the "msgtype" field.
  18575. func (m *MsgMutation) ClearMsgtype() {
  18576. m.msgtype = nil
  18577. m.addmsgtype = nil
  18578. m.clearedFields[msg.FieldMsgtype] = struct{}{}
  18579. }
  18580. // MsgtypeCleared returns if the "msgtype" field was cleared in this mutation.
  18581. func (m *MsgMutation) MsgtypeCleared() bool {
  18582. _, ok := m.clearedFields[msg.FieldMsgtype]
  18583. return ok
  18584. }
  18585. // ResetMsgtype resets all changes to the "msgtype" field.
  18586. func (m *MsgMutation) ResetMsgtype() {
  18587. m.msgtype = nil
  18588. m.addmsgtype = nil
  18589. delete(m.clearedFields, msg.FieldMsgtype)
  18590. }
  18591. // SetMsg sets the "msg" field.
  18592. func (m *MsgMutation) SetMsg(s string) {
  18593. m.msg = &s
  18594. }
  18595. // Msg returns the value of the "msg" field in the mutation.
  18596. func (m *MsgMutation) Msg() (r string, exists bool) {
  18597. v := m.msg
  18598. if v == nil {
  18599. return
  18600. }
  18601. return *v, true
  18602. }
  18603. // OldMsg returns the old "msg" field's value of the Msg entity.
  18604. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  18605. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18606. func (m *MsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  18607. if !m.op.Is(OpUpdateOne) {
  18608. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  18609. }
  18610. if m.id == nil || m.oldValue == nil {
  18611. return v, errors.New("OldMsg requires an ID field in the mutation")
  18612. }
  18613. oldValue, err := m.oldValue(ctx)
  18614. if err != nil {
  18615. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  18616. }
  18617. return oldValue.Msg, nil
  18618. }
  18619. // ClearMsg clears the value of the "msg" field.
  18620. func (m *MsgMutation) ClearMsg() {
  18621. m.msg = nil
  18622. m.clearedFields[msg.FieldMsg] = struct{}{}
  18623. }
  18624. // MsgCleared returns if the "msg" field was cleared in this mutation.
  18625. func (m *MsgMutation) MsgCleared() bool {
  18626. _, ok := m.clearedFields[msg.FieldMsg]
  18627. return ok
  18628. }
  18629. // ResetMsg resets all changes to the "msg" field.
  18630. func (m *MsgMutation) ResetMsg() {
  18631. m.msg = nil
  18632. delete(m.clearedFields, msg.FieldMsg)
  18633. }
  18634. // SetBatchNo sets the "batch_no" field.
  18635. func (m *MsgMutation) SetBatchNo(s string) {
  18636. m.batch_no = &s
  18637. }
  18638. // BatchNo returns the value of the "batch_no" field in the mutation.
  18639. func (m *MsgMutation) BatchNo() (r string, exists bool) {
  18640. v := m.batch_no
  18641. if v == nil {
  18642. return
  18643. }
  18644. return *v, true
  18645. }
  18646. // OldBatchNo returns the old "batch_no" field's value of the Msg entity.
  18647. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  18648. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18649. func (m *MsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  18650. if !m.op.Is(OpUpdateOne) {
  18651. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  18652. }
  18653. if m.id == nil || m.oldValue == nil {
  18654. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  18655. }
  18656. oldValue, err := m.oldValue(ctx)
  18657. if err != nil {
  18658. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  18659. }
  18660. return oldValue.BatchNo, nil
  18661. }
  18662. // ClearBatchNo clears the value of the "batch_no" field.
  18663. func (m *MsgMutation) ClearBatchNo() {
  18664. m.batch_no = nil
  18665. m.clearedFields[msg.FieldBatchNo] = struct{}{}
  18666. }
  18667. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  18668. func (m *MsgMutation) BatchNoCleared() bool {
  18669. _, ok := m.clearedFields[msg.FieldBatchNo]
  18670. return ok
  18671. }
  18672. // ResetBatchNo resets all changes to the "batch_no" field.
  18673. func (m *MsgMutation) ResetBatchNo() {
  18674. m.batch_no = nil
  18675. delete(m.clearedFields, msg.FieldBatchNo)
  18676. }
  18677. // Where appends a list predicates to the MsgMutation builder.
  18678. func (m *MsgMutation) Where(ps ...predicate.Msg) {
  18679. m.predicates = append(m.predicates, ps...)
  18680. }
  18681. // WhereP appends storage-level predicates to the MsgMutation builder. Using this method,
  18682. // users can use type-assertion to append predicates that do not depend on any generated package.
  18683. func (m *MsgMutation) WhereP(ps ...func(*sql.Selector)) {
  18684. p := make([]predicate.Msg, len(ps))
  18685. for i := range ps {
  18686. p[i] = ps[i]
  18687. }
  18688. m.Where(p...)
  18689. }
  18690. // Op returns the operation name.
  18691. func (m *MsgMutation) Op() Op {
  18692. return m.op
  18693. }
  18694. // SetOp allows setting the mutation operation.
  18695. func (m *MsgMutation) SetOp(op Op) {
  18696. m.op = op
  18697. }
  18698. // Type returns the node type of this mutation (Msg).
  18699. func (m *MsgMutation) Type() string {
  18700. return m.typ
  18701. }
  18702. // Fields returns all fields that were changed during this mutation. Note that in
  18703. // order to get all numeric fields that were incremented/decremented, call
  18704. // AddedFields().
  18705. func (m *MsgMutation) Fields() []string {
  18706. fields := make([]string, 0, 9)
  18707. if m.created_at != nil {
  18708. fields = append(fields, msg.FieldCreatedAt)
  18709. }
  18710. if m.updated_at != nil {
  18711. fields = append(fields, msg.FieldUpdatedAt)
  18712. }
  18713. if m.deleted_at != nil {
  18714. fields = append(fields, msg.FieldDeletedAt)
  18715. }
  18716. if m.status != nil {
  18717. fields = append(fields, msg.FieldStatus)
  18718. }
  18719. if m.fromwxid != nil {
  18720. fields = append(fields, msg.FieldFromwxid)
  18721. }
  18722. if m.toid != nil {
  18723. fields = append(fields, msg.FieldToid)
  18724. }
  18725. if m.msgtype != nil {
  18726. fields = append(fields, msg.FieldMsgtype)
  18727. }
  18728. if m.msg != nil {
  18729. fields = append(fields, msg.FieldMsg)
  18730. }
  18731. if m.batch_no != nil {
  18732. fields = append(fields, msg.FieldBatchNo)
  18733. }
  18734. return fields
  18735. }
  18736. // Field returns the value of a field with the given name. The second boolean
  18737. // return value indicates that this field was not set, or was not defined in the
  18738. // schema.
  18739. func (m *MsgMutation) Field(name string) (ent.Value, bool) {
  18740. switch name {
  18741. case msg.FieldCreatedAt:
  18742. return m.CreatedAt()
  18743. case msg.FieldUpdatedAt:
  18744. return m.UpdatedAt()
  18745. case msg.FieldDeletedAt:
  18746. return m.DeletedAt()
  18747. case msg.FieldStatus:
  18748. return m.Status()
  18749. case msg.FieldFromwxid:
  18750. return m.Fromwxid()
  18751. case msg.FieldToid:
  18752. return m.Toid()
  18753. case msg.FieldMsgtype:
  18754. return m.Msgtype()
  18755. case msg.FieldMsg:
  18756. return m.Msg()
  18757. case msg.FieldBatchNo:
  18758. return m.BatchNo()
  18759. }
  18760. return nil, false
  18761. }
  18762. // OldField returns the old value of the field from the database. An error is
  18763. // returned if the mutation operation is not UpdateOne, or the query to the
  18764. // database failed.
  18765. func (m *MsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  18766. switch name {
  18767. case msg.FieldCreatedAt:
  18768. return m.OldCreatedAt(ctx)
  18769. case msg.FieldUpdatedAt:
  18770. return m.OldUpdatedAt(ctx)
  18771. case msg.FieldDeletedAt:
  18772. return m.OldDeletedAt(ctx)
  18773. case msg.FieldStatus:
  18774. return m.OldStatus(ctx)
  18775. case msg.FieldFromwxid:
  18776. return m.OldFromwxid(ctx)
  18777. case msg.FieldToid:
  18778. return m.OldToid(ctx)
  18779. case msg.FieldMsgtype:
  18780. return m.OldMsgtype(ctx)
  18781. case msg.FieldMsg:
  18782. return m.OldMsg(ctx)
  18783. case msg.FieldBatchNo:
  18784. return m.OldBatchNo(ctx)
  18785. }
  18786. return nil, fmt.Errorf("unknown Msg field %s", name)
  18787. }
  18788. // SetField sets the value of a field with the given name. It returns an error if
  18789. // the field is not defined in the schema, or if the type mismatched the field
  18790. // type.
  18791. func (m *MsgMutation) SetField(name string, value ent.Value) error {
  18792. switch name {
  18793. case msg.FieldCreatedAt:
  18794. v, ok := value.(time.Time)
  18795. if !ok {
  18796. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18797. }
  18798. m.SetCreatedAt(v)
  18799. return nil
  18800. case msg.FieldUpdatedAt:
  18801. v, ok := value.(time.Time)
  18802. if !ok {
  18803. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18804. }
  18805. m.SetUpdatedAt(v)
  18806. return nil
  18807. case msg.FieldDeletedAt:
  18808. v, ok := value.(time.Time)
  18809. if !ok {
  18810. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18811. }
  18812. m.SetDeletedAt(v)
  18813. return nil
  18814. case msg.FieldStatus:
  18815. v, ok := value.(uint8)
  18816. if !ok {
  18817. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18818. }
  18819. m.SetStatus(v)
  18820. return nil
  18821. case msg.FieldFromwxid:
  18822. v, ok := value.(string)
  18823. if !ok {
  18824. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18825. }
  18826. m.SetFromwxid(v)
  18827. return nil
  18828. case msg.FieldToid:
  18829. v, ok := value.(string)
  18830. if !ok {
  18831. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18832. }
  18833. m.SetToid(v)
  18834. return nil
  18835. case msg.FieldMsgtype:
  18836. v, ok := value.(int32)
  18837. if !ok {
  18838. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18839. }
  18840. m.SetMsgtype(v)
  18841. return nil
  18842. case msg.FieldMsg:
  18843. v, ok := value.(string)
  18844. if !ok {
  18845. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18846. }
  18847. m.SetMsg(v)
  18848. return nil
  18849. case msg.FieldBatchNo:
  18850. v, ok := value.(string)
  18851. if !ok {
  18852. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18853. }
  18854. m.SetBatchNo(v)
  18855. return nil
  18856. }
  18857. return fmt.Errorf("unknown Msg field %s", name)
  18858. }
  18859. // AddedFields returns all numeric fields that were incremented/decremented during
  18860. // this mutation.
  18861. func (m *MsgMutation) AddedFields() []string {
  18862. var fields []string
  18863. if m.addstatus != nil {
  18864. fields = append(fields, msg.FieldStatus)
  18865. }
  18866. if m.addmsgtype != nil {
  18867. fields = append(fields, msg.FieldMsgtype)
  18868. }
  18869. return fields
  18870. }
  18871. // AddedField returns the numeric value that was incremented/decremented on a field
  18872. // with the given name. The second boolean return value indicates that this field
  18873. // was not set, or was not defined in the schema.
  18874. func (m *MsgMutation) AddedField(name string) (ent.Value, bool) {
  18875. switch name {
  18876. case msg.FieldStatus:
  18877. return m.AddedStatus()
  18878. case msg.FieldMsgtype:
  18879. return m.AddedMsgtype()
  18880. }
  18881. return nil, false
  18882. }
  18883. // AddField adds the value to the field with the given name. It returns an error if
  18884. // the field is not defined in the schema, or if the type mismatched the field
  18885. // type.
  18886. func (m *MsgMutation) AddField(name string, value ent.Value) error {
  18887. switch name {
  18888. case msg.FieldStatus:
  18889. v, ok := value.(int8)
  18890. if !ok {
  18891. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18892. }
  18893. m.AddStatus(v)
  18894. return nil
  18895. case msg.FieldMsgtype:
  18896. v, ok := value.(int32)
  18897. if !ok {
  18898. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18899. }
  18900. m.AddMsgtype(v)
  18901. return nil
  18902. }
  18903. return fmt.Errorf("unknown Msg numeric field %s", name)
  18904. }
  18905. // ClearedFields returns all nullable fields that were cleared during this
  18906. // mutation.
  18907. func (m *MsgMutation) ClearedFields() []string {
  18908. var fields []string
  18909. if m.FieldCleared(msg.FieldDeletedAt) {
  18910. fields = append(fields, msg.FieldDeletedAt)
  18911. }
  18912. if m.FieldCleared(msg.FieldStatus) {
  18913. fields = append(fields, msg.FieldStatus)
  18914. }
  18915. if m.FieldCleared(msg.FieldFromwxid) {
  18916. fields = append(fields, msg.FieldFromwxid)
  18917. }
  18918. if m.FieldCleared(msg.FieldToid) {
  18919. fields = append(fields, msg.FieldToid)
  18920. }
  18921. if m.FieldCleared(msg.FieldMsgtype) {
  18922. fields = append(fields, msg.FieldMsgtype)
  18923. }
  18924. if m.FieldCleared(msg.FieldMsg) {
  18925. fields = append(fields, msg.FieldMsg)
  18926. }
  18927. if m.FieldCleared(msg.FieldBatchNo) {
  18928. fields = append(fields, msg.FieldBatchNo)
  18929. }
  18930. return fields
  18931. }
  18932. // FieldCleared returns a boolean indicating if a field with the given name was
  18933. // cleared in this mutation.
  18934. func (m *MsgMutation) FieldCleared(name string) bool {
  18935. _, ok := m.clearedFields[name]
  18936. return ok
  18937. }
  18938. // ClearField clears the value of the field with the given name. It returns an
  18939. // error if the field is not defined in the schema.
  18940. func (m *MsgMutation) ClearField(name string) error {
  18941. switch name {
  18942. case msg.FieldDeletedAt:
  18943. m.ClearDeletedAt()
  18944. return nil
  18945. case msg.FieldStatus:
  18946. m.ClearStatus()
  18947. return nil
  18948. case msg.FieldFromwxid:
  18949. m.ClearFromwxid()
  18950. return nil
  18951. case msg.FieldToid:
  18952. m.ClearToid()
  18953. return nil
  18954. case msg.FieldMsgtype:
  18955. m.ClearMsgtype()
  18956. return nil
  18957. case msg.FieldMsg:
  18958. m.ClearMsg()
  18959. return nil
  18960. case msg.FieldBatchNo:
  18961. m.ClearBatchNo()
  18962. return nil
  18963. }
  18964. return fmt.Errorf("unknown Msg nullable field %s", name)
  18965. }
  18966. // ResetField resets all changes in the mutation for the field with the given name.
  18967. // It returns an error if the field is not defined in the schema.
  18968. func (m *MsgMutation) ResetField(name string) error {
  18969. switch name {
  18970. case msg.FieldCreatedAt:
  18971. m.ResetCreatedAt()
  18972. return nil
  18973. case msg.FieldUpdatedAt:
  18974. m.ResetUpdatedAt()
  18975. return nil
  18976. case msg.FieldDeletedAt:
  18977. m.ResetDeletedAt()
  18978. return nil
  18979. case msg.FieldStatus:
  18980. m.ResetStatus()
  18981. return nil
  18982. case msg.FieldFromwxid:
  18983. m.ResetFromwxid()
  18984. return nil
  18985. case msg.FieldToid:
  18986. m.ResetToid()
  18987. return nil
  18988. case msg.FieldMsgtype:
  18989. m.ResetMsgtype()
  18990. return nil
  18991. case msg.FieldMsg:
  18992. m.ResetMsg()
  18993. return nil
  18994. case msg.FieldBatchNo:
  18995. m.ResetBatchNo()
  18996. return nil
  18997. }
  18998. return fmt.Errorf("unknown Msg field %s", name)
  18999. }
  19000. // AddedEdges returns all edge names that were set/added in this mutation.
  19001. func (m *MsgMutation) AddedEdges() []string {
  19002. edges := make([]string, 0, 0)
  19003. return edges
  19004. }
  19005. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  19006. // name in this mutation.
  19007. func (m *MsgMutation) AddedIDs(name string) []ent.Value {
  19008. return nil
  19009. }
  19010. // RemovedEdges returns all edge names that were removed in this mutation.
  19011. func (m *MsgMutation) RemovedEdges() []string {
  19012. edges := make([]string, 0, 0)
  19013. return edges
  19014. }
  19015. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  19016. // the given name in this mutation.
  19017. func (m *MsgMutation) RemovedIDs(name string) []ent.Value {
  19018. return nil
  19019. }
  19020. // ClearedEdges returns all edge names that were cleared in this mutation.
  19021. func (m *MsgMutation) ClearedEdges() []string {
  19022. edges := make([]string, 0, 0)
  19023. return edges
  19024. }
  19025. // EdgeCleared returns a boolean which indicates if the edge with the given name
  19026. // was cleared in this mutation.
  19027. func (m *MsgMutation) EdgeCleared(name string) bool {
  19028. return false
  19029. }
  19030. // ClearEdge clears the value of the edge with the given name. It returns an error
  19031. // if that edge is not defined in the schema.
  19032. func (m *MsgMutation) ClearEdge(name string) error {
  19033. return fmt.Errorf("unknown Msg unique edge %s", name)
  19034. }
  19035. // ResetEdge resets all changes to the edge with the given name in this mutation.
  19036. // It returns an error if the edge is not defined in the schema.
  19037. func (m *MsgMutation) ResetEdge(name string) error {
  19038. return fmt.Errorf("unknown Msg edge %s", name)
  19039. }
  19040. // PayRechargeMutation represents an operation that mutates the PayRecharge nodes in the graph.
  19041. type PayRechargeMutation struct {
  19042. config
  19043. op Op
  19044. typ string
  19045. id *uint64
  19046. created_at *time.Time
  19047. updated_at *time.Time
  19048. deleted_at *time.Time
  19049. user_id *string
  19050. number *float32
  19051. addnumber *float32
  19052. status *int
  19053. addstatus *int
  19054. money *float32
  19055. addmoney *float32
  19056. out_trade_no *string
  19057. organization_id *uint64
  19058. addorganization_id *int64
  19059. clearedFields map[string]struct{}
  19060. done bool
  19061. oldValue func(context.Context) (*PayRecharge, error)
  19062. predicates []predicate.PayRecharge
  19063. }
  19064. var _ ent.Mutation = (*PayRechargeMutation)(nil)
  19065. // payrechargeOption allows management of the mutation configuration using functional options.
  19066. type payrechargeOption func(*PayRechargeMutation)
  19067. // newPayRechargeMutation creates new mutation for the PayRecharge entity.
  19068. func newPayRechargeMutation(c config, op Op, opts ...payrechargeOption) *PayRechargeMutation {
  19069. m := &PayRechargeMutation{
  19070. config: c,
  19071. op: op,
  19072. typ: TypePayRecharge,
  19073. clearedFields: make(map[string]struct{}),
  19074. }
  19075. for _, opt := range opts {
  19076. opt(m)
  19077. }
  19078. return m
  19079. }
  19080. // withPayRechargeID sets the ID field of the mutation.
  19081. func withPayRechargeID(id uint64) payrechargeOption {
  19082. return func(m *PayRechargeMutation) {
  19083. var (
  19084. err error
  19085. once sync.Once
  19086. value *PayRecharge
  19087. )
  19088. m.oldValue = func(ctx context.Context) (*PayRecharge, error) {
  19089. once.Do(func() {
  19090. if m.done {
  19091. err = errors.New("querying old values post mutation is not allowed")
  19092. } else {
  19093. value, err = m.Client().PayRecharge.Get(ctx, id)
  19094. }
  19095. })
  19096. return value, err
  19097. }
  19098. m.id = &id
  19099. }
  19100. }
  19101. // withPayRecharge sets the old PayRecharge of the mutation.
  19102. func withPayRecharge(node *PayRecharge) payrechargeOption {
  19103. return func(m *PayRechargeMutation) {
  19104. m.oldValue = func(context.Context) (*PayRecharge, error) {
  19105. return node, nil
  19106. }
  19107. m.id = &node.ID
  19108. }
  19109. }
  19110. // Client returns a new `ent.Client` from the mutation. If the mutation was
  19111. // executed in a transaction (ent.Tx), a transactional client is returned.
  19112. func (m PayRechargeMutation) Client() *Client {
  19113. client := &Client{config: m.config}
  19114. client.init()
  19115. return client
  19116. }
  19117. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  19118. // it returns an error otherwise.
  19119. func (m PayRechargeMutation) Tx() (*Tx, error) {
  19120. if _, ok := m.driver.(*txDriver); !ok {
  19121. return nil, errors.New("ent: mutation is not running in a transaction")
  19122. }
  19123. tx := &Tx{config: m.config}
  19124. tx.init()
  19125. return tx, nil
  19126. }
  19127. // SetID sets the value of the id field. Note that this
  19128. // operation is only accepted on creation of PayRecharge entities.
  19129. func (m *PayRechargeMutation) SetID(id uint64) {
  19130. m.id = &id
  19131. }
  19132. // ID returns the ID value in the mutation. Note that the ID is only available
  19133. // if it was provided to the builder or after it was returned from the database.
  19134. func (m *PayRechargeMutation) ID() (id uint64, exists bool) {
  19135. if m.id == nil {
  19136. return
  19137. }
  19138. return *m.id, true
  19139. }
  19140. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  19141. // That means, if the mutation is applied within a transaction with an isolation level such
  19142. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  19143. // or updated by the mutation.
  19144. func (m *PayRechargeMutation) IDs(ctx context.Context) ([]uint64, error) {
  19145. switch {
  19146. case m.op.Is(OpUpdateOne | OpDeleteOne):
  19147. id, exists := m.ID()
  19148. if exists {
  19149. return []uint64{id}, nil
  19150. }
  19151. fallthrough
  19152. case m.op.Is(OpUpdate | OpDelete):
  19153. return m.Client().PayRecharge.Query().Where(m.predicates...).IDs(ctx)
  19154. default:
  19155. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  19156. }
  19157. }
  19158. // SetCreatedAt sets the "created_at" field.
  19159. func (m *PayRechargeMutation) SetCreatedAt(t time.Time) {
  19160. m.created_at = &t
  19161. }
  19162. // CreatedAt returns the value of the "created_at" field in the mutation.
  19163. func (m *PayRechargeMutation) CreatedAt() (r time.Time, exists bool) {
  19164. v := m.created_at
  19165. if v == nil {
  19166. return
  19167. }
  19168. return *v, true
  19169. }
  19170. // OldCreatedAt returns the old "created_at" field's value of the PayRecharge entity.
  19171. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  19172. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19173. func (m *PayRechargeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  19174. if !m.op.Is(OpUpdateOne) {
  19175. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  19176. }
  19177. if m.id == nil || m.oldValue == nil {
  19178. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  19179. }
  19180. oldValue, err := m.oldValue(ctx)
  19181. if err != nil {
  19182. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  19183. }
  19184. return oldValue.CreatedAt, nil
  19185. }
  19186. // ResetCreatedAt resets all changes to the "created_at" field.
  19187. func (m *PayRechargeMutation) ResetCreatedAt() {
  19188. m.created_at = nil
  19189. }
  19190. // SetUpdatedAt sets the "updated_at" field.
  19191. func (m *PayRechargeMutation) SetUpdatedAt(t time.Time) {
  19192. m.updated_at = &t
  19193. }
  19194. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  19195. func (m *PayRechargeMutation) UpdatedAt() (r time.Time, exists bool) {
  19196. v := m.updated_at
  19197. if v == nil {
  19198. return
  19199. }
  19200. return *v, true
  19201. }
  19202. // OldUpdatedAt returns the old "updated_at" field's value of the PayRecharge entity.
  19203. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  19204. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19205. func (m *PayRechargeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  19206. if !m.op.Is(OpUpdateOne) {
  19207. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  19208. }
  19209. if m.id == nil || m.oldValue == nil {
  19210. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  19211. }
  19212. oldValue, err := m.oldValue(ctx)
  19213. if err != nil {
  19214. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  19215. }
  19216. return oldValue.UpdatedAt, nil
  19217. }
  19218. // ResetUpdatedAt resets all changes to the "updated_at" field.
  19219. func (m *PayRechargeMutation) ResetUpdatedAt() {
  19220. m.updated_at = nil
  19221. }
  19222. // SetDeletedAt sets the "deleted_at" field.
  19223. func (m *PayRechargeMutation) SetDeletedAt(t time.Time) {
  19224. m.deleted_at = &t
  19225. }
  19226. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  19227. func (m *PayRechargeMutation) DeletedAt() (r time.Time, exists bool) {
  19228. v := m.deleted_at
  19229. if v == nil {
  19230. return
  19231. }
  19232. return *v, true
  19233. }
  19234. // OldDeletedAt returns the old "deleted_at" field's value of the PayRecharge entity.
  19235. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  19236. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19237. func (m *PayRechargeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  19238. if !m.op.Is(OpUpdateOne) {
  19239. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  19240. }
  19241. if m.id == nil || m.oldValue == nil {
  19242. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  19243. }
  19244. oldValue, err := m.oldValue(ctx)
  19245. if err != nil {
  19246. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  19247. }
  19248. return oldValue.DeletedAt, nil
  19249. }
  19250. // ClearDeletedAt clears the value of the "deleted_at" field.
  19251. func (m *PayRechargeMutation) ClearDeletedAt() {
  19252. m.deleted_at = nil
  19253. m.clearedFields[payrecharge.FieldDeletedAt] = struct{}{}
  19254. }
  19255. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  19256. func (m *PayRechargeMutation) DeletedAtCleared() bool {
  19257. _, ok := m.clearedFields[payrecharge.FieldDeletedAt]
  19258. return ok
  19259. }
  19260. // ResetDeletedAt resets all changes to the "deleted_at" field.
  19261. func (m *PayRechargeMutation) ResetDeletedAt() {
  19262. m.deleted_at = nil
  19263. delete(m.clearedFields, payrecharge.FieldDeletedAt)
  19264. }
  19265. // SetUserID sets the "user_id" field.
  19266. func (m *PayRechargeMutation) SetUserID(s string) {
  19267. m.user_id = &s
  19268. }
  19269. // UserID returns the value of the "user_id" field in the mutation.
  19270. func (m *PayRechargeMutation) UserID() (r string, exists bool) {
  19271. v := m.user_id
  19272. if v == nil {
  19273. return
  19274. }
  19275. return *v, true
  19276. }
  19277. // OldUserID returns the old "user_id" field's value of the PayRecharge entity.
  19278. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  19279. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19280. func (m *PayRechargeMutation) OldUserID(ctx context.Context) (v string, err error) {
  19281. if !m.op.Is(OpUpdateOne) {
  19282. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  19283. }
  19284. if m.id == nil || m.oldValue == nil {
  19285. return v, errors.New("OldUserID requires an ID field in the mutation")
  19286. }
  19287. oldValue, err := m.oldValue(ctx)
  19288. if err != nil {
  19289. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  19290. }
  19291. return oldValue.UserID, nil
  19292. }
  19293. // ResetUserID resets all changes to the "user_id" field.
  19294. func (m *PayRechargeMutation) ResetUserID() {
  19295. m.user_id = nil
  19296. }
  19297. // SetNumber sets the "number" field.
  19298. func (m *PayRechargeMutation) SetNumber(f float32) {
  19299. m.number = &f
  19300. m.addnumber = nil
  19301. }
  19302. // Number returns the value of the "number" field in the mutation.
  19303. func (m *PayRechargeMutation) Number() (r float32, exists bool) {
  19304. v := m.number
  19305. if v == nil {
  19306. return
  19307. }
  19308. return *v, true
  19309. }
  19310. // OldNumber returns the old "number" field's value of the PayRecharge entity.
  19311. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  19312. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19313. func (m *PayRechargeMutation) OldNumber(ctx context.Context) (v float32, err error) {
  19314. if !m.op.Is(OpUpdateOne) {
  19315. return v, errors.New("OldNumber is only allowed on UpdateOne operations")
  19316. }
  19317. if m.id == nil || m.oldValue == nil {
  19318. return v, errors.New("OldNumber requires an ID field in the mutation")
  19319. }
  19320. oldValue, err := m.oldValue(ctx)
  19321. if err != nil {
  19322. return v, fmt.Errorf("querying old value for OldNumber: %w", err)
  19323. }
  19324. return oldValue.Number, nil
  19325. }
  19326. // AddNumber adds f to the "number" field.
  19327. func (m *PayRechargeMutation) AddNumber(f float32) {
  19328. if m.addnumber != nil {
  19329. *m.addnumber += f
  19330. } else {
  19331. m.addnumber = &f
  19332. }
  19333. }
  19334. // AddedNumber returns the value that was added to the "number" field in this mutation.
  19335. func (m *PayRechargeMutation) AddedNumber() (r float32, exists bool) {
  19336. v := m.addnumber
  19337. if v == nil {
  19338. return
  19339. }
  19340. return *v, true
  19341. }
  19342. // ResetNumber resets all changes to the "number" field.
  19343. func (m *PayRechargeMutation) ResetNumber() {
  19344. m.number = nil
  19345. m.addnumber = nil
  19346. }
  19347. // SetStatus sets the "status" field.
  19348. func (m *PayRechargeMutation) SetStatus(i int) {
  19349. m.status = &i
  19350. m.addstatus = nil
  19351. }
  19352. // Status returns the value of the "status" field in the mutation.
  19353. func (m *PayRechargeMutation) Status() (r int, exists bool) {
  19354. v := m.status
  19355. if v == nil {
  19356. return
  19357. }
  19358. return *v, true
  19359. }
  19360. // OldStatus returns the old "status" field's value of the PayRecharge entity.
  19361. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  19362. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19363. func (m *PayRechargeMutation) OldStatus(ctx context.Context) (v int, err error) {
  19364. if !m.op.Is(OpUpdateOne) {
  19365. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  19366. }
  19367. if m.id == nil || m.oldValue == nil {
  19368. return v, errors.New("OldStatus requires an ID field in the mutation")
  19369. }
  19370. oldValue, err := m.oldValue(ctx)
  19371. if err != nil {
  19372. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  19373. }
  19374. return oldValue.Status, nil
  19375. }
  19376. // AddStatus adds i to the "status" field.
  19377. func (m *PayRechargeMutation) AddStatus(i int) {
  19378. if m.addstatus != nil {
  19379. *m.addstatus += i
  19380. } else {
  19381. m.addstatus = &i
  19382. }
  19383. }
  19384. // AddedStatus returns the value that was added to the "status" field in this mutation.
  19385. func (m *PayRechargeMutation) AddedStatus() (r int, exists bool) {
  19386. v := m.addstatus
  19387. if v == nil {
  19388. return
  19389. }
  19390. return *v, true
  19391. }
  19392. // ClearStatus clears the value of the "status" field.
  19393. func (m *PayRechargeMutation) ClearStatus() {
  19394. m.status = nil
  19395. m.addstatus = nil
  19396. m.clearedFields[payrecharge.FieldStatus] = struct{}{}
  19397. }
  19398. // StatusCleared returns if the "status" field was cleared in this mutation.
  19399. func (m *PayRechargeMutation) StatusCleared() bool {
  19400. _, ok := m.clearedFields[payrecharge.FieldStatus]
  19401. return ok
  19402. }
  19403. // ResetStatus resets all changes to the "status" field.
  19404. func (m *PayRechargeMutation) ResetStatus() {
  19405. m.status = nil
  19406. m.addstatus = nil
  19407. delete(m.clearedFields, payrecharge.FieldStatus)
  19408. }
  19409. // SetMoney sets the "money" field.
  19410. func (m *PayRechargeMutation) SetMoney(f float32) {
  19411. m.money = &f
  19412. m.addmoney = nil
  19413. }
  19414. // Money returns the value of the "money" field in the mutation.
  19415. func (m *PayRechargeMutation) Money() (r float32, exists bool) {
  19416. v := m.money
  19417. if v == nil {
  19418. return
  19419. }
  19420. return *v, true
  19421. }
  19422. // OldMoney returns the old "money" field's value of the PayRecharge entity.
  19423. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  19424. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19425. func (m *PayRechargeMutation) OldMoney(ctx context.Context) (v float32, err error) {
  19426. if !m.op.Is(OpUpdateOne) {
  19427. return v, errors.New("OldMoney is only allowed on UpdateOne operations")
  19428. }
  19429. if m.id == nil || m.oldValue == nil {
  19430. return v, errors.New("OldMoney requires an ID field in the mutation")
  19431. }
  19432. oldValue, err := m.oldValue(ctx)
  19433. if err != nil {
  19434. return v, fmt.Errorf("querying old value for OldMoney: %w", err)
  19435. }
  19436. return oldValue.Money, nil
  19437. }
  19438. // AddMoney adds f to the "money" field.
  19439. func (m *PayRechargeMutation) AddMoney(f float32) {
  19440. if m.addmoney != nil {
  19441. *m.addmoney += f
  19442. } else {
  19443. m.addmoney = &f
  19444. }
  19445. }
  19446. // AddedMoney returns the value that was added to the "money" field in this mutation.
  19447. func (m *PayRechargeMutation) AddedMoney() (r float32, exists bool) {
  19448. v := m.addmoney
  19449. if v == nil {
  19450. return
  19451. }
  19452. return *v, true
  19453. }
  19454. // ClearMoney clears the value of the "money" field.
  19455. func (m *PayRechargeMutation) ClearMoney() {
  19456. m.money = nil
  19457. m.addmoney = nil
  19458. m.clearedFields[payrecharge.FieldMoney] = struct{}{}
  19459. }
  19460. // MoneyCleared returns if the "money" field was cleared in this mutation.
  19461. func (m *PayRechargeMutation) MoneyCleared() bool {
  19462. _, ok := m.clearedFields[payrecharge.FieldMoney]
  19463. return ok
  19464. }
  19465. // ResetMoney resets all changes to the "money" field.
  19466. func (m *PayRechargeMutation) ResetMoney() {
  19467. m.money = nil
  19468. m.addmoney = nil
  19469. delete(m.clearedFields, payrecharge.FieldMoney)
  19470. }
  19471. // SetOutTradeNo sets the "out_trade_no" field.
  19472. func (m *PayRechargeMutation) SetOutTradeNo(s string) {
  19473. m.out_trade_no = &s
  19474. }
  19475. // OutTradeNo returns the value of the "out_trade_no" field in the mutation.
  19476. func (m *PayRechargeMutation) OutTradeNo() (r string, exists bool) {
  19477. v := m.out_trade_no
  19478. if v == nil {
  19479. return
  19480. }
  19481. return *v, true
  19482. }
  19483. // OldOutTradeNo returns the old "out_trade_no" field's value of the PayRecharge entity.
  19484. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  19485. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19486. func (m *PayRechargeMutation) OldOutTradeNo(ctx context.Context) (v string, err error) {
  19487. if !m.op.Is(OpUpdateOne) {
  19488. return v, errors.New("OldOutTradeNo is only allowed on UpdateOne operations")
  19489. }
  19490. if m.id == nil || m.oldValue == nil {
  19491. return v, errors.New("OldOutTradeNo requires an ID field in the mutation")
  19492. }
  19493. oldValue, err := m.oldValue(ctx)
  19494. if err != nil {
  19495. return v, fmt.Errorf("querying old value for OldOutTradeNo: %w", err)
  19496. }
  19497. return oldValue.OutTradeNo, nil
  19498. }
  19499. // ClearOutTradeNo clears the value of the "out_trade_no" field.
  19500. func (m *PayRechargeMutation) ClearOutTradeNo() {
  19501. m.out_trade_no = nil
  19502. m.clearedFields[payrecharge.FieldOutTradeNo] = struct{}{}
  19503. }
  19504. // OutTradeNoCleared returns if the "out_trade_no" field was cleared in this mutation.
  19505. func (m *PayRechargeMutation) OutTradeNoCleared() bool {
  19506. _, ok := m.clearedFields[payrecharge.FieldOutTradeNo]
  19507. return ok
  19508. }
  19509. // ResetOutTradeNo resets all changes to the "out_trade_no" field.
  19510. func (m *PayRechargeMutation) ResetOutTradeNo() {
  19511. m.out_trade_no = nil
  19512. delete(m.clearedFields, payrecharge.FieldOutTradeNo)
  19513. }
  19514. // SetOrganizationID sets the "organization_id" field.
  19515. func (m *PayRechargeMutation) SetOrganizationID(u uint64) {
  19516. m.organization_id = &u
  19517. m.addorganization_id = nil
  19518. }
  19519. // OrganizationID returns the value of the "organization_id" field in the mutation.
  19520. func (m *PayRechargeMutation) OrganizationID() (r uint64, exists bool) {
  19521. v := m.organization_id
  19522. if v == nil {
  19523. return
  19524. }
  19525. return *v, true
  19526. }
  19527. // OldOrganizationID returns the old "organization_id" field's value of the PayRecharge entity.
  19528. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  19529. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19530. func (m *PayRechargeMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  19531. if !m.op.Is(OpUpdateOne) {
  19532. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  19533. }
  19534. if m.id == nil || m.oldValue == nil {
  19535. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  19536. }
  19537. oldValue, err := m.oldValue(ctx)
  19538. if err != nil {
  19539. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  19540. }
  19541. return oldValue.OrganizationID, nil
  19542. }
  19543. // AddOrganizationID adds u to the "organization_id" field.
  19544. func (m *PayRechargeMutation) AddOrganizationID(u int64) {
  19545. if m.addorganization_id != nil {
  19546. *m.addorganization_id += u
  19547. } else {
  19548. m.addorganization_id = &u
  19549. }
  19550. }
  19551. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  19552. func (m *PayRechargeMutation) AddedOrganizationID() (r int64, exists bool) {
  19553. v := m.addorganization_id
  19554. if v == nil {
  19555. return
  19556. }
  19557. return *v, true
  19558. }
  19559. // ResetOrganizationID resets all changes to the "organization_id" field.
  19560. func (m *PayRechargeMutation) ResetOrganizationID() {
  19561. m.organization_id = nil
  19562. m.addorganization_id = nil
  19563. }
  19564. // Where appends a list predicates to the PayRechargeMutation builder.
  19565. func (m *PayRechargeMutation) Where(ps ...predicate.PayRecharge) {
  19566. m.predicates = append(m.predicates, ps...)
  19567. }
  19568. // WhereP appends storage-level predicates to the PayRechargeMutation builder. Using this method,
  19569. // users can use type-assertion to append predicates that do not depend on any generated package.
  19570. func (m *PayRechargeMutation) WhereP(ps ...func(*sql.Selector)) {
  19571. p := make([]predicate.PayRecharge, len(ps))
  19572. for i := range ps {
  19573. p[i] = ps[i]
  19574. }
  19575. m.Where(p...)
  19576. }
  19577. // Op returns the operation name.
  19578. func (m *PayRechargeMutation) Op() Op {
  19579. return m.op
  19580. }
  19581. // SetOp allows setting the mutation operation.
  19582. func (m *PayRechargeMutation) SetOp(op Op) {
  19583. m.op = op
  19584. }
  19585. // Type returns the node type of this mutation (PayRecharge).
  19586. func (m *PayRechargeMutation) Type() string {
  19587. return m.typ
  19588. }
  19589. // Fields returns all fields that were changed during this mutation. Note that in
  19590. // order to get all numeric fields that were incremented/decremented, call
  19591. // AddedFields().
  19592. func (m *PayRechargeMutation) Fields() []string {
  19593. fields := make([]string, 0, 9)
  19594. if m.created_at != nil {
  19595. fields = append(fields, payrecharge.FieldCreatedAt)
  19596. }
  19597. if m.updated_at != nil {
  19598. fields = append(fields, payrecharge.FieldUpdatedAt)
  19599. }
  19600. if m.deleted_at != nil {
  19601. fields = append(fields, payrecharge.FieldDeletedAt)
  19602. }
  19603. if m.user_id != nil {
  19604. fields = append(fields, payrecharge.FieldUserID)
  19605. }
  19606. if m.number != nil {
  19607. fields = append(fields, payrecharge.FieldNumber)
  19608. }
  19609. if m.status != nil {
  19610. fields = append(fields, payrecharge.FieldStatus)
  19611. }
  19612. if m.money != nil {
  19613. fields = append(fields, payrecharge.FieldMoney)
  19614. }
  19615. if m.out_trade_no != nil {
  19616. fields = append(fields, payrecharge.FieldOutTradeNo)
  19617. }
  19618. if m.organization_id != nil {
  19619. fields = append(fields, payrecharge.FieldOrganizationID)
  19620. }
  19621. return fields
  19622. }
  19623. // Field returns the value of a field with the given name. The second boolean
  19624. // return value indicates that this field was not set, or was not defined in the
  19625. // schema.
  19626. func (m *PayRechargeMutation) Field(name string) (ent.Value, bool) {
  19627. switch name {
  19628. case payrecharge.FieldCreatedAt:
  19629. return m.CreatedAt()
  19630. case payrecharge.FieldUpdatedAt:
  19631. return m.UpdatedAt()
  19632. case payrecharge.FieldDeletedAt:
  19633. return m.DeletedAt()
  19634. case payrecharge.FieldUserID:
  19635. return m.UserID()
  19636. case payrecharge.FieldNumber:
  19637. return m.Number()
  19638. case payrecharge.FieldStatus:
  19639. return m.Status()
  19640. case payrecharge.FieldMoney:
  19641. return m.Money()
  19642. case payrecharge.FieldOutTradeNo:
  19643. return m.OutTradeNo()
  19644. case payrecharge.FieldOrganizationID:
  19645. return m.OrganizationID()
  19646. }
  19647. return nil, false
  19648. }
  19649. // OldField returns the old value of the field from the database. An error is
  19650. // returned if the mutation operation is not UpdateOne, or the query to the
  19651. // database failed.
  19652. func (m *PayRechargeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  19653. switch name {
  19654. case payrecharge.FieldCreatedAt:
  19655. return m.OldCreatedAt(ctx)
  19656. case payrecharge.FieldUpdatedAt:
  19657. return m.OldUpdatedAt(ctx)
  19658. case payrecharge.FieldDeletedAt:
  19659. return m.OldDeletedAt(ctx)
  19660. case payrecharge.FieldUserID:
  19661. return m.OldUserID(ctx)
  19662. case payrecharge.FieldNumber:
  19663. return m.OldNumber(ctx)
  19664. case payrecharge.FieldStatus:
  19665. return m.OldStatus(ctx)
  19666. case payrecharge.FieldMoney:
  19667. return m.OldMoney(ctx)
  19668. case payrecharge.FieldOutTradeNo:
  19669. return m.OldOutTradeNo(ctx)
  19670. case payrecharge.FieldOrganizationID:
  19671. return m.OldOrganizationID(ctx)
  19672. }
  19673. return nil, fmt.Errorf("unknown PayRecharge field %s", name)
  19674. }
  19675. // SetField sets the value of a field with the given name. It returns an error if
  19676. // the field is not defined in the schema, or if the type mismatched the field
  19677. // type.
  19678. func (m *PayRechargeMutation) SetField(name string, value ent.Value) error {
  19679. switch name {
  19680. case payrecharge.FieldCreatedAt:
  19681. v, ok := value.(time.Time)
  19682. if !ok {
  19683. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19684. }
  19685. m.SetCreatedAt(v)
  19686. return nil
  19687. case payrecharge.FieldUpdatedAt:
  19688. v, ok := value.(time.Time)
  19689. if !ok {
  19690. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19691. }
  19692. m.SetUpdatedAt(v)
  19693. return nil
  19694. case payrecharge.FieldDeletedAt:
  19695. v, ok := value.(time.Time)
  19696. if !ok {
  19697. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19698. }
  19699. m.SetDeletedAt(v)
  19700. return nil
  19701. case payrecharge.FieldUserID:
  19702. v, ok := value.(string)
  19703. if !ok {
  19704. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19705. }
  19706. m.SetUserID(v)
  19707. return nil
  19708. case payrecharge.FieldNumber:
  19709. v, ok := value.(float32)
  19710. if !ok {
  19711. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19712. }
  19713. m.SetNumber(v)
  19714. return nil
  19715. case payrecharge.FieldStatus:
  19716. v, ok := value.(int)
  19717. if !ok {
  19718. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19719. }
  19720. m.SetStatus(v)
  19721. return nil
  19722. case payrecharge.FieldMoney:
  19723. v, ok := value.(float32)
  19724. if !ok {
  19725. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19726. }
  19727. m.SetMoney(v)
  19728. return nil
  19729. case payrecharge.FieldOutTradeNo:
  19730. v, ok := value.(string)
  19731. if !ok {
  19732. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19733. }
  19734. m.SetOutTradeNo(v)
  19735. return nil
  19736. case payrecharge.FieldOrganizationID:
  19737. v, ok := value.(uint64)
  19738. if !ok {
  19739. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19740. }
  19741. m.SetOrganizationID(v)
  19742. return nil
  19743. }
  19744. return fmt.Errorf("unknown PayRecharge field %s", name)
  19745. }
  19746. // AddedFields returns all numeric fields that were incremented/decremented during
  19747. // this mutation.
  19748. func (m *PayRechargeMutation) AddedFields() []string {
  19749. var fields []string
  19750. if m.addnumber != nil {
  19751. fields = append(fields, payrecharge.FieldNumber)
  19752. }
  19753. if m.addstatus != nil {
  19754. fields = append(fields, payrecharge.FieldStatus)
  19755. }
  19756. if m.addmoney != nil {
  19757. fields = append(fields, payrecharge.FieldMoney)
  19758. }
  19759. if m.addorganization_id != nil {
  19760. fields = append(fields, payrecharge.FieldOrganizationID)
  19761. }
  19762. return fields
  19763. }
  19764. // AddedField returns the numeric value that was incremented/decremented on a field
  19765. // with the given name. The second boolean return value indicates that this field
  19766. // was not set, or was not defined in the schema.
  19767. func (m *PayRechargeMutation) AddedField(name string) (ent.Value, bool) {
  19768. switch name {
  19769. case payrecharge.FieldNumber:
  19770. return m.AddedNumber()
  19771. case payrecharge.FieldStatus:
  19772. return m.AddedStatus()
  19773. case payrecharge.FieldMoney:
  19774. return m.AddedMoney()
  19775. case payrecharge.FieldOrganizationID:
  19776. return m.AddedOrganizationID()
  19777. }
  19778. return nil, false
  19779. }
  19780. // AddField adds the value to the field with the given name. It returns an error if
  19781. // the field is not defined in the schema, or if the type mismatched the field
  19782. // type.
  19783. func (m *PayRechargeMutation) AddField(name string, value ent.Value) error {
  19784. switch name {
  19785. case payrecharge.FieldNumber:
  19786. v, ok := value.(float32)
  19787. if !ok {
  19788. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19789. }
  19790. m.AddNumber(v)
  19791. return nil
  19792. case payrecharge.FieldStatus:
  19793. v, ok := value.(int)
  19794. if !ok {
  19795. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19796. }
  19797. m.AddStatus(v)
  19798. return nil
  19799. case payrecharge.FieldMoney:
  19800. v, ok := value.(float32)
  19801. if !ok {
  19802. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19803. }
  19804. m.AddMoney(v)
  19805. return nil
  19806. case payrecharge.FieldOrganizationID:
  19807. v, ok := value.(int64)
  19808. if !ok {
  19809. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19810. }
  19811. m.AddOrganizationID(v)
  19812. return nil
  19813. }
  19814. return fmt.Errorf("unknown PayRecharge numeric field %s", name)
  19815. }
  19816. // ClearedFields returns all nullable fields that were cleared during this
  19817. // mutation.
  19818. func (m *PayRechargeMutation) ClearedFields() []string {
  19819. var fields []string
  19820. if m.FieldCleared(payrecharge.FieldDeletedAt) {
  19821. fields = append(fields, payrecharge.FieldDeletedAt)
  19822. }
  19823. if m.FieldCleared(payrecharge.FieldStatus) {
  19824. fields = append(fields, payrecharge.FieldStatus)
  19825. }
  19826. if m.FieldCleared(payrecharge.FieldMoney) {
  19827. fields = append(fields, payrecharge.FieldMoney)
  19828. }
  19829. if m.FieldCleared(payrecharge.FieldOutTradeNo) {
  19830. fields = append(fields, payrecharge.FieldOutTradeNo)
  19831. }
  19832. return fields
  19833. }
  19834. // FieldCleared returns a boolean indicating if a field with the given name was
  19835. // cleared in this mutation.
  19836. func (m *PayRechargeMutation) FieldCleared(name string) bool {
  19837. _, ok := m.clearedFields[name]
  19838. return ok
  19839. }
  19840. // ClearField clears the value of the field with the given name. It returns an
  19841. // error if the field is not defined in the schema.
  19842. func (m *PayRechargeMutation) ClearField(name string) error {
  19843. switch name {
  19844. case payrecharge.FieldDeletedAt:
  19845. m.ClearDeletedAt()
  19846. return nil
  19847. case payrecharge.FieldStatus:
  19848. m.ClearStatus()
  19849. return nil
  19850. case payrecharge.FieldMoney:
  19851. m.ClearMoney()
  19852. return nil
  19853. case payrecharge.FieldOutTradeNo:
  19854. m.ClearOutTradeNo()
  19855. return nil
  19856. }
  19857. return fmt.Errorf("unknown PayRecharge nullable field %s", name)
  19858. }
  19859. // ResetField resets all changes in the mutation for the field with the given name.
  19860. // It returns an error if the field is not defined in the schema.
  19861. func (m *PayRechargeMutation) ResetField(name string) error {
  19862. switch name {
  19863. case payrecharge.FieldCreatedAt:
  19864. m.ResetCreatedAt()
  19865. return nil
  19866. case payrecharge.FieldUpdatedAt:
  19867. m.ResetUpdatedAt()
  19868. return nil
  19869. case payrecharge.FieldDeletedAt:
  19870. m.ResetDeletedAt()
  19871. return nil
  19872. case payrecharge.FieldUserID:
  19873. m.ResetUserID()
  19874. return nil
  19875. case payrecharge.FieldNumber:
  19876. m.ResetNumber()
  19877. return nil
  19878. case payrecharge.FieldStatus:
  19879. m.ResetStatus()
  19880. return nil
  19881. case payrecharge.FieldMoney:
  19882. m.ResetMoney()
  19883. return nil
  19884. case payrecharge.FieldOutTradeNo:
  19885. m.ResetOutTradeNo()
  19886. return nil
  19887. case payrecharge.FieldOrganizationID:
  19888. m.ResetOrganizationID()
  19889. return nil
  19890. }
  19891. return fmt.Errorf("unknown PayRecharge field %s", name)
  19892. }
  19893. // AddedEdges returns all edge names that were set/added in this mutation.
  19894. func (m *PayRechargeMutation) AddedEdges() []string {
  19895. edges := make([]string, 0, 0)
  19896. return edges
  19897. }
  19898. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  19899. // name in this mutation.
  19900. func (m *PayRechargeMutation) AddedIDs(name string) []ent.Value {
  19901. return nil
  19902. }
  19903. // RemovedEdges returns all edge names that were removed in this mutation.
  19904. func (m *PayRechargeMutation) RemovedEdges() []string {
  19905. edges := make([]string, 0, 0)
  19906. return edges
  19907. }
  19908. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  19909. // the given name in this mutation.
  19910. func (m *PayRechargeMutation) RemovedIDs(name string) []ent.Value {
  19911. return nil
  19912. }
  19913. // ClearedEdges returns all edge names that were cleared in this mutation.
  19914. func (m *PayRechargeMutation) ClearedEdges() []string {
  19915. edges := make([]string, 0, 0)
  19916. return edges
  19917. }
  19918. // EdgeCleared returns a boolean which indicates if the edge with the given name
  19919. // was cleared in this mutation.
  19920. func (m *PayRechargeMutation) EdgeCleared(name string) bool {
  19921. return false
  19922. }
  19923. // ClearEdge clears the value of the edge with the given name. It returns an error
  19924. // if that edge is not defined in the schema.
  19925. func (m *PayRechargeMutation) ClearEdge(name string) error {
  19926. return fmt.Errorf("unknown PayRecharge unique edge %s", name)
  19927. }
  19928. // ResetEdge resets all changes to the edge with the given name in this mutation.
  19929. // It returns an error if the edge is not defined in the schema.
  19930. func (m *PayRechargeMutation) ResetEdge(name string) error {
  19931. return fmt.Errorf("unknown PayRecharge edge %s", name)
  19932. }
  19933. // ServerMutation represents an operation that mutates the Server nodes in the graph.
  19934. type ServerMutation struct {
  19935. config
  19936. op Op
  19937. typ string
  19938. id *uint64
  19939. created_at *time.Time
  19940. updated_at *time.Time
  19941. status *uint8
  19942. addstatus *int8
  19943. deleted_at *time.Time
  19944. name *string
  19945. public_ip *string
  19946. private_ip *string
  19947. admin_port *string
  19948. clearedFields map[string]struct{}
  19949. wxs map[uint64]struct{}
  19950. removedwxs map[uint64]struct{}
  19951. clearedwxs bool
  19952. done bool
  19953. oldValue func(context.Context) (*Server, error)
  19954. predicates []predicate.Server
  19955. }
  19956. var _ ent.Mutation = (*ServerMutation)(nil)
  19957. // serverOption allows management of the mutation configuration using functional options.
  19958. type serverOption func(*ServerMutation)
  19959. // newServerMutation creates new mutation for the Server entity.
  19960. func newServerMutation(c config, op Op, opts ...serverOption) *ServerMutation {
  19961. m := &ServerMutation{
  19962. config: c,
  19963. op: op,
  19964. typ: TypeServer,
  19965. clearedFields: make(map[string]struct{}),
  19966. }
  19967. for _, opt := range opts {
  19968. opt(m)
  19969. }
  19970. return m
  19971. }
  19972. // withServerID sets the ID field of the mutation.
  19973. func withServerID(id uint64) serverOption {
  19974. return func(m *ServerMutation) {
  19975. var (
  19976. err error
  19977. once sync.Once
  19978. value *Server
  19979. )
  19980. m.oldValue = func(ctx context.Context) (*Server, error) {
  19981. once.Do(func() {
  19982. if m.done {
  19983. err = errors.New("querying old values post mutation is not allowed")
  19984. } else {
  19985. value, err = m.Client().Server.Get(ctx, id)
  19986. }
  19987. })
  19988. return value, err
  19989. }
  19990. m.id = &id
  19991. }
  19992. }
  19993. // withServer sets the old Server of the mutation.
  19994. func withServer(node *Server) serverOption {
  19995. return func(m *ServerMutation) {
  19996. m.oldValue = func(context.Context) (*Server, error) {
  19997. return node, nil
  19998. }
  19999. m.id = &node.ID
  20000. }
  20001. }
  20002. // Client returns a new `ent.Client` from the mutation. If the mutation was
  20003. // executed in a transaction (ent.Tx), a transactional client is returned.
  20004. func (m ServerMutation) Client() *Client {
  20005. client := &Client{config: m.config}
  20006. client.init()
  20007. return client
  20008. }
  20009. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  20010. // it returns an error otherwise.
  20011. func (m ServerMutation) Tx() (*Tx, error) {
  20012. if _, ok := m.driver.(*txDriver); !ok {
  20013. return nil, errors.New("ent: mutation is not running in a transaction")
  20014. }
  20015. tx := &Tx{config: m.config}
  20016. tx.init()
  20017. return tx, nil
  20018. }
  20019. // SetID sets the value of the id field. Note that this
  20020. // operation is only accepted on creation of Server entities.
  20021. func (m *ServerMutation) SetID(id uint64) {
  20022. m.id = &id
  20023. }
  20024. // ID returns the ID value in the mutation. Note that the ID is only available
  20025. // if it was provided to the builder or after it was returned from the database.
  20026. func (m *ServerMutation) ID() (id uint64, exists bool) {
  20027. if m.id == nil {
  20028. return
  20029. }
  20030. return *m.id, true
  20031. }
  20032. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  20033. // That means, if the mutation is applied within a transaction with an isolation level such
  20034. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  20035. // or updated by the mutation.
  20036. func (m *ServerMutation) IDs(ctx context.Context) ([]uint64, error) {
  20037. switch {
  20038. case m.op.Is(OpUpdateOne | OpDeleteOne):
  20039. id, exists := m.ID()
  20040. if exists {
  20041. return []uint64{id}, nil
  20042. }
  20043. fallthrough
  20044. case m.op.Is(OpUpdate | OpDelete):
  20045. return m.Client().Server.Query().Where(m.predicates...).IDs(ctx)
  20046. default:
  20047. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  20048. }
  20049. }
  20050. // SetCreatedAt sets the "created_at" field.
  20051. func (m *ServerMutation) SetCreatedAt(t time.Time) {
  20052. m.created_at = &t
  20053. }
  20054. // CreatedAt returns the value of the "created_at" field in the mutation.
  20055. func (m *ServerMutation) CreatedAt() (r time.Time, exists bool) {
  20056. v := m.created_at
  20057. if v == nil {
  20058. return
  20059. }
  20060. return *v, true
  20061. }
  20062. // OldCreatedAt returns the old "created_at" field's value of the Server entity.
  20063. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  20064. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20065. func (m *ServerMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  20066. if !m.op.Is(OpUpdateOne) {
  20067. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  20068. }
  20069. if m.id == nil || m.oldValue == nil {
  20070. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  20071. }
  20072. oldValue, err := m.oldValue(ctx)
  20073. if err != nil {
  20074. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  20075. }
  20076. return oldValue.CreatedAt, nil
  20077. }
  20078. // ResetCreatedAt resets all changes to the "created_at" field.
  20079. func (m *ServerMutation) ResetCreatedAt() {
  20080. m.created_at = nil
  20081. }
  20082. // SetUpdatedAt sets the "updated_at" field.
  20083. func (m *ServerMutation) SetUpdatedAt(t time.Time) {
  20084. m.updated_at = &t
  20085. }
  20086. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  20087. func (m *ServerMutation) UpdatedAt() (r time.Time, exists bool) {
  20088. v := m.updated_at
  20089. if v == nil {
  20090. return
  20091. }
  20092. return *v, true
  20093. }
  20094. // OldUpdatedAt returns the old "updated_at" field's value of the Server entity.
  20095. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  20096. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20097. func (m *ServerMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  20098. if !m.op.Is(OpUpdateOne) {
  20099. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  20100. }
  20101. if m.id == nil || m.oldValue == nil {
  20102. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  20103. }
  20104. oldValue, err := m.oldValue(ctx)
  20105. if err != nil {
  20106. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  20107. }
  20108. return oldValue.UpdatedAt, nil
  20109. }
  20110. // ResetUpdatedAt resets all changes to the "updated_at" field.
  20111. func (m *ServerMutation) ResetUpdatedAt() {
  20112. m.updated_at = nil
  20113. }
  20114. // SetStatus sets the "status" field.
  20115. func (m *ServerMutation) SetStatus(u uint8) {
  20116. m.status = &u
  20117. m.addstatus = nil
  20118. }
  20119. // Status returns the value of the "status" field in the mutation.
  20120. func (m *ServerMutation) Status() (r uint8, exists bool) {
  20121. v := m.status
  20122. if v == nil {
  20123. return
  20124. }
  20125. return *v, true
  20126. }
  20127. // OldStatus returns the old "status" field's value of the Server entity.
  20128. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  20129. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20130. func (m *ServerMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  20131. if !m.op.Is(OpUpdateOne) {
  20132. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  20133. }
  20134. if m.id == nil || m.oldValue == nil {
  20135. return v, errors.New("OldStatus requires an ID field in the mutation")
  20136. }
  20137. oldValue, err := m.oldValue(ctx)
  20138. if err != nil {
  20139. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  20140. }
  20141. return oldValue.Status, nil
  20142. }
  20143. // AddStatus adds u to the "status" field.
  20144. func (m *ServerMutation) AddStatus(u int8) {
  20145. if m.addstatus != nil {
  20146. *m.addstatus += u
  20147. } else {
  20148. m.addstatus = &u
  20149. }
  20150. }
  20151. // AddedStatus returns the value that was added to the "status" field in this mutation.
  20152. func (m *ServerMutation) AddedStatus() (r int8, exists bool) {
  20153. v := m.addstatus
  20154. if v == nil {
  20155. return
  20156. }
  20157. return *v, true
  20158. }
  20159. // ClearStatus clears the value of the "status" field.
  20160. func (m *ServerMutation) ClearStatus() {
  20161. m.status = nil
  20162. m.addstatus = nil
  20163. m.clearedFields[server.FieldStatus] = struct{}{}
  20164. }
  20165. // StatusCleared returns if the "status" field was cleared in this mutation.
  20166. func (m *ServerMutation) StatusCleared() bool {
  20167. _, ok := m.clearedFields[server.FieldStatus]
  20168. return ok
  20169. }
  20170. // ResetStatus resets all changes to the "status" field.
  20171. func (m *ServerMutation) ResetStatus() {
  20172. m.status = nil
  20173. m.addstatus = nil
  20174. delete(m.clearedFields, server.FieldStatus)
  20175. }
  20176. // SetDeletedAt sets the "deleted_at" field.
  20177. func (m *ServerMutation) SetDeletedAt(t time.Time) {
  20178. m.deleted_at = &t
  20179. }
  20180. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  20181. func (m *ServerMutation) DeletedAt() (r time.Time, exists bool) {
  20182. v := m.deleted_at
  20183. if v == nil {
  20184. return
  20185. }
  20186. return *v, true
  20187. }
  20188. // OldDeletedAt returns the old "deleted_at" field's value of the Server entity.
  20189. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  20190. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20191. func (m *ServerMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  20192. if !m.op.Is(OpUpdateOne) {
  20193. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  20194. }
  20195. if m.id == nil || m.oldValue == nil {
  20196. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  20197. }
  20198. oldValue, err := m.oldValue(ctx)
  20199. if err != nil {
  20200. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  20201. }
  20202. return oldValue.DeletedAt, nil
  20203. }
  20204. // ClearDeletedAt clears the value of the "deleted_at" field.
  20205. func (m *ServerMutation) ClearDeletedAt() {
  20206. m.deleted_at = nil
  20207. m.clearedFields[server.FieldDeletedAt] = struct{}{}
  20208. }
  20209. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  20210. func (m *ServerMutation) DeletedAtCleared() bool {
  20211. _, ok := m.clearedFields[server.FieldDeletedAt]
  20212. return ok
  20213. }
  20214. // ResetDeletedAt resets all changes to the "deleted_at" field.
  20215. func (m *ServerMutation) ResetDeletedAt() {
  20216. m.deleted_at = nil
  20217. delete(m.clearedFields, server.FieldDeletedAt)
  20218. }
  20219. // SetName sets the "name" field.
  20220. func (m *ServerMutation) SetName(s string) {
  20221. m.name = &s
  20222. }
  20223. // Name returns the value of the "name" field in the mutation.
  20224. func (m *ServerMutation) Name() (r string, exists bool) {
  20225. v := m.name
  20226. if v == nil {
  20227. return
  20228. }
  20229. return *v, true
  20230. }
  20231. // OldName returns the old "name" field's value of the Server entity.
  20232. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  20233. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20234. func (m *ServerMutation) OldName(ctx context.Context) (v string, err error) {
  20235. if !m.op.Is(OpUpdateOne) {
  20236. return v, errors.New("OldName is only allowed on UpdateOne operations")
  20237. }
  20238. if m.id == nil || m.oldValue == nil {
  20239. return v, errors.New("OldName requires an ID field in the mutation")
  20240. }
  20241. oldValue, err := m.oldValue(ctx)
  20242. if err != nil {
  20243. return v, fmt.Errorf("querying old value for OldName: %w", err)
  20244. }
  20245. return oldValue.Name, nil
  20246. }
  20247. // ResetName resets all changes to the "name" field.
  20248. func (m *ServerMutation) ResetName() {
  20249. m.name = nil
  20250. }
  20251. // SetPublicIP sets the "public_ip" field.
  20252. func (m *ServerMutation) SetPublicIP(s string) {
  20253. m.public_ip = &s
  20254. }
  20255. // PublicIP returns the value of the "public_ip" field in the mutation.
  20256. func (m *ServerMutation) PublicIP() (r string, exists bool) {
  20257. v := m.public_ip
  20258. if v == nil {
  20259. return
  20260. }
  20261. return *v, true
  20262. }
  20263. // OldPublicIP returns the old "public_ip" field's value of the Server entity.
  20264. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  20265. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20266. func (m *ServerMutation) OldPublicIP(ctx context.Context) (v string, err error) {
  20267. if !m.op.Is(OpUpdateOne) {
  20268. return v, errors.New("OldPublicIP is only allowed on UpdateOne operations")
  20269. }
  20270. if m.id == nil || m.oldValue == nil {
  20271. return v, errors.New("OldPublicIP requires an ID field in the mutation")
  20272. }
  20273. oldValue, err := m.oldValue(ctx)
  20274. if err != nil {
  20275. return v, fmt.Errorf("querying old value for OldPublicIP: %w", err)
  20276. }
  20277. return oldValue.PublicIP, nil
  20278. }
  20279. // ResetPublicIP resets all changes to the "public_ip" field.
  20280. func (m *ServerMutation) ResetPublicIP() {
  20281. m.public_ip = nil
  20282. }
  20283. // SetPrivateIP sets the "private_ip" field.
  20284. func (m *ServerMutation) SetPrivateIP(s string) {
  20285. m.private_ip = &s
  20286. }
  20287. // PrivateIP returns the value of the "private_ip" field in the mutation.
  20288. func (m *ServerMutation) PrivateIP() (r string, exists bool) {
  20289. v := m.private_ip
  20290. if v == nil {
  20291. return
  20292. }
  20293. return *v, true
  20294. }
  20295. // OldPrivateIP returns the old "private_ip" field's value of the Server entity.
  20296. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  20297. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20298. func (m *ServerMutation) OldPrivateIP(ctx context.Context) (v string, err error) {
  20299. if !m.op.Is(OpUpdateOne) {
  20300. return v, errors.New("OldPrivateIP is only allowed on UpdateOne operations")
  20301. }
  20302. if m.id == nil || m.oldValue == nil {
  20303. return v, errors.New("OldPrivateIP requires an ID field in the mutation")
  20304. }
  20305. oldValue, err := m.oldValue(ctx)
  20306. if err != nil {
  20307. return v, fmt.Errorf("querying old value for OldPrivateIP: %w", err)
  20308. }
  20309. return oldValue.PrivateIP, nil
  20310. }
  20311. // ResetPrivateIP resets all changes to the "private_ip" field.
  20312. func (m *ServerMutation) ResetPrivateIP() {
  20313. m.private_ip = nil
  20314. }
  20315. // SetAdminPort sets the "admin_port" field.
  20316. func (m *ServerMutation) SetAdminPort(s string) {
  20317. m.admin_port = &s
  20318. }
  20319. // AdminPort returns the value of the "admin_port" field in the mutation.
  20320. func (m *ServerMutation) AdminPort() (r string, exists bool) {
  20321. v := m.admin_port
  20322. if v == nil {
  20323. return
  20324. }
  20325. return *v, true
  20326. }
  20327. // OldAdminPort returns the old "admin_port" field's value of the Server entity.
  20328. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  20329. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20330. func (m *ServerMutation) OldAdminPort(ctx context.Context) (v string, err error) {
  20331. if !m.op.Is(OpUpdateOne) {
  20332. return v, errors.New("OldAdminPort is only allowed on UpdateOne operations")
  20333. }
  20334. if m.id == nil || m.oldValue == nil {
  20335. return v, errors.New("OldAdminPort requires an ID field in the mutation")
  20336. }
  20337. oldValue, err := m.oldValue(ctx)
  20338. if err != nil {
  20339. return v, fmt.Errorf("querying old value for OldAdminPort: %w", err)
  20340. }
  20341. return oldValue.AdminPort, nil
  20342. }
  20343. // ResetAdminPort resets all changes to the "admin_port" field.
  20344. func (m *ServerMutation) ResetAdminPort() {
  20345. m.admin_port = nil
  20346. }
  20347. // AddWxIDs adds the "wxs" edge to the Wx entity by ids.
  20348. func (m *ServerMutation) AddWxIDs(ids ...uint64) {
  20349. if m.wxs == nil {
  20350. m.wxs = make(map[uint64]struct{})
  20351. }
  20352. for i := range ids {
  20353. m.wxs[ids[i]] = struct{}{}
  20354. }
  20355. }
  20356. // ClearWxs clears the "wxs" edge to the Wx entity.
  20357. func (m *ServerMutation) ClearWxs() {
  20358. m.clearedwxs = true
  20359. }
  20360. // WxsCleared reports if the "wxs" edge to the Wx entity was cleared.
  20361. func (m *ServerMutation) WxsCleared() bool {
  20362. return m.clearedwxs
  20363. }
  20364. // RemoveWxIDs removes the "wxs" edge to the Wx entity by IDs.
  20365. func (m *ServerMutation) RemoveWxIDs(ids ...uint64) {
  20366. if m.removedwxs == nil {
  20367. m.removedwxs = make(map[uint64]struct{})
  20368. }
  20369. for i := range ids {
  20370. delete(m.wxs, ids[i])
  20371. m.removedwxs[ids[i]] = struct{}{}
  20372. }
  20373. }
  20374. // RemovedWxs returns the removed IDs of the "wxs" edge to the Wx entity.
  20375. func (m *ServerMutation) RemovedWxsIDs() (ids []uint64) {
  20376. for id := range m.removedwxs {
  20377. ids = append(ids, id)
  20378. }
  20379. return
  20380. }
  20381. // WxsIDs returns the "wxs" edge IDs in the mutation.
  20382. func (m *ServerMutation) WxsIDs() (ids []uint64) {
  20383. for id := range m.wxs {
  20384. ids = append(ids, id)
  20385. }
  20386. return
  20387. }
  20388. // ResetWxs resets all changes to the "wxs" edge.
  20389. func (m *ServerMutation) ResetWxs() {
  20390. m.wxs = nil
  20391. m.clearedwxs = false
  20392. m.removedwxs = nil
  20393. }
  20394. // Where appends a list predicates to the ServerMutation builder.
  20395. func (m *ServerMutation) Where(ps ...predicate.Server) {
  20396. m.predicates = append(m.predicates, ps...)
  20397. }
  20398. // WhereP appends storage-level predicates to the ServerMutation builder. Using this method,
  20399. // users can use type-assertion to append predicates that do not depend on any generated package.
  20400. func (m *ServerMutation) WhereP(ps ...func(*sql.Selector)) {
  20401. p := make([]predicate.Server, len(ps))
  20402. for i := range ps {
  20403. p[i] = ps[i]
  20404. }
  20405. m.Where(p...)
  20406. }
  20407. // Op returns the operation name.
  20408. func (m *ServerMutation) Op() Op {
  20409. return m.op
  20410. }
  20411. // SetOp allows setting the mutation operation.
  20412. func (m *ServerMutation) SetOp(op Op) {
  20413. m.op = op
  20414. }
  20415. // Type returns the node type of this mutation (Server).
  20416. func (m *ServerMutation) Type() string {
  20417. return m.typ
  20418. }
  20419. // Fields returns all fields that were changed during this mutation. Note that in
  20420. // order to get all numeric fields that were incremented/decremented, call
  20421. // AddedFields().
  20422. func (m *ServerMutation) Fields() []string {
  20423. fields := make([]string, 0, 8)
  20424. if m.created_at != nil {
  20425. fields = append(fields, server.FieldCreatedAt)
  20426. }
  20427. if m.updated_at != nil {
  20428. fields = append(fields, server.FieldUpdatedAt)
  20429. }
  20430. if m.status != nil {
  20431. fields = append(fields, server.FieldStatus)
  20432. }
  20433. if m.deleted_at != nil {
  20434. fields = append(fields, server.FieldDeletedAt)
  20435. }
  20436. if m.name != nil {
  20437. fields = append(fields, server.FieldName)
  20438. }
  20439. if m.public_ip != nil {
  20440. fields = append(fields, server.FieldPublicIP)
  20441. }
  20442. if m.private_ip != nil {
  20443. fields = append(fields, server.FieldPrivateIP)
  20444. }
  20445. if m.admin_port != nil {
  20446. fields = append(fields, server.FieldAdminPort)
  20447. }
  20448. return fields
  20449. }
  20450. // Field returns the value of a field with the given name. The second boolean
  20451. // return value indicates that this field was not set, or was not defined in the
  20452. // schema.
  20453. func (m *ServerMutation) Field(name string) (ent.Value, bool) {
  20454. switch name {
  20455. case server.FieldCreatedAt:
  20456. return m.CreatedAt()
  20457. case server.FieldUpdatedAt:
  20458. return m.UpdatedAt()
  20459. case server.FieldStatus:
  20460. return m.Status()
  20461. case server.FieldDeletedAt:
  20462. return m.DeletedAt()
  20463. case server.FieldName:
  20464. return m.Name()
  20465. case server.FieldPublicIP:
  20466. return m.PublicIP()
  20467. case server.FieldPrivateIP:
  20468. return m.PrivateIP()
  20469. case server.FieldAdminPort:
  20470. return m.AdminPort()
  20471. }
  20472. return nil, false
  20473. }
  20474. // OldField returns the old value of the field from the database. An error is
  20475. // returned if the mutation operation is not UpdateOne, or the query to the
  20476. // database failed.
  20477. func (m *ServerMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  20478. switch name {
  20479. case server.FieldCreatedAt:
  20480. return m.OldCreatedAt(ctx)
  20481. case server.FieldUpdatedAt:
  20482. return m.OldUpdatedAt(ctx)
  20483. case server.FieldStatus:
  20484. return m.OldStatus(ctx)
  20485. case server.FieldDeletedAt:
  20486. return m.OldDeletedAt(ctx)
  20487. case server.FieldName:
  20488. return m.OldName(ctx)
  20489. case server.FieldPublicIP:
  20490. return m.OldPublicIP(ctx)
  20491. case server.FieldPrivateIP:
  20492. return m.OldPrivateIP(ctx)
  20493. case server.FieldAdminPort:
  20494. return m.OldAdminPort(ctx)
  20495. }
  20496. return nil, fmt.Errorf("unknown Server field %s", name)
  20497. }
  20498. // SetField sets the value of a field with the given name. It returns an error if
  20499. // the field is not defined in the schema, or if the type mismatched the field
  20500. // type.
  20501. func (m *ServerMutation) SetField(name string, value ent.Value) error {
  20502. switch name {
  20503. case server.FieldCreatedAt:
  20504. v, ok := value.(time.Time)
  20505. if !ok {
  20506. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20507. }
  20508. m.SetCreatedAt(v)
  20509. return nil
  20510. case server.FieldUpdatedAt:
  20511. v, ok := value.(time.Time)
  20512. if !ok {
  20513. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20514. }
  20515. m.SetUpdatedAt(v)
  20516. return nil
  20517. case server.FieldStatus:
  20518. v, ok := value.(uint8)
  20519. if !ok {
  20520. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20521. }
  20522. m.SetStatus(v)
  20523. return nil
  20524. case server.FieldDeletedAt:
  20525. v, ok := value.(time.Time)
  20526. if !ok {
  20527. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20528. }
  20529. m.SetDeletedAt(v)
  20530. return nil
  20531. case server.FieldName:
  20532. v, ok := value.(string)
  20533. if !ok {
  20534. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20535. }
  20536. m.SetName(v)
  20537. return nil
  20538. case server.FieldPublicIP:
  20539. v, ok := value.(string)
  20540. if !ok {
  20541. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20542. }
  20543. m.SetPublicIP(v)
  20544. return nil
  20545. case server.FieldPrivateIP:
  20546. v, ok := value.(string)
  20547. if !ok {
  20548. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20549. }
  20550. m.SetPrivateIP(v)
  20551. return nil
  20552. case server.FieldAdminPort:
  20553. v, ok := value.(string)
  20554. if !ok {
  20555. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20556. }
  20557. m.SetAdminPort(v)
  20558. return nil
  20559. }
  20560. return fmt.Errorf("unknown Server field %s", name)
  20561. }
  20562. // AddedFields returns all numeric fields that were incremented/decremented during
  20563. // this mutation.
  20564. func (m *ServerMutation) AddedFields() []string {
  20565. var fields []string
  20566. if m.addstatus != nil {
  20567. fields = append(fields, server.FieldStatus)
  20568. }
  20569. return fields
  20570. }
  20571. // AddedField returns the numeric value that was incremented/decremented on a field
  20572. // with the given name. The second boolean return value indicates that this field
  20573. // was not set, or was not defined in the schema.
  20574. func (m *ServerMutation) AddedField(name string) (ent.Value, bool) {
  20575. switch name {
  20576. case server.FieldStatus:
  20577. return m.AddedStatus()
  20578. }
  20579. return nil, false
  20580. }
  20581. // AddField adds the value to the field with the given name. It returns an error if
  20582. // the field is not defined in the schema, or if the type mismatched the field
  20583. // type.
  20584. func (m *ServerMutation) AddField(name string, value ent.Value) error {
  20585. switch name {
  20586. case server.FieldStatus:
  20587. v, ok := value.(int8)
  20588. if !ok {
  20589. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20590. }
  20591. m.AddStatus(v)
  20592. return nil
  20593. }
  20594. return fmt.Errorf("unknown Server numeric field %s", name)
  20595. }
  20596. // ClearedFields returns all nullable fields that were cleared during this
  20597. // mutation.
  20598. func (m *ServerMutation) ClearedFields() []string {
  20599. var fields []string
  20600. if m.FieldCleared(server.FieldStatus) {
  20601. fields = append(fields, server.FieldStatus)
  20602. }
  20603. if m.FieldCleared(server.FieldDeletedAt) {
  20604. fields = append(fields, server.FieldDeletedAt)
  20605. }
  20606. return fields
  20607. }
  20608. // FieldCleared returns a boolean indicating if a field with the given name was
  20609. // cleared in this mutation.
  20610. func (m *ServerMutation) FieldCleared(name string) bool {
  20611. _, ok := m.clearedFields[name]
  20612. return ok
  20613. }
  20614. // ClearField clears the value of the field with the given name. It returns an
  20615. // error if the field is not defined in the schema.
  20616. func (m *ServerMutation) ClearField(name string) error {
  20617. switch name {
  20618. case server.FieldStatus:
  20619. m.ClearStatus()
  20620. return nil
  20621. case server.FieldDeletedAt:
  20622. m.ClearDeletedAt()
  20623. return nil
  20624. }
  20625. return fmt.Errorf("unknown Server nullable field %s", name)
  20626. }
  20627. // ResetField resets all changes in the mutation for the field with the given name.
  20628. // It returns an error if the field is not defined in the schema.
  20629. func (m *ServerMutation) ResetField(name string) error {
  20630. switch name {
  20631. case server.FieldCreatedAt:
  20632. m.ResetCreatedAt()
  20633. return nil
  20634. case server.FieldUpdatedAt:
  20635. m.ResetUpdatedAt()
  20636. return nil
  20637. case server.FieldStatus:
  20638. m.ResetStatus()
  20639. return nil
  20640. case server.FieldDeletedAt:
  20641. m.ResetDeletedAt()
  20642. return nil
  20643. case server.FieldName:
  20644. m.ResetName()
  20645. return nil
  20646. case server.FieldPublicIP:
  20647. m.ResetPublicIP()
  20648. return nil
  20649. case server.FieldPrivateIP:
  20650. m.ResetPrivateIP()
  20651. return nil
  20652. case server.FieldAdminPort:
  20653. m.ResetAdminPort()
  20654. return nil
  20655. }
  20656. return fmt.Errorf("unknown Server field %s", name)
  20657. }
  20658. // AddedEdges returns all edge names that were set/added in this mutation.
  20659. func (m *ServerMutation) AddedEdges() []string {
  20660. edges := make([]string, 0, 1)
  20661. if m.wxs != nil {
  20662. edges = append(edges, server.EdgeWxs)
  20663. }
  20664. return edges
  20665. }
  20666. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  20667. // name in this mutation.
  20668. func (m *ServerMutation) AddedIDs(name string) []ent.Value {
  20669. switch name {
  20670. case server.EdgeWxs:
  20671. ids := make([]ent.Value, 0, len(m.wxs))
  20672. for id := range m.wxs {
  20673. ids = append(ids, id)
  20674. }
  20675. return ids
  20676. }
  20677. return nil
  20678. }
  20679. // RemovedEdges returns all edge names that were removed in this mutation.
  20680. func (m *ServerMutation) RemovedEdges() []string {
  20681. edges := make([]string, 0, 1)
  20682. if m.removedwxs != nil {
  20683. edges = append(edges, server.EdgeWxs)
  20684. }
  20685. return edges
  20686. }
  20687. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  20688. // the given name in this mutation.
  20689. func (m *ServerMutation) RemovedIDs(name string) []ent.Value {
  20690. switch name {
  20691. case server.EdgeWxs:
  20692. ids := make([]ent.Value, 0, len(m.removedwxs))
  20693. for id := range m.removedwxs {
  20694. ids = append(ids, id)
  20695. }
  20696. return ids
  20697. }
  20698. return nil
  20699. }
  20700. // ClearedEdges returns all edge names that were cleared in this mutation.
  20701. func (m *ServerMutation) ClearedEdges() []string {
  20702. edges := make([]string, 0, 1)
  20703. if m.clearedwxs {
  20704. edges = append(edges, server.EdgeWxs)
  20705. }
  20706. return edges
  20707. }
  20708. // EdgeCleared returns a boolean which indicates if the edge with the given name
  20709. // was cleared in this mutation.
  20710. func (m *ServerMutation) EdgeCleared(name string) bool {
  20711. switch name {
  20712. case server.EdgeWxs:
  20713. return m.clearedwxs
  20714. }
  20715. return false
  20716. }
  20717. // ClearEdge clears the value of the edge with the given name. It returns an error
  20718. // if that edge is not defined in the schema.
  20719. func (m *ServerMutation) ClearEdge(name string) error {
  20720. switch name {
  20721. }
  20722. return fmt.Errorf("unknown Server unique edge %s", name)
  20723. }
  20724. // ResetEdge resets all changes to the edge with the given name in this mutation.
  20725. // It returns an error if the edge is not defined in the schema.
  20726. func (m *ServerMutation) ResetEdge(name string) error {
  20727. switch name {
  20728. case server.EdgeWxs:
  20729. m.ResetWxs()
  20730. return nil
  20731. }
  20732. return fmt.Errorf("unknown Server edge %s", name)
  20733. }
  20734. // SopNodeMutation represents an operation that mutates the SopNode nodes in the graph.
  20735. type SopNodeMutation struct {
  20736. config
  20737. op Op
  20738. typ string
  20739. id *uint64
  20740. created_at *time.Time
  20741. updated_at *time.Time
  20742. status *uint8
  20743. addstatus *int8
  20744. deleted_at *time.Time
  20745. parent_id *uint64
  20746. addparent_id *int64
  20747. name *string
  20748. condition_type *int
  20749. addcondition_type *int
  20750. condition_list *[]string
  20751. appendcondition_list []string
  20752. no_reply_condition *uint64
  20753. addno_reply_condition *int64
  20754. no_reply_unit *string
  20755. action_message *[]custom_types.Action
  20756. appendaction_message []custom_types.Action
  20757. action_label_add *[]uint64
  20758. appendaction_label_add []uint64
  20759. action_label_del *[]uint64
  20760. appendaction_label_del []uint64
  20761. action_forward **custom_types.ActionForward
  20762. clearedFields map[string]struct{}
  20763. sop_stage *uint64
  20764. clearedsop_stage bool
  20765. node_messages map[uint64]struct{}
  20766. removednode_messages map[uint64]struct{}
  20767. clearednode_messages bool
  20768. done bool
  20769. oldValue func(context.Context) (*SopNode, error)
  20770. predicates []predicate.SopNode
  20771. }
  20772. var _ ent.Mutation = (*SopNodeMutation)(nil)
  20773. // sopnodeOption allows management of the mutation configuration using functional options.
  20774. type sopnodeOption func(*SopNodeMutation)
  20775. // newSopNodeMutation creates new mutation for the SopNode entity.
  20776. func newSopNodeMutation(c config, op Op, opts ...sopnodeOption) *SopNodeMutation {
  20777. m := &SopNodeMutation{
  20778. config: c,
  20779. op: op,
  20780. typ: TypeSopNode,
  20781. clearedFields: make(map[string]struct{}),
  20782. }
  20783. for _, opt := range opts {
  20784. opt(m)
  20785. }
  20786. return m
  20787. }
  20788. // withSopNodeID sets the ID field of the mutation.
  20789. func withSopNodeID(id uint64) sopnodeOption {
  20790. return func(m *SopNodeMutation) {
  20791. var (
  20792. err error
  20793. once sync.Once
  20794. value *SopNode
  20795. )
  20796. m.oldValue = func(ctx context.Context) (*SopNode, error) {
  20797. once.Do(func() {
  20798. if m.done {
  20799. err = errors.New("querying old values post mutation is not allowed")
  20800. } else {
  20801. value, err = m.Client().SopNode.Get(ctx, id)
  20802. }
  20803. })
  20804. return value, err
  20805. }
  20806. m.id = &id
  20807. }
  20808. }
  20809. // withSopNode sets the old SopNode of the mutation.
  20810. func withSopNode(node *SopNode) sopnodeOption {
  20811. return func(m *SopNodeMutation) {
  20812. m.oldValue = func(context.Context) (*SopNode, error) {
  20813. return node, nil
  20814. }
  20815. m.id = &node.ID
  20816. }
  20817. }
  20818. // Client returns a new `ent.Client` from the mutation. If the mutation was
  20819. // executed in a transaction (ent.Tx), a transactional client is returned.
  20820. func (m SopNodeMutation) Client() *Client {
  20821. client := &Client{config: m.config}
  20822. client.init()
  20823. return client
  20824. }
  20825. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  20826. // it returns an error otherwise.
  20827. func (m SopNodeMutation) Tx() (*Tx, error) {
  20828. if _, ok := m.driver.(*txDriver); !ok {
  20829. return nil, errors.New("ent: mutation is not running in a transaction")
  20830. }
  20831. tx := &Tx{config: m.config}
  20832. tx.init()
  20833. return tx, nil
  20834. }
  20835. // SetID sets the value of the id field. Note that this
  20836. // operation is only accepted on creation of SopNode entities.
  20837. func (m *SopNodeMutation) SetID(id uint64) {
  20838. m.id = &id
  20839. }
  20840. // ID returns the ID value in the mutation. Note that the ID is only available
  20841. // if it was provided to the builder or after it was returned from the database.
  20842. func (m *SopNodeMutation) ID() (id uint64, exists bool) {
  20843. if m.id == nil {
  20844. return
  20845. }
  20846. return *m.id, true
  20847. }
  20848. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  20849. // That means, if the mutation is applied within a transaction with an isolation level such
  20850. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  20851. // or updated by the mutation.
  20852. func (m *SopNodeMutation) IDs(ctx context.Context) ([]uint64, error) {
  20853. switch {
  20854. case m.op.Is(OpUpdateOne | OpDeleteOne):
  20855. id, exists := m.ID()
  20856. if exists {
  20857. return []uint64{id}, nil
  20858. }
  20859. fallthrough
  20860. case m.op.Is(OpUpdate | OpDelete):
  20861. return m.Client().SopNode.Query().Where(m.predicates...).IDs(ctx)
  20862. default:
  20863. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  20864. }
  20865. }
  20866. // SetCreatedAt sets the "created_at" field.
  20867. func (m *SopNodeMutation) SetCreatedAt(t time.Time) {
  20868. m.created_at = &t
  20869. }
  20870. // CreatedAt returns the value of the "created_at" field in the mutation.
  20871. func (m *SopNodeMutation) CreatedAt() (r time.Time, exists bool) {
  20872. v := m.created_at
  20873. if v == nil {
  20874. return
  20875. }
  20876. return *v, true
  20877. }
  20878. // OldCreatedAt returns the old "created_at" field's value of the SopNode entity.
  20879. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  20880. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20881. func (m *SopNodeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  20882. if !m.op.Is(OpUpdateOne) {
  20883. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  20884. }
  20885. if m.id == nil || m.oldValue == nil {
  20886. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  20887. }
  20888. oldValue, err := m.oldValue(ctx)
  20889. if err != nil {
  20890. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  20891. }
  20892. return oldValue.CreatedAt, nil
  20893. }
  20894. // ResetCreatedAt resets all changes to the "created_at" field.
  20895. func (m *SopNodeMutation) ResetCreatedAt() {
  20896. m.created_at = nil
  20897. }
  20898. // SetUpdatedAt sets the "updated_at" field.
  20899. func (m *SopNodeMutation) SetUpdatedAt(t time.Time) {
  20900. m.updated_at = &t
  20901. }
  20902. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  20903. func (m *SopNodeMutation) UpdatedAt() (r time.Time, exists bool) {
  20904. v := m.updated_at
  20905. if v == nil {
  20906. return
  20907. }
  20908. return *v, true
  20909. }
  20910. // OldUpdatedAt returns the old "updated_at" field's value of the SopNode entity.
  20911. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  20912. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20913. func (m *SopNodeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  20914. if !m.op.Is(OpUpdateOne) {
  20915. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  20916. }
  20917. if m.id == nil || m.oldValue == nil {
  20918. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  20919. }
  20920. oldValue, err := m.oldValue(ctx)
  20921. if err != nil {
  20922. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  20923. }
  20924. return oldValue.UpdatedAt, nil
  20925. }
  20926. // ResetUpdatedAt resets all changes to the "updated_at" field.
  20927. func (m *SopNodeMutation) ResetUpdatedAt() {
  20928. m.updated_at = nil
  20929. }
  20930. // SetStatus sets the "status" field.
  20931. func (m *SopNodeMutation) SetStatus(u uint8) {
  20932. m.status = &u
  20933. m.addstatus = nil
  20934. }
  20935. // Status returns the value of the "status" field in the mutation.
  20936. func (m *SopNodeMutation) Status() (r uint8, exists bool) {
  20937. v := m.status
  20938. if v == nil {
  20939. return
  20940. }
  20941. return *v, true
  20942. }
  20943. // OldStatus returns the old "status" field's value of the SopNode entity.
  20944. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  20945. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20946. func (m *SopNodeMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  20947. if !m.op.Is(OpUpdateOne) {
  20948. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  20949. }
  20950. if m.id == nil || m.oldValue == nil {
  20951. return v, errors.New("OldStatus requires an ID field in the mutation")
  20952. }
  20953. oldValue, err := m.oldValue(ctx)
  20954. if err != nil {
  20955. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  20956. }
  20957. return oldValue.Status, nil
  20958. }
  20959. // AddStatus adds u to the "status" field.
  20960. func (m *SopNodeMutation) AddStatus(u int8) {
  20961. if m.addstatus != nil {
  20962. *m.addstatus += u
  20963. } else {
  20964. m.addstatus = &u
  20965. }
  20966. }
  20967. // AddedStatus returns the value that was added to the "status" field in this mutation.
  20968. func (m *SopNodeMutation) AddedStatus() (r int8, exists bool) {
  20969. v := m.addstatus
  20970. if v == nil {
  20971. return
  20972. }
  20973. return *v, true
  20974. }
  20975. // ClearStatus clears the value of the "status" field.
  20976. func (m *SopNodeMutation) ClearStatus() {
  20977. m.status = nil
  20978. m.addstatus = nil
  20979. m.clearedFields[sopnode.FieldStatus] = struct{}{}
  20980. }
  20981. // StatusCleared returns if the "status" field was cleared in this mutation.
  20982. func (m *SopNodeMutation) StatusCleared() bool {
  20983. _, ok := m.clearedFields[sopnode.FieldStatus]
  20984. return ok
  20985. }
  20986. // ResetStatus resets all changes to the "status" field.
  20987. func (m *SopNodeMutation) ResetStatus() {
  20988. m.status = nil
  20989. m.addstatus = nil
  20990. delete(m.clearedFields, sopnode.FieldStatus)
  20991. }
  20992. // SetDeletedAt sets the "deleted_at" field.
  20993. func (m *SopNodeMutation) SetDeletedAt(t time.Time) {
  20994. m.deleted_at = &t
  20995. }
  20996. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  20997. func (m *SopNodeMutation) DeletedAt() (r time.Time, exists bool) {
  20998. v := m.deleted_at
  20999. if v == nil {
  21000. return
  21001. }
  21002. return *v, true
  21003. }
  21004. // OldDeletedAt returns the old "deleted_at" field's value of the SopNode entity.
  21005. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21006. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21007. func (m *SopNodeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  21008. if !m.op.Is(OpUpdateOne) {
  21009. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  21010. }
  21011. if m.id == nil || m.oldValue == nil {
  21012. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  21013. }
  21014. oldValue, err := m.oldValue(ctx)
  21015. if err != nil {
  21016. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  21017. }
  21018. return oldValue.DeletedAt, nil
  21019. }
  21020. // ClearDeletedAt clears the value of the "deleted_at" field.
  21021. func (m *SopNodeMutation) ClearDeletedAt() {
  21022. m.deleted_at = nil
  21023. m.clearedFields[sopnode.FieldDeletedAt] = struct{}{}
  21024. }
  21025. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  21026. func (m *SopNodeMutation) DeletedAtCleared() bool {
  21027. _, ok := m.clearedFields[sopnode.FieldDeletedAt]
  21028. return ok
  21029. }
  21030. // ResetDeletedAt resets all changes to the "deleted_at" field.
  21031. func (m *SopNodeMutation) ResetDeletedAt() {
  21032. m.deleted_at = nil
  21033. delete(m.clearedFields, sopnode.FieldDeletedAt)
  21034. }
  21035. // SetStageID sets the "stage_id" field.
  21036. func (m *SopNodeMutation) SetStageID(u uint64) {
  21037. m.sop_stage = &u
  21038. }
  21039. // StageID returns the value of the "stage_id" field in the mutation.
  21040. func (m *SopNodeMutation) StageID() (r uint64, exists bool) {
  21041. v := m.sop_stage
  21042. if v == nil {
  21043. return
  21044. }
  21045. return *v, true
  21046. }
  21047. // OldStageID returns the old "stage_id" field's value of the SopNode entity.
  21048. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21049. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21050. func (m *SopNodeMutation) OldStageID(ctx context.Context) (v uint64, err error) {
  21051. if !m.op.Is(OpUpdateOne) {
  21052. return v, errors.New("OldStageID is only allowed on UpdateOne operations")
  21053. }
  21054. if m.id == nil || m.oldValue == nil {
  21055. return v, errors.New("OldStageID requires an ID field in the mutation")
  21056. }
  21057. oldValue, err := m.oldValue(ctx)
  21058. if err != nil {
  21059. return v, fmt.Errorf("querying old value for OldStageID: %w", err)
  21060. }
  21061. return oldValue.StageID, nil
  21062. }
  21063. // ResetStageID resets all changes to the "stage_id" field.
  21064. func (m *SopNodeMutation) ResetStageID() {
  21065. m.sop_stage = nil
  21066. }
  21067. // SetParentID sets the "parent_id" field.
  21068. func (m *SopNodeMutation) SetParentID(u uint64) {
  21069. m.parent_id = &u
  21070. m.addparent_id = nil
  21071. }
  21072. // ParentID returns the value of the "parent_id" field in the mutation.
  21073. func (m *SopNodeMutation) ParentID() (r uint64, exists bool) {
  21074. v := m.parent_id
  21075. if v == nil {
  21076. return
  21077. }
  21078. return *v, true
  21079. }
  21080. // OldParentID returns the old "parent_id" field's value of the SopNode entity.
  21081. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21082. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21083. func (m *SopNodeMutation) OldParentID(ctx context.Context) (v uint64, err error) {
  21084. if !m.op.Is(OpUpdateOne) {
  21085. return v, errors.New("OldParentID is only allowed on UpdateOne operations")
  21086. }
  21087. if m.id == nil || m.oldValue == nil {
  21088. return v, errors.New("OldParentID requires an ID field in the mutation")
  21089. }
  21090. oldValue, err := m.oldValue(ctx)
  21091. if err != nil {
  21092. return v, fmt.Errorf("querying old value for OldParentID: %w", err)
  21093. }
  21094. return oldValue.ParentID, nil
  21095. }
  21096. // AddParentID adds u to the "parent_id" field.
  21097. func (m *SopNodeMutation) AddParentID(u int64) {
  21098. if m.addparent_id != nil {
  21099. *m.addparent_id += u
  21100. } else {
  21101. m.addparent_id = &u
  21102. }
  21103. }
  21104. // AddedParentID returns the value that was added to the "parent_id" field in this mutation.
  21105. func (m *SopNodeMutation) AddedParentID() (r int64, exists bool) {
  21106. v := m.addparent_id
  21107. if v == nil {
  21108. return
  21109. }
  21110. return *v, true
  21111. }
  21112. // ResetParentID resets all changes to the "parent_id" field.
  21113. func (m *SopNodeMutation) ResetParentID() {
  21114. m.parent_id = nil
  21115. m.addparent_id = nil
  21116. }
  21117. // SetName sets the "name" field.
  21118. func (m *SopNodeMutation) SetName(s string) {
  21119. m.name = &s
  21120. }
  21121. // Name returns the value of the "name" field in the mutation.
  21122. func (m *SopNodeMutation) Name() (r string, exists bool) {
  21123. v := m.name
  21124. if v == nil {
  21125. return
  21126. }
  21127. return *v, true
  21128. }
  21129. // OldName returns the old "name" field's value of the SopNode entity.
  21130. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21131. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21132. func (m *SopNodeMutation) OldName(ctx context.Context) (v string, err error) {
  21133. if !m.op.Is(OpUpdateOne) {
  21134. return v, errors.New("OldName is only allowed on UpdateOne operations")
  21135. }
  21136. if m.id == nil || m.oldValue == nil {
  21137. return v, errors.New("OldName requires an ID field in the mutation")
  21138. }
  21139. oldValue, err := m.oldValue(ctx)
  21140. if err != nil {
  21141. return v, fmt.Errorf("querying old value for OldName: %w", err)
  21142. }
  21143. return oldValue.Name, nil
  21144. }
  21145. // ResetName resets all changes to the "name" field.
  21146. func (m *SopNodeMutation) ResetName() {
  21147. m.name = nil
  21148. }
  21149. // SetConditionType sets the "condition_type" field.
  21150. func (m *SopNodeMutation) SetConditionType(i int) {
  21151. m.condition_type = &i
  21152. m.addcondition_type = nil
  21153. }
  21154. // ConditionType returns the value of the "condition_type" field in the mutation.
  21155. func (m *SopNodeMutation) ConditionType() (r int, exists bool) {
  21156. v := m.condition_type
  21157. if v == nil {
  21158. return
  21159. }
  21160. return *v, true
  21161. }
  21162. // OldConditionType returns the old "condition_type" field's value of the SopNode entity.
  21163. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21164. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21165. func (m *SopNodeMutation) OldConditionType(ctx context.Context) (v int, err error) {
  21166. if !m.op.Is(OpUpdateOne) {
  21167. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  21168. }
  21169. if m.id == nil || m.oldValue == nil {
  21170. return v, errors.New("OldConditionType requires an ID field in the mutation")
  21171. }
  21172. oldValue, err := m.oldValue(ctx)
  21173. if err != nil {
  21174. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  21175. }
  21176. return oldValue.ConditionType, nil
  21177. }
  21178. // AddConditionType adds i to the "condition_type" field.
  21179. func (m *SopNodeMutation) AddConditionType(i int) {
  21180. if m.addcondition_type != nil {
  21181. *m.addcondition_type += i
  21182. } else {
  21183. m.addcondition_type = &i
  21184. }
  21185. }
  21186. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  21187. func (m *SopNodeMutation) AddedConditionType() (r int, exists bool) {
  21188. v := m.addcondition_type
  21189. if v == nil {
  21190. return
  21191. }
  21192. return *v, true
  21193. }
  21194. // ResetConditionType resets all changes to the "condition_type" field.
  21195. func (m *SopNodeMutation) ResetConditionType() {
  21196. m.condition_type = nil
  21197. m.addcondition_type = nil
  21198. }
  21199. // SetConditionList sets the "condition_list" field.
  21200. func (m *SopNodeMutation) SetConditionList(s []string) {
  21201. m.condition_list = &s
  21202. m.appendcondition_list = nil
  21203. }
  21204. // ConditionList returns the value of the "condition_list" field in the mutation.
  21205. func (m *SopNodeMutation) ConditionList() (r []string, exists bool) {
  21206. v := m.condition_list
  21207. if v == nil {
  21208. return
  21209. }
  21210. return *v, true
  21211. }
  21212. // OldConditionList returns the old "condition_list" field's value of the SopNode entity.
  21213. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21214. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21215. func (m *SopNodeMutation) OldConditionList(ctx context.Context) (v []string, err error) {
  21216. if !m.op.Is(OpUpdateOne) {
  21217. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  21218. }
  21219. if m.id == nil || m.oldValue == nil {
  21220. return v, errors.New("OldConditionList requires an ID field in the mutation")
  21221. }
  21222. oldValue, err := m.oldValue(ctx)
  21223. if err != nil {
  21224. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  21225. }
  21226. return oldValue.ConditionList, nil
  21227. }
  21228. // AppendConditionList adds s to the "condition_list" field.
  21229. func (m *SopNodeMutation) AppendConditionList(s []string) {
  21230. m.appendcondition_list = append(m.appendcondition_list, s...)
  21231. }
  21232. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  21233. func (m *SopNodeMutation) AppendedConditionList() ([]string, bool) {
  21234. if len(m.appendcondition_list) == 0 {
  21235. return nil, false
  21236. }
  21237. return m.appendcondition_list, true
  21238. }
  21239. // ClearConditionList clears the value of the "condition_list" field.
  21240. func (m *SopNodeMutation) ClearConditionList() {
  21241. m.condition_list = nil
  21242. m.appendcondition_list = nil
  21243. m.clearedFields[sopnode.FieldConditionList] = struct{}{}
  21244. }
  21245. // ConditionListCleared returns if the "condition_list" field was cleared in this mutation.
  21246. func (m *SopNodeMutation) ConditionListCleared() bool {
  21247. _, ok := m.clearedFields[sopnode.FieldConditionList]
  21248. return ok
  21249. }
  21250. // ResetConditionList resets all changes to the "condition_list" field.
  21251. func (m *SopNodeMutation) ResetConditionList() {
  21252. m.condition_list = nil
  21253. m.appendcondition_list = nil
  21254. delete(m.clearedFields, sopnode.FieldConditionList)
  21255. }
  21256. // SetNoReplyCondition sets the "no_reply_condition" field.
  21257. func (m *SopNodeMutation) SetNoReplyCondition(u uint64) {
  21258. m.no_reply_condition = &u
  21259. m.addno_reply_condition = nil
  21260. }
  21261. // NoReplyCondition returns the value of the "no_reply_condition" field in the mutation.
  21262. func (m *SopNodeMutation) NoReplyCondition() (r uint64, exists bool) {
  21263. v := m.no_reply_condition
  21264. if v == nil {
  21265. return
  21266. }
  21267. return *v, true
  21268. }
  21269. // OldNoReplyCondition returns the old "no_reply_condition" field's value of the SopNode entity.
  21270. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21271. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21272. func (m *SopNodeMutation) OldNoReplyCondition(ctx context.Context) (v uint64, err error) {
  21273. if !m.op.Is(OpUpdateOne) {
  21274. return v, errors.New("OldNoReplyCondition is only allowed on UpdateOne operations")
  21275. }
  21276. if m.id == nil || m.oldValue == nil {
  21277. return v, errors.New("OldNoReplyCondition requires an ID field in the mutation")
  21278. }
  21279. oldValue, err := m.oldValue(ctx)
  21280. if err != nil {
  21281. return v, fmt.Errorf("querying old value for OldNoReplyCondition: %w", err)
  21282. }
  21283. return oldValue.NoReplyCondition, nil
  21284. }
  21285. // AddNoReplyCondition adds u to the "no_reply_condition" field.
  21286. func (m *SopNodeMutation) AddNoReplyCondition(u int64) {
  21287. if m.addno_reply_condition != nil {
  21288. *m.addno_reply_condition += u
  21289. } else {
  21290. m.addno_reply_condition = &u
  21291. }
  21292. }
  21293. // AddedNoReplyCondition returns the value that was added to the "no_reply_condition" field in this mutation.
  21294. func (m *SopNodeMutation) AddedNoReplyCondition() (r int64, exists bool) {
  21295. v := m.addno_reply_condition
  21296. if v == nil {
  21297. return
  21298. }
  21299. return *v, true
  21300. }
  21301. // ResetNoReplyCondition resets all changes to the "no_reply_condition" field.
  21302. func (m *SopNodeMutation) ResetNoReplyCondition() {
  21303. m.no_reply_condition = nil
  21304. m.addno_reply_condition = nil
  21305. }
  21306. // SetNoReplyUnit sets the "no_reply_unit" field.
  21307. func (m *SopNodeMutation) SetNoReplyUnit(s string) {
  21308. m.no_reply_unit = &s
  21309. }
  21310. // NoReplyUnit returns the value of the "no_reply_unit" field in the mutation.
  21311. func (m *SopNodeMutation) NoReplyUnit() (r string, exists bool) {
  21312. v := m.no_reply_unit
  21313. if v == nil {
  21314. return
  21315. }
  21316. return *v, true
  21317. }
  21318. // OldNoReplyUnit returns the old "no_reply_unit" field's value of the SopNode entity.
  21319. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21320. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21321. func (m *SopNodeMutation) OldNoReplyUnit(ctx context.Context) (v string, err error) {
  21322. if !m.op.Is(OpUpdateOne) {
  21323. return v, errors.New("OldNoReplyUnit is only allowed on UpdateOne operations")
  21324. }
  21325. if m.id == nil || m.oldValue == nil {
  21326. return v, errors.New("OldNoReplyUnit requires an ID field in the mutation")
  21327. }
  21328. oldValue, err := m.oldValue(ctx)
  21329. if err != nil {
  21330. return v, fmt.Errorf("querying old value for OldNoReplyUnit: %w", err)
  21331. }
  21332. return oldValue.NoReplyUnit, nil
  21333. }
  21334. // ResetNoReplyUnit resets all changes to the "no_reply_unit" field.
  21335. func (m *SopNodeMutation) ResetNoReplyUnit() {
  21336. m.no_reply_unit = nil
  21337. }
  21338. // SetActionMessage sets the "action_message" field.
  21339. func (m *SopNodeMutation) SetActionMessage(ct []custom_types.Action) {
  21340. m.action_message = &ct
  21341. m.appendaction_message = nil
  21342. }
  21343. // ActionMessage returns the value of the "action_message" field in the mutation.
  21344. func (m *SopNodeMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  21345. v := m.action_message
  21346. if v == nil {
  21347. return
  21348. }
  21349. return *v, true
  21350. }
  21351. // OldActionMessage returns the old "action_message" field's value of the SopNode entity.
  21352. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21353. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21354. func (m *SopNodeMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  21355. if !m.op.Is(OpUpdateOne) {
  21356. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  21357. }
  21358. if m.id == nil || m.oldValue == nil {
  21359. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  21360. }
  21361. oldValue, err := m.oldValue(ctx)
  21362. if err != nil {
  21363. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  21364. }
  21365. return oldValue.ActionMessage, nil
  21366. }
  21367. // AppendActionMessage adds ct to the "action_message" field.
  21368. func (m *SopNodeMutation) AppendActionMessage(ct []custom_types.Action) {
  21369. m.appendaction_message = append(m.appendaction_message, ct...)
  21370. }
  21371. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  21372. func (m *SopNodeMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  21373. if len(m.appendaction_message) == 0 {
  21374. return nil, false
  21375. }
  21376. return m.appendaction_message, true
  21377. }
  21378. // ClearActionMessage clears the value of the "action_message" field.
  21379. func (m *SopNodeMutation) ClearActionMessage() {
  21380. m.action_message = nil
  21381. m.appendaction_message = nil
  21382. m.clearedFields[sopnode.FieldActionMessage] = struct{}{}
  21383. }
  21384. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  21385. func (m *SopNodeMutation) ActionMessageCleared() bool {
  21386. _, ok := m.clearedFields[sopnode.FieldActionMessage]
  21387. return ok
  21388. }
  21389. // ResetActionMessage resets all changes to the "action_message" field.
  21390. func (m *SopNodeMutation) ResetActionMessage() {
  21391. m.action_message = nil
  21392. m.appendaction_message = nil
  21393. delete(m.clearedFields, sopnode.FieldActionMessage)
  21394. }
  21395. // SetActionLabelAdd sets the "action_label_add" field.
  21396. func (m *SopNodeMutation) SetActionLabelAdd(u []uint64) {
  21397. m.action_label_add = &u
  21398. m.appendaction_label_add = nil
  21399. }
  21400. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  21401. func (m *SopNodeMutation) ActionLabelAdd() (r []uint64, exists bool) {
  21402. v := m.action_label_add
  21403. if v == nil {
  21404. return
  21405. }
  21406. return *v, true
  21407. }
  21408. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopNode entity.
  21409. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21410. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21411. func (m *SopNodeMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  21412. if !m.op.Is(OpUpdateOne) {
  21413. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  21414. }
  21415. if m.id == nil || m.oldValue == nil {
  21416. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  21417. }
  21418. oldValue, err := m.oldValue(ctx)
  21419. if err != nil {
  21420. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  21421. }
  21422. return oldValue.ActionLabelAdd, nil
  21423. }
  21424. // AppendActionLabelAdd adds u to the "action_label_add" field.
  21425. func (m *SopNodeMutation) AppendActionLabelAdd(u []uint64) {
  21426. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  21427. }
  21428. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  21429. func (m *SopNodeMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  21430. if len(m.appendaction_label_add) == 0 {
  21431. return nil, false
  21432. }
  21433. return m.appendaction_label_add, true
  21434. }
  21435. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  21436. func (m *SopNodeMutation) ClearActionLabelAdd() {
  21437. m.action_label_add = nil
  21438. m.appendaction_label_add = nil
  21439. m.clearedFields[sopnode.FieldActionLabelAdd] = struct{}{}
  21440. }
  21441. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  21442. func (m *SopNodeMutation) ActionLabelAddCleared() bool {
  21443. _, ok := m.clearedFields[sopnode.FieldActionLabelAdd]
  21444. return ok
  21445. }
  21446. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  21447. func (m *SopNodeMutation) ResetActionLabelAdd() {
  21448. m.action_label_add = nil
  21449. m.appendaction_label_add = nil
  21450. delete(m.clearedFields, sopnode.FieldActionLabelAdd)
  21451. }
  21452. // SetActionLabelDel sets the "action_label_del" field.
  21453. func (m *SopNodeMutation) SetActionLabelDel(u []uint64) {
  21454. m.action_label_del = &u
  21455. m.appendaction_label_del = nil
  21456. }
  21457. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  21458. func (m *SopNodeMutation) ActionLabelDel() (r []uint64, exists bool) {
  21459. v := m.action_label_del
  21460. if v == nil {
  21461. return
  21462. }
  21463. return *v, true
  21464. }
  21465. // OldActionLabelDel returns the old "action_label_del" field's value of the SopNode entity.
  21466. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21467. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21468. func (m *SopNodeMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  21469. if !m.op.Is(OpUpdateOne) {
  21470. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  21471. }
  21472. if m.id == nil || m.oldValue == nil {
  21473. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  21474. }
  21475. oldValue, err := m.oldValue(ctx)
  21476. if err != nil {
  21477. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  21478. }
  21479. return oldValue.ActionLabelDel, nil
  21480. }
  21481. // AppendActionLabelDel adds u to the "action_label_del" field.
  21482. func (m *SopNodeMutation) AppendActionLabelDel(u []uint64) {
  21483. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  21484. }
  21485. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  21486. func (m *SopNodeMutation) AppendedActionLabelDel() ([]uint64, bool) {
  21487. if len(m.appendaction_label_del) == 0 {
  21488. return nil, false
  21489. }
  21490. return m.appendaction_label_del, true
  21491. }
  21492. // ClearActionLabelDel clears the value of the "action_label_del" field.
  21493. func (m *SopNodeMutation) ClearActionLabelDel() {
  21494. m.action_label_del = nil
  21495. m.appendaction_label_del = nil
  21496. m.clearedFields[sopnode.FieldActionLabelDel] = struct{}{}
  21497. }
  21498. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  21499. func (m *SopNodeMutation) ActionLabelDelCleared() bool {
  21500. _, ok := m.clearedFields[sopnode.FieldActionLabelDel]
  21501. return ok
  21502. }
  21503. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  21504. func (m *SopNodeMutation) ResetActionLabelDel() {
  21505. m.action_label_del = nil
  21506. m.appendaction_label_del = nil
  21507. delete(m.clearedFields, sopnode.FieldActionLabelDel)
  21508. }
  21509. // SetActionForward sets the "action_forward" field.
  21510. func (m *SopNodeMutation) SetActionForward(ctf *custom_types.ActionForward) {
  21511. m.action_forward = &ctf
  21512. }
  21513. // ActionForward returns the value of the "action_forward" field in the mutation.
  21514. func (m *SopNodeMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  21515. v := m.action_forward
  21516. if v == nil {
  21517. return
  21518. }
  21519. return *v, true
  21520. }
  21521. // OldActionForward returns the old "action_forward" field's value of the SopNode entity.
  21522. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21523. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21524. func (m *SopNodeMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  21525. if !m.op.Is(OpUpdateOne) {
  21526. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  21527. }
  21528. if m.id == nil || m.oldValue == nil {
  21529. return v, errors.New("OldActionForward requires an ID field in the mutation")
  21530. }
  21531. oldValue, err := m.oldValue(ctx)
  21532. if err != nil {
  21533. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  21534. }
  21535. return oldValue.ActionForward, nil
  21536. }
  21537. // ClearActionForward clears the value of the "action_forward" field.
  21538. func (m *SopNodeMutation) ClearActionForward() {
  21539. m.action_forward = nil
  21540. m.clearedFields[sopnode.FieldActionForward] = struct{}{}
  21541. }
  21542. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  21543. func (m *SopNodeMutation) ActionForwardCleared() bool {
  21544. _, ok := m.clearedFields[sopnode.FieldActionForward]
  21545. return ok
  21546. }
  21547. // ResetActionForward resets all changes to the "action_forward" field.
  21548. func (m *SopNodeMutation) ResetActionForward() {
  21549. m.action_forward = nil
  21550. delete(m.clearedFields, sopnode.FieldActionForward)
  21551. }
  21552. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  21553. func (m *SopNodeMutation) SetSopStageID(id uint64) {
  21554. m.sop_stage = &id
  21555. }
  21556. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  21557. func (m *SopNodeMutation) ClearSopStage() {
  21558. m.clearedsop_stage = true
  21559. m.clearedFields[sopnode.FieldStageID] = struct{}{}
  21560. }
  21561. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  21562. func (m *SopNodeMutation) SopStageCleared() bool {
  21563. return m.clearedsop_stage
  21564. }
  21565. // SopStageID returns the "sop_stage" edge ID in the mutation.
  21566. func (m *SopNodeMutation) SopStageID() (id uint64, exists bool) {
  21567. if m.sop_stage != nil {
  21568. return *m.sop_stage, true
  21569. }
  21570. return
  21571. }
  21572. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  21573. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  21574. // SopStageID instead. It exists only for internal usage by the builders.
  21575. func (m *SopNodeMutation) SopStageIDs() (ids []uint64) {
  21576. if id := m.sop_stage; id != nil {
  21577. ids = append(ids, *id)
  21578. }
  21579. return
  21580. }
  21581. // ResetSopStage resets all changes to the "sop_stage" edge.
  21582. func (m *SopNodeMutation) ResetSopStage() {
  21583. m.sop_stage = nil
  21584. m.clearedsop_stage = false
  21585. }
  21586. // AddNodeMessageIDs adds the "node_messages" edge to the MessageRecords entity by ids.
  21587. func (m *SopNodeMutation) AddNodeMessageIDs(ids ...uint64) {
  21588. if m.node_messages == nil {
  21589. m.node_messages = make(map[uint64]struct{})
  21590. }
  21591. for i := range ids {
  21592. m.node_messages[ids[i]] = struct{}{}
  21593. }
  21594. }
  21595. // ClearNodeMessages clears the "node_messages" edge to the MessageRecords entity.
  21596. func (m *SopNodeMutation) ClearNodeMessages() {
  21597. m.clearednode_messages = true
  21598. }
  21599. // NodeMessagesCleared reports if the "node_messages" edge to the MessageRecords entity was cleared.
  21600. func (m *SopNodeMutation) NodeMessagesCleared() bool {
  21601. return m.clearednode_messages
  21602. }
  21603. // RemoveNodeMessageIDs removes the "node_messages" edge to the MessageRecords entity by IDs.
  21604. func (m *SopNodeMutation) RemoveNodeMessageIDs(ids ...uint64) {
  21605. if m.removednode_messages == nil {
  21606. m.removednode_messages = make(map[uint64]struct{})
  21607. }
  21608. for i := range ids {
  21609. delete(m.node_messages, ids[i])
  21610. m.removednode_messages[ids[i]] = struct{}{}
  21611. }
  21612. }
  21613. // RemovedNodeMessages returns the removed IDs of the "node_messages" edge to the MessageRecords entity.
  21614. func (m *SopNodeMutation) RemovedNodeMessagesIDs() (ids []uint64) {
  21615. for id := range m.removednode_messages {
  21616. ids = append(ids, id)
  21617. }
  21618. return
  21619. }
  21620. // NodeMessagesIDs returns the "node_messages" edge IDs in the mutation.
  21621. func (m *SopNodeMutation) NodeMessagesIDs() (ids []uint64) {
  21622. for id := range m.node_messages {
  21623. ids = append(ids, id)
  21624. }
  21625. return
  21626. }
  21627. // ResetNodeMessages resets all changes to the "node_messages" edge.
  21628. func (m *SopNodeMutation) ResetNodeMessages() {
  21629. m.node_messages = nil
  21630. m.clearednode_messages = false
  21631. m.removednode_messages = nil
  21632. }
  21633. // Where appends a list predicates to the SopNodeMutation builder.
  21634. func (m *SopNodeMutation) Where(ps ...predicate.SopNode) {
  21635. m.predicates = append(m.predicates, ps...)
  21636. }
  21637. // WhereP appends storage-level predicates to the SopNodeMutation builder. Using this method,
  21638. // users can use type-assertion to append predicates that do not depend on any generated package.
  21639. func (m *SopNodeMutation) WhereP(ps ...func(*sql.Selector)) {
  21640. p := make([]predicate.SopNode, len(ps))
  21641. for i := range ps {
  21642. p[i] = ps[i]
  21643. }
  21644. m.Where(p...)
  21645. }
  21646. // Op returns the operation name.
  21647. func (m *SopNodeMutation) Op() Op {
  21648. return m.op
  21649. }
  21650. // SetOp allows setting the mutation operation.
  21651. func (m *SopNodeMutation) SetOp(op Op) {
  21652. m.op = op
  21653. }
  21654. // Type returns the node type of this mutation (SopNode).
  21655. func (m *SopNodeMutation) Type() string {
  21656. return m.typ
  21657. }
  21658. // Fields returns all fields that were changed during this mutation. Note that in
  21659. // order to get all numeric fields that were incremented/decremented, call
  21660. // AddedFields().
  21661. func (m *SopNodeMutation) Fields() []string {
  21662. fields := make([]string, 0, 15)
  21663. if m.created_at != nil {
  21664. fields = append(fields, sopnode.FieldCreatedAt)
  21665. }
  21666. if m.updated_at != nil {
  21667. fields = append(fields, sopnode.FieldUpdatedAt)
  21668. }
  21669. if m.status != nil {
  21670. fields = append(fields, sopnode.FieldStatus)
  21671. }
  21672. if m.deleted_at != nil {
  21673. fields = append(fields, sopnode.FieldDeletedAt)
  21674. }
  21675. if m.sop_stage != nil {
  21676. fields = append(fields, sopnode.FieldStageID)
  21677. }
  21678. if m.parent_id != nil {
  21679. fields = append(fields, sopnode.FieldParentID)
  21680. }
  21681. if m.name != nil {
  21682. fields = append(fields, sopnode.FieldName)
  21683. }
  21684. if m.condition_type != nil {
  21685. fields = append(fields, sopnode.FieldConditionType)
  21686. }
  21687. if m.condition_list != nil {
  21688. fields = append(fields, sopnode.FieldConditionList)
  21689. }
  21690. if m.no_reply_condition != nil {
  21691. fields = append(fields, sopnode.FieldNoReplyCondition)
  21692. }
  21693. if m.no_reply_unit != nil {
  21694. fields = append(fields, sopnode.FieldNoReplyUnit)
  21695. }
  21696. if m.action_message != nil {
  21697. fields = append(fields, sopnode.FieldActionMessage)
  21698. }
  21699. if m.action_label_add != nil {
  21700. fields = append(fields, sopnode.FieldActionLabelAdd)
  21701. }
  21702. if m.action_label_del != nil {
  21703. fields = append(fields, sopnode.FieldActionLabelDel)
  21704. }
  21705. if m.action_forward != nil {
  21706. fields = append(fields, sopnode.FieldActionForward)
  21707. }
  21708. return fields
  21709. }
  21710. // Field returns the value of a field with the given name. The second boolean
  21711. // return value indicates that this field was not set, or was not defined in the
  21712. // schema.
  21713. func (m *SopNodeMutation) Field(name string) (ent.Value, bool) {
  21714. switch name {
  21715. case sopnode.FieldCreatedAt:
  21716. return m.CreatedAt()
  21717. case sopnode.FieldUpdatedAt:
  21718. return m.UpdatedAt()
  21719. case sopnode.FieldStatus:
  21720. return m.Status()
  21721. case sopnode.FieldDeletedAt:
  21722. return m.DeletedAt()
  21723. case sopnode.FieldStageID:
  21724. return m.StageID()
  21725. case sopnode.FieldParentID:
  21726. return m.ParentID()
  21727. case sopnode.FieldName:
  21728. return m.Name()
  21729. case sopnode.FieldConditionType:
  21730. return m.ConditionType()
  21731. case sopnode.FieldConditionList:
  21732. return m.ConditionList()
  21733. case sopnode.FieldNoReplyCondition:
  21734. return m.NoReplyCondition()
  21735. case sopnode.FieldNoReplyUnit:
  21736. return m.NoReplyUnit()
  21737. case sopnode.FieldActionMessage:
  21738. return m.ActionMessage()
  21739. case sopnode.FieldActionLabelAdd:
  21740. return m.ActionLabelAdd()
  21741. case sopnode.FieldActionLabelDel:
  21742. return m.ActionLabelDel()
  21743. case sopnode.FieldActionForward:
  21744. return m.ActionForward()
  21745. }
  21746. return nil, false
  21747. }
  21748. // OldField returns the old value of the field from the database. An error is
  21749. // returned if the mutation operation is not UpdateOne, or the query to the
  21750. // database failed.
  21751. func (m *SopNodeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  21752. switch name {
  21753. case sopnode.FieldCreatedAt:
  21754. return m.OldCreatedAt(ctx)
  21755. case sopnode.FieldUpdatedAt:
  21756. return m.OldUpdatedAt(ctx)
  21757. case sopnode.FieldStatus:
  21758. return m.OldStatus(ctx)
  21759. case sopnode.FieldDeletedAt:
  21760. return m.OldDeletedAt(ctx)
  21761. case sopnode.FieldStageID:
  21762. return m.OldStageID(ctx)
  21763. case sopnode.FieldParentID:
  21764. return m.OldParentID(ctx)
  21765. case sopnode.FieldName:
  21766. return m.OldName(ctx)
  21767. case sopnode.FieldConditionType:
  21768. return m.OldConditionType(ctx)
  21769. case sopnode.FieldConditionList:
  21770. return m.OldConditionList(ctx)
  21771. case sopnode.FieldNoReplyCondition:
  21772. return m.OldNoReplyCondition(ctx)
  21773. case sopnode.FieldNoReplyUnit:
  21774. return m.OldNoReplyUnit(ctx)
  21775. case sopnode.FieldActionMessage:
  21776. return m.OldActionMessage(ctx)
  21777. case sopnode.FieldActionLabelAdd:
  21778. return m.OldActionLabelAdd(ctx)
  21779. case sopnode.FieldActionLabelDel:
  21780. return m.OldActionLabelDel(ctx)
  21781. case sopnode.FieldActionForward:
  21782. return m.OldActionForward(ctx)
  21783. }
  21784. return nil, fmt.Errorf("unknown SopNode field %s", name)
  21785. }
  21786. // SetField sets the value of a field with the given name. It returns an error if
  21787. // the field is not defined in the schema, or if the type mismatched the field
  21788. // type.
  21789. func (m *SopNodeMutation) SetField(name string, value ent.Value) error {
  21790. switch name {
  21791. case sopnode.FieldCreatedAt:
  21792. v, ok := value.(time.Time)
  21793. if !ok {
  21794. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21795. }
  21796. m.SetCreatedAt(v)
  21797. return nil
  21798. case sopnode.FieldUpdatedAt:
  21799. v, ok := value.(time.Time)
  21800. if !ok {
  21801. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21802. }
  21803. m.SetUpdatedAt(v)
  21804. return nil
  21805. case sopnode.FieldStatus:
  21806. v, ok := value.(uint8)
  21807. if !ok {
  21808. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21809. }
  21810. m.SetStatus(v)
  21811. return nil
  21812. case sopnode.FieldDeletedAt:
  21813. v, ok := value.(time.Time)
  21814. if !ok {
  21815. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21816. }
  21817. m.SetDeletedAt(v)
  21818. return nil
  21819. case sopnode.FieldStageID:
  21820. v, ok := value.(uint64)
  21821. if !ok {
  21822. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21823. }
  21824. m.SetStageID(v)
  21825. return nil
  21826. case sopnode.FieldParentID:
  21827. v, ok := value.(uint64)
  21828. if !ok {
  21829. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21830. }
  21831. m.SetParentID(v)
  21832. return nil
  21833. case sopnode.FieldName:
  21834. v, ok := value.(string)
  21835. if !ok {
  21836. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21837. }
  21838. m.SetName(v)
  21839. return nil
  21840. case sopnode.FieldConditionType:
  21841. v, ok := value.(int)
  21842. if !ok {
  21843. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21844. }
  21845. m.SetConditionType(v)
  21846. return nil
  21847. case sopnode.FieldConditionList:
  21848. v, ok := value.([]string)
  21849. if !ok {
  21850. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21851. }
  21852. m.SetConditionList(v)
  21853. return nil
  21854. case sopnode.FieldNoReplyCondition:
  21855. v, ok := value.(uint64)
  21856. if !ok {
  21857. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21858. }
  21859. m.SetNoReplyCondition(v)
  21860. return nil
  21861. case sopnode.FieldNoReplyUnit:
  21862. v, ok := value.(string)
  21863. if !ok {
  21864. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21865. }
  21866. m.SetNoReplyUnit(v)
  21867. return nil
  21868. case sopnode.FieldActionMessage:
  21869. v, ok := value.([]custom_types.Action)
  21870. if !ok {
  21871. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21872. }
  21873. m.SetActionMessage(v)
  21874. return nil
  21875. case sopnode.FieldActionLabelAdd:
  21876. v, ok := value.([]uint64)
  21877. if !ok {
  21878. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21879. }
  21880. m.SetActionLabelAdd(v)
  21881. return nil
  21882. case sopnode.FieldActionLabelDel:
  21883. v, ok := value.([]uint64)
  21884. if !ok {
  21885. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21886. }
  21887. m.SetActionLabelDel(v)
  21888. return nil
  21889. case sopnode.FieldActionForward:
  21890. v, ok := value.(*custom_types.ActionForward)
  21891. if !ok {
  21892. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21893. }
  21894. m.SetActionForward(v)
  21895. return nil
  21896. }
  21897. return fmt.Errorf("unknown SopNode field %s", name)
  21898. }
  21899. // AddedFields returns all numeric fields that were incremented/decremented during
  21900. // this mutation.
  21901. func (m *SopNodeMutation) AddedFields() []string {
  21902. var fields []string
  21903. if m.addstatus != nil {
  21904. fields = append(fields, sopnode.FieldStatus)
  21905. }
  21906. if m.addparent_id != nil {
  21907. fields = append(fields, sopnode.FieldParentID)
  21908. }
  21909. if m.addcondition_type != nil {
  21910. fields = append(fields, sopnode.FieldConditionType)
  21911. }
  21912. if m.addno_reply_condition != nil {
  21913. fields = append(fields, sopnode.FieldNoReplyCondition)
  21914. }
  21915. return fields
  21916. }
  21917. // AddedField returns the numeric value that was incremented/decremented on a field
  21918. // with the given name. The second boolean return value indicates that this field
  21919. // was not set, or was not defined in the schema.
  21920. func (m *SopNodeMutation) AddedField(name string) (ent.Value, bool) {
  21921. switch name {
  21922. case sopnode.FieldStatus:
  21923. return m.AddedStatus()
  21924. case sopnode.FieldParentID:
  21925. return m.AddedParentID()
  21926. case sopnode.FieldConditionType:
  21927. return m.AddedConditionType()
  21928. case sopnode.FieldNoReplyCondition:
  21929. return m.AddedNoReplyCondition()
  21930. }
  21931. return nil, false
  21932. }
  21933. // AddField adds the value to the field with the given name. It returns an error if
  21934. // the field is not defined in the schema, or if the type mismatched the field
  21935. // type.
  21936. func (m *SopNodeMutation) AddField(name string, value ent.Value) error {
  21937. switch name {
  21938. case sopnode.FieldStatus:
  21939. v, ok := value.(int8)
  21940. if !ok {
  21941. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21942. }
  21943. m.AddStatus(v)
  21944. return nil
  21945. case sopnode.FieldParentID:
  21946. v, ok := value.(int64)
  21947. if !ok {
  21948. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21949. }
  21950. m.AddParentID(v)
  21951. return nil
  21952. case sopnode.FieldConditionType:
  21953. v, ok := value.(int)
  21954. if !ok {
  21955. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21956. }
  21957. m.AddConditionType(v)
  21958. return nil
  21959. case sopnode.FieldNoReplyCondition:
  21960. v, ok := value.(int64)
  21961. if !ok {
  21962. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21963. }
  21964. m.AddNoReplyCondition(v)
  21965. return nil
  21966. }
  21967. return fmt.Errorf("unknown SopNode numeric field %s", name)
  21968. }
  21969. // ClearedFields returns all nullable fields that were cleared during this
  21970. // mutation.
  21971. func (m *SopNodeMutation) ClearedFields() []string {
  21972. var fields []string
  21973. if m.FieldCleared(sopnode.FieldStatus) {
  21974. fields = append(fields, sopnode.FieldStatus)
  21975. }
  21976. if m.FieldCleared(sopnode.FieldDeletedAt) {
  21977. fields = append(fields, sopnode.FieldDeletedAt)
  21978. }
  21979. if m.FieldCleared(sopnode.FieldConditionList) {
  21980. fields = append(fields, sopnode.FieldConditionList)
  21981. }
  21982. if m.FieldCleared(sopnode.FieldActionMessage) {
  21983. fields = append(fields, sopnode.FieldActionMessage)
  21984. }
  21985. if m.FieldCleared(sopnode.FieldActionLabelAdd) {
  21986. fields = append(fields, sopnode.FieldActionLabelAdd)
  21987. }
  21988. if m.FieldCleared(sopnode.FieldActionLabelDel) {
  21989. fields = append(fields, sopnode.FieldActionLabelDel)
  21990. }
  21991. if m.FieldCleared(sopnode.FieldActionForward) {
  21992. fields = append(fields, sopnode.FieldActionForward)
  21993. }
  21994. return fields
  21995. }
  21996. // FieldCleared returns a boolean indicating if a field with the given name was
  21997. // cleared in this mutation.
  21998. func (m *SopNodeMutation) FieldCleared(name string) bool {
  21999. _, ok := m.clearedFields[name]
  22000. return ok
  22001. }
  22002. // ClearField clears the value of the field with the given name. It returns an
  22003. // error if the field is not defined in the schema.
  22004. func (m *SopNodeMutation) ClearField(name string) error {
  22005. switch name {
  22006. case sopnode.FieldStatus:
  22007. m.ClearStatus()
  22008. return nil
  22009. case sopnode.FieldDeletedAt:
  22010. m.ClearDeletedAt()
  22011. return nil
  22012. case sopnode.FieldConditionList:
  22013. m.ClearConditionList()
  22014. return nil
  22015. case sopnode.FieldActionMessage:
  22016. m.ClearActionMessage()
  22017. return nil
  22018. case sopnode.FieldActionLabelAdd:
  22019. m.ClearActionLabelAdd()
  22020. return nil
  22021. case sopnode.FieldActionLabelDel:
  22022. m.ClearActionLabelDel()
  22023. return nil
  22024. case sopnode.FieldActionForward:
  22025. m.ClearActionForward()
  22026. return nil
  22027. }
  22028. return fmt.Errorf("unknown SopNode nullable field %s", name)
  22029. }
  22030. // ResetField resets all changes in the mutation for the field with the given name.
  22031. // It returns an error if the field is not defined in the schema.
  22032. func (m *SopNodeMutation) ResetField(name string) error {
  22033. switch name {
  22034. case sopnode.FieldCreatedAt:
  22035. m.ResetCreatedAt()
  22036. return nil
  22037. case sopnode.FieldUpdatedAt:
  22038. m.ResetUpdatedAt()
  22039. return nil
  22040. case sopnode.FieldStatus:
  22041. m.ResetStatus()
  22042. return nil
  22043. case sopnode.FieldDeletedAt:
  22044. m.ResetDeletedAt()
  22045. return nil
  22046. case sopnode.FieldStageID:
  22047. m.ResetStageID()
  22048. return nil
  22049. case sopnode.FieldParentID:
  22050. m.ResetParentID()
  22051. return nil
  22052. case sopnode.FieldName:
  22053. m.ResetName()
  22054. return nil
  22055. case sopnode.FieldConditionType:
  22056. m.ResetConditionType()
  22057. return nil
  22058. case sopnode.FieldConditionList:
  22059. m.ResetConditionList()
  22060. return nil
  22061. case sopnode.FieldNoReplyCondition:
  22062. m.ResetNoReplyCondition()
  22063. return nil
  22064. case sopnode.FieldNoReplyUnit:
  22065. m.ResetNoReplyUnit()
  22066. return nil
  22067. case sopnode.FieldActionMessage:
  22068. m.ResetActionMessage()
  22069. return nil
  22070. case sopnode.FieldActionLabelAdd:
  22071. m.ResetActionLabelAdd()
  22072. return nil
  22073. case sopnode.FieldActionLabelDel:
  22074. m.ResetActionLabelDel()
  22075. return nil
  22076. case sopnode.FieldActionForward:
  22077. m.ResetActionForward()
  22078. return nil
  22079. }
  22080. return fmt.Errorf("unknown SopNode field %s", name)
  22081. }
  22082. // AddedEdges returns all edge names that were set/added in this mutation.
  22083. func (m *SopNodeMutation) AddedEdges() []string {
  22084. edges := make([]string, 0, 2)
  22085. if m.sop_stage != nil {
  22086. edges = append(edges, sopnode.EdgeSopStage)
  22087. }
  22088. if m.node_messages != nil {
  22089. edges = append(edges, sopnode.EdgeNodeMessages)
  22090. }
  22091. return edges
  22092. }
  22093. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  22094. // name in this mutation.
  22095. func (m *SopNodeMutation) AddedIDs(name string) []ent.Value {
  22096. switch name {
  22097. case sopnode.EdgeSopStage:
  22098. if id := m.sop_stage; id != nil {
  22099. return []ent.Value{*id}
  22100. }
  22101. case sopnode.EdgeNodeMessages:
  22102. ids := make([]ent.Value, 0, len(m.node_messages))
  22103. for id := range m.node_messages {
  22104. ids = append(ids, id)
  22105. }
  22106. return ids
  22107. }
  22108. return nil
  22109. }
  22110. // RemovedEdges returns all edge names that were removed in this mutation.
  22111. func (m *SopNodeMutation) RemovedEdges() []string {
  22112. edges := make([]string, 0, 2)
  22113. if m.removednode_messages != nil {
  22114. edges = append(edges, sopnode.EdgeNodeMessages)
  22115. }
  22116. return edges
  22117. }
  22118. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  22119. // the given name in this mutation.
  22120. func (m *SopNodeMutation) RemovedIDs(name string) []ent.Value {
  22121. switch name {
  22122. case sopnode.EdgeNodeMessages:
  22123. ids := make([]ent.Value, 0, len(m.removednode_messages))
  22124. for id := range m.removednode_messages {
  22125. ids = append(ids, id)
  22126. }
  22127. return ids
  22128. }
  22129. return nil
  22130. }
  22131. // ClearedEdges returns all edge names that were cleared in this mutation.
  22132. func (m *SopNodeMutation) ClearedEdges() []string {
  22133. edges := make([]string, 0, 2)
  22134. if m.clearedsop_stage {
  22135. edges = append(edges, sopnode.EdgeSopStage)
  22136. }
  22137. if m.clearednode_messages {
  22138. edges = append(edges, sopnode.EdgeNodeMessages)
  22139. }
  22140. return edges
  22141. }
  22142. // EdgeCleared returns a boolean which indicates if the edge with the given name
  22143. // was cleared in this mutation.
  22144. func (m *SopNodeMutation) EdgeCleared(name string) bool {
  22145. switch name {
  22146. case sopnode.EdgeSopStage:
  22147. return m.clearedsop_stage
  22148. case sopnode.EdgeNodeMessages:
  22149. return m.clearednode_messages
  22150. }
  22151. return false
  22152. }
  22153. // ClearEdge clears the value of the edge with the given name. It returns an error
  22154. // if that edge is not defined in the schema.
  22155. func (m *SopNodeMutation) ClearEdge(name string) error {
  22156. switch name {
  22157. case sopnode.EdgeSopStage:
  22158. m.ClearSopStage()
  22159. return nil
  22160. }
  22161. return fmt.Errorf("unknown SopNode unique edge %s", name)
  22162. }
  22163. // ResetEdge resets all changes to the edge with the given name in this mutation.
  22164. // It returns an error if the edge is not defined in the schema.
  22165. func (m *SopNodeMutation) ResetEdge(name string) error {
  22166. switch name {
  22167. case sopnode.EdgeSopStage:
  22168. m.ResetSopStage()
  22169. return nil
  22170. case sopnode.EdgeNodeMessages:
  22171. m.ResetNodeMessages()
  22172. return nil
  22173. }
  22174. return fmt.Errorf("unknown SopNode edge %s", name)
  22175. }
  22176. // SopStageMutation represents an operation that mutates the SopStage nodes in the graph.
  22177. type SopStageMutation struct {
  22178. config
  22179. op Op
  22180. typ string
  22181. id *uint64
  22182. created_at *time.Time
  22183. updated_at *time.Time
  22184. status *uint8
  22185. addstatus *int8
  22186. deleted_at *time.Time
  22187. name *string
  22188. condition_type *int
  22189. addcondition_type *int
  22190. condition_operator *int
  22191. addcondition_operator *int
  22192. condition_list *[]custom_types.Condition
  22193. appendcondition_list []custom_types.Condition
  22194. action_message *[]custom_types.Action
  22195. appendaction_message []custom_types.Action
  22196. action_label_add *[]uint64
  22197. appendaction_label_add []uint64
  22198. action_label_del *[]uint64
  22199. appendaction_label_del []uint64
  22200. action_forward **custom_types.ActionForward
  22201. index_sort *int
  22202. addindex_sort *int
  22203. clearedFields map[string]struct{}
  22204. sop_task *uint64
  22205. clearedsop_task bool
  22206. stage_nodes map[uint64]struct{}
  22207. removedstage_nodes map[uint64]struct{}
  22208. clearedstage_nodes bool
  22209. stage_messages map[uint64]struct{}
  22210. removedstage_messages map[uint64]struct{}
  22211. clearedstage_messages bool
  22212. done bool
  22213. oldValue func(context.Context) (*SopStage, error)
  22214. predicates []predicate.SopStage
  22215. }
  22216. var _ ent.Mutation = (*SopStageMutation)(nil)
  22217. // sopstageOption allows management of the mutation configuration using functional options.
  22218. type sopstageOption func(*SopStageMutation)
  22219. // newSopStageMutation creates new mutation for the SopStage entity.
  22220. func newSopStageMutation(c config, op Op, opts ...sopstageOption) *SopStageMutation {
  22221. m := &SopStageMutation{
  22222. config: c,
  22223. op: op,
  22224. typ: TypeSopStage,
  22225. clearedFields: make(map[string]struct{}),
  22226. }
  22227. for _, opt := range opts {
  22228. opt(m)
  22229. }
  22230. return m
  22231. }
  22232. // withSopStageID sets the ID field of the mutation.
  22233. func withSopStageID(id uint64) sopstageOption {
  22234. return func(m *SopStageMutation) {
  22235. var (
  22236. err error
  22237. once sync.Once
  22238. value *SopStage
  22239. )
  22240. m.oldValue = func(ctx context.Context) (*SopStage, error) {
  22241. once.Do(func() {
  22242. if m.done {
  22243. err = errors.New("querying old values post mutation is not allowed")
  22244. } else {
  22245. value, err = m.Client().SopStage.Get(ctx, id)
  22246. }
  22247. })
  22248. return value, err
  22249. }
  22250. m.id = &id
  22251. }
  22252. }
  22253. // withSopStage sets the old SopStage of the mutation.
  22254. func withSopStage(node *SopStage) sopstageOption {
  22255. return func(m *SopStageMutation) {
  22256. m.oldValue = func(context.Context) (*SopStage, error) {
  22257. return node, nil
  22258. }
  22259. m.id = &node.ID
  22260. }
  22261. }
  22262. // Client returns a new `ent.Client` from the mutation. If the mutation was
  22263. // executed in a transaction (ent.Tx), a transactional client is returned.
  22264. func (m SopStageMutation) Client() *Client {
  22265. client := &Client{config: m.config}
  22266. client.init()
  22267. return client
  22268. }
  22269. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  22270. // it returns an error otherwise.
  22271. func (m SopStageMutation) Tx() (*Tx, error) {
  22272. if _, ok := m.driver.(*txDriver); !ok {
  22273. return nil, errors.New("ent: mutation is not running in a transaction")
  22274. }
  22275. tx := &Tx{config: m.config}
  22276. tx.init()
  22277. return tx, nil
  22278. }
  22279. // SetID sets the value of the id field. Note that this
  22280. // operation is only accepted on creation of SopStage entities.
  22281. func (m *SopStageMutation) SetID(id uint64) {
  22282. m.id = &id
  22283. }
  22284. // ID returns the ID value in the mutation. Note that the ID is only available
  22285. // if it was provided to the builder or after it was returned from the database.
  22286. func (m *SopStageMutation) ID() (id uint64, exists bool) {
  22287. if m.id == nil {
  22288. return
  22289. }
  22290. return *m.id, true
  22291. }
  22292. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  22293. // That means, if the mutation is applied within a transaction with an isolation level such
  22294. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  22295. // or updated by the mutation.
  22296. func (m *SopStageMutation) IDs(ctx context.Context) ([]uint64, error) {
  22297. switch {
  22298. case m.op.Is(OpUpdateOne | OpDeleteOne):
  22299. id, exists := m.ID()
  22300. if exists {
  22301. return []uint64{id}, nil
  22302. }
  22303. fallthrough
  22304. case m.op.Is(OpUpdate | OpDelete):
  22305. return m.Client().SopStage.Query().Where(m.predicates...).IDs(ctx)
  22306. default:
  22307. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  22308. }
  22309. }
  22310. // SetCreatedAt sets the "created_at" field.
  22311. func (m *SopStageMutation) SetCreatedAt(t time.Time) {
  22312. m.created_at = &t
  22313. }
  22314. // CreatedAt returns the value of the "created_at" field in the mutation.
  22315. func (m *SopStageMutation) CreatedAt() (r time.Time, exists bool) {
  22316. v := m.created_at
  22317. if v == nil {
  22318. return
  22319. }
  22320. return *v, true
  22321. }
  22322. // OldCreatedAt returns the old "created_at" field's value of the SopStage entity.
  22323. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22324. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22325. func (m *SopStageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  22326. if !m.op.Is(OpUpdateOne) {
  22327. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  22328. }
  22329. if m.id == nil || m.oldValue == nil {
  22330. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  22331. }
  22332. oldValue, err := m.oldValue(ctx)
  22333. if err != nil {
  22334. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  22335. }
  22336. return oldValue.CreatedAt, nil
  22337. }
  22338. // ResetCreatedAt resets all changes to the "created_at" field.
  22339. func (m *SopStageMutation) ResetCreatedAt() {
  22340. m.created_at = nil
  22341. }
  22342. // SetUpdatedAt sets the "updated_at" field.
  22343. func (m *SopStageMutation) SetUpdatedAt(t time.Time) {
  22344. m.updated_at = &t
  22345. }
  22346. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  22347. func (m *SopStageMutation) UpdatedAt() (r time.Time, exists bool) {
  22348. v := m.updated_at
  22349. if v == nil {
  22350. return
  22351. }
  22352. return *v, true
  22353. }
  22354. // OldUpdatedAt returns the old "updated_at" field's value of the SopStage entity.
  22355. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22356. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22357. func (m *SopStageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  22358. if !m.op.Is(OpUpdateOne) {
  22359. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  22360. }
  22361. if m.id == nil || m.oldValue == nil {
  22362. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  22363. }
  22364. oldValue, err := m.oldValue(ctx)
  22365. if err != nil {
  22366. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  22367. }
  22368. return oldValue.UpdatedAt, nil
  22369. }
  22370. // ResetUpdatedAt resets all changes to the "updated_at" field.
  22371. func (m *SopStageMutation) ResetUpdatedAt() {
  22372. m.updated_at = nil
  22373. }
  22374. // SetStatus sets the "status" field.
  22375. func (m *SopStageMutation) SetStatus(u uint8) {
  22376. m.status = &u
  22377. m.addstatus = nil
  22378. }
  22379. // Status returns the value of the "status" field in the mutation.
  22380. func (m *SopStageMutation) Status() (r uint8, exists bool) {
  22381. v := m.status
  22382. if v == nil {
  22383. return
  22384. }
  22385. return *v, true
  22386. }
  22387. // OldStatus returns the old "status" field's value of the SopStage entity.
  22388. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22389. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22390. func (m *SopStageMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  22391. if !m.op.Is(OpUpdateOne) {
  22392. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  22393. }
  22394. if m.id == nil || m.oldValue == nil {
  22395. return v, errors.New("OldStatus requires an ID field in the mutation")
  22396. }
  22397. oldValue, err := m.oldValue(ctx)
  22398. if err != nil {
  22399. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  22400. }
  22401. return oldValue.Status, nil
  22402. }
  22403. // AddStatus adds u to the "status" field.
  22404. func (m *SopStageMutation) AddStatus(u int8) {
  22405. if m.addstatus != nil {
  22406. *m.addstatus += u
  22407. } else {
  22408. m.addstatus = &u
  22409. }
  22410. }
  22411. // AddedStatus returns the value that was added to the "status" field in this mutation.
  22412. func (m *SopStageMutation) AddedStatus() (r int8, exists bool) {
  22413. v := m.addstatus
  22414. if v == nil {
  22415. return
  22416. }
  22417. return *v, true
  22418. }
  22419. // ClearStatus clears the value of the "status" field.
  22420. func (m *SopStageMutation) ClearStatus() {
  22421. m.status = nil
  22422. m.addstatus = nil
  22423. m.clearedFields[sopstage.FieldStatus] = struct{}{}
  22424. }
  22425. // StatusCleared returns if the "status" field was cleared in this mutation.
  22426. func (m *SopStageMutation) StatusCleared() bool {
  22427. _, ok := m.clearedFields[sopstage.FieldStatus]
  22428. return ok
  22429. }
  22430. // ResetStatus resets all changes to the "status" field.
  22431. func (m *SopStageMutation) ResetStatus() {
  22432. m.status = nil
  22433. m.addstatus = nil
  22434. delete(m.clearedFields, sopstage.FieldStatus)
  22435. }
  22436. // SetDeletedAt sets the "deleted_at" field.
  22437. func (m *SopStageMutation) SetDeletedAt(t time.Time) {
  22438. m.deleted_at = &t
  22439. }
  22440. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  22441. func (m *SopStageMutation) DeletedAt() (r time.Time, exists bool) {
  22442. v := m.deleted_at
  22443. if v == nil {
  22444. return
  22445. }
  22446. return *v, true
  22447. }
  22448. // OldDeletedAt returns the old "deleted_at" field's value of the SopStage entity.
  22449. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22450. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22451. func (m *SopStageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  22452. if !m.op.Is(OpUpdateOne) {
  22453. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  22454. }
  22455. if m.id == nil || m.oldValue == nil {
  22456. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  22457. }
  22458. oldValue, err := m.oldValue(ctx)
  22459. if err != nil {
  22460. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  22461. }
  22462. return oldValue.DeletedAt, nil
  22463. }
  22464. // ClearDeletedAt clears the value of the "deleted_at" field.
  22465. func (m *SopStageMutation) ClearDeletedAt() {
  22466. m.deleted_at = nil
  22467. m.clearedFields[sopstage.FieldDeletedAt] = struct{}{}
  22468. }
  22469. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  22470. func (m *SopStageMutation) DeletedAtCleared() bool {
  22471. _, ok := m.clearedFields[sopstage.FieldDeletedAt]
  22472. return ok
  22473. }
  22474. // ResetDeletedAt resets all changes to the "deleted_at" field.
  22475. func (m *SopStageMutation) ResetDeletedAt() {
  22476. m.deleted_at = nil
  22477. delete(m.clearedFields, sopstage.FieldDeletedAt)
  22478. }
  22479. // SetTaskID sets the "task_id" field.
  22480. func (m *SopStageMutation) SetTaskID(u uint64) {
  22481. m.sop_task = &u
  22482. }
  22483. // TaskID returns the value of the "task_id" field in the mutation.
  22484. func (m *SopStageMutation) TaskID() (r uint64, exists bool) {
  22485. v := m.sop_task
  22486. if v == nil {
  22487. return
  22488. }
  22489. return *v, true
  22490. }
  22491. // OldTaskID returns the old "task_id" field's value of the SopStage entity.
  22492. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22493. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22494. func (m *SopStageMutation) OldTaskID(ctx context.Context) (v uint64, err error) {
  22495. if !m.op.Is(OpUpdateOne) {
  22496. return v, errors.New("OldTaskID is only allowed on UpdateOne operations")
  22497. }
  22498. if m.id == nil || m.oldValue == nil {
  22499. return v, errors.New("OldTaskID requires an ID field in the mutation")
  22500. }
  22501. oldValue, err := m.oldValue(ctx)
  22502. if err != nil {
  22503. return v, fmt.Errorf("querying old value for OldTaskID: %w", err)
  22504. }
  22505. return oldValue.TaskID, nil
  22506. }
  22507. // ResetTaskID resets all changes to the "task_id" field.
  22508. func (m *SopStageMutation) ResetTaskID() {
  22509. m.sop_task = nil
  22510. }
  22511. // SetName sets the "name" field.
  22512. func (m *SopStageMutation) SetName(s string) {
  22513. m.name = &s
  22514. }
  22515. // Name returns the value of the "name" field in the mutation.
  22516. func (m *SopStageMutation) Name() (r string, exists bool) {
  22517. v := m.name
  22518. if v == nil {
  22519. return
  22520. }
  22521. return *v, true
  22522. }
  22523. // OldName returns the old "name" field's value of the SopStage entity.
  22524. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22525. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22526. func (m *SopStageMutation) OldName(ctx context.Context) (v string, err error) {
  22527. if !m.op.Is(OpUpdateOne) {
  22528. return v, errors.New("OldName is only allowed on UpdateOne operations")
  22529. }
  22530. if m.id == nil || m.oldValue == nil {
  22531. return v, errors.New("OldName requires an ID field in the mutation")
  22532. }
  22533. oldValue, err := m.oldValue(ctx)
  22534. if err != nil {
  22535. return v, fmt.Errorf("querying old value for OldName: %w", err)
  22536. }
  22537. return oldValue.Name, nil
  22538. }
  22539. // ResetName resets all changes to the "name" field.
  22540. func (m *SopStageMutation) ResetName() {
  22541. m.name = nil
  22542. }
  22543. // SetConditionType sets the "condition_type" field.
  22544. func (m *SopStageMutation) SetConditionType(i int) {
  22545. m.condition_type = &i
  22546. m.addcondition_type = nil
  22547. }
  22548. // ConditionType returns the value of the "condition_type" field in the mutation.
  22549. func (m *SopStageMutation) ConditionType() (r int, exists bool) {
  22550. v := m.condition_type
  22551. if v == nil {
  22552. return
  22553. }
  22554. return *v, true
  22555. }
  22556. // OldConditionType returns the old "condition_type" field's value of the SopStage entity.
  22557. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22558. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22559. func (m *SopStageMutation) OldConditionType(ctx context.Context) (v int, err error) {
  22560. if !m.op.Is(OpUpdateOne) {
  22561. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  22562. }
  22563. if m.id == nil || m.oldValue == nil {
  22564. return v, errors.New("OldConditionType requires an ID field in the mutation")
  22565. }
  22566. oldValue, err := m.oldValue(ctx)
  22567. if err != nil {
  22568. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  22569. }
  22570. return oldValue.ConditionType, nil
  22571. }
  22572. // AddConditionType adds i to the "condition_type" field.
  22573. func (m *SopStageMutation) AddConditionType(i int) {
  22574. if m.addcondition_type != nil {
  22575. *m.addcondition_type += i
  22576. } else {
  22577. m.addcondition_type = &i
  22578. }
  22579. }
  22580. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  22581. func (m *SopStageMutation) AddedConditionType() (r int, exists bool) {
  22582. v := m.addcondition_type
  22583. if v == nil {
  22584. return
  22585. }
  22586. return *v, true
  22587. }
  22588. // ResetConditionType resets all changes to the "condition_type" field.
  22589. func (m *SopStageMutation) ResetConditionType() {
  22590. m.condition_type = nil
  22591. m.addcondition_type = nil
  22592. }
  22593. // SetConditionOperator sets the "condition_operator" field.
  22594. func (m *SopStageMutation) SetConditionOperator(i int) {
  22595. m.condition_operator = &i
  22596. m.addcondition_operator = nil
  22597. }
  22598. // ConditionOperator returns the value of the "condition_operator" field in the mutation.
  22599. func (m *SopStageMutation) ConditionOperator() (r int, exists bool) {
  22600. v := m.condition_operator
  22601. if v == nil {
  22602. return
  22603. }
  22604. return *v, true
  22605. }
  22606. // OldConditionOperator returns the old "condition_operator" field's value of the SopStage entity.
  22607. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22608. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22609. func (m *SopStageMutation) OldConditionOperator(ctx context.Context) (v int, err error) {
  22610. if !m.op.Is(OpUpdateOne) {
  22611. return v, errors.New("OldConditionOperator is only allowed on UpdateOne operations")
  22612. }
  22613. if m.id == nil || m.oldValue == nil {
  22614. return v, errors.New("OldConditionOperator requires an ID field in the mutation")
  22615. }
  22616. oldValue, err := m.oldValue(ctx)
  22617. if err != nil {
  22618. return v, fmt.Errorf("querying old value for OldConditionOperator: %w", err)
  22619. }
  22620. return oldValue.ConditionOperator, nil
  22621. }
  22622. // AddConditionOperator adds i to the "condition_operator" field.
  22623. func (m *SopStageMutation) AddConditionOperator(i int) {
  22624. if m.addcondition_operator != nil {
  22625. *m.addcondition_operator += i
  22626. } else {
  22627. m.addcondition_operator = &i
  22628. }
  22629. }
  22630. // AddedConditionOperator returns the value that was added to the "condition_operator" field in this mutation.
  22631. func (m *SopStageMutation) AddedConditionOperator() (r int, exists bool) {
  22632. v := m.addcondition_operator
  22633. if v == nil {
  22634. return
  22635. }
  22636. return *v, true
  22637. }
  22638. // ResetConditionOperator resets all changes to the "condition_operator" field.
  22639. func (m *SopStageMutation) ResetConditionOperator() {
  22640. m.condition_operator = nil
  22641. m.addcondition_operator = nil
  22642. }
  22643. // SetConditionList sets the "condition_list" field.
  22644. func (m *SopStageMutation) SetConditionList(ct []custom_types.Condition) {
  22645. m.condition_list = &ct
  22646. m.appendcondition_list = nil
  22647. }
  22648. // ConditionList returns the value of the "condition_list" field in the mutation.
  22649. func (m *SopStageMutation) ConditionList() (r []custom_types.Condition, exists bool) {
  22650. v := m.condition_list
  22651. if v == nil {
  22652. return
  22653. }
  22654. return *v, true
  22655. }
  22656. // OldConditionList returns the old "condition_list" field's value of the SopStage entity.
  22657. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22658. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22659. func (m *SopStageMutation) OldConditionList(ctx context.Context) (v []custom_types.Condition, err error) {
  22660. if !m.op.Is(OpUpdateOne) {
  22661. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  22662. }
  22663. if m.id == nil || m.oldValue == nil {
  22664. return v, errors.New("OldConditionList requires an ID field in the mutation")
  22665. }
  22666. oldValue, err := m.oldValue(ctx)
  22667. if err != nil {
  22668. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  22669. }
  22670. return oldValue.ConditionList, nil
  22671. }
  22672. // AppendConditionList adds ct to the "condition_list" field.
  22673. func (m *SopStageMutation) AppendConditionList(ct []custom_types.Condition) {
  22674. m.appendcondition_list = append(m.appendcondition_list, ct...)
  22675. }
  22676. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  22677. func (m *SopStageMutation) AppendedConditionList() ([]custom_types.Condition, bool) {
  22678. if len(m.appendcondition_list) == 0 {
  22679. return nil, false
  22680. }
  22681. return m.appendcondition_list, true
  22682. }
  22683. // ResetConditionList resets all changes to the "condition_list" field.
  22684. func (m *SopStageMutation) ResetConditionList() {
  22685. m.condition_list = nil
  22686. m.appendcondition_list = nil
  22687. }
  22688. // SetActionMessage sets the "action_message" field.
  22689. func (m *SopStageMutation) SetActionMessage(ct []custom_types.Action) {
  22690. m.action_message = &ct
  22691. m.appendaction_message = nil
  22692. }
  22693. // ActionMessage returns the value of the "action_message" field in the mutation.
  22694. func (m *SopStageMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  22695. v := m.action_message
  22696. if v == nil {
  22697. return
  22698. }
  22699. return *v, true
  22700. }
  22701. // OldActionMessage returns the old "action_message" field's value of the SopStage entity.
  22702. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22703. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22704. func (m *SopStageMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  22705. if !m.op.Is(OpUpdateOne) {
  22706. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  22707. }
  22708. if m.id == nil || m.oldValue == nil {
  22709. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  22710. }
  22711. oldValue, err := m.oldValue(ctx)
  22712. if err != nil {
  22713. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  22714. }
  22715. return oldValue.ActionMessage, nil
  22716. }
  22717. // AppendActionMessage adds ct to the "action_message" field.
  22718. func (m *SopStageMutation) AppendActionMessage(ct []custom_types.Action) {
  22719. m.appendaction_message = append(m.appendaction_message, ct...)
  22720. }
  22721. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  22722. func (m *SopStageMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  22723. if len(m.appendaction_message) == 0 {
  22724. return nil, false
  22725. }
  22726. return m.appendaction_message, true
  22727. }
  22728. // ClearActionMessage clears the value of the "action_message" field.
  22729. func (m *SopStageMutation) ClearActionMessage() {
  22730. m.action_message = nil
  22731. m.appendaction_message = nil
  22732. m.clearedFields[sopstage.FieldActionMessage] = struct{}{}
  22733. }
  22734. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  22735. func (m *SopStageMutation) ActionMessageCleared() bool {
  22736. _, ok := m.clearedFields[sopstage.FieldActionMessage]
  22737. return ok
  22738. }
  22739. // ResetActionMessage resets all changes to the "action_message" field.
  22740. func (m *SopStageMutation) ResetActionMessage() {
  22741. m.action_message = nil
  22742. m.appendaction_message = nil
  22743. delete(m.clearedFields, sopstage.FieldActionMessage)
  22744. }
  22745. // SetActionLabelAdd sets the "action_label_add" field.
  22746. func (m *SopStageMutation) SetActionLabelAdd(u []uint64) {
  22747. m.action_label_add = &u
  22748. m.appendaction_label_add = nil
  22749. }
  22750. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  22751. func (m *SopStageMutation) ActionLabelAdd() (r []uint64, exists bool) {
  22752. v := m.action_label_add
  22753. if v == nil {
  22754. return
  22755. }
  22756. return *v, true
  22757. }
  22758. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopStage entity.
  22759. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22760. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22761. func (m *SopStageMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  22762. if !m.op.Is(OpUpdateOne) {
  22763. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  22764. }
  22765. if m.id == nil || m.oldValue == nil {
  22766. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  22767. }
  22768. oldValue, err := m.oldValue(ctx)
  22769. if err != nil {
  22770. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  22771. }
  22772. return oldValue.ActionLabelAdd, nil
  22773. }
  22774. // AppendActionLabelAdd adds u to the "action_label_add" field.
  22775. func (m *SopStageMutation) AppendActionLabelAdd(u []uint64) {
  22776. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  22777. }
  22778. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  22779. func (m *SopStageMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  22780. if len(m.appendaction_label_add) == 0 {
  22781. return nil, false
  22782. }
  22783. return m.appendaction_label_add, true
  22784. }
  22785. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  22786. func (m *SopStageMutation) ClearActionLabelAdd() {
  22787. m.action_label_add = nil
  22788. m.appendaction_label_add = nil
  22789. m.clearedFields[sopstage.FieldActionLabelAdd] = struct{}{}
  22790. }
  22791. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  22792. func (m *SopStageMutation) ActionLabelAddCleared() bool {
  22793. _, ok := m.clearedFields[sopstage.FieldActionLabelAdd]
  22794. return ok
  22795. }
  22796. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  22797. func (m *SopStageMutation) ResetActionLabelAdd() {
  22798. m.action_label_add = nil
  22799. m.appendaction_label_add = nil
  22800. delete(m.clearedFields, sopstage.FieldActionLabelAdd)
  22801. }
  22802. // SetActionLabelDel sets the "action_label_del" field.
  22803. func (m *SopStageMutation) SetActionLabelDel(u []uint64) {
  22804. m.action_label_del = &u
  22805. m.appendaction_label_del = nil
  22806. }
  22807. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  22808. func (m *SopStageMutation) ActionLabelDel() (r []uint64, exists bool) {
  22809. v := m.action_label_del
  22810. if v == nil {
  22811. return
  22812. }
  22813. return *v, true
  22814. }
  22815. // OldActionLabelDel returns the old "action_label_del" field's value of the SopStage entity.
  22816. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22817. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22818. func (m *SopStageMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  22819. if !m.op.Is(OpUpdateOne) {
  22820. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  22821. }
  22822. if m.id == nil || m.oldValue == nil {
  22823. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  22824. }
  22825. oldValue, err := m.oldValue(ctx)
  22826. if err != nil {
  22827. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  22828. }
  22829. return oldValue.ActionLabelDel, nil
  22830. }
  22831. // AppendActionLabelDel adds u to the "action_label_del" field.
  22832. func (m *SopStageMutation) AppendActionLabelDel(u []uint64) {
  22833. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  22834. }
  22835. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  22836. func (m *SopStageMutation) AppendedActionLabelDel() ([]uint64, bool) {
  22837. if len(m.appendaction_label_del) == 0 {
  22838. return nil, false
  22839. }
  22840. return m.appendaction_label_del, true
  22841. }
  22842. // ClearActionLabelDel clears the value of the "action_label_del" field.
  22843. func (m *SopStageMutation) ClearActionLabelDel() {
  22844. m.action_label_del = nil
  22845. m.appendaction_label_del = nil
  22846. m.clearedFields[sopstage.FieldActionLabelDel] = struct{}{}
  22847. }
  22848. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  22849. func (m *SopStageMutation) ActionLabelDelCleared() bool {
  22850. _, ok := m.clearedFields[sopstage.FieldActionLabelDel]
  22851. return ok
  22852. }
  22853. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  22854. func (m *SopStageMutation) ResetActionLabelDel() {
  22855. m.action_label_del = nil
  22856. m.appendaction_label_del = nil
  22857. delete(m.clearedFields, sopstage.FieldActionLabelDel)
  22858. }
  22859. // SetActionForward sets the "action_forward" field.
  22860. func (m *SopStageMutation) SetActionForward(ctf *custom_types.ActionForward) {
  22861. m.action_forward = &ctf
  22862. }
  22863. // ActionForward returns the value of the "action_forward" field in the mutation.
  22864. func (m *SopStageMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  22865. v := m.action_forward
  22866. if v == nil {
  22867. return
  22868. }
  22869. return *v, true
  22870. }
  22871. // OldActionForward returns the old "action_forward" field's value of the SopStage entity.
  22872. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22873. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22874. func (m *SopStageMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  22875. if !m.op.Is(OpUpdateOne) {
  22876. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  22877. }
  22878. if m.id == nil || m.oldValue == nil {
  22879. return v, errors.New("OldActionForward requires an ID field in the mutation")
  22880. }
  22881. oldValue, err := m.oldValue(ctx)
  22882. if err != nil {
  22883. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  22884. }
  22885. return oldValue.ActionForward, nil
  22886. }
  22887. // ClearActionForward clears the value of the "action_forward" field.
  22888. func (m *SopStageMutation) ClearActionForward() {
  22889. m.action_forward = nil
  22890. m.clearedFields[sopstage.FieldActionForward] = struct{}{}
  22891. }
  22892. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  22893. func (m *SopStageMutation) ActionForwardCleared() bool {
  22894. _, ok := m.clearedFields[sopstage.FieldActionForward]
  22895. return ok
  22896. }
  22897. // ResetActionForward resets all changes to the "action_forward" field.
  22898. func (m *SopStageMutation) ResetActionForward() {
  22899. m.action_forward = nil
  22900. delete(m.clearedFields, sopstage.FieldActionForward)
  22901. }
  22902. // SetIndexSort sets the "index_sort" field.
  22903. func (m *SopStageMutation) SetIndexSort(i int) {
  22904. m.index_sort = &i
  22905. m.addindex_sort = nil
  22906. }
  22907. // IndexSort returns the value of the "index_sort" field in the mutation.
  22908. func (m *SopStageMutation) IndexSort() (r int, exists bool) {
  22909. v := m.index_sort
  22910. if v == nil {
  22911. return
  22912. }
  22913. return *v, true
  22914. }
  22915. // OldIndexSort returns the old "index_sort" field's value of the SopStage entity.
  22916. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22917. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22918. func (m *SopStageMutation) OldIndexSort(ctx context.Context) (v int, err error) {
  22919. if !m.op.Is(OpUpdateOne) {
  22920. return v, errors.New("OldIndexSort is only allowed on UpdateOne operations")
  22921. }
  22922. if m.id == nil || m.oldValue == nil {
  22923. return v, errors.New("OldIndexSort requires an ID field in the mutation")
  22924. }
  22925. oldValue, err := m.oldValue(ctx)
  22926. if err != nil {
  22927. return v, fmt.Errorf("querying old value for OldIndexSort: %w", err)
  22928. }
  22929. return oldValue.IndexSort, nil
  22930. }
  22931. // AddIndexSort adds i to the "index_sort" field.
  22932. func (m *SopStageMutation) AddIndexSort(i int) {
  22933. if m.addindex_sort != nil {
  22934. *m.addindex_sort += i
  22935. } else {
  22936. m.addindex_sort = &i
  22937. }
  22938. }
  22939. // AddedIndexSort returns the value that was added to the "index_sort" field in this mutation.
  22940. func (m *SopStageMutation) AddedIndexSort() (r int, exists bool) {
  22941. v := m.addindex_sort
  22942. if v == nil {
  22943. return
  22944. }
  22945. return *v, true
  22946. }
  22947. // ClearIndexSort clears the value of the "index_sort" field.
  22948. func (m *SopStageMutation) ClearIndexSort() {
  22949. m.index_sort = nil
  22950. m.addindex_sort = nil
  22951. m.clearedFields[sopstage.FieldIndexSort] = struct{}{}
  22952. }
  22953. // IndexSortCleared returns if the "index_sort" field was cleared in this mutation.
  22954. func (m *SopStageMutation) IndexSortCleared() bool {
  22955. _, ok := m.clearedFields[sopstage.FieldIndexSort]
  22956. return ok
  22957. }
  22958. // ResetIndexSort resets all changes to the "index_sort" field.
  22959. func (m *SopStageMutation) ResetIndexSort() {
  22960. m.index_sort = nil
  22961. m.addindex_sort = nil
  22962. delete(m.clearedFields, sopstage.FieldIndexSort)
  22963. }
  22964. // SetSopTaskID sets the "sop_task" edge to the SopTask entity by id.
  22965. func (m *SopStageMutation) SetSopTaskID(id uint64) {
  22966. m.sop_task = &id
  22967. }
  22968. // ClearSopTask clears the "sop_task" edge to the SopTask entity.
  22969. func (m *SopStageMutation) ClearSopTask() {
  22970. m.clearedsop_task = true
  22971. m.clearedFields[sopstage.FieldTaskID] = struct{}{}
  22972. }
  22973. // SopTaskCleared reports if the "sop_task" edge to the SopTask entity was cleared.
  22974. func (m *SopStageMutation) SopTaskCleared() bool {
  22975. return m.clearedsop_task
  22976. }
  22977. // SopTaskID returns the "sop_task" edge ID in the mutation.
  22978. func (m *SopStageMutation) SopTaskID() (id uint64, exists bool) {
  22979. if m.sop_task != nil {
  22980. return *m.sop_task, true
  22981. }
  22982. return
  22983. }
  22984. // SopTaskIDs returns the "sop_task" edge IDs in the mutation.
  22985. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  22986. // SopTaskID instead. It exists only for internal usage by the builders.
  22987. func (m *SopStageMutation) SopTaskIDs() (ids []uint64) {
  22988. if id := m.sop_task; id != nil {
  22989. ids = append(ids, *id)
  22990. }
  22991. return
  22992. }
  22993. // ResetSopTask resets all changes to the "sop_task" edge.
  22994. func (m *SopStageMutation) ResetSopTask() {
  22995. m.sop_task = nil
  22996. m.clearedsop_task = false
  22997. }
  22998. // AddStageNodeIDs adds the "stage_nodes" edge to the SopNode entity by ids.
  22999. func (m *SopStageMutation) AddStageNodeIDs(ids ...uint64) {
  23000. if m.stage_nodes == nil {
  23001. m.stage_nodes = make(map[uint64]struct{})
  23002. }
  23003. for i := range ids {
  23004. m.stage_nodes[ids[i]] = struct{}{}
  23005. }
  23006. }
  23007. // ClearStageNodes clears the "stage_nodes" edge to the SopNode entity.
  23008. func (m *SopStageMutation) ClearStageNodes() {
  23009. m.clearedstage_nodes = true
  23010. }
  23011. // StageNodesCleared reports if the "stage_nodes" edge to the SopNode entity was cleared.
  23012. func (m *SopStageMutation) StageNodesCleared() bool {
  23013. return m.clearedstage_nodes
  23014. }
  23015. // RemoveStageNodeIDs removes the "stage_nodes" edge to the SopNode entity by IDs.
  23016. func (m *SopStageMutation) RemoveStageNodeIDs(ids ...uint64) {
  23017. if m.removedstage_nodes == nil {
  23018. m.removedstage_nodes = make(map[uint64]struct{})
  23019. }
  23020. for i := range ids {
  23021. delete(m.stage_nodes, ids[i])
  23022. m.removedstage_nodes[ids[i]] = struct{}{}
  23023. }
  23024. }
  23025. // RemovedStageNodes returns the removed IDs of the "stage_nodes" edge to the SopNode entity.
  23026. func (m *SopStageMutation) RemovedStageNodesIDs() (ids []uint64) {
  23027. for id := range m.removedstage_nodes {
  23028. ids = append(ids, id)
  23029. }
  23030. return
  23031. }
  23032. // StageNodesIDs returns the "stage_nodes" edge IDs in the mutation.
  23033. func (m *SopStageMutation) StageNodesIDs() (ids []uint64) {
  23034. for id := range m.stage_nodes {
  23035. ids = append(ids, id)
  23036. }
  23037. return
  23038. }
  23039. // ResetStageNodes resets all changes to the "stage_nodes" edge.
  23040. func (m *SopStageMutation) ResetStageNodes() {
  23041. m.stage_nodes = nil
  23042. m.clearedstage_nodes = false
  23043. m.removedstage_nodes = nil
  23044. }
  23045. // AddStageMessageIDs adds the "stage_messages" edge to the MessageRecords entity by ids.
  23046. func (m *SopStageMutation) AddStageMessageIDs(ids ...uint64) {
  23047. if m.stage_messages == nil {
  23048. m.stage_messages = make(map[uint64]struct{})
  23049. }
  23050. for i := range ids {
  23051. m.stage_messages[ids[i]] = struct{}{}
  23052. }
  23053. }
  23054. // ClearStageMessages clears the "stage_messages" edge to the MessageRecords entity.
  23055. func (m *SopStageMutation) ClearStageMessages() {
  23056. m.clearedstage_messages = true
  23057. }
  23058. // StageMessagesCleared reports if the "stage_messages" edge to the MessageRecords entity was cleared.
  23059. func (m *SopStageMutation) StageMessagesCleared() bool {
  23060. return m.clearedstage_messages
  23061. }
  23062. // RemoveStageMessageIDs removes the "stage_messages" edge to the MessageRecords entity by IDs.
  23063. func (m *SopStageMutation) RemoveStageMessageIDs(ids ...uint64) {
  23064. if m.removedstage_messages == nil {
  23065. m.removedstage_messages = make(map[uint64]struct{})
  23066. }
  23067. for i := range ids {
  23068. delete(m.stage_messages, ids[i])
  23069. m.removedstage_messages[ids[i]] = struct{}{}
  23070. }
  23071. }
  23072. // RemovedStageMessages returns the removed IDs of the "stage_messages" edge to the MessageRecords entity.
  23073. func (m *SopStageMutation) RemovedStageMessagesIDs() (ids []uint64) {
  23074. for id := range m.removedstage_messages {
  23075. ids = append(ids, id)
  23076. }
  23077. return
  23078. }
  23079. // StageMessagesIDs returns the "stage_messages" edge IDs in the mutation.
  23080. func (m *SopStageMutation) StageMessagesIDs() (ids []uint64) {
  23081. for id := range m.stage_messages {
  23082. ids = append(ids, id)
  23083. }
  23084. return
  23085. }
  23086. // ResetStageMessages resets all changes to the "stage_messages" edge.
  23087. func (m *SopStageMutation) ResetStageMessages() {
  23088. m.stage_messages = nil
  23089. m.clearedstage_messages = false
  23090. m.removedstage_messages = nil
  23091. }
  23092. // Where appends a list predicates to the SopStageMutation builder.
  23093. func (m *SopStageMutation) Where(ps ...predicate.SopStage) {
  23094. m.predicates = append(m.predicates, ps...)
  23095. }
  23096. // WhereP appends storage-level predicates to the SopStageMutation builder. Using this method,
  23097. // users can use type-assertion to append predicates that do not depend on any generated package.
  23098. func (m *SopStageMutation) WhereP(ps ...func(*sql.Selector)) {
  23099. p := make([]predicate.SopStage, len(ps))
  23100. for i := range ps {
  23101. p[i] = ps[i]
  23102. }
  23103. m.Where(p...)
  23104. }
  23105. // Op returns the operation name.
  23106. func (m *SopStageMutation) Op() Op {
  23107. return m.op
  23108. }
  23109. // SetOp allows setting the mutation operation.
  23110. func (m *SopStageMutation) SetOp(op Op) {
  23111. m.op = op
  23112. }
  23113. // Type returns the node type of this mutation (SopStage).
  23114. func (m *SopStageMutation) Type() string {
  23115. return m.typ
  23116. }
  23117. // Fields returns all fields that were changed during this mutation. Note that in
  23118. // order to get all numeric fields that were incremented/decremented, call
  23119. // AddedFields().
  23120. func (m *SopStageMutation) Fields() []string {
  23121. fields := make([]string, 0, 14)
  23122. if m.created_at != nil {
  23123. fields = append(fields, sopstage.FieldCreatedAt)
  23124. }
  23125. if m.updated_at != nil {
  23126. fields = append(fields, sopstage.FieldUpdatedAt)
  23127. }
  23128. if m.status != nil {
  23129. fields = append(fields, sopstage.FieldStatus)
  23130. }
  23131. if m.deleted_at != nil {
  23132. fields = append(fields, sopstage.FieldDeletedAt)
  23133. }
  23134. if m.sop_task != nil {
  23135. fields = append(fields, sopstage.FieldTaskID)
  23136. }
  23137. if m.name != nil {
  23138. fields = append(fields, sopstage.FieldName)
  23139. }
  23140. if m.condition_type != nil {
  23141. fields = append(fields, sopstage.FieldConditionType)
  23142. }
  23143. if m.condition_operator != nil {
  23144. fields = append(fields, sopstage.FieldConditionOperator)
  23145. }
  23146. if m.condition_list != nil {
  23147. fields = append(fields, sopstage.FieldConditionList)
  23148. }
  23149. if m.action_message != nil {
  23150. fields = append(fields, sopstage.FieldActionMessage)
  23151. }
  23152. if m.action_label_add != nil {
  23153. fields = append(fields, sopstage.FieldActionLabelAdd)
  23154. }
  23155. if m.action_label_del != nil {
  23156. fields = append(fields, sopstage.FieldActionLabelDel)
  23157. }
  23158. if m.action_forward != nil {
  23159. fields = append(fields, sopstage.FieldActionForward)
  23160. }
  23161. if m.index_sort != nil {
  23162. fields = append(fields, sopstage.FieldIndexSort)
  23163. }
  23164. return fields
  23165. }
  23166. // Field returns the value of a field with the given name. The second boolean
  23167. // return value indicates that this field was not set, or was not defined in the
  23168. // schema.
  23169. func (m *SopStageMutation) Field(name string) (ent.Value, bool) {
  23170. switch name {
  23171. case sopstage.FieldCreatedAt:
  23172. return m.CreatedAt()
  23173. case sopstage.FieldUpdatedAt:
  23174. return m.UpdatedAt()
  23175. case sopstage.FieldStatus:
  23176. return m.Status()
  23177. case sopstage.FieldDeletedAt:
  23178. return m.DeletedAt()
  23179. case sopstage.FieldTaskID:
  23180. return m.TaskID()
  23181. case sopstage.FieldName:
  23182. return m.Name()
  23183. case sopstage.FieldConditionType:
  23184. return m.ConditionType()
  23185. case sopstage.FieldConditionOperator:
  23186. return m.ConditionOperator()
  23187. case sopstage.FieldConditionList:
  23188. return m.ConditionList()
  23189. case sopstage.FieldActionMessage:
  23190. return m.ActionMessage()
  23191. case sopstage.FieldActionLabelAdd:
  23192. return m.ActionLabelAdd()
  23193. case sopstage.FieldActionLabelDel:
  23194. return m.ActionLabelDel()
  23195. case sopstage.FieldActionForward:
  23196. return m.ActionForward()
  23197. case sopstage.FieldIndexSort:
  23198. return m.IndexSort()
  23199. }
  23200. return nil, false
  23201. }
  23202. // OldField returns the old value of the field from the database. An error is
  23203. // returned if the mutation operation is not UpdateOne, or the query to the
  23204. // database failed.
  23205. func (m *SopStageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  23206. switch name {
  23207. case sopstage.FieldCreatedAt:
  23208. return m.OldCreatedAt(ctx)
  23209. case sopstage.FieldUpdatedAt:
  23210. return m.OldUpdatedAt(ctx)
  23211. case sopstage.FieldStatus:
  23212. return m.OldStatus(ctx)
  23213. case sopstage.FieldDeletedAt:
  23214. return m.OldDeletedAt(ctx)
  23215. case sopstage.FieldTaskID:
  23216. return m.OldTaskID(ctx)
  23217. case sopstage.FieldName:
  23218. return m.OldName(ctx)
  23219. case sopstage.FieldConditionType:
  23220. return m.OldConditionType(ctx)
  23221. case sopstage.FieldConditionOperator:
  23222. return m.OldConditionOperator(ctx)
  23223. case sopstage.FieldConditionList:
  23224. return m.OldConditionList(ctx)
  23225. case sopstage.FieldActionMessage:
  23226. return m.OldActionMessage(ctx)
  23227. case sopstage.FieldActionLabelAdd:
  23228. return m.OldActionLabelAdd(ctx)
  23229. case sopstage.FieldActionLabelDel:
  23230. return m.OldActionLabelDel(ctx)
  23231. case sopstage.FieldActionForward:
  23232. return m.OldActionForward(ctx)
  23233. case sopstage.FieldIndexSort:
  23234. return m.OldIndexSort(ctx)
  23235. }
  23236. return nil, fmt.Errorf("unknown SopStage field %s", name)
  23237. }
  23238. // SetField sets the value of a field with the given name. It returns an error if
  23239. // the field is not defined in the schema, or if the type mismatched the field
  23240. // type.
  23241. func (m *SopStageMutation) SetField(name string, value ent.Value) error {
  23242. switch name {
  23243. case sopstage.FieldCreatedAt:
  23244. v, ok := value.(time.Time)
  23245. if !ok {
  23246. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23247. }
  23248. m.SetCreatedAt(v)
  23249. return nil
  23250. case sopstage.FieldUpdatedAt:
  23251. v, ok := value.(time.Time)
  23252. if !ok {
  23253. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23254. }
  23255. m.SetUpdatedAt(v)
  23256. return nil
  23257. case sopstage.FieldStatus:
  23258. v, ok := value.(uint8)
  23259. if !ok {
  23260. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23261. }
  23262. m.SetStatus(v)
  23263. return nil
  23264. case sopstage.FieldDeletedAt:
  23265. v, ok := value.(time.Time)
  23266. if !ok {
  23267. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23268. }
  23269. m.SetDeletedAt(v)
  23270. return nil
  23271. case sopstage.FieldTaskID:
  23272. v, ok := value.(uint64)
  23273. if !ok {
  23274. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23275. }
  23276. m.SetTaskID(v)
  23277. return nil
  23278. case sopstage.FieldName:
  23279. v, ok := value.(string)
  23280. if !ok {
  23281. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23282. }
  23283. m.SetName(v)
  23284. return nil
  23285. case sopstage.FieldConditionType:
  23286. v, ok := value.(int)
  23287. if !ok {
  23288. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23289. }
  23290. m.SetConditionType(v)
  23291. return nil
  23292. case sopstage.FieldConditionOperator:
  23293. v, ok := value.(int)
  23294. if !ok {
  23295. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23296. }
  23297. m.SetConditionOperator(v)
  23298. return nil
  23299. case sopstage.FieldConditionList:
  23300. v, ok := value.([]custom_types.Condition)
  23301. if !ok {
  23302. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23303. }
  23304. m.SetConditionList(v)
  23305. return nil
  23306. case sopstage.FieldActionMessage:
  23307. v, ok := value.([]custom_types.Action)
  23308. if !ok {
  23309. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23310. }
  23311. m.SetActionMessage(v)
  23312. return nil
  23313. case sopstage.FieldActionLabelAdd:
  23314. v, ok := value.([]uint64)
  23315. if !ok {
  23316. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23317. }
  23318. m.SetActionLabelAdd(v)
  23319. return nil
  23320. case sopstage.FieldActionLabelDel:
  23321. v, ok := value.([]uint64)
  23322. if !ok {
  23323. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23324. }
  23325. m.SetActionLabelDel(v)
  23326. return nil
  23327. case sopstage.FieldActionForward:
  23328. v, ok := value.(*custom_types.ActionForward)
  23329. if !ok {
  23330. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23331. }
  23332. m.SetActionForward(v)
  23333. return nil
  23334. case sopstage.FieldIndexSort:
  23335. v, ok := value.(int)
  23336. if !ok {
  23337. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23338. }
  23339. m.SetIndexSort(v)
  23340. return nil
  23341. }
  23342. return fmt.Errorf("unknown SopStage field %s", name)
  23343. }
  23344. // AddedFields returns all numeric fields that were incremented/decremented during
  23345. // this mutation.
  23346. func (m *SopStageMutation) AddedFields() []string {
  23347. var fields []string
  23348. if m.addstatus != nil {
  23349. fields = append(fields, sopstage.FieldStatus)
  23350. }
  23351. if m.addcondition_type != nil {
  23352. fields = append(fields, sopstage.FieldConditionType)
  23353. }
  23354. if m.addcondition_operator != nil {
  23355. fields = append(fields, sopstage.FieldConditionOperator)
  23356. }
  23357. if m.addindex_sort != nil {
  23358. fields = append(fields, sopstage.FieldIndexSort)
  23359. }
  23360. return fields
  23361. }
  23362. // AddedField returns the numeric value that was incremented/decremented on a field
  23363. // with the given name. The second boolean return value indicates that this field
  23364. // was not set, or was not defined in the schema.
  23365. func (m *SopStageMutation) AddedField(name string) (ent.Value, bool) {
  23366. switch name {
  23367. case sopstage.FieldStatus:
  23368. return m.AddedStatus()
  23369. case sopstage.FieldConditionType:
  23370. return m.AddedConditionType()
  23371. case sopstage.FieldConditionOperator:
  23372. return m.AddedConditionOperator()
  23373. case sopstage.FieldIndexSort:
  23374. return m.AddedIndexSort()
  23375. }
  23376. return nil, false
  23377. }
  23378. // AddField adds the value to the field with the given name. It returns an error if
  23379. // the field is not defined in the schema, or if the type mismatched the field
  23380. // type.
  23381. func (m *SopStageMutation) AddField(name string, value ent.Value) error {
  23382. switch name {
  23383. case sopstage.FieldStatus:
  23384. v, ok := value.(int8)
  23385. if !ok {
  23386. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23387. }
  23388. m.AddStatus(v)
  23389. return nil
  23390. case sopstage.FieldConditionType:
  23391. v, ok := value.(int)
  23392. if !ok {
  23393. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23394. }
  23395. m.AddConditionType(v)
  23396. return nil
  23397. case sopstage.FieldConditionOperator:
  23398. v, ok := value.(int)
  23399. if !ok {
  23400. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23401. }
  23402. m.AddConditionOperator(v)
  23403. return nil
  23404. case sopstage.FieldIndexSort:
  23405. v, ok := value.(int)
  23406. if !ok {
  23407. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23408. }
  23409. m.AddIndexSort(v)
  23410. return nil
  23411. }
  23412. return fmt.Errorf("unknown SopStage numeric field %s", name)
  23413. }
  23414. // ClearedFields returns all nullable fields that were cleared during this
  23415. // mutation.
  23416. func (m *SopStageMutation) ClearedFields() []string {
  23417. var fields []string
  23418. if m.FieldCleared(sopstage.FieldStatus) {
  23419. fields = append(fields, sopstage.FieldStatus)
  23420. }
  23421. if m.FieldCleared(sopstage.FieldDeletedAt) {
  23422. fields = append(fields, sopstage.FieldDeletedAt)
  23423. }
  23424. if m.FieldCleared(sopstage.FieldActionMessage) {
  23425. fields = append(fields, sopstage.FieldActionMessage)
  23426. }
  23427. if m.FieldCleared(sopstage.FieldActionLabelAdd) {
  23428. fields = append(fields, sopstage.FieldActionLabelAdd)
  23429. }
  23430. if m.FieldCleared(sopstage.FieldActionLabelDel) {
  23431. fields = append(fields, sopstage.FieldActionLabelDel)
  23432. }
  23433. if m.FieldCleared(sopstage.FieldActionForward) {
  23434. fields = append(fields, sopstage.FieldActionForward)
  23435. }
  23436. if m.FieldCleared(sopstage.FieldIndexSort) {
  23437. fields = append(fields, sopstage.FieldIndexSort)
  23438. }
  23439. return fields
  23440. }
  23441. // FieldCleared returns a boolean indicating if a field with the given name was
  23442. // cleared in this mutation.
  23443. func (m *SopStageMutation) FieldCleared(name string) bool {
  23444. _, ok := m.clearedFields[name]
  23445. return ok
  23446. }
  23447. // ClearField clears the value of the field with the given name. It returns an
  23448. // error if the field is not defined in the schema.
  23449. func (m *SopStageMutation) ClearField(name string) error {
  23450. switch name {
  23451. case sopstage.FieldStatus:
  23452. m.ClearStatus()
  23453. return nil
  23454. case sopstage.FieldDeletedAt:
  23455. m.ClearDeletedAt()
  23456. return nil
  23457. case sopstage.FieldActionMessage:
  23458. m.ClearActionMessage()
  23459. return nil
  23460. case sopstage.FieldActionLabelAdd:
  23461. m.ClearActionLabelAdd()
  23462. return nil
  23463. case sopstage.FieldActionLabelDel:
  23464. m.ClearActionLabelDel()
  23465. return nil
  23466. case sopstage.FieldActionForward:
  23467. m.ClearActionForward()
  23468. return nil
  23469. case sopstage.FieldIndexSort:
  23470. m.ClearIndexSort()
  23471. return nil
  23472. }
  23473. return fmt.Errorf("unknown SopStage nullable field %s", name)
  23474. }
  23475. // ResetField resets all changes in the mutation for the field with the given name.
  23476. // It returns an error if the field is not defined in the schema.
  23477. func (m *SopStageMutation) ResetField(name string) error {
  23478. switch name {
  23479. case sopstage.FieldCreatedAt:
  23480. m.ResetCreatedAt()
  23481. return nil
  23482. case sopstage.FieldUpdatedAt:
  23483. m.ResetUpdatedAt()
  23484. return nil
  23485. case sopstage.FieldStatus:
  23486. m.ResetStatus()
  23487. return nil
  23488. case sopstage.FieldDeletedAt:
  23489. m.ResetDeletedAt()
  23490. return nil
  23491. case sopstage.FieldTaskID:
  23492. m.ResetTaskID()
  23493. return nil
  23494. case sopstage.FieldName:
  23495. m.ResetName()
  23496. return nil
  23497. case sopstage.FieldConditionType:
  23498. m.ResetConditionType()
  23499. return nil
  23500. case sopstage.FieldConditionOperator:
  23501. m.ResetConditionOperator()
  23502. return nil
  23503. case sopstage.FieldConditionList:
  23504. m.ResetConditionList()
  23505. return nil
  23506. case sopstage.FieldActionMessage:
  23507. m.ResetActionMessage()
  23508. return nil
  23509. case sopstage.FieldActionLabelAdd:
  23510. m.ResetActionLabelAdd()
  23511. return nil
  23512. case sopstage.FieldActionLabelDel:
  23513. m.ResetActionLabelDel()
  23514. return nil
  23515. case sopstage.FieldActionForward:
  23516. m.ResetActionForward()
  23517. return nil
  23518. case sopstage.FieldIndexSort:
  23519. m.ResetIndexSort()
  23520. return nil
  23521. }
  23522. return fmt.Errorf("unknown SopStage field %s", name)
  23523. }
  23524. // AddedEdges returns all edge names that were set/added in this mutation.
  23525. func (m *SopStageMutation) AddedEdges() []string {
  23526. edges := make([]string, 0, 3)
  23527. if m.sop_task != nil {
  23528. edges = append(edges, sopstage.EdgeSopTask)
  23529. }
  23530. if m.stage_nodes != nil {
  23531. edges = append(edges, sopstage.EdgeStageNodes)
  23532. }
  23533. if m.stage_messages != nil {
  23534. edges = append(edges, sopstage.EdgeStageMessages)
  23535. }
  23536. return edges
  23537. }
  23538. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  23539. // name in this mutation.
  23540. func (m *SopStageMutation) AddedIDs(name string) []ent.Value {
  23541. switch name {
  23542. case sopstage.EdgeSopTask:
  23543. if id := m.sop_task; id != nil {
  23544. return []ent.Value{*id}
  23545. }
  23546. case sopstage.EdgeStageNodes:
  23547. ids := make([]ent.Value, 0, len(m.stage_nodes))
  23548. for id := range m.stage_nodes {
  23549. ids = append(ids, id)
  23550. }
  23551. return ids
  23552. case sopstage.EdgeStageMessages:
  23553. ids := make([]ent.Value, 0, len(m.stage_messages))
  23554. for id := range m.stage_messages {
  23555. ids = append(ids, id)
  23556. }
  23557. return ids
  23558. }
  23559. return nil
  23560. }
  23561. // RemovedEdges returns all edge names that were removed in this mutation.
  23562. func (m *SopStageMutation) RemovedEdges() []string {
  23563. edges := make([]string, 0, 3)
  23564. if m.removedstage_nodes != nil {
  23565. edges = append(edges, sopstage.EdgeStageNodes)
  23566. }
  23567. if m.removedstage_messages != nil {
  23568. edges = append(edges, sopstage.EdgeStageMessages)
  23569. }
  23570. return edges
  23571. }
  23572. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  23573. // the given name in this mutation.
  23574. func (m *SopStageMutation) RemovedIDs(name string) []ent.Value {
  23575. switch name {
  23576. case sopstage.EdgeStageNodes:
  23577. ids := make([]ent.Value, 0, len(m.removedstage_nodes))
  23578. for id := range m.removedstage_nodes {
  23579. ids = append(ids, id)
  23580. }
  23581. return ids
  23582. case sopstage.EdgeStageMessages:
  23583. ids := make([]ent.Value, 0, len(m.removedstage_messages))
  23584. for id := range m.removedstage_messages {
  23585. ids = append(ids, id)
  23586. }
  23587. return ids
  23588. }
  23589. return nil
  23590. }
  23591. // ClearedEdges returns all edge names that were cleared in this mutation.
  23592. func (m *SopStageMutation) ClearedEdges() []string {
  23593. edges := make([]string, 0, 3)
  23594. if m.clearedsop_task {
  23595. edges = append(edges, sopstage.EdgeSopTask)
  23596. }
  23597. if m.clearedstage_nodes {
  23598. edges = append(edges, sopstage.EdgeStageNodes)
  23599. }
  23600. if m.clearedstage_messages {
  23601. edges = append(edges, sopstage.EdgeStageMessages)
  23602. }
  23603. return edges
  23604. }
  23605. // EdgeCleared returns a boolean which indicates if the edge with the given name
  23606. // was cleared in this mutation.
  23607. func (m *SopStageMutation) EdgeCleared(name string) bool {
  23608. switch name {
  23609. case sopstage.EdgeSopTask:
  23610. return m.clearedsop_task
  23611. case sopstage.EdgeStageNodes:
  23612. return m.clearedstage_nodes
  23613. case sopstage.EdgeStageMessages:
  23614. return m.clearedstage_messages
  23615. }
  23616. return false
  23617. }
  23618. // ClearEdge clears the value of the edge with the given name. It returns an error
  23619. // if that edge is not defined in the schema.
  23620. func (m *SopStageMutation) ClearEdge(name string) error {
  23621. switch name {
  23622. case sopstage.EdgeSopTask:
  23623. m.ClearSopTask()
  23624. return nil
  23625. }
  23626. return fmt.Errorf("unknown SopStage unique edge %s", name)
  23627. }
  23628. // ResetEdge resets all changes to the edge with the given name in this mutation.
  23629. // It returns an error if the edge is not defined in the schema.
  23630. func (m *SopStageMutation) ResetEdge(name string) error {
  23631. switch name {
  23632. case sopstage.EdgeSopTask:
  23633. m.ResetSopTask()
  23634. return nil
  23635. case sopstage.EdgeStageNodes:
  23636. m.ResetStageNodes()
  23637. return nil
  23638. case sopstage.EdgeStageMessages:
  23639. m.ResetStageMessages()
  23640. return nil
  23641. }
  23642. return fmt.Errorf("unknown SopStage edge %s", name)
  23643. }
  23644. // SopTaskMutation represents an operation that mutates the SopTask nodes in the graph.
  23645. type SopTaskMutation struct {
  23646. config
  23647. op Op
  23648. typ string
  23649. id *uint64
  23650. created_at *time.Time
  23651. updated_at *time.Time
  23652. status *uint8
  23653. addstatus *int8
  23654. deleted_at *time.Time
  23655. name *string
  23656. bot_wxid_list *[]string
  23657. appendbot_wxid_list []string
  23658. _type *int
  23659. add_type *int
  23660. plan_start_time *time.Time
  23661. plan_end_time *time.Time
  23662. creator_id *string
  23663. organization_id *uint64
  23664. addorganization_id *int64
  23665. token *[]string
  23666. appendtoken []string
  23667. clearedFields map[string]struct{}
  23668. task_stages map[uint64]struct{}
  23669. removedtask_stages map[uint64]struct{}
  23670. clearedtask_stages bool
  23671. done bool
  23672. oldValue func(context.Context) (*SopTask, error)
  23673. predicates []predicate.SopTask
  23674. }
  23675. var _ ent.Mutation = (*SopTaskMutation)(nil)
  23676. // soptaskOption allows management of the mutation configuration using functional options.
  23677. type soptaskOption func(*SopTaskMutation)
  23678. // newSopTaskMutation creates new mutation for the SopTask entity.
  23679. func newSopTaskMutation(c config, op Op, opts ...soptaskOption) *SopTaskMutation {
  23680. m := &SopTaskMutation{
  23681. config: c,
  23682. op: op,
  23683. typ: TypeSopTask,
  23684. clearedFields: make(map[string]struct{}),
  23685. }
  23686. for _, opt := range opts {
  23687. opt(m)
  23688. }
  23689. return m
  23690. }
  23691. // withSopTaskID sets the ID field of the mutation.
  23692. func withSopTaskID(id uint64) soptaskOption {
  23693. return func(m *SopTaskMutation) {
  23694. var (
  23695. err error
  23696. once sync.Once
  23697. value *SopTask
  23698. )
  23699. m.oldValue = func(ctx context.Context) (*SopTask, error) {
  23700. once.Do(func() {
  23701. if m.done {
  23702. err = errors.New("querying old values post mutation is not allowed")
  23703. } else {
  23704. value, err = m.Client().SopTask.Get(ctx, id)
  23705. }
  23706. })
  23707. return value, err
  23708. }
  23709. m.id = &id
  23710. }
  23711. }
  23712. // withSopTask sets the old SopTask of the mutation.
  23713. func withSopTask(node *SopTask) soptaskOption {
  23714. return func(m *SopTaskMutation) {
  23715. m.oldValue = func(context.Context) (*SopTask, error) {
  23716. return node, nil
  23717. }
  23718. m.id = &node.ID
  23719. }
  23720. }
  23721. // Client returns a new `ent.Client` from the mutation. If the mutation was
  23722. // executed in a transaction (ent.Tx), a transactional client is returned.
  23723. func (m SopTaskMutation) Client() *Client {
  23724. client := &Client{config: m.config}
  23725. client.init()
  23726. return client
  23727. }
  23728. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  23729. // it returns an error otherwise.
  23730. func (m SopTaskMutation) Tx() (*Tx, error) {
  23731. if _, ok := m.driver.(*txDriver); !ok {
  23732. return nil, errors.New("ent: mutation is not running in a transaction")
  23733. }
  23734. tx := &Tx{config: m.config}
  23735. tx.init()
  23736. return tx, nil
  23737. }
  23738. // SetID sets the value of the id field. Note that this
  23739. // operation is only accepted on creation of SopTask entities.
  23740. func (m *SopTaskMutation) SetID(id uint64) {
  23741. m.id = &id
  23742. }
  23743. // ID returns the ID value in the mutation. Note that the ID is only available
  23744. // if it was provided to the builder or after it was returned from the database.
  23745. func (m *SopTaskMutation) ID() (id uint64, exists bool) {
  23746. if m.id == nil {
  23747. return
  23748. }
  23749. return *m.id, true
  23750. }
  23751. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  23752. // That means, if the mutation is applied within a transaction with an isolation level such
  23753. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  23754. // or updated by the mutation.
  23755. func (m *SopTaskMutation) IDs(ctx context.Context) ([]uint64, error) {
  23756. switch {
  23757. case m.op.Is(OpUpdateOne | OpDeleteOne):
  23758. id, exists := m.ID()
  23759. if exists {
  23760. return []uint64{id}, nil
  23761. }
  23762. fallthrough
  23763. case m.op.Is(OpUpdate | OpDelete):
  23764. return m.Client().SopTask.Query().Where(m.predicates...).IDs(ctx)
  23765. default:
  23766. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  23767. }
  23768. }
  23769. // SetCreatedAt sets the "created_at" field.
  23770. func (m *SopTaskMutation) SetCreatedAt(t time.Time) {
  23771. m.created_at = &t
  23772. }
  23773. // CreatedAt returns the value of the "created_at" field in the mutation.
  23774. func (m *SopTaskMutation) CreatedAt() (r time.Time, exists bool) {
  23775. v := m.created_at
  23776. if v == nil {
  23777. return
  23778. }
  23779. return *v, true
  23780. }
  23781. // OldCreatedAt returns the old "created_at" field's value of the SopTask entity.
  23782. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  23783. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23784. func (m *SopTaskMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  23785. if !m.op.Is(OpUpdateOne) {
  23786. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  23787. }
  23788. if m.id == nil || m.oldValue == nil {
  23789. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  23790. }
  23791. oldValue, err := m.oldValue(ctx)
  23792. if err != nil {
  23793. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  23794. }
  23795. return oldValue.CreatedAt, nil
  23796. }
  23797. // ResetCreatedAt resets all changes to the "created_at" field.
  23798. func (m *SopTaskMutation) ResetCreatedAt() {
  23799. m.created_at = nil
  23800. }
  23801. // SetUpdatedAt sets the "updated_at" field.
  23802. func (m *SopTaskMutation) SetUpdatedAt(t time.Time) {
  23803. m.updated_at = &t
  23804. }
  23805. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  23806. func (m *SopTaskMutation) UpdatedAt() (r time.Time, exists bool) {
  23807. v := m.updated_at
  23808. if v == nil {
  23809. return
  23810. }
  23811. return *v, true
  23812. }
  23813. // OldUpdatedAt returns the old "updated_at" field's value of the SopTask entity.
  23814. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  23815. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23816. func (m *SopTaskMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  23817. if !m.op.Is(OpUpdateOne) {
  23818. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  23819. }
  23820. if m.id == nil || m.oldValue == nil {
  23821. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  23822. }
  23823. oldValue, err := m.oldValue(ctx)
  23824. if err != nil {
  23825. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  23826. }
  23827. return oldValue.UpdatedAt, nil
  23828. }
  23829. // ResetUpdatedAt resets all changes to the "updated_at" field.
  23830. func (m *SopTaskMutation) ResetUpdatedAt() {
  23831. m.updated_at = nil
  23832. }
  23833. // SetStatus sets the "status" field.
  23834. func (m *SopTaskMutation) SetStatus(u uint8) {
  23835. m.status = &u
  23836. m.addstatus = nil
  23837. }
  23838. // Status returns the value of the "status" field in the mutation.
  23839. func (m *SopTaskMutation) Status() (r uint8, exists bool) {
  23840. v := m.status
  23841. if v == nil {
  23842. return
  23843. }
  23844. return *v, true
  23845. }
  23846. // OldStatus returns the old "status" field's value of the SopTask entity.
  23847. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  23848. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23849. func (m *SopTaskMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  23850. if !m.op.Is(OpUpdateOne) {
  23851. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  23852. }
  23853. if m.id == nil || m.oldValue == nil {
  23854. return v, errors.New("OldStatus requires an ID field in the mutation")
  23855. }
  23856. oldValue, err := m.oldValue(ctx)
  23857. if err != nil {
  23858. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  23859. }
  23860. return oldValue.Status, nil
  23861. }
  23862. // AddStatus adds u to the "status" field.
  23863. func (m *SopTaskMutation) AddStatus(u int8) {
  23864. if m.addstatus != nil {
  23865. *m.addstatus += u
  23866. } else {
  23867. m.addstatus = &u
  23868. }
  23869. }
  23870. // AddedStatus returns the value that was added to the "status" field in this mutation.
  23871. func (m *SopTaskMutation) AddedStatus() (r int8, exists bool) {
  23872. v := m.addstatus
  23873. if v == nil {
  23874. return
  23875. }
  23876. return *v, true
  23877. }
  23878. // ClearStatus clears the value of the "status" field.
  23879. func (m *SopTaskMutation) ClearStatus() {
  23880. m.status = nil
  23881. m.addstatus = nil
  23882. m.clearedFields[soptask.FieldStatus] = struct{}{}
  23883. }
  23884. // StatusCleared returns if the "status" field was cleared in this mutation.
  23885. func (m *SopTaskMutation) StatusCleared() bool {
  23886. _, ok := m.clearedFields[soptask.FieldStatus]
  23887. return ok
  23888. }
  23889. // ResetStatus resets all changes to the "status" field.
  23890. func (m *SopTaskMutation) ResetStatus() {
  23891. m.status = nil
  23892. m.addstatus = nil
  23893. delete(m.clearedFields, soptask.FieldStatus)
  23894. }
  23895. // SetDeletedAt sets the "deleted_at" field.
  23896. func (m *SopTaskMutation) SetDeletedAt(t time.Time) {
  23897. m.deleted_at = &t
  23898. }
  23899. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  23900. func (m *SopTaskMutation) DeletedAt() (r time.Time, exists bool) {
  23901. v := m.deleted_at
  23902. if v == nil {
  23903. return
  23904. }
  23905. return *v, true
  23906. }
  23907. // OldDeletedAt returns the old "deleted_at" field's value of the SopTask entity.
  23908. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  23909. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23910. func (m *SopTaskMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  23911. if !m.op.Is(OpUpdateOne) {
  23912. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  23913. }
  23914. if m.id == nil || m.oldValue == nil {
  23915. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  23916. }
  23917. oldValue, err := m.oldValue(ctx)
  23918. if err != nil {
  23919. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  23920. }
  23921. return oldValue.DeletedAt, nil
  23922. }
  23923. // ClearDeletedAt clears the value of the "deleted_at" field.
  23924. func (m *SopTaskMutation) ClearDeletedAt() {
  23925. m.deleted_at = nil
  23926. m.clearedFields[soptask.FieldDeletedAt] = struct{}{}
  23927. }
  23928. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  23929. func (m *SopTaskMutation) DeletedAtCleared() bool {
  23930. _, ok := m.clearedFields[soptask.FieldDeletedAt]
  23931. return ok
  23932. }
  23933. // ResetDeletedAt resets all changes to the "deleted_at" field.
  23934. func (m *SopTaskMutation) ResetDeletedAt() {
  23935. m.deleted_at = nil
  23936. delete(m.clearedFields, soptask.FieldDeletedAt)
  23937. }
  23938. // SetName sets the "name" field.
  23939. func (m *SopTaskMutation) SetName(s string) {
  23940. m.name = &s
  23941. }
  23942. // Name returns the value of the "name" field in the mutation.
  23943. func (m *SopTaskMutation) Name() (r string, exists bool) {
  23944. v := m.name
  23945. if v == nil {
  23946. return
  23947. }
  23948. return *v, true
  23949. }
  23950. // OldName returns the old "name" field's value of the SopTask entity.
  23951. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  23952. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23953. func (m *SopTaskMutation) OldName(ctx context.Context) (v string, err error) {
  23954. if !m.op.Is(OpUpdateOne) {
  23955. return v, errors.New("OldName is only allowed on UpdateOne operations")
  23956. }
  23957. if m.id == nil || m.oldValue == nil {
  23958. return v, errors.New("OldName requires an ID field in the mutation")
  23959. }
  23960. oldValue, err := m.oldValue(ctx)
  23961. if err != nil {
  23962. return v, fmt.Errorf("querying old value for OldName: %w", err)
  23963. }
  23964. return oldValue.Name, nil
  23965. }
  23966. // ResetName resets all changes to the "name" field.
  23967. func (m *SopTaskMutation) ResetName() {
  23968. m.name = nil
  23969. }
  23970. // SetBotWxidList sets the "bot_wxid_list" field.
  23971. func (m *SopTaskMutation) SetBotWxidList(s []string) {
  23972. m.bot_wxid_list = &s
  23973. m.appendbot_wxid_list = nil
  23974. }
  23975. // BotWxidList returns the value of the "bot_wxid_list" field in the mutation.
  23976. func (m *SopTaskMutation) BotWxidList() (r []string, exists bool) {
  23977. v := m.bot_wxid_list
  23978. if v == nil {
  23979. return
  23980. }
  23981. return *v, true
  23982. }
  23983. // OldBotWxidList returns the old "bot_wxid_list" field's value of the SopTask entity.
  23984. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  23985. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23986. func (m *SopTaskMutation) OldBotWxidList(ctx context.Context) (v []string, err error) {
  23987. if !m.op.Is(OpUpdateOne) {
  23988. return v, errors.New("OldBotWxidList is only allowed on UpdateOne operations")
  23989. }
  23990. if m.id == nil || m.oldValue == nil {
  23991. return v, errors.New("OldBotWxidList requires an ID field in the mutation")
  23992. }
  23993. oldValue, err := m.oldValue(ctx)
  23994. if err != nil {
  23995. return v, fmt.Errorf("querying old value for OldBotWxidList: %w", err)
  23996. }
  23997. return oldValue.BotWxidList, nil
  23998. }
  23999. // AppendBotWxidList adds s to the "bot_wxid_list" field.
  24000. func (m *SopTaskMutation) AppendBotWxidList(s []string) {
  24001. m.appendbot_wxid_list = append(m.appendbot_wxid_list, s...)
  24002. }
  24003. // AppendedBotWxidList returns the list of values that were appended to the "bot_wxid_list" field in this mutation.
  24004. func (m *SopTaskMutation) AppendedBotWxidList() ([]string, bool) {
  24005. if len(m.appendbot_wxid_list) == 0 {
  24006. return nil, false
  24007. }
  24008. return m.appendbot_wxid_list, true
  24009. }
  24010. // ClearBotWxidList clears the value of the "bot_wxid_list" field.
  24011. func (m *SopTaskMutation) ClearBotWxidList() {
  24012. m.bot_wxid_list = nil
  24013. m.appendbot_wxid_list = nil
  24014. m.clearedFields[soptask.FieldBotWxidList] = struct{}{}
  24015. }
  24016. // BotWxidListCleared returns if the "bot_wxid_list" field was cleared in this mutation.
  24017. func (m *SopTaskMutation) BotWxidListCleared() bool {
  24018. _, ok := m.clearedFields[soptask.FieldBotWxidList]
  24019. return ok
  24020. }
  24021. // ResetBotWxidList resets all changes to the "bot_wxid_list" field.
  24022. func (m *SopTaskMutation) ResetBotWxidList() {
  24023. m.bot_wxid_list = nil
  24024. m.appendbot_wxid_list = nil
  24025. delete(m.clearedFields, soptask.FieldBotWxidList)
  24026. }
  24027. // SetType sets the "type" field.
  24028. func (m *SopTaskMutation) SetType(i int) {
  24029. m._type = &i
  24030. m.add_type = nil
  24031. }
  24032. // GetType returns the value of the "type" field in the mutation.
  24033. func (m *SopTaskMutation) GetType() (r int, exists bool) {
  24034. v := m._type
  24035. if v == nil {
  24036. return
  24037. }
  24038. return *v, true
  24039. }
  24040. // OldType returns the old "type" field's value of the SopTask entity.
  24041. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  24042. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24043. func (m *SopTaskMutation) OldType(ctx context.Context) (v int, err error) {
  24044. if !m.op.Is(OpUpdateOne) {
  24045. return v, errors.New("OldType is only allowed on UpdateOne operations")
  24046. }
  24047. if m.id == nil || m.oldValue == nil {
  24048. return v, errors.New("OldType requires an ID field in the mutation")
  24049. }
  24050. oldValue, err := m.oldValue(ctx)
  24051. if err != nil {
  24052. return v, fmt.Errorf("querying old value for OldType: %w", err)
  24053. }
  24054. return oldValue.Type, nil
  24055. }
  24056. // AddType adds i to the "type" field.
  24057. func (m *SopTaskMutation) AddType(i int) {
  24058. if m.add_type != nil {
  24059. *m.add_type += i
  24060. } else {
  24061. m.add_type = &i
  24062. }
  24063. }
  24064. // AddedType returns the value that was added to the "type" field in this mutation.
  24065. func (m *SopTaskMutation) AddedType() (r int, exists bool) {
  24066. v := m.add_type
  24067. if v == nil {
  24068. return
  24069. }
  24070. return *v, true
  24071. }
  24072. // ResetType resets all changes to the "type" field.
  24073. func (m *SopTaskMutation) ResetType() {
  24074. m._type = nil
  24075. m.add_type = nil
  24076. }
  24077. // SetPlanStartTime sets the "plan_start_time" field.
  24078. func (m *SopTaskMutation) SetPlanStartTime(t time.Time) {
  24079. m.plan_start_time = &t
  24080. }
  24081. // PlanStartTime returns the value of the "plan_start_time" field in the mutation.
  24082. func (m *SopTaskMutation) PlanStartTime() (r time.Time, exists bool) {
  24083. v := m.plan_start_time
  24084. if v == nil {
  24085. return
  24086. }
  24087. return *v, true
  24088. }
  24089. // OldPlanStartTime returns the old "plan_start_time" field's value of the SopTask entity.
  24090. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  24091. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24092. func (m *SopTaskMutation) OldPlanStartTime(ctx context.Context) (v time.Time, err error) {
  24093. if !m.op.Is(OpUpdateOne) {
  24094. return v, errors.New("OldPlanStartTime is only allowed on UpdateOne operations")
  24095. }
  24096. if m.id == nil || m.oldValue == nil {
  24097. return v, errors.New("OldPlanStartTime requires an ID field in the mutation")
  24098. }
  24099. oldValue, err := m.oldValue(ctx)
  24100. if err != nil {
  24101. return v, fmt.Errorf("querying old value for OldPlanStartTime: %w", err)
  24102. }
  24103. return oldValue.PlanStartTime, nil
  24104. }
  24105. // ClearPlanStartTime clears the value of the "plan_start_time" field.
  24106. func (m *SopTaskMutation) ClearPlanStartTime() {
  24107. m.plan_start_time = nil
  24108. m.clearedFields[soptask.FieldPlanStartTime] = struct{}{}
  24109. }
  24110. // PlanStartTimeCleared returns if the "plan_start_time" field was cleared in this mutation.
  24111. func (m *SopTaskMutation) PlanStartTimeCleared() bool {
  24112. _, ok := m.clearedFields[soptask.FieldPlanStartTime]
  24113. return ok
  24114. }
  24115. // ResetPlanStartTime resets all changes to the "plan_start_time" field.
  24116. func (m *SopTaskMutation) ResetPlanStartTime() {
  24117. m.plan_start_time = nil
  24118. delete(m.clearedFields, soptask.FieldPlanStartTime)
  24119. }
  24120. // SetPlanEndTime sets the "plan_end_time" field.
  24121. func (m *SopTaskMutation) SetPlanEndTime(t time.Time) {
  24122. m.plan_end_time = &t
  24123. }
  24124. // PlanEndTime returns the value of the "plan_end_time" field in the mutation.
  24125. func (m *SopTaskMutation) PlanEndTime() (r time.Time, exists bool) {
  24126. v := m.plan_end_time
  24127. if v == nil {
  24128. return
  24129. }
  24130. return *v, true
  24131. }
  24132. // OldPlanEndTime returns the old "plan_end_time" field's value of the SopTask entity.
  24133. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  24134. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24135. func (m *SopTaskMutation) OldPlanEndTime(ctx context.Context) (v time.Time, err error) {
  24136. if !m.op.Is(OpUpdateOne) {
  24137. return v, errors.New("OldPlanEndTime is only allowed on UpdateOne operations")
  24138. }
  24139. if m.id == nil || m.oldValue == nil {
  24140. return v, errors.New("OldPlanEndTime requires an ID field in the mutation")
  24141. }
  24142. oldValue, err := m.oldValue(ctx)
  24143. if err != nil {
  24144. return v, fmt.Errorf("querying old value for OldPlanEndTime: %w", err)
  24145. }
  24146. return oldValue.PlanEndTime, nil
  24147. }
  24148. // ClearPlanEndTime clears the value of the "plan_end_time" field.
  24149. func (m *SopTaskMutation) ClearPlanEndTime() {
  24150. m.plan_end_time = nil
  24151. m.clearedFields[soptask.FieldPlanEndTime] = struct{}{}
  24152. }
  24153. // PlanEndTimeCleared returns if the "plan_end_time" field was cleared in this mutation.
  24154. func (m *SopTaskMutation) PlanEndTimeCleared() bool {
  24155. _, ok := m.clearedFields[soptask.FieldPlanEndTime]
  24156. return ok
  24157. }
  24158. // ResetPlanEndTime resets all changes to the "plan_end_time" field.
  24159. func (m *SopTaskMutation) ResetPlanEndTime() {
  24160. m.plan_end_time = nil
  24161. delete(m.clearedFields, soptask.FieldPlanEndTime)
  24162. }
  24163. // SetCreatorID sets the "creator_id" field.
  24164. func (m *SopTaskMutation) SetCreatorID(s string) {
  24165. m.creator_id = &s
  24166. }
  24167. // CreatorID returns the value of the "creator_id" field in the mutation.
  24168. func (m *SopTaskMutation) CreatorID() (r string, exists bool) {
  24169. v := m.creator_id
  24170. if v == nil {
  24171. return
  24172. }
  24173. return *v, true
  24174. }
  24175. // OldCreatorID returns the old "creator_id" field's value of the SopTask entity.
  24176. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  24177. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24178. func (m *SopTaskMutation) OldCreatorID(ctx context.Context) (v string, err error) {
  24179. if !m.op.Is(OpUpdateOne) {
  24180. return v, errors.New("OldCreatorID is only allowed on UpdateOne operations")
  24181. }
  24182. if m.id == nil || m.oldValue == nil {
  24183. return v, errors.New("OldCreatorID requires an ID field in the mutation")
  24184. }
  24185. oldValue, err := m.oldValue(ctx)
  24186. if err != nil {
  24187. return v, fmt.Errorf("querying old value for OldCreatorID: %w", err)
  24188. }
  24189. return oldValue.CreatorID, nil
  24190. }
  24191. // ClearCreatorID clears the value of the "creator_id" field.
  24192. func (m *SopTaskMutation) ClearCreatorID() {
  24193. m.creator_id = nil
  24194. m.clearedFields[soptask.FieldCreatorID] = struct{}{}
  24195. }
  24196. // CreatorIDCleared returns if the "creator_id" field was cleared in this mutation.
  24197. func (m *SopTaskMutation) CreatorIDCleared() bool {
  24198. _, ok := m.clearedFields[soptask.FieldCreatorID]
  24199. return ok
  24200. }
  24201. // ResetCreatorID resets all changes to the "creator_id" field.
  24202. func (m *SopTaskMutation) ResetCreatorID() {
  24203. m.creator_id = nil
  24204. delete(m.clearedFields, soptask.FieldCreatorID)
  24205. }
  24206. // SetOrganizationID sets the "organization_id" field.
  24207. func (m *SopTaskMutation) SetOrganizationID(u uint64) {
  24208. m.organization_id = &u
  24209. m.addorganization_id = nil
  24210. }
  24211. // OrganizationID returns the value of the "organization_id" field in the mutation.
  24212. func (m *SopTaskMutation) OrganizationID() (r uint64, exists bool) {
  24213. v := m.organization_id
  24214. if v == nil {
  24215. return
  24216. }
  24217. return *v, true
  24218. }
  24219. // OldOrganizationID returns the old "organization_id" field's value of the SopTask entity.
  24220. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  24221. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24222. func (m *SopTaskMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  24223. if !m.op.Is(OpUpdateOne) {
  24224. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  24225. }
  24226. if m.id == nil || m.oldValue == nil {
  24227. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  24228. }
  24229. oldValue, err := m.oldValue(ctx)
  24230. if err != nil {
  24231. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  24232. }
  24233. return oldValue.OrganizationID, nil
  24234. }
  24235. // AddOrganizationID adds u to the "organization_id" field.
  24236. func (m *SopTaskMutation) AddOrganizationID(u int64) {
  24237. if m.addorganization_id != nil {
  24238. *m.addorganization_id += u
  24239. } else {
  24240. m.addorganization_id = &u
  24241. }
  24242. }
  24243. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  24244. func (m *SopTaskMutation) AddedOrganizationID() (r int64, exists bool) {
  24245. v := m.addorganization_id
  24246. if v == nil {
  24247. return
  24248. }
  24249. return *v, true
  24250. }
  24251. // ClearOrganizationID clears the value of the "organization_id" field.
  24252. func (m *SopTaskMutation) ClearOrganizationID() {
  24253. m.organization_id = nil
  24254. m.addorganization_id = nil
  24255. m.clearedFields[soptask.FieldOrganizationID] = struct{}{}
  24256. }
  24257. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  24258. func (m *SopTaskMutation) OrganizationIDCleared() bool {
  24259. _, ok := m.clearedFields[soptask.FieldOrganizationID]
  24260. return ok
  24261. }
  24262. // ResetOrganizationID resets all changes to the "organization_id" field.
  24263. func (m *SopTaskMutation) ResetOrganizationID() {
  24264. m.organization_id = nil
  24265. m.addorganization_id = nil
  24266. delete(m.clearedFields, soptask.FieldOrganizationID)
  24267. }
  24268. // SetToken sets the "token" field.
  24269. func (m *SopTaskMutation) SetToken(s []string) {
  24270. m.token = &s
  24271. m.appendtoken = nil
  24272. }
  24273. // Token returns the value of the "token" field in the mutation.
  24274. func (m *SopTaskMutation) Token() (r []string, exists bool) {
  24275. v := m.token
  24276. if v == nil {
  24277. return
  24278. }
  24279. return *v, true
  24280. }
  24281. // OldToken returns the old "token" field's value of the SopTask entity.
  24282. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  24283. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24284. func (m *SopTaskMutation) OldToken(ctx context.Context) (v []string, err error) {
  24285. if !m.op.Is(OpUpdateOne) {
  24286. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  24287. }
  24288. if m.id == nil || m.oldValue == nil {
  24289. return v, errors.New("OldToken requires an ID field in the mutation")
  24290. }
  24291. oldValue, err := m.oldValue(ctx)
  24292. if err != nil {
  24293. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  24294. }
  24295. return oldValue.Token, nil
  24296. }
  24297. // AppendToken adds s to the "token" field.
  24298. func (m *SopTaskMutation) AppendToken(s []string) {
  24299. m.appendtoken = append(m.appendtoken, s...)
  24300. }
  24301. // AppendedToken returns the list of values that were appended to the "token" field in this mutation.
  24302. func (m *SopTaskMutation) AppendedToken() ([]string, bool) {
  24303. if len(m.appendtoken) == 0 {
  24304. return nil, false
  24305. }
  24306. return m.appendtoken, true
  24307. }
  24308. // ClearToken clears the value of the "token" field.
  24309. func (m *SopTaskMutation) ClearToken() {
  24310. m.token = nil
  24311. m.appendtoken = nil
  24312. m.clearedFields[soptask.FieldToken] = struct{}{}
  24313. }
  24314. // TokenCleared returns if the "token" field was cleared in this mutation.
  24315. func (m *SopTaskMutation) TokenCleared() bool {
  24316. _, ok := m.clearedFields[soptask.FieldToken]
  24317. return ok
  24318. }
  24319. // ResetToken resets all changes to the "token" field.
  24320. func (m *SopTaskMutation) ResetToken() {
  24321. m.token = nil
  24322. m.appendtoken = nil
  24323. delete(m.clearedFields, soptask.FieldToken)
  24324. }
  24325. // AddTaskStageIDs adds the "task_stages" edge to the SopStage entity by ids.
  24326. func (m *SopTaskMutation) AddTaskStageIDs(ids ...uint64) {
  24327. if m.task_stages == nil {
  24328. m.task_stages = make(map[uint64]struct{})
  24329. }
  24330. for i := range ids {
  24331. m.task_stages[ids[i]] = struct{}{}
  24332. }
  24333. }
  24334. // ClearTaskStages clears the "task_stages" edge to the SopStage entity.
  24335. func (m *SopTaskMutation) ClearTaskStages() {
  24336. m.clearedtask_stages = true
  24337. }
  24338. // TaskStagesCleared reports if the "task_stages" edge to the SopStage entity was cleared.
  24339. func (m *SopTaskMutation) TaskStagesCleared() bool {
  24340. return m.clearedtask_stages
  24341. }
  24342. // RemoveTaskStageIDs removes the "task_stages" edge to the SopStage entity by IDs.
  24343. func (m *SopTaskMutation) RemoveTaskStageIDs(ids ...uint64) {
  24344. if m.removedtask_stages == nil {
  24345. m.removedtask_stages = make(map[uint64]struct{})
  24346. }
  24347. for i := range ids {
  24348. delete(m.task_stages, ids[i])
  24349. m.removedtask_stages[ids[i]] = struct{}{}
  24350. }
  24351. }
  24352. // RemovedTaskStages returns the removed IDs of the "task_stages" edge to the SopStage entity.
  24353. func (m *SopTaskMutation) RemovedTaskStagesIDs() (ids []uint64) {
  24354. for id := range m.removedtask_stages {
  24355. ids = append(ids, id)
  24356. }
  24357. return
  24358. }
  24359. // TaskStagesIDs returns the "task_stages" edge IDs in the mutation.
  24360. func (m *SopTaskMutation) TaskStagesIDs() (ids []uint64) {
  24361. for id := range m.task_stages {
  24362. ids = append(ids, id)
  24363. }
  24364. return
  24365. }
  24366. // ResetTaskStages resets all changes to the "task_stages" edge.
  24367. func (m *SopTaskMutation) ResetTaskStages() {
  24368. m.task_stages = nil
  24369. m.clearedtask_stages = false
  24370. m.removedtask_stages = nil
  24371. }
  24372. // Where appends a list predicates to the SopTaskMutation builder.
  24373. func (m *SopTaskMutation) Where(ps ...predicate.SopTask) {
  24374. m.predicates = append(m.predicates, ps...)
  24375. }
  24376. // WhereP appends storage-level predicates to the SopTaskMutation builder. Using this method,
  24377. // users can use type-assertion to append predicates that do not depend on any generated package.
  24378. func (m *SopTaskMutation) WhereP(ps ...func(*sql.Selector)) {
  24379. p := make([]predicate.SopTask, len(ps))
  24380. for i := range ps {
  24381. p[i] = ps[i]
  24382. }
  24383. m.Where(p...)
  24384. }
  24385. // Op returns the operation name.
  24386. func (m *SopTaskMutation) Op() Op {
  24387. return m.op
  24388. }
  24389. // SetOp allows setting the mutation operation.
  24390. func (m *SopTaskMutation) SetOp(op Op) {
  24391. m.op = op
  24392. }
  24393. // Type returns the node type of this mutation (SopTask).
  24394. func (m *SopTaskMutation) Type() string {
  24395. return m.typ
  24396. }
  24397. // Fields returns all fields that were changed during this mutation. Note that in
  24398. // order to get all numeric fields that were incremented/decremented, call
  24399. // AddedFields().
  24400. func (m *SopTaskMutation) Fields() []string {
  24401. fields := make([]string, 0, 12)
  24402. if m.created_at != nil {
  24403. fields = append(fields, soptask.FieldCreatedAt)
  24404. }
  24405. if m.updated_at != nil {
  24406. fields = append(fields, soptask.FieldUpdatedAt)
  24407. }
  24408. if m.status != nil {
  24409. fields = append(fields, soptask.FieldStatus)
  24410. }
  24411. if m.deleted_at != nil {
  24412. fields = append(fields, soptask.FieldDeletedAt)
  24413. }
  24414. if m.name != nil {
  24415. fields = append(fields, soptask.FieldName)
  24416. }
  24417. if m.bot_wxid_list != nil {
  24418. fields = append(fields, soptask.FieldBotWxidList)
  24419. }
  24420. if m._type != nil {
  24421. fields = append(fields, soptask.FieldType)
  24422. }
  24423. if m.plan_start_time != nil {
  24424. fields = append(fields, soptask.FieldPlanStartTime)
  24425. }
  24426. if m.plan_end_time != nil {
  24427. fields = append(fields, soptask.FieldPlanEndTime)
  24428. }
  24429. if m.creator_id != nil {
  24430. fields = append(fields, soptask.FieldCreatorID)
  24431. }
  24432. if m.organization_id != nil {
  24433. fields = append(fields, soptask.FieldOrganizationID)
  24434. }
  24435. if m.token != nil {
  24436. fields = append(fields, soptask.FieldToken)
  24437. }
  24438. return fields
  24439. }
  24440. // Field returns the value of a field with the given name. The second boolean
  24441. // return value indicates that this field was not set, or was not defined in the
  24442. // schema.
  24443. func (m *SopTaskMutation) Field(name string) (ent.Value, bool) {
  24444. switch name {
  24445. case soptask.FieldCreatedAt:
  24446. return m.CreatedAt()
  24447. case soptask.FieldUpdatedAt:
  24448. return m.UpdatedAt()
  24449. case soptask.FieldStatus:
  24450. return m.Status()
  24451. case soptask.FieldDeletedAt:
  24452. return m.DeletedAt()
  24453. case soptask.FieldName:
  24454. return m.Name()
  24455. case soptask.FieldBotWxidList:
  24456. return m.BotWxidList()
  24457. case soptask.FieldType:
  24458. return m.GetType()
  24459. case soptask.FieldPlanStartTime:
  24460. return m.PlanStartTime()
  24461. case soptask.FieldPlanEndTime:
  24462. return m.PlanEndTime()
  24463. case soptask.FieldCreatorID:
  24464. return m.CreatorID()
  24465. case soptask.FieldOrganizationID:
  24466. return m.OrganizationID()
  24467. case soptask.FieldToken:
  24468. return m.Token()
  24469. }
  24470. return nil, false
  24471. }
  24472. // OldField returns the old value of the field from the database. An error is
  24473. // returned if the mutation operation is not UpdateOne, or the query to the
  24474. // database failed.
  24475. func (m *SopTaskMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  24476. switch name {
  24477. case soptask.FieldCreatedAt:
  24478. return m.OldCreatedAt(ctx)
  24479. case soptask.FieldUpdatedAt:
  24480. return m.OldUpdatedAt(ctx)
  24481. case soptask.FieldStatus:
  24482. return m.OldStatus(ctx)
  24483. case soptask.FieldDeletedAt:
  24484. return m.OldDeletedAt(ctx)
  24485. case soptask.FieldName:
  24486. return m.OldName(ctx)
  24487. case soptask.FieldBotWxidList:
  24488. return m.OldBotWxidList(ctx)
  24489. case soptask.FieldType:
  24490. return m.OldType(ctx)
  24491. case soptask.FieldPlanStartTime:
  24492. return m.OldPlanStartTime(ctx)
  24493. case soptask.FieldPlanEndTime:
  24494. return m.OldPlanEndTime(ctx)
  24495. case soptask.FieldCreatorID:
  24496. return m.OldCreatorID(ctx)
  24497. case soptask.FieldOrganizationID:
  24498. return m.OldOrganizationID(ctx)
  24499. case soptask.FieldToken:
  24500. return m.OldToken(ctx)
  24501. }
  24502. return nil, fmt.Errorf("unknown SopTask field %s", name)
  24503. }
  24504. // SetField sets the value of a field with the given name. It returns an error if
  24505. // the field is not defined in the schema, or if the type mismatched the field
  24506. // type.
  24507. func (m *SopTaskMutation) SetField(name string, value ent.Value) error {
  24508. switch name {
  24509. case soptask.FieldCreatedAt:
  24510. v, ok := value.(time.Time)
  24511. if !ok {
  24512. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24513. }
  24514. m.SetCreatedAt(v)
  24515. return nil
  24516. case soptask.FieldUpdatedAt:
  24517. v, ok := value.(time.Time)
  24518. if !ok {
  24519. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24520. }
  24521. m.SetUpdatedAt(v)
  24522. return nil
  24523. case soptask.FieldStatus:
  24524. v, ok := value.(uint8)
  24525. if !ok {
  24526. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24527. }
  24528. m.SetStatus(v)
  24529. return nil
  24530. case soptask.FieldDeletedAt:
  24531. v, ok := value.(time.Time)
  24532. if !ok {
  24533. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24534. }
  24535. m.SetDeletedAt(v)
  24536. return nil
  24537. case soptask.FieldName:
  24538. v, ok := value.(string)
  24539. if !ok {
  24540. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24541. }
  24542. m.SetName(v)
  24543. return nil
  24544. case soptask.FieldBotWxidList:
  24545. v, ok := value.([]string)
  24546. if !ok {
  24547. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24548. }
  24549. m.SetBotWxidList(v)
  24550. return nil
  24551. case soptask.FieldType:
  24552. v, ok := value.(int)
  24553. if !ok {
  24554. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24555. }
  24556. m.SetType(v)
  24557. return nil
  24558. case soptask.FieldPlanStartTime:
  24559. v, ok := value.(time.Time)
  24560. if !ok {
  24561. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24562. }
  24563. m.SetPlanStartTime(v)
  24564. return nil
  24565. case soptask.FieldPlanEndTime:
  24566. v, ok := value.(time.Time)
  24567. if !ok {
  24568. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24569. }
  24570. m.SetPlanEndTime(v)
  24571. return nil
  24572. case soptask.FieldCreatorID:
  24573. v, ok := value.(string)
  24574. if !ok {
  24575. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24576. }
  24577. m.SetCreatorID(v)
  24578. return nil
  24579. case soptask.FieldOrganizationID:
  24580. v, ok := value.(uint64)
  24581. if !ok {
  24582. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24583. }
  24584. m.SetOrganizationID(v)
  24585. return nil
  24586. case soptask.FieldToken:
  24587. v, ok := value.([]string)
  24588. if !ok {
  24589. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24590. }
  24591. m.SetToken(v)
  24592. return nil
  24593. }
  24594. return fmt.Errorf("unknown SopTask field %s", name)
  24595. }
  24596. // AddedFields returns all numeric fields that were incremented/decremented during
  24597. // this mutation.
  24598. func (m *SopTaskMutation) AddedFields() []string {
  24599. var fields []string
  24600. if m.addstatus != nil {
  24601. fields = append(fields, soptask.FieldStatus)
  24602. }
  24603. if m.add_type != nil {
  24604. fields = append(fields, soptask.FieldType)
  24605. }
  24606. if m.addorganization_id != nil {
  24607. fields = append(fields, soptask.FieldOrganizationID)
  24608. }
  24609. return fields
  24610. }
  24611. // AddedField returns the numeric value that was incremented/decremented on a field
  24612. // with the given name. The second boolean return value indicates that this field
  24613. // was not set, or was not defined in the schema.
  24614. func (m *SopTaskMutation) AddedField(name string) (ent.Value, bool) {
  24615. switch name {
  24616. case soptask.FieldStatus:
  24617. return m.AddedStatus()
  24618. case soptask.FieldType:
  24619. return m.AddedType()
  24620. case soptask.FieldOrganizationID:
  24621. return m.AddedOrganizationID()
  24622. }
  24623. return nil, false
  24624. }
  24625. // AddField adds the value to the field with the given name. It returns an error if
  24626. // the field is not defined in the schema, or if the type mismatched the field
  24627. // type.
  24628. func (m *SopTaskMutation) AddField(name string, value ent.Value) error {
  24629. switch name {
  24630. case soptask.FieldStatus:
  24631. v, ok := value.(int8)
  24632. if !ok {
  24633. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24634. }
  24635. m.AddStatus(v)
  24636. return nil
  24637. case soptask.FieldType:
  24638. v, ok := value.(int)
  24639. if !ok {
  24640. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24641. }
  24642. m.AddType(v)
  24643. return nil
  24644. case soptask.FieldOrganizationID:
  24645. v, ok := value.(int64)
  24646. if !ok {
  24647. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24648. }
  24649. m.AddOrganizationID(v)
  24650. return nil
  24651. }
  24652. return fmt.Errorf("unknown SopTask numeric field %s", name)
  24653. }
  24654. // ClearedFields returns all nullable fields that were cleared during this
  24655. // mutation.
  24656. func (m *SopTaskMutation) ClearedFields() []string {
  24657. var fields []string
  24658. if m.FieldCleared(soptask.FieldStatus) {
  24659. fields = append(fields, soptask.FieldStatus)
  24660. }
  24661. if m.FieldCleared(soptask.FieldDeletedAt) {
  24662. fields = append(fields, soptask.FieldDeletedAt)
  24663. }
  24664. if m.FieldCleared(soptask.FieldBotWxidList) {
  24665. fields = append(fields, soptask.FieldBotWxidList)
  24666. }
  24667. if m.FieldCleared(soptask.FieldPlanStartTime) {
  24668. fields = append(fields, soptask.FieldPlanStartTime)
  24669. }
  24670. if m.FieldCleared(soptask.FieldPlanEndTime) {
  24671. fields = append(fields, soptask.FieldPlanEndTime)
  24672. }
  24673. if m.FieldCleared(soptask.FieldCreatorID) {
  24674. fields = append(fields, soptask.FieldCreatorID)
  24675. }
  24676. if m.FieldCleared(soptask.FieldOrganizationID) {
  24677. fields = append(fields, soptask.FieldOrganizationID)
  24678. }
  24679. if m.FieldCleared(soptask.FieldToken) {
  24680. fields = append(fields, soptask.FieldToken)
  24681. }
  24682. return fields
  24683. }
  24684. // FieldCleared returns a boolean indicating if a field with the given name was
  24685. // cleared in this mutation.
  24686. func (m *SopTaskMutation) FieldCleared(name string) bool {
  24687. _, ok := m.clearedFields[name]
  24688. return ok
  24689. }
  24690. // ClearField clears the value of the field with the given name. It returns an
  24691. // error if the field is not defined in the schema.
  24692. func (m *SopTaskMutation) ClearField(name string) error {
  24693. switch name {
  24694. case soptask.FieldStatus:
  24695. m.ClearStatus()
  24696. return nil
  24697. case soptask.FieldDeletedAt:
  24698. m.ClearDeletedAt()
  24699. return nil
  24700. case soptask.FieldBotWxidList:
  24701. m.ClearBotWxidList()
  24702. return nil
  24703. case soptask.FieldPlanStartTime:
  24704. m.ClearPlanStartTime()
  24705. return nil
  24706. case soptask.FieldPlanEndTime:
  24707. m.ClearPlanEndTime()
  24708. return nil
  24709. case soptask.FieldCreatorID:
  24710. m.ClearCreatorID()
  24711. return nil
  24712. case soptask.FieldOrganizationID:
  24713. m.ClearOrganizationID()
  24714. return nil
  24715. case soptask.FieldToken:
  24716. m.ClearToken()
  24717. return nil
  24718. }
  24719. return fmt.Errorf("unknown SopTask nullable field %s", name)
  24720. }
  24721. // ResetField resets all changes in the mutation for the field with the given name.
  24722. // It returns an error if the field is not defined in the schema.
  24723. func (m *SopTaskMutation) ResetField(name string) error {
  24724. switch name {
  24725. case soptask.FieldCreatedAt:
  24726. m.ResetCreatedAt()
  24727. return nil
  24728. case soptask.FieldUpdatedAt:
  24729. m.ResetUpdatedAt()
  24730. return nil
  24731. case soptask.FieldStatus:
  24732. m.ResetStatus()
  24733. return nil
  24734. case soptask.FieldDeletedAt:
  24735. m.ResetDeletedAt()
  24736. return nil
  24737. case soptask.FieldName:
  24738. m.ResetName()
  24739. return nil
  24740. case soptask.FieldBotWxidList:
  24741. m.ResetBotWxidList()
  24742. return nil
  24743. case soptask.FieldType:
  24744. m.ResetType()
  24745. return nil
  24746. case soptask.FieldPlanStartTime:
  24747. m.ResetPlanStartTime()
  24748. return nil
  24749. case soptask.FieldPlanEndTime:
  24750. m.ResetPlanEndTime()
  24751. return nil
  24752. case soptask.FieldCreatorID:
  24753. m.ResetCreatorID()
  24754. return nil
  24755. case soptask.FieldOrganizationID:
  24756. m.ResetOrganizationID()
  24757. return nil
  24758. case soptask.FieldToken:
  24759. m.ResetToken()
  24760. return nil
  24761. }
  24762. return fmt.Errorf("unknown SopTask field %s", name)
  24763. }
  24764. // AddedEdges returns all edge names that were set/added in this mutation.
  24765. func (m *SopTaskMutation) AddedEdges() []string {
  24766. edges := make([]string, 0, 1)
  24767. if m.task_stages != nil {
  24768. edges = append(edges, soptask.EdgeTaskStages)
  24769. }
  24770. return edges
  24771. }
  24772. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  24773. // name in this mutation.
  24774. func (m *SopTaskMutation) AddedIDs(name string) []ent.Value {
  24775. switch name {
  24776. case soptask.EdgeTaskStages:
  24777. ids := make([]ent.Value, 0, len(m.task_stages))
  24778. for id := range m.task_stages {
  24779. ids = append(ids, id)
  24780. }
  24781. return ids
  24782. }
  24783. return nil
  24784. }
  24785. // RemovedEdges returns all edge names that were removed in this mutation.
  24786. func (m *SopTaskMutation) RemovedEdges() []string {
  24787. edges := make([]string, 0, 1)
  24788. if m.removedtask_stages != nil {
  24789. edges = append(edges, soptask.EdgeTaskStages)
  24790. }
  24791. return edges
  24792. }
  24793. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  24794. // the given name in this mutation.
  24795. func (m *SopTaskMutation) RemovedIDs(name string) []ent.Value {
  24796. switch name {
  24797. case soptask.EdgeTaskStages:
  24798. ids := make([]ent.Value, 0, len(m.removedtask_stages))
  24799. for id := range m.removedtask_stages {
  24800. ids = append(ids, id)
  24801. }
  24802. return ids
  24803. }
  24804. return nil
  24805. }
  24806. // ClearedEdges returns all edge names that were cleared in this mutation.
  24807. func (m *SopTaskMutation) ClearedEdges() []string {
  24808. edges := make([]string, 0, 1)
  24809. if m.clearedtask_stages {
  24810. edges = append(edges, soptask.EdgeTaskStages)
  24811. }
  24812. return edges
  24813. }
  24814. // EdgeCleared returns a boolean which indicates if the edge with the given name
  24815. // was cleared in this mutation.
  24816. func (m *SopTaskMutation) EdgeCleared(name string) bool {
  24817. switch name {
  24818. case soptask.EdgeTaskStages:
  24819. return m.clearedtask_stages
  24820. }
  24821. return false
  24822. }
  24823. // ClearEdge clears the value of the edge with the given name. It returns an error
  24824. // if that edge is not defined in the schema.
  24825. func (m *SopTaskMutation) ClearEdge(name string) error {
  24826. switch name {
  24827. }
  24828. return fmt.Errorf("unknown SopTask unique edge %s", name)
  24829. }
  24830. // ResetEdge resets all changes to the edge with the given name in this mutation.
  24831. // It returns an error if the edge is not defined in the schema.
  24832. func (m *SopTaskMutation) ResetEdge(name string) error {
  24833. switch name {
  24834. case soptask.EdgeTaskStages:
  24835. m.ResetTaskStages()
  24836. return nil
  24837. }
  24838. return fmt.Errorf("unknown SopTask edge %s", name)
  24839. }
  24840. // TokenMutation represents an operation that mutates the Token nodes in the graph.
  24841. type TokenMutation struct {
  24842. config
  24843. op Op
  24844. typ string
  24845. id *uint64
  24846. created_at *time.Time
  24847. updated_at *time.Time
  24848. deleted_at *time.Time
  24849. expire_at *time.Time
  24850. token *string
  24851. mac *string
  24852. organization_id *uint64
  24853. addorganization_id *int64
  24854. custom_agent_base *string
  24855. custom_agent_key *string
  24856. openai_base *string
  24857. openai_key *string
  24858. clearedFields map[string]struct{}
  24859. agent *uint64
  24860. clearedagent bool
  24861. done bool
  24862. oldValue func(context.Context) (*Token, error)
  24863. predicates []predicate.Token
  24864. }
  24865. var _ ent.Mutation = (*TokenMutation)(nil)
  24866. // tokenOption allows management of the mutation configuration using functional options.
  24867. type tokenOption func(*TokenMutation)
  24868. // newTokenMutation creates new mutation for the Token entity.
  24869. func newTokenMutation(c config, op Op, opts ...tokenOption) *TokenMutation {
  24870. m := &TokenMutation{
  24871. config: c,
  24872. op: op,
  24873. typ: TypeToken,
  24874. clearedFields: make(map[string]struct{}),
  24875. }
  24876. for _, opt := range opts {
  24877. opt(m)
  24878. }
  24879. return m
  24880. }
  24881. // withTokenID sets the ID field of the mutation.
  24882. func withTokenID(id uint64) tokenOption {
  24883. return func(m *TokenMutation) {
  24884. var (
  24885. err error
  24886. once sync.Once
  24887. value *Token
  24888. )
  24889. m.oldValue = func(ctx context.Context) (*Token, error) {
  24890. once.Do(func() {
  24891. if m.done {
  24892. err = errors.New("querying old values post mutation is not allowed")
  24893. } else {
  24894. value, err = m.Client().Token.Get(ctx, id)
  24895. }
  24896. })
  24897. return value, err
  24898. }
  24899. m.id = &id
  24900. }
  24901. }
  24902. // withToken sets the old Token of the mutation.
  24903. func withToken(node *Token) tokenOption {
  24904. return func(m *TokenMutation) {
  24905. m.oldValue = func(context.Context) (*Token, error) {
  24906. return node, nil
  24907. }
  24908. m.id = &node.ID
  24909. }
  24910. }
  24911. // Client returns a new `ent.Client` from the mutation. If the mutation was
  24912. // executed in a transaction (ent.Tx), a transactional client is returned.
  24913. func (m TokenMutation) Client() *Client {
  24914. client := &Client{config: m.config}
  24915. client.init()
  24916. return client
  24917. }
  24918. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  24919. // it returns an error otherwise.
  24920. func (m TokenMutation) Tx() (*Tx, error) {
  24921. if _, ok := m.driver.(*txDriver); !ok {
  24922. return nil, errors.New("ent: mutation is not running in a transaction")
  24923. }
  24924. tx := &Tx{config: m.config}
  24925. tx.init()
  24926. return tx, nil
  24927. }
  24928. // SetID sets the value of the id field. Note that this
  24929. // operation is only accepted on creation of Token entities.
  24930. func (m *TokenMutation) SetID(id uint64) {
  24931. m.id = &id
  24932. }
  24933. // ID returns the ID value in the mutation. Note that the ID is only available
  24934. // if it was provided to the builder or after it was returned from the database.
  24935. func (m *TokenMutation) ID() (id uint64, exists bool) {
  24936. if m.id == nil {
  24937. return
  24938. }
  24939. return *m.id, true
  24940. }
  24941. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  24942. // That means, if the mutation is applied within a transaction with an isolation level such
  24943. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  24944. // or updated by the mutation.
  24945. func (m *TokenMutation) IDs(ctx context.Context) ([]uint64, error) {
  24946. switch {
  24947. case m.op.Is(OpUpdateOne | OpDeleteOne):
  24948. id, exists := m.ID()
  24949. if exists {
  24950. return []uint64{id}, nil
  24951. }
  24952. fallthrough
  24953. case m.op.Is(OpUpdate | OpDelete):
  24954. return m.Client().Token.Query().Where(m.predicates...).IDs(ctx)
  24955. default:
  24956. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  24957. }
  24958. }
  24959. // SetCreatedAt sets the "created_at" field.
  24960. func (m *TokenMutation) SetCreatedAt(t time.Time) {
  24961. m.created_at = &t
  24962. }
  24963. // CreatedAt returns the value of the "created_at" field in the mutation.
  24964. func (m *TokenMutation) CreatedAt() (r time.Time, exists bool) {
  24965. v := m.created_at
  24966. if v == nil {
  24967. return
  24968. }
  24969. return *v, true
  24970. }
  24971. // OldCreatedAt returns the old "created_at" field's value of the Token entity.
  24972. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  24973. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24974. func (m *TokenMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  24975. if !m.op.Is(OpUpdateOne) {
  24976. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  24977. }
  24978. if m.id == nil || m.oldValue == nil {
  24979. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  24980. }
  24981. oldValue, err := m.oldValue(ctx)
  24982. if err != nil {
  24983. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  24984. }
  24985. return oldValue.CreatedAt, nil
  24986. }
  24987. // ResetCreatedAt resets all changes to the "created_at" field.
  24988. func (m *TokenMutation) ResetCreatedAt() {
  24989. m.created_at = nil
  24990. }
  24991. // SetUpdatedAt sets the "updated_at" field.
  24992. func (m *TokenMutation) SetUpdatedAt(t time.Time) {
  24993. m.updated_at = &t
  24994. }
  24995. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  24996. func (m *TokenMutation) UpdatedAt() (r time.Time, exists bool) {
  24997. v := m.updated_at
  24998. if v == nil {
  24999. return
  25000. }
  25001. return *v, true
  25002. }
  25003. // OldUpdatedAt returns the old "updated_at" field's value of the Token entity.
  25004. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  25005. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25006. func (m *TokenMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  25007. if !m.op.Is(OpUpdateOne) {
  25008. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  25009. }
  25010. if m.id == nil || m.oldValue == nil {
  25011. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  25012. }
  25013. oldValue, err := m.oldValue(ctx)
  25014. if err != nil {
  25015. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  25016. }
  25017. return oldValue.UpdatedAt, nil
  25018. }
  25019. // ResetUpdatedAt resets all changes to the "updated_at" field.
  25020. func (m *TokenMutation) ResetUpdatedAt() {
  25021. m.updated_at = nil
  25022. }
  25023. // SetDeletedAt sets the "deleted_at" field.
  25024. func (m *TokenMutation) SetDeletedAt(t time.Time) {
  25025. m.deleted_at = &t
  25026. }
  25027. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  25028. func (m *TokenMutation) DeletedAt() (r time.Time, exists bool) {
  25029. v := m.deleted_at
  25030. if v == nil {
  25031. return
  25032. }
  25033. return *v, true
  25034. }
  25035. // OldDeletedAt returns the old "deleted_at" field's value of the Token entity.
  25036. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  25037. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25038. func (m *TokenMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  25039. if !m.op.Is(OpUpdateOne) {
  25040. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  25041. }
  25042. if m.id == nil || m.oldValue == nil {
  25043. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  25044. }
  25045. oldValue, err := m.oldValue(ctx)
  25046. if err != nil {
  25047. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  25048. }
  25049. return oldValue.DeletedAt, nil
  25050. }
  25051. // ClearDeletedAt clears the value of the "deleted_at" field.
  25052. func (m *TokenMutation) ClearDeletedAt() {
  25053. m.deleted_at = nil
  25054. m.clearedFields[token.FieldDeletedAt] = struct{}{}
  25055. }
  25056. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  25057. func (m *TokenMutation) DeletedAtCleared() bool {
  25058. _, ok := m.clearedFields[token.FieldDeletedAt]
  25059. return ok
  25060. }
  25061. // ResetDeletedAt resets all changes to the "deleted_at" field.
  25062. func (m *TokenMutation) ResetDeletedAt() {
  25063. m.deleted_at = nil
  25064. delete(m.clearedFields, token.FieldDeletedAt)
  25065. }
  25066. // SetExpireAt sets the "expire_at" field.
  25067. func (m *TokenMutation) SetExpireAt(t time.Time) {
  25068. m.expire_at = &t
  25069. }
  25070. // ExpireAt returns the value of the "expire_at" field in the mutation.
  25071. func (m *TokenMutation) ExpireAt() (r time.Time, exists bool) {
  25072. v := m.expire_at
  25073. if v == nil {
  25074. return
  25075. }
  25076. return *v, true
  25077. }
  25078. // OldExpireAt returns the old "expire_at" field's value of the Token entity.
  25079. // If the Token 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 *TokenMutation) OldExpireAt(ctx context.Context) (v time.Time, err error) {
  25082. if !m.op.Is(OpUpdateOne) {
  25083. return v, errors.New("OldExpireAt is only allowed on UpdateOne operations")
  25084. }
  25085. if m.id == nil || m.oldValue == nil {
  25086. return v, errors.New("OldExpireAt 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 OldExpireAt: %w", err)
  25091. }
  25092. return oldValue.ExpireAt, nil
  25093. }
  25094. // ClearExpireAt clears the value of the "expire_at" field.
  25095. func (m *TokenMutation) ClearExpireAt() {
  25096. m.expire_at = nil
  25097. m.clearedFields[token.FieldExpireAt] = struct{}{}
  25098. }
  25099. // ExpireAtCleared returns if the "expire_at" field was cleared in this mutation.
  25100. func (m *TokenMutation) ExpireAtCleared() bool {
  25101. _, ok := m.clearedFields[token.FieldExpireAt]
  25102. return ok
  25103. }
  25104. // ResetExpireAt resets all changes to the "expire_at" field.
  25105. func (m *TokenMutation) ResetExpireAt() {
  25106. m.expire_at = nil
  25107. delete(m.clearedFields, token.FieldExpireAt)
  25108. }
  25109. // SetToken sets the "token" field.
  25110. func (m *TokenMutation) SetToken(s string) {
  25111. m.token = &s
  25112. }
  25113. // Token returns the value of the "token" field in the mutation.
  25114. func (m *TokenMutation) Token() (r string, exists bool) {
  25115. v := m.token
  25116. if v == nil {
  25117. return
  25118. }
  25119. return *v, true
  25120. }
  25121. // OldToken returns the old "token" field's value of the Token entity.
  25122. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  25123. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25124. func (m *TokenMutation) OldToken(ctx context.Context) (v string, err error) {
  25125. if !m.op.Is(OpUpdateOne) {
  25126. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  25127. }
  25128. if m.id == nil || m.oldValue == nil {
  25129. return v, errors.New("OldToken requires an ID field in the mutation")
  25130. }
  25131. oldValue, err := m.oldValue(ctx)
  25132. if err != nil {
  25133. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  25134. }
  25135. return oldValue.Token, nil
  25136. }
  25137. // ClearToken clears the value of the "token" field.
  25138. func (m *TokenMutation) ClearToken() {
  25139. m.token = nil
  25140. m.clearedFields[token.FieldToken] = struct{}{}
  25141. }
  25142. // TokenCleared returns if the "token" field was cleared in this mutation.
  25143. func (m *TokenMutation) TokenCleared() bool {
  25144. _, ok := m.clearedFields[token.FieldToken]
  25145. return ok
  25146. }
  25147. // ResetToken resets all changes to the "token" field.
  25148. func (m *TokenMutation) ResetToken() {
  25149. m.token = nil
  25150. delete(m.clearedFields, token.FieldToken)
  25151. }
  25152. // SetMAC sets the "mac" field.
  25153. func (m *TokenMutation) SetMAC(s string) {
  25154. m.mac = &s
  25155. }
  25156. // MAC returns the value of the "mac" field in the mutation.
  25157. func (m *TokenMutation) MAC() (r string, exists bool) {
  25158. v := m.mac
  25159. if v == nil {
  25160. return
  25161. }
  25162. return *v, true
  25163. }
  25164. // OldMAC returns the old "mac" field's value of the Token entity.
  25165. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  25166. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25167. func (m *TokenMutation) OldMAC(ctx context.Context) (v string, err error) {
  25168. if !m.op.Is(OpUpdateOne) {
  25169. return v, errors.New("OldMAC is only allowed on UpdateOne operations")
  25170. }
  25171. if m.id == nil || m.oldValue == nil {
  25172. return v, errors.New("OldMAC requires an ID field in the mutation")
  25173. }
  25174. oldValue, err := m.oldValue(ctx)
  25175. if err != nil {
  25176. return v, fmt.Errorf("querying old value for OldMAC: %w", err)
  25177. }
  25178. return oldValue.MAC, nil
  25179. }
  25180. // ClearMAC clears the value of the "mac" field.
  25181. func (m *TokenMutation) ClearMAC() {
  25182. m.mac = nil
  25183. m.clearedFields[token.FieldMAC] = struct{}{}
  25184. }
  25185. // MACCleared returns if the "mac" field was cleared in this mutation.
  25186. func (m *TokenMutation) MACCleared() bool {
  25187. _, ok := m.clearedFields[token.FieldMAC]
  25188. return ok
  25189. }
  25190. // ResetMAC resets all changes to the "mac" field.
  25191. func (m *TokenMutation) ResetMAC() {
  25192. m.mac = nil
  25193. delete(m.clearedFields, token.FieldMAC)
  25194. }
  25195. // SetOrganizationID sets the "organization_id" field.
  25196. func (m *TokenMutation) SetOrganizationID(u uint64) {
  25197. m.organization_id = &u
  25198. m.addorganization_id = nil
  25199. }
  25200. // OrganizationID returns the value of the "organization_id" field in the mutation.
  25201. func (m *TokenMutation) OrganizationID() (r uint64, exists bool) {
  25202. v := m.organization_id
  25203. if v == nil {
  25204. return
  25205. }
  25206. return *v, true
  25207. }
  25208. // OldOrganizationID returns the old "organization_id" field's value of the Token entity.
  25209. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  25210. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25211. func (m *TokenMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  25212. if !m.op.Is(OpUpdateOne) {
  25213. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  25214. }
  25215. if m.id == nil || m.oldValue == nil {
  25216. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  25217. }
  25218. oldValue, err := m.oldValue(ctx)
  25219. if err != nil {
  25220. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  25221. }
  25222. return oldValue.OrganizationID, nil
  25223. }
  25224. // AddOrganizationID adds u to the "organization_id" field.
  25225. func (m *TokenMutation) AddOrganizationID(u int64) {
  25226. if m.addorganization_id != nil {
  25227. *m.addorganization_id += u
  25228. } else {
  25229. m.addorganization_id = &u
  25230. }
  25231. }
  25232. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  25233. func (m *TokenMutation) AddedOrganizationID() (r int64, exists bool) {
  25234. v := m.addorganization_id
  25235. if v == nil {
  25236. return
  25237. }
  25238. return *v, true
  25239. }
  25240. // ResetOrganizationID resets all changes to the "organization_id" field.
  25241. func (m *TokenMutation) ResetOrganizationID() {
  25242. m.organization_id = nil
  25243. m.addorganization_id = nil
  25244. }
  25245. // SetAgentID sets the "agent_id" field.
  25246. func (m *TokenMutation) SetAgentID(u uint64) {
  25247. m.agent = &u
  25248. }
  25249. // AgentID returns the value of the "agent_id" field in the mutation.
  25250. func (m *TokenMutation) AgentID() (r uint64, exists bool) {
  25251. v := m.agent
  25252. if v == nil {
  25253. return
  25254. }
  25255. return *v, true
  25256. }
  25257. // OldAgentID returns the old "agent_id" field's value of the Token entity.
  25258. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  25259. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25260. func (m *TokenMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  25261. if !m.op.Is(OpUpdateOne) {
  25262. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  25263. }
  25264. if m.id == nil || m.oldValue == nil {
  25265. return v, errors.New("OldAgentID requires an ID field in the mutation")
  25266. }
  25267. oldValue, err := m.oldValue(ctx)
  25268. if err != nil {
  25269. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  25270. }
  25271. return oldValue.AgentID, nil
  25272. }
  25273. // ResetAgentID resets all changes to the "agent_id" field.
  25274. func (m *TokenMutation) ResetAgentID() {
  25275. m.agent = nil
  25276. }
  25277. // SetCustomAgentBase sets the "custom_agent_base" field.
  25278. func (m *TokenMutation) SetCustomAgentBase(s string) {
  25279. m.custom_agent_base = &s
  25280. }
  25281. // CustomAgentBase returns the value of the "custom_agent_base" field in the mutation.
  25282. func (m *TokenMutation) CustomAgentBase() (r string, exists bool) {
  25283. v := m.custom_agent_base
  25284. if v == nil {
  25285. return
  25286. }
  25287. return *v, true
  25288. }
  25289. // OldCustomAgentBase returns the old "custom_agent_base" field's value of the Token entity.
  25290. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  25291. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25292. func (m *TokenMutation) OldCustomAgentBase(ctx context.Context) (v string, err error) {
  25293. if !m.op.Is(OpUpdateOne) {
  25294. return v, errors.New("OldCustomAgentBase is only allowed on UpdateOne operations")
  25295. }
  25296. if m.id == nil || m.oldValue == nil {
  25297. return v, errors.New("OldCustomAgentBase requires an ID field in the mutation")
  25298. }
  25299. oldValue, err := m.oldValue(ctx)
  25300. if err != nil {
  25301. return v, fmt.Errorf("querying old value for OldCustomAgentBase: %w", err)
  25302. }
  25303. return oldValue.CustomAgentBase, nil
  25304. }
  25305. // ClearCustomAgentBase clears the value of the "custom_agent_base" field.
  25306. func (m *TokenMutation) ClearCustomAgentBase() {
  25307. m.custom_agent_base = nil
  25308. m.clearedFields[token.FieldCustomAgentBase] = struct{}{}
  25309. }
  25310. // CustomAgentBaseCleared returns if the "custom_agent_base" field was cleared in this mutation.
  25311. func (m *TokenMutation) CustomAgentBaseCleared() bool {
  25312. _, ok := m.clearedFields[token.FieldCustomAgentBase]
  25313. return ok
  25314. }
  25315. // ResetCustomAgentBase resets all changes to the "custom_agent_base" field.
  25316. func (m *TokenMutation) ResetCustomAgentBase() {
  25317. m.custom_agent_base = nil
  25318. delete(m.clearedFields, token.FieldCustomAgentBase)
  25319. }
  25320. // SetCustomAgentKey sets the "custom_agent_key" field.
  25321. func (m *TokenMutation) SetCustomAgentKey(s string) {
  25322. m.custom_agent_key = &s
  25323. }
  25324. // CustomAgentKey returns the value of the "custom_agent_key" field in the mutation.
  25325. func (m *TokenMutation) CustomAgentKey() (r string, exists bool) {
  25326. v := m.custom_agent_key
  25327. if v == nil {
  25328. return
  25329. }
  25330. return *v, true
  25331. }
  25332. // OldCustomAgentKey returns the old "custom_agent_key" field's value of the Token entity.
  25333. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  25334. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25335. func (m *TokenMutation) OldCustomAgentKey(ctx context.Context) (v string, err error) {
  25336. if !m.op.Is(OpUpdateOne) {
  25337. return v, errors.New("OldCustomAgentKey is only allowed on UpdateOne operations")
  25338. }
  25339. if m.id == nil || m.oldValue == nil {
  25340. return v, errors.New("OldCustomAgentKey requires an ID field in the mutation")
  25341. }
  25342. oldValue, err := m.oldValue(ctx)
  25343. if err != nil {
  25344. return v, fmt.Errorf("querying old value for OldCustomAgentKey: %w", err)
  25345. }
  25346. return oldValue.CustomAgentKey, nil
  25347. }
  25348. // ClearCustomAgentKey clears the value of the "custom_agent_key" field.
  25349. func (m *TokenMutation) ClearCustomAgentKey() {
  25350. m.custom_agent_key = nil
  25351. m.clearedFields[token.FieldCustomAgentKey] = struct{}{}
  25352. }
  25353. // CustomAgentKeyCleared returns if the "custom_agent_key" field was cleared in this mutation.
  25354. func (m *TokenMutation) CustomAgentKeyCleared() bool {
  25355. _, ok := m.clearedFields[token.FieldCustomAgentKey]
  25356. return ok
  25357. }
  25358. // ResetCustomAgentKey resets all changes to the "custom_agent_key" field.
  25359. func (m *TokenMutation) ResetCustomAgentKey() {
  25360. m.custom_agent_key = nil
  25361. delete(m.clearedFields, token.FieldCustomAgentKey)
  25362. }
  25363. // SetOpenaiBase sets the "openai_base" field.
  25364. func (m *TokenMutation) SetOpenaiBase(s string) {
  25365. m.openai_base = &s
  25366. }
  25367. // OpenaiBase returns the value of the "openai_base" field in the mutation.
  25368. func (m *TokenMutation) OpenaiBase() (r string, exists bool) {
  25369. v := m.openai_base
  25370. if v == nil {
  25371. return
  25372. }
  25373. return *v, true
  25374. }
  25375. // OldOpenaiBase returns the old "openai_base" field's value of the Token entity.
  25376. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  25377. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25378. func (m *TokenMutation) OldOpenaiBase(ctx context.Context) (v string, err error) {
  25379. if !m.op.Is(OpUpdateOne) {
  25380. return v, errors.New("OldOpenaiBase is only allowed on UpdateOne operations")
  25381. }
  25382. if m.id == nil || m.oldValue == nil {
  25383. return v, errors.New("OldOpenaiBase requires an ID field in the mutation")
  25384. }
  25385. oldValue, err := m.oldValue(ctx)
  25386. if err != nil {
  25387. return v, fmt.Errorf("querying old value for OldOpenaiBase: %w", err)
  25388. }
  25389. return oldValue.OpenaiBase, nil
  25390. }
  25391. // ClearOpenaiBase clears the value of the "openai_base" field.
  25392. func (m *TokenMutation) ClearOpenaiBase() {
  25393. m.openai_base = nil
  25394. m.clearedFields[token.FieldOpenaiBase] = struct{}{}
  25395. }
  25396. // OpenaiBaseCleared returns if the "openai_base" field was cleared in this mutation.
  25397. func (m *TokenMutation) OpenaiBaseCleared() bool {
  25398. _, ok := m.clearedFields[token.FieldOpenaiBase]
  25399. return ok
  25400. }
  25401. // ResetOpenaiBase resets all changes to the "openai_base" field.
  25402. func (m *TokenMutation) ResetOpenaiBase() {
  25403. m.openai_base = nil
  25404. delete(m.clearedFields, token.FieldOpenaiBase)
  25405. }
  25406. // SetOpenaiKey sets the "openai_key" field.
  25407. func (m *TokenMutation) SetOpenaiKey(s string) {
  25408. m.openai_key = &s
  25409. }
  25410. // OpenaiKey returns the value of the "openai_key" field in the mutation.
  25411. func (m *TokenMutation) OpenaiKey() (r string, exists bool) {
  25412. v := m.openai_key
  25413. if v == nil {
  25414. return
  25415. }
  25416. return *v, true
  25417. }
  25418. // OldOpenaiKey returns the old "openai_key" field's value of the Token entity.
  25419. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  25420. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25421. func (m *TokenMutation) OldOpenaiKey(ctx context.Context) (v string, err error) {
  25422. if !m.op.Is(OpUpdateOne) {
  25423. return v, errors.New("OldOpenaiKey is only allowed on UpdateOne operations")
  25424. }
  25425. if m.id == nil || m.oldValue == nil {
  25426. return v, errors.New("OldOpenaiKey requires an ID field in the mutation")
  25427. }
  25428. oldValue, err := m.oldValue(ctx)
  25429. if err != nil {
  25430. return v, fmt.Errorf("querying old value for OldOpenaiKey: %w", err)
  25431. }
  25432. return oldValue.OpenaiKey, nil
  25433. }
  25434. // ClearOpenaiKey clears the value of the "openai_key" field.
  25435. func (m *TokenMutation) ClearOpenaiKey() {
  25436. m.openai_key = nil
  25437. m.clearedFields[token.FieldOpenaiKey] = struct{}{}
  25438. }
  25439. // OpenaiKeyCleared returns if the "openai_key" field was cleared in this mutation.
  25440. func (m *TokenMutation) OpenaiKeyCleared() bool {
  25441. _, ok := m.clearedFields[token.FieldOpenaiKey]
  25442. return ok
  25443. }
  25444. // ResetOpenaiKey resets all changes to the "openai_key" field.
  25445. func (m *TokenMutation) ResetOpenaiKey() {
  25446. m.openai_key = nil
  25447. delete(m.clearedFields, token.FieldOpenaiKey)
  25448. }
  25449. // ClearAgent clears the "agent" edge to the Agent entity.
  25450. func (m *TokenMutation) ClearAgent() {
  25451. m.clearedagent = true
  25452. m.clearedFields[token.FieldAgentID] = struct{}{}
  25453. }
  25454. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  25455. func (m *TokenMutation) AgentCleared() bool {
  25456. return m.clearedagent
  25457. }
  25458. // AgentIDs returns the "agent" edge IDs in the mutation.
  25459. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  25460. // AgentID instead. It exists only for internal usage by the builders.
  25461. func (m *TokenMutation) AgentIDs() (ids []uint64) {
  25462. if id := m.agent; id != nil {
  25463. ids = append(ids, *id)
  25464. }
  25465. return
  25466. }
  25467. // ResetAgent resets all changes to the "agent" edge.
  25468. func (m *TokenMutation) ResetAgent() {
  25469. m.agent = nil
  25470. m.clearedagent = false
  25471. }
  25472. // Where appends a list predicates to the TokenMutation builder.
  25473. func (m *TokenMutation) Where(ps ...predicate.Token) {
  25474. m.predicates = append(m.predicates, ps...)
  25475. }
  25476. // WhereP appends storage-level predicates to the TokenMutation builder. Using this method,
  25477. // users can use type-assertion to append predicates that do not depend on any generated package.
  25478. func (m *TokenMutation) WhereP(ps ...func(*sql.Selector)) {
  25479. p := make([]predicate.Token, len(ps))
  25480. for i := range ps {
  25481. p[i] = ps[i]
  25482. }
  25483. m.Where(p...)
  25484. }
  25485. // Op returns the operation name.
  25486. func (m *TokenMutation) Op() Op {
  25487. return m.op
  25488. }
  25489. // SetOp allows setting the mutation operation.
  25490. func (m *TokenMutation) SetOp(op Op) {
  25491. m.op = op
  25492. }
  25493. // Type returns the node type of this mutation (Token).
  25494. func (m *TokenMutation) Type() string {
  25495. return m.typ
  25496. }
  25497. // Fields returns all fields that were changed during this mutation. Note that in
  25498. // order to get all numeric fields that were incremented/decremented, call
  25499. // AddedFields().
  25500. func (m *TokenMutation) Fields() []string {
  25501. fields := make([]string, 0, 12)
  25502. if m.created_at != nil {
  25503. fields = append(fields, token.FieldCreatedAt)
  25504. }
  25505. if m.updated_at != nil {
  25506. fields = append(fields, token.FieldUpdatedAt)
  25507. }
  25508. if m.deleted_at != nil {
  25509. fields = append(fields, token.FieldDeletedAt)
  25510. }
  25511. if m.expire_at != nil {
  25512. fields = append(fields, token.FieldExpireAt)
  25513. }
  25514. if m.token != nil {
  25515. fields = append(fields, token.FieldToken)
  25516. }
  25517. if m.mac != nil {
  25518. fields = append(fields, token.FieldMAC)
  25519. }
  25520. if m.organization_id != nil {
  25521. fields = append(fields, token.FieldOrganizationID)
  25522. }
  25523. if m.agent != nil {
  25524. fields = append(fields, token.FieldAgentID)
  25525. }
  25526. if m.custom_agent_base != nil {
  25527. fields = append(fields, token.FieldCustomAgentBase)
  25528. }
  25529. if m.custom_agent_key != nil {
  25530. fields = append(fields, token.FieldCustomAgentKey)
  25531. }
  25532. if m.openai_base != nil {
  25533. fields = append(fields, token.FieldOpenaiBase)
  25534. }
  25535. if m.openai_key != nil {
  25536. fields = append(fields, token.FieldOpenaiKey)
  25537. }
  25538. return fields
  25539. }
  25540. // Field returns the value of a field with the given name. The second boolean
  25541. // return value indicates that this field was not set, or was not defined in the
  25542. // schema.
  25543. func (m *TokenMutation) Field(name string) (ent.Value, bool) {
  25544. switch name {
  25545. case token.FieldCreatedAt:
  25546. return m.CreatedAt()
  25547. case token.FieldUpdatedAt:
  25548. return m.UpdatedAt()
  25549. case token.FieldDeletedAt:
  25550. return m.DeletedAt()
  25551. case token.FieldExpireAt:
  25552. return m.ExpireAt()
  25553. case token.FieldToken:
  25554. return m.Token()
  25555. case token.FieldMAC:
  25556. return m.MAC()
  25557. case token.FieldOrganizationID:
  25558. return m.OrganizationID()
  25559. case token.FieldAgentID:
  25560. return m.AgentID()
  25561. case token.FieldCustomAgentBase:
  25562. return m.CustomAgentBase()
  25563. case token.FieldCustomAgentKey:
  25564. return m.CustomAgentKey()
  25565. case token.FieldOpenaiBase:
  25566. return m.OpenaiBase()
  25567. case token.FieldOpenaiKey:
  25568. return m.OpenaiKey()
  25569. }
  25570. return nil, false
  25571. }
  25572. // OldField returns the old value of the field from the database. An error is
  25573. // returned if the mutation operation is not UpdateOne, or the query to the
  25574. // database failed.
  25575. func (m *TokenMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  25576. switch name {
  25577. case token.FieldCreatedAt:
  25578. return m.OldCreatedAt(ctx)
  25579. case token.FieldUpdatedAt:
  25580. return m.OldUpdatedAt(ctx)
  25581. case token.FieldDeletedAt:
  25582. return m.OldDeletedAt(ctx)
  25583. case token.FieldExpireAt:
  25584. return m.OldExpireAt(ctx)
  25585. case token.FieldToken:
  25586. return m.OldToken(ctx)
  25587. case token.FieldMAC:
  25588. return m.OldMAC(ctx)
  25589. case token.FieldOrganizationID:
  25590. return m.OldOrganizationID(ctx)
  25591. case token.FieldAgentID:
  25592. return m.OldAgentID(ctx)
  25593. case token.FieldCustomAgentBase:
  25594. return m.OldCustomAgentBase(ctx)
  25595. case token.FieldCustomAgentKey:
  25596. return m.OldCustomAgentKey(ctx)
  25597. case token.FieldOpenaiBase:
  25598. return m.OldOpenaiBase(ctx)
  25599. case token.FieldOpenaiKey:
  25600. return m.OldOpenaiKey(ctx)
  25601. }
  25602. return nil, fmt.Errorf("unknown Token field %s", name)
  25603. }
  25604. // SetField sets the value of a field with the given name. It returns an error if
  25605. // the field is not defined in the schema, or if the type mismatched the field
  25606. // type.
  25607. func (m *TokenMutation) SetField(name string, value ent.Value) error {
  25608. switch name {
  25609. case token.FieldCreatedAt:
  25610. v, ok := value.(time.Time)
  25611. if !ok {
  25612. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25613. }
  25614. m.SetCreatedAt(v)
  25615. return nil
  25616. case token.FieldUpdatedAt:
  25617. v, ok := value.(time.Time)
  25618. if !ok {
  25619. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25620. }
  25621. m.SetUpdatedAt(v)
  25622. return nil
  25623. case token.FieldDeletedAt:
  25624. v, ok := value.(time.Time)
  25625. if !ok {
  25626. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25627. }
  25628. m.SetDeletedAt(v)
  25629. return nil
  25630. case token.FieldExpireAt:
  25631. v, ok := value.(time.Time)
  25632. if !ok {
  25633. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25634. }
  25635. m.SetExpireAt(v)
  25636. return nil
  25637. case token.FieldToken:
  25638. v, ok := value.(string)
  25639. if !ok {
  25640. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25641. }
  25642. m.SetToken(v)
  25643. return nil
  25644. case token.FieldMAC:
  25645. v, ok := value.(string)
  25646. if !ok {
  25647. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25648. }
  25649. m.SetMAC(v)
  25650. return nil
  25651. case token.FieldOrganizationID:
  25652. v, ok := value.(uint64)
  25653. if !ok {
  25654. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25655. }
  25656. m.SetOrganizationID(v)
  25657. return nil
  25658. case token.FieldAgentID:
  25659. v, ok := value.(uint64)
  25660. if !ok {
  25661. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25662. }
  25663. m.SetAgentID(v)
  25664. return nil
  25665. case token.FieldCustomAgentBase:
  25666. v, ok := value.(string)
  25667. if !ok {
  25668. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25669. }
  25670. m.SetCustomAgentBase(v)
  25671. return nil
  25672. case token.FieldCustomAgentKey:
  25673. v, ok := value.(string)
  25674. if !ok {
  25675. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25676. }
  25677. m.SetCustomAgentKey(v)
  25678. return nil
  25679. case token.FieldOpenaiBase:
  25680. v, ok := value.(string)
  25681. if !ok {
  25682. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25683. }
  25684. m.SetOpenaiBase(v)
  25685. return nil
  25686. case token.FieldOpenaiKey:
  25687. v, ok := value.(string)
  25688. if !ok {
  25689. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25690. }
  25691. m.SetOpenaiKey(v)
  25692. return nil
  25693. }
  25694. return fmt.Errorf("unknown Token field %s", name)
  25695. }
  25696. // AddedFields returns all numeric fields that were incremented/decremented during
  25697. // this mutation.
  25698. func (m *TokenMutation) AddedFields() []string {
  25699. var fields []string
  25700. if m.addorganization_id != nil {
  25701. fields = append(fields, token.FieldOrganizationID)
  25702. }
  25703. return fields
  25704. }
  25705. // AddedField returns the numeric value that was incremented/decremented on a field
  25706. // with the given name. The second boolean return value indicates that this field
  25707. // was not set, or was not defined in the schema.
  25708. func (m *TokenMutation) AddedField(name string) (ent.Value, bool) {
  25709. switch name {
  25710. case token.FieldOrganizationID:
  25711. return m.AddedOrganizationID()
  25712. }
  25713. return nil, false
  25714. }
  25715. // AddField adds the value to the field with the given name. It returns an error if
  25716. // the field is not defined in the schema, or if the type mismatched the field
  25717. // type.
  25718. func (m *TokenMutation) AddField(name string, value ent.Value) error {
  25719. switch name {
  25720. case token.FieldOrganizationID:
  25721. v, ok := value.(int64)
  25722. if !ok {
  25723. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25724. }
  25725. m.AddOrganizationID(v)
  25726. return nil
  25727. }
  25728. return fmt.Errorf("unknown Token numeric field %s", name)
  25729. }
  25730. // ClearedFields returns all nullable fields that were cleared during this
  25731. // mutation.
  25732. func (m *TokenMutation) ClearedFields() []string {
  25733. var fields []string
  25734. if m.FieldCleared(token.FieldDeletedAt) {
  25735. fields = append(fields, token.FieldDeletedAt)
  25736. }
  25737. if m.FieldCleared(token.FieldExpireAt) {
  25738. fields = append(fields, token.FieldExpireAt)
  25739. }
  25740. if m.FieldCleared(token.FieldToken) {
  25741. fields = append(fields, token.FieldToken)
  25742. }
  25743. if m.FieldCleared(token.FieldMAC) {
  25744. fields = append(fields, token.FieldMAC)
  25745. }
  25746. if m.FieldCleared(token.FieldCustomAgentBase) {
  25747. fields = append(fields, token.FieldCustomAgentBase)
  25748. }
  25749. if m.FieldCleared(token.FieldCustomAgentKey) {
  25750. fields = append(fields, token.FieldCustomAgentKey)
  25751. }
  25752. if m.FieldCleared(token.FieldOpenaiBase) {
  25753. fields = append(fields, token.FieldOpenaiBase)
  25754. }
  25755. if m.FieldCleared(token.FieldOpenaiKey) {
  25756. fields = append(fields, token.FieldOpenaiKey)
  25757. }
  25758. return fields
  25759. }
  25760. // FieldCleared returns a boolean indicating if a field with the given name was
  25761. // cleared in this mutation.
  25762. func (m *TokenMutation) FieldCleared(name string) bool {
  25763. _, ok := m.clearedFields[name]
  25764. return ok
  25765. }
  25766. // ClearField clears the value of the field with the given name. It returns an
  25767. // error if the field is not defined in the schema.
  25768. func (m *TokenMutation) ClearField(name string) error {
  25769. switch name {
  25770. case token.FieldDeletedAt:
  25771. m.ClearDeletedAt()
  25772. return nil
  25773. case token.FieldExpireAt:
  25774. m.ClearExpireAt()
  25775. return nil
  25776. case token.FieldToken:
  25777. m.ClearToken()
  25778. return nil
  25779. case token.FieldMAC:
  25780. m.ClearMAC()
  25781. return nil
  25782. case token.FieldCustomAgentBase:
  25783. m.ClearCustomAgentBase()
  25784. return nil
  25785. case token.FieldCustomAgentKey:
  25786. m.ClearCustomAgentKey()
  25787. return nil
  25788. case token.FieldOpenaiBase:
  25789. m.ClearOpenaiBase()
  25790. return nil
  25791. case token.FieldOpenaiKey:
  25792. m.ClearOpenaiKey()
  25793. return nil
  25794. }
  25795. return fmt.Errorf("unknown Token nullable field %s", name)
  25796. }
  25797. // ResetField resets all changes in the mutation for the field with the given name.
  25798. // It returns an error if the field is not defined in the schema.
  25799. func (m *TokenMutation) ResetField(name string) error {
  25800. switch name {
  25801. case token.FieldCreatedAt:
  25802. m.ResetCreatedAt()
  25803. return nil
  25804. case token.FieldUpdatedAt:
  25805. m.ResetUpdatedAt()
  25806. return nil
  25807. case token.FieldDeletedAt:
  25808. m.ResetDeletedAt()
  25809. return nil
  25810. case token.FieldExpireAt:
  25811. m.ResetExpireAt()
  25812. return nil
  25813. case token.FieldToken:
  25814. m.ResetToken()
  25815. return nil
  25816. case token.FieldMAC:
  25817. m.ResetMAC()
  25818. return nil
  25819. case token.FieldOrganizationID:
  25820. m.ResetOrganizationID()
  25821. return nil
  25822. case token.FieldAgentID:
  25823. m.ResetAgentID()
  25824. return nil
  25825. case token.FieldCustomAgentBase:
  25826. m.ResetCustomAgentBase()
  25827. return nil
  25828. case token.FieldCustomAgentKey:
  25829. m.ResetCustomAgentKey()
  25830. return nil
  25831. case token.FieldOpenaiBase:
  25832. m.ResetOpenaiBase()
  25833. return nil
  25834. case token.FieldOpenaiKey:
  25835. m.ResetOpenaiKey()
  25836. return nil
  25837. }
  25838. return fmt.Errorf("unknown Token field %s", name)
  25839. }
  25840. // AddedEdges returns all edge names that were set/added in this mutation.
  25841. func (m *TokenMutation) AddedEdges() []string {
  25842. edges := make([]string, 0, 1)
  25843. if m.agent != nil {
  25844. edges = append(edges, token.EdgeAgent)
  25845. }
  25846. return edges
  25847. }
  25848. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  25849. // name in this mutation.
  25850. func (m *TokenMutation) AddedIDs(name string) []ent.Value {
  25851. switch name {
  25852. case token.EdgeAgent:
  25853. if id := m.agent; id != nil {
  25854. return []ent.Value{*id}
  25855. }
  25856. }
  25857. return nil
  25858. }
  25859. // RemovedEdges returns all edge names that were removed in this mutation.
  25860. func (m *TokenMutation) RemovedEdges() []string {
  25861. edges := make([]string, 0, 1)
  25862. return edges
  25863. }
  25864. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  25865. // the given name in this mutation.
  25866. func (m *TokenMutation) RemovedIDs(name string) []ent.Value {
  25867. return nil
  25868. }
  25869. // ClearedEdges returns all edge names that were cleared in this mutation.
  25870. func (m *TokenMutation) ClearedEdges() []string {
  25871. edges := make([]string, 0, 1)
  25872. if m.clearedagent {
  25873. edges = append(edges, token.EdgeAgent)
  25874. }
  25875. return edges
  25876. }
  25877. // EdgeCleared returns a boolean which indicates if the edge with the given name
  25878. // was cleared in this mutation.
  25879. func (m *TokenMutation) EdgeCleared(name string) bool {
  25880. switch name {
  25881. case token.EdgeAgent:
  25882. return m.clearedagent
  25883. }
  25884. return false
  25885. }
  25886. // ClearEdge clears the value of the edge with the given name. It returns an error
  25887. // if that edge is not defined in the schema.
  25888. func (m *TokenMutation) ClearEdge(name string) error {
  25889. switch name {
  25890. case token.EdgeAgent:
  25891. m.ClearAgent()
  25892. return nil
  25893. }
  25894. return fmt.Errorf("unknown Token unique edge %s", name)
  25895. }
  25896. // ResetEdge resets all changes to the edge with the given name in this mutation.
  25897. // It returns an error if the edge is not defined in the schema.
  25898. func (m *TokenMutation) ResetEdge(name string) error {
  25899. switch name {
  25900. case token.EdgeAgent:
  25901. m.ResetAgent()
  25902. return nil
  25903. }
  25904. return fmt.Errorf("unknown Token edge %s", name)
  25905. }
  25906. // TutorialMutation represents an operation that mutates the Tutorial nodes in the graph.
  25907. type TutorialMutation struct {
  25908. config
  25909. op Op
  25910. typ string
  25911. id *uint64
  25912. created_at *time.Time
  25913. updated_at *time.Time
  25914. deleted_at *time.Time
  25915. index *int
  25916. addindex *int
  25917. title *string
  25918. content *string
  25919. organization_id *uint64
  25920. addorganization_id *int64
  25921. clearedFields map[string]struct{}
  25922. employee *uint64
  25923. clearedemployee bool
  25924. done bool
  25925. oldValue func(context.Context) (*Tutorial, error)
  25926. predicates []predicate.Tutorial
  25927. }
  25928. var _ ent.Mutation = (*TutorialMutation)(nil)
  25929. // tutorialOption allows management of the mutation configuration using functional options.
  25930. type tutorialOption func(*TutorialMutation)
  25931. // newTutorialMutation creates new mutation for the Tutorial entity.
  25932. func newTutorialMutation(c config, op Op, opts ...tutorialOption) *TutorialMutation {
  25933. m := &TutorialMutation{
  25934. config: c,
  25935. op: op,
  25936. typ: TypeTutorial,
  25937. clearedFields: make(map[string]struct{}),
  25938. }
  25939. for _, opt := range opts {
  25940. opt(m)
  25941. }
  25942. return m
  25943. }
  25944. // withTutorialID sets the ID field of the mutation.
  25945. func withTutorialID(id uint64) tutorialOption {
  25946. return func(m *TutorialMutation) {
  25947. var (
  25948. err error
  25949. once sync.Once
  25950. value *Tutorial
  25951. )
  25952. m.oldValue = func(ctx context.Context) (*Tutorial, error) {
  25953. once.Do(func() {
  25954. if m.done {
  25955. err = errors.New("querying old values post mutation is not allowed")
  25956. } else {
  25957. value, err = m.Client().Tutorial.Get(ctx, id)
  25958. }
  25959. })
  25960. return value, err
  25961. }
  25962. m.id = &id
  25963. }
  25964. }
  25965. // withTutorial sets the old Tutorial of the mutation.
  25966. func withTutorial(node *Tutorial) tutorialOption {
  25967. return func(m *TutorialMutation) {
  25968. m.oldValue = func(context.Context) (*Tutorial, error) {
  25969. return node, nil
  25970. }
  25971. m.id = &node.ID
  25972. }
  25973. }
  25974. // Client returns a new `ent.Client` from the mutation. If the mutation was
  25975. // executed in a transaction (ent.Tx), a transactional client is returned.
  25976. func (m TutorialMutation) Client() *Client {
  25977. client := &Client{config: m.config}
  25978. client.init()
  25979. return client
  25980. }
  25981. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  25982. // it returns an error otherwise.
  25983. func (m TutorialMutation) Tx() (*Tx, error) {
  25984. if _, ok := m.driver.(*txDriver); !ok {
  25985. return nil, errors.New("ent: mutation is not running in a transaction")
  25986. }
  25987. tx := &Tx{config: m.config}
  25988. tx.init()
  25989. return tx, nil
  25990. }
  25991. // SetID sets the value of the id field. Note that this
  25992. // operation is only accepted on creation of Tutorial entities.
  25993. func (m *TutorialMutation) SetID(id uint64) {
  25994. m.id = &id
  25995. }
  25996. // ID returns the ID value in the mutation. Note that the ID is only available
  25997. // if it was provided to the builder or after it was returned from the database.
  25998. func (m *TutorialMutation) ID() (id uint64, exists bool) {
  25999. if m.id == nil {
  26000. return
  26001. }
  26002. return *m.id, true
  26003. }
  26004. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  26005. // That means, if the mutation is applied within a transaction with an isolation level such
  26006. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  26007. // or updated by the mutation.
  26008. func (m *TutorialMutation) IDs(ctx context.Context) ([]uint64, error) {
  26009. switch {
  26010. case m.op.Is(OpUpdateOne | OpDeleteOne):
  26011. id, exists := m.ID()
  26012. if exists {
  26013. return []uint64{id}, nil
  26014. }
  26015. fallthrough
  26016. case m.op.Is(OpUpdate | OpDelete):
  26017. return m.Client().Tutorial.Query().Where(m.predicates...).IDs(ctx)
  26018. default:
  26019. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  26020. }
  26021. }
  26022. // SetCreatedAt sets the "created_at" field.
  26023. func (m *TutorialMutation) SetCreatedAt(t time.Time) {
  26024. m.created_at = &t
  26025. }
  26026. // CreatedAt returns the value of the "created_at" field in the mutation.
  26027. func (m *TutorialMutation) CreatedAt() (r time.Time, exists bool) {
  26028. v := m.created_at
  26029. if v == nil {
  26030. return
  26031. }
  26032. return *v, true
  26033. }
  26034. // OldCreatedAt returns the old "created_at" field's value of the Tutorial entity.
  26035. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  26036. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26037. func (m *TutorialMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  26038. if !m.op.Is(OpUpdateOne) {
  26039. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  26040. }
  26041. if m.id == nil || m.oldValue == nil {
  26042. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  26043. }
  26044. oldValue, err := m.oldValue(ctx)
  26045. if err != nil {
  26046. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  26047. }
  26048. return oldValue.CreatedAt, nil
  26049. }
  26050. // ResetCreatedAt resets all changes to the "created_at" field.
  26051. func (m *TutorialMutation) ResetCreatedAt() {
  26052. m.created_at = nil
  26053. }
  26054. // SetUpdatedAt sets the "updated_at" field.
  26055. func (m *TutorialMutation) SetUpdatedAt(t time.Time) {
  26056. m.updated_at = &t
  26057. }
  26058. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  26059. func (m *TutorialMutation) UpdatedAt() (r time.Time, exists bool) {
  26060. v := m.updated_at
  26061. if v == nil {
  26062. return
  26063. }
  26064. return *v, true
  26065. }
  26066. // OldUpdatedAt returns the old "updated_at" field's value of the Tutorial entity.
  26067. // If the Tutorial 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 *TutorialMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  26070. if !m.op.Is(OpUpdateOne) {
  26071. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  26072. }
  26073. if m.id == nil || m.oldValue == nil {
  26074. return v, errors.New("OldUpdatedAt 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 OldUpdatedAt: %w", err)
  26079. }
  26080. return oldValue.UpdatedAt, nil
  26081. }
  26082. // ResetUpdatedAt resets all changes to the "updated_at" field.
  26083. func (m *TutorialMutation) ResetUpdatedAt() {
  26084. m.updated_at = nil
  26085. }
  26086. // SetDeletedAt sets the "deleted_at" field.
  26087. func (m *TutorialMutation) SetDeletedAt(t time.Time) {
  26088. m.deleted_at = &t
  26089. }
  26090. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  26091. func (m *TutorialMutation) DeletedAt() (r time.Time, exists bool) {
  26092. v := m.deleted_at
  26093. if v == nil {
  26094. return
  26095. }
  26096. return *v, true
  26097. }
  26098. // OldDeletedAt returns the old "deleted_at" field's value of the Tutorial entity.
  26099. // If the Tutorial 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 *TutorialMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  26102. if !m.op.Is(OpUpdateOne) {
  26103. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  26104. }
  26105. if m.id == nil || m.oldValue == nil {
  26106. return v, errors.New("OldDeletedAt 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 OldDeletedAt: %w", err)
  26111. }
  26112. return oldValue.DeletedAt, nil
  26113. }
  26114. // ClearDeletedAt clears the value of the "deleted_at" field.
  26115. func (m *TutorialMutation) ClearDeletedAt() {
  26116. m.deleted_at = nil
  26117. m.clearedFields[tutorial.FieldDeletedAt] = struct{}{}
  26118. }
  26119. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  26120. func (m *TutorialMutation) DeletedAtCleared() bool {
  26121. _, ok := m.clearedFields[tutorial.FieldDeletedAt]
  26122. return ok
  26123. }
  26124. // ResetDeletedAt resets all changes to the "deleted_at" field.
  26125. func (m *TutorialMutation) ResetDeletedAt() {
  26126. m.deleted_at = nil
  26127. delete(m.clearedFields, tutorial.FieldDeletedAt)
  26128. }
  26129. // SetEmployeeID sets the "employee_id" field.
  26130. func (m *TutorialMutation) SetEmployeeID(u uint64) {
  26131. m.employee = &u
  26132. }
  26133. // EmployeeID returns the value of the "employee_id" field in the mutation.
  26134. func (m *TutorialMutation) EmployeeID() (r uint64, exists bool) {
  26135. v := m.employee
  26136. if v == nil {
  26137. return
  26138. }
  26139. return *v, true
  26140. }
  26141. // OldEmployeeID returns the old "employee_id" field's value of the Tutorial entity.
  26142. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  26143. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26144. func (m *TutorialMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  26145. if !m.op.Is(OpUpdateOne) {
  26146. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  26147. }
  26148. if m.id == nil || m.oldValue == nil {
  26149. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  26150. }
  26151. oldValue, err := m.oldValue(ctx)
  26152. if err != nil {
  26153. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  26154. }
  26155. return oldValue.EmployeeID, nil
  26156. }
  26157. // ResetEmployeeID resets all changes to the "employee_id" field.
  26158. func (m *TutorialMutation) ResetEmployeeID() {
  26159. m.employee = nil
  26160. }
  26161. // SetIndex sets the "index" field.
  26162. func (m *TutorialMutation) SetIndex(i int) {
  26163. m.index = &i
  26164. m.addindex = nil
  26165. }
  26166. // Index returns the value of the "index" field in the mutation.
  26167. func (m *TutorialMutation) Index() (r int, exists bool) {
  26168. v := m.index
  26169. if v == nil {
  26170. return
  26171. }
  26172. return *v, true
  26173. }
  26174. // OldIndex returns the old "index" field's value of the Tutorial entity.
  26175. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  26176. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26177. func (m *TutorialMutation) OldIndex(ctx context.Context) (v int, err error) {
  26178. if !m.op.Is(OpUpdateOne) {
  26179. return v, errors.New("OldIndex is only allowed on UpdateOne operations")
  26180. }
  26181. if m.id == nil || m.oldValue == nil {
  26182. return v, errors.New("OldIndex requires an ID field in the mutation")
  26183. }
  26184. oldValue, err := m.oldValue(ctx)
  26185. if err != nil {
  26186. return v, fmt.Errorf("querying old value for OldIndex: %w", err)
  26187. }
  26188. return oldValue.Index, nil
  26189. }
  26190. // AddIndex adds i to the "index" field.
  26191. func (m *TutorialMutation) AddIndex(i int) {
  26192. if m.addindex != nil {
  26193. *m.addindex += i
  26194. } else {
  26195. m.addindex = &i
  26196. }
  26197. }
  26198. // AddedIndex returns the value that was added to the "index" field in this mutation.
  26199. func (m *TutorialMutation) AddedIndex() (r int, exists bool) {
  26200. v := m.addindex
  26201. if v == nil {
  26202. return
  26203. }
  26204. return *v, true
  26205. }
  26206. // ResetIndex resets all changes to the "index" field.
  26207. func (m *TutorialMutation) ResetIndex() {
  26208. m.index = nil
  26209. m.addindex = nil
  26210. }
  26211. // SetTitle sets the "title" field.
  26212. func (m *TutorialMutation) SetTitle(s string) {
  26213. m.title = &s
  26214. }
  26215. // Title returns the value of the "title" field in the mutation.
  26216. func (m *TutorialMutation) Title() (r string, exists bool) {
  26217. v := m.title
  26218. if v == nil {
  26219. return
  26220. }
  26221. return *v, true
  26222. }
  26223. // OldTitle returns the old "title" field's value of the Tutorial entity.
  26224. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  26225. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26226. func (m *TutorialMutation) OldTitle(ctx context.Context) (v string, err error) {
  26227. if !m.op.Is(OpUpdateOne) {
  26228. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  26229. }
  26230. if m.id == nil || m.oldValue == nil {
  26231. return v, errors.New("OldTitle requires an ID field in the mutation")
  26232. }
  26233. oldValue, err := m.oldValue(ctx)
  26234. if err != nil {
  26235. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  26236. }
  26237. return oldValue.Title, nil
  26238. }
  26239. // ResetTitle resets all changes to the "title" field.
  26240. func (m *TutorialMutation) ResetTitle() {
  26241. m.title = nil
  26242. }
  26243. // SetContent sets the "content" field.
  26244. func (m *TutorialMutation) SetContent(s string) {
  26245. m.content = &s
  26246. }
  26247. // Content returns the value of the "content" field in the mutation.
  26248. func (m *TutorialMutation) Content() (r string, exists bool) {
  26249. v := m.content
  26250. if v == nil {
  26251. return
  26252. }
  26253. return *v, true
  26254. }
  26255. // OldContent returns the old "content" field's value of the Tutorial entity.
  26256. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  26257. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26258. func (m *TutorialMutation) OldContent(ctx context.Context) (v string, err error) {
  26259. if !m.op.Is(OpUpdateOne) {
  26260. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  26261. }
  26262. if m.id == nil || m.oldValue == nil {
  26263. return v, errors.New("OldContent requires an ID field in the mutation")
  26264. }
  26265. oldValue, err := m.oldValue(ctx)
  26266. if err != nil {
  26267. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  26268. }
  26269. return oldValue.Content, nil
  26270. }
  26271. // ResetContent resets all changes to the "content" field.
  26272. func (m *TutorialMutation) ResetContent() {
  26273. m.content = nil
  26274. }
  26275. // SetOrganizationID sets the "organization_id" field.
  26276. func (m *TutorialMutation) SetOrganizationID(u uint64) {
  26277. m.organization_id = &u
  26278. m.addorganization_id = nil
  26279. }
  26280. // OrganizationID returns the value of the "organization_id" field in the mutation.
  26281. func (m *TutorialMutation) OrganizationID() (r uint64, exists bool) {
  26282. v := m.organization_id
  26283. if v == nil {
  26284. return
  26285. }
  26286. return *v, true
  26287. }
  26288. // OldOrganizationID returns the old "organization_id" field's value of the Tutorial entity.
  26289. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  26290. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26291. func (m *TutorialMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  26292. if !m.op.Is(OpUpdateOne) {
  26293. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  26294. }
  26295. if m.id == nil || m.oldValue == nil {
  26296. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  26297. }
  26298. oldValue, err := m.oldValue(ctx)
  26299. if err != nil {
  26300. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  26301. }
  26302. return oldValue.OrganizationID, nil
  26303. }
  26304. // AddOrganizationID adds u to the "organization_id" field.
  26305. func (m *TutorialMutation) AddOrganizationID(u int64) {
  26306. if m.addorganization_id != nil {
  26307. *m.addorganization_id += u
  26308. } else {
  26309. m.addorganization_id = &u
  26310. }
  26311. }
  26312. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  26313. func (m *TutorialMutation) AddedOrganizationID() (r int64, exists bool) {
  26314. v := m.addorganization_id
  26315. if v == nil {
  26316. return
  26317. }
  26318. return *v, true
  26319. }
  26320. // ResetOrganizationID resets all changes to the "organization_id" field.
  26321. func (m *TutorialMutation) ResetOrganizationID() {
  26322. m.organization_id = nil
  26323. m.addorganization_id = nil
  26324. }
  26325. // ClearEmployee clears the "employee" edge to the Employee entity.
  26326. func (m *TutorialMutation) ClearEmployee() {
  26327. m.clearedemployee = true
  26328. m.clearedFields[tutorial.FieldEmployeeID] = struct{}{}
  26329. }
  26330. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  26331. func (m *TutorialMutation) EmployeeCleared() bool {
  26332. return m.clearedemployee
  26333. }
  26334. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  26335. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  26336. // EmployeeID instead. It exists only for internal usage by the builders.
  26337. func (m *TutorialMutation) EmployeeIDs() (ids []uint64) {
  26338. if id := m.employee; id != nil {
  26339. ids = append(ids, *id)
  26340. }
  26341. return
  26342. }
  26343. // ResetEmployee resets all changes to the "employee" edge.
  26344. func (m *TutorialMutation) ResetEmployee() {
  26345. m.employee = nil
  26346. m.clearedemployee = false
  26347. }
  26348. // Where appends a list predicates to the TutorialMutation builder.
  26349. func (m *TutorialMutation) Where(ps ...predicate.Tutorial) {
  26350. m.predicates = append(m.predicates, ps...)
  26351. }
  26352. // WhereP appends storage-level predicates to the TutorialMutation builder. Using this method,
  26353. // users can use type-assertion to append predicates that do not depend on any generated package.
  26354. func (m *TutorialMutation) WhereP(ps ...func(*sql.Selector)) {
  26355. p := make([]predicate.Tutorial, len(ps))
  26356. for i := range ps {
  26357. p[i] = ps[i]
  26358. }
  26359. m.Where(p...)
  26360. }
  26361. // Op returns the operation name.
  26362. func (m *TutorialMutation) Op() Op {
  26363. return m.op
  26364. }
  26365. // SetOp allows setting the mutation operation.
  26366. func (m *TutorialMutation) SetOp(op Op) {
  26367. m.op = op
  26368. }
  26369. // Type returns the node type of this mutation (Tutorial).
  26370. func (m *TutorialMutation) Type() string {
  26371. return m.typ
  26372. }
  26373. // Fields returns all fields that were changed during this mutation. Note that in
  26374. // order to get all numeric fields that were incremented/decremented, call
  26375. // AddedFields().
  26376. func (m *TutorialMutation) Fields() []string {
  26377. fields := make([]string, 0, 8)
  26378. if m.created_at != nil {
  26379. fields = append(fields, tutorial.FieldCreatedAt)
  26380. }
  26381. if m.updated_at != nil {
  26382. fields = append(fields, tutorial.FieldUpdatedAt)
  26383. }
  26384. if m.deleted_at != nil {
  26385. fields = append(fields, tutorial.FieldDeletedAt)
  26386. }
  26387. if m.employee != nil {
  26388. fields = append(fields, tutorial.FieldEmployeeID)
  26389. }
  26390. if m.index != nil {
  26391. fields = append(fields, tutorial.FieldIndex)
  26392. }
  26393. if m.title != nil {
  26394. fields = append(fields, tutorial.FieldTitle)
  26395. }
  26396. if m.content != nil {
  26397. fields = append(fields, tutorial.FieldContent)
  26398. }
  26399. if m.organization_id != nil {
  26400. fields = append(fields, tutorial.FieldOrganizationID)
  26401. }
  26402. return fields
  26403. }
  26404. // Field returns the value of a field with the given name. The second boolean
  26405. // return value indicates that this field was not set, or was not defined in the
  26406. // schema.
  26407. func (m *TutorialMutation) Field(name string) (ent.Value, bool) {
  26408. switch name {
  26409. case tutorial.FieldCreatedAt:
  26410. return m.CreatedAt()
  26411. case tutorial.FieldUpdatedAt:
  26412. return m.UpdatedAt()
  26413. case tutorial.FieldDeletedAt:
  26414. return m.DeletedAt()
  26415. case tutorial.FieldEmployeeID:
  26416. return m.EmployeeID()
  26417. case tutorial.FieldIndex:
  26418. return m.Index()
  26419. case tutorial.FieldTitle:
  26420. return m.Title()
  26421. case tutorial.FieldContent:
  26422. return m.Content()
  26423. case tutorial.FieldOrganizationID:
  26424. return m.OrganizationID()
  26425. }
  26426. return nil, false
  26427. }
  26428. // OldField returns the old value of the field from the database. An error is
  26429. // returned if the mutation operation is not UpdateOne, or the query to the
  26430. // database failed.
  26431. func (m *TutorialMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  26432. switch name {
  26433. case tutorial.FieldCreatedAt:
  26434. return m.OldCreatedAt(ctx)
  26435. case tutorial.FieldUpdatedAt:
  26436. return m.OldUpdatedAt(ctx)
  26437. case tutorial.FieldDeletedAt:
  26438. return m.OldDeletedAt(ctx)
  26439. case tutorial.FieldEmployeeID:
  26440. return m.OldEmployeeID(ctx)
  26441. case tutorial.FieldIndex:
  26442. return m.OldIndex(ctx)
  26443. case tutorial.FieldTitle:
  26444. return m.OldTitle(ctx)
  26445. case tutorial.FieldContent:
  26446. return m.OldContent(ctx)
  26447. case tutorial.FieldOrganizationID:
  26448. return m.OldOrganizationID(ctx)
  26449. }
  26450. return nil, fmt.Errorf("unknown Tutorial field %s", name)
  26451. }
  26452. // SetField sets the value of a field with the given name. It returns an error if
  26453. // the field is not defined in the schema, or if the type mismatched the field
  26454. // type.
  26455. func (m *TutorialMutation) SetField(name string, value ent.Value) error {
  26456. switch name {
  26457. case tutorial.FieldCreatedAt:
  26458. v, ok := value.(time.Time)
  26459. if !ok {
  26460. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26461. }
  26462. m.SetCreatedAt(v)
  26463. return nil
  26464. case tutorial.FieldUpdatedAt:
  26465. v, ok := value.(time.Time)
  26466. if !ok {
  26467. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26468. }
  26469. m.SetUpdatedAt(v)
  26470. return nil
  26471. case tutorial.FieldDeletedAt:
  26472. v, ok := value.(time.Time)
  26473. if !ok {
  26474. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26475. }
  26476. m.SetDeletedAt(v)
  26477. return nil
  26478. case tutorial.FieldEmployeeID:
  26479. v, ok := value.(uint64)
  26480. if !ok {
  26481. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26482. }
  26483. m.SetEmployeeID(v)
  26484. return nil
  26485. case tutorial.FieldIndex:
  26486. v, ok := value.(int)
  26487. if !ok {
  26488. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26489. }
  26490. m.SetIndex(v)
  26491. return nil
  26492. case tutorial.FieldTitle:
  26493. v, ok := value.(string)
  26494. if !ok {
  26495. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26496. }
  26497. m.SetTitle(v)
  26498. return nil
  26499. case tutorial.FieldContent:
  26500. v, ok := value.(string)
  26501. if !ok {
  26502. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26503. }
  26504. m.SetContent(v)
  26505. return nil
  26506. case tutorial.FieldOrganizationID:
  26507. v, ok := value.(uint64)
  26508. if !ok {
  26509. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26510. }
  26511. m.SetOrganizationID(v)
  26512. return nil
  26513. }
  26514. return fmt.Errorf("unknown Tutorial field %s", name)
  26515. }
  26516. // AddedFields returns all numeric fields that were incremented/decremented during
  26517. // this mutation.
  26518. func (m *TutorialMutation) AddedFields() []string {
  26519. var fields []string
  26520. if m.addindex != nil {
  26521. fields = append(fields, tutorial.FieldIndex)
  26522. }
  26523. if m.addorganization_id != nil {
  26524. fields = append(fields, tutorial.FieldOrganizationID)
  26525. }
  26526. return fields
  26527. }
  26528. // AddedField returns the numeric value that was incremented/decremented on a field
  26529. // with the given name. The second boolean return value indicates that this field
  26530. // was not set, or was not defined in the schema.
  26531. func (m *TutorialMutation) AddedField(name string) (ent.Value, bool) {
  26532. switch name {
  26533. case tutorial.FieldIndex:
  26534. return m.AddedIndex()
  26535. case tutorial.FieldOrganizationID:
  26536. return m.AddedOrganizationID()
  26537. }
  26538. return nil, false
  26539. }
  26540. // AddField adds the value to the field with the given name. It returns an error if
  26541. // the field is not defined in the schema, or if the type mismatched the field
  26542. // type.
  26543. func (m *TutorialMutation) AddField(name string, value ent.Value) error {
  26544. switch name {
  26545. case tutorial.FieldIndex:
  26546. v, ok := value.(int)
  26547. if !ok {
  26548. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26549. }
  26550. m.AddIndex(v)
  26551. return nil
  26552. case tutorial.FieldOrganizationID:
  26553. v, ok := value.(int64)
  26554. if !ok {
  26555. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26556. }
  26557. m.AddOrganizationID(v)
  26558. return nil
  26559. }
  26560. return fmt.Errorf("unknown Tutorial numeric field %s", name)
  26561. }
  26562. // ClearedFields returns all nullable fields that were cleared during this
  26563. // mutation.
  26564. func (m *TutorialMutation) ClearedFields() []string {
  26565. var fields []string
  26566. if m.FieldCleared(tutorial.FieldDeletedAt) {
  26567. fields = append(fields, tutorial.FieldDeletedAt)
  26568. }
  26569. return fields
  26570. }
  26571. // FieldCleared returns a boolean indicating if a field with the given name was
  26572. // cleared in this mutation.
  26573. func (m *TutorialMutation) FieldCleared(name string) bool {
  26574. _, ok := m.clearedFields[name]
  26575. return ok
  26576. }
  26577. // ClearField clears the value of the field with the given name. It returns an
  26578. // error if the field is not defined in the schema.
  26579. func (m *TutorialMutation) ClearField(name string) error {
  26580. switch name {
  26581. case tutorial.FieldDeletedAt:
  26582. m.ClearDeletedAt()
  26583. return nil
  26584. }
  26585. return fmt.Errorf("unknown Tutorial nullable field %s", name)
  26586. }
  26587. // ResetField resets all changes in the mutation for the field with the given name.
  26588. // It returns an error if the field is not defined in the schema.
  26589. func (m *TutorialMutation) ResetField(name string) error {
  26590. switch name {
  26591. case tutorial.FieldCreatedAt:
  26592. m.ResetCreatedAt()
  26593. return nil
  26594. case tutorial.FieldUpdatedAt:
  26595. m.ResetUpdatedAt()
  26596. return nil
  26597. case tutorial.FieldDeletedAt:
  26598. m.ResetDeletedAt()
  26599. return nil
  26600. case tutorial.FieldEmployeeID:
  26601. m.ResetEmployeeID()
  26602. return nil
  26603. case tutorial.FieldIndex:
  26604. m.ResetIndex()
  26605. return nil
  26606. case tutorial.FieldTitle:
  26607. m.ResetTitle()
  26608. return nil
  26609. case tutorial.FieldContent:
  26610. m.ResetContent()
  26611. return nil
  26612. case tutorial.FieldOrganizationID:
  26613. m.ResetOrganizationID()
  26614. return nil
  26615. }
  26616. return fmt.Errorf("unknown Tutorial field %s", name)
  26617. }
  26618. // AddedEdges returns all edge names that were set/added in this mutation.
  26619. func (m *TutorialMutation) AddedEdges() []string {
  26620. edges := make([]string, 0, 1)
  26621. if m.employee != nil {
  26622. edges = append(edges, tutorial.EdgeEmployee)
  26623. }
  26624. return edges
  26625. }
  26626. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  26627. // name in this mutation.
  26628. func (m *TutorialMutation) AddedIDs(name string) []ent.Value {
  26629. switch name {
  26630. case tutorial.EdgeEmployee:
  26631. if id := m.employee; id != nil {
  26632. return []ent.Value{*id}
  26633. }
  26634. }
  26635. return nil
  26636. }
  26637. // RemovedEdges returns all edge names that were removed in this mutation.
  26638. func (m *TutorialMutation) RemovedEdges() []string {
  26639. edges := make([]string, 0, 1)
  26640. return edges
  26641. }
  26642. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  26643. // the given name in this mutation.
  26644. func (m *TutorialMutation) RemovedIDs(name string) []ent.Value {
  26645. return nil
  26646. }
  26647. // ClearedEdges returns all edge names that were cleared in this mutation.
  26648. func (m *TutorialMutation) ClearedEdges() []string {
  26649. edges := make([]string, 0, 1)
  26650. if m.clearedemployee {
  26651. edges = append(edges, tutorial.EdgeEmployee)
  26652. }
  26653. return edges
  26654. }
  26655. // EdgeCleared returns a boolean which indicates if the edge with the given name
  26656. // was cleared in this mutation.
  26657. func (m *TutorialMutation) EdgeCleared(name string) bool {
  26658. switch name {
  26659. case tutorial.EdgeEmployee:
  26660. return m.clearedemployee
  26661. }
  26662. return false
  26663. }
  26664. // ClearEdge clears the value of the edge with the given name. It returns an error
  26665. // if that edge is not defined in the schema.
  26666. func (m *TutorialMutation) ClearEdge(name string) error {
  26667. switch name {
  26668. case tutorial.EdgeEmployee:
  26669. m.ClearEmployee()
  26670. return nil
  26671. }
  26672. return fmt.Errorf("unknown Tutorial unique edge %s", name)
  26673. }
  26674. // ResetEdge resets all changes to the edge with the given name in this mutation.
  26675. // It returns an error if the edge is not defined in the schema.
  26676. func (m *TutorialMutation) ResetEdge(name string) error {
  26677. switch name {
  26678. case tutorial.EdgeEmployee:
  26679. m.ResetEmployee()
  26680. return nil
  26681. }
  26682. return fmt.Errorf("unknown Tutorial edge %s", name)
  26683. }
  26684. // UsageDetailMutation represents an operation that mutates the UsageDetail nodes in the graph.
  26685. type UsageDetailMutation struct {
  26686. config
  26687. op Op
  26688. typ string
  26689. id *uint64
  26690. created_at *time.Time
  26691. updated_at *time.Time
  26692. status *uint8
  26693. addstatus *int8
  26694. _type *int
  26695. add_type *int
  26696. bot_id *string
  26697. receiver_id *string
  26698. app *int
  26699. addapp *int
  26700. session_id *uint64
  26701. addsession_id *int64
  26702. request *string
  26703. response *string
  26704. original_data *custom_types.OriginalData
  26705. total_tokens *uint64
  26706. addtotal_tokens *int64
  26707. prompt_tokens *uint64
  26708. addprompt_tokens *int64
  26709. completion_tokens *uint64
  26710. addcompletion_tokens *int64
  26711. organization_id *uint64
  26712. addorganization_id *int64
  26713. clearedFields map[string]struct{}
  26714. done bool
  26715. oldValue func(context.Context) (*UsageDetail, error)
  26716. predicates []predicate.UsageDetail
  26717. }
  26718. var _ ent.Mutation = (*UsageDetailMutation)(nil)
  26719. // usagedetailOption allows management of the mutation configuration using functional options.
  26720. type usagedetailOption func(*UsageDetailMutation)
  26721. // newUsageDetailMutation creates new mutation for the UsageDetail entity.
  26722. func newUsageDetailMutation(c config, op Op, opts ...usagedetailOption) *UsageDetailMutation {
  26723. m := &UsageDetailMutation{
  26724. config: c,
  26725. op: op,
  26726. typ: TypeUsageDetail,
  26727. clearedFields: make(map[string]struct{}),
  26728. }
  26729. for _, opt := range opts {
  26730. opt(m)
  26731. }
  26732. return m
  26733. }
  26734. // withUsageDetailID sets the ID field of the mutation.
  26735. func withUsageDetailID(id uint64) usagedetailOption {
  26736. return func(m *UsageDetailMutation) {
  26737. var (
  26738. err error
  26739. once sync.Once
  26740. value *UsageDetail
  26741. )
  26742. m.oldValue = func(ctx context.Context) (*UsageDetail, error) {
  26743. once.Do(func() {
  26744. if m.done {
  26745. err = errors.New("querying old values post mutation is not allowed")
  26746. } else {
  26747. value, err = m.Client().UsageDetail.Get(ctx, id)
  26748. }
  26749. })
  26750. return value, err
  26751. }
  26752. m.id = &id
  26753. }
  26754. }
  26755. // withUsageDetail sets the old UsageDetail of the mutation.
  26756. func withUsageDetail(node *UsageDetail) usagedetailOption {
  26757. return func(m *UsageDetailMutation) {
  26758. m.oldValue = func(context.Context) (*UsageDetail, error) {
  26759. return node, nil
  26760. }
  26761. m.id = &node.ID
  26762. }
  26763. }
  26764. // Client returns a new `ent.Client` from the mutation. If the mutation was
  26765. // executed in a transaction (ent.Tx), a transactional client is returned.
  26766. func (m UsageDetailMutation) Client() *Client {
  26767. client := &Client{config: m.config}
  26768. client.init()
  26769. return client
  26770. }
  26771. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  26772. // it returns an error otherwise.
  26773. func (m UsageDetailMutation) Tx() (*Tx, error) {
  26774. if _, ok := m.driver.(*txDriver); !ok {
  26775. return nil, errors.New("ent: mutation is not running in a transaction")
  26776. }
  26777. tx := &Tx{config: m.config}
  26778. tx.init()
  26779. return tx, nil
  26780. }
  26781. // SetID sets the value of the id field. Note that this
  26782. // operation is only accepted on creation of UsageDetail entities.
  26783. func (m *UsageDetailMutation) SetID(id uint64) {
  26784. m.id = &id
  26785. }
  26786. // ID returns the ID value in the mutation. Note that the ID is only available
  26787. // if it was provided to the builder or after it was returned from the database.
  26788. func (m *UsageDetailMutation) ID() (id uint64, exists bool) {
  26789. if m.id == nil {
  26790. return
  26791. }
  26792. return *m.id, true
  26793. }
  26794. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  26795. // That means, if the mutation is applied within a transaction with an isolation level such
  26796. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  26797. // or updated by the mutation.
  26798. func (m *UsageDetailMutation) IDs(ctx context.Context) ([]uint64, error) {
  26799. switch {
  26800. case m.op.Is(OpUpdateOne | OpDeleteOne):
  26801. id, exists := m.ID()
  26802. if exists {
  26803. return []uint64{id}, nil
  26804. }
  26805. fallthrough
  26806. case m.op.Is(OpUpdate | OpDelete):
  26807. return m.Client().UsageDetail.Query().Where(m.predicates...).IDs(ctx)
  26808. default:
  26809. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  26810. }
  26811. }
  26812. // SetCreatedAt sets the "created_at" field.
  26813. func (m *UsageDetailMutation) SetCreatedAt(t time.Time) {
  26814. m.created_at = &t
  26815. }
  26816. // CreatedAt returns the value of the "created_at" field in the mutation.
  26817. func (m *UsageDetailMutation) CreatedAt() (r time.Time, exists bool) {
  26818. v := m.created_at
  26819. if v == nil {
  26820. return
  26821. }
  26822. return *v, true
  26823. }
  26824. // OldCreatedAt returns the old "created_at" field's value of the UsageDetail entity.
  26825. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  26826. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26827. func (m *UsageDetailMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  26828. if !m.op.Is(OpUpdateOne) {
  26829. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  26830. }
  26831. if m.id == nil || m.oldValue == nil {
  26832. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  26833. }
  26834. oldValue, err := m.oldValue(ctx)
  26835. if err != nil {
  26836. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  26837. }
  26838. return oldValue.CreatedAt, nil
  26839. }
  26840. // ResetCreatedAt resets all changes to the "created_at" field.
  26841. func (m *UsageDetailMutation) ResetCreatedAt() {
  26842. m.created_at = nil
  26843. }
  26844. // SetUpdatedAt sets the "updated_at" field.
  26845. func (m *UsageDetailMutation) SetUpdatedAt(t time.Time) {
  26846. m.updated_at = &t
  26847. }
  26848. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  26849. func (m *UsageDetailMutation) UpdatedAt() (r time.Time, exists bool) {
  26850. v := m.updated_at
  26851. if v == nil {
  26852. return
  26853. }
  26854. return *v, true
  26855. }
  26856. // OldUpdatedAt returns the old "updated_at" field's value of the UsageDetail entity.
  26857. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  26858. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26859. func (m *UsageDetailMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  26860. if !m.op.Is(OpUpdateOne) {
  26861. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  26862. }
  26863. if m.id == nil || m.oldValue == nil {
  26864. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  26865. }
  26866. oldValue, err := m.oldValue(ctx)
  26867. if err != nil {
  26868. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  26869. }
  26870. return oldValue.UpdatedAt, nil
  26871. }
  26872. // ResetUpdatedAt resets all changes to the "updated_at" field.
  26873. func (m *UsageDetailMutation) ResetUpdatedAt() {
  26874. m.updated_at = nil
  26875. }
  26876. // SetStatus sets the "status" field.
  26877. func (m *UsageDetailMutation) SetStatus(u uint8) {
  26878. m.status = &u
  26879. m.addstatus = nil
  26880. }
  26881. // Status returns the value of the "status" field in the mutation.
  26882. func (m *UsageDetailMutation) Status() (r uint8, exists bool) {
  26883. v := m.status
  26884. if v == nil {
  26885. return
  26886. }
  26887. return *v, true
  26888. }
  26889. // OldStatus returns the old "status" field's value of the UsageDetail entity.
  26890. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  26891. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26892. func (m *UsageDetailMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  26893. if !m.op.Is(OpUpdateOne) {
  26894. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  26895. }
  26896. if m.id == nil || m.oldValue == nil {
  26897. return v, errors.New("OldStatus requires an ID field in the mutation")
  26898. }
  26899. oldValue, err := m.oldValue(ctx)
  26900. if err != nil {
  26901. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  26902. }
  26903. return oldValue.Status, nil
  26904. }
  26905. // AddStatus adds u to the "status" field.
  26906. func (m *UsageDetailMutation) AddStatus(u int8) {
  26907. if m.addstatus != nil {
  26908. *m.addstatus += u
  26909. } else {
  26910. m.addstatus = &u
  26911. }
  26912. }
  26913. // AddedStatus returns the value that was added to the "status" field in this mutation.
  26914. func (m *UsageDetailMutation) AddedStatus() (r int8, exists bool) {
  26915. v := m.addstatus
  26916. if v == nil {
  26917. return
  26918. }
  26919. return *v, true
  26920. }
  26921. // ClearStatus clears the value of the "status" field.
  26922. func (m *UsageDetailMutation) ClearStatus() {
  26923. m.status = nil
  26924. m.addstatus = nil
  26925. m.clearedFields[usagedetail.FieldStatus] = struct{}{}
  26926. }
  26927. // StatusCleared returns if the "status" field was cleared in this mutation.
  26928. func (m *UsageDetailMutation) StatusCleared() bool {
  26929. _, ok := m.clearedFields[usagedetail.FieldStatus]
  26930. return ok
  26931. }
  26932. // ResetStatus resets all changes to the "status" field.
  26933. func (m *UsageDetailMutation) ResetStatus() {
  26934. m.status = nil
  26935. m.addstatus = nil
  26936. delete(m.clearedFields, usagedetail.FieldStatus)
  26937. }
  26938. // SetType sets the "type" field.
  26939. func (m *UsageDetailMutation) SetType(i int) {
  26940. m._type = &i
  26941. m.add_type = nil
  26942. }
  26943. // GetType returns the value of the "type" field in the mutation.
  26944. func (m *UsageDetailMutation) GetType() (r int, exists bool) {
  26945. v := m._type
  26946. if v == nil {
  26947. return
  26948. }
  26949. return *v, true
  26950. }
  26951. // OldType returns the old "type" field's value of the UsageDetail entity.
  26952. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  26953. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26954. func (m *UsageDetailMutation) OldType(ctx context.Context) (v int, err error) {
  26955. if !m.op.Is(OpUpdateOne) {
  26956. return v, errors.New("OldType is only allowed on UpdateOne operations")
  26957. }
  26958. if m.id == nil || m.oldValue == nil {
  26959. return v, errors.New("OldType requires an ID field in the mutation")
  26960. }
  26961. oldValue, err := m.oldValue(ctx)
  26962. if err != nil {
  26963. return v, fmt.Errorf("querying old value for OldType: %w", err)
  26964. }
  26965. return oldValue.Type, nil
  26966. }
  26967. // AddType adds i to the "type" field.
  26968. func (m *UsageDetailMutation) AddType(i int) {
  26969. if m.add_type != nil {
  26970. *m.add_type += i
  26971. } else {
  26972. m.add_type = &i
  26973. }
  26974. }
  26975. // AddedType returns the value that was added to the "type" field in this mutation.
  26976. func (m *UsageDetailMutation) AddedType() (r int, exists bool) {
  26977. v := m.add_type
  26978. if v == nil {
  26979. return
  26980. }
  26981. return *v, true
  26982. }
  26983. // ClearType clears the value of the "type" field.
  26984. func (m *UsageDetailMutation) ClearType() {
  26985. m._type = nil
  26986. m.add_type = nil
  26987. m.clearedFields[usagedetail.FieldType] = struct{}{}
  26988. }
  26989. // TypeCleared returns if the "type" field was cleared in this mutation.
  26990. func (m *UsageDetailMutation) TypeCleared() bool {
  26991. _, ok := m.clearedFields[usagedetail.FieldType]
  26992. return ok
  26993. }
  26994. // ResetType resets all changes to the "type" field.
  26995. func (m *UsageDetailMutation) ResetType() {
  26996. m._type = nil
  26997. m.add_type = nil
  26998. delete(m.clearedFields, usagedetail.FieldType)
  26999. }
  27000. // SetBotID sets the "bot_id" field.
  27001. func (m *UsageDetailMutation) SetBotID(s string) {
  27002. m.bot_id = &s
  27003. }
  27004. // BotID returns the value of the "bot_id" field in the mutation.
  27005. func (m *UsageDetailMutation) BotID() (r string, exists bool) {
  27006. v := m.bot_id
  27007. if v == nil {
  27008. return
  27009. }
  27010. return *v, true
  27011. }
  27012. // OldBotID returns the old "bot_id" field's value of the UsageDetail entity.
  27013. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27014. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27015. func (m *UsageDetailMutation) OldBotID(ctx context.Context) (v string, err error) {
  27016. if !m.op.Is(OpUpdateOne) {
  27017. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  27018. }
  27019. if m.id == nil || m.oldValue == nil {
  27020. return v, errors.New("OldBotID requires an ID field in the mutation")
  27021. }
  27022. oldValue, err := m.oldValue(ctx)
  27023. if err != nil {
  27024. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  27025. }
  27026. return oldValue.BotID, nil
  27027. }
  27028. // ResetBotID resets all changes to the "bot_id" field.
  27029. func (m *UsageDetailMutation) ResetBotID() {
  27030. m.bot_id = nil
  27031. }
  27032. // SetReceiverID sets the "receiver_id" field.
  27033. func (m *UsageDetailMutation) SetReceiverID(s string) {
  27034. m.receiver_id = &s
  27035. }
  27036. // ReceiverID returns the value of the "receiver_id" field in the mutation.
  27037. func (m *UsageDetailMutation) ReceiverID() (r string, exists bool) {
  27038. v := m.receiver_id
  27039. if v == nil {
  27040. return
  27041. }
  27042. return *v, true
  27043. }
  27044. // OldReceiverID returns the old "receiver_id" field's value of the UsageDetail entity.
  27045. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27046. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27047. func (m *UsageDetailMutation) OldReceiverID(ctx context.Context) (v string, err error) {
  27048. if !m.op.Is(OpUpdateOne) {
  27049. return v, errors.New("OldReceiverID is only allowed on UpdateOne operations")
  27050. }
  27051. if m.id == nil || m.oldValue == nil {
  27052. return v, errors.New("OldReceiverID requires an ID field in the mutation")
  27053. }
  27054. oldValue, err := m.oldValue(ctx)
  27055. if err != nil {
  27056. return v, fmt.Errorf("querying old value for OldReceiverID: %w", err)
  27057. }
  27058. return oldValue.ReceiverID, nil
  27059. }
  27060. // ResetReceiverID resets all changes to the "receiver_id" field.
  27061. func (m *UsageDetailMutation) ResetReceiverID() {
  27062. m.receiver_id = nil
  27063. }
  27064. // SetApp sets the "app" field.
  27065. func (m *UsageDetailMutation) SetApp(i int) {
  27066. m.app = &i
  27067. m.addapp = nil
  27068. }
  27069. // App returns the value of the "app" field in the mutation.
  27070. func (m *UsageDetailMutation) App() (r int, exists bool) {
  27071. v := m.app
  27072. if v == nil {
  27073. return
  27074. }
  27075. return *v, true
  27076. }
  27077. // OldApp returns the old "app" field's value of the UsageDetail entity.
  27078. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27079. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27080. func (m *UsageDetailMutation) OldApp(ctx context.Context) (v int, err error) {
  27081. if !m.op.Is(OpUpdateOne) {
  27082. return v, errors.New("OldApp is only allowed on UpdateOne operations")
  27083. }
  27084. if m.id == nil || m.oldValue == nil {
  27085. return v, errors.New("OldApp requires an ID field in the mutation")
  27086. }
  27087. oldValue, err := m.oldValue(ctx)
  27088. if err != nil {
  27089. return v, fmt.Errorf("querying old value for OldApp: %w", err)
  27090. }
  27091. return oldValue.App, nil
  27092. }
  27093. // AddApp adds i to the "app" field.
  27094. func (m *UsageDetailMutation) AddApp(i int) {
  27095. if m.addapp != nil {
  27096. *m.addapp += i
  27097. } else {
  27098. m.addapp = &i
  27099. }
  27100. }
  27101. // AddedApp returns the value that was added to the "app" field in this mutation.
  27102. func (m *UsageDetailMutation) AddedApp() (r int, exists bool) {
  27103. v := m.addapp
  27104. if v == nil {
  27105. return
  27106. }
  27107. return *v, true
  27108. }
  27109. // ClearApp clears the value of the "app" field.
  27110. func (m *UsageDetailMutation) ClearApp() {
  27111. m.app = nil
  27112. m.addapp = nil
  27113. m.clearedFields[usagedetail.FieldApp] = struct{}{}
  27114. }
  27115. // AppCleared returns if the "app" field was cleared in this mutation.
  27116. func (m *UsageDetailMutation) AppCleared() bool {
  27117. _, ok := m.clearedFields[usagedetail.FieldApp]
  27118. return ok
  27119. }
  27120. // ResetApp resets all changes to the "app" field.
  27121. func (m *UsageDetailMutation) ResetApp() {
  27122. m.app = nil
  27123. m.addapp = nil
  27124. delete(m.clearedFields, usagedetail.FieldApp)
  27125. }
  27126. // SetSessionID sets the "session_id" field.
  27127. func (m *UsageDetailMutation) SetSessionID(u uint64) {
  27128. m.session_id = &u
  27129. m.addsession_id = nil
  27130. }
  27131. // SessionID returns the value of the "session_id" field in the mutation.
  27132. func (m *UsageDetailMutation) SessionID() (r uint64, exists bool) {
  27133. v := m.session_id
  27134. if v == nil {
  27135. return
  27136. }
  27137. return *v, true
  27138. }
  27139. // OldSessionID returns the old "session_id" field's value of the UsageDetail entity.
  27140. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27141. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27142. func (m *UsageDetailMutation) OldSessionID(ctx context.Context) (v uint64, err error) {
  27143. if !m.op.Is(OpUpdateOne) {
  27144. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  27145. }
  27146. if m.id == nil || m.oldValue == nil {
  27147. return v, errors.New("OldSessionID requires an ID field in the mutation")
  27148. }
  27149. oldValue, err := m.oldValue(ctx)
  27150. if err != nil {
  27151. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  27152. }
  27153. return oldValue.SessionID, nil
  27154. }
  27155. // AddSessionID adds u to the "session_id" field.
  27156. func (m *UsageDetailMutation) AddSessionID(u int64) {
  27157. if m.addsession_id != nil {
  27158. *m.addsession_id += u
  27159. } else {
  27160. m.addsession_id = &u
  27161. }
  27162. }
  27163. // AddedSessionID returns the value that was added to the "session_id" field in this mutation.
  27164. func (m *UsageDetailMutation) AddedSessionID() (r int64, exists bool) {
  27165. v := m.addsession_id
  27166. if v == nil {
  27167. return
  27168. }
  27169. return *v, true
  27170. }
  27171. // ClearSessionID clears the value of the "session_id" field.
  27172. func (m *UsageDetailMutation) ClearSessionID() {
  27173. m.session_id = nil
  27174. m.addsession_id = nil
  27175. m.clearedFields[usagedetail.FieldSessionID] = struct{}{}
  27176. }
  27177. // SessionIDCleared returns if the "session_id" field was cleared in this mutation.
  27178. func (m *UsageDetailMutation) SessionIDCleared() bool {
  27179. _, ok := m.clearedFields[usagedetail.FieldSessionID]
  27180. return ok
  27181. }
  27182. // ResetSessionID resets all changes to the "session_id" field.
  27183. func (m *UsageDetailMutation) ResetSessionID() {
  27184. m.session_id = nil
  27185. m.addsession_id = nil
  27186. delete(m.clearedFields, usagedetail.FieldSessionID)
  27187. }
  27188. // SetRequest sets the "request" field.
  27189. func (m *UsageDetailMutation) SetRequest(s string) {
  27190. m.request = &s
  27191. }
  27192. // Request returns the value of the "request" field in the mutation.
  27193. func (m *UsageDetailMutation) Request() (r string, exists bool) {
  27194. v := m.request
  27195. if v == nil {
  27196. return
  27197. }
  27198. return *v, true
  27199. }
  27200. // OldRequest returns the old "request" field's value of the UsageDetail entity.
  27201. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27202. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27203. func (m *UsageDetailMutation) OldRequest(ctx context.Context) (v string, err error) {
  27204. if !m.op.Is(OpUpdateOne) {
  27205. return v, errors.New("OldRequest is only allowed on UpdateOne operations")
  27206. }
  27207. if m.id == nil || m.oldValue == nil {
  27208. return v, errors.New("OldRequest requires an ID field in the mutation")
  27209. }
  27210. oldValue, err := m.oldValue(ctx)
  27211. if err != nil {
  27212. return v, fmt.Errorf("querying old value for OldRequest: %w", err)
  27213. }
  27214. return oldValue.Request, nil
  27215. }
  27216. // ResetRequest resets all changes to the "request" field.
  27217. func (m *UsageDetailMutation) ResetRequest() {
  27218. m.request = nil
  27219. }
  27220. // SetResponse sets the "response" field.
  27221. func (m *UsageDetailMutation) SetResponse(s string) {
  27222. m.response = &s
  27223. }
  27224. // Response returns the value of the "response" field in the mutation.
  27225. func (m *UsageDetailMutation) Response() (r string, exists bool) {
  27226. v := m.response
  27227. if v == nil {
  27228. return
  27229. }
  27230. return *v, true
  27231. }
  27232. // OldResponse returns the old "response" field's value of the UsageDetail entity.
  27233. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27234. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27235. func (m *UsageDetailMutation) OldResponse(ctx context.Context) (v string, err error) {
  27236. if !m.op.Is(OpUpdateOne) {
  27237. return v, errors.New("OldResponse is only allowed on UpdateOne operations")
  27238. }
  27239. if m.id == nil || m.oldValue == nil {
  27240. return v, errors.New("OldResponse requires an ID field in the mutation")
  27241. }
  27242. oldValue, err := m.oldValue(ctx)
  27243. if err != nil {
  27244. return v, fmt.Errorf("querying old value for OldResponse: %w", err)
  27245. }
  27246. return oldValue.Response, nil
  27247. }
  27248. // ResetResponse resets all changes to the "response" field.
  27249. func (m *UsageDetailMutation) ResetResponse() {
  27250. m.response = nil
  27251. }
  27252. // SetOriginalData sets the "original_data" field.
  27253. func (m *UsageDetailMutation) SetOriginalData(ctd custom_types.OriginalData) {
  27254. m.original_data = &ctd
  27255. }
  27256. // OriginalData returns the value of the "original_data" field in the mutation.
  27257. func (m *UsageDetailMutation) OriginalData() (r custom_types.OriginalData, exists bool) {
  27258. v := m.original_data
  27259. if v == nil {
  27260. return
  27261. }
  27262. return *v, true
  27263. }
  27264. // OldOriginalData returns the old "original_data" field's value of the UsageDetail entity.
  27265. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27266. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27267. func (m *UsageDetailMutation) OldOriginalData(ctx context.Context) (v custom_types.OriginalData, err error) {
  27268. if !m.op.Is(OpUpdateOne) {
  27269. return v, errors.New("OldOriginalData is only allowed on UpdateOne operations")
  27270. }
  27271. if m.id == nil || m.oldValue == nil {
  27272. return v, errors.New("OldOriginalData requires an ID field in the mutation")
  27273. }
  27274. oldValue, err := m.oldValue(ctx)
  27275. if err != nil {
  27276. return v, fmt.Errorf("querying old value for OldOriginalData: %w", err)
  27277. }
  27278. return oldValue.OriginalData, nil
  27279. }
  27280. // ResetOriginalData resets all changes to the "original_data" field.
  27281. func (m *UsageDetailMutation) ResetOriginalData() {
  27282. m.original_data = nil
  27283. }
  27284. // SetTotalTokens sets the "total_tokens" field.
  27285. func (m *UsageDetailMutation) SetTotalTokens(u uint64) {
  27286. m.total_tokens = &u
  27287. m.addtotal_tokens = nil
  27288. }
  27289. // TotalTokens returns the value of the "total_tokens" field in the mutation.
  27290. func (m *UsageDetailMutation) TotalTokens() (r uint64, exists bool) {
  27291. v := m.total_tokens
  27292. if v == nil {
  27293. return
  27294. }
  27295. return *v, true
  27296. }
  27297. // OldTotalTokens returns the old "total_tokens" field's value of the UsageDetail entity.
  27298. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27299. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27300. func (m *UsageDetailMutation) OldTotalTokens(ctx context.Context) (v uint64, err error) {
  27301. if !m.op.Is(OpUpdateOne) {
  27302. return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
  27303. }
  27304. if m.id == nil || m.oldValue == nil {
  27305. return v, errors.New("OldTotalTokens requires an ID field in the mutation")
  27306. }
  27307. oldValue, err := m.oldValue(ctx)
  27308. if err != nil {
  27309. return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
  27310. }
  27311. return oldValue.TotalTokens, nil
  27312. }
  27313. // AddTotalTokens adds u to the "total_tokens" field.
  27314. func (m *UsageDetailMutation) AddTotalTokens(u int64) {
  27315. if m.addtotal_tokens != nil {
  27316. *m.addtotal_tokens += u
  27317. } else {
  27318. m.addtotal_tokens = &u
  27319. }
  27320. }
  27321. // AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
  27322. func (m *UsageDetailMutation) AddedTotalTokens() (r int64, exists bool) {
  27323. v := m.addtotal_tokens
  27324. if v == nil {
  27325. return
  27326. }
  27327. return *v, true
  27328. }
  27329. // ClearTotalTokens clears the value of the "total_tokens" field.
  27330. func (m *UsageDetailMutation) ClearTotalTokens() {
  27331. m.total_tokens = nil
  27332. m.addtotal_tokens = nil
  27333. m.clearedFields[usagedetail.FieldTotalTokens] = struct{}{}
  27334. }
  27335. // TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
  27336. func (m *UsageDetailMutation) TotalTokensCleared() bool {
  27337. _, ok := m.clearedFields[usagedetail.FieldTotalTokens]
  27338. return ok
  27339. }
  27340. // ResetTotalTokens resets all changes to the "total_tokens" field.
  27341. func (m *UsageDetailMutation) ResetTotalTokens() {
  27342. m.total_tokens = nil
  27343. m.addtotal_tokens = nil
  27344. delete(m.clearedFields, usagedetail.FieldTotalTokens)
  27345. }
  27346. // SetPromptTokens sets the "prompt_tokens" field.
  27347. func (m *UsageDetailMutation) SetPromptTokens(u uint64) {
  27348. m.prompt_tokens = &u
  27349. m.addprompt_tokens = nil
  27350. }
  27351. // PromptTokens returns the value of the "prompt_tokens" field in the mutation.
  27352. func (m *UsageDetailMutation) PromptTokens() (r uint64, exists bool) {
  27353. v := m.prompt_tokens
  27354. if v == nil {
  27355. return
  27356. }
  27357. return *v, true
  27358. }
  27359. // OldPromptTokens returns the old "prompt_tokens" field's value of the UsageDetail entity.
  27360. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27361. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27362. func (m *UsageDetailMutation) OldPromptTokens(ctx context.Context) (v uint64, err error) {
  27363. if !m.op.Is(OpUpdateOne) {
  27364. return v, errors.New("OldPromptTokens is only allowed on UpdateOne operations")
  27365. }
  27366. if m.id == nil || m.oldValue == nil {
  27367. return v, errors.New("OldPromptTokens requires an ID field in the mutation")
  27368. }
  27369. oldValue, err := m.oldValue(ctx)
  27370. if err != nil {
  27371. return v, fmt.Errorf("querying old value for OldPromptTokens: %w", err)
  27372. }
  27373. return oldValue.PromptTokens, nil
  27374. }
  27375. // AddPromptTokens adds u to the "prompt_tokens" field.
  27376. func (m *UsageDetailMutation) AddPromptTokens(u int64) {
  27377. if m.addprompt_tokens != nil {
  27378. *m.addprompt_tokens += u
  27379. } else {
  27380. m.addprompt_tokens = &u
  27381. }
  27382. }
  27383. // AddedPromptTokens returns the value that was added to the "prompt_tokens" field in this mutation.
  27384. func (m *UsageDetailMutation) AddedPromptTokens() (r int64, exists bool) {
  27385. v := m.addprompt_tokens
  27386. if v == nil {
  27387. return
  27388. }
  27389. return *v, true
  27390. }
  27391. // ClearPromptTokens clears the value of the "prompt_tokens" field.
  27392. func (m *UsageDetailMutation) ClearPromptTokens() {
  27393. m.prompt_tokens = nil
  27394. m.addprompt_tokens = nil
  27395. m.clearedFields[usagedetail.FieldPromptTokens] = struct{}{}
  27396. }
  27397. // PromptTokensCleared returns if the "prompt_tokens" field was cleared in this mutation.
  27398. func (m *UsageDetailMutation) PromptTokensCleared() bool {
  27399. _, ok := m.clearedFields[usagedetail.FieldPromptTokens]
  27400. return ok
  27401. }
  27402. // ResetPromptTokens resets all changes to the "prompt_tokens" field.
  27403. func (m *UsageDetailMutation) ResetPromptTokens() {
  27404. m.prompt_tokens = nil
  27405. m.addprompt_tokens = nil
  27406. delete(m.clearedFields, usagedetail.FieldPromptTokens)
  27407. }
  27408. // SetCompletionTokens sets the "completion_tokens" field.
  27409. func (m *UsageDetailMutation) SetCompletionTokens(u uint64) {
  27410. m.completion_tokens = &u
  27411. m.addcompletion_tokens = nil
  27412. }
  27413. // CompletionTokens returns the value of the "completion_tokens" field in the mutation.
  27414. func (m *UsageDetailMutation) CompletionTokens() (r uint64, exists bool) {
  27415. v := m.completion_tokens
  27416. if v == nil {
  27417. return
  27418. }
  27419. return *v, true
  27420. }
  27421. // OldCompletionTokens returns the old "completion_tokens" field's value of the UsageDetail entity.
  27422. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27423. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27424. func (m *UsageDetailMutation) OldCompletionTokens(ctx context.Context) (v uint64, err error) {
  27425. if !m.op.Is(OpUpdateOne) {
  27426. return v, errors.New("OldCompletionTokens is only allowed on UpdateOne operations")
  27427. }
  27428. if m.id == nil || m.oldValue == nil {
  27429. return v, errors.New("OldCompletionTokens requires an ID field in the mutation")
  27430. }
  27431. oldValue, err := m.oldValue(ctx)
  27432. if err != nil {
  27433. return v, fmt.Errorf("querying old value for OldCompletionTokens: %w", err)
  27434. }
  27435. return oldValue.CompletionTokens, nil
  27436. }
  27437. // AddCompletionTokens adds u to the "completion_tokens" field.
  27438. func (m *UsageDetailMutation) AddCompletionTokens(u int64) {
  27439. if m.addcompletion_tokens != nil {
  27440. *m.addcompletion_tokens += u
  27441. } else {
  27442. m.addcompletion_tokens = &u
  27443. }
  27444. }
  27445. // AddedCompletionTokens returns the value that was added to the "completion_tokens" field in this mutation.
  27446. func (m *UsageDetailMutation) AddedCompletionTokens() (r int64, exists bool) {
  27447. v := m.addcompletion_tokens
  27448. if v == nil {
  27449. return
  27450. }
  27451. return *v, true
  27452. }
  27453. // ClearCompletionTokens clears the value of the "completion_tokens" field.
  27454. func (m *UsageDetailMutation) ClearCompletionTokens() {
  27455. m.completion_tokens = nil
  27456. m.addcompletion_tokens = nil
  27457. m.clearedFields[usagedetail.FieldCompletionTokens] = struct{}{}
  27458. }
  27459. // CompletionTokensCleared returns if the "completion_tokens" field was cleared in this mutation.
  27460. func (m *UsageDetailMutation) CompletionTokensCleared() bool {
  27461. _, ok := m.clearedFields[usagedetail.FieldCompletionTokens]
  27462. return ok
  27463. }
  27464. // ResetCompletionTokens resets all changes to the "completion_tokens" field.
  27465. func (m *UsageDetailMutation) ResetCompletionTokens() {
  27466. m.completion_tokens = nil
  27467. m.addcompletion_tokens = nil
  27468. delete(m.clearedFields, usagedetail.FieldCompletionTokens)
  27469. }
  27470. // SetOrganizationID sets the "organization_id" field.
  27471. func (m *UsageDetailMutation) SetOrganizationID(u uint64) {
  27472. m.organization_id = &u
  27473. m.addorganization_id = nil
  27474. }
  27475. // OrganizationID returns the value of the "organization_id" field in the mutation.
  27476. func (m *UsageDetailMutation) OrganizationID() (r uint64, exists bool) {
  27477. v := m.organization_id
  27478. if v == nil {
  27479. return
  27480. }
  27481. return *v, true
  27482. }
  27483. // OldOrganizationID returns the old "organization_id" field's value of the UsageDetail entity.
  27484. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27485. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27486. func (m *UsageDetailMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  27487. if !m.op.Is(OpUpdateOne) {
  27488. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  27489. }
  27490. if m.id == nil || m.oldValue == nil {
  27491. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  27492. }
  27493. oldValue, err := m.oldValue(ctx)
  27494. if err != nil {
  27495. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  27496. }
  27497. return oldValue.OrganizationID, nil
  27498. }
  27499. // AddOrganizationID adds u to the "organization_id" field.
  27500. func (m *UsageDetailMutation) AddOrganizationID(u int64) {
  27501. if m.addorganization_id != nil {
  27502. *m.addorganization_id += u
  27503. } else {
  27504. m.addorganization_id = &u
  27505. }
  27506. }
  27507. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  27508. func (m *UsageDetailMutation) AddedOrganizationID() (r int64, exists bool) {
  27509. v := m.addorganization_id
  27510. if v == nil {
  27511. return
  27512. }
  27513. return *v, true
  27514. }
  27515. // ClearOrganizationID clears the value of the "organization_id" field.
  27516. func (m *UsageDetailMutation) ClearOrganizationID() {
  27517. m.organization_id = nil
  27518. m.addorganization_id = nil
  27519. m.clearedFields[usagedetail.FieldOrganizationID] = struct{}{}
  27520. }
  27521. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  27522. func (m *UsageDetailMutation) OrganizationIDCleared() bool {
  27523. _, ok := m.clearedFields[usagedetail.FieldOrganizationID]
  27524. return ok
  27525. }
  27526. // ResetOrganizationID resets all changes to the "organization_id" field.
  27527. func (m *UsageDetailMutation) ResetOrganizationID() {
  27528. m.organization_id = nil
  27529. m.addorganization_id = nil
  27530. delete(m.clearedFields, usagedetail.FieldOrganizationID)
  27531. }
  27532. // Where appends a list predicates to the UsageDetailMutation builder.
  27533. func (m *UsageDetailMutation) Where(ps ...predicate.UsageDetail) {
  27534. m.predicates = append(m.predicates, ps...)
  27535. }
  27536. // WhereP appends storage-level predicates to the UsageDetailMutation builder. Using this method,
  27537. // users can use type-assertion to append predicates that do not depend on any generated package.
  27538. func (m *UsageDetailMutation) WhereP(ps ...func(*sql.Selector)) {
  27539. p := make([]predicate.UsageDetail, len(ps))
  27540. for i := range ps {
  27541. p[i] = ps[i]
  27542. }
  27543. m.Where(p...)
  27544. }
  27545. // Op returns the operation name.
  27546. func (m *UsageDetailMutation) Op() Op {
  27547. return m.op
  27548. }
  27549. // SetOp allows setting the mutation operation.
  27550. func (m *UsageDetailMutation) SetOp(op Op) {
  27551. m.op = op
  27552. }
  27553. // Type returns the node type of this mutation (UsageDetail).
  27554. func (m *UsageDetailMutation) Type() string {
  27555. return m.typ
  27556. }
  27557. // Fields returns all fields that were changed during this mutation. Note that in
  27558. // order to get all numeric fields that were incremented/decremented, call
  27559. // AddedFields().
  27560. func (m *UsageDetailMutation) Fields() []string {
  27561. fields := make([]string, 0, 15)
  27562. if m.created_at != nil {
  27563. fields = append(fields, usagedetail.FieldCreatedAt)
  27564. }
  27565. if m.updated_at != nil {
  27566. fields = append(fields, usagedetail.FieldUpdatedAt)
  27567. }
  27568. if m.status != nil {
  27569. fields = append(fields, usagedetail.FieldStatus)
  27570. }
  27571. if m._type != nil {
  27572. fields = append(fields, usagedetail.FieldType)
  27573. }
  27574. if m.bot_id != nil {
  27575. fields = append(fields, usagedetail.FieldBotID)
  27576. }
  27577. if m.receiver_id != nil {
  27578. fields = append(fields, usagedetail.FieldReceiverID)
  27579. }
  27580. if m.app != nil {
  27581. fields = append(fields, usagedetail.FieldApp)
  27582. }
  27583. if m.session_id != nil {
  27584. fields = append(fields, usagedetail.FieldSessionID)
  27585. }
  27586. if m.request != nil {
  27587. fields = append(fields, usagedetail.FieldRequest)
  27588. }
  27589. if m.response != nil {
  27590. fields = append(fields, usagedetail.FieldResponse)
  27591. }
  27592. if m.original_data != nil {
  27593. fields = append(fields, usagedetail.FieldOriginalData)
  27594. }
  27595. if m.total_tokens != nil {
  27596. fields = append(fields, usagedetail.FieldTotalTokens)
  27597. }
  27598. if m.prompt_tokens != nil {
  27599. fields = append(fields, usagedetail.FieldPromptTokens)
  27600. }
  27601. if m.completion_tokens != nil {
  27602. fields = append(fields, usagedetail.FieldCompletionTokens)
  27603. }
  27604. if m.organization_id != nil {
  27605. fields = append(fields, usagedetail.FieldOrganizationID)
  27606. }
  27607. return fields
  27608. }
  27609. // Field returns the value of a field with the given name. The second boolean
  27610. // return value indicates that this field was not set, or was not defined in the
  27611. // schema.
  27612. func (m *UsageDetailMutation) Field(name string) (ent.Value, bool) {
  27613. switch name {
  27614. case usagedetail.FieldCreatedAt:
  27615. return m.CreatedAt()
  27616. case usagedetail.FieldUpdatedAt:
  27617. return m.UpdatedAt()
  27618. case usagedetail.FieldStatus:
  27619. return m.Status()
  27620. case usagedetail.FieldType:
  27621. return m.GetType()
  27622. case usagedetail.FieldBotID:
  27623. return m.BotID()
  27624. case usagedetail.FieldReceiverID:
  27625. return m.ReceiverID()
  27626. case usagedetail.FieldApp:
  27627. return m.App()
  27628. case usagedetail.FieldSessionID:
  27629. return m.SessionID()
  27630. case usagedetail.FieldRequest:
  27631. return m.Request()
  27632. case usagedetail.FieldResponse:
  27633. return m.Response()
  27634. case usagedetail.FieldOriginalData:
  27635. return m.OriginalData()
  27636. case usagedetail.FieldTotalTokens:
  27637. return m.TotalTokens()
  27638. case usagedetail.FieldPromptTokens:
  27639. return m.PromptTokens()
  27640. case usagedetail.FieldCompletionTokens:
  27641. return m.CompletionTokens()
  27642. case usagedetail.FieldOrganizationID:
  27643. return m.OrganizationID()
  27644. }
  27645. return nil, false
  27646. }
  27647. // OldField returns the old value of the field from the database. An error is
  27648. // returned if the mutation operation is not UpdateOne, or the query to the
  27649. // database failed.
  27650. func (m *UsageDetailMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  27651. switch name {
  27652. case usagedetail.FieldCreatedAt:
  27653. return m.OldCreatedAt(ctx)
  27654. case usagedetail.FieldUpdatedAt:
  27655. return m.OldUpdatedAt(ctx)
  27656. case usagedetail.FieldStatus:
  27657. return m.OldStatus(ctx)
  27658. case usagedetail.FieldType:
  27659. return m.OldType(ctx)
  27660. case usagedetail.FieldBotID:
  27661. return m.OldBotID(ctx)
  27662. case usagedetail.FieldReceiverID:
  27663. return m.OldReceiverID(ctx)
  27664. case usagedetail.FieldApp:
  27665. return m.OldApp(ctx)
  27666. case usagedetail.FieldSessionID:
  27667. return m.OldSessionID(ctx)
  27668. case usagedetail.FieldRequest:
  27669. return m.OldRequest(ctx)
  27670. case usagedetail.FieldResponse:
  27671. return m.OldResponse(ctx)
  27672. case usagedetail.FieldOriginalData:
  27673. return m.OldOriginalData(ctx)
  27674. case usagedetail.FieldTotalTokens:
  27675. return m.OldTotalTokens(ctx)
  27676. case usagedetail.FieldPromptTokens:
  27677. return m.OldPromptTokens(ctx)
  27678. case usagedetail.FieldCompletionTokens:
  27679. return m.OldCompletionTokens(ctx)
  27680. case usagedetail.FieldOrganizationID:
  27681. return m.OldOrganizationID(ctx)
  27682. }
  27683. return nil, fmt.Errorf("unknown UsageDetail field %s", name)
  27684. }
  27685. // SetField sets the value of a field with the given name. It returns an error if
  27686. // the field is not defined in the schema, or if the type mismatched the field
  27687. // type.
  27688. func (m *UsageDetailMutation) SetField(name string, value ent.Value) error {
  27689. switch name {
  27690. case usagedetail.FieldCreatedAt:
  27691. v, ok := value.(time.Time)
  27692. if !ok {
  27693. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27694. }
  27695. m.SetCreatedAt(v)
  27696. return nil
  27697. case usagedetail.FieldUpdatedAt:
  27698. v, ok := value.(time.Time)
  27699. if !ok {
  27700. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27701. }
  27702. m.SetUpdatedAt(v)
  27703. return nil
  27704. case usagedetail.FieldStatus:
  27705. v, ok := value.(uint8)
  27706. if !ok {
  27707. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27708. }
  27709. m.SetStatus(v)
  27710. return nil
  27711. case usagedetail.FieldType:
  27712. v, ok := value.(int)
  27713. if !ok {
  27714. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27715. }
  27716. m.SetType(v)
  27717. return nil
  27718. case usagedetail.FieldBotID:
  27719. v, ok := value.(string)
  27720. if !ok {
  27721. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27722. }
  27723. m.SetBotID(v)
  27724. return nil
  27725. case usagedetail.FieldReceiverID:
  27726. v, ok := value.(string)
  27727. if !ok {
  27728. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27729. }
  27730. m.SetReceiverID(v)
  27731. return nil
  27732. case usagedetail.FieldApp:
  27733. v, ok := value.(int)
  27734. if !ok {
  27735. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27736. }
  27737. m.SetApp(v)
  27738. return nil
  27739. case usagedetail.FieldSessionID:
  27740. v, ok := value.(uint64)
  27741. if !ok {
  27742. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27743. }
  27744. m.SetSessionID(v)
  27745. return nil
  27746. case usagedetail.FieldRequest:
  27747. v, ok := value.(string)
  27748. if !ok {
  27749. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27750. }
  27751. m.SetRequest(v)
  27752. return nil
  27753. case usagedetail.FieldResponse:
  27754. v, ok := value.(string)
  27755. if !ok {
  27756. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27757. }
  27758. m.SetResponse(v)
  27759. return nil
  27760. case usagedetail.FieldOriginalData:
  27761. v, ok := value.(custom_types.OriginalData)
  27762. if !ok {
  27763. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27764. }
  27765. m.SetOriginalData(v)
  27766. return nil
  27767. case usagedetail.FieldTotalTokens:
  27768. v, ok := value.(uint64)
  27769. if !ok {
  27770. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27771. }
  27772. m.SetTotalTokens(v)
  27773. return nil
  27774. case usagedetail.FieldPromptTokens:
  27775. v, ok := value.(uint64)
  27776. if !ok {
  27777. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27778. }
  27779. m.SetPromptTokens(v)
  27780. return nil
  27781. case usagedetail.FieldCompletionTokens:
  27782. v, ok := value.(uint64)
  27783. if !ok {
  27784. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27785. }
  27786. m.SetCompletionTokens(v)
  27787. return nil
  27788. case usagedetail.FieldOrganizationID:
  27789. v, ok := value.(uint64)
  27790. if !ok {
  27791. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27792. }
  27793. m.SetOrganizationID(v)
  27794. return nil
  27795. }
  27796. return fmt.Errorf("unknown UsageDetail field %s", name)
  27797. }
  27798. // AddedFields returns all numeric fields that were incremented/decremented during
  27799. // this mutation.
  27800. func (m *UsageDetailMutation) AddedFields() []string {
  27801. var fields []string
  27802. if m.addstatus != nil {
  27803. fields = append(fields, usagedetail.FieldStatus)
  27804. }
  27805. if m.add_type != nil {
  27806. fields = append(fields, usagedetail.FieldType)
  27807. }
  27808. if m.addapp != nil {
  27809. fields = append(fields, usagedetail.FieldApp)
  27810. }
  27811. if m.addsession_id != nil {
  27812. fields = append(fields, usagedetail.FieldSessionID)
  27813. }
  27814. if m.addtotal_tokens != nil {
  27815. fields = append(fields, usagedetail.FieldTotalTokens)
  27816. }
  27817. if m.addprompt_tokens != nil {
  27818. fields = append(fields, usagedetail.FieldPromptTokens)
  27819. }
  27820. if m.addcompletion_tokens != nil {
  27821. fields = append(fields, usagedetail.FieldCompletionTokens)
  27822. }
  27823. if m.addorganization_id != nil {
  27824. fields = append(fields, usagedetail.FieldOrganizationID)
  27825. }
  27826. return fields
  27827. }
  27828. // AddedField returns the numeric value that was incremented/decremented on a field
  27829. // with the given name. The second boolean return value indicates that this field
  27830. // was not set, or was not defined in the schema.
  27831. func (m *UsageDetailMutation) AddedField(name string) (ent.Value, bool) {
  27832. switch name {
  27833. case usagedetail.FieldStatus:
  27834. return m.AddedStatus()
  27835. case usagedetail.FieldType:
  27836. return m.AddedType()
  27837. case usagedetail.FieldApp:
  27838. return m.AddedApp()
  27839. case usagedetail.FieldSessionID:
  27840. return m.AddedSessionID()
  27841. case usagedetail.FieldTotalTokens:
  27842. return m.AddedTotalTokens()
  27843. case usagedetail.FieldPromptTokens:
  27844. return m.AddedPromptTokens()
  27845. case usagedetail.FieldCompletionTokens:
  27846. return m.AddedCompletionTokens()
  27847. case usagedetail.FieldOrganizationID:
  27848. return m.AddedOrganizationID()
  27849. }
  27850. return nil, false
  27851. }
  27852. // AddField adds the value to the field with the given name. It returns an error if
  27853. // the field is not defined in the schema, or if the type mismatched the field
  27854. // type.
  27855. func (m *UsageDetailMutation) AddField(name string, value ent.Value) error {
  27856. switch name {
  27857. case usagedetail.FieldStatus:
  27858. v, ok := value.(int8)
  27859. if !ok {
  27860. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27861. }
  27862. m.AddStatus(v)
  27863. return nil
  27864. case usagedetail.FieldType:
  27865. v, ok := value.(int)
  27866. if !ok {
  27867. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27868. }
  27869. m.AddType(v)
  27870. return nil
  27871. case usagedetail.FieldApp:
  27872. v, ok := value.(int)
  27873. if !ok {
  27874. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27875. }
  27876. m.AddApp(v)
  27877. return nil
  27878. case usagedetail.FieldSessionID:
  27879. v, ok := value.(int64)
  27880. if !ok {
  27881. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27882. }
  27883. m.AddSessionID(v)
  27884. return nil
  27885. case usagedetail.FieldTotalTokens:
  27886. v, ok := value.(int64)
  27887. if !ok {
  27888. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27889. }
  27890. m.AddTotalTokens(v)
  27891. return nil
  27892. case usagedetail.FieldPromptTokens:
  27893. v, ok := value.(int64)
  27894. if !ok {
  27895. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27896. }
  27897. m.AddPromptTokens(v)
  27898. return nil
  27899. case usagedetail.FieldCompletionTokens:
  27900. v, ok := value.(int64)
  27901. if !ok {
  27902. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27903. }
  27904. m.AddCompletionTokens(v)
  27905. return nil
  27906. case usagedetail.FieldOrganizationID:
  27907. v, ok := value.(int64)
  27908. if !ok {
  27909. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27910. }
  27911. m.AddOrganizationID(v)
  27912. return nil
  27913. }
  27914. return fmt.Errorf("unknown UsageDetail numeric field %s", name)
  27915. }
  27916. // ClearedFields returns all nullable fields that were cleared during this
  27917. // mutation.
  27918. func (m *UsageDetailMutation) ClearedFields() []string {
  27919. var fields []string
  27920. if m.FieldCleared(usagedetail.FieldStatus) {
  27921. fields = append(fields, usagedetail.FieldStatus)
  27922. }
  27923. if m.FieldCleared(usagedetail.FieldType) {
  27924. fields = append(fields, usagedetail.FieldType)
  27925. }
  27926. if m.FieldCleared(usagedetail.FieldApp) {
  27927. fields = append(fields, usagedetail.FieldApp)
  27928. }
  27929. if m.FieldCleared(usagedetail.FieldSessionID) {
  27930. fields = append(fields, usagedetail.FieldSessionID)
  27931. }
  27932. if m.FieldCleared(usagedetail.FieldTotalTokens) {
  27933. fields = append(fields, usagedetail.FieldTotalTokens)
  27934. }
  27935. if m.FieldCleared(usagedetail.FieldPromptTokens) {
  27936. fields = append(fields, usagedetail.FieldPromptTokens)
  27937. }
  27938. if m.FieldCleared(usagedetail.FieldCompletionTokens) {
  27939. fields = append(fields, usagedetail.FieldCompletionTokens)
  27940. }
  27941. if m.FieldCleared(usagedetail.FieldOrganizationID) {
  27942. fields = append(fields, usagedetail.FieldOrganizationID)
  27943. }
  27944. return fields
  27945. }
  27946. // FieldCleared returns a boolean indicating if a field with the given name was
  27947. // cleared in this mutation.
  27948. func (m *UsageDetailMutation) FieldCleared(name string) bool {
  27949. _, ok := m.clearedFields[name]
  27950. return ok
  27951. }
  27952. // ClearField clears the value of the field with the given name. It returns an
  27953. // error if the field is not defined in the schema.
  27954. func (m *UsageDetailMutation) ClearField(name string) error {
  27955. switch name {
  27956. case usagedetail.FieldStatus:
  27957. m.ClearStatus()
  27958. return nil
  27959. case usagedetail.FieldType:
  27960. m.ClearType()
  27961. return nil
  27962. case usagedetail.FieldApp:
  27963. m.ClearApp()
  27964. return nil
  27965. case usagedetail.FieldSessionID:
  27966. m.ClearSessionID()
  27967. return nil
  27968. case usagedetail.FieldTotalTokens:
  27969. m.ClearTotalTokens()
  27970. return nil
  27971. case usagedetail.FieldPromptTokens:
  27972. m.ClearPromptTokens()
  27973. return nil
  27974. case usagedetail.FieldCompletionTokens:
  27975. m.ClearCompletionTokens()
  27976. return nil
  27977. case usagedetail.FieldOrganizationID:
  27978. m.ClearOrganizationID()
  27979. return nil
  27980. }
  27981. return fmt.Errorf("unknown UsageDetail nullable field %s", name)
  27982. }
  27983. // ResetField resets all changes in the mutation for the field with the given name.
  27984. // It returns an error if the field is not defined in the schema.
  27985. func (m *UsageDetailMutation) ResetField(name string) error {
  27986. switch name {
  27987. case usagedetail.FieldCreatedAt:
  27988. m.ResetCreatedAt()
  27989. return nil
  27990. case usagedetail.FieldUpdatedAt:
  27991. m.ResetUpdatedAt()
  27992. return nil
  27993. case usagedetail.FieldStatus:
  27994. m.ResetStatus()
  27995. return nil
  27996. case usagedetail.FieldType:
  27997. m.ResetType()
  27998. return nil
  27999. case usagedetail.FieldBotID:
  28000. m.ResetBotID()
  28001. return nil
  28002. case usagedetail.FieldReceiverID:
  28003. m.ResetReceiverID()
  28004. return nil
  28005. case usagedetail.FieldApp:
  28006. m.ResetApp()
  28007. return nil
  28008. case usagedetail.FieldSessionID:
  28009. m.ResetSessionID()
  28010. return nil
  28011. case usagedetail.FieldRequest:
  28012. m.ResetRequest()
  28013. return nil
  28014. case usagedetail.FieldResponse:
  28015. m.ResetResponse()
  28016. return nil
  28017. case usagedetail.FieldOriginalData:
  28018. m.ResetOriginalData()
  28019. return nil
  28020. case usagedetail.FieldTotalTokens:
  28021. m.ResetTotalTokens()
  28022. return nil
  28023. case usagedetail.FieldPromptTokens:
  28024. m.ResetPromptTokens()
  28025. return nil
  28026. case usagedetail.FieldCompletionTokens:
  28027. m.ResetCompletionTokens()
  28028. return nil
  28029. case usagedetail.FieldOrganizationID:
  28030. m.ResetOrganizationID()
  28031. return nil
  28032. }
  28033. return fmt.Errorf("unknown UsageDetail field %s", name)
  28034. }
  28035. // AddedEdges returns all edge names that were set/added in this mutation.
  28036. func (m *UsageDetailMutation) AddedEdges() []string {
  28037. edges := make([]string, 0, 0)
  28038. return edges
  28039. }
  28040. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  28041. // name in this mutation.
  28042. func (m *UsageDetailMutation) AddedIDs(name string) []ent.Value {
  28043. return nil
  28044. }
  28045. // RemovedEdges returns all edge names that were removed in this mutation.
  28046. func (m *UsageDetailMutation) RemovedEdges() []string {
  28047. edges := make([]string, 0, 0)
  28048. return edges
  28049. }
  28050. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  28051. // the given name in this mutation.
  28052. func (m *UsageDetailMutation) RemovedIDs(name string) []ent.Value {
  28053. return nil
  28054. }
  28055. // ClearedEdges returns all edge names that were cleared in this mutation.
  28056. func (m *UsageDetailMutation) ClearedEdges() []string {
  28057. edges := make([]string, 0, 0)
  28058. return edges
  28059. }
  28060. // EdgeCleared returns a boolean which indicates if the edge with the given name
  28061. // was cleared in this mutation.
  28062. func (m *UsageDetailMutation) EdgeCleared(name string) bool {
  28063. return false
  28064. }
  28065. // ClearEdge clears the value of the edge with the given name. It returns an error
  28066. // if that edge is not defined in the schema.
  28067. func (m *UsageDetailMutation) ClearEdge(name string) error {
  28068. return fmt.Errorf("unknown UsageDetail unique edge %s", name)
  28069. }
  28070. // ResetEdge resets all changes to the edge with the given name in this mutation.
  28071. // It returns an error if the edge is not defined in the schema.
  28072. func (m *UsageDetailMutation) ResetEdge(name string) error {
  28073. return fmt.Errorf("unknown UsageDetail edge %s", name)
  28074. }
  28075. // UsageStatisticDayMutation represents an operation that mutates the UsageStatisticDay nodes in the graph.
  28076. type UsageStatisticDayMutation struct {
  28077. config
  28078. op Op
  28079. typ string
  28080. id *uint64
  28081. created_at *time.Time
  28082. updated_at *time.Time
  28083. status *uint8
  28084. addstatus *int8
  28085. deleted_at *time.Time
  28086. addtime *uint64
  28087. addaddtime *int64
  28088. _type *int
  28089. add_type *int
  28090. bot_id *string
  28091. organization_id *uint64
  28092. addorganization_id *int64
  28093. ai_response *uint64
  28094. addai_response *int64
  28095. sop_run *uint64
  28096. addsop_run *int64
  28097. total_friend *uint64
  28098. addtotal_friend *int64
  28099. total_group *uint64
  28100. addtotal_group *int64
  28101. account_balance *uint64
  28102. addaccount_balance *int64
  28103. consume_token *uint64
  28104. addconsume_token *int64
  28105. active_user *uint64
  28106. addactive_user *int64
  28107. new_user *int64
  28108. addnew_user *int64
  28109. label_dist *[]custom_types.LabelDist
  28110. appendlabel_dist []custom_types.LabelDist
  28111. clearedFields map[string]struct{}
  28112. done bool
  28113. oldValue func(context.Context) (*UsageStatisticDay, error)
  28114. predicates []predicate.UsageStatisticDay
  28115. }
  28116. var _ ent.Mutation = (*UsageStatisticDayMutation)(nil)
  28117. // usagestatisticdayOption allows management of the mutation configuration using functional options.
  28118. type usagestatisticdayOption func(*UsageStatisticDayMutation)
  28119. // newUsageStatisticDayMutation creates new mutation for the UsageStatisticDay entity.
  28120. func newUsageStatisticDayMutation(c config, op Op, opts ...usagestatisticdayOption) *UsageStatisticDayMutation {
  28121. m := &UsageStatisticDayMutation{
  28122. config: c,
  28123. op: op,
  28124. typ: TypeUsageStatisticDay,
  28125. clearedFields: make(map[string]struct{}),
  28126. }
  28127. for _, opt := range opts {
  28128. opt(m)
  28129. }
  28130. return m
  28131. }
  28132. // withUsageStatisticDayID sets the ID field of the mutation.
  28133. func withUsageStatisticDayID(id uint64) usagestatisticdayOption {
  28134. return func(m *UsageStatisticDayMutation) {
  28135. var (
  28136. err error
  28137. once sync.Once
  28138. value *UsageStatisticDay
  28139. )
  28140. m.oldValue = func(ctx context.Context) (*UsageStatisticDay, error) {
  28141. once.Do(func() {
  28142. if m.done {
  28143. err = errors.New("querying old values post mutation is not allowed")
  28144. } else {
  28145. value, err = m.Client().UsageStatisticDay.Get(ctx, id)
  28146. }
  28147. })
  28148. return value, err
  28149. }
  28150. m.id = &id
  28151. }
  28152. }
  28153. // withUsageStatisticDay sets the old UsageStatisticDay of the mutation.
  28154. func withUsageStatisticDay(node *UsageStatisticDay) usagestatisticdayOption {
  28155. return func(m *UsageStatisticDayMutation) {
  28156. m.oldValue = func(context.Context) (*UsageStatisticDay, error) {
  28157. return node, nil
  28158. }
  28159. m.id = &node.ID
  28160. }
  28161. }
  28162. // Client returns a new `ent.Client` from the mutation. If the mutation was
  28163. // executed in a transaction (ent.Tx), a transactional client is returned.
  28164. func (m UsageStatisticDayMutation) Client() *Client {
  28165. client := &Client{config: m.config}
  28166. client.init()
  28167. return client
  28168. }
  28169. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  28170. // it returns an error otherwise.
  28171. func (m UsageStatisticDayMutation) Tx() (*Tx, error) {
  28172. if _, ok := m.driver.(*txDriver); !ok {
  28173. return nil, errors.New("ent: mutation is not running in a transaction")
  28174. }
  28175. tx := &Tx{config: m.config}
  28176. tx.init()
  28177. return tx, nil
  28178. }
  28179. // SetID sets the value of the id field. Note that this
  28180. // operation is only accepted on creation of UsageStatisticDay entities.
  28181. func (m *UsageStatisticDayMutation) SetID(id uint64) {
  28182. m.id = &id
  28183. }
  28184. // ID returns the ID value in the mutation. Note that the ID is only available
  28185. // if it was provided to the builder or after it was returned from the database.
  28186. func (m *UsageStatisticDayMutation) ID() (id uint64, exists bool) {
  28187. if m.id == nil {
  28188. return
  28189. }
  28190. return *m.id, true
  28191. }
  28192. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  28193. // That means, if the mutation is applied within a transaction with an isolation level such
  28194. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  28195. // or updated by the mutation.
  28196. func (m *UsageStatisticDayMutation) IDs(ctx context.Context) ([]uint64, error) {
  28197. switch {
  28198. case m.op.Is(OpUpdateOne | OpDeleteOne):
  28199. id, exists := m.ID()
  28200. if exists {
  28201. return []uint64{id}, nil
  28202. }
  28203. fallthrough
  28204. case m.op.Is(OpUpdate | OpDelete):
  28205. return m.Client().UsageStatisticDay.Query().Where(m.predicates...).IDs(ctx)
  28206. default:
  28207. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  28208. }
  28209. }
  28210. // SetCreatedAt sets the "created_at" field.
  28211. func (m *UsageStatisticDayMutation) SetCreatedAt(t time.Time) {
  28212. m.created_at = &t
  28213. }
  28214. // CreatedAt returns the value of the "created_at" field in the mutation.
  28215. func (m *UsageStatisticDayMutation) CreatedAt() (r time.Time, exists bool) {
  28216. v := m.created_at
  28217. if v == nil {
  28218. return
  28219. }
  28220. return *v, true
  28221. }
  28222. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticDay entity.
  28223. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28224. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28225. func (m *UsageStatisticDayMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  28226. if !m.op.Is(OpUpdateOne) {
  28227. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  28228. }
  28229. if m.id == nil || m.oldValue == nil {
  28230. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  28231. }
  28232. oldValue, err := m.oldValue(ctx)
  28233. if err != nil {
  28234. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  28235. }
  28236. return oldValue.CreatedAt, nil
  28237. }
  28238. // ResetCreatedAt resets all changes to the "created_at" field.
  28239. func (m *UsageStatisticDayMutation) ResetCreatedAt() {
  28240. m.created_at = nil
  28241. }
  28242. // SetUpdatedAt sets the "updated_at" field.
  28243. func (m *UsageStatisticDayMutation) SetUpdatedAt(t time.Time) {
  28244. m.updated_at = &t
  28245. }
  28246. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  28247. func (m *UsageStatisticDayMutation) UpdatedAt() (r time.Time, exists bool) {
  28248. v := m.updated_at
  28249. if v == nil {
  28250. return
  28251. }
  28252. return *v, true
  28253. }
  28254. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticDay entity.
  28255. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28256. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28257. func (m *UsageStatisticDayMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  28258. if !m.op.Is(OpUpdateOne) {
  28259. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  28260. }
  28261. if m.id == nil || m.oldValue == nil {
  28262. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  28263. }
  28264. oldValue, err := m.oldValue(ctx)
  28265. if err != nil {
  28266. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  28267. }
  28268. return oldValue.UpdatedAt, nil
  28269. }
  28270. // ResetUpdatedAt resets all changes to the "updated_at" field.
  28271. func (m *UsageStatisticDayMutation) ResetUpdatedAt() {
  28272. m.updated_at = nil
  28273. }
  28274. // SetStatus sets the "status" field.
  28275. func (m *UsageStatisticDayMutation) SetStatus(u uint8) {
  28276. m.status = &u
  28277. m.addstatus = nil
  28278. }
  28279. // Status returns the value of the "status" field in the mutation.
  28280. func (m *UsageStatisticDayMutation) Status() (r uint8, exists bool) {
  28281. v := m.status
  28282. if v == nil {
  28283. return
  28284. }
  28285. return *v, true
  28286. }
  28287. // OldStatus returns the old "status" field's value of the UsageStatisticDay entity.
  28288. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28289. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28290. func (m *UsageStatisticDayMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  28291. if !m.op.Is(OpUpdateOne) {
  28292. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  28293. }
  28294. if m.id == nil || m.oldValue == nil {
  28295. return v, errors.New("OldStatus requires an ID field in the mutation")
  28296. }
  28297. oldValue, err := m.oldValue(ctx)
  28298. if err != nil {
  28299. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  28300. }
  28301. return oldValue.Status, nil
  28302. }
  28303. // AddStatus adds u to the "status" field.
  28304. func (m *UsageStatisticDayMutation) AddStatus(u int8) {
  28305. if m.addstatus != nil {
  28306. *m.addstatus += u
  28307. } else {
  28308. m.addstatus = &u
  28309. }
  28310. }
  28311. // AddedStatus returns the value that was added to the "status" field in this mutation.
  28312. func (m *UsageStatisticDayMutation) AddedStatus() (r int8, exists bool) {
  28313. v := m.addstatus
  28314. if v == nil {
  28315. return
  28316. }
  28317. return *v, true
  28318. }
  28319. // ClearStatus clears the value of the "status" field.
  28320. func (m *UsageStatisticDayMutation) ClearStatus() {
  28321. m.status = nil
  28322. m.addstatus = nil
  28323. m.clearedFields[usagestatisticday.FieldStatus] = struct{}{}
  28324. }
  28325. // StatusCleared returns if the "status" field was cleared in this mutation.
  28326. func (m *UsageStatisticDayMutation) StatusCleared() bool {
  28327. _, ok := m.clearedFields[usagestatisticday.FieldStatus]
  28328. return ok
  28329. }
  28330. // ResetStatus resets all changes to the "status" field.
  28331. func (m *UsageStatisticDayMutation) ResetStatus() {
  28332. m.status = nil
  28333. m.addstatus = nil
  28334. delete(m.clearedFields, usagestatisticday.FieldStatus)
  28335. }
  28336. // SetDeletedAt sets the "deleted_at" field.
  28337. func (m *UsageStatisticDayMutation) SetDeletedAt(t time.Time) {
  28338. m.deleted_at = &t
  28339. }
  28340. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  28341. func (m *UsageStatisticDayMutation) DeletedAt() (r time.Time, exists bool) {
  28342. v := m.deleted_at
  28343. if v == nil {
  28344. return
  28345. }
  28346. return *v, true
  28347. }
  28348. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticDay entity.
  28349. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28350. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28351. func (m *UsageStatisticDayMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  28352. if !m.op.Is(OpUpdateOne) {
  28353. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  28354. }
  28355. if m.id == nil || m.oldValue == nil {
  28356. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  28357. }
  28358. oldValue, err := m.oldValue(ctx)
  28359. if err != nil {
  28360. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  28361. }
  28362. return oldValue.DeletedAt, nil
  28363. }
  28364. // ClearDeletedAt clears the value of the "deleted_at" field.
  28365. func (m *UsageStatisticDayMutation) ClearDeletedAt() {
  28366. m.deleted_at = nil
  28367. m.clearedFields[usagestatisticday.FieldDeletedAt] = struct{}{}
  28368. }
  28369. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  28370. func (m *UsageStatisticDayMutation) DeletedAtCleared() bool {
  28371. _, ok := m.clearedFields[usagestatisticday.FieldDeletedAt]
  28372. return ok
  28373. }
  28374. // ResetDeletedAt resets all changes to the "deleted_at" field.
  28375. func (m *UsageStatisticDayMutation) ResetDeletedAt() {
  28376. m.deleted_at = nil
  28377. delete(m.clearedFields, usagestatisticday.FieldDeletedAt)
  28378. }
  28379. // SetAddtime sets the "addtime" field.
  28380. func (m *UsageStatisticDayMutation) SetAddtime(u uint64) {
  28381. m.addtime = &u
  28382. m.addaddtime = nil
  28383. }
  28384. // Addtime returns the value of the "addtime" field in the mutation.
  28385. func (m *UsageStatisticDayMutation) Addtime() (r uint64, exists bool) {
  28386. v := m.addtime
  28387. if v == nil {
  28388. return
  28389. }
  28390. return *v, true
  28391. }
  28392. // OldAddtime returns the old "addtime" field's value of the UsageStatisticDay entity.
  28393. // If the UsageStatisticDay 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 *UsageStatisticDayMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  28396. if !m.op.Is(OpUpdateOne) {
  28397. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  28398. }
  28399. if m.id == nil || m.oldValue == nil {
  28400. return v, errors.New("OldAddtime 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 OldAddtime: %w", err)
  28405. }
  28406. return oldValue.Addtime, nil
  28407. }
  28408. // AddAddtime adds u to the "addtime" field.
  28409. func (m *UsageStatisticDayMutation) AddAddtime(u int64) {
  28410. if m.addaddtime != nil {
  28411. *m.addaddtime += u
  28412. } else {
  28413. m.addaddtime = &u
  28414. }
  28415. }
  28416. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  28417. func (m *UsageStatisticDayMutation) AddedAddtime() (r int64, exists bool) {
  28418. v := m.addaddtime
  28419. if v == nil {
  28420. return
  28421. }
  28422. return *v, true
  28423. }
  28424. // ResetAddtime resets all changes to the "addtime" field.
  28425. func (m *UsageStatisticDayMutation) ResetAddtime() {
  28426. m.addtime = nil
  28427. m.addaddtime = nil
  28428. }
  28429. // SetType sets the "type" field.
  28430. func (m *UsageStatisticDayMutation) SetType(i int) {
  28431. m._type = &i
  28432. m.add_type = nil
  28433. }
  28434. // GetType returns the value of the "type" field in the mutation.
  28435. func (m *UsageStatisticDayMutation) GetType() (r int, exists bool) {
  28436. v := m._type
  28437. if v == nil {
  28438. return
  28439. }
  28440. return *v, true
  28441. }
  28442. // OldType returns the old "type" field's value of the UsageStatisticDay entity.
  28443. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28444. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28445. func (m *UsageStatisticDayMutation) OldType(ctx context.Context) (v int, err error) {
  28446. if !m.op.Is(OpUpdateOne) {
  28447. return v, errors.New("OldType is only allowed on UpdateOne operations")
  28448. }
  28449. if m.id == nil || m.oldValue == nil {
  28450. return v, errors.New("OldType requires an ID field in the mutation")
  28451. }
  28452. oldValue, err := m.oldValue(ctx)
  28453. if err != nil {
  28454. return v, fmt.Errorf("querying old value for OldType: %w", err)
  28455. }
  28456. return oldValue.Type, nil
  28457. }
  28458. // AddType adds i to the "type" field.
  28459. func (m *UsageStatisticDayMutation) AddType(i int) {
  28460. if m.add_type != nil {
  28461. *m.add_type += i
  28462. } else {
  28463. m.add_type = &i
  28464. }
  28465. }
  28466. // AddedType returns the value that was added to the "type" field in this mutation.
  28467. func (m *UsageStatisticDayMutation) AddedType() (r int, exists bool) {
  28468. v := m.add_type
  28469. if v == nil {
  28470. return
  28471. }
  28472. return *v, true
  28473. }
  28474. // ResetType resets all changes to the "type" field.
  28475. func (m *UsageStatisticDayMutation) ResetType() {
  28476. m._type = nil
  28477. m.add_type = nil
  28478. }
  28479. // SetBotID sets the "bot_id" field.
  28480. func (m *UsageStatisticDayMutation) SetBotID(s string) {
  28481. m.bot_id = &s
  28482. }
  28483. // BotID returns the value of the "bot_id" field in the mutation.
  28484. func (m *UsageStatisticDayMutation) BotID() (r string, exists bool) {
  28485. v := m.bot_id
  28486. if v == nil {
  28487. return
  28488. }
  28489. return *v, true
  28490. }
  28491. // OldBotID returns the old "bot_id" field's value of the UsageStatisticDay entity.
  28492. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28493. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28494. func (m *UsageStatisticDayMutation) OldBotID(ctx context.Context) (v string, err error) {
  28495. if !m.op.Is(OpUpdateOne) {
  28496. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  28497. }
  28498. if m.id == nil || m.oldValue == nil {
  28499. return v, errors.New("OldBotID requires an ID field in the mutation")
  28500. }
  28501. oldValue, err := m.oldValue(ctx)
  28502. if err != nil {
  28503. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  28504. }
  28505. return oldValue.BotID, nil
  28506. }
  28507. // ClearBotID clears the value of the "bot_id" field.
  28508. func (m *UsageStatisticDayMutation) ClearBotID() {
  28509. m.bot_id = nil
  28510. m.clearedFields[usagestatisticday.FieldBotID] = struct{}{}
  28511. }
  28512. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  28513. func (m *UsageStatisticDayMutation) BotIDCleared() bool {
  28514. _, ok := m.clearedFields[usagestatisticday.FieldBotID]
  28515. return ok
  28516. }
  28517. // ResetBotID resets all changes to the "bot_id" field.
  28518. func (m *UsageStatisticDayMutation) ResetBotID() {
  28519. m.bot_id = nil
  28520. delete(m.clearedFields, usagestatisticday.FieldBotID)
  28521. }
  28522. // SetOrganizationID sets the "organization_id" field.
  28523. func (m *UsageStatisticDayMutation) SetOrganizationID(u uint64) {
  28524. m.organization_id = &u
  28525. m.addorganization_id = nil
  28526. }
  28527. // OrganizationID returns the value of the "organization_id" field in the mutation.
  28528. func (m *UsageStatisticDayMutation) OrganizationID() (r uint64, exists bool) {
  28529. v := m.organization_id
  28530. if v == nil {
  28531. return
  28532. }
  28533. return *v, true
  28534. }
  28535. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticDay entity.
  28536. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28537. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28538. func (m *UsageStatisticDayMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  28539. if !m.op.Is(OpUpdateOne) {
  28540. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  28541. }
  28542. if m.id == nil || m.oldValue == nil {
  28543. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  28544. }
  28545. oldValue, err := m.oldValue(ctx)
  28546. if err != nil {
  28547. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  28548. }
  28549. return oldValue.OrganizationID, nil
  28550. }
  28551. // AddOrganizationID adds u to the "organization_id" field.
  28552. func (m *UsageStatisticDayMutation) AddOrganizationID(u int64) {
  28553. if m.addorganization_id != nil {
  28554. *m.addorganization_id += u
  28555. } else {
  28556. m.addorganization_id = &u
  28557. }
  28558. }
  28559. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  28560. func (m *UsageStatisticDayMutation) AddedOrganizationID() (r int64, exists bool) {
  28561. v := m.addorganization_id
  28562. if v == nil {
  28563. return
  28564. }
  28565. return *v, true
  28566. }
  28567. // ClearOrganizationID clears the value of the "organization_id" field.
  28568. func (m *UsageStatisticDayMutation) ClearOrganizationID() {
  28569. m.organization_id = nil
  28570. m.addorganization_id = nil
  28571. m.clearedFields[usagestatisticday.FieldOrganizationID] = struct{}{}
  28572. }
  28573. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  28574. func (m *UsageStatisticDayMutation) OrganizationIDCleared() bool {
  28575. _, ok := m.clearedFields[usagestatisticday.FieldOrganizationID]
  28576. return ok
  28577. }
  28578. // ResetOrganizationID resets all changes to the "organization_id" field.
  28579. func (m *UsageStatisticDayMutation) ResetOrganizationID() {
  28580. m.organization_id = nil
  28581. m.addorganization_id = nil
  28582. delete(m.clearedFields, usagestatisticday.FieldOrganizationID)
  28583. }
  28584. // SetAiResponse sets the "ai_response" field.
  28585. func (m *UsageStatisticDayMutation) SetAiResponse(u uint64) {
  28586. m.ai_response = &u
  28587. m.addai_response = nil
  28588. }
  28589. // AiResponse returns the value of the "ai_response" field in the mutation.
  28590. func (m *UsageStatisticDayMutation) AiResponse() (r uint64, exists bool) {
  28591. v := m.ai_response
  28592. if v == nil {
  28593. return
  28594. }
  28595. return *v, true
  28596. }
  28597. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticDay entity.
  28598. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28599. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28600. func (m *UsageStatisticDayMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  28601. if !m.op.Is(OpUpdateOne) {
  28602. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  28603. }
  28604. if m.id == nil || m.oldValue == nil {
  28605. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  28606. }
  28607. oldValue, err := m.oldValue(ctx)
  28608. if err != nil {
  28609. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  28610. }
  28611. return oldValue.AiResponse, nil
  28612. }
  28613. // AddAiResponse adds u to the "ai_response" field.
  28614. func (m *UsageStatisticDayMutation) AddAiResponse(u int64) {
  28615. if m.addai_response != nil {
  28616. *m.addai_response += u
  28617. } else {
  28618. m.addai_response = &u
  28619. }
  28620. }
  28621. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  28622. func (m *UsageStatisticDayMutation) AddedAiResponse() (r int64, exists bool) {
  28623. v := m.addai_response
  28624. if v == nil {
  28625. return
  28626. }
  28627. return *v, true
  28628. }
  28629. // ResetAiResponse resets all changes to the "ai_response" field.
  28630. func (m *UsageStatisticDayMutation) ResetAiResponse() {
  28631. m.ai_response = nil
  28632. m.addai_response = nil
  28633. }
  28634. // SetSopRun sets the "sop_run" field.
  28635. func (m *UsageStatisticDayMutation) SetSopRun(u uint64) {
  28636. m.sop_run = &u
  28637. m.addsop_run = nil
  28638. }
  28639. // SopRun returns the value of the "sop_run" field in the mutation.
  28640. func (m *UsageStatisticDayMutation) SopRun() (r uint64, exists bool) {
  28641. v := m.sop_run
  28642. if v == nil {
  28643. return
  28644. }
  28645. return *v, true
  28646. }
  28647. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticDay entity.
  28648. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28649. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28650. func (m *UsageStatisticDayMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  28651. if !m.op.Is(OpUpdateOne) {
  28652. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  28653. }
  28654. if m.id == nil || m.oldValue == nil {
  28655. return v, errors.New("OldSopRun requires an ID field in the mutation")
  28656. }
  28657. oldValue, err := m.oldValue(ctx)
  28658. if err != nil {
  28659. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  28660. }
  28661. return oldValue.SopRun, nil
  28662. }
  28663. // AddSopRun adds u to the "sop_run" field.
  28664. func (m *UsageStatisticDayMutation) AddSopRun(u int64) {
  28665. if m.addsop_run != nil {
  28666. *m.addsop_run += u
  28667. } else {
  28668. m.addsop_run = &u
  28669. }
  28670. }
  28671. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  28672. func (m *UsageStatisticDayMutation) AddedSopRun() (r int64, exists bool) {
  28673. v := m.addsop_run
  28674. if v == nil {
  28675. return
  28676. }
  28677. return *v, true
  28678. }
  28679. // ResetSopRun resets all changes to the "sop_run" field.
  28680. func (m *UsageStatisticDayMutation) ResetSopRun() {
  28681. m.sop_run = nil
  28682. m.addsop_run = nil
  28683. }
  28684. // SetTotalFriend sets the "total_friend" field.
  28685. func (m *UsageStatisticDayMutation) SetTotalFriend(u uint64) {
  28686. m.total_friend = &u
  28687. m.addtotal_friend = nil
  28688. }
  28689. // TotalFriend returns the value of the "total_friend" field in the mutation.
  28690. func (m *UsageStatisticDayMutation) TotalFriend() (r uint64, exists bool) {
  28691. v := m.total_friend
  28692. if v == nil {
  28693. return
  28694. }
  28695. return *v, true
  28696. }
  28697. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticDay entity.
  28698. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28699. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28700. func (m *UsageStatisticDayMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  28701. if !m.op.Is(OpUpdateOne) {
  28702. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  28703. }
  28704. if m.id == nil || m.oldValue == nil {
  28705. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  28706. }
  28707. oldValue, err := m.oldValue(ctx)
  28708. if err != nil {
  28709. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  28710. }
  28711. return oldValue.TotalFriend, nil
  28712. }
  28713. // AddTotalFriend adds u to the "total_friend" field.
  28714. func (m *UsageStatisticDayMutation) AddTotalFriend(u int64) {
  28715. if m.addtotal_friend != nil {
  28716. *m.addtotal_friend += u
  28717. } else {
  28718. m.addtotal_friend = &u
  28719. }
  28720. }
  28721. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  28722. func (m *UsageStatisticDayMutation) AddedTotalFriend() (r int64, exists bool) {
  28723. v := m.addtotal_friend
  28724. if v == nil {
  28725. return
  28726. }
  28727. return *v, true
  28728. }
  28729. // ResetTotalFriend resets all changes to the "total_friend" field.
  28730. func (m *UsageStatisticDayMutation) ResetTotalFriend() {
  28731. m.total_friend = nil
  28732. m.addtotal_friend = nil
  28733. }
  28734. // SetTotalGroup sets the "total_group" field.
  28735. func (m *UsageStatisticDayMutation) SetTotalGroup(u uint64) {
  28736. m.total_group = &u
  28737. m.addtotal_group = nil
  28738. }
  28739. // TotalGroup returns the value of the "total_group" field in the mutation.
  28740. func (m *UsageStatisticDayMutation) TotalGroup() (r uint64, exists bool) {
  28741. v := m.total_group
  28742. if v == nil {
  28743. return
  28744. }
  28745. return *v, true
  28746. }
  28747. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticDay entity.
  28748. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28749. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28750. func (m *UsageStatisticDayMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  28751. if !m.op.Is(OpUpdateOne) {
  28752. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  28753. }
  28754. if m.id == nil || m.oldValue == nil {
  28755. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  28756. }
  28757. oldValue, err := m.oldValue(ctx)
  28758. if err != nil {
  28759. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  28760. }
  28761. return oldValue.TotalGroup, nil
  28762. }
  28763. // AddTotalGroup adds u to the "total_group" field.
  28764. func (m *UsageStatisticDayMutation) AddTotalGroup(u int64) {
  28765. if m.addtotal_group != nil {
  28766. *m.addtotal_group += u
  28767. } else {
  28768. m.addtotal_group = &u
  28769. }
  28770. }
  28771. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  28772. func (m *UsageStatisticDayMutation) AddedTotalGroup() (r int64, exists bool) {
  28773. v := m.addtotal_group
  28774. if v == nil {
  28775. return
  28776. }
  28777. return *v, true
  28778. }
  28779. // ResetTotalGroup resets all changes to the "total_group" field.
  28780. func (m *UsageStatisticDayMutation) ResetTotalGroup() {
  28781. m.total_group = nil
  28782. m.addtotal_group = nil
  28783. }
  28784. // SetAccountBalance sets the "account_balance" field.
  28785. func (m *UsageStatisticDayMutation) SetAccountBalance(u uint64) {
  28786. m.account_balance = &u
  28787. m.addaccount_balance = nil
  28788. }
  28789. // AccountBalance returns the value of the "account_balance" field in the mutation.
  28790. func (m *UsageStatisticDayMutation) AccountBalance() (r uint64, exists bool) {
  28791. v := m.account_balance
  28792. if v == nil {
  28793. return
  28794. }
  28795. return *v, true
  28796. }
  28797. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticDay entity.
  28798. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28799. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28800. func (m *UsageStatisticDayMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  28801. if !m.op.Is(OpUpdateOne) {
  28802. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  28803. }
  28804. if m.id == nil || m.oldValue == nil {
  28805. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  28806. }
  28807. oldValue, err := m.oldValue(ctx)
  28808. if err != nil {
  28809. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  28810. }
  28811. return oldValue.AccountBalance, nil
  28812. }
  28813. // AddAccountBalance adds u to the "account_balance" field.
  28814. func (m *UsageStatisticDayMutation) AddAccountBalance(u int64) {
  28815. if m.addaccount_balance != nil {
  28816. *m.addaccount_balance += u
  28817. } else {
  28818. m.addaccount_balance = &u
  28819. }
  28820. }
  28821. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  28822. func (m *UsageStatisticDayMutation) AddedAccountBalance() (r int64, exists bool) {
  28823. v := m.addaccount_balance
  28824. if v == nil {
  28825. return
  28826. }
  28827. return *v, true
  28828. }
  28829. // ResetAccountBalance resets all changes to the "account_balance" field.
  28830. func (m *UsageStatisticDayMutation) ResetAccountBalance() {
  28831. m.account_balance = nil
  28832. m.addaccount_balance = nil
  28833. }
  28834. // SetConsumeToken sets the "consume_token" field.
  28835. func (m *UsageStatisticDayMutation) SetConsumeToken(u uint64) {
  28836. m.consume_token = &u
  28837. m.addconsume_token = nil
  28838. }
  28839. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  28840. func (m *UsageStatisticDayMutation) ConsumeToken() (r uint64, exists bool) {
  28841. v := m.consume_token
  28842. if v == nil {
  28843. return
  28844. }
  28845. return *v, true
  28846. }
  28847. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticDay entity.
  28848. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28849. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28850. func (m *UsageStatisticDayMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  28851. if !m.op.Is(OpUpdateOne) {
  28852. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  28853. }
  28854. if m.id == nil || m.oldValue == nil {
  28855. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  28856. }
  28857. oldValue, err := m.oldValue(ctx)
  28858. if err != nil {
  28859. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  28860. }
  28861. return oldValue.ConsumeToken, nil
  28862. }
  28863. // AddConsumeToken adds u to the "consume_token" field.
  28864. func (m *UsageStatisticDayMutation) AddConsumeToken(u int64) {
  28865. if m.addconsume_token != nil {
  28866. *m.addconsume_token += u
  28867. } else {
  28868. m.addconsume_token = &u
  28869. }
  28870. }
  28871. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  28872. func (m *UsageStatisticDayMutation) AddedConsumeToken() (r int64, exists bool) {
  28873. v := m.addconsume_token
  28874. if v == nil {
  28875. return
  28876. }
  28877. return *v, true
  28878. }
  28879. // ResetConsumeToken resets all changes to the "consume_token" field.
  28880. func (m *UsageStatisticDayMutation) ResetConsumeToken() {
  28881. m.consume_token = nil
  28882. m.addconsume_token = nil
  28883. }
  28884. // SetActiveUser sets the "active_user" field.
  28885. func (m *UsageStatisticDayMutation) SetActiveUser(u uint64) {
  28886. m.active_user = &u
  28887. m.addactive_user = nil
  28888. }
  28889. // ActiveUser returns the value of the "active_user" field in the mutation.
  28890. func (m *UsageStatisticDayMutation) ActiveUser() (r uint64, exists bool) {
  28891. v := m.active_user
  28892. if v == nil {
  28893. return
  28894. }
  28895. return *v, true
  28896. }
  28897. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticDay entity.
  28898. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28899. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28900. func (m *UsageStatisticDayMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  28901. if !m.op.Is(OpUpdateOne) {
  28902. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  28903. }
  28904. if m.id == nil || m.oldValue == nil {
  28905. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  28906. }
  28907. oldValue, err := m.oldValue(ctx)
  28908. if err != nil {
  28909. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  28910. }
  28911. return oldValue.ActiveUser, nil
  28912. }
  28913. // AddActiveUser adds u to the "active_user" field.
  28914. func (m *UsageStatisticDayMutation) AddActiveUser(u int64) {
  28915. if m.addactive_user != nil {
  28916. *m.addactive_user += u
  28917. } else {
  28918. m.addactive_user = &u
  28919. }
  28920. }
  28921. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  28922. func (m *UsageStatisticDayMutation) AddedActiveUser() (r int64, exists bool) {
  28923. v := m.addactive_user
  28924. if v == nil {
  28925. return
  28926. }
  28927. return *v, true
  28928. }
  28929. // ResetActiveUser resets all changes to the "active_user" field.
  28930. func (m *UsageStatisticDayMutation) ResetActiveUser() {
  28931. m.active_user = nil
  28932. m.addactive_user = nil
  28933. }
  28934. // SetNewUser sets the "new_user" field.
  28935. func (m *UsageStatisticDayMutation) SetNewUser(i int64) {
  28936. m.new_user = &i
  28937. m.addnew_user = nil
  28938. }
  28939. // NewUser returns the value of the "new_user" field in the mutation.
  28940. func (m *UsageStatisticDayMutation) NewUser() (r int64, exists bool) {
  28941. v := m.new_user
  28942. if v == nil {
  28943. return
  28944. }
  28945. return *v, true
  28946. }
  28947. // OldNewUser returns the old "new_user" field's value of the UsageStatisticDay entity.
  28948. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28949. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28950. func (m *UsageStatisticDayMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  28951. if !m.op.Is(OpUpdateOne) {
  28952. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  28953. }
  28954. if m.id == nil || m.oldValue == nil {
  28955. return v, errors.New("OldNewUser requires an ID field in the mutation")
  28956. }
  28957. oldValue, err := m.oldValue(ctx)
  28958. if err != nil {
  28959. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  28960. }
  28961. return oldValue.NewUser, nil
  28962. }
  28963. // AddNewUser adds i to the "new_user" field.
  28964. func (m *UsageStatisticDayMutation) AddNewUser(i int64) {
  28965. if m.addnew_user != nil {
  28966. *m.addnew_user += i
  28967. } else {
  28968. m.addnew_user = &i
  28969. }
  28970. }
  28971. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  28972. func (m *UsageStatisticDayMutation) AddedNewUser() (r int64, exists bool) {
  28973. v := m.addnew_user
  28974. if v == nil {
  28975. return
  28976. }
  28977. return *v, true
  28978. }
  28979. // ResetNewUser resets all changes to the "new_user" field.
  28980. func (m *UsageStatisticDayMutation) ResetNewUser() {
  28981. m.new_user = nil
  28982. m.addnew_user = nil
  28983. }
  28984. // SetLabelDist sets the "label_dist" field.
  28985. func (m *UsageStatisticDayMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  28986. m.label_dist = &ctd
  28987. m.appendlabel_dist = nil
  28988. }
  28989. // LabelDist returns the value of the "label_dist" field in the mutation.
  28990. func (m *UsageStatisticDayMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  28991. v := m.label_dist
  28992. if v == nil {
  28993. return
  28994. }
  28995. return *v, true
  28996. }
  28997. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticDay entity.
  28998. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28999. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29000. func (m *UsageStatisticDayMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  29001. if !m.op.Is(OpUpdateOne) {
  29002. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  29003. }
  29004. if m.id == nil || m.oldValue == nil {
  29005. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  29006. }
  29007. oldValue, err := m.oldValue(ctx)
  29008. if err != nil {
  29009. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  29010. }
  29011. return oldValue.LabelDist, nil
  29012. }
  29013. // AppendLabelDist adds ctd to the "label_dist" field.
  29014. func (m *UsageStatisticDayMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  29015. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  29016. }
  29017. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  29018. func (m *UsageStatisticDayMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  29019. if len(m.appendlabel_dist) == 0 {
  29020. return nil, false
  29021. }
  29022. return m.appendlabel_dist, true
  29023. }
  29024. // ResetLabelDist resets all changes to the "label_dist" field.
  29025. func (m *UsageStatisticDayMutation) ResetLabelDist() {
  29026. m.label_dist = nil
  29027. m.appendlabel_dist = nil
  29028. }
  29029. // Where appends a list predicates to the UsageStatisticDayMutation builder.
  29030. func (m *UsageStatisticDayMutation) Where(ps ...predicate.UsageStatisticDay) {
  29031. m.predicates = append(m.predicates, ps...)
  29032. }
  29033. // WhereP appends storage-level predicates to the UsageStatisticDayMutation builder. Using this method,
  29034. // users can use type-assertion to append predicates that do not depend on any generated package.
  29035. func (m *UsageStatisticDayMutation) WhereP(ps ...func(*sql.Selector)) {
  29036. p := make([]predicate.UsageStatisticDay, len(ps))
  29037. for i := range ps {
  29038. p[i] = ps[i]
  29039. }
  29040. m.Where(p...)
  29041. }
  29042. // Op returns the operation name.
  29043. func (m *UsageStatisticDayMutation) Op() Op {
  29044. return m.op
  29045. }
  29046. // SetOp allows setting the mutation operation.
  29047. func (m *UsageStatisticDayMutation) SetOp(op Op) {
  29048. m.op = op
  29049. }
  29050. // Type returns the node type of this mutation (UsageStatisticDay).
  29051. func (m *UsageStatisticDayMutation) Type() string {
  29052. return m.typ
  29053. }
  29054. // Fields returns all fields that were changed during this mutation. Note that in
  29055. // order to get all numeric fields that were incremented/decremented, call
  29056. // AddedFields().
  29057. func (m *UsageStatisticDayMutation) Fields() []string {
  29058. fields := make([]string, 0, 17)
  29059. if m.created_at != nil {
  29060. fields = append(fields, usagestatisticday.FieldCreatedAt)
  29061. }
  29062. if m.updated_at != nil {
  29063. fields = append(fields, usagestatisticday.FieldUpdatedAt)
  29064. }
  29065. if m.status != nil {
  29066. fields = append(fields, usagestatisticday.FieldStatus)
  29067. }
  29068. if m.deleted_at != nil {
  29069. fields = append(fields, usagestatisticday.FieldDeletedAt)
  29070. }
  29071. if m.addtime != nil {
  29072. fields = append(fields, usagestatisticday.FieldAddtime)
  29073. }
  29074. if m._type != nil {
  29075. fields = append(fields, usagestatisticday.FieldType)
  29076. }
  29077. if m.bot_id != nil {
  29078. fields = append(fields, usagestatisticday.FieldBotID)
  29079. }
  29080. if m.organization_id != nil {
  29081. fields = append(fields, usagestatisticday.FieldOrganizationID)
  29082. }
  29083. if m.ai_response != nil {
  29084. fields = append(fields, usagestatisticday.FieldAiResponse)
  29085. }
  29086. if m.sop_run != nil {
  29087. fields = append(fields, usagestatisticday.FieldSopRun)
  29088. }
  29089. if m.total_friend != nil {
  29090. fields = append(fields, usagestatisticday.FieldTotalFriend)
  29091. }
  29092. if m.total_group != nil {
  29093. fields = append(fields, usagestatisticday.FieldTotalGroup)
  29094. }
  29095. if m.account_balance != nil {
  29096. fields = append(fields, usagestatisticday.FieldAccountBalance)
  29097. }
  29098. if m.consume_token != nil {
  29099. fields = append(fields, usagestatisticday.FieldConsumeToken)
  29100. }
  29101. if m.active_user != nil {
  29102. fields = append(fields, usagestatisticday.FieldActiveUser)
  29103. }
  29104. if m.new_user != nil {
  29105. fields = append(fields, usagestatisticday.FieldNewUser)
  29106. }
  29107. if m.label_dist != nil {
  29108. fields = append(fields, usagestatisticday.FieldLabelDist)
  29109. }
  29110. return fields
  29111. }
  29112. // Field returns the value of a field with the given name. The second boolean
  29113. // return value indicates that this field was not set, or was not defined in the
  29114. // schema.
  29115. func (m *UsageStatisticDayMutation) Field(name string) (ent.Value, bool) {
  29116. switch name {
  29117. case usagestatisticday.FieldCreatedAt:
  29118. return m.CreatedAt()
  29119. case usagestatisticday.FieldUpdatedAt:
  29120. return m.UpdatedAt()
  29121. case usagestatisticday.FieldStatus:
  29122. return m.Status()
  29123. case usagestatisticday.FieldDeletedAt:
  29124. return m.DeletedAt()
  29125. case usagestatisticday.FieldAddtime:
  29126. return m.Addtime()
  29127. case usagestatisticday.FieldType:
  29128. return m.GetType()
  29129. case usagestatisticday.FieldBotID:
  29130. return m.BotID()
  29131. case usagestatisticday.FieldOrganizationID:
  29132. return m.OrganizationID()
  29133. case usagestatisticday.FieldAiResponse:
  29134. return m.AiResponse()
  29135. case usagestatisticday.FieldSopRun:
  29136. return m.SopRun()
  29137. case usagestatisticday.FieldTotalFriend:
  29138. return m.TotalFriend()
  29139. case usagestatisticday.FieldTotalGroup:
  29140. return m.TotalGroup()
  29141. case usagestatisticday.FieldAccountBalance:
  29142. return m.AccountBalance()
  29143. case usagestatisticday.FieldConsumeToken:
  29144. return m.ConsumeToken()
  29145. case usagestatisticday.FieldActiveUser:
  29146. return m.ActiveUser()
  29147. case usagestatisticday.FieldNewUser:
  29148. return m.NewUser()
  29149. case usagestatisticday.FieldLabelDist:
  29150. return m.LabelDist()
  29151. }
  29152. return nil, false
  29153. }
  29154. // OldField returns the old value of the field from the database. An error is
  29155. // returned if the mutation operation is not UpdateOne, or the query to the
  29156. // database failed.
  29157. func (m *UsageStatisticDayMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  29158. switch name {
  29159. case usagestatisticday.FieldCreatedAt:
  29160. return m.OldCreatedAt(ctx)
  29161. case usagestatisticday.FieldUpdatedAt:
  29162. return m.OldUpdatedAt(ctx)
  29163. case usagestatisticday.FieldStatus:
  29164. return m.OldStatus(ctx)
  29165. case usagestatisticday.FieldDeletedAt:
  29166. return m.OldDeletedAt(ctx)
  29167. case usagestatisticday.FieldAddtime:
  29168. return m.OldAddtime(ctx)
  29169. case usagestatisticday.FieldType:
  29170. return m.OldType(ctx)
  29171. case usagestatisticday.FieldBotID:
  29172. return m.OldBotID(ctx)
  29173. case usagestatisticday.FieldOrganizationID:
  29174. return m.OldOrganizationID(ctx)
  29175. case usagestatisticday.FieldAiResponse:
  29176. return m.OldAiResponse(ctx)
  29177. case usagestatisticday.FieldSopRun:
  29178. return m.OldSopRun(ctx)
  29179. case usagestatisticday.FieldTotalFriend:
  29180. return m.OldTotalFriend(ctx)
  29181. case usagestatisticday.FieldTotalGroup:
  29182. return m.OldTotalGroup(ctx)
  29183. case usagestatisticday.FieldAccountBalance:
  29184. return m.OldAccountBalance(ctx)
  29185. case usagestatisticday.FieldConsumeToken:
  29186. return m.OldConsumeToken(ctx)
  29187. case usagestatisticday.FieldActiveUser:
  29188. return m.OldActiveUser(ctx)
  29189. case usagestatisticday.FieldNewUser:
  29190. return m.OldNewUser(ctx)
  29191. case usagestatisticday.FieldLabelDist:
  29192. return m.OldLabelDist(ctx)
  29193. }
  29194. return nil, fmt.Errorf("unknown UsageStatisticDay field %s", name)
  29195. }
  29196. // SetField sets the value of a field with the given name. It returns an error if
  29197. // the field is not defined in the schema, or if the type mismatched the field
  29198. // type.
  29199. func (m *UsageStatisticDayMutation) SetField(name string, value ent.Value) error {
  29200. switch name {
  29201. case usagestatisticday.FieldCreatedAt:
  29202. v, ok := value.(time.Time)
  29203. if !ok {
  29204. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29205. }
  29206. m.SetCreatedAt(v)
  29207. return nil
  29208. case usagestatisticday.FieldUpdatedAt:
  29209. v, ok := value.(time.Time)
  29210. if !ok {
  29211. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29212. }
  29213. m.SetUpdatedAt(v)
  29214. return nil
  29215. case usagestatisticday.FieldStatus:
  29216. v, ok := value.(uint8)
  29217. if !ok {
  29218. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29219. }
  29220. m.SetStatus(v)
  29221. return nil
  29222. case usagestatisticday.FieldDeletedAt:
  29223. v, ok := value.(time.Time)
  29224. if !ok {
  29225. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29226. }
  29227. m.SetDeletedAt(v)
  29228. return nil
  29229. case usagestatisticday.FieldAddtime:
  29230. v, ok := value.(uint64)
  29231. if !ok {
  29232. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29233. }
  29234. m.SetAddtime(v)
  29235. return nil
  29236. case usagestatisticday.FieldType:
  29237. v, ok := value.(int)
  29238. if !ok {
  29239. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29240. }
  29241. m.SetType(v)
  29242. return nil
  29243. case usagestatisticday.FieldBotID:
  29244. v, ok := value.(string)
  29245. if !ok {
  29246. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29247. }
  29248. m.SetBotID(v)
  29249. return nil
  29250. case usagestatisticday.FieldOrganizationID:
  29251. v, ok := value.(uint64)
  29252. if !ok {
  29253. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29254. }
  29255. m.SetOrganizationID(v)
  29256. return nil
  29257. case usagestatisticday.FieldAiResponse:
  29258. v, ok := value.(uint64)
  29259. if !ok {
  29260. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29261. }
  29262. m.SetAiResponse(v)
  29263. return nil
  29264. case usagestatisticday.FieldSopRun:
  29265. v, ok := value.(uint64)
  29266. if !ok {
  29267. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29268. }
  29269. m.SetSopRun(v)
  29270. return nil
  29271. case usagestatisticday.FieldTotalFriend:
  29272. v, ok := value.(uint64)
  29273. if !ok {
  29274. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29275. }
  29276. m.SetTotalFriend(v)
  29277. return nil
  29278. case usagestatisticday.FieldTotalGroup:
  29279. v, ok := value.(uint64)
  29280. if !ok {
  29281. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29282. }
  29283. m.SetTotalGroup(v)
  29284. return nil
  29285. case usagestatisticday.FieldAccountBalance:
  29286. v, ok := value.(uint64)
  29287. if !ok {
  29288. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29289. }
  29290. m.SetAccountBalance(v)
  29291. return nil
  29292. case usagestatisticday.FieldConsumeToken:
  29293. v, ok := value.(uint64)
  29294. if !ok {
  29295. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29296. }
  29297. m.SetConsumeToken(v)
  29298. return nil
  29299. case usagestatisticday.FieldActiveUser:
  29300. v, ok := value.(uint64)
  29301. if !ok {
  29302. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29303. }
  29304. m.SetActiveUser(v)
  29305. return nil
  29306. case usagestatisticday.FieldNewUser:
  29307. v, ok := value.(int64)
  29308. if !ok {
  29309. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29310. }
  29311. m.SetNewUser(v)
  29312. return nil
  29313. case usagestatisticday.FieldLabelDist:
  29314. v, ok := value.([]custom_types.LabelDist)
  29315. if !ok {
  29316. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29317. }
  29318. m.SetLabelDist(v)
  29319. return nil
  29320. }
  29321. return fmt.Errorf("unknown UsageStatisticDay field %s", name)
  29322. }
  29323. // AddedFields returns all numeric fields that were incremented/decremented during
  29324. // this mutation.
  29325. func (m *UsageStatisticDayMutation) AddedFields() []string {
  29326. var fields []string
  29327. if m.addstatus != nil {
  29328. fields = append(fields, usagestatisticday.FieldStatus)
  29329. }
  29330. if m.addaddtime != nil {
  29331. fields = append(fields, usagestatisticday.FieldAddtime)
  29332. }
  29333. if m.add_type != nil {
  29334. fields = append(fields, usagestatisticday.FieldType)
  29335. }
  29336. if m.addorganization_id != nil {
  29337. fields = append(fields, usagestatisticday.FieldOrganizationID)
  29338. }
  29339. if m.addai_response != nil {
  29340. fields = append(fields, usagestatisticday.FieldAiResponse)
  29341. }
  29342. if m.addsop_run != nil {
  29343. fields = append(fields, usagestatisticday.FieldSopRun)
  29344. }
  29345. if m.addtotal_friend != nil {
  29346. fields = append(fields, usagestatisticday.FieldTotalFriend)
  29347. }
  29348. if m.addtotal_group != nil {
  29349. fields = append(fields, usagestatisticday.FieldTotalGroup)
  29350. }
  29351. if m.addaccount_balance != nil {
  29352. fields = append(fields, usagestatisticday.FieldAccountBalance)
  29353. }
  29354. if m.addconsume_token != nil {
  29355. fields = append(fields, usagestatisticday.FieldConsumeToken)
  29356. }
  29357. if m.addactive_user != nil {
  29358. fields = append(fields, usagestatisticday.FieldActiveUser)
  29359. }
  29360. if m.addnew_user != nil {
  29361. fields = append(fields, usagestatisticday.FieldNewUser)
  29362. }
  29363. return fields
  29364. }
  29365. // AddedField returns the numeric value that was incremented/decremented on a field
  29366. // with the given name. The second boolean return value indicates that this field
  29367. // was not set, or was not defined in the schema.
  29368. func (m *UsageStatisticDayMutation) AddedField(name string) (ent.Value, bool) {
  29369. switch name {
  29370. case usagestatisticday.FieldStatus:
  29371. return m.AddedStatus()
  29372. case usagestatisticday.FieldAddtime:
  29373. return m.AddedAddtime()
  29374. case usagestatisticday.FieldType:
  29375. return m.AddedType()
  29376. case usagestatisticday.FieldOrganizationID:
  29377. return m.AddedOrganizationID()
  29378. case usagestatisticday.FieldAiResponse:
  29379. return m.AddedAiResponse()
  29380. case usagestatisticday.FieldSopRun:
  29381. return m.AddedSopRun()
  29382. case usagestatisticday.FieldTotalFriend:
  29383. return m.AddedTotalFriend()
  29384. case usagestatisticday.FieldTotalGroup:
  29385. return m.AddedTotalGroup()
  29386. case usagestatisticday.FieldAccountBalance:
  29387. return m.AddedAccountBalance()
  29388. case usagestatisticday.FieldConsumeToken:
  29389. return m.AddedConsumeToken()
  29390. case usagestatisticday.FieldActiveUser:
  29391. return m.AddedActiveUser()
  29392. case usagestatisticday.FieldNewUser:
  29393. return m.AddedNewUser()
  29394. }
  29395. return nil, false
  29396. }
  29397. // AddField adds the value to the field with the given name. It returns an error if
  29398. // the field is not defined in the schema, or if the type mismatched the field
  29399. // type.
  29400. func (m *UsageStatisticDayMutation) AddField(name string, value ent.Value) error {
  29401. switch name {
  29402. case usagestatisticday.FieldStatus:
  29403. v, ok := value.(int8)
  29404. if !ok {
  29405. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29406. }
  29407. m.AddStatus(v)
  29408. return nil
  29409. case usagestatisticday.FieldAddtime:
  29410. v, ok := value.(int64)
  29411. if !ok {
  29412. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29413. }
  29414. m.AddAddtime(v)
  29415. return nil
  29416. case usagestatisticday.FieldType:
  29417. v, ok := value.(int)
  29418. if !ok {
  29419. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29420. }
  29421. m.AddType(v)
  29422. return nil
  29423. case usagestatisticday.FieldOrganizationID:
  29424. v, ok := value.(int64)
  29425. if !ok {
  29426. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29427. }
  29428. m.AddOrganizationID(v)
  29429. return nil
  29430. case usagestatisticday.FieldAiResponse:
  29431. v, ok := value.(int64)
  29432. if !ok {
  29433. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29434. }
  29435. m.AddAiResponse(v)
  29436. return nil
  29437. case usagestatisticday.FieldSopRun:
  29438. v, ok := value.(int64)
  29439. if !ok {
  29440. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29441. }
  29442. m.AddSopRun(v)
  29443. return nil
  29444. case usagestatisticday.FieldTotalFriend:
  29445. v, ok := value.(int64)
  29446. if !ok {
  29447. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29448. }
  29449. m.AddTotalFriend(v)
  29450. return nil
  29451. case usagestatisticday.FieldTotalGroup:
  29452. v, ok := value.(int64)
  29453. if !ok {
  29454. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29455. }
  29456. m.AddTotalGroup(v)
  29457. return nil
  29458. case usagestatisticday.FieldAccountBalance:
  29459. v, ok := value.(int64)
  29460. if !ok {
  29461. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29462. }
  29463. m.AddAccountBalance(v)
  29464. return nil
  29465. case usagestatisticday.FieldConsumeToken:
  29466. v, ok := value.(int64)
  29467. if !ok {
  29468. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29469. }
  29470. m.AddConsumeToken(v)
  29471. return nil
  29472. case usagestatisticday.FieldActiveUser:
  29473. v, ok := value.(int64)
  29474. if !ok {
  29475. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29476. }
  29477. m.AddActiveUser(v)
  29478. return nil
  29479. case usagestatisticday.FieldNewUser:
  29480. v, ok := value.(int64)
  29481. if !ok {
  29482. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29483. }
  29484. m.AddNewUser(v)
  29485. return nil
  29486. }
  29487. return fmt.Errorf("unknown UsageStatisticDay numeric field %s", name)
  29488. }
  29489. // ClearedFields returns all nullable fields that were cleared during this
  29490. // mutation.
  29491. func (m *UsageStatisticDayMutation) ClearedFields() []string {
  29492. var fields []string
  29493. if m.FieldCleared(usagestatisticday.FieldStatus) {
  29494. fields = append(fields, usagestatisticday.FieldStatus)
  29495. }
  29496. if m.FieldCleared(usagestatisticday.FieldDeletedAt) {
  29497. fields = append(fields, usagestatisticday.FieldDeletedAt)
  29498. }
  29499. if m.FieldCleared(usagestatisticday.FieldBotID) {
  29500. fields = append(fields, usagestatisticday.FieldBotID)
  29501. }
  29502. if m.FieldCleared(usagestatisticday.FieldOrganizationID) {
  29503. fields = append(fields, usagestatisticday.FieldOrganizationID)
  29504. }
  29505. return fields
  29506. }
  29507. // FieldCleared returns a boolean indicating if a field with the given name was
  29508. // cleared in this mutation.
  29509. func (m *UsageStatisticDayMutation) FieldCleared(name string) bool {
  29510. _, ok := m.clearedFields[name]
  29511. return ok
  29512. }
  29513. // ClearField clears the value of the field with the given name. It returns an
  29514. // error if the field is not defined in the schema.
  29515. func (m *UsageStatisticDayMutation) ClearField(name string) error {
  29516. switch name {
  29517. case usagestatisticday.FieldStatus:
  29518. m.ClearStatus()
  29519. return nil
  29520. case usagestatisticday.FieldDeletedAt:
  29521. m.ClearDeletedAt()
  29522. return nil
  29523. case usagestatisticday.FieldBotID:
  29524. m.ClearBotID()
  29525. return nil
  29526. case usagestatisticday.FieldOrganizationID:
  29527. m.ClearOrganizationID()
  29528. return nil
  29529. }
  29530. return fmt.Errorf("unknown UsageStatisticDay nullable field %s", name)
  29531. }
  29532. // ResetField resets all changes in the mutation for the field with the given name.
  29533. // It returns an error if the field is not defined in the schema.
  29534. func (m *UsageStatisticDayMutation) ResetField(name string) error {
  29535. switch name {
  29536. case usagestatisticday.FieldCreatedAt:
  29537. m.ResetCreatedAt()
  29538. return nil
  29539. case usagestatisticday.FieldUpdatedAt:
  29540. m.ResetUpdatedAt()
  29541. return nil
  29542. case usagestatisticday.FieldStatus:
  29543. m.ResetStatus()
  29544. return nil
  29545. case usagestatisticday.FieldDeletedAt:
  29546. m.ResetDeletedAt()
  29547. return nil
  29548. case usagestatisticday.FieldAddtime:
  29549. m.ResetAddtime()
  29550. return nil
  29551. case usagestatisticday.FieldType:
  29552. m.ResetType()
  29553. return nil
  29554. case usagestatisticday.FieldBotID:
  29555. m.ResetBotID()
  29556. return nil
  29557. case usagestatisticday.FieldOrganizationID:
  29558. m.ResetOrganizationID()
  29559. return nil
  29560. case usagestatisticday.FieldAiResponse:
  29561. m.ResetAiResponse()
  29562. return nil
  29563. case usagestatisticday.FieldSopRun:
  29564. m.ResetSopRun()
  29565. return nil
  29566. case usagestatisticday.FieldTotalFriend:
  29567. m.ResetTotalFriend()
  29568. return nil
  29569. case usagestatisticday.FieldTotalGroup:
  29570. m.ResetTotalGroup()
  29571. return nil
  29572. case usagestatisticday.FieldAccountBalance:
  29573. m.ResetAccountBalance()
  29574. return nil
  29575. case usagestatisticday.FieldConsumeToken:
  29576. m.ResetConsumeToken()
  29577. return nil
  29578. case usagestatisticday.FieldActiveUser:
  29579. m.ResetActiveUser()
  29580. return nil
  29581. case usagestatisticday.FieldNewUser:
  29582. m.ResetNewUser()
  29583. return nil
  29584. case usagestatisticday.FieldLabelDist:
  29585. m.ResetLabelDist()
  29586. return nil
  29587. }
  29588. return fmt.Errorf("unknown UsageStatisticDay field %s", name)
  29589. }
  29590. // AddedEdges returns all edge names that were set/added in this mutation.
  29591. func (m *UsageStatisticDayMutation) AddedEdges() []string {
  29592. edges := make([]string, 0, 0)
  29593. return edges
  29594. }
  29595. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  29596. // name in this mutation.
  29597. func (m *UsageStatisticDayMutation) AddedIDs(name string) []ent.Value {
  29598. return nil
  29599. }
  29600. // RemovedEdges returns all edge names that were removed in this mutation.
  29601. func (m *UsageStatisticDayMutation) RemovedEdges() []string {
  29602. edges := make([]string, 0, 0)
  29603. return edges
  29604. }
  29605. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  29606. // the given name in this mutation.
  29607. func (m *UsageStatisticDayMutation) RemovedIDs(name string) []ent.Value {
  29608. return nil
  29609. }
  29610. // ClearedEdges returns all edge names that were cleared in this mutation.
  29611. func (m *UsageStatisticDayMutation) ClearedEdges() []string {
  29612. edges := make([]string, 0, 0)
  29613. return edges
  29614. }
  29615. // EdgeCleared returns a boolean which indicates if the edge with the given name
  29616. // was cleared in this mutation.
  29617. func (m *UsageStatisticDayMutation) EdgeCleared(name string) bool {
  29618. return false
  29619. }
  29620. // ClearEdge clears the value of the edge with the given name. It returns an error
  29621. // if that edge is not defined in the schema.
  29622. func (m *UsageStatisticDayMutation) ClearEdge(name string) error {
  29623. return fmt.Errorf("unknown UsageStatisticDay unique edge %s", name)
  29624. }
  29625. // ResetEdge resets all changes to the edge with the given name in this mutation.
  29626. // It returns an error if the edge is not defined in the schema.
  29627. func (m *UsageStatisticDayMutation) ResetEdge(name string) error {
  29628. return fmt.Errorf("unknown UsageStatisticDay edge %s", name)
  29629. }
  29630. // UsageStatisticHourMutation represents an operation that mutates the UsageStatisticHour nodes in the graph.
  29631. type UsageStatisticHourMutation struct {
  29632. config
  29633. op Op
  29634. typ string
  29635. id *uint64
  29636. created_at *time.Time
  29637. updated_at *time.Time
  29638. status *uint8
  29639. addstatus *int8
  29640. deleted_at *time.Time
  29641. addtime *uint64
  29642. addaddtime *int64
  29643. _type *int
  29644. add_type *int
  29645. bot_id *string
  29646. organization_id *uint64
  29647. addorganization_id *int64
  29648. ai_response *uint64
  29649. addai_response *int64
  29650. sop_run *uint64
  29651. addsop_run *int64
  29652. total_friend *uint64
  29653. addtotal_friend *int64
  29654. total_group *uint64
  29655. addtotal_group *int64
  29656. account_balance *uint64
  29657. addaccount_balance *int64
  29658. consume_token *uint64
  29659. addconsume_token *int64
  29660. active_user *uint64
  29661. addactive_user *int64
  29662. new_user *int64
  29663. addnew_user *int64
  29664. label_dist *[]custom_types.LabelDist
  29665. appendlabel_dist []custom_types.LabelDist
  29666. clearedFields map[string]struct{}
  29667. done bool
  29668. oldValue func(context.Context) (*UsageStatisticHour, error)
  29669. predicates []predicate.UsageStatisticHour
  29670. }
  29671. var _ ent.Mutation = (*UsageStatisticHourMutation)(nil)
  29672. // usagestatistichourOption allows management of the mutation configuration using functional options.
  29673. type usagestatistichourOption func(*UsageStatisticHourMutation)
  29674. // newUsageStatisticHourMutation creates new mutation for the UsageStatisticHour entity.
  29675. func newUsageStatisticHourMutation(c config, op Op, opts ...usagestatistichourOption) *UsageStatisticHourMutation {
  29676. m := &UsageStatisticHourMutation{
  29677. config: c,
  29678. op: op,
  29679. typ: TypeUsageStatisticHour,
  29680. clearedFields: make(map[string]struct{}),
  29681. }
  29682. for _, opt := range opts {
  29683. opt(m)
  29684. }
  29685. return m
  29686. }
  29687. // withUsageStatisticHourID sets the ID field of the mutation.
  29688. func withUsageStatisticHourID(id uint64) usagestatistichourOption {
  29689. return func(m *UsageStatisticHourMutation) {
  29690. var (
  29691. err error
  29692. once sync.Once
  29693. value *UsageStatisticHour
  29694. )
  29695. m.oldValue = func(ctx context.Context) (*UsageStatisticHour, error) {
  29696. once.Do(func() {
  29697. if m.done {
  29698. err = errors.New("querying old values post mutation is not allowed")
  29699. } else {
  29700. value, err = m.Client().UsageStatisticHour.Get(ctx, id)
  29701. }
  29702. })
  29703. return value, err
  29704. }
  29705. m.id = &id
  29706. }
  29707. }
  29708. // withUsageStatisticHour sets the old UsageStatisticHour of the mutation.
  29709. func withUsageStatisticHour(node *UsageStatisticHour) usagestatistichourOption {
  29710. return func(m *UsageStatisticHourMutation) {
  29711. m.oldValue = func(context.Context) (*UsageStatisticHour, error) {
  29712. return node, nil
  29713. }
  29714. m.id = &node.ID
  29715. }
  29716. }
  29717. // Client returns a new `ent.Client` from the mutation. If the mutation was
  29718. // executed in a transaction (ent.Tx), a transactional client is returned.
  29719. func (m UsageStatisticHourMutation) Client() *Client {
  29720. client := &Client{config: m.config}
  29721. client.init()
  29722. return client
  29723. }
  29724. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  29725. // it returns an error otherwise.
  29726. func (m UsageStatisticHourMutation) Tx() (*Tx, error) {
  29727. if _, ok := m.driver.(*txDriver); !ok {
  29728. return nil, errors.New("ent: mutation is not running in a transaction")
  29729. }
  29730. tx := &Tx{config: m.config}
  29731. tx.init()
  29732. return tx, nil
  29733. }
  29734. // SetID sets the value of the id field. Note that this
  29735. // operation is only accepted on creation of UsageStatisticHour entities.
  29736. func (m *UsageStatisticHourMutation) SetID(id uint64) {
  29737. m.id = &id
  29738. }
  29739. // ID returns the ID value in the mutation. Note that the ID is only available
  29740. // if it was provided to the builder or after it was returned from the database.
  29741. func (m *UsageStatisticHourMutation) ID() (id uint64, exists bool) {
  29742. if m.id == nil {
  29743. return
  29744. }
  29745. return *m.id, true
  29746. }
  29747. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  29748. // That means, if the mutation is applied within a transaction with an isolation level such
  29749. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  29750. // or updated by the mutation.
  29751. func (m *UsageStatisticHourMutation) IDs(ctx context.Context) ([]uint64, error) {
  29752. switch {
  29753. case m.op.Is(OpUpdateOne | OpDeleteOne):
  29754. id, exists := m.ID()
  29755. if exists {
  29756. return []uint64{id}, nil
  29757. }
  29758. fallthrough
  29759. case m.op.Is(OpUpdate | OpDelete):
  29760. return m.Client().UsageStatisticHour.Query().Where(m.predicates...).IDs(ctx)
  29761. default:
  29762. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  29763. }
  29764. }
  29765. // SetCreatedAt sets the "created_at" field.
  29766. func (m *UsageStatisticHourMutation) SetCreatedAt(t time.Time) {
  29767. m.created_at = &t
  29768. }
  29769. // CreatedAt returns the value of the "created_at" field in the mutation.
  29770. func (m *UsageStatisticHourMutation) CreatedAt() (r time.Time, exists bool) {
  29771. v := m.created_at
  29772. if v == nil {
  29773. return
  29774. }
  29775. return *v, true
  29776. }
  29777. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticHour entity.
  29778. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  29779. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29780. func (m *UsageStatisticHourMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  29781. if !m.op.Is(OpUpdateOne) {
  29782. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  29783. }
  29784. if m.id == nil || m.oldValue == nil {
  29785. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  29786. }
  29787. oldValue, err := m.oldValue(ctx)
  29788. if err != nil {
  29789. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  29790. }
  29791. return oldValue.CreatedAt, nil
  29792. }
  29793. // ResetCreatedAt resets all changes to the "created_at" field.
  29794. func (m *UsageStatisticHourMutation) ResetCreatedAt() {
  29795. m.created_at = nil
  29796. }
  29797. // SetUpdatedAt sets the "updated_at" field.
  29798. func (m *UsageStatisticHourMutation) SetUpdatedAt(t time.Time) {
  29799. m.updated_at = &t
  29800. }
  29801. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  29802. func (m *UsageStatisticHourMutation) UpdatedAt() (r time.Time, exists bool) {
  29803. v := m.updated_at
  29804. if v == nil {
  29805. return
  29806. }
  29807. return *v, true
  29808. }
  29809. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticHour entity.
  29810. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  29811. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29812. func (m *UsageStatisticHourMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  29813. if !m.op.Is(OpUpdateOne) {
  29814. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  29815. }
  29816. if m.id == nil || m.oldValue == nil {
  29817. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  29818. }
  29819. oldValue, err := m.oldValue(ctx)
  29820. if err != nil {
  29821. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  29822. }
  29823. return oldValue.UpdatedAt, nil
  29824. }
  29825. // ResetUpdatedAt resets all changes to the "updated_at" field.
  29826. func (m *UsageStatisticHourMutation) ResetUpdatedAt() {
  29827. m.updated_at = nil
  29828. }
  29829. // SetStatus sets the "status" field.
  29830. func (m *UsageStatisticHourMutation) SetStatus(u uint8) {
  29831. m.status = &u
  29832. m.addstatus = nil
  29833. }
  29834. // Status returns the value of the "status" field in the mutation.
  29835. func (m *UsageStatisticHourMutation) Status() (r uint8, exists bool) {
  29836. v := m.status
  29837. if v == nil {
  29838. return
  29839. }
  29840. return *v, true
  29841. }
  29842. // OldStatus returns the old "status" field's value of the UsageStatisticHour entity.
  29843. // If the UsageStatisticHour 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 *UsageStatisticHourMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  29846. if !m.op.Is(OpUpdateOne) {
  29847. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  29848. }
  29849. if m.id == nil || m.oldValue == nil {
  29850. return v, errors.New("OldStatus 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 OldStatus: %w", err)
  29855. }
  29856. return oldValue.Status, nil
  29857. }
  29858. // AddStatus adds u to the "status" field.
  29859. func (m *UsageStatisticHourMutation) AddStatus(u int8) {
  29860. if m.addstatus != nil {
  29861. *m.addstatus += u
  29862. } else {
  29863. m.addstatus = &u
  29864. }
  29865. }
  29866. // AddedStatus returns the value that was added to the "status" field in this mutation.
  29867. func (m *UsageStatisticHourMutation) AddedStatus() (r int8, exists bool) {
  29868. v := m.addstatus
  29869. if v == nil {
  29870. return
  29871. }
  29872. return *v, true
  29873. }
  29874. // ClearStatus clears the value of the "status" field.
  29875. func (m *UsageStatisticHourMutation) ClearStatus() {
  29876. m.status = nil
  29877. m.addstatus = nil
  29878. m.clearedFields[usagestatistichour.FieldStatus] = struct{}{}
  29879. }
  29880. // StatusCleared returns if the "status" field was cleared in this mutation.
  29881. func (m *UsageStatisticHourMutation) StatusCleared() bool {
  29882. _, ok := m.clearedFields[usagestatistichour.FieldStatus]
  29883. return ok
  29884. }
  29885. // ResetStatus resets all changes to the "status" field.
  29886. func (m *UsageStatisticHourMutation) ResetStatus() {
  29887. m.status = nil
  29888. m.addstatus = nil
  29889. delete(m.clearedFields, usagestatistichour.FieldStatus)
  29890. }
  29891. // SetDeletedAt sets the "deleted_at" field.
  29892. func (m *UsageStatisticHourMutation) SetDeletedAt(t time.Time) {
  29893. m.deleted_at = &t
  29894. }
  29895. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  29896. func (m *UsageStatisticHourMutation) DeletedAt() (r time.Time, exists bool) {
  29897. v := m.deleted_at
  29898. if v == nil {
  29899. return
  29900. }
  29901. return *v, true
  29902. }
  29903. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticHour entity.
  29904. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  29905. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29906. func (m *UsageStatisticHourMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  29907. if !m.op.Is(OpUpdateOne) {
  29908. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  29909. }
  29910. if m.id == nil || m.oldValue == nil {
  29911. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  29912. }
  29913. oldValue, err := m.oldValue(ctx)
  29914. if err != nil {
  29915. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  29916. }
  29917. return oldValue.DeletedAt, nil
  29918. }
  29919. // ClearDeletedAt clears the value of the "deleted_at" field.
  29920. func (m *UsageStatisticHourMutation) ClearDeletedAt() {
  29921. m.deleted_at = nil
  29922. m.clearedFields[usagestatistichour.FieldDeletedAt] = struct{}{}
  29923. }
  29924. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  29925. func (m *UsageStatisticHourMutation) DeletedAtCleared() bool {
  29926. _, ok := m.clearedFields[usagestatistichour.FieldDeletedAt]
  29927. return ok
  29928. }
  29929. // ResetDeletedAt resets all changes to the "deleted_at" field.
  29930. func (m *UsageStatisticHourMutation) ResetDeletedAt() {
  29931. m.deleted_at = nil
  29932. delete(m.clearedFields, usagestatistichour.FieldDeletedAt)
  29933. }
  29934. // SetAddtime sets the "addtime" field.
  29935. func (m *UsageStatisticHourMutation) SetAddtime(u uint64) {
  29936. m.addtime = &u
  29937. m.addaddtime = nil
  29938. }
  29939. // Addtime returns the value of the "addtime" field in the mutation.
  29940. func (m *UsageStatisticHourMutation) Addtime() (r uint64, exists bool) {
  29941. v := m.addtime
  29942. if v == nil {
  29943. return
  29944. }
  29945. return *v, true
  29946. }
  29947. // OldAddtime returns the old "addtime" field's value of the UsageStatisticHour entity.
  29948. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  29949. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29950. func (m *UsageStatisticHourMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  29951. if !m.op.Is(OpUpdateOne) {
  29952. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  29953. }
  29954. if m.id == nil || m.oldValue == nil {
  29955. return v, errors.New("OldAddtime requires an ID field in the mutation")
  29956. }
  29957. oldValue, err := m.oldValue(ctx)
  29958. if err != nil {
  29959. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  29960. }
  29961. return oldValue.Addtime, nil
  29962. }
  29963. // AddAddtime adds u to the "addtime" field.
  29964. func (m *UsageStatisticHourMutation) AddAddtime(u int64) {
  29965. if m.addaddtime != nil {
  29966. *m.addaddtime += u
  29967. } else {
  29968. m.addaddtime = &u
  29969. }
  29970. }
  29971. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  29972. func (m *UsageStatisticHourMutation) AddedAddtime() (r int64, exists bool) {
  29973. v := m.addaddtime
  29974. if v == nil {
  29975. return
  29976. }
  29977. return *v, true
  29978. }
  29979. // ResetAddtime resets all changes to the "addtime" field.
  29980. func (m *UsageStatisticHourMutation) ResetAddtime() {
  29981. m.addtime = nil
  29982. m.addaddtime = nil
  29983. }
  29984. // SetType sets the "type" field.
  29985. func (m *UsageStatisticHourMutation) SetType(i int) {
  29986. m._type = &i
  29987. m.add_type = nil
  29988. }
  29989. // GetType returns the value of the "type" field in the mutation.
  29990. func (m *UsageStatisticHourMutation) GetType() (r int, exists bool) {
  29991. v := m._type
  29992. if v == nil {
  29993. return
  29994. }
  29995. return *v, true
  29996. }
  29997. // OldType returns the old "type" field's value of the UsageStatisticHour entity.
  29998. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  29999. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30000. func (m *UsageStatisticHourMutation) OldType(ctx context.Context) (v int, err error) {
  30001. if !m.op.Is(OpUpdateOne) {
  30002. return v, errors.New("OldType is only allowed on UpdateOne operations")
  30003. }
  30004. if m.id == nil || m.oldValue == nil {
  30005. return v, errors.New("OldType requires an ID field in the mutation")
  30006. }
  30007. oldValue, err := m.oldValue(ctx)
  30008. if err != nil {
  30009. return v, fmt.Errorf("querying old value for OldType: %w", err)
  30010. }
  30011. return oldValue.Type, nil
  30012. }
  30013. // AddType adds i to the "type" field.
  30014. func (m *UsageStatisticHourMutation) AddType(i int) {
  30015. if m.add_type != nil {
  30016. *m.add_type += i
  30017. } else {
  30018. m.add_type = &i
  30019. }
  30020. }
  30021. // AddedType returns the value that was added to the "type" field in this mutation.
  30022. func (m *UsageStatisticHourMutation) AddedType() (r int, exists bool) {
  30023. v := m.add_type
  30024. if v == nil {
  30025. return
  30026. }
  30027. return *v, true
  30028. }
  30029. // ResetType resets all changes to the "type" field.
  30030. func (m *UsageStatisticHourMutation) ResetType() {
  30031. m._type = nil
  30032. m.add_type = nil
  30033. }
  30034. // SetBotID sets the "bot_id" field.
  30035. func (m *UsageStatisticHourMutation) SetBotID(s string) {
  30036. m.bot_id = &s
  30037. }
  30038. // BotID returns the value of the "bot_id" field in the mutation.
  30039. func (m *UsageStatisticHourMutation) BotID() (r string, exists bool) {
  30040. v := m.bot_id
  30041. if v == nil {
  30042. return
  30043. }
  30044. return *v, true
  30045. }
  30046. // OldBotID returns the old "bot_id" field's value of the UsageStatisticHour entity.
  30047. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30048. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30049. func (m *UsageStatisticHourMutation) OldBotID(ctx context.Context) (v string, err error) {
  30050. if !m.op.Is(OpUpdateOne) {
  30051. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  30052. }
  30053. if m.id == nil || m.oldValue == nil {
  30054. return v, errors.New("OldBotID requires an ID field in the mutation")
  30055. }
  30056. oldValue, err := m.oldValue(ctx)
  30057. if err != nil {
  30058. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  30059. }
  30060. return oldValue.BotID, nil
  30061. }
  30062. // ClearBotID clears the value of the "bot_id" field.
  30063. func (m *UsageStatisticHourMutation) ClearBotID() {
  30064. m.bot_id = nil
  30065. m.clearedFields[usagestatistichour.FieldBotID] = struct{}{}
  30066. }
  30067. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  30068. func (m *UsageStatisticHourMutation) BotIDCleared() bool {
  30069. _, ok := m.clearedFields[usagestatistichour.FieldBotID]
  30070. return ok
  30071. }
  30072. // ResetBotID resets all changes to the "bot_id" field.
  30073. func (m *UsageStatisticHourMutation) ResetBotID() {
  30074. m.bot_id = nil
  30075. delete(m.clearedFields, usagestatistichour.FieldBotID)
  30076. }
  30077. // SetOrganizationID sets the "organization_id" field.
  30078. func (m *UsageStatisticHourMutation) SetOrganizationID(u uint64) {
  30079. m.organization_id = &u
  30080. m.addorganization_id = nil
  30081. }
  30082. // OrganizationID returns the value of the "organization_id" field in the mutation.
  30083. func (m *UsageStatisticHourMutation) OrganizationID() (r uint64, exists bool) {
  30084. v := m.organization_id
  30085. if v == nil {
  30086. return
  30087. }
  30088. return *v, true
  30089. }
  30090. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticHour entity.
  30091. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30092. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30093. func (m *UsageStatisticHourMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  30094. if !m.op.Is(OpUpdateOne) {
  30095. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  30096. }
  30097. if m.id == nil || m.oldValue == nil {
  30098. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  30099. }
  30100. oldValue, err := m.oldValue(ctx)
  30101. if err != nil {
  30102. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  30103. }
  30104. return oldValue.OrganizationID, nil
  30105. }
  30106. // AddOrganizationID adds u to the "organization_id" field.
  30107. func (m *UsageStatisticHourMutation) AddOrganizationID(u int64) {
  30108. if m.addorganization_id != nil {
  30109. *m.addorganization_id += u
  30110. } else {
  30111. m.addorganization_id = &u
  30112. }
  30113. }
  30114. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  30115. func (m *UsageStatisticHourMutation) AddedOrganizationID() (r int64, exists bool) {
  30116. v := m.addorganization_id
  30117. if v == nil {
  30118. return
  30119. }
  30120. return *v, true
  30121. }
  30122. // ClearOrganizationID clears the value of the "organization_id" field.
  30123. func (m *UsageStatisticHourMutation) ClearOrganizationID() {
  30124. m.organization_id = nil
  30125. m.addorganization_id = nil
  30126. m.clearedFields[usagestatistichour.FieldOrganizationID] = struct{}{}
  30127. }
  30128. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  30129. func (m *UsageStatisticHourMutation) OrganizationIDCleared() bool {
  30130. _, ok := m.clearedFields[usagestatistichour.FieldOrganizationID]
  30131. return ok
  30132. }
  30133. // ResetOrganizationID resets all changes to the "organization_id" field.
  30134. func (m *UsageStatisticHourMutation) ResetOrganizationID() {
  30135. m.organization_id = nil
  30136. m.addorganization_id = nil
  30137. delete(m.clearedFields, usagestatistichour.FieldOrganizationID)
  30138. }
  30139. // SetAiResponse sets the "ai_response" field.
  30140. func (m *UsageStatisticHourMutation) SetAiResponse(u uint64) {
  30141. m.ai_response = &u
  30142. m.addai_response = nil
  30143. }
  30144. // AiResponse returns the value of the "ai_response" field in the mutation.
  30145. func (m *UsageStatisticHourMutation) AiResponse() (r uint64, exists bool) {
  30146. v := m.ai_response
  30147. if v == nil {
  30148. return
  30149. }
  30150. return *v, true
  30151. }
  30152. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticHour entity.
  30153. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30154. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30155. func (m *UsageStatisticHourMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  30156. if !m.op.Is(OpUpdateOne) {
  30157. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  30158. }
  30159. if m.id == nil || m.oldValue == nil {
  30160. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  30161. }
  30162. oldValue, err := m.oldValue(ctx)
  30163. if err != nil {
  30164. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  30165. }
  30166. return oldValue.AiResponse, nil
  30167. }
  30168. // AddAiResponse adds u to the "ai_response" field.
  30169. func (m *UsageStatisticHourMutation) AddAiResponse(u int64) {
  30170. if m.addai_response != nil {
  30171. *m.addai_response += u
  30172. } else {
  30173. m.addai_response = &u
  30174. }
  30175. }
  30176. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  30177. func (m *UsageStatisticHourMutation) AddedAiResponse() (r int64, exists bool) {
  30178. v := m.addai_response
  30179. if v == nil {
  30180. return
  30181. }
  30182. return *v, true
  30183. }
  30184. // ResetAiResponse resets all changes to the "ai_response" field.
  30185. func (m *UsageStatisticHourMutation) ResetAiResponse() {
  30186. m.ai_response = nil
  30187. m.addai_response = nil
  30188. }
  30189. // SetSopRun sets the "sop_run" field.
  30190. func (m *UsageStatisticHourMutation) SetSopRun(u uint64) {
  30191. m.sop_run = &u
  30192. m.addsop_run = nil
  30193. }
  30194. // SopRun returns the value of the "sop_run" field in the mutation.
  30195. func (m *UsageStatisticHourMutation) SopRun() (r uint64, exists bool) {
  30196. v := m.sop_run
  30197. if v == nil {
  30198. return
  30199. }
  30200. return *v, true
  30201. }
  30202. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticHour entity.
  30203. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30204. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30205. func (m *UsageStatisticHourMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  30206. if !m.op.Is(OpUpdateOne) {
  30207. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  30208. }
  30209. if m.id == nil || m.oldValue == nil {
  30210. return v, errors.New("OldSopRun requires an ID field in the mutation")
  30211. }
  30212. oldValue, err := m.oldValue(ctx)
  30213. if err != nil {
  30214. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  30215. }
  30216. return oldValue.SopRun, nil
  30217. }
  30218. // AddSopRun adds u to the "sop_run" field.
  30219. func (m *UsageStatisticHourMutation) AddSopRun(u int64) {
  30220. if m.addsop_run != nil {
  30221. *m.addsop_run += u
  30222. } else {
  30223. m.addsop_run = &u
  30224. }
  30225. }
  30226. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  30227. func (m *UsageStatisticHourMutation) AddedSopRun() (r int64, exists bool) {
  30228. v := m.addsop_run
  30229. if v == nil {
  30230. return
  30231. }
  30232. return *v, true
  30233. }
  30234. // ResetSopRun resets all changes to the "sop_run" field.
  30235. func (m *UsageStatisticHourMutation) ResetSopRun() {
  30236. m.sop_run = nil
  30237. m.addsop_run = nil
  30238. }
  30239. // SetTotalFriend sets the "total_friend" field.
  30240. func (m *UsageStatisticHourMutation) SetTotalFriend(u uint64) {
  30241. m.total_friend = &u
  30242. m.addtotal_friend = nil
  30243. }
  30244. // TotalFriend returns the value of the "total_friend" field in the mutation.
  30245. func (m *UsageStatisticHourMutation) TotalFriend() (r uint64, exists bool) {
  30246. v := m.total_friend
  30247. if v == nil {
  30248. return
  30249. }
  30250. return *v, true
  30251. }
  30252. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticHour entity.
  30253. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30254. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30255. func (m *UsageStatisticHourMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  30256. if !m.op.Is(OpUpdateOne) {
  30257. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  30258. }
  30259. if m.id == nil || m.oldValue == nil {
  30260. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  30261. }
  30262. oldValue, err := m.oldValue(ctx)
  30263. if err != nil {
  30264. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  30265. }
  30266. return oldValue.TotalFriend, nil
  30267. }
  30268. // AddTotalFriend adds u to the "total_friend" field.
  30269. func (m *UsageStatisticHourMutation) AddTotalFriend(u int64) {
  30270. if m.addtotal_friend != nil {
  30271. *m.addtotal_friend += u
  30272. } else {
  30273. m.addtotal_friend = &u
  30274. }
  30275. }
  30276. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  30277. func (m *UsageStatisticHourMutation) AddedTotalFriend() (r int64, exists bool) {
  30278. v := m.addtotal_friend
  30279. if v == nil {
  30280. return
  30281. }
  30282. return *v, true
  30283. }
  30284. // ResetTotalFriend resets all changes to the "total_friend" field.
  30285. func (m *UsageStatisticHourMutation) ResetTotalFriend() {
  30286. m.total_friend = nil
  30287. m.addtotal_friend = nil
  30288. }
  30289. // SetTotalGroup sets the "total_group" field.
  30290. func (m *UsageStatisticHourMutation) SetTotalGroup(u uint64) {
  30291. m.total_group = &u
  30292. m.addtotal_group = nil
  30293. }
  30294. // TotalGroup returns the value of the "total_group" field in the mutation.
  30295. func (m *UsageStatisticHourMutation) TotalGroup() (r uint64, exists bool) {
  30296. v := m.total_group
  30297. if v == nil {
  30298. return
  30299. }
  30300. return *v, true
  30301. }
  30302. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticHour entity.
  30303. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30304. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30305. func (m *UsageStatisticHourMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  30306. if !m.op.Is(OpUpdateOne) {
  30307. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  30308. }
  30309. if m.id == nil || m.oldValue == nil {
  30310. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  30311. }
  30312. oldValue, err := m.oldValue(ctx)
  30313. if err != nil {
  30314. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  30315. }
  30316. return oldValue.TotalGroup, nil
  30317. }
  30318. // AddTotalGroup adds u to the "total_group" field.
  30319. func (m *UsageStatisticHourMutation) AddTotalGroup(u int64) {
  30320. if m.addtotal_group != nil {
  30321. *m.addtotal_group += u
  30322. } else {
  30323. m.addtotal_group = &u
  30324. }
  30325. }
  30326. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  30327. func (m *UsageStatisticHourMutation) AddedTotalGroup() (r int64, exists bool) {
  30328. v := m.addtotal_group
  30329. if v == nil {
  30330. return
  30331. }
  30332. return *v, true
  30333. }
  30334. // ResetTotalGroup resets all changes to the "total_group" field.
  30335. func (m *UsageStatisticHourMutation) ResetTotalGroup() {
  30336. m.total_group = nil
  30337. m.addtotal_group = nil
  30338. }
  30339. // SetAccountBalance sets the "account_balance" field.
  30340. func (m *UsageStatisticHourMutation) SetAccountBalance(u uint64) {
  30341. m.account_balance = &u
  30342. m.addaccount_balance = nil
  30343. }
  30344. // AccountBalance returns the value of the "account_balance" field in the mutation.
  30345. func (m *UsageStatisticHourMutation) AccountBalance() (r uint64, exists bool) {
  30346. v := m.account_balance
  30347. if v == nil {
  30348. return
  30349. }
  30350. return *v, true
  30351. }
  30352. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticHour entity.
  30353. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30354. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30355. func (m *UsageStatisticHourMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  30356. if !m.op.Is(OpUpdateOne) {
  30357. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  30358. }
  30359. if m.id == nil || m.oldValue == nil {
  30360. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  30361. }
  30362. oldValue, err := m.oldValue(ctx)
  30363. if err != nil {
  30364. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  30365. }
  30366. return oldValue.AccountBalance, nil
  30367. }
  30368. // AddAccountBalance adds u to the "account_balance" field.
  30369. func (m *UsageStatisticHourMutation) AddAccountBalance(u int64) {
  30370. if m.addaccount_balance != nil {
  30371. *m.addaccount_balance += u
  30372. } else {
  30373. m.addaccount_balance = &u
  30374. }
  30375. }
  30376. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  30377. func (m *UsageStatisticHourMutation) AddedAccountBalance() (r int64, exists bool) {
  30378. v := m.addaccount_balance
  30379. if v == nil {
  30380. return
  30381. }
  30382. return *v, true
  30383. }
  30384. // ResetAccountBalance resets all changes to the "account_balance" field.
  30385. func (m *UsageStatisticHourMutation) ResetAccountBalance() {
  30386. m.account_balance = nil
  30387. m.addaccount_balance = nil
  30388. }
  30389. // SetConsumeToken sets the "consume_token" field.
  30390. func (m *UsageStatisticHourMutation) SetConsumeToken(u uint64) {
  30391. m.consume_token = &u
  30392. m.addconsume_token = nil
  30393. }
  30394. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  30395. func (m *UsageStatisticHourMutation) ConsumeToken() (r uint64, exists bool) {
  30396. v := m.consume_token
  30397. if v == nil {
  30398. return
  30399. }
  30400. return *v, true
  30401. }
  30402. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticHour entity.
  30403. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30404. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30405. func (m *UsageStatisticHourMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  30406. if !m.op.Is(OpUpdateOne) {
  30407. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  30408. }
  30409. if m.id == nil || m.oldValue == nil {
  30410. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  30411. }
  30412. oldValue, err := m.oldValue(ctx)
  30413. if err != nil {
  30414. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  30415. }
  30416. return oldValue.ConsumeToken, nil
  30417. }
  30418. // AddConsumeToken adds u to the "consume_token" field.
  30419. func (m *UsageStatisticHourMutation) AddConsumeToken(u int64) {
  30420. if m.addconsume_token != nil {
  30421. *m.addconsume_token += u
  30422. } else {
  30423. m.addconsume_token = &u
  30424. }
  30425. }
  30426. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  30427. func (m *UsageStatisticHourMutation) AddedConsumeToken() (r int64, exists bool) {
  30428. v := m.addconsume_token
  30429. if v == nil {
  30430. return
  30431. }
  30432. return *v, true
  30433. }
  30434. // ResetConsumeToken resets all changes to the "consume_token" field.
  30435. func (m *UsageStatisticHourMutation) ResetConsumeToken() {
  30436. m.consume_token = nil
  30437. m.addconsume_token = nil
  30438. }
  30439. // SetActiveUser sets the "active_user" field.
  30440. func (m *UsageStatisticHourMutation) SetActiveUser(u uint64) {
  30441. m.active_user = &u
  30442. m.addactive_user = nil
  30443. }
  30444. // ActiveUser returns the value of the "active_user" field in the mutation.
  30445. func (m *UsageStatisticHourMutation) ActiveUser() (r uint64, exists bool) {
  30446. v := m.active_user
  30447. if v == nil {
  30448. return
  30449. }
  30450. return *v, true
  30451. }
  30452. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticHour entity.
  30453. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30454. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30455. func (m *UsageStatisticHourMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  30456. if !m.op.Is(OpUpdateOne) {
  30457. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  30458. }
  30459. if m.id == nil || m.oldValue == nil {
  30460. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  30461. }
  30462. oldValue, err := m.oldValue(ctx)
  30463. if err != nil {
  30464. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  30465. }
  30466. return oldValue.ActiveUser, nil
  30467. }
  30468. // AddActiveUser adds u to the "active_user" field.
  30469. func (m *UsageStatisticHourMutation) AddActiveUser(u int64) {
  30470. if m.addactive_user != nil {
  30471. *m.addactive_user += u
  30472. } else {
  30473. m.addactive_user = &u
  30474. }
  30475. }
  30476. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  30477. func (m *UsageStatisticHourMutation) AddedActiveUser() (r int64, exists bool) {
  30478. v := m.addactive_user
  30479. if v == nil {
  30480. return
  30481. }
  30482. return *v, true
  30483. }
  30484. // ResetActiveUser resets all changes to the "active_user" field.
  30485. func (m *UsageStatisticHourMutation) ResetActiveUser() {
  30486. m.active_user = nil
  30487. m.addactive_user = nil
  30488. }
  30489. // SetNewUser sets the "new_user" field.
  30490. func (m *UsageStatisticHourMutation) SetNewUser(i int64) {
  30491. m.new_user = &i
  30492. m.addnew_user = nil
  30493. }
  30494. // NewUser returns the value of the "new_user" field in the mutation.
  30495. func (m *UsageStatisticHourMutation) NewUser() (r int64, exists bool) {
  30496. v := m.new_user
  30497. if v == nil {
  30498. return
  30499. }
  30500. return *v, true
  30501. }
  30502. // OldNewUser returns the old "new_user" field's value of the UsageStatisticHour entity.
  30503. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30504. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30505. func (m *UsageStatisticHourMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  30506. if !m.op.Is(OpUpdateOne) {
  30507. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  30508. }
  30509. if m.id == nil || m.oldValue == nil {
  30510. return v, errors.New("OldNewUser requires an ID field in the mutation")
  30511. }
  30512. oldValue, err := m.oldValue(ctx)
  30513. if err != nil {
  30514. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  30515. }
  30516. return oldValue.NewUser, nil
  30517. }
  30518. // AddNewUser adds i to the "new_user" field.
  30519. func (m *UsageStatisticHourMutation) AddNewUser(i int64) {
  30520. if m.addnew_user != nil {
  30521. *m.addnew_user += i
  30522. } else {
  30523. m.addnew_user = &i
  30524. }
  30525. }
  30526. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  30527. func (m *UsageStatisticHourMutation) AddedNewUser() (r int64, exists bool) {
  30528. v := m.addnew_user
  30529. if v == nil {
  30530. return
  30531. }
  30532. return *v, true
  30533. }
  30534. // ResetNewUser resets all changes to the "new_user" field.
  30535. func (m *UsageStatisticHourMutation) ResetNewUser() {
  30536. m.new_user = nil
  30537. m.addnew_user = nil
  30538. }
  30539. // SetLabelDist sets the "label_dist" field.
  30540. func (m *UsageStatisticHourMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  30541. m.label_dist = &ctd
  30542. m.appendlabel_dist = nil
  30543. }
  30544. // LabelDist returns the value of the "label_dist" field in the mutation.
  30545. func (m *UsageStatisticHourMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  30546. v := m.label_dist
  30547. if v == nil {
  30548. return
  30549. }
  30550. return *v, true
  30551. }
  30552. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticHour entity.
  30553. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30554. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30555. func (m *UsageStatisticHourMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  30556. if !m.op.Is(OpUpdateOne) {
  30557. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  30558. }
  30559. if m.id == nil || m.oldValue == nil {
  30560. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  30561. }
  30562. oldValue, err := m.oldValue(ctx)
  30563. if err != nil {
  30564. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  30565. }
  30566. return oldValue.LabelDist, nil
  30567. }
  30568. // AppendLabelDist adds ctd to the "label_dist" field.
  30569. func (m *UsageStatisticHourMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  30570. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  30571. }
  30572. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  30573. func (m *UsageStatisticHourMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  30574. if len(m.appendlabel_dist) == 0 {
  30575. return nil, false
  30576. }
  30577. return m.appendlabel_dist, true
  30578. }
  30579. // ResetLabelDist resets all changes to the "label_dist" field.
  30580. func (m *UsageStatisticHourMutation) ResetLabelDist() {
  30581. m.label_dist = nil
  30582. m.appendlabel_dist = nil
  30583. }
  30584. // Where appends a list predicates to the UsageStatisticHourMutation builder.
  30585. func (m *UsageStatisticHourMutation) Where(ps ...predicate.UsageStatisticHour) {
  30586. m.predicates = append(m.predicates, ps...)
  30587. }
  30588. // WhereP appends storage-level predicates to the UsageStatisticHourMutation builder. Using this method,
  30589. // users can use type-assertion to append predicates that do not depend on any generated package.
  30590. func (m *UsageStatisticHourMutation) WhereP(ps ...func(*sql.Selector)) {
  30591. p := make([]predicate.UsageStatisticHour, len(ps))
  30592. for i := range ps {
  30593. p[i] = ps[i]
  30594. }
  30595. m.Where(p...)
  30596. }
  30597. // Op returns the operation name.
  30598. func (m *UsageStatisticHourMutation) Op() Op {
  30599. return m.op
  30600. }
  30601. // SetOp allows setting the mutation operation.
  30602. func (m *UsageStatisticHourMutation) SetOp(op Op) {
  30603. m.op = op
  30604. }
  30605. // Type returns the node type of this mutation (UsageStatisticHour).
  30606. func (m *UsageStatisticHourMutation) Type() string {
  30607. return m.typ
  30608. }
  30609. // Fields returns all fields that were changed during this mutation. Note that in
  30610. // order to get all numeric fields that were incremented/decremented, call
  30611. // AddedFields().
  30612. func (m *UsageStatisticHourMutation) Fields() []string {
  30613. fields := make([]string, 0, 17)
  30614. if m.created_at != nil {
  30615. fields = append(fields, usagestatistichour.FieldCreatedAt)
  30616. }
  30617. if m.updated_at != nil {
  30618. fields = append(fields, usagestatistichour.FieldUpdatedAt)
  30619. }
  30620. if m.status != nil {
  30621. fields = append(fields, usagestatistichour.FieldStatus)
  30622. }
  30623. if m.deleted_at != nil {
  30624. fields = append(fields, usagestatistichour.FieldDeletedAt)
  30625. }
  30626. if m.addtime != nil {
  30627. fields = append(fields, usagestatistichour.FieldAddtime)
  30628. }
  30629. if m._type != nil {
  30630. fields = append(fields, usagestatistichour.FieldType)
  30631. }
  30632. if m.bot_id != nil {
  30633. fields = append(fields, usagestatistichour.FieldBotID)
  30634. }
  30635. if m.organization_id != nil {
  30636. fields = append(fields, usagestatistichour.FieldOrganizationID)
  30637. }
  30638. if m.ai_response != nil {
  30639. fields = append(fields, usagestatistichour.FieldAiResponse)
  30640. }
  30641. if m.sop_run != nil {
  30642. fields = append(fields, usagestatistichour.FieldSopRun)
  30643. }
  30644. if m.total_friend != nil {
  30645. fields = append(fields, usagestatistichour.FieldTotalFriend)
  30646. }
  30647. if m.total_group != nil {
  30648. fields = append(fields, usagestatistichour.FieldTotalGroup)
  30649. }
  30650. if m.account_balance != nil {
  30651. fields = append(fields, usagestatistichour.FieldAccountBalance)
  30652. }
  30653. if m.consume_token != nil {
  30654. fields = append(fields, usagestatistichour.FieldConsumeToken)
  30655. }
  30656. if m.active_user != nil {
  30657. fields = append(fields, usagestatistichour.FieldActiveUser)
  30658. }
  30659. if m.new_user != nil {
  30660. fields = append(fields, usagestatistichour.FieldNewUser)
  30661. }
  30662. if m.label_dist != nil {
  30663. fields = append(fields, usagestatistichour.FieldLabelDist)
  30664. }
  30665. return fields
  30666. }
  30667. // Field returns the value of a field with the given name. The second boolean
  30668. // return value indicates that this field was not set, or was not defined in the
  30669. // schema.
  30670. func (m *UsageStatisticHourMutation) Field(name string) (ent.Value, bool) {
  30671. switch name {
  30672. case usagestatistichour.FieldCreatedAt:
  30673. return m.CreatedAt()
  30674. case usagestatistichour.FieldUpdatedAt:
  30675. return m.UpdatedAt()
  30676. case usagestatistichour.FieldStatus:
  30677. return m.Status()
  30678. case usagestatistichour.FieldDeletedAt:
  30679. return m.DeletedAt()
  30680. case usagestatistichour.FieldAddtime:
  30681. return m.Addtime()
  30682. case usagestatistichour.FieldType:
  30683. return m.GetType()
  30684. case usagestatistichour.FieldBotID:
  30685. return m.BotID()
  30686. case usagestatistichour.FieldOrganizationID:
  30687. return m.OrganizationID()
  30688. case usagestatistichour.FieldAiResponse:
  30689. return m.AiResponse()
  30690. case usagestatistichour.FieldSopRun:
  30691. return m.SopRun()
  30692. case usagestatistichour.FieldTotalFriend:
  30693. return m.TotalFriend()
  30694. case usagestatistichour.FieldTotalGroup:
  30695. return m.TotalGroup()
  30696. case usagestatistichour.FieldAccountBalance:
  30697. return m.AccountBalance()
  30698. case usagestatistichour.FieldConsumeToken:
  30699. return m.ConsumeToken()
  30700. case usagestatistichour.FieldActiveUser:
  30701. return m.ActiveUser()
  30702. case usagestatistichour.FieldNewUser:
  30703. return m.NewUser()
  30704. case usagestatistichour.FieldLabelDist:
  30705. return m.LabelDist()
  30706. }
  30707. return nil, false
  30708. }
  30709. // OldField returns the old value of the field from the database. An error is
  30710. // returned if the mutation operation is not UpdateOne, or the query to the
  30711. // database failed.
  30712. func (m *UsageStatisticHourMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  30713. switch name {
  30714. case usagestatistichour.FieldCreatedAt:
  30715. return m.OldCreatedAt(ctx)
  30716. case usagestatistichour.FieldUpdatedAt:
  30717. return m.OldUpdatedAt(ctx)
  30718. case usagestatistichour.FieldStatus:
  30719. return m.OldStatus(ctx)
  30720. case usagestatistichour.FieldDeletedAt:
  30721. return m.OldDeletedAt(ctx)
  30722. case usagestatistichour.FieldAddtime:
  30723. return m.OldAddtime(ctx)
  30724. case usagestatistichour.FieldType:
  30725. return m.OldType(ctx)
  30726. case usagestatistichour.FieldBotID:
  30727. return m.OldBotID(ctx)
  30728. case usagestatistichour.FieldOrganizationID:
  30729. return m.OldOrganizationID(ctx)
  30730. case usagestatistichour.FieldAiResponse:
  30731. return m.OldAiResponse(ctx)
  30732. case usagestatistichour.FieldSopRun:
  30733. return m.OldSopRun(ctx)
  30734. case usagestatistichour.FieldTotalFriend:
  30735. return m.OldTotalFriend(ctx)
  30736. case usagestatistichour.FieldTotalGroup:
  30737. return m.OldTotalGroup(ctx)
  30738. case usagestatistichour.FieldAccountBalance:
  30739. return m.OldAccountBalance(ctx)
  30740. case usagestatistichour.FieldConsumeToken:
  30741. return m.OldConsumeToken(ctx)
  30742. case usagestatistichour.FieldActiveUser:
  30743. return m.OldActiveUser(ctx)
  30744. case usagestatistichour.FieldNewUser:
  30745. return m.OldNewUser(ctx)
  30746. case usagestatistichour.FieldLabelDist:
  30747. return m.OldLabelDist(ctx)
  30748. }
  30749. return nil, fmt.Errorf("unknown UsageStatisticHour field %s", name)
  30750. }
  30751. // SetField sets the value of a field with the given name. It returns an error if
  30752. // the field is not defined in the schema, or if the type mismatched the field
  30753. // type.
  30754. func (m *UsageStatisticHourMutation) SetField(name string, value ent.Value) error {
  30755. switch name {
  30756. case usagestatistichour.FieldCreatedAt:
  30757. v, ok := value.(time.Time)
  30758. if !ok {
  30759. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30760. }
  30761. m.SetCreatedAt(v)
  30762. return nil
  30763. case usagestatistichour.FieldUpdatedAt:
  30764. v, ok := value.(time.Time)
  30765. if !ok {
  30766. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30767. }
  30768. m.SetUpdatedAt(v)
  30769. return nil
  30770. case usagestatistichour.FieldStatus:
  30771. v, ok := value.(uint8)
  30772. if !ok {
  30773. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30774. }
  30775. m.SetStatus(v)
  30776. return nil
  30777. case usagestatistichour.FieldDeletedAt:
  30778. v, ok := value.(time.Time)
  30779. if !ok {
  30780. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30781. }
  30782. m.SetDeletedAt(v)
  30783. return nil
  30784. case usagestatistichour.FieldAddtime:
  30785. v, ok := value.(uint64)
  30786. if !ok {
  30787. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30788. }
  30789. m.SetAddtime(v)
  30790. return nil
  30791. case usagestatistichour.FieldType:
  30792. v, ok := value.(int)
  30793. if !ok {
  30794. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30795. }
  30796. m.SetType(v)
  30797. return nil
  30798. case usagestatistichour.FieldBotID:
  30799. v, ok := value.(string)
  30800. if !ok {
  30801. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30802. }
  30803. m.SetBotID(v)
  30804. return nil
  30805. case usagestatistichour.FieldOrganizationID:
  30806. v, ok := value.(uint64)
  30807. if !ok {
  30808. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30809. }
  30810. m.SetOrganizationID(v)
  30811. return nil
  30812. case usagestatistichour.FieldAiResponse:
  30813. v, ok := value.(uint64)
  30814. if !ok {
  30815. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30816. }
  30817. m.SetAiResponse(v)
  30818. return nil
  30819. case usagestatistichour.FieldSopRun:
  30820. v, ok := value.(uint64)
  30821. if !ok {
  30822. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30823. }
  30824. m.SetSopRun(v)
  30825. return nil
  30826. case usagestatistichour.FieldTotalFriend:
  30827. v, ok := value.(uint64)
  30828. if !ok {
  30829. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30830. }
  30831. m.SetTotalFriend(v)
  30832. return nil
  30833. case usagestatistichour.FieldTotalGroup:
  30834. v, ok := value.(uint64)
  30835. if !ok {
  30836. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30837. }
  30838. m.SetTotalGroup(v)
  30839. return nil
  30840. case usagestatistichour.FieldAccountBalance:
  30841. v, ok := value.(uint64)
  30842. if !ok {
  30843. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30844. }
  30845. m.SetAccountBalance(v)
  30846. return nil
  30847. case usagestatistichour.FieldConsumeToken:
  30848. v, ok := value.(uint64)
  30849. if !ok {
  30850. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30851. }
  30852. m.SetConsumeToken(v)
  30853. return nil
  30854. case usagestatistichour.FieldActiveUser:
  30855. v, ok := value.(uint64)
  30856. if !ok {
  30857. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30858. }
  30859. m.SetActiveUser(v)
  30860. return nil
  30861. case usagestatistichour.FieldNewUser:
  30862. v, ok := value.(int64)
  30863. if !ok {
  30864. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30865. }
  30866. m.SetNewUser(v)
  30867. return nil
  30868. case usagestatistichour.FieldLabelDist:
  30869. v, ok := value.([]custom_types.LabelDist)
  30870. if !ok {
  30871. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30872. }
  30873. m.SetLabelDist(v)
  30874. return nil
  30875. }
  30876. return fmt.Errorf("unknown UsageStatisticHour field %s", name)
  30877. }
  30878. // AddedFields returns all numeric fields that were incremented/decremented during
  30879. // this mutation.
  30880. func (m *UsageStatisticHourMutation) AddedFields() []string {
  30881. var fields []string
  30882. if m.addstatus != nil {
  30883. fields = append(fields, usagestatistichour.FieldStatus)
  30884. }
  30885. if m.addaddtime != nil {
  30886. fields = append(fields, usagestatistichour.FieldAddtime)
  30887. }
  30888. if m.add_type != nil {
  30889. fields = append(fields, usagestatistichour.FieldType)
  30890. }
  30891. if m.addorganization_id != nil {
  30892. fields = append(fields, usagestatistichour.FieldOrganizationID)
  30893. }
  30894. if m.addai_response != nil {
  30895. fields = append(fields, usagestatistichour.FieldAiResponse)
  30896. }
  30897. if m.addsop_run != nil {
  30898. fields = append(fields, usagestatistichour.FieldSopRun)
  30899. }
  30900. if m.addtotal_friend != nil {
  30901. fields = append(fields, usagestatistichour.FieldTotalFriend)
  30902. }
  30903. if m.addtotal_group != nil {
  30904. fields = append(fields, usagestatistichour.FieldTotalGroup)
  30905. }
  30906. if m.addaccount_balance != nil {
  30907. fields = append(fields, usagestatistichour.FieldAccountBalance)
  30908. }
  30909. if m.addconsume_token != nil {
  30910. fields = append(fields, usagestatistichour.FieldConsumeToken)
  30911. }
  30912. if m.addactive_user != nil {
  30913. fields = append(fields, usagestatistichour.FieldActiveUser)
  30914. }
  30915. if m.addnew_user != nil {
  30916. fields = append(fields, usagestatistichour.FieldNewUser)
  30917. }
  30918. return fields
  30919. }
  30920. // AddedField returns the numeric value that was incremented/decremented on a field
  30921. // with the given name. The second boolean return value indicates that this field
  30922. // was not set, or was not defined in the schema.
  30923. func (m *UsageStatisticHourMutation) AddedField(name string) (ent.Value, bool) {
  30924. switch name {
  30925. case usagestatistichour.FieldStatus:
  30926. return m.AddedStatus()
  30927. case usagestatistichour.FieldAddtime:
  30928. return m.AddedAddtime()
  30929. case usagestatistichour.FieldType:
  30930. return m.AddedType()
  30931. case usagestatistichour.FieldOrganizationID:
  30932. return m.AddedOrganizationID()
  30933. case usagestatistichour.FieldAiResponse:
  30934. return m.AddedAiResponse()
  30935. case usagestatistichour.FieldSopRun:
  30936. return m.AddedSopRun()
  30937. case usagestatistichour.FieldTotalFriend:
  30938. return m.AddedTotalFriend()
  30939. case usagestatistichour.FieldTotalGroup:
  30940. return m.AddedTotalGroup()
  30941. case usagestatistichour.FieldAccountBalance:
  30942. return m.AddedAccountBalance()
  30943. case usagestatistichour.FieldConsumeToken:
  30944. return m.AddedConsumeToken()
  30945. case usagestatistichour.FieldActiveUser:
  30946. return m.AddedActiveUser()
  30947. case usagestatistichour.FieldNewUser:
  30948. return m.AddedNewUser()
  30949. }
  30950. return nil, false
  30951. }
  30952. // AddField adds the value to the field with the given name. It returns an error if
  30953. // the field is not defined in the schema, or if the type mismatched the field
  30954. // type.
  30955. func (m *UsageStatisticHourMutation) AddField(name string, value ent.Value) error {
  30956. switch name {
  30957. case usagestatistichour.FieldStatus:
  30958. v, ok := value.(int8)
  30959. if !ok {
  30960. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30961. }
  30962. m.AddStatus(v)
  30963. return nil
  30964. case usagestatistichour.FieldAddtime:
  30965. v, ok := value.(int64)
  30966. if !ok {
  30967. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30968. }
  30969. m.AddAddtime(v)
  30970. return nil
  30971. case usagestatistichour.FieldType:
  30972. v, ok := value.(int)
  30973. if !ok {
  30974. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30975. }
  30976. m.AddType(v)
  30977. return nil
  30978. case usagestatistichour.FieldOrganizationID:
  30979. v, ok := value.(int64)
  30980. if !ok {
  30981. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30982. }
  30983. m.AddOrganizationID(v)
  30984. return nil
  30985. case usagestatistichour.FieldAiResponse:
  30986. v, ok := value.(int64)
  30987. if !ok {
  30988. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30989. }
  30990. m.AddAiResponse(v)
  30991. return nil
  30992. case usagestatistichour.FieldSopRun:
  30993. v, ok := value.(int64)
  30994. if !ok {
  30995. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30996. }
  30997. m.AddSopRun(v)
  30998. return nil
  30999. case usagestatistichour.FieldTotalFriend:
  31000. v, ok := value.(int64)
  31001. if !ok {
  31002. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31003. }
  31004. m.AddTotalFriend(v)
  31005. return nil
  31006. case usagestatistichour.FieldTotalGroup:
  31007. v, ok := value.(int64)
  31008. if !ok {
  31009. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31010. }
  31011. m.AddTotalGroup(v)
  31012. return nil
  31013. case usagestatistichour.FieldAccountBalance:
  31014. v, ok := value.(int64)
  31015. if !ok {
  31016. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31017. }
  31018. m.AddAccountBalance(v)
  31019. return nil
  31020. case usagestatistichour.FieldConsumeToken:
  31021. v, ok := value.(int64)
  31022. if !ok {
  31023. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31024. }
  31025. m.AddConsumeToken(v)
  31026. return nil
  31027. case usagestatistichour.FieldActiveUser:
  31028. v, ok := value.(int64)
  31029. if !ok {
  31030. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31031. }
  31032. m.AddActiveUser(v)
  31033. return nil
  31034. case usagestatistichour.FieldNewUser:
  31035. v, ok := value.(int64)
  31036. if !ok {
  31037. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31038. }
  31039. m.AddNewUser(v)
  31040. return nil
  31041. }
  31042. return fmt.Errorf("unknown UsageStatisticHour numeric field %s", name)
  31043. }
  31044. // ClearedFields returns all nullable fields that were cleared during this
  31045. // mutation.
  31046. func (m *UsageStatisticHourMutation) ClearedFields() []string {
  31047. var fields []string
  31048. if m.FieldCleared(usagestatistichour.FieldStatus) {
  31049. fields = append(fields, usagestatistichour.FieldStatus)
  31050. }
  31051. if m.FieldCleared(usagestatistichour.FieldDeletedAt) {
  31052. fields = append(fields, usagestatistichour.FieldDeletedAt)
  31053. }
  31054. if m.FieldCleared(usagestatistichour.FieldBotID) {
  31055. fields = append(fields, usagestatistichour.FieldBotID)
  31056. }
  31057. if m.FieldCleared(usagestatistichour.FieldOrganizationID) {
  31058. fields = append(fields, usagestatistichour.FieldOrganizationID)
  31059. }
  31060. return fields
  31061. }
  31062. // FieldCleared returns a boolean indicating if a field with the given name was
  31063. // cleared in this mutation.
  31064. func (m *UsageStatisticHourMutation) FieldCleared(name string) bool {
  31065. _, ok := m.clearedFields[name]
  31066. return ok
  31067. }
  31068. // ClearField clears the value of the field with the given name. It returns an
  31069. // error if the field is not defined in the schema.
  31070. func (m *UsageStatisticHourMutation) ClearField(name string) error {
  31071. switch name {
  31072. case usagestatistichour.FieldStatus:
  31073. m.ClearStatus()
  31074. return nil
  31075. case usagestatistichour.FieldDeletedAt:
  31076. m.ClearDeletedAt()
  31077. return nil
  31078. case usagestatistichour.FieldBotID:
  31079. m.ClearBotID()
  31080. return nil
  31081. case usagestatistichour.FieldOrganizationID:
  31082. m.ClearOrganizationID()
  31083. return nil
  31084. }
  31085. return fmt.Errorf("unknown UsageStatisticHour nullable field %s", name)
  31086. }
  31087. // ResetField resets all changes in the mutation for the field with the given name.
  31088. // It returns an error if the field is not defined in the schema.
  31089. func (m *UsageStatisticHourMutation) ResetField(name string) error {
  31090. switch name {
  31091. case usagestatistichour.FieldCreatedAt:
  31092. m.ResetCreatedAt()
  31093. return nil
  31094. case usagestatistichour.FieldUpdatedAt:
  31095. m.ResetUpdatedAt()
  31096. return nil
  31097. case usagestatistichour.FieldStatus:
  31098. m.ResetStatus()
  31099. return nil
  31100. case usagestatistichour.FieldDeletedAt:
  31101. m.ResetDeletedAt()
  31102. return nil
  31103. case usagestatistichour.FieldAddtime:
  31104. m.ResetAddtime()
  31105. return nil
  31106. case usagestatistichour.FieldType:
  31107. m.ResetType()
  31108. return nil
  31109. case usagestatistichour.FieldBotID:
  31110. m.ResetBotID()
  31111. return nil
  31112. case usagestatistichour.FieldOrganizationID:
  31113. m.ResetOrganizationID()
  31114. return nil
  31115. case usagestatistichour.FieldAiResponse:
  31116. m.ResetAiResponse()
  31117. return nil
  31118. case usagestatistichour.FieldSopRun:
  31119. m.ResetSopRun()
  31120. return nil
  31121. case usagestatistichour.FieldTotalFriend:
  31122. m.ResetTotalFriend()
  31123. return nil
  31124. case usagestatistichour.FieldTotalGroup:
  31125. m.ResetTotalGroup()
  31126. return nil
  31127. case usagestatistichour.FieldAccountBalance:
  31128. m.ResetAccountBalance()
  31129. return nil
  31130. case usagestatistichour.FieldConsumeToken:
  31131. m.ResetConsumeToken()
  31132. return nil
  31133. case usagestatistichour.FieldActiveUser:
  31134. m.ResetActiveUser()
  31135. return nil
  31136. case usagestatistichour.FieldNewUser:
  31137. m.ResetNewUser()
  31138. return nil
  31139. case usagestatistichour.FieldLabelDist:
  31140. m.ResetLabelDist()
  31141. return nil
  31142. }
  31143. return fmt.Errorf("unknown UsageStatisticHour field %s", name)
  31144. }
  31145. // AddedEdges returns all edge names that were set/added in this mutation.
  31146. func (m *UsageStatisticHourMutation) AddedEdges() []string {
  31147. edges := make([]string, 0, 0)
  31148. return edges
  31149. }
  31150. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  31151. // name in this mutation.
  31152. func (m *UsageStatisticHourMutation) AddedIDs(name string) []ent.Value {
  31153. return nil
  31154. }
  31155. // RemovedEdges returns all edge names that were removed in this mutation.
  31156. func (m *UsageStatisticHourMutation) RemovedEdges() []string {
  31157. edges := make([]string, 0, 0)
  31158. return edges
  31159. }
  31160. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  31161. // the given name in this mutation.
  31162. func (m *UsageStatisticHourMutation) RemovedIDs(name string) []ent.Value {
  31163. return nil
  31164. }
  31165. // ClearedEdges returns all edge names that were cleared in this mutation.
  31166. func (m *UsageStatisticHourMutation) ClearedEdges() []string {
  31167. edges := make([]string, 0, 0)
  31168. return edges
  31169. }
  31170. // EdgeCleared returns a boolean which indicates if the edge with the given name
  31171. // was cleared in this mutation.
  31172. func (m *UsageStatisticHourMutation) EdgeCleared(name string) bool {
  31173. return false
  31174. }
  31175. // ClearEdge clears the value of the edge with the given name. It returns an error
  31176. // if that edge is not defined in the schema.
  31177. func (m *UsageStatisticHourMutation) ClearEdge(name string) error {
  31178. return fmt.Errorf("unknown UsageStatisticHour unique edge %s", name)
  31179. }
  31180. // ResetEdge resets all changes to the edge with the given name in this mutation.
  31181. // It returns an error if the edge is not defined in the schema.
  31182. func (m *UsageStatisticHourMutation) ResetEdge(name string) error {
  31183. return fmt.Errorf("unknown UsageStatisticHour edge %s", name)
  31184. }
  31185. // UsageStatisticMonthMutation represents an operation that mutates the UsageStatisticMonth nodes in the graph.
  31186. type UsageStatisticMonthMutation struct {
  31187. config
  31188. op Op
  31189. typ string
  31190. id *uint64
  31191. created_at *time.Time
  31192. updated_at *time.Time
  31193. status *uint8
  31194. addstatus *int8
  31195. deleted_at *time.Time
  31196. addtime *uint64
  31197. addaddtime *int64
  31198. _type *int
  31199. add_type *int
  31200. bot_id *string
  31201. organization_id *uint64
  31202. addorganization_id *int64
  31203. ai_response *uint64
  31204. addai_response *int64
  31205. sop_run *uint64
  31206. addsop_run *int64
  31207. total_friend *uint64
  31208. addtotal_friend *int64
  31209. total_group *uint64
  31210. addtotal_group *int64
  31211. account_balance *uint64
  31212. addaccount_balance *int64
  31213. consume_token *uint64
  31214. addconsume_token *int64
  31215. active_user *uint64
  31216. addactive_user *int64
  31217. new_user *int64
  31218. addnew_user *int64
  31219. label_dist *[]custom_types.LabelDist
  31220. appendlabel_dist []custom_types.LabelDist
  31221. clearedFields map[string]struct{}
  31222. done bool
  31223. oldValue func(context.Context) (*UsageStatisticMonth, error)
  31224. predicates []predicate.UsageStatisticMonth
  31225. }
  31226. var _ ent.Mutation = (*UsageStatisticMonthMutation)(nil)
  31227. // usagestatisticmonthOption allows management of the mutation configuration using functional options.
  31228. type usagestatisticmonthOption func(*UsageStatisticMonthMutation)
  31229. // newUsageStatisticMonthMutation creates new mutation for the UsageStatisticMonth entity.
  31230. func newUsageStatisticMonthMutation(c config, op Op, opts ...usagestatisticmonthOption) *UsageStatisticMonthMutation {
  31231. m := &UsageStatisticMonthMutation{
  31232. config: c,
  31233. op: op,
  31234. typ: TypeUsageStatisticMonth,
  31235. clearedFields: make(map[string]struct{}),
  31236. }
  31237. for _, opt := range opts {
  31238. opt(m)
  31239. }
  31240. return m
  31241. }
  31242. // withUsageStatisticMonthID sets the ID field of the mutation.
  31243. func withUsageStatisticMonthID(id uint64) usagestatisticmonthOption {
  31244. return func(m *UsageStatisticMonthMutation) {
  31245. var (
  31246. err error
  31247. once sync.Once
  31248. value *UsageStatisticMonth
  31249. )
  31250. m.oldValue = func(ctx context.Context) (*UsageStatisticMonth, error) {
  31251. once.Do(func() {
  31252. if m.done {
  31253. err = errors.New("querying old values post mutation is not allowed")
  31254. } else {
  31255. value, err = m.Client().UsageStatisticMonth.Get(ctx, id)
  31256. }
  31257. })
  31258. return value, err
  31259. }
  31260. m.id = &id
  31261. }
  31262. }
  31263. // withUsageStatisticMonth sets the old UsageStatisticMonth of the mutation.
  31264. func withUsageStatisticMonth(node *UsageStatisticMonth) usagestatisticmonthOption {
  31265. return func(m *UsageStatisticMonthMutation) {
  31266. m.oldValue = func(context.Context) (*UsageStatisticMonth, error) {
  31267. return node, nil
  31268. }
  31269. m.id = &node.ID
  31270. }
  31271. }
  31272. // Client returns a new `ent.Client` from the mutation. If the mutation was
  31273. // executed in a transaction (ent.Tx), a transactional client is returned.
  31274. func (m UsageStatisticMonthMutation) Client() *Client {
  31275. client := &Client{config: m.config}
  31276. client.init()
  31277. return client
  31278. }
  31279. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  31280. // it returns an error otherwise.
  31281. func (m UsageStatisticMonthMutation) Tx() (*Tx, error) {
  31282. if _, ok := m.driver.(*txDriver); !ok {
  31283. return nil, errors.New("ent: mutation is not running in a transaction")
  31284. }
  31285. tx := &Tx{config: m.config}
  31286. tx.init()
  31287. return tx, nil
  31288. }
  31289. // SetID sets the value of the id field. Note that this
  31290. // operation is only accepted on creation of UsageStatisticMonth entities.
  31291. func (m *UsageStatisticMonthMutation) SetID(id uint64) {
  31292. m.id = &id
  31293. }
  31294. // ID returns the ID value in the mutation. Note that the ID is only available
  31295. // if it was provided to the builder or after it was returned from the database.
  31296. func (m *UsageStatisticMonthMutation) ID() (id uint64, exists bool) {
  31297. if m.id == nil {
  31298. return
  31299. }
  31300. return *m.id, true
  31301. }
  31302. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  31303. // That means, if the mutation is applied within a transaction with an isolation level such
  31304. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  31305. // or updated by the mutation.
  31306. func (m *UsageStatisticMonthMutation) IDs(ctx context.Context) ([]uint64, error) {
  31307. switch {
  31308. case m.op.Is(OpUpdateOne | OpDeleteOne):
  31309. id, exists := m.ID()
  31310. if exists {
  31311. return []uint64{id}, nil
  31312. }
  31313. fallthrough
  31314. case m.op.Is(OpUpdate | OpDelete):
  31315. return m.Client().UsageStatisticMonth.Query().Where(m.predicates...).IDs(ctx)
  31316. default:
  31317. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  31318. }
  31319. }
  31320. // SetCreatedAt sets the "created_at" field.
  31321. func (m *UsageStatisticMonthMutation) SetCreatedAt(t time.Time) {
  31322. m.created_at = &t
  31323. }
  31324. // CreatedAt returns the value of the "created_at" field in the mutation.
  31325. func (m *UsageStatisticMonthMutation) CreatedAt() (r time.Time, exists bool) {
  31326. v := m.created_at
  31327. if v == nil {
  31328. return
  31329. }
  31330. return *v, true
  31331. }
  31332. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticMonth entity.
  31333. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31334. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31335. func (m *UsageStatisticMonthMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  31336. if !m.op.Is(OpUpdateOne) {
  31337. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  31338. }
  31339. if m.id == nil || m.oldValue == nil {
  31340. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  31341. }
  31342. oldValue, err := m.oldValue(ctx)
  31343. if err != nil {
  31344. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  31345. }
  31346. return oldValue.CreatedAt, nil
  31347. }
  31348. // ResetCreatedAt resets all changes to the "created_at" field.
  31349. func (m *UsageStatisticMonthMutation) ResetCreatedAt() {
  31350. m.created_at = nil
  31351. }
  31352. // SetUpdatedAt sets the "updated_at" field.
  31353. func (m *UsageStatisticMonthMutation) SetUpdatedAt(t time.Time) {
  31354. m.updated_at = &t
  31355. }
  31356. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  31357. func (m *UsageStatisticMonthMutation) UpdatedAt() (r time.Time, exists bool) {
  31358. v := m.updated_at
  31359. if v == nil {
  31360. return
  31361. }
  31362. return *v, true
  31363. }
  31364. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticMonth entity.
  31365. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31366. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31367. func (m *UsageStatisticMonthMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  31368. if !m.op.Is(OpUpdateOne) {
  31369. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  31370. }
  31371. if m.id == nil || m.oldValue == nil {
  31372. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  31373. }
  31374. oldValue, err := m.oldValue(ctx)
  31375. if err != nil {
  31376. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  31377. }
  31378. return oldValue.UpdatedAt, nil
  31379. }
  31380. // ResetUpdatedAt resets all changes to the "updated_at" field.
  31381. func (m *UsageStatisticMonthMutation) ResetUpdatedAt() {
  31382. m.updated_at = nil
  31383. }
  31384. // SetStatus sets the "status" field.
  31385. func (m *UsageStatisticMonthMutation) SetStatus(u uint8) {
  31386. m.status = &u
  31387. m.addstatus = nil
  31388. }
  31389. // Status returns the value of the "status" field in the mutation.
  31390. func (m *UsageStatisticMonthMutation) Status() (r uint8, exists bool) {
  31391. v := m.status
  31392. if v == nil {
  31393. return
  31394. }
  31395. return *v, true
  31396. }
  31397. // OldStatus returns the old "status" field's value of the UsageStatisticMonth entity.
  31398. // If the UsageStatisticMonth 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 *UsageStatisticMonthMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  31401. if !m.op.Is(OpUpdateOne) {
  31402. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  31403. }
  31404. if m.id == nil || m.oldValue == nil {
  31405. return v, errors.New("OldStatus 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 OldStatus: %w", err)
  31410. }
  31411. return oldValue.Status, nil
  31412. }
  31413. // AddStatus adds u to the "status" field.
  31414. func (m *UsageStatisticMonthMutation) AddStatus(u int8) {
  31415. if m.addstatus != nil {
  31416. *m.addstatus += u
  31417. } else {
  31418. m.addstatus = &u
  31419. }
  31420. }
  31421. // AddedStatus returns the value that was added to the "status" field in this mutation.
  31422. func (m *UsageStatisticMonthMutation) AddedStatus() (r int8, exists bool) {
  31423. v := m.addstatus
  31424. if v == nil {
  31425. return
  31426. }
  31427. return *v, true
  31428. }
  31429. // ClearStatus clears the value of the "status" field.
  31430. func (m *UsageStatisticMonthMutation) ClearStatus() {
  31431. m.status = nil
  31432. m.addstatus = nil
  31433. m.clearedFields[usagestatisticmonth.FieldStatus] = struct{}{}
  31434. }
  31435. // StatusCleared returns if the "status" field was cleared in this mutation.
  31436. func (m *UsageStatisticMonthMutation) StatusCleared() bool {
  31437. _, ok := m.clearedFields[usagestatisticmonth.FieldStatus]
  31438. return ok
  31439. }
  31440. // ResetStatus resets all changes to the "status" field.
  31441. func (m *UsageStatisticMonthMutation) ResetStatus() {
  31442. m.status = nil
  31443. m.addstatus = nil
  31444. delete(m.clearedFields, usagestatisticmonth.FieldStatus)
  31445. }
  31446. // SetDeletedAt sets the "deleted_at" field.
  31447. func (m *UsageStatisticMonthMutation) SetDeletedAt(t time.Time) {
  31448. m.deleted_at = &t
  31449. }
  31450. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  31451. func (m *UsageStatisticMonthMutation) DeletedAt() (r time.Time, exists bool) {
  31452. v := m.deleted_at
  31453. if v == nil {
  31454. return
  31455. }
  31456. return *v, true
  31457. }
  31458. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticMonth entity.
  31459. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31460. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31461. func (m *UsageStatisticMonthMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  31462. if !m.op.Is(OpUpdateOne) {
  31463. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  31464. }
  31465. if m.id == nil || m.oldValue == nil {
  31466. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  31467. }
  31468. oldValue, err := m.oldValue(ctx)
  31469. if err != nil {
  31470. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  31471. }
  31472. return oldValue.DeletedAt, nil
  31473. }
  31474. // ClearDeletedAt clears the value of the "deleted_at" field.
  31475. func (m *UsageStatisticMonthMutation) ClearDeletedAt() {
  31476. m.deleted_at = nil
  31477. m.clearedFields[usagestatisticmonth.FieldDeletedAt] = struct{}{}
  31478. }
  31479. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  31480. func (m *UsageStatisticMonthMutation) DeletedAtCleared() bool {
  31481. _, ok := m.clearedFields[usagestatisticmonth.FieldDeletedAt]
  31482. return ok
  31483. }
  31484. // ResetDeletedAt resets all changes to the "deleted_at" field.
  31485. func (m *UsageStatisticMonthMutation) ResetDeletedAt() {
  31486. m.deleted_at = nil
  31487. delete(m.clearedFields, usagestatisticmonth.FieldDeletedAt)
  31488. }
  31489. // SetAddtime sets the "addtime" field.
  31490. func (m *UsageStatisticMonthMutation) SetAddtime(u uint64) {
  31491. m.addtime = &u
  31492. m.addaddtime = nil
  31493. }
  31494. // Addtime returns the value of the "addtime" field in the mutation.
  31495. func (m *UsageStatisticMonthMutation) Addtime() (r uint64, exists bool) {
  31496. v := m.addtime
  31497. if v == nil {
  31498. return
  31499. }
  31500. return *v, true
  31501. }
  31502. // OldAddtime returns the old "addtime" field's value of the UsageStatisticMonth entity.
  31503. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31504. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31505. func (m *UsageStatisticMonthMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  31506. if !m.op.Is(OpUpdateOne) {
  31507. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  31508. }
  31509. if m.id == nil || m.oldValue == nil {
  31510. return v, errors.New("OldAddtime requires an ID field in the mutation")
  31511. }
  31512. oldValue, err := m.oldValue(ctx)
  31513. if err != nil {
  31514. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  31515. }
  31516. return oldValue.Addtime, nil
  31517. }
  31518. // AddAddtime adds u to the "addtime" field.
  31519. func (m *UsageStatisticMonthMutation) AddAddtime(u int64) {
  31520. if m.addaddtime != nil {
  31521. *m.addaddtime += u
  31522. } else {
  31523. m.addaddtime = &u
  31524. }
  31525. }
  31526. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  31527. func (m *UsageStatisticMonthMutation) AddedAddtime() (r int64, exists bool) {
  31528. v := m.addaddtime
  31529. if v == nil {
  31530. return
  31531. }
  31532. return *v, true
  31533. }
  31534. // ResetAddtime resets all changes to the "addtime" field.
  31535. func (m *UsageStatisticMonthMutation) ResetAddtime() {
  31536. m.addtime = nil
  31537. m.addaddtime = nil
  31538. }
  31539. // SetType sets the "type" field.
  31540. func (m *UsageStatisticMonthMutation) SetType(i int) {
  31541. m._type = &i
  31542. m.add_type = nil
  31543. }
  31544. // GetType returns the value of the "type" field in the mutation.
  31545. func (m *UsageStatisticMonthMutation) GetType() (r int, exists bool) {
  31546. v := m._type
  31547. if v == nil {
  31548. return
  31549. }
  31550. return *v, true
  31551. }
  31552. // OldType returns the old "type" field's value of the UsageStatisticMonth entity.
  31553. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31554. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31555. func (m *UsageStatisticMonthMutation) OldType(ctx context.Context) (v int, err error) {
  31556. if !m.op.Is(OpUpdateOne) {
  31557. return v, errors.New("OldType is only allowed on UpdateOne operations")
  31558. }
  31559. if m.id == nil || m.oldValue == nil {
  31560. return v, errors.New("OldType requires an ID field in the mutation")
  31561. }
  31562. oldValue, err := m.oldValue(ctx)
  31563. if err != nil {
  31564. return v, fmt.Errorf("querying old value for OldType: %w", err)
  31565. }
  31566. return oldValue.Type, nil
  31567. }
  31568. // AddType adds i to the "type" field.
  31569. func (m *UsageStatisticMonthMutation) AddType(i int) {
  31570. if m.add_type != nil {
  31571. *m.add_type += i
  31572. } else {
  31573. m.add_type = &i
  31574. }
  31575. }
  31576. // AddedType returns the value that was added to the "type" field in this mutation.
  31577. func (m *UsageStatisticMonthMutation) AddedType() (r int, exists bool) {
  31578. v := m.add_type
  31579. if v == nil {
  31580. return
  31581. }
  31582. return *v, true
  31583. }
  31584. // ResetType resets all changes to the "type" field.
  31585. func (m *UsageStatisticMonthMutation) ResetType() {
  31586. m._type = nil
  31587. m.add_type = nil
  31588. }
  31589. // SetBotID sets the "bot_id" field.
  31590. func (m *UsageStatisticMonthMutation) SetBotID(s string) {
  31591. m.bot_id = &s
  31592. }
  31593. // BotID returns the value of the "bot_id" field in the mutation.
  31594. func (m *UsageStatisticMonthMutation) BotID() (r string, exists bool) {
  31595. v := m.bot_id
  31596. if v == nil {
  31597. return
  31598. }
  31599. return *v, true
  31600. }
  31601. // OldBotID returns the old "bot_id" field's value of the UsageStatisticMonth entity.
  31602. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31603. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31604. func (m *UsageStatisticMonthMutation) OldBotID(ctx context.Context) (v string, err error) {
  31605. if !m.op.Is(OpUpdateOne) {
  31606. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  31607. }
  31608. if m.id == nil || m.oldValue == nil {
  31609. return v, errors.New("OldBotID requires an ID field in the mutation")
  31610. }
  31611. oldValue, err := m.oldValue(ctx)
  31612. if err != nil {
  31613. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  31614. }
  31615. return oldValue.BotID, nil
  31616. }
  31617. // ClearBotID clears the value of the "bot_id" field.
  31618. func (m *UsageStatisticMonthMutation) ClearBotID() {
  31619. m.bot_id = nil
  31620. m.clearedFields[usagestatisticmonth.FieldBotID] = struct{}{}
  31621. }
  31622. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  31623. func (m *UsageStatisticMonthMutation) BotIDCleared() bool {
  31624. _, ok := m.clearedFields[usagestatisticmonth.FieldBotID]
  31625. return ok
  31626. }
  31627. // ResetBotID resets all changes to the "bot_id" field.
  31628. func (m *UsageStatisticMonthMutation) ResetBotID() {
  31629. m.bot_id = nil
  31630. delete(m.clearedFields, usagestatisticmonth.FieldBotID)
  31631. }
  31632. // SetOrganizationID sets the "organization_id" field.
  31633. func (m *UsageStatisticMonthMutation) SetOrganizationID(u uint64) {
  31634. m.organization_id = &u
  31635. m.addorganization_id = nil
  31636. }
  31637. // OrganizationID returns the value of the "organization_id" field in the mutation.
  31638. func (m *UsageStatisticMonthMutation) OrganizationID() (r uint64, exists bool) {
  31639. v := m.organization_id
  31640. if v == nil {
  31641. return
  31642. }
  31643. return *v, true
  31644. }
  31645. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticMonth entity.
  31646. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31647. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31648. func (m *UsageStatisticMonthMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  31649. if !m.op.Is(OpUpdateOne) {
  31650. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  31651. }
  31652. if m.id == nil || m.oldValue == nil {
  31653. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  31654. }
  31655. oldValue, err := m.oldValue(ctx)
  31656. if err != nil {
  31657. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  31658. }
  31659. return oldValue.OrganizationID, nil
  31660. }
  31661. // AddOrganizationID adds u to the "organization_id" field.
  31662. func (m *UsageStatisticMonthMutation) AddOrganizationID(u int64) {
  31663. if m.addorganization_id != nil {
  31664. *m.addorganization_id += u
  31665. } else {
  31666. m.addorganization_id = &u
  31667. }
  31668. }
  31669. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  31670. func (m *UsageStatisticMonthMutation) AddedOrganizationID() (r int64, exists bool) {
  31671. v := m.addorganization_id
  31672. if v == nil {
  31673. return
  31674. }
  31675. return *v, true
  31676. }
  31677. // ClearOrganizationID clears the value of the "organization_id" field.
  31678. func (m *UsageStatisticMonthMutation) ClearOrganizationID() {
  31679. m.organization_id = nil
  31680. m.addorganization_id = nil
  31681. m.clearedFields[usagestatisticmonth.FieldOrganizationID] = struct{}{}
  31682. }
  31683. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  31684. func (m *UsageStatisticMonthMutation) OrganizationIDCleared() bool {
  31685. _, ok := m.clearedFields[usagestatisticmonth.FieldOrganizationID]
  31686. return ok
  31687. }
  31688. // ResetOrganizationID resets all changes to the "organization_id" field.
  31689. func (m *UsageStatisticMonthMutation) ResetOrganizationID() {
  31690. m.organization_id = nil
  31691. m.addorganization_id = nil
  31692. delete(m.clearedFields, usagestatisticmonth.FieldOrganizationID)
  31693. }
  31694. // SetAiResponse sets the "ai_response" field.
  31695. func (m *UsageStatisticMonthMutation) SetAiResponse(u uint64) {
  31696. m.ai_response = &u
  31697. m.addai_response = nil
  31698. }
  31699. // AiResponse returns the value of the "ai_response" field in the mutation.
  31700. func (m *UsageStatisticMonthMutation) AiResponse() (r uint64, exists bool) {
  31701. v := m.ai_response
  31702. if v == nil {
  31703. return
  31704. }
  31705. return *v, true
  31706. }
  31707. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticMonth entity.
  31708. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31709. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31710. func (m *UsageStatisticMonthMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  31711. if !m.op.Is(OpUpdateOne) {
  31712. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  31713. }
  31714. if m.id == nil || m.oldValue == nil {
  31715. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  31716. }
  31717. oldValue, err := m.oldValue(ctx)
  31718. if err != nil {
  31719. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  31720. }
  31721. return oldValue.AiResponse, nil
  31722. }
  31723. // AddAiResponse adds u to the "ai_response" field.
  31724. func (m *UsageStatisticMonthMutation) AddAiResponse(u int64) {
  31725. if m.addai_response != nil {
  31726. *m.addai_response += u
  31727. } else {
  31728. m.addai_response = &u
  31729. }
  31730. }
  31731. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  31732. func (m *UsageStatisticMonthMutation) AddedAiResponse() (r int64, exists bool) {
  31733. v := m.addai_response
  31734. if v == nil {
  31735. return
  31736. }
  31737. return *v, true
  31738. }
  31739. // ResetAiResponse resets all changes to the "ai_response" field.
  31740. func (m *UsageStatisticMonthMutation) ResetAiResponse() {
  31741. m.ai_response = nil
  31742. m.addai_response = nil
  31743. }
  31744. // SetSopRun sets the "sop_run" field.
  31745. func (m *UsageStatisticMonthMutation) SetSopRun(u uint64) {
  31746. m.sop_run = &u
  31747. m.addsop_run = nil
  31748. }
  31749. // SopRun returns the value of the "sop_run" field in the mutation.
  31750. func (m *UsageStatisticMonthMutation) SopRun() (r uint64, exists bool) {
  31751. v := m.sop_run
  31752. if v == nil {
  31753. return
  31754. }
  31755. return *v, true
  31756. }
  31757. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticMonth entity.
  31758. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31759. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31760. func (m *UsageStatisticMonthMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  31761. if !m.op.Is(OpUpdateOne) {
  31762. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  31763. }
  31764. if m.id == nil || m.oldValue == nil {
  31765. return v, errors.New("OldSopRun requires an ID field in the mutation")
  31766. }
  31767. oldValue, err := m.oldValue(ctx)
  31768. if err != nil {
  31769. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  31770. }
  31771. return oldValue.SopRun, nil
  31772. }
  31773. // AddSopRun adds u to the "sop_run" field.
  31774. func (m *UsageStatisticMonthMutation) AddSopRun(u int64) {
  31775. if m.addsop_run != nil {
  31776. *m.addsop_run += u
  31777. } else {
  31778. m.addsop_run = &u
  31779. }
  31780. }
  31781. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  31782. func (m *UsageStatisticMonthMutation) AddedSopRun() (r int64, exists bool) {
  31783. v := m.addsop_run
  31784. if v == nil {
  31785. return
  31786. }
  31787. return *v, true
  31788. }
  31789. // ResetSopRun resets all changes to the "sop_run" field.
  31790. func (m *UsageStatisticMonthMutation) ResetSopRun() {
  31791. m.sop_run = nil
  31792. m.addsop_run = nil
  31793. }
  31794. // SetTotalFriend sets the "total_friend" field.
  31795. func (m *UsageStatisticMonthMutation) SetTotalFriend(u uint64) {
  31796. m.total_friend = &u
  31797. m.addtotal_friend = nil
  31798. }
  31799. // TotalFriend returns the value of the "total_friend" field in the mutation.
  31800. func (m *UsageStatisticMonthMutation) TotalFriend() (r uint64, exists bool) {
  31801. v := m.total_friend
  31802. if v == nil {
  31803. return
  31804. }
  31805. return *v, true
  31806. }
  31807. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticMonth entity.
  31808. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31809. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31810. func (m *UsageStatisticMonthMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  31811. if !m.op.Is(OpUpdateOne) {
  31812. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  31813. }
  31814. if m.id == nil || m.oldValue == nil {
  31815. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  31816. }
  31817. oldValue, err := m.oldValue(ctx)
  31818. if err != nil {
  31819. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  31820. }
  31821. return oldValue.TotalFriend, nil
  31822. }
  31823. // AddTotalFriend adds u to the "total_friend" field.
  31824. func (m *UsageStatisticMonthMutation) AddTotalFriend(u int64) {
  31825. if m.addtotal_friend != nil {
  31826. *m.addtotal_friend += u
  31827. } else {
  31828. m.addtotal_friend = &u
  31829. }
  31830. }
  31831. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  31832. func (m *UsageStatisticMonthMutation) AddedTotalFriend() (r int64, exists bool) {
  31833. v := m.addtotal_friend
  31834. if v == nil {
  31835. return
  31836. }
  31837. return *v, true
  31838. }
  31839. // ResetTotalFriend resets all changes to the "total_friend" field.
  31840. func (m *UsageStatisticMonthMutation) ResetTotalFriend() {
  31841. m.total_friend = nil
  31842. m.addtotal_friend = nil
  31843. }
  31844. // SetTotalGroup sets the "total_group" field.
  31845. func (m *UsageStatisticMonthMutation) SetTotalGroup(u uint64) {
  31846. m.total_group = &u
  31847. m.addtotal_group = nil
  31848. }
  31849. // TotalGroup returns the value of the "total_group" field in the mutation.
  31850. func (m *UsageStatisticMonthMutation) TotalGroup() (r uint64, exists bool) {
  31851. v := m.total_group
  31852. if v == nil {
  31853. return
  31854. }
  31855. return *v, true
  31856. }
  31857. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticMonth entity.
  31858. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31859. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31860. func (m *UsageStatisticMonthMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  31861. if !m.op.Is(OpUpdateOne) {
  31862. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  31863. }
  31864. if m.id == nil || m.oldValue == nil {
  31865. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  31866. }
  31867. oldValue, err := m.oldValue(ctx)
  31868. if err != nil {
  31869. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  31870. }
  31871. return oldValue.TotalGroup, nil
  31872. }
  31873. // AddTotalGroup adds u to the "total_group" field.
  31874. func (m *UsageStatisticMonthMutation) AddTotalGroup(u int64) {
  31875. if m.addtotal_group != nil {
  31876. *m.addtotal_group += u
  31877. } else {
  31878. m.addtotal_group = &u
  31879. }
  31880. }
  31881. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  31882. func (m *UsageStatisticMonthMutation) AddedTotalGroup() (r int64, exists bool) {
  31883. v := m.addtotal_group
  31884. if v == nil {
  31885. return
  31886. }
  31887. return *v, true
  31888. }
  31889. // ResetTotalGroup resets all changes to the "total_group" field.
  31890. func (m *UsageStatisticMonthMutation) ResetTotalGroup() {
  31891. m.total_group = nil
  31892. m.addtotal_group = nil
  31893. }
  31894. // SetAccountBalance sets the "account_balance" field.
  31895. func (m *UsageStatisticMonthMutation) SetAccountBalance(u uint64) {
  31896. m.account_balance = &u
  31897. m.addaccount_balance = nil
  31898. }
  31899. // AccountBalance returns the value of the "account_balance" field in the mutation.
  31900. func (m *UsageStatisticMonthMutation) AccountBalance() (r uint64, exists bool) {
  31901. v := m.account_balance
  31902. if v == nil {
  31903. return
  31904. }
  31905. return *v, true
  31906. }
  31907. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticMonth entity.
  31908. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31909. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31910. func (m *UsageStatisticMonthMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  31911. if !m.op.Is(OpUpdateOne) {
  31912. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  31913. }
  31914. if m.id == nil || m.oldValue == nil {
  31915. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  31916. }
  31917. oldValue, err := m.oldValue(ctx)
  31918. if err != nil {
  31919. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  31920. }
  31921. return oldValue.AccountBalance, nil
  31922. }
  31923. // AddAccountBalance adds u to the "account_balance" field.
  31924. func (m *UsageStatisticMonthMutation) AddAccountBalance(u int64) {
  31925. if m.addaccount_balance != nil {
  31926. *m.addaccount_balance += u
  31927. } else {
  31928. m.addaccount_balance = &u
  31929. }
  31930. }
  31931. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  31932. func (m *UsageStatisticMonthMutation) AddedAccountBalance() (r int64, exists bool) {
  31933. v := m.addaccount_balance
  31934. if v == nil {
  31935. return
  31936. }
  31937. return *v, true
  31938. }
  31939. // ResetAccountBalance resets all changes to the "account_balance" field.
  31940. func (m *UsageStatisticMonthMutation) ResetAccountBalance() {
  31941. m.account_balance = nil
  31942. m.addaccount_balance = nil
  31943. }
  31944. // SetConsumeToken sets the "consume_token" field.
  31945. func (m *UsageStatisticMonthMutation) SetConsumeToken(u uint64) {
  31946. m.consume_token = &u
  31947. m.addconsume_token = nil
  31948. }
  31949. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  31950. func (m *UsageStatisticMonthMutation) ConsumeToken() (r uint64, exists bool) {
  31951. v := m.consume_token
  31952. if v == nil {
  31953. return
  31954. }
  31955. return *v, true
  31956. }
  31957. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticMonth entity.
  31958. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31959. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31960. func (m *UsageStatisticMonthMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  31961. if !m.op.Is(OpUpdateOne) {
  31962. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  31963. }
  31964. if m.id == nil || m.oldValue == nil {
  31965. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  31966. }
  31967. oldValue, err := m.oldValue(ctx)
  31968. if err != nil {
  31969. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  31970. }
  31971. return oldValue.ConsumeToken, nil
  31972. }
  31973. // AddConsumeToken adds u to the "consume_token" field.
  31974. func (m *UsageStatisticMonthMutation) AddConsumeToken(u int64) {
  31975. if m.addconsume_token != nil {
  31976. *m.addconsume_token += u
  31977. } else {
  31978. m.addconsume_token = &u
  31979. }
  31980. }
  31981. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  31982. func (m *UsageStatisticMonthMutation) AddedConsumeToken() (r int64, exists bool) {
  31983. v := m.addconsume_token
  31984. if v == nil {
  31985. return
  31986. }
  31987. return *v, true
  31988. }
  31989. // ResetConsumeToken resets all changes to the "consume_token" field.
  31990. func (m *UsageStatisticMonthMutation) ResetConsumeToken() {
  31991. m.consume_token = nil
  31992. m.addconsume_token = nil
  31993. }
  31994. // SetActiveUser sets the "active_user" field.
  31995. func (m *UsageStatisticMonthMutation) SetActiveUser(u uint64) {
  31996. m.active_user = &u
  31997. m.addactive_user = nil
  31998. }
  31999. // ActiveUser returns the value of the "active_user" field in the mutation.
  32000. func (m *UsageStatisticMonthMutation) ActiveUser() (r uint64, exists bool) {
  32001. v := m.active_user
  32002. if v == nil {
  32003. return
  32004. }
  32005. return *v, true
  32006. }
  32007. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticMonth entity.
  32008. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  32009. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32010. func (m *UsageStatisticMonthMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  32011. if !m.op.Is(OpUpdateOne) {
  32012. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  32013. }
  32014. if m.id == nil || m.oldValue == nil {
  32015. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  32016. }
  32017. oldValue, err := m.oldValue(ctx)
  32018. if err != nil {
  32019. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  32020. }
  32021. return oldValue.ActiveUser, nil
  32022. }
  32023. // AddActiveUser adds u to the "active_user" field.
  32024. func (m *UsageStatisticMonthMutation) AddActiveUser(u int64) {
  32025. if m.addactive_user != nil {
  32026. *m.addactive_user += u
  32027. } else {
  32028. m.addactive_user = &u
  32029. }
  32030. }
  32031. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  32032. func (m *UsageStatisticMonthMutation) AddedActiveUser() (r int64, exists bool) {
  32033. v := m.addactive_user
  32034. if v == nil {
  32035. return
  32036. }
  32037. return *v, true
  32038. }
  32039. // ResetActiveUser resets all changes to the "active_user" field.
  32040. func (m *UsageStatisticMonthMutation) ResetActiveUser() {
  32041. m.active_user = nil
  32042. m.addactive_user = nil
  32043. }
  32044. // SetNewUser sets the "new_user" field.
  32045. func (m *UsageStatisticMonthMutation) SetNewUser(i int64) {
  32046. m.new_user = &i
  32047. m.addnew_user = nil
  32048. }
  32049. // NewUser returns the value of the "new_user" field in the mutation.
  32050. func (m *UsageStatisticMonthMutation) NewUser() (r int64, exists bool) {
  32051. v := m.new_user
  32052. if v == nil {
  32053. return
  32054. }
  32055. return *v, true
  32056. }
  32057. // OldNewUser returns the old "new_user" field's value of the UsageStatisticMonth entity.
  32058. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  32059. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32060. func (m *UsageStatisticMonthMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  32061. if !m.op.Is(OpUpdateOne) {
  32062. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  32063. }
  32064. if m.id == nil || m.oldValue == nil {
  32065. return v, errors.New("OldNewUser requires an ID field in the mutation")
  32066. }
  32067. oldValue, err := m.oldValue(ctx)
  32068. if err != nil {
  32069. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  32070. }
  32071. return oldValue.NewUser, nil
  32072. }
  32073. // AddNewUser adds i to the "new_user" field.
  32074. func (m *UsageStatisticMonthMutation) AddNewUser(i int64) {
  32075. if m.addnew_user != nil {
  32076. *m.addnew_user += i
  32077. } else {
  32078. m.addnew_user = &i
  32079. }
  32080. }
  32081. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  32082. func (m *UsageStatisticMonthMutation) AddedNewUser() (r int64, exists bool) {
  32083. v := m.addnew_user
  32084. if v == nil {
  32085. return
  32086. }
  32087. return *v, true
  32088. }
  32089. // ResetNewUser resets all changes to the "new_user" field.
  32090. func (m *UsageStatisticMonthMutation) ResetNewUser() {
  32091. m.new_user = nil
  32092. m.addnew_user = nil
  32093. }
  32094. // SetLabelDist sets the "label_dist" field.
  32095. func (m *UsageStatisticMonthMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  32096. m.label_dist = &ctd
  32097. m.appendlabel_dist = nil
  32098. }
  32099. // LabelDist returns the value of the "label_dist" field in the mutation.
  32100. func (m *UsageStatisticMonthMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  32101. v := m.label_dist
  32102. if v == nil {
  32103. return
  32104. }
  32105. return *v, true
  32106. }
  32107. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticMonth entity.
  32108. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  32109. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32110. func (m *UsageStatisticMonthMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  32111. if !m.op.Is(OpUpdateOne) {
  32112. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  32113. }
  32114. if m.id == nil || m.oldValue == nil {
  32115. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  32116. }
  32117. oldValue, err := m.oldValue(ctx)
  32118. if err != nil {
  32119. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  32120. }
  32121. return oldValue.LabelDist, nil
  32122. }
  32123. // AppendLabelDist adds ctd to the "label_dist" field.
  32124. func (m *UsageStatisticMonthMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  32125. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  32126. }
  32127. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  32128. func (m *UsageStatisticMonthMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  32129. if len(m.appendlabel_dist) == 0 {
  32130. return nil, false
  32131. }
  32132. return m.appendlabel_dist, true
  32133. }
  32134. // ResetLabelDist resets all changes to the "label_dist" field.
  32135. func (m *UsageStatisticMonthMutation) ResetLabelDist() {
  32136. m.label_dist = nil
  32137. m.appendlabel_dist = nil
  32138. }
  32139. // Where appends a list predicates to the UsageStatisticMonthMutation builder.
  32140. func (m *UsageStatisticMonthMutation) Where(ps ...predicate.UsageStatisticMonth) {
  32141. m.predicates = append(m.predicates, ps...)
  32142. }
  32143. // WhereP appends storage-level predicates to the UsageStatisticMonthMutation builder. Using this method,
  32144. // users can use type-assertion to append predicates that do not depend on any generated package.
  32145. func (m *UsageStatisticMonthMutation) WhereP(ps ...func(*sql.Selector)) {
  32146. p := make([]predicate.UsageStatisticMonth, len(ps))
  32147. for i := range ps {
  32148. p[i] = ps[i]
  32149. }
  32150. m.Where(p...)
  32151. }
  32152. // Op returns the operation name.
  32153. func (m *UsageStatisticMonthMutation) Op() Op {
  32154. return m.op
  32155. }
  32156. // SetOp allows setting the mutation operation.
  32157. func (m *UsageStatisticMonthMutation) SetOp(op Op) {
  32158. m.op = op
  32159. }
  32160. // Type returns the node type of this mutation (UsageStatisticMonth).
  32161. func (m *UsageStatisticMonthMutation) Type() string {
  32162. return m.typ
  32163. }
  32164. // Fields returns all fields that were changed during this mutation. Note that in
  32165. // order to get all numeric fields that were incremented/decremented, call
  32166. // AddedFields().
  32167. func (m *UsageStatisticMonthMutation) Fields() []string {
  32168. fields := make([]string, 0, 17)
  32169. if m.created_at != nil {
  32170. fields = append(fields, usagestatisticmonth.FieldCreatedAt)
  32171. }
  32172. if m.updated_at != nil {
  32173. fields = append(fields, usagestatisticmonth.FieldUpdatedAt)
  32174. }
  32175. if m.status != nil {
  32176. fields = append(fields, usagestatisticmonth.FieldStatus)
  32177. }
  32178. if m.deleted_at != nil {
  32179. fields = append(fields, usagestatisticmonth.FieldDeletedAt)
  32180. }
  32181. if m.addtime != nil {
  32182. fields = append(fields, usagestatisticmonth.FieldAddtime)
  32183. }
  32184. if m._type != nil {
  32185. fields = append(fields, usagestatisticmonth.FieldType)
  32186. }
  32187. if m.bot_id != nil {
  32188. fields = append(fields, usagestatisticmonth.FieldBotID)
  32189. }
  32190. if m.organization_id != nil {
  32191. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  32192. }
  32193. if m.ai_response != nil {
  32194. fields = append(fields, usagestatisticmonth.FieldAiResponse)
  32195. }
  32196. if m.sop_run != nil {
  32197. fields = append(fields, usagestatisticmonth.FieldSopRun)
  32198. }
  32199. if m.total_friend != nil {
  32200. fields = append(fields, usagestatisticmonth.FieldTotalFriend)
  32201. }
  32202. if m.total_group != nil {
  32203. fields = append(fields, usagestatisticmonth.FieldTotalGroup)
  32204. }
  32205. if m.account_balance != nil {
  32206. fields = append(fields, usagestatisticmonth.FieldAccountBalance)
  32207. }
  32208. if m.consume_token != nil {
  32209. fields = append(fields, usagestatisticmonth.FieldConsumeToken)
  32210. }
  32211. if m.active_user != nil {
  32212. fields = append(fields, usagestatisticmonth.FieldActiveUser)
  32213. }
  32214. if m.new_user != nil {
  32215. fields = append(fields, usagestatisticmonth.FieldNewUser)
  32216. }
  32217. if m.label_dist != nil {
  32218. fields = append(fields, usagestatisticmonth.FieldLabelDist)
  32219. }
  32220. return fields
  32221. }
  32222. // Field returns the value of a field with the given name. The second boolean
  32223. // return value indicates that this field was not set, or was not defined in the
  32224. // schema.
  32225. func (m *UsageStatisticMonthMutation) Field(name string) (ent.Value, bool) {
  32226. switch name {
  32227. case usagestatisticmonth.FieldCreatedAt:
  32228. return m.CreatedAt()
  32229. case usagestatisticmonth.FieldUpdatedAt:
  32230. return m.UpdatedAt()
  32231. case usagestatisticmonth.FieldStatus:
  32232. return m.Status()
  32233. case usagestatisticmonth.FieldDeletedAt:
  32234. return m.DeletedAt()
  32235. case usagestatisticmonth.FieldAddtime:
  32236. return m.Addtime()
  32237. case usagestatisticmonth.FieldType:
  32238. return m.GetType()
  32239. case usagestatisticmonth.FieldBotID:
  32240. return m.BotID()
  32241. case usagestatisticmonth.FieldOrganizationID:
  32242. return m.OrganizationID()
  32243. case usagestatisticmonth.FieldAiResponse:
  32244. return m.AiResponse()
  32245. case usagestatisticmonth.FieldSopRun:
  32246. return m.SopRun()
  32247. case usagestatisticmonth.FieldTotalFriend:
  32248. return m.TotalFriend()
  32249. case usagestatisticmonth.FieldTotalGroup:
  32250. return m.TotalGroup()
  32251. case usagestatisticmonth.FieldAccountBalance:
  32252. return m.AccountBalance()
  32253. case usagestatisticmonth.FieldConsumeToken:
  32254. return m.ConsumeToken()
  32255. case usagestatisticmonth.FieldActiveUser:
  32256. return m.ActiveUser()
  32257. case usagestatisticmonth.FieldNewUser:
  32258. return m.NewUser()
  32259. case usagestatisticmonth.FieldLabelDist:
  32260. return m.LabelDist()
  32261. }
  32262. return nil, false
  32263. }
  32264. // OldField returns the old value of the field from the database. An error is
  32265. // returned if the mutation operation is not UpdateOne, or the query to the
  32266. // database failed.
  32267. func (m *UsageStatisticMonthMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  32268. switch name {
  32269. case usagestatisticmonth.FieldCreatedAt:
  32270. return m.OldCreatedAt(ctx)
  32271. case usagestatisticmonth.FieldUpdatedAt:
  32272. return m.OldUpdatedAt(ctx)
  32273. case usagestatisticmonth.FieldStatus:
  32274. return m.OldStatus(ctx)
  32275. case usagestatisticmonth.FieldDeletedAt:
  32276. return m.OldDeletedAt(ctx)
  32277. case usagestatisticmonth.FieldAddtime:
  32278. return m.OldAddtime(ctx)
  32279. case usagestatisticmonth.FieldType:
  32280. return m.OldType(ctx)
  32281. case usagestatisticmonth.FieldBotID:
  32282. return m.OldBotID(ctx)
  32283. case usagestatisticmonth.FieldOrganizationID:
  32284. return m.OldOrganizationID(ctx)
  32285. case usagestatisticmonth.FieldAiResponse:
  32286. return m.OldAiResponse(ctx)
  32287. case usagestatisticmonth.FieldSopRun:
  32288. return m.OldSopRun(ctx)
  32289. case usagestatisticmonth.FieldTotalFriend:
  32290. return m.OldTotalFriend(ctx)
  32291. case usagestatisticmonth.FieldTotalGroup:
  32292. return m.OldTotalGroup(ctx)
  32293. case usagestatisticmonth.FieldAccountBalance:
  32294. return m.OldAccountBalance(ctx)
  32295. case usagestatisticmonth.FieldConsumeToken:
  32296. return m.OldConsumeToken(ctx)
  32297. case usagestatisticmonth.FieldActiveUser:
  32298. return m.OldActiveUser(ctx)
  32299. case usagestatisticmonth.FieldNewUser:
  32300. return m.OldNewUser(ctx)
  32301. case usagestatisticmonth.FieldLabelDist:
  32302. return m.OldLabelDist(ctx)
  32303. }
  32304. return nil, fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  32305. }
  32306. // SetField sets the value of a field with the given name. It returns an error if
  32307. // the field is not defined in the schema, or if the type mismatched the field
  32308. // type.
  32309. func (m *UsageStatisticMonthMutation) SetField(name string, value ent.Value) error {
  32310. switch name {
  32311. case usagestatisticmonth.FieldCreatedAt:
  32312. v, ok := value.(time.Time)
  32313. if !ok {
  32314. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32315. }
  32316. m.SetCreatedAt(v)
  32317. return nil
  32318. case usagestatisticmonth.FieldUpdatedAt:
  32319. v, ok := value.(time.Time)
  32320. if !ok {
  32321. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32322. }
  32323. m.SetUpdatedAt(v)
  32324. return nil
  32325. case usagestatisticmonth.FieldStatus:
  32326. v, ok := value.(uint8)
  32327. if !ok {
  32328. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32329. }
  32330. m.SetStatus(v)
  32331. return nil
  32332. case usagestatisticmonth.FieldDeletedAt:
  32333. v, ok := value.(time.Time)
  32334. if !ok {
  32335. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32336. }
  32337. m.SetDeletedAt(v)
  32338. return nil
  32339. case usagestatisticmonth.FieldAddtime:
  32340. v, ok := value.(uint64)
  32341. if !ok {
  32342. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32343. }
  32344. m.SetAddtime(v)
  32345. return nil
  32346. case usagestatisticmonth.FieldType:
  32347. v, ok := value.(int)
  32348. if !ok {
  32349. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32350. }
  32351. m.SetType(v)
  32352. return nil
  32353. case usagestatisticmonth.FieldBotID:
  32354. v, ok := value.(string)
  32355. if !ok {
  32356. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32357. }
  32358. m.SetBotID(v)
  32359. return nil
  32360. case usagestatisticmonth.FieldOrganizationID:
  32361. v, ok := value.(uint64)
  32362. if !ok {
  32363. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32364. }
  32365. m.SetOrganizationID(v)
  32366. return nil
  32367. case usagestatisticmonth.FieldAiResponse:
  32368. v, ok := value.(uint64)
  32369. if !ok {
  32370. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32371. }
  32372. m.SetAiResponse(v)
  32373. return nil
  32374. case usagestatisticmonth.FieldSopRun:
  32375. v, ok := value.(uint64)
  32376. if !ok {
  32377. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32378. }
  32379. m.SetSopRun(v)
  32380. return nil
  32381. case usagestatisticmonth.FieldTotalFriend:
  32382. v, ok := value.(uint64)
  32383. if !ok {
  32384. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32385. }
  32386. m.SetTotalFriend(v)
  32387. return nil
  32388. case usagestatisticmonth.FieldTotalGroup:
  32389. v, ok := value.(uint64)
  32390. if !ok {
  32391. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32392. }
  32393. m.SetTotalGroup(v)
  32394. return nil
  32395. case usagestatisticmonth.FieldAccountBalance:
  32396. v, ok := value.(uint64)
  32397. if !ok {
  32398. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32399. }
  32400. m.SetAccountBalance(v)
  32401. return nil
  32402. case usagestatisticmonth.FieldConsumeToken:
  32403. v, ok := value.(uint64)
  32404. if !ok {
  32405. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32406. }
  32407. m.SetConsumeToken(v)
  32408. return nil
  32409. case usagestatisticmonth.FieldActiveUser:
  32410. v, ok := value.(uint64)
  32411. if !ok {
  32412. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32413. }
  32414. m.SetActiveUser(v)
  32415. return nil
  32416. case usagestatisticmonth.FieldNewUser:
  32417. v, ok := value.(int64)
  32418. if !ok {
  32419. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32420. }
  32421. m.SetNewUser(v)
  32422. return nil
  32423. case usagestatisticmonth.FieldLabelDist:
  32424. v, ok := value.([]custom_types.LabelDist)
  32425. if !ok {
  32426. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32427. }
  32428. m.SetLabelDist(v)
  32429. return nil
  32430. }
  32431. return fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  32432. }
  32433. // AddedFields returns all numeric fields that were incremented/decremented during
  32434. // this mutation.
  32435. func (m *UsageStatisticMonthMutation) AddedFields() []string {
  32436. var fields []string
  32437. if m.addstatus != nil {
  32438. fields = append(fields, usagestatisticmonth.FieldStatus)
  32439. }
  32440. if m.addaddtime != nil {
  32441. fields = append(fields, usagestatisticmonth.FieldAddtime)
  32442. }
  32443. if m.add_type != nil {
  32444. fields = append(fields, usagestatisticmonth.FieldType)
  32445. }
  32446. if m.addorganization_id != nil {
  32447. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  32448. }
  32449. if m.addai_response != nil {
  32450. fields = append(fields, usagestatisticmonth.FieldAiResponse)
  32451. }
  32452. if m.addsop_run != nil {
  32453. fields = append(fields, usagestatisticmonth.FieldSopRun)
  32454. }
  32455. if m.addtotal_friend != nil {
  32456. fields = append(fields, usagestatisticmonth.FieldTotalFriend)
  32457. }
  32458. if m.addtotal_group != nil {
  32459. fields = append(fields, usagestatisticmonth.FieldTotalGroup)
  32460. }
  32461. if m.addaccount_balance != nil {
  32462. fields = append(fields, usagestatisticmonth.FieldAccountBalance)
  32463. }
  32464. if m.addconsume_token != nil {
  32465. fields = append(fields, usagestatisticmonth.FieldConsumeToken)
  32466. }
  32467. if m.addactive_user != nil {
  32468. fields = append(fields, usagestatisticmonth.FieldActiveUser)
  32469. }
  32470. if m.addnew_user != nil {
  32471. fields = append(fields, usagestatisticmonth.FieldNewUser)
  32472. }
  32473. return fields
  32474. }
  32475. // AddedField returns the numeric value that was incremented/decremented on a field
  32476. // with the given name. The second boolean return value indicates that this field
  32477. // was not set, or was not defined in the schema.
  32478. func (m *UsageStatisticMonthMutation) AddedField(name string) (ent.Value, bool) {
  32479. switch name {
  32480. case usagestatisticmonth.FieldStatus:
  32481. return m.AddedStatus()
  32482. case usagestatisticmonth.FieldAddtime:
  32483. return m.AddedAddtime()
  32484. case usagestatisticmonth.FieldType:
  32485. return m.AddedType()
  32486. case usagestatisticmonth.FieldOrganizationID:
  32487. return m.AddedOrganizationID()
  32488. case usagestatisticmonth.FieldAiResponse:
  32489. return m.AddedAiResponse()
  32490. case usagestatisticmonth.FieldSopRun:
  32491. return m.AddedSopRun()
  32492. case usagestatisticmonth.FieldTotalFriend:
  32493. return m.AddedTotalFriend()
  32494. case usagestatisticmonth.FieldTotalGroup:
  32495. return m.AddedTotalGroup()
  32496. case usagestatisticmonth.FieldAccountBalance:
  32497. return m.AddedAccountBalance()
  32498. case usagestatisticmonth.FieldConsumeToken:
  32499. return m.AddedConsumeToken()
  32500. case usagestatisticmonth.FieldActiveUser:
  32501. return m.AddedActiveUser()
  32502. case usagestatisticmonth.FieldNewUser:
  32503. return m.AddedNewUser()
  32504. }
  32505. return nil, false
  32506. }
  32507. // AddField adds the value to the field with the given name. It returns an error if
  32508. // the field is not defined in the schema, or if the type mismatched the field
  32509. // type.
  32510. func (m *UsageStatisticMonthMutation) AddField(name string, value ent.Value) error {
  32511. switch name {
  32512. case usagestatisticmonth.FieldStatus:
  32513. v, ok := value.(int8)
  32514. if !ok {
  32515. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32516. }
  32517. m.AddStatus(v)
  32518. return nil
  32519. case usagestatisticmonth.FieldAddtime:
  32520. v, ok := value.(int64)
  32521. if !ok {
  32522. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32523. }
  32524. m.AddAddtime(v)
  32525. return nil
  32526. case usagestatisticmonth.FieldType:
  32527. v, ok := value.(int)
  32528. if !ok {
  32529. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32530. }
  32531. m.AddType(v)
  32532. return nil
  32533. case usagestatisticmonth.FieldOrganizationID:
  32534. v, ok := value.(int64)
  32535. if !ok {
  32536. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32537. }
  32538. m.AddOrganizationID(v)
  32539. return nil
  32540. case usagestatisticmonth.FieldAiResponse:
  32541. v, ok := value.(int64)
  32542. if !ok {
  32543. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32544. }
  32545. m.AddAiResponse(v)
  32546. return nil
  32547. case usagestatisticmonth.FieldSopRun:
  32548. v, ok := value.(int64)
  32549. if !ok {
  32550. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32551. }
  32552. m.AddSopRun(v)
  32553. return nil
  32554. case usagestatisticmonth.FieldTotalFriend:
  32555. v, ok := value.(int64)
  32556. if !ok {
  32557. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32558. }
  32559. m.AddTotalFriend(v)
  32560. return nil
  32561. case usagestatisticmonth.FieldTotalGroup:
  32562. v, ok := value.(int64)
  32563. if !ok {
  32564. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32565. }
  32566. m.AddTotalGroup(v)
  32567. return nil
  32568. case usagestatisticmonth.FieldAccountBalance:
  32569. v, ok := value.(int64)
  32570. if !ok {
  32571. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32572. }
  32573. m.AddAccountBalance(v)
  32574. return nil
  32575. case usagestatisticmonth.FieldConsumeToken:
  32576. v, ok := value.(int64)
  32577. if !ok {
  32578. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32579. }
  32580. m.AddConsumeToken(v)
  32581. return nil
  32582. case usagestatisticmonth.FieldActiveUser:
  32583. v, ok := value.(int64)
  32584. if !ok {
  32585. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32586. }
  32587. m.AddActiveUser(v)
  32588. return nil
  32589. case usagestatisticmonth.FieldNewUser:
  32590. v, ok := value.(int64)
  32591. if !ok {
  32592. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32593. }
  32594. m.AddNewUser(v)
  32595. return nil
  32596. }
  32597. return fmt.Errorf("unknown UsageStatisticMonth numeric field %s", name)
  32598. }
  32599. // ClearedFields returns all nullable fields that were cleared during this
  32600. // mutation.
  32601. func (m *UsageStatisticMonthMutation) ClearedFields() []string {
  32602. var fields []string
  32603. if m.FieldCleared(usagestatisticmonth.FieldStatus) {
  32604. fields = append(fields, usagestatisticmonth.FieldStatus)
  32605. }
  32606. if m.FieldCleared(usagestatisticmonth.FieldDeletedAt) {
  32607. fields = append(fields, usagestatisticmonth.FieldDeletedAt)
  32608. }
  32609. if m.FieldCleared(usagestatisticmonth.FieldBotID) {
  32610. fields = append(fields, usagestatisticmonth.FieldBotID)
  32611. }
  32612. if m.FieldCleared(usagestatisticmonth.FieldOrganizationID) {
  32613. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  32614. }
  32615. return fields
  32616. }
  32617. // FieldCleared returns a boolean indicating if a field with the given name was
  32618. // cleared in this mutation.
  32619. func (m *UsageStatisticMonthMutation) FieldCleared(name string) bool {
  32620. _, ok := m.clearedFields[name]
  32621. return ok
  32622. }
  32623. // ClearField clears the value of the field with the given name. It returns an
  32624. // error if the field is not defined in the schema.
  32625. func (m *UsageStatisticMonthMutation) ClearField(name string) error {
  32626. switch name {
  32627. case usagestatisticmonth.FieldStatus:
  32628. m.ClearStatus()
  32629. return nil
  32630. case usagestatisticmonth.FieldDeletedAt:
  32631. m.ClearDeletedAt()
  32632. return nil
  32633. case usagestatisticmonth.FieldBotID:
  32634. m.ClearBotID()
  32635. return nil
  32636. case usagestatisticmonth.FieldOrganizationID:
  32637. m.ClearOrganizationID()
  32638. return nil
  32639. }
  32640. return fmt.Errorf("unknown UsageStatisticMonth nullable field %s", name)
  32641. }
  32642. // ResetField resets all changes in the mutation for the field with the given name.
  32643. // It returns an error if the field is not defined in the schema.
  32644. func (m *UsageStatisticMonthMutation) ResetField(name string) error {
  32645. switch name {
  32646. case usagestatisticmonth.FieldCreatedAt:
  32647. m.ResetCreatedAt()
  32648. return nil
  32649. case usagestatisticmonth.FieldUpdatedAt:
  32650. m.ResetUpdatedAt()
  32651. return nil
  32652. case usagestatisticmonth.FieldStatus:
  32653. m.ResetStatus()
  32654. return nil
  32655. case usagestatisticmonth.FieldDeletedAt:
  32656. m.ResetDeletedAt()
  32657. return nil
  32658. case usagestatisticmonth.FieldAddtime:
  32659. m.ResetAddtime()
  32660. return nil
  32661. case usagestatisticmonth.FieldType:
  32662. m.ResetType()
  32663. return nil
  32664. case usagestatisticmonth.FieldBotID:
  32665. m.ResetBotID()
  32666. return nil
  32667. case usagestatisticmonth.FieldOrganizationID:
  32668. m.ResetOrganizationID()
  32669. return nil
  32670. case usagestatisticmonth.FieldAiResponse:
  32671. m.ResetAiResponse()
  32672. return nil
  32673. case usagestatisticmonth.FieldSopRun:
  32674. m.ResetSopRun()
  32675. return nil
  32676. case usagestatisticmonth.FieldTotalFriend:
  32677. m.ResetTotalFriend()
  32678. return nil
  32679. case usagestatisticmonth.FieldTotalGroup:
  32680. m.ResetTotalGroup()
  32681. return nil
  32682. case usagestatisticmonth.FieldAccountBalance:
  32683. m.ResetAccountBalance()
  32684. return nil
  32685. case usagestatisticmonth.FieldConsumeToken:
  32686. m.ResetConsumeToken()
  32687. return nil
  32688. case usagestatisticmonth.FieldActiveUser:
  32689. m.ResetActiveUser()
  32690. return nil
  32691. case usagestatisticmonth.FieldNewUser:
  32692. m.ResetNewUser()
  32693. return nil
  32694. case usagestatisticmonth.FieldLabelDist:
  32695. m.ResetLabelDist()
  32696. return nil
  32697. }
  32698. return fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  32699. }
  32700. // AddedEdges returns all edge names that were set/added in this mutation.
  32701. func (m *UsageStatisticMonthMutation) AddedEdges() []string {
  32702. edges := make([]string, 0, 0)
  32703. return edges
  32704. }
  32705. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  32706. // name in this mutation.
  32707. func (m *UsageStatisticMonthMutation) AddedIDs(name string) []ent.Value {
  32708. return nil
  32709. }
  32710. // RemovedEdges returns all edge names that were removed in this mutation.
  32711. func (m *UsageStatisticMonthMutation) RemovedEdges() []string {
  32712. edges := make([]string, 0, 0)
  32713. return edges
  32714. }
  32715. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  32716. // the given name in this mutation.
  32717. func (m *UsageStatisticMonthMutation) RemovedIDs(name string) []ent.Value {
  32718. return nil
  32719. }
  32720. // ClearedEdges returns all edge names that were cleared in this mutation.
  32721. func (m *UsageStatisticMonthMutation) ClearedEdges() []string {
  32722. edges := make([]string, 0, 0)
  32723. return edges
  32724. }
  32725. // EdgeCleared returns a boolean which indicates if the edge with the given name
  32726. // was cleared in this mutation.
  32727. func (m *UsageStatisticMonthMutation) EdgeCleared(name string) bool {
  32728. return false
  32729. }
  32730. // ClearEdge clears the value of the edge with the given name. It returns an error
  32731. // if that edge is not defined in the schema.
  32732. func (m *UsageStatisticMonthMutation) ClearEdge(name string) error {
  32733. return fmt.Errorf("unknown UsageStatisticMonth unique edge %s", name)
  32734. }
  32735. // ResetEdge resets all changes to the edge with the given name in this mutation.
  32736. // It returns an error if the edge is not defined in the schema.
  32737. func (m *UsageStatisticMonthMutation) ResetEdge(name string) error {
  32738. return fmt.Errorf("unknown UsageStatisticMonth edge %s", name)
  32739. }
  32740. // UsageTotalMutation represents an operation that mutates the UsageTotal nodes in the graph.
  32741. type UsageTotalMutation struct {
  32742. config
  32743. op Op
  32744. typ string
  32745. id *uint64
  32746. created_at *time.Time
  32747. updated_at *time.Time
  32748. status *uint8
  32749. addstatus *int8
  32750. _type *int
  32751. add_type *int
  32752. bot_id *string
  32753. total_tokens *uint64
  32754. addtotal_tokens *int64
  32755. start_index *uint64
  32756. addstart_index *int64
  32757. end_index *uint64
  32758. addend_index *int64
  32759. organization_id *uint64
  32760. addorganization_id *int64
  32761. clearedFields map[string]struct{}
  32762. done bool
  32763. oldValue func(context.Context) (*UsageTotal, error)
  32764. predicates []predicate.UsageTotal
  32765. }
  32766. var _ ent.Mutation = (*UsageTotalMutation)(nil)
  32767. // usagetotalOption allows management of the mutation configuration using functional options.
  32768. type usagetotalOption func(*UsageTotalMutation)
  32769. // newUsageTotalMutation creates new mutation for the UsageTotal entity.
  32770. func newUsageTotalMutation(c config, op Op, opts ...usagetotalOption) *UsageTotalMutation {
  32771. m := &UsageTotalMutation{
  32772. config: c,
  32773. op: op,
  32774. typ: TypeUsageTotal,
  32775. clearedFields: make(map[string]struct{}),
  32776. }
  32777. for _, opt := range opts {
  32778. opt(m)
  32779. }
  32780. return m
  32781. }
  32782. // withUsageTotalID sets the ID field of the mutation.
  32783. func withUsageTotalID(id uint64) usagetotalOption {
  32784. return func(m *UsageTotalMutation) {
  32785. var (
  32786. err error
  32787. once sync.Once
  32788. value *UsageTotal
  32789. )
  32790. m.oldValue = func(ctx context.Context) (*UsageTotal, error) {
  32791. once.Do(func() {
  32792. if m.done {
  32793. err = errors.New("querying old values post mutation is not allowed")
  32794. } else {
  32795. value, err = m.Client().UsageTotal.Get(ctx, id)
  32796. }
  32797. })
  32798. return value, err
  32799. }
  32800. m.id = &id
  32801. }
  32802. }
  32803. // withUsageTotal sets the old UsageTotal of the mutation.
  32804. func withUsageTotal(node *UsageTotal) usagetotalOption {
  32805. return func(m *UsageTotalMutation) {
  32806. m.oldValue = func(context.Context) (*UsageTotal, error) {
  32807. return node, nil
  32808. }
  32809. m.id = &node.ID
  32810. }
  32811. }
  32812. // Client returns a new `ent.Client` from the mutation. If the mutation was
  32813. // executed in a transaction (ent.Tx), a transactional client is returned.
  32814. func (m UsageTotalMutation) Client() *Client {
  32815. client := &Client{config: m.config}
  32816. client.init()
  32817. return client
  32818. }
  32819. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  32820. // it returns an error otherwise.
  32821. func (m UsageTotalMutation) Tx() (*Tx, error) {
  32822. if _, ok := m.driver.(*txDriver); !ok {
  32823. return nil, errors.New("ent: mutation is not running in a transaction")
  32824. }
  32825. tx := &Tx{config: m.config}
  32826. tx.init()
  32827. return tx, nil
  32828. }
  32829. // SetID sets the value of the id field. Note that this
  32830. // operation is only accepted on creation of UsageTotal entities.
  32831. func (m *UsageTotalMutation) SetID(id uint64) {
  32832. m.id = &id
  32833. }
  32834. // ID returns the ID value in the mutation. Note that the ID is only available
  32835. // if it was provided to the builder or after it was returned from the database.
  32836. func (m *UsageTotalMutation) ID() (id uint64, exists bool) {
  32837. if m.id == nil {
  32838. return
  32839. }
  32840. return *m.id, true
  32841. }
  32842. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  32843. // That means, if the mutation is applied within a transaction with an isolation level such
  32844. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  32845. // or updated by the mutation.
  32846. func (m *UsageTotalMutation) IDs(ctx context.Context) ([]uint64, error) {
  32847. switch {
  32848. case m.op.Is(OpUpdateOne | OpDeleteOne):
  32849. id, exists := m.ID()
  32850. if exists {
  32851. return []uint64{id}, nil
  32852. }
  32853. fallthrough
  32854. case m.op.Is(OpUpdate | OpDelete):
  32855. return m.Client().UsageTotal.Query().Where(m.predicates...).IDs(ctx)
  32856. default:
  32857. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  32858. }
  32859. }
  32860. // SetCreatedAt sets the "created_at" field.
  32861. func (m *UsageTotalMutation) SetCreatedAt(t time.Time) {
  32862. m.created_at = &t
  32863. }
  32864. // CreatedAt returns the value of the "created_at" field in the mutation.
  32865. func (m *UsageTotalMutation) CreatedAt() (r time.Time, exists bool) {
  32866. v := m.created_at
  32867. if v == nil {
  32868. return
  32869. }
  32870. return *v, true
  32871. }
  32872. // OldCreatedAt returns the old "created_at" field's value of the UsageTotal entity.
  32873. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  32874. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32875. func (m *UsageTotalMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  32876. if !m.op.Is(OpUpdateOne) {
  32877. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  32878. }
  32879. if m.id == nil || m.oldValue == nil {
  32880. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  32881. }
  32882. oldValue, err := m.oldValue(ctx)
  32883. if err != nil {
  32884. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  32885. }
  32886. return oldValue.CreatedAt, nil
  32887. }
  32888. // ResetCreatedAt resets all changes to the "created_at" field.
  32889. func (m *UsageTotalMutation) ResetCreatedAt() {
  32890. m.created_at = nil
  32891. }
  32892. // SetUpdatedAt sets the "updated_at" field.
  32893. func (m *UsageTotalMutation) SetUpdatedAt(t time.Time) {
  32894. m.updated_at = &t
  32895. }
  32896. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  32897. func (m *UsageTotalMutation) UpdatedAt() (r time.Time, exists bool) {
  32898. v := m.updated_at
  32899. if v == nil {
  32900. return
  32901. }
  32902. return *v, true
  32903. }
  32904. // OldUpdatedAt returns the old "updated_at" field's value of the UsageTotal entity.
  32905. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  32906. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32907. func (m *UsageTotalMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  32908. if !m.op.Is(OpUpdateOne) {
  32909. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  32910. }
  32911. if m.id == nil || m.oldValue == nil {
  32912. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  32913. }
  32914. oldValue, err := m.oldValue(ctx)
  32915. if err != nil {
  32916. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  32917. }
  32918. return oldValue.UpdatedAt, nil
  32919. }
  32920. // ResetUpdatedAt resets all changes to the "updated_at" field.
  32921. func (m *UsageTotalMutation) ResetUpdatedAt() {
  32922. m.updated_at = nil
  32923. }
  32924. // SetStatus sets the "status" field.
  32925. func (m *UsageTotalMutation) SetStatus(u uint8) {
  32926. m.status = &u
  32927. m.addstatus = nil
  32928. }
  32929. // Status returns the value of the "status" field in the mutation.
  32930. func (m *UsageTotalMutation) Status() (r uint8, exists bool) {
  32931. v := m.status
  32932. if v == nil {
  32933. return
  32934. }
  32935. return *v, true
  32936. }
  32937. // OldStatus returns the old "status" field's value of the UsageTotal entity.
  32938. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  32939. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32940. func (m *UsageTotalMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  32941. if !m.op.Is(OpUpdateOne) {
  32942. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  32943. }
  32944. if m.id == nil || m.oldValue == nil {
  32945. return v, errors.New("OldStatus requires an ID field in the mutation")
  32946. }
  32947. oldValue, err := m.oldValue(ctx)
  32948. if err != nil {
  32949. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  32950. }
  32951. return oldValue.Status, nil
  32952. }
  32953. // AddStatus adds u to the "status" field.
  32954. func (m *UsageTotalMutation) AddStatus(u int8) {
  32955. if m.addstatus != nil {
  32956. *m.addstatus += u
  32957. } else {
  32958. m.addstatus = &u
  32959. }
  32960. }
  32961. // AddedStatus returns the value that was added to the "status" field in this mutation.
  32962. func (m *UsageTotalMutation) AddedStatus() (r int8, exists bool) {
  32963. v := m.addstatus
  32964. if v == nil {
  32965. return
  32966. }
  32967. return *v, true
  32968. }
  32969. // ClearStatus clears the value of the "status" field.
  32970. func (m *UsageTotalMutation) ClearStatus() {
  32971. m.status = nil
  32972. m.addstatus = nil
  32973. m.clearedFields[usagetotal.FieldStatus] = struct{}{}
  32974. }
  32975. // StatusCleared returns if the "status" field was cleared in this mutation.
  32976. func (m *UsageTotalMutation) StatusCleared() bool {
  32977. _, ok := m.clearedFields[usagetotal.FieldStatus]
  32978. return ok
  32979. }
  32980. // ResetStatus resets all changes to the "status" field.
  32981. func (m *UsageTotalMutation) ResetStatus() {
  32982. m.status = nil
  32983. m.addstatus = nil
  32984. delete(m.clearedFields, usagetotal.FieldStatus)
  32985. }
  32986. // SetType sets the "type" field.
  32987. func (m *UsageTotalMutation) SetType(i int) {
  32988. m._type = &i
  32989. m.add_type = nil
  32990. }
  32991. // GetType returns the value of the "type" field in the mutation.
  32992. func (m *UsageTotalMutation) GetType() (r int, exists bool) {
  32993. v := m._type
  32994. if v == nil {
  32995. return
  32996. }
  32997. return *v, true
  32998. }
  32999. // OldType returns the old "type" field's value of the UsageTotal entity.
  33000. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  33001. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33002. func (m *UsageTotalMutation) OldType(ctx context.Context) (v int, err error) {
  33003. if !m.op.Is(OpUpdateOne) {
  33004. return v, errors.New("OldType is only allowed on UpdateOne operations")
  33005. }
  33006. if m.id == nil || m.oldValue == nil {
  33007. return v, errors.New("OldType requires an ID field in the mutation")
  33008. }
  33009. oldValue, err := m.oldValue(ctx)
  33010. if err != nil {
  33011. return v, fmt.Errorf("querying old value for OldType: %w", err)
  33012. }
  33013. return oldValue.Type, nil
  33014. }
  33015. // AddType adds i to the "type" field.
  33016. func (m *UsageTotalMutation) AddType(i int) {
  33017. if m.add_type != nil {
  33018. *m.add_type += i
  33019. } else {
  33020. m.add_type = &i
  33021. }
  33022. }
  33023. // AddedType returns the value that was added to the "type" field in this mutation.
  33024. func (m *UsageTotalMutation) AddedType() (r int, exists bool) {
  33025. v := m.add_type
  33026. if v == nil {
  33027. return
  33028. }
  33029. return *v, true
  33030. }
  33031. // ClearType clears the value of the "type" field.
  33032. func (m *UsageTotalMutation) ClearType() {
  33033. m._type = nil
  33034. m.add_type = nil
  33035. m.clearedFields[usagetotal.FieldType] = struct{}{}
  33036. }
  33037. // TypeCleared returns if the "type" field was cleared in this mutation.
  33038. func (m *UsageTotalMutation) TypeCleared() bool {
  33039. _, ok := m.clearedFields[usagetotal.FieldType]
  33040. return ok
  33041. }
  33042. // ResetType resets all changes to the "type" field.
  33043. func (m *UsageTotalMutation) ResetType() {
  33044. m._type = nil
  33045. m.add_type = nil
  33046. delete(m.clearedFields, usagetotal.FieldType)
  33047. }
  33048. // SetBotID sets the "bot_id" field.
  33049. func (m *UsageTotalMutation) SetBotID(s string) {
  33050. m.bot_id = &s
  33051. }
  33052. // BotID returns the value of the "bot_id" field in the mutation.
  33053. func (m *UsageTotalMutation) BotID() (r string, exists bool) {
  33054. v := m.bot_id
  33055. if v == nil {
  33056. return
  33057. }
  33058. return *v, true
  33059. }
  33060. // OldBotID returns the old "bot_id" field's value of the UsageTotal entity.
  33061. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  33062. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33063. func (m *UsageTotalMutation) OldBotID(ctx context.Context) (v string, err error) {
  33064. if !m.op.Is(OpUpdateOne) {
  33065. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  33066. }
  33067. if m.id == nil || m.oldValue == nil {
  33068. return v, errors.New("OldBotID requires an ID field in the mutation")
  33069. }
  33070. oldValue, err := m.oldValue(ctx)
  33071. if err != nil {
  33072. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  33073. }
  33074. return oldValue.BotID, nil
  33075. }
  33076. // ResetBotID resets all changes to the "bot_id" field.
  33077. func (m *UsageTotalMutation) ResetBotID() {
  33078. m.bot_id = nil
  33079. }
  33080. // SetTotalTokens sets the "total_tokens" field.
  33081. func (m *UsageTotalMutation) SetTotalTokens(u uint64) {
  33082. m.total_tokens = &u
  33083. m.addtotal_tokens = nil
  33084. }
  33085. // TotalTokens returns the value of the "total_tokens" field in the mutation.
  33086. func (m *UsageTotalMutation) TotalTokens() (r uint64, exists bool) {
  33087. v := m.total_tokens
  33088. if v == nil {
  33089. return
  33090. }
  33091. return *v, true
  33092. }
  33093. // OldTotalTokens returns the old "total_tokens" field's value of the UsageTotal entity.
  33094. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  33095. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33096. func (m *UsageTotalMutation) OldTotalTokens(ctx context.Context) (v uint64, err error) {
  33097. if !m.op.Is(OpUpdateOne) {
  33098. return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
  33099. }
  33100. if m.id == nil || m.oldValue == nil {
  33101. return v, errors.New("OldTotalTokens requires an ID field in the mutation")
  33102. }
  33103. oldValue, err := m.oldValue(ctx)
  33104. if err != nil {
  33105. return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
  33106. }
  33107. return oldValue.TotalTokens, nil
  33108. }
  33109. // AddTotalTokens adds u to the "total_tokens" field.
  33110. func (m *UsageTotalMutation) AddTotalTokens(u int64) {
  33111. if m.addtotal_tokens != nil {
  33112. *m.addtotal_tokens += u
  33113. } else {
  33114. m.addtotal_tokens = &u
  33115. }
  33116. }
  33117. // AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
  33118. func (m *UsageTotalMutation) AddedTotalTokens() (r int64, exists bool) {
  33119. v := m.addtotal_tokens
  33120. if v == nil {
  33121. return
  33122. }
  33123. return *v, true
  33124. }
  33125. // ClearTotalTokens clears the value of the "total_tokens" field.
  33126. func (m *UsageTotalMutation) ClearTotalTokens() {
  33127. m.total_tokens = nil
  33128. m.addtotal_tokens = nil
  33129. m.clearedFields[usagetotal.FieldTotalTokens] = struct{}{}
  33130. }
  33131. // TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
  33132. func (m *UsageTotalMutation) TotalTokensCleared() bool {
  33133. _, ok := m.clearedFields[usagetotal.FieldTotalTokens]
  33134. return ok
  33135. }
  33136. // ResetTotalTokens resets all changes to the "total_tokens" field.
  33137. func (m *UsageTotalMutation) ResetTotalTokens() {
  33138. m.total_tokens = nil
  33139. m.addtotal_tokens = nil
  33140. delete(m.clearedFields, usagetotal.FieldTotalTokens)
  33141. }
  33142. // SetStartIndex sets the "start_index" field.
  33143. func (m *UsageTotalMutation) SetStartIndex(u uint64) {
  33144. m.start_index = &u
  33145. m.addstart_index = nil
  33146. }
  33147. // StartIndex returns the value of the "start_index" field in the mutation.
  33148. func (m *UsageTotalMutation) StartIndex() (r uint64, exists bool) {
  33149. v := m.start_index
  33150. if v == nil {
  33151. return
  33152. }
  33153. return *v, true
  33154. }
  33155. // OldStartIndex returns the old "start_index" field's value of the UsageTotal entity.
  33156. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  33157. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33158. func (m *UsageTotalMutation) OldStartIndex(ctx context.Context) (v uint64, err error) {
  33159. if !m.op.Is(OpUpdateOne) {
  33160. return v, errors.New("OldStartIndex is only allowed on UpdateOne operations")
  33161. }
  33162. if m.id == nil || m.oldValue == nil {
  33163. return v, errors.New("OldStartIndex requires an ID field in the mutation")
  33164. }
  33165. oldValue, err := m.oldValue(ctx)
  33166. if err != nil {
  33167. return v, fmt.Errorf("querying old value for OldStartIndex: %w", err)
  33168. }
  33169. return oldValue.StartIndex, nil
  33170. }
  33171. // AddStartIndex adds u to the "start_index" field.
  33172. func (m *UsageTotalMutation) AddStartIndex(u int64) {
  33173. if m.addstart_index != nil {
  33174. *m.addstart_index += u
  33175. } else {
  33176. m.addstart_index = &u
  33177. }
  33178. }
  33179. // AddedStartIndex returns the value that was added to the "start_index" field in this mutation.
  33180. func (m *UsageTotalMutation) AddedStartIndex() (r int64, exists bool) {
  33181. v := m.addstart_index
  33182. if v == nil {
  33183. return
  33184. }
  33185. return *v, true
  33186. }
  33187. // ClearStartIndex clears the value of the "start_index" field.
  33188. func (m *UsageTotalMutation) ClearStartIndex() {
  33189. m.start_index = nil
  33190. m.addstart_index = nil
  33191. m.clearedFields[usagetotal.FieldStartIndex] = struct{}{}
  33192. }
  33193. // StartIndexCleared returns if the "start_index" field was cleared in this mutation.
  33194. func (m *UsageTotalMutation) StartIndexCleared() bool {
  33195. _, ok := m.clearedFields[usagetotal.FieldStartIndex]
  33196. return ok
  33197. }
  33198. // ResetStartIndex resets all changes to the "start_index" field.
  33199. func (m *UsageTotalMutation) ResetStartIndex() {
  33200. m.start_index = nil
  33201. m.addstart_index = nil
  33202. delete(m.clearedFields, usagetotal.FieldStartIndex)
  33203. }
  33204. // SetEndIndex sets the "end_index" field.
  33205. func (m *UsageTotalMutation) SetEndIndex(u uint64) {
  33206. m.end_index = &u
  33207. m.addend_index = nil
  33208. }
  33209. // EndIndex returns the value of the "end_index" field in the mutation.
  33210. func (m *UsageTotalMutation) EndIndex() (r uint64, exists bool) {
  33211. v := m.end_index
  33212. if v == nil {
  33213. return
  33214. }
  33215. return *v, true
  33216. }
  33217. // OldEndIndex returns the old "end_index" field's value of the UsageTotal entity.
  33218. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  33219. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33220. func (m *UsageTotalMutation) OldEndIndex(ctx context.Context) (v uint64, err error) {
  33221. if !m.op.Is(OpUpdateOne) {
  33222. return v, errors.New("OldEndIndex is only allowed on UpdateOne operations")
  33223. }
  33224. if m.id == nil || m.oldValue == nil {
  33225. return v, errors.New("OldEndIndex requires an ID field in the mutation")
  33226. }
  33227. oldValue, err := m.oldValue(ctx)
  33228. if err != nil {
  33229. return v, fmt.Errorf("querying old value for OldEndIndex: %w", err)
  33230. }
  33231. return oldValue.EndIndex, nil
  33232. }
  33233. // AddEndIndex adds u to the "end_index" field.
  33234. func (m *UsageTotalMutation) AddEndIndex(u int64) {
  33235. if m.addend_index != nil {
  33236. *m.addend_index += u
  33237. } else {
  33238. m.addend_index = &u
  33239. }
  33240. }
  33241. // AddedEndIndex returns the value that was added to the "end_index" field in this mutation.
  33242. func (m *UsageTotalMutation) AddedEndIndex() (r int64, exists bool) {
  33243. v := m.addend_index
  33244. if v == nil {
  33245. return
  33246. }
  33247. return *v, true
  33248. }
  33249. // ClearEndIndex clears the value of the "end_index" field.
  33250. func (m *UsageTotalMutation) ClearEndIndex() {
  33251. m.end_index = nil
  33252. m.addend_index = nil
  33253. m.clearedFields[usagetotal.FieldEndIndex] = struct{}{}
  33254. }
  33255. // EndIndexCleared returns if the "end_index" field was cleared in this mutation.
  33256. func (m *UsageTotalMutation) EndIndexCleared() bool {
  33257. _, ok := m.clearedFields[usagetotal.FieldEndIndex]
  33258. return ok
  33259. }
  33260. // ResetEndIndex resets all changes to the "end_index" field.
  33261. func (m *UsageTotalMutation) ResetEndIndex() {
  33262. m.end_index = nil
  33263. m.addend_index = nil
  33264. delete(m.clearedFields, usagetotal.FieldEndIndex)
  33265. }
  33266. // SetOrganizationID sets the "organization_id" field.
  33267. func (m *UsageTotalMutation) SetOrganizationID(u uint64) {
  33268. m.organization_id = &u
  33269. m.addorganization_id = nil
  33270. }
  33271. // OrganizationID returns the value of the "organization_id" field in the mutation.
  33272. func (m *UsageTotalMutation) OrganizationID() (r uint64, exists bool) {
  33273. v := m.organization_id
  33274. if v == nil {
  33275. return
  33276. }
  33277. return *v, true
  33278. }
  33279. // OldOrganizationID returns the old "organization_id" field's value of the UsageTotal entity.
  33280. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  33281. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33282. func (m *UsageTotalMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  33283. if !m.op.Is(OpUpdateOne) {
  33284. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  33285. }
  33286. if m.id == nil || m.oldValue == nil {
  33287. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  33288. }
  33289. oldValue, err := m.oldValue(ctx)
  33290. if err != nil {
  33291. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  33292. }
  33293. return oldValue.OrganizationID, nil
  33294. }
  33295. // AddOrganizationID adds u to the "organization_id" field.
  33296. func (m *UsageTotalMutation) AddOrganizationID(u int64) {
  33297. if m.addorganization_id != nil {
  33298. *m.addorganization_id += u
  33299. } else {
  33300. m.addorganization_id = &u
  33301. }
  33302. }
  33303. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  33304. func (m *UsageTotalMutation) AddedOrganizationID() (r int64, exists bool) {
  33305. v := m.addorganization_id
  33306. if v == nil {
  33307. return
  33308. }
  33309. return *v, true
  33310. }
  33311. // ClearOrganizationID clears the value of the "organization_id" field.
  33312. func (m *UsageTotalMutation) ClearOrganizationID() {
  33313. m.organization_id = nil
  33314. m.addorganization_id = nil
  33315. m.clearedFields[usagetotal.FieldOrganizationID] = struct{}{}
  33316. }
  33317. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  33318. func (m *UsageTotalMutation) OrganizationIDCleared() bool {
  33319. _, ok := m.clearedFields[usagetotal.FieldOrganizationID]
  33320. return ok
  33321. }
  33322. // ResetOrganizationID resets all changes to the "organization_id" field.
  33323. func (m *UsageTotalMutation) ResetOrganizationID() {
  33324. m.organization_id = nil
  33325. m.addorganization_id = nil
  33326. delete(m.clearedFields, usagetotal.FieldOrganizationID)
  33327. }
  33328. // Where appends a list predicates to the UsageTotalMutation builder.
  33329. func (m *UsageTotalMutation) Where(ps ...predicate.UsageTotal) {
  33330. m.predicates = append(m.predicates, ps...)
  33331. }
  33332. // WhereP appends storage-level predicates to the UsageTotalMutation builder. Using this method,
  33333. // users can use type-assertion to append predicates that do not depend on any generated package.
  33334. func (m *UsageTotalMutation) WhereP(ps ...func(*sql.Selector)) {
  33335. p := make([]predicate.UsageTotal, len(ps))
  33336. for i := range ps {
  33337. p[i] = ps[i]
  33338. }
  33339. m.Where(p...)
  33340. }
  33341. // Op returns the operation name.
  33342. func (m *UsageTotalMutation) Op() Op {
  33343. return m.op
  33344. }
  33345. // SetOp allows setting the mutation operation.
  33346. func (m *UsageTotalMutation) SetOp(op Op) {
  33347. m.op = op
  33348. }
  33349. // Type returns the node type of this mutation (UsageTotal).
  33350. func (m *UsageTotalMutation) Type() string {
  33351. return m.typ
  33352. }
  33353. // Fields returns all fields that were changed during this mutation. Note that in
  33354. // order to get all numeric fields that were incremented/decremented, call
  33355. // AddedFields().
  33356. func (m *UsageTotalMutation) Fields() []string {
  33357. fields := make([]string, 0, 9)
  33358. if m.created_at != nil {
  33359. fields = append(fields, usagetotal.FieldCreatedAt)
  33360. }
  33361. if m.updated_at != nil {
  33362. fields = append(fields, usagetotal.FieldUpdatedAt)
  33363. }
  33364. if m.status != nil {
  33365. fields = append(fields, usagetotal.FieldStatus)
  33366. }
  33367. if m._type != nil {
  33368. fields = append(fields, usagetotal.FieldType)
  33369. }
  33370. if m.bot_id != nil {
  33371. fields = append(fields, usagetotal.FieldBotID)
  33372. }
  33373. if m.total_tokens != nil {
  33374. fields = append(fields, usagetotal.FieldTotalTokens)
  33375. }
  33376. if m.start_index != nil {
  33377. fields = append(fields, usagetotal.FieldStartIndex)
  33378. }
  33379. if m.end_index != nil {
  33380. fields = append(fields, usagetotal.FieldEndIndex)
  33381. }
  33382. if m.organization_id != nil {
  33383. fields = append(fields, usagetotal.FieldOrganizationID)
  33384. }
  33385. return fields
  33386. }
  33387. // Field returns the value of a field with the given name. The second boolean
  33388. // return value indicates that this field was not set, or was not defined in the
  33389. // schema.
  33390. func (m *UsageTotalMutation) Field(name string) (ent.Value, bool) {
  33391. switch name {
  33392. case usagetotal.FieldCreatedAt:
  33393. return m.CreatedAt()
  33394. case usagetotal.FieldUpdatedAt:
  33395. return m.UpdatedAt()
  33396. case usagetotal.FieldStatus:
  33397. return m.Status()
  33398. case usagetotal.FieldType:
  33399. return m.GetType()
  33400. case usagetotal.FieldBotID:
  33401. return m.BotID()
  33402. case usagetotal.FieldTotalTokens:
  33403. return m.TotalTokens()
  33404. case usagetotal.FieldStartIndex:
  33405. return m.StartIndex()
  33406. case usagetotal.FieldEndIndex:
  33407. return m.EndIndex()
  33408. case usagetotal.FieldOrganizationID:
  33409. return m.OrganizationID()
  33410. }
  33411. return nil, false
  33412. }
  33413. // OldField returns the old value of the field from the database. An error is
  33414. // returned if the mutation operation is not UpdateOne, or the query to the
  33415. // database failed.
  33416. func (m *UsageTotalMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  33417. switch name {
  33418. case usagetotal.FieldCreatedAt:
  33419. return m.OldCreatedAt(ctx)
  33420. case usagetotal.FieldUpdatedAt:
  33421. return m.OldUpdatedAt(ctx)
  33422. case usagetotal.FieldStatus:
  33423. return m.OldStatus(ctx)
  33424. case usagetotal.FieldType:
  33425. return m.OldType(ctx)
  33426. case usagetotal.FieldBotID:
  33427. return m.OldBotID(ctx)
  33428. case usagetotal.FieldTotalTokens:
  33429. return m.OldTotalTokens(ctx)
  33430. case usagetotal.FieldStartIndex:
  33431. return m.OldStartIndex(ctx)
  33432. case usagetotal.FieldEndIndex:
  33433. return m.OldEndIndex(ctx)
  33434. case usagetotal.FieldOrganizationID:
  33435. return m.OldOrganizationID(ctx)
  33436. }
  33437. return nil, fmt.Errorf("unknown UsageTotal field %s", name)
  33438. }
  33439. // SetField sets the value of a field with the given name. It returns an error if
  33440. // the field is not defined in the schema, or if the type mismatched the field
  33441. // type.
  33442. func (m *UsageTotalMutation) SetField(name string, value ent.Value) error {
  33443. switch name {
  33444. case usagetotal.FieldCreatedAt:
  33445. v, ok := value.(time.Time)
  33446. if !ok {
  33447. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33448. }
  33449. m.SetCreatedAt(v)
  33450. return nil
  33451. case usagetotal.FieldUpdatedAt:
  33452. v, ok := value.(time.Time)
  33453. if !ok {
  33454. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33455. }
  33456. m.SetUpdatedAt(v)
  33457. return nil
  33458. case usagetotal.FieldStatus:
  33459. v, ok := value.(uint8)
  33460. if !ok {
  33461. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33462. }
  33463. m.SetStatus(v)
  33464. return nil
  33465. case usagetotal.FieldType:
  33466. v, ok := value.(int)
  33467. if !ok {
  33468. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33469. }
  33470. m.SetType(v)
  33471. return nil
  33472. case usagetotal.FieldBotID:
  33473. v, ok := value.(string)
  33474. if !ok {
  33475. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33476. }
  33477. m.SetBotID(v)
  33478. return nil
  33479. case usagetotal.FieldTotalTokens:
  33480. v, ok := value.(uint64)
  33481. if !ok {
  33482. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33483. }
  33484. m.SetTotalTokens(v)
  33485. return nil
  33486. case usagetotal.FieldStartIndex:
  33487. v, ok := value.(uint64)
  33488. if !ok {
  33489. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33490. }
  33491. m.SetStartIndex(v)
  33492. return nil
  33493. case usagetotal.FieldEndIndex:
  33494. v, ok := value.(uint64)
  33495. if !ok {
  33496. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33497. }
  33498. m.SetEndIndex(v)
  33499. return nil
  33500. case usagetotal.FieldOrganizationID:
  33501. v, ok := value.(uint64)
  33502. if !ok {
  33503. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33504. }
  33505. m.SetOrganizationID(v)
  33506. return nil
  33507. }
  33508. return fmt.Errorf("unknown UsageTotal field %s", name)
  33509. }
  33510. // AddedFields returns all numeric fields that were incremented/decremented during
  33511. // this mutation.
  33512. func (m *UsageTotalMutation) AddedFields() []string {
  33513. var fields []string
  33514. if m.addstatus != nil {
  33515. fields = append(fields, usagetotal.FieldStatus)
  33516. }
  33517. if m.add_type != nil {
  33518. fields = append(fields, usagetotal.FieldType)
  33519. }
  33520. if m.addtotal_tokens != nil {
  33521. fields = append(fields, usagetotal.FieldTotalTokens)
  33522. }
  33523. if m.addstart_index != nil {
  33524. fields = append(fields, usagetotal.FieldStartIndex)
  33525. }
  33526. if m.addend_index != nil {
  33527. fields = append(fields, usagetotal.FieldEndIndex)
  33528. }
  33529. if m.addorganization_id != nil {
  33530. fields = append(fields, usagetotal.FieldOrganizationID)
  33531. }
  33532. return fields
  33533. }
  33534. // AddedField returns the numeric value that was incremented/decremented on a field
  33535. // with the given name. The second boolean return value indicates that this field
  33536. // was not set, or was not defined in the schema.
  33537. func (m *UsageTotalMutation) AddedField(name string) (ent.Value, bool) {
  33538. switch name {
  33539. case usagetotal.FieldStatus:
  33540. return m.AddedStatus()
  33541. case usagetotal.FieldType:
  33542. return m.AddedType()
  33543. case usagetotal.FieldTotalTokens:
  33544. return m.AddedTotalTokens()
  33545. case usagetotal.FieldStartIndex:
  33546. return m.AddedStartIndex()
  33547. case usagetotal.FieldEndIndex:
  33548. return m.AddedEndIndex()
  33549. case usagetotal.FieldOrganizationID:
  33550. return m.AddedOrganizationID()
  33551. }
  33552. return nil, false
  33553. }
  33554. // AddField adds the value to the field with the given name. It returns an error if
  33555. // the field is not defined in the schema, or if the type mismatched the field
  33556. // type.
  33557. func (m *UsageTotalMutation) AddField(name string, value ent.Value) error {
  33558. switch name {
  33559. case usagetotal.FieldStatus:
  33560. v, ok := value.(int8)
  33561. if !ok {
  33562. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33563. }
  33564. m.AddStatus(v)
  33565. return nil
  33566. case usagetotal.FieldType:
  33567. v, ok := value.(int)
  33568. if !ok {
  33569. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33570. }
  33571. m.AddType(v)
  33572. return nil
  33573. case usagetotal.FieldTotalTokens:
  33574. v, ok := value.(int64)
  33575. if !ok {
  33576. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33577. }
  33578. m.AddTotalTokens(v)
  33579. return nil
  33580. case usagetotal.FieldStartIndex:
  33581. v, ok := value.(int64)
  33582. if !ok {
  33583. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33584. }
  33585. m.AddStartIndex(v)
  33586. return nil
  33587. case usagetotal.FieldEndIndex:
  33588. v, ok := value.(int64)
  33589. if !ok {
  33590. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33591. }
  33592. m.AddEndIndex(v)
  33593. return nil
  33594. case usagetotal.FieldOrganizationID:
  33595. v, ok := value.(int64)
  33596. if !ok {
  33597. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33598. }
  33599. m.AddOrganizationID(v)
  33600. return nil
  33601. }
  33602. return fmt.Errorf("unknown UsageTotal numeric field %s", name)
  33603. }
  33604. // ClearedFields returns all nullable fields that were cleared during this
  33605. // mutation.
  33606. func (m *UsageTotalMutation) ClearedFields() []string {
  33607. var fields []string
  33608. if m.FieldCleared(usagetotal.FieldStatus) {
  33609. fields = append(fields, usagetotal.FieldStatus)
  33610. }
  33611. if m.FieldCleared(usagetotal.FieldType) {
  33612. fields = append(fields, usagetotal.FieldType)
  33613. }
  33614. if m.FieldCleared(usagetotal.FieldTotalTokens) {
  33615. fields = append(fields, usagetotal.FieldTotalTokens)
  33616. }
  33617. if m.FieldCleared(usagetotal.FieldStartIndex) {
  33618. fields = append(fields, usagetotal.FieldStartIndex)
  33619. }
  33620. if m.FieldCleared(usagetotal.FieldEndIndex) {
  33621. fields = append(fields, usagetotal.FieldEndIndex)
  33622. }
  33623. if m.FieldCleared(usagetotal.FieldOrganizationID) {
  33624. fields = append(fields, usagetotal.FieldOrganizationID)
  33625. }
  33626. return fields
  33627. }
  33628. // FieldCleared returns a boolean indicating if a field with the given name was
  33629. // cleared in this mutation.
  33630. func (m *UsageTotalMutation) FieldCleared(name string) bool {
  33631. _, ok := m.clearedFields[name]
  33632. return ok
  33633. }
  33634. // ClearField clears the value of the field with the given name. It returns an
  33635. // error if the field is not defined in the schema.
  33636. func (m *UsageTotalMutation) ClearField(name string) error {
  33637. switch name {
  33638. case usagetotal.FieldStatus:
  33639. m.ClearStatus()
  33640. return nil
  33641. case usagetotal.FieldType:
  33642. m.ClearType()
  33643. return nil
  33644. case usagetotal.FieldTotalTokens:
  33645. m.ClearTotalTokens()
  33646. return nil
  33647. case usagetotal.FieldStartIndex:
  33648. m.ClearStartIndex()
  33649. return nil
  33650. case usagetotal.FieldEndIndex:
  33651. m.ClearEndIndex()
  33652. return nil
  33653. case usagetotal.FieldOrganizationID:
  33654. m.ClearOrganizationID()
  33655. return nil
  33656. }
  33657. return fmt.Errorf("unknown UsageTotal nullable field %s", name)
  33658. }
  33659. // ResetField resets all changes in the mutation for the field with the given name.
  33660. // It returns an error if the field is not defined in the schema.
  33661. func (m *UsageTotalMutation) ResetField(name string) error {
  33662. switch name {
  33663. case usagetotal.FieldCreatedAt:
  33664. m.ResetCreatedAt()
  33665. return nil
  33666. case usagetotal.FieldUpdatedAt:
  33667. m.ResetUpdatedAt()
  33668. return nil
  33669. case usagetotal.FieldStatus:
  33670. m.ResetStatus()
  33671. return nil
  33672. case usagetotal.FieldType:
  33673. m.ResetType()
  33674. return nil
  33675. case usagetotal.FieldBotID:
  33676. m.ResetBotID()
  33677. return nil
  33678. case usagetotal.FieldTotalTokens:
  33679. m.ResetTotalTokens()
  33680. return nil
  33681. case usagetotal.FieldStartIndex:
  33682. m.ResetStartIndex()
  33683. return nil
  33684. case usagetotal.FieldEndIndex:
  33685. m.ResetEndIndex()
  33686. return nil
  33687. case usagetotal.FieldOrganizationID:
  33688. m.ResetOrganizationID()
  33689. return nil
  33690. }
  33691. return fmt.Errorf("unknown UsageTotal field %s", name)
  33692. }
  33693. // AddedEdges returns all edge names that were set/added in this mutation.
  33694. func (m *UsageTotalMutation) AddedEdges() []string {
  33695. edges := make([]string, 0, 0)
  33696. return edges
  33697. }
  33698. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  33699. // name in this mutation.
  33700. func (m *UsageTotalMutation) AddedIDs(name string) []ent.Value {
  33701. return nil
  33702. }
  33703. // RemovedEdges returns all edge names that were removed in this mutation.
  33704. func (m *UsageTotalMutation) RemovedEdges() []string {
  33705. edges := make([]string, 0, 0)
  33706. return edges
  33707. }
  33708. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  33709. // the given name in this mutation.
  33710. func (m *UsageTotalMutation) RemovedIDs(name string) []ent.Value {
  33711. return nil
  33712. }
  33713. // ClearedEdges returns all edge names that were cleared in this mutation.
  33714. func (m *UsageTotalMutation) ClearedEdges() []string {
  33715. edges := make([]string, 0, 0)
  33716. return edges
  33717. }
  33718. // EdgeCleared returns a boolean which indicates if the edge with the given name
  33719. // was cleared in this mutation.
  33720. func (m *UsageTotalMutation) EdgeCleared(name string) bool {
  33721. return false
  33722. }
  33723. // ClearEdge clears the value of the edge with the given name. It returns an error
  33724. // if that edge is not defined in the schema.
  33725. func (m *UsageTotalMutation) ClearEdge(name string) error {
  33726. return fmt.Errorf("unknown UsageTotal unique edge %s", name)
  33727. }
  33728. // ResetEdge resets all changes to the edge with the given name in this mutation.
  33729. // It returns an error if the edge is not defined in the schema.
  33730. func (m *UsageTotalMutation) ResetEdge(name string) error {
  33731. return fmt.Errorf("unknown UsageTotal edge %s", name)
  33732. }
  33733. // WhatsappMutation represents an operation that mutates the Whatsapp nodes in the graph.
  33734. type WhatsappMutation struct {
  33735. config
  33736. op Op
  33737. typ string
  33738. id *uint64
  33739. created_at *time.Time
  33740. updated_at *time.Time
  33741. status *uint8
  33742. addstatus *int8
  33743. deleted_at *time.Time
  33744. wa_id *string
  33745. callback *string
  33746. account *string
  33747. cc *string
  33748. phone *string
  33749. phone_name *string
  33750. phone_status *int8
  33751. addphone_status *int8
  33752. organization_id *uint64
  33753. addorganization_id *int64
  33754. api_base *string
  33755. api_key *string
  33756. allow_list *[]string
  33757. appendallow_list []string
  33758. group_allow_list *[]string
  33759. appendgroup_allow_list []string
  33760. block_list *[]string
  33761. appendblock_list []string
  33762. group_block_list *[]string
  33763. appendgroup_block_list []string
  33764. clearedFields map[string]struct{}
  33765. agent *uint64
  33766. clearedagent bool
  33767. done bool
  33768. oldValue func(context.Context) (*Whatsapp, error)
  33769. predicates []predicate.Whatsapp
  33770. }
  33771. var _ ent.Mutation = (*WhatsappMutation)(nil)
  33772. // whatsappOption allows management of the mutation configuration using functional options.
  33773. type whatsappOption func(*WhatsappMutation)
  33774. // newWhatsappMutation creates new mutation for the Whatsapp entity.
  33775. func newWhatsappMutation(c config, op Op, opts ...whatsappOption) *WhatsappMutation {
  33776. m := &WhatsappMutation{
  33777. config: c,
  33778. op: op,
  33779. typ: TypeWhatsapp,
  33780. clearedFields: make(map[string]struct{}),
  33781. }
  33782. for _, opt := range opts {
  33783. opt(m)
  33784. }
  33785. return m
  33786. }
  33787. // withWhatsappID sets the ID field of the mutation.
  33788. func withWhatsappID(id uint64) whatsappOption {
  33789. return func(m *WhatsappMutation) {
  33790. var (
  33791. err error
  33792. once sync.Once
  33793. value *Whatsapp
  33794. )
  33795. m.oldValue = func(ctx context.Context) (*Whatsapp, error) {
  33796. once.Do(func() {
  33797. if m.done {
  33798. err = errors.New("querying old values post mutation is not allowed")
  33799. } else {
  33800. value, err = m.Client().Whatsapp.Get(ctx, id)
  33801. }
  33802. })
  33803. return value, err
  33804. }
  33805. m.id = &id
  33806. }
  33807. }
  33808. // withWhatsapp sets the old Whatsapp of the mutation.
  33809. func withWhatsapp(node *Whatsapp) whatsappOption {
  33810. return func(m *WhatsappMutation) {
  33811. m.oldValue = func(context.Context) (*Whatsapp, error) {
  33812. return node, nil
  33813. }
  33814. m.id = &node.ID
  33815. }
  33816. }
  33817. // Client returns a new `ent.Client` from the mutation. If the mutation was
  33818. // executed in a transaction (ent.Tx), a transactional client is returned.
  33819. func (m WhatsappMutation) Client() *Client {
  33820. client := &Client{config: m.config}
  33821. client.init()
  33822. return client
  33823. }
  33824. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  33825. // it returns an error otherwise.
  33826. func (m WhatsappMutation) Tx() (*Tx, error) {
  33827. if _, ok := m.driver.(*txDriver); !ok {
  33828. return nil, errors.New("ent: mutation is not running in a transaction")
  33829. }
  33830. tx := &Tx{config: m.config}
  33831. tx.init()
  33832. return tx, nil
  33833. }
  33834. // SetID sets the value of the id field. Note that this
  33835. // operation is only accepted on creation of Whatsapp entities.
  33836. func (m *WhatsappMutation) SetID(id uint64) {
  33837. m.id = &id
  33838. }
  33839. // ID returns the ID value in the mutation. Note that the ID is only available
  33840. // if it was provided to the builder or after it was returned from the database.
  33841. func (m *WhatsappMutation) ID() (id uint64, exists bool) {
  33842. if m.id == nil {
  33843. return
  33844. }
  33845. return *m.id, true
  33846. }
  33847. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  33848. // That means, if the mutation is applied within a transaction with an isolation level such
  33849. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  33850. // or updated by the mutation.
  33851. func (m *WhatsappMutation) IDs(ctx context.Context) ([]uint64, error) {
  33852. switch {
  33853. case m.op.Is(OpUpdateOne | OpDeleteOne):
  33854. id, exists := m.ID()
  33855. if exists {
  33856. return []uint64{id}, nil
  33857. }
  33858. fallthrough
  33859. case m.op.Is(OpUpdate | OpDelete):
  33860. return m.Client().Whatsapp.Query().Where(m.predicates...).IDs(ctx)
  33861. default:
  33862. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  33863. }
  33864. }
  33865. // SetCreatedAt sets the "created_at" field.
  33866. func (m *WhatsappMutation) SetCreatedAt(t time.Time) {
  33867. m.created_at = &t
  33868. }
  33869. // CreatedAt returns the value of the "created_at" field in the mutation.
  33870. func (m *WhatsappMutation) CreatedAt() (r time.Time, exists bool) {
  33871. v := m.created_at
  33872. if v == nil {
  33873. return
  33874. }
  33875. return *v, true
  33876. }
  33877. // OldCreatedAt returns the old "created_at" field's value of the Whatsapp entity.
  33878. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  33879. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33880. func (m *WhatsappMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  33881. if !m.op.Is(OpUpdateOne) {
  33882. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  33883. }
  33884. if m.id == nil || m.oldValue == nil {
  33885. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  33886. }
  33887. oldValue, err := m.oldValue(ctx)
  33888. if err != nil {
  33889. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  33890. }
  33891. return oldValue.CreatedAt, nil
  33892. }
  33893. // ResetCreatedAt resets all changes to the "created_at" field.
  33894. func (m *WhatsappMutation) ResetCreatedAt() {
  33895. m.created_at = nil
  33896. }
  33897. // SetUpdatedAt sets the "updated_at" field.
  33898. func (m *WhatsappMutation) SetUpdatedAt(t time.Time) {
  33899. m.updated_at = &t
  33900. }
  33901. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  33902. func (m *WhatsappMutation) UpdatedAt() (r time.Time, exists bool) {
  33903. v := m.updated_at
  33904. if v == nil {
  33905. return
  33906. }
  33907. return *v, true
  33908. }
  33909. // OldUpdatedAt returns the old "updated_at" field's value of the Whatsapp entity.
  33910. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  33911. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33912. func (m *WhatsappMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  33913. if !m.op.Is(OpUpdateOne) {
  33914. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  33915. }
  33916. if m.id == nil || m.oldValue == nil {
  33917. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  33918. }
  33919. oldValue, err := m.oldValue(ctx)
  33920. if err != nil {
  33921. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  33922. }
  33923. return oldValue.UpdatedAt, nil
  33924. }
  33925. // ResetUpdatedAt resets all changes to the "updated_at" field.
  33926. func (m *WhatsappMutation) ResetUpdatedAt() {
  33927. m.updated_at = nil
  33928. }
  33929. // SetStatus sets the "status" field.
  33930. func (m *WhatsappMutation) SetStatus(u uint8) {
  33931. m.status = &u
  33932. m.addstatus = nil
  33933. }
  33934. // Status returns the value of the "status" field in the mutation.
  33935. func (m *WhatsappMutation) Status() (r uint8, exists bool) {
  33936. v := m.status
  33937. if v == nil {
  33938. return
  33939. }
  33940. return *v, true
  33941. }
  33942. // OldStatus returns the old "status" field's value of the Whatsapp entity.
  33943. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  33944. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33945. func (m *WhatsappMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  33946. if !m.op.Is(OpUpdateOne) {
  33947. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  33948. }
  33949. if m.id == nil || m.oldValue == nil {
  33950. return v, errors.New("OldStatus requires an ID field in the mutation")
  33951. }
  33952. oldValue, err := m.oldValue(ctx)
  33953. if err != nil {
  33954. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  33955. }
  33956. return oldValue.Status, nil
  33957. }
  33958. // AddStatus adds u to the "status" field.
  33959. func (m *WhatsappMutation) AddStatus(u int8) {
  33960. if m.addstatus != nil {
  33961. *m.addstatus += u
  33962. } else {
  33963. m.addstatus = &u
  33964. }
  33965. }
  33966. // AddedStatus returns the value that was added to the "status" field in this mutation.
  33967. func (m *WhatsappMutation) AddedStatus() (r int8, exists bool) {
  33968. v := m.addstatus
  33969. if v == nil {
  33970. return
  33971. }
  33972. return *v, true
  33973. }
  33974. // ClearStatus clears the value of the "status" field.
  33975. func (m *WhatsappMutation) ClearStatus() {
  33976. m.status = nil
  33977. m.addstatus = nil
  33978. m.clearedFields[whatsapp.FieldStatus] = struct{}{}
  33979. }
  33980. // StatusCleared returns if the "status" field was cleared in this mutation.
  33981. func (m *WhatsappMutation) StatusCleared() bool {
  33982. _, ok := m.clearedFields[whatsapp.FieldStatus]
  33983. return ok
  33984. }
  33985. // ResetStatus resets all changes to the "status" field.
  33986. func (m *WhatsappMutation) ResetStatus() {
  33987. m.status = nil
  33988. m.addstatus = nil
  33989. delete(m.clearedFields, whatsapp.FieldStatus)
  33990. }
  33991. // SetDeletedAt sets the "deleted_at" field.
  33992. func (m *WhatsappMutation) SetDeletedAt(t time.Time) {
  33993. m.deleted_at = &t
  33994. }
  33995. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  33996. func (m *WhatsappMutation) DeletedAt() (r time.Time, exists bool) {
  33997. v := m.deleted_at
  33998. if v == nil {
  33999. return
  34000. }
  34001. return *v, true
  34002. }
  34003. // OldDeletedAt returns the old "deleted_at" field's value of the Whatsapp entity.
  34004. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34005. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34006. func (m *WhatsappMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  34007. if !m.op.Is(OpUpdateOne) {
  34008. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  34009. }
  34010. if m.id == nil || m.oldValue == nil {
  34011. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  34012. }
  34013. oldValue, err := m.oldValue(ctx)
  34014. if err != nil {
  34015. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  34016. }
  34017. return oldValue.DeletedAt, nil
  34018. }
  34019. // ClearDeletedAt clears the value of the "deleted_at" field.
  34020. func (m *WhatsappMutation) ClearDeletedAt() {
  34021. m.deleted_at = nil
  34022. m.clearedFields[whatsapp.FieldDeletedAt] = struct{}{}
  34023. }
  34024. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  34025. func (m *WhatsappMutation) DeletedAtCleared() bool {
  34026. _, ok := m.clearedFields[whatsapp.FieldDeletedAt]
  34027. return ok
  34028. }
  34029. // ResetDeletedAt resets all changes to the "deleted_at" field.
  34030. func (m *WhatsappMutation) ResetDeletedAt() {
  34031. m.deleted_at = nil
  34032. delete(m.clearedFields, whatsapp.FieldDeletedAt)
  34033. }
  34034. // SetWaID sets the "wa_id" field.
  34035. func (m *WhatsappMutation) SetWaID(s string) {
  34036. m.wa_id = &s
  34037. }
  34038. // WaID returns the value of the "wa_id" field in the mutation.
  34039. func (m *WhatsappMutation) WaID() (r string, exists bool) {
  34040. v := m.wa_id
  34041. if v == nil {
  34042. return
  34043. }
  34044. return *v, true
  34045. }
  34046. // OldWaID returns the old "wa_id" field's value of the Whatsapp entity.
  34047. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34048. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34049. func (m *WhatsappMutation) OldWaID(ctx context.Context) (v string, err error) {
  34050. if !m.op.Is(OpUpdateOne) {
  34051. return v, errors.New("OldWaID is only allowed on UpdateOne operations")
  34052. }
  34053. if m.id == nil || m.oldValue == nil {
  34054. return v, errors.New("OldWaID requires an ID field in the mutation")
  34055. }
  34056. oldValue, err := m.oldValue(ctx)
  34057. if err != nil {
  34058. return v, fmt.Errorf("querying old value for OldWaID: %w", err)
  34059. }
  34060. return oldValue.WaID, nil
  34061. }
  34062. // ClearWaID clears the value of the "wa_id" field.
  34063. func (m *WhatsappMutation) ClearWaID() {
  34064. m.wa_id = nil
  34065. m.clearedFields[whatsapp.FieldWaID] = struct{}{}
  34066. }
  34067. // WaIDCleared returns if the "wa_id" field was cleared in this mutation.
  34068. func (m *WhatsappMutation) WaIDCleared() bool {
  34069. _, ok := m.clearedFields[whatsapp.FieldWaID]
  34070. return ok
  34071. }
  34072. // ResetWaID resets all changes to the "wa_id" field.
  34073. func (m *WhatsappMutation) ResetWaID() {
  34074. m.wa_id = nil
  34075. delete(m.clearedFields, whatsapp.FieldWaID)
  34076. }
  34077. // SetCallback sets the "callback" field.
  34078. func (m *WhatsappMutation) SetCallback(s string) {
  34079. m.callback = &s
  34080. }
  34081. // Callback returns the value of the "callback" field in the mutation.
  34082. func (m *WhatsappMutation) Callback() (r string, exists bool) {
  34083. v := m.callback
  34084. if v == nil {
  34085. return
  34086. }
  34087. return *v, true
  34088. }
  34089. // OldCallback returns the old "callback" field's value of the Whatsapp entity.
  34090. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34091. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34092. func (m *WhatsappMutation) OldCallback(ctx context.Context) (v string, err error) {
  34093. if !m.op.Is(OpUpdateOne) {
  34094. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  34095. }
  34096. if m.id == nil || m.oldValue == nil {
  34097. return v, errors.New("OldCallback requires an ID field in the mutation")
  34098. }
  34099. oldValue, err := m.oldValue(ctx)
  34100. if err != nil {
  34101. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  34102. }
  34103. return oldValue.Callback, nil
  34104. }
  34105. // ClearCallback clears the value of the "callback" field.
  34106. func (m *WhatsappMutation) ClearCallback() {
  34107. m.callback = nil
  34108. m.clearedFields[whatsapp.FieldCallback] = struct{}{}
  34109. }
  34110. // CallbackCleared returns if the "callback" field was cleared in this mutation.
  34111. func (m *WhatsappMutation) CallbackCleared() bool {
  34112. _, ok := m.clearedFields[whatsapp.FieldCallback]
  34113. return ok
  34114. }
  34115. // ResetCallback resets all changes to the "callback" field.
  34116. func (m *WhatsappMutation) ResetCallback() {
  34117. m.callback = nil
  34118. delete(m.clearedFields, whatsapp.FieldCallback)
  34119. }
  34120. // SetAgentID sets the "agent_id" field.
  34121. func (m *WhatsappMutation) SetAgentID(u uint64) {
  34122. m.agent = &u
  34123. }
  34124. // AgentID returns the value of the "agent_id" field in the mutation.
  34125. func (m *WhatsappMutation) AgentID() (r uint64, exists bool) {
  34126. v := m.agent
  34127. if v == nil {
  34128. return
  34129. }
  34130. return *v, true
  34131. }
  34132. // OldAgentID returns the old "agent_id" field's value of the Whatsapp entity.
  34133. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34134. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34135. func (m *WhatsappMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  34136. if !m.op.Is(OpUpdateOne) {
  34137. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  34138. }
  34139. if m.id == nil || m.oldValue == nil {
  34140. return v, errors.New("OldAgentID requires an ID field in the mutation")
  34141. }
  34142. oldValue, err := m.oldValue(ctx)
  34143. if err != nil {
  34144. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  34145. }
  34146. return oldValue.AgentID, nil
  34147. }
  34148. // ResetAgentID resets all changes to the "agent_id" field.
  34149. func (m *WhatsappMutation) ResetAgentID() {
  34150. m.agent = nil
  34151. }
  34152. // SetAccount sets the "account" field.
  34153. func (m *WhatsappMutation) SetAccount(s string) {
  34154. m.account = &s
  34155. }
  34156. // Account returns the value of the "account" field in the mutation.
  34157. func (m *WhatsappMutation) Account() (r string, exists bool) {
  34158. v := m.account
  34159. if v == nil {
  34160. return
  34161. }
  34162. return *v, true
  34163. }
  34164. // OldAccount returns the old "account" field's value of the Whatsapp entity.
  34165. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34166. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34167. func (m *WhatsappMutation) OldAccount(ctx context.Context) (v string, err error) {
  34168. if !m.op.Is(OpUpdateOne) {
  34169. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  34170. }
  34171. if m.id == nil || m.oldValue == nil {
  34172. return v, errors.New("OldAccount requires an ID field in the mutation")
  34173. }
  34174. oldValue, err := m.oldValue(ctx)
  34175. if err != nil {
  34176. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  34177. }
  34178. return oldValue.Account, nil
  34179. }
  34180. // ClearAccount clears the value of the "account" field.
  34181. func (m *WhatsappMutation) ClearAccount() {
  34182. m.account = nil
  34183. m.clearedFields[whatsapp.FieldAccount] = struct{}{}
  34184. }
  34185. // AccountCleared returns if the "account" field was cleared in this mutation.
  34186. func (m *WhatsappMutation) AccountCleared() bool {
  34187. _, ok := m.clearedFields[whatsapp.FieldAccount]
  34188. return ok
  34189. }
  34190. // ResetAccount resets all changes to the "account" field.
  34191. func (m *WhatsappMutation) ResetAccount() {
  34192. m.account = nil
  34193. delete(m.clearedFields, whatsapp.FieldAccount)
  34194. }
  34195. // SetCc sets the "cc" field.
  34196. func (m *WhatsappMutation) SetCc(s string) {
  34197. m.cc = &s
  34198. }
  34199. // Cc returns the value of the "cc" field in the mutation.
  34200. func (m *WhatsappMutation) Cc() (r string, exists bool) {
  34201. v := m.cc
  34202. if v == nil {
  34203. return
  34204. }
  34205. return *v, true
  34206. }
  34207. // OldCc returns the old "cc" field's value of the Whatsapp entity.
  34208. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34209. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34210. func (m *WhatsappMutation) OldCc(ctx context.Context) (v string, err error) {
  34211. if !m.op.Is(OpUpdateOne) {
  34212. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  34213. }
  34214. if m.id == nil || m.oldValue == nil {
  34215. return v, errors.New("OldCc requires an ID field in the mutation")
  34216. }
  34217. oldValue, err := m.oldValue(ctx)
  34218. if err != nil {
  34219. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  34220. }
  34221. return oldValue.Cc, nil
  34222. }
  34223. // ResetCc resets all changes to the "cc" field.
  34224. func (m *WhatsappMutation) ResetCc() {
  34225. m.cc = nil
  34226. }
  34227. // SetPhone sets the "phone" field.
  34228. func (m *WhatsappMutation) SetPhone(s string) {
  34229. m.phone = &s
  34230. }
  34231. // Phone returns the value of the "phone" field in the mutation.
  34232. func (m *WhatsappMutation) Phone() (r string, exists bool) {
  34233. v := m.phone
  34234. if v == nil {
  34235. return
  34236. }
  34237. return *v, true
  34238. }
  34239. // OldPhone returns the old "phone" field's value of the Whatsapp entity.
  34240. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34241. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34242. func (m *WhatsappMutation) OldPhone(ctx context.Context) (v string, err error) {
  34243. if !m.op.Is(OpUpdateOne) {
  34244. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  34245. }
  34246. if m.id == nil || m.oldValue == nil {
  34247. return v, errors.New("OldPhone requires an ID field in the mutation")
  34248. }
  34249. oldValue, err := m.oldValue(ctx)
  34250. if err != nil {
  34251. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  34252. }
  34253. return oldValue.Phone, nil
  34254. }
  34255. // ResetPhone resets all changes to the "phone" field.
  34256. func (m *WhatsappMutation) ResetPhone() {
  34257. m.phone = nil
  34258. }
  34259. // SetPhoneName sets the "phone_name" field.
  34260. func (m *WhatsappMutation) SetPhoneName(s string) {
  34261. m.phone_name = &s
  34262. }
  34263. // PhoneName returns the value of the "phone_name" field in the mutation.
  34264. func (m *WhatsappMutation) PhoneName() (r string, exists bool) {
  34265. v := m.phone_name
  34266. if v == nil {
  34267. return
  34268. }
  34269. return *v, true
  34270. }
  34271. // OldPhoneName returns the old "phone_name" field's value of the Whatsapp entity.
  34272. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34273. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34274. func (m *WhatsappMutation) OldPhoneName(ctx context.Context) (v string, err error) {
  34275. if !m.op.Is(OpUpdateOne) {
  34276. return v, errors.New("OldPhoneName is only allowed on UpdateOne operations")
  34277. }
  34278. if m.id == nil || m.oldValue == nil {
  34279. return v, errors.New("OldPhoneName requires an ID field in the mutation")
  34280. }
  34281. oldValue, err := m.oldValue(ctx)
  34282. if err != nil {
  34283. return v, fmt.Errorf("querying old value for OldPhoneName: %w", err)
  34284. }
  34285. return oldValue.PhoneName, nil
  34286. }
  34287. // ResetPhoneName resets all changes to the "phone_name" field.
  34288. func (m *WhatsappMutation) ResetPhoneName() {
  34289. m.phone_name = nil
  34290. }
  34291. // SetPhoneStatus sets the "phone_status" field.
  34292. func (m *WhatsappMutation) SetPhoneStatus(i int8) {
  34293. m.phone_status = &i
  34294. m.addphone_status = nil
  34295. }
  34296. // PhoneStatus returns the value of the "phone_status" field in the mutation.
  34297. func (m *WhatsappMutation) PhoneStatus() (r int8, exists bool) {
  34298. v := m.phone_status
  34299. if v == nil {
  34300. return
  34301. }
  34302. return *v, true
  34303. }
  34304. // OldPhoneStatus returns the old "phone_status" field's value of the Whatsapp entity.
  34305. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34306. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34307. func (m *WhatsappMutation) OldPhoneStatus(ctx context.Context) (v int8, err error) {
  34308. if !m.op.Is(OpUpdateOne) {
  34309. return v, errors.New("OldPhoneStatus is only allowed on UpdateOne operations")
  34310. }
  34311. if m.id == nil || m.oldValue == nil {
  34312. return v, errors.New("OldPhoneStatus requires an ID field in the mutation")
  34313. }
  34314. oldValue, err := m.oldValue(ctx)
  34315. if err != nil {
  34316. return v, fmt.Errorf("querying old value for OldPhoneStatus: %w", err)
  34317. }
  34318. return oldValue.PhoneStatus, nil
  34319. }
  34320. // AddPhoneStatus adds i to the "phone_status" field.
  34321. func (m *WhatsappMutation) AddPhoneStatus(i int8) {
  34322. if m.addphone_status != nil {
  34323. *m.addphone_status += i
  34324. } else {
  34325. m.addphone_status = &i
  34326. }
  34327. }
  34328. // AddedPhoneStatus returns the value that was added to the "phone_status" field in this mutation.
  34329. func (m *WhatsappMutation) AddedPhoneStatus() (r int8, exists bool) {
  34330. v := m.addphone_status
  34331. if v == nil {
  34332. return
  34333. }
  34334. return *v, true
  34335. }
  34336. // ResetPhoneStatus resets all changes to the "phone_status" field.
  34337. func (m *WhatsappMutation) ResetPhoneStatus() {
  34338. m.phone_status = nil
  34339. m.addphone_status = nil
  34340. }
  34341. // SetOrganizationID sets the "organization_id" field.
  34342. func (m *WhatsappMutation) SetOrganizationID(u uint64) {
  34343. m.organization_id = &u
  34344. m.addorganization_id = nil
  34345. }
  34346. // OrganizationID returns the value of the "organization_id" field in the mutation.
  34347. func (m *WhatsappMutation) OrganizationID() (r uint64, exists bool) {
  34348. v := m.organization_id
  34349. if v == nil {
  34350. return
  34351. }
  34352. return *v, true
  34353. }
  34354. // OldOrganizationID returns the old "organization_id" field's value of the Whatsapp entity.
  34355. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34356. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34357. func (m *WhatsappMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  34358. if !m.op.Is(OpUpdateOne) {
  34359. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  34360. }
  34361. if m.id == nil || m.oldValue == nil {
  34362. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  34363. }
  34364. oldValue, err := m.oldValue(ctx)
  34365. if err != nil {
  34366. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  34367. }
  34368. return oldValue.OrganizationID, nil
  34369. }
  34370. // AddOrganizationID adds u to the "organization_id" field.
  34371. func (m *WhatsappMutation) AddOrganizationID(u int64) {
  34372. if m.addorganization_id != nil {
  34373. *m.addorganization_id += u
  34374. } else {
  34375. m.addorganization_id = &u
  34376. }
  34377. }
  34378. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  34379. func (m *WhatsappMutation) AddedOrganizationID() (r int64, exists bool) {
  34380. v := m.addorganization_id
  34381. if v == nil {
  34382. return
  34383. }
  34384. return *v, true
  34385. }
  34386. // ClearOrganizationID clears the value of the "organization_id" field.
  34387. func (m *WhatsappMutation) ClearOrganizationID() {
  34388. m.organization_id = nil
  34389. m.addorganization_id = nil
  34390. m.clearedFields[whatsapp.FieldOrganizationID] = struct{}{}
  34391. }
  34392. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  34393. func (m *WhatsappMutation) OrganizationIDCleared() bool {
  34394. _, ok := m.clearedFields[whatsapp.FieldOrganizationID]
  34395. return ok
  34396. }
  34397. // ResetOrganizationID resets all changes to the "organization_id" field.
  34398. func (m *WhatsappMutation) ResetOrganizationID() {
  34399. m.organization_id = nil
  34400. m.addorganization_id = nil
  34401. delete(m.clearedFields, whatsapp.FieldOrganizationID)
  34402. }
  34403. // SetAPIBase sets the "api_base" field.
  34404. func (m *WhatsappMutation) SetAPIBase(s string) {
  34405. m.api_base = &s
  34406. }
  34407. // APIBase returns the value of the "api_base" field in the mutation.
  34408. func (m *WhatsappMutation) APIBase() (r string, exists bool) {
  34409. v := m.api_base
  34410. if v == nil {
  34411. return
  34412. }
  34413. return *v, true
  34414. }
  34415. // OldAPIBase returns the old "api_base" field's value of the Whatsapp entity.
  34416. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34417. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34418. func (m *WhatsappMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  34419. if !m.op.Is(OpUpdateOne) {
  34420. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  34421. }
  34422. if m.id == nil || m.oldValue == nil {
  34423. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  34424. }
  34425. oldValue, err := m.oldValue(ctx)
  34426. if err != nil {
  34427. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  34428. }
  34429. return oldValue.APIBase, nil
  34430. }
  34431. // ClearAPIBase clears the value of the "api_base" field.
  34432. func (m *WhatsappMutation) ClearAPIBase() {
  34433. m.api_base = nil
  34434. m.clearedFields[whatsapp.FieldAPIBase] = struct{}{}
  34435. }
  34436. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  34437. func (m *WhatsappMutation) APIBaseCleared() bool {
  34438. _, ok := m.clearedFields[whatsapp.FieldAPIBase]
  34439. return ok
  34440. }
  34441. // ResetAPIBase resets all changes to the "api_base" field.
  34442. func (m *WhatsappMutation) ResetAPIBase() {
  34443. m.api_base = nil
  34444. delete(m.clearedFields, whatsapp.FieldAPIBase)
  34445. }
  34446. // SetAPIKey sets the "api_key" field.
  34447. func (m *WhatsappMutation) SetAPIKey(s string) {
  34448. m.api_key = &s
  34449. }
  34450. // APIKey returns the value of the "api_key" field in the mutation.
  34451. func (m *WhatsappMutation) APIKey() (r string, exists bool) {
  34452. v := m.api_key
  34453. if v == nil {
  34454. return
  34455. }
  34456. return *v, true
  34457. }
  34458. // OldAPIKey returns the old "api_key" field's value of the Whatsapp entity.
  34459. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34460. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34461. func (m *WhatsappMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  34462. if !m.op.Is(OpUpdateOne) {
  34463. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  34464. }
  34465. if m.id == nil || m.oldValue == nil {
  34466. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  34467. }
  34468. oldValue, err := m.oldValue(ctx)
  34469. if err != nil {
  34470. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  34471. }
  34472. return oldValue.APIKey, nil
  34473. }
  34474. // ClearAPIKey clears the value of the "api_key" field.
  34475. func (m *WhatsappMutation) ClearAPIKey() {
  34476. m.api_key = nil
  34477. m.clearedFields[whatsapp.FieldAPIKey] = struct{}{}
  34478. }
  34479. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  34480. func (m *WhatsappMutation) APIKeyCleared() bool {
  34481. _, ok := m.clearedFields[whatsapp.FieldAPIKey]
  34482. return ok
  34483. }
  34484. // ResetAPIKey resets all changes to the "api_key" field.
  34485. func (m *WhatsappMutation) ResetAPIKey() {
  34486. m.api_key = nil
  34487. delete(m.clearedFields, whatsapp.FieldAPIKey)
  34488. }
  34489. // SetAllowList sets the "allow_list" field.
  34490. func (m *WhatsappMutation) SetAllowList(s []string) {
  34491. m.allow_list = &s
  34492. m.appendallow_list = nil
  34493. }
  34494. // AllowList returns the value of the "allow_list" field in the mutation.
  34495. func (m *WhatsappMutation) AllowList() (r []string, exists bool) {
  34496. v := m.allow_list
  34497. if v == nil {
  34498. return
  34499. }
  34500. return *v, true
  34501. }
  34502. // OldAllowList returns the old "allow_list" field's value of the Whatsapp entity.
  34503. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34504. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34505. func (m *WhatsappMutation) OldAllowList(ctx context.Context) (v []string, err error) {
  34506. if !m.op.Is(OpUpdateOne) {
  34507. return v, errors.New("OldAllowList is only allowed on UpdateOne operations")
  34508. }
  34509. if m.id == nil || m.oldValue == nil {
  34510. return v, errors.New("OldAllowList requires an ID field in the mutation")
  34511. }
  34512. oldValue, err := m.oldValue(ctx)
  34513. if err != nil {
  34514. return v, fmt.Errorf("querying old value for OldAllowList: %w", err)
  34515. }
  34516. return oldValue.AllowList, nil
  34517. }
  34518. // AppendAllowList adds s to the "allow_list" field.
  34519. func (m *WhatsappMutation) AppendAllowList(s []string) {
  34520. m.appendallow_list = append(m.appendallow_list, s...)
  34521. }
  34522. // AppendedAllowList returns the list of values that were appended to the "allow_list" field in this mutation.
  34523. func (m *WhatsappMutation) AppendedAllowList() ([]string, bool) {
  34524. if len(m.appendallow_list) == 0 {
  34525. return nil, false
  34526. }
  34527. return m.appendallow_list, true
  34528. }
  34529. // ClearAllowList clears the value of the "allow_list" field.
  34530. func (m *WhatsappMutation) ClearAllowList() {
  34531. m.allow_list = nil
  34532. m.appendallow_list = nil
  34533. m.clearedFields[whatsapp.FieldAllowList] = struct{}{}
  34534. }
  34535. // AllowListCleared returns if the "allow_list" field was cleared in this mutation.
  34536. func (m *WhatsappMutation) AllowListCleared() bool {
  34537. _, ok := m.clearedFields[whatsapp.FieldAllowList]
  34538. return ok
  34539. }
  34540. // ResetAllowList resets all changes to the "allow_list" field.
  34541. func (m *WhatsappMutation) ResetAllowList() {
  34542. m.allow_list = nil
  34543. m.appendallow_list = nil
  34544. delete(m.clearedFields, whatsapp.FieldAllowList)
  34545. }
  34546. // SetGroupAllowList sets the "group_allow_list" field.
  34547. func (m *WhatsappMutation) SetGroupAllowList(s []string) {
  34548. m.group_allow_list = &s
  34549. m.appendgroup_allow_list = nil
  34550. }
  34551. // GroupAllowList returns the value of the "group_allow_list" field in the mutation.
  34552. func (m *WhatsappMutation) GroupAllowList() (r []string, exists bool) {
  34553. v := m.group_allow_list
  34554. if v == nil {
  34555. return
  34556. }
  34557. return *v, true
  34558. }
  34559. // OldGroupAllowList returns the old "group_allow_list" field's value of the Whatsapp entity.
  34560. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34561. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34562. func (m *WhatsappMutation) OldGroupAllowList(ctx context.Context) (v []string, err error) {
  34563. if !m.op.Is(OpUpdateOne) {
  34564. return v, errors.New("OldGroupAllowList is only allowed on UpdateOne operations")
  34565. }
  34566. if m.id == nil || m.oldValue == nil {
  34567. return v, errors.New("OldGroupAllowList requires an ID field in the mutation")
  34568. }
  34569. oldValue, err := m.oldValue(ctx)
  34570. if err != nil {
  34571. return v, fmt.Errorf("querying old value for OldGroupAllowList: %w", err)
  34572. }
  34573. return oldValue.GroupAllowList, nil
  34574. }
  34575. // AppendGroupAllowList adds s to the "group_allow_list" field.
  34576. func (m *WhatsappMutation) AppendGroupAllowList(s []string) {
  34577. m.appendgroup_allow_list = append(m.appendgroup_allow_list, s...)
  34578. }
  34579. // AppendedGroupAllowList returns the list of values that were appended to the "group_allow_list" field in this mutation.
  34580. func (m *WhatsappMutation) AppendedGroupAllowList() ([]string, bool) {
  34581. if len(m.appendgroup_allow_list) == 0 {
  34582. return nil, false
  34583. }
  34584. return m.appendgroup_allow_list, true
  34585. }
  34586. // ClearGroupAllowList clears the value of the "group_allow_list" field.
  34587. func (m *WhatsappMutation) ClearGroupAllowList() {
  34588. m.group_allow_list = nil
  34589. m.appendgroup_allow_list = nil
  34590. m.clearedFields[whatsapp.FieldGroupAllowList] = struct{}{}
  34591. }
  34592. // GroupAllowListCleared returns if the "group_allow_list" field was cleared in this mutation.
  34593. func (m *WhatsappMutation) GroupAllowListCleared() bool {
  34594. _, ok := m.clearedFields[whatsapp.FieldGroupAllowList]
  34595. return ok
  34596. }
  34597. // ResetGroupAllowList resets all changes to the "group_allow_list" field.
  34598. func (m *WhatsappMutation) ResetGroupAllowList() {
  34599. m.group_allow_list = nil
  34600. m.appendgroup_allow_list = nil
  34601. delete(m.clearedFields, whatsapp.FieldGroupAllowList)
  34602. }
  34603. // SetBlockList sets the "block_list" field.
  34604. func (m *WhatsappMutation) SetBlockList(s []string) {
  34605. m.block_list = &s
  34606. m.appendblock_list = nil
  34607. }
  34608. // BlockList returns the value of the "block_list" field in the mutation.
  34609. func (m *WhatsappMutation) BlockList() (r []string, exists bool) {
  34610. v := m.block_list
  34611. if v == nil {
  34612. return
  34613. }
  34614. return *v, true
  34615. }
  34616. // OldBlockList returns the old "block_list" field's value of the Whatsapp entity.
  34617. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34618. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34619. func (m *WhatsappMutation) OldBlockList(ctx context.Context) (v []string, err error) {
  34620. if !m.op.Is(OpUpdateOne) {
  34621. return v, errors.New("OldBlockList is only allowed on UpdateOne operations")
  34622. }
  34623. if m.id == nil || m.oldValue == nil {
  34624. return v, errors.New("OldBlockList requires an ID field in the mutation")
  34625. }
  34626. oldValue, err := m.oldValue(ctx)
  34627. if err != nil {
  34628. return v, fmt.Errorf("querying old value for OldBlockList: %w", err)
  34629. }
  34630. return oldValue.BlockList, nil
  34631. }
  34632. // AppendBlockList adds s to the "block_list" field.
  34633. func (m *WhatsappMutation) AppendBlockList(s []string) {
  34634. m.appendblock_list = append(m.appendblock_list, s...)
  34635. }
  34636. // AppendedBlockList returns the list of values that were appended to the "block_list" field in this mutation.
  34637. func (m *WhatsappMutation) AppendedBlockList() ([]string, bool) {
  34638. if len(m.appendblock_list) == 0 {
  34639. return nil, false
  34640. }
  34641. return m.appendblock_list, true
  34642. }
  34643. // ClearBlockList clears the value of the "block_list" field.
  34644. func (m *WhatsappMutation) ClearBlockList() {
  34645. m.block_list = nil
  34646. m.appendblock_list = nil
  34647. m.clearedFields[whatsapp.FieldBlockList] = struct{}{}
  34648. }
  34649. // BlockListCleared returns if the "block_list" field was cleared in this mutation.
  34650. func (m *WhatsappMutation) BlockListCleared() bool {
  34651. _, ok := m.clearedFields[whatsapp.FieldBlockList]
  34652. return ok
  34653. }
  34654. // ResetBlockList resets all changes to the "block_list" field.
  34655. func (m *WhatsappMutation) ResetBlockList() {
  34656. m.block_list = nil
  34657. m.appendblock_list = nil
  34658. delete(m.clearedFields, whatsapp.FieldBlockList)
  34659. }
  34660. // SetGroupBlockList sets the "group_block_list" field.
  34661. func (m *WhatsappMutation) SetGroupBlockList(s []string) {
  34662. m.group_block_list = &s
  34663. m.appendgroup_block_list = nil
  34664. }
  34665. // GroupBlockList returns the value of the "group_block_list" field in the mutation.
  34666. func (m *WhatsappMutation) GroupBlockList() (r []string, exists bool) {
  34667. v := m.group_block_list
  34668. if v == nil {
  34669. return
  34670. }
  34671. return *v, true
  34672. }
  34673. // OldGroupBlockList returns the old "group_block_list" field's value of the Whatsapp entity.
  34674. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34675. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34676. func (m *WhatsappMutation) OldGroupBlockList(ctx context.Context) (v []string, err error) {
  34677. if !m.op.Is(OpUpdateOne) {
  34678. return v, errors.New("OldGroupBlockList is only allowed on UpdateOne operations")
  34679. }
  34680. if m.id == nil || m.oldValue == nil {
  34681. return v, errors.New("OldGroupBlockList requires an ID field in the mutation")
  34682. }
  34683. oldValue, err := m.oldValue(ctx)
  34684. if err != nil {
  34685. return v, fmt.Errorf("querying old value for OldGroupBlockList: %w", err)
  34686. }
  34687. return oldValue.GroupBlockList, nil
  34688. }
  34689. // AppendGroupBlockList adds s to the "group_block_list" field.
  34690. func (m *WhatsappMutation) AppendGroupBlockList(s []string) {
  34691. m.appendgroup_block_list = append(m.appendgroup_block_list, s...)
  34692. }
  34693. // AppendedGroupBlockList returns the list of values that were appended to the "group_block_list" field in this mutation.
  34694. func (m *WhatsappMutation) AppendedGroupBlockList() ([]string, bool) {
  34695. if len(m.appendgroup_block_list) == 0 {
  34696. return nil, false
  34697. }
  34698. return m.appendgroup_block_list, true
  34699. }
  34700. // ClearGroupBlockList clears the value of the "group_block_list" field.
  34701. func (m *WhatsappMutation) ClearGroupBlockList() {
  34702. m.group_block_list = nil
  34703. m.appendgroup_block_list = nil
  34704. m.clearedFields[whatsapp.FieldGroupBlockList] = struct{}{}
  34705. }
  34706. // GroupBlockListCleared returns if the "group_block_list" field was cleared in this mutation.
  34707. func (m *WhatsappMutation) GroupBlockListCleared() bool {
  34708. _, ok := m.clearedFields[whatsapp.FieldGroupBlockList]
  34709. return ok
  34710. }
  34711. // ResetGroupBlockList resets all changes to the "group_block_list" field.
  34712. func (m *WhatsappMutation) ResetGroupBlockList() {
  34713. m.group_block_list = nil
  34714. m.appendgroup_block_list = nil
  34715. delete(m.clearedFields, whatsapp.FieldGroupBlockList)
  34716. }
  34717. // ClearAgent clears the "agent" edge to the Agent entity.
  34718. func (m *WhatsappMutation) ClearAgent() {
  34719. m.clearedagent = true
  34720. m.clearedFields[whatsapp.FieldAgentID] = struct{}{}
  34721. }
  34722. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  34723. func (m *WhatsappMutation) AgentCleared() bool {
  34724. return m.clearedagent
  34725. }
  34726. // AgentIDs returns the "agent" edge IDs in the mutation.
  34727. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  34728. // AgentID instead. It exists only for internal usage by the builders.
  34729. func (m *WhatsappMutation) AgentIDs() (ids []uint64) {
  34730. if id := m.agent; id != nil {
  34731. ids = append(ids, *id)
  34732. }
  34733. return
  34734. }
  34735. // ResetAgent resets all changes to the "agent" edge.
  34736. func (m *WhatsappMutation) ResetAgent() {
  34737. m.agent = nil
  34738. m.clearedagent = false
  34739. }
  34740. // Where appends a list predicates to the WhatsappMutation builder.
  34741. func (m *WhatsappMutation) Where(ps ...predicate.Whatsapp) {
  34742. m.predicates = append(m.predicates, ps...)
  34743. }
  34744. // WhereP appends storage-level predicates to the WhatsappMutation builder. Using this method,
  34745. // users can use type-assertion to append predicates that do not depend on any generated package.
  34746. func (m *WhatsappMutation) WhereP(ps ...func(*sql.Selector)) {
  34747. p := make([]predicate.Whatsapp, len(ps))
  34748. for i := range ps {
  34749. p[i] = ps[i]
  34750. }
  34751. m.Where(p...)
  34752. }
  34753. // Op returns the operation name.
  34754. func (m *WhatsappMutation) Op() Op {
  34755. return m.op
  34756. }
  34757. // SetOp allows setting the mutation operation.
  34758. func (m *WhatsappMutation) SetOp(op Op) {
  34759. m.op = op
  34760. }
  34761. // Type returns the node type of this mutation (Whatsapp).
  34762. func (m *WhatsappMutation) Type() string {
  34763. return m.typ
  34764. }
  34765. // Fields returns all fields that were changed during this mutation. Note that in
  34766. // order to get all numeric fields that were incremented/decremented, call
  34767. // AddedFields().
  34768. func (m *WhatsappMutation) Fields() []string {
  34769. fields := make([]string, 0, 19)
  34770. if m.created_at != nil {
  34771. fields = append(fields, whatsapp.FieldCreatedAt)
  34772. }
  34773. if m.updated_at != nil {
  34774. fields = append(fields, whatsapp.FieldUpdatedAt)
  34775. }
  34776. if m.status != nil {
  34777. fields = append(fields, whatsapp.FieldStatus)
  34778. }
  34779. if m.deleted_at != nil {
  34780. fields = append(fields, whatsapp.FieldDeletedAt)
  34781. }
  34782. if m.wa_id != nil {
  34783. fields = append(fields, whatsapp.FieldWaID)
  34784. }
  34785. if m.callback != nil {
  34786. fields = append(fields, whatsapp.FieldCallback)
  34787. }
  34788. if m.agent != nil {
  34789. fields = append(fields, whatsapp.FieldAgentID)
  34790. }
  34791. if m.account != nil {
  34792. fields = append(fields, whatsapp.FieldAccount)
  34793. }
  34794. if m.cc != nil {
  34795. fields = append(fields, whatsapp.FieldCc)
  34796. }
  34797. if m.phone != nil {
  34798. fields = append(fields, whatsapp.FieldPhone)
  34799. }
  34800. if m.phone_name != nil {
  34801. fields = append(fields, whatsapp.FieldPhoneName)
  34802. }
  34803. if m.phone_status != nil {
  34804. fields = append(fields, whatsapp.FieldPhoneStatus)
  34805. }
  34806. if m.organization_id != nil {
  34807. fields = append(fields, whatsapp.FieldOrganizationID)
  34808. }
  34809. if m.api_base != nil {
  34810. fields = append(fields, whatsapp.FieldAPIBase)
  34811. }
  34812. if m.api_key != nil {
  34813. fields = append(fields, whatsapp.FieldAPIKey)
  34814. }
  34815. if m.allow_list != nil {
  34816. fields = append(fields, whatsapp.FieldAllowList)
  34817. }
  34818. if m.group_allow_list != nil {
  34819. fields = append(fields, whatsapp.FieldGroupAllowList)
  34820. }
  34821. if m.block_list != nil {
  34822. fields = append(fields, whatsapp.FieldBlockList)
  34823. }
  34824. if m.group_block_list != nil {
  34825. fields = append(fields, whatsapp.FieldGroupBlockList)
  34826. }
  34827. return fields
  34828. }
  34829. // Field returns the value of a field with the given name. The second boolean
  34830. // return value indicates that this field was not set, or was not defined in the
  34831. // schema.
  34832. func (m *WhatsappMutation) Field(name string) (ent.Value, bool) {
  34833. switch name {
  34834. case whatsapp.FieldCreatedAt:
  34835. return m.CreatedAt()
  34836. case whatsapp.FieldUpdatedAt:
  34837. return m.UpdatedAt()
  34838. case whatsapp.FieldStatus:
  34839. return m.Status()
  34840. case whatsapp.FieldDeletedAt:
  34841. return m.DeletedAt()
  34842. case whatsapp.FieldWaID:
  34843. return m.WaID()
  34844. case whatsapp.FieldCallback:
  34845. return m.Callback()
  34846. case whatsapp.FieldAgentID:
  34847. return m.AgentID()
  34848. case whatsapp.FieldAccount:
  34849. return m.Account()
  34850. case whatsapp.FieldCc:
  34851. return m.Cc()
  34852. case whatsapp.FieldPhone:
  34853. return m.Phone()
  34854. case whatsapp.FieldPhoneName:
  34855. return m.PhoneName()
  34856. case whatsapp.FieldPhoneStatus:
  34857. return m.PhoneStatus()
  34858. case whatsapp.FieldOrganizationID:
  34859. return m.OrganizationID()
  34860. case whatsapp.FieldAPIBase:
  34861. return m.APIBase()
  34862. case whatsapp.FieldAPIKey:
  34863. return m.APIKey()
  34864. case whatsapp.FieldAllowList:
  34865. return m.AllowList()
  34866. case whatsapp.FieldGroupAllowList:
  34867. return m.GroupAllowList()
  34868. case whatsapp.FieldBlockList:
  34869. return m.BlockList()
  34870. case whatsapp.FieldGroupBlockList:
  34871. return m.GroupBlockList()
  34872. }
  34873. return nil, false
  34874. }
  34875. // OldField returns the old value of the field from the database. An error is
  34876. // returned if the mutation operation is not UpdateOne, or the query to the
  34877. // database failed.
  34878. func (m *WhatsappMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  34879. switch name {
  34880. case whatsapp.FieldCreatedAt:
  34881. return m.OldCreatedAt(ctx)
  34882. case whatsapp.FieldUpdatedAt:
  34883. return m.OldUpdatedAt(ctx)
  34884. case whatsapp.FieldStatus:
  34885. return m.OldStatus(ctx)
  34886. case whatsapp.FieldDeletedAt:
  34887. return m.OldDeletedAt(ctx)
  34888. case whatsapp.FieldWaID:
  34889. return m.OldWaID(ctx)
  34890. case whatsapp.FieldCallback:
  34891. return m.OldCallback(ctx)
  34892. case whatsapp.FieldAgentID:
  34893. return m.OldAgentID(ctx)
  34894. case whatsapp.FieldAccount:
  34895. return m.OldAccount(ctx)
  34896. case whatsapp.FieldCc:
  34897. return m.OldCc(ctx)
  34898. case whatsapp.FieldPhone:
  34899. return m.OldPhone(ctx)
  34900. case whatsapp.FieldPhoneName:
  34901. return m.OldPhoneName(ctx)
  34902. case whatsapp.FieldPhoneStatus:
  34903. return m.OldPhoneStatus(ctx)
  34904. case whatsapp.FieldOrganizationID:
  34905. return m.OldOrganizationID(ctx)
  34906. case whatsapp.FieldAPIBase:
  34907. return m.OldAPIBase(ctx)
  34908. case whatsapp.FieldAPIKey:
  34909. return m.OldAPIKey(ctx)
  34910. case whatsapp.FieldAllowList:
  34911. return m.OldAllowList(ctx)
  34912. case whatsapp.FieldGroupAllowList:
  34913. return m.OldGroupAllowList(ctx)
  34914. case whatsapp.FieldBlockList:
  34915. return m.OldBlockList(ctx)
  34916. case whatsapp.FieldGroupBlockList:
  34917. return m.OldGroupBlockList(ctx)
  34918. }
  34919. return nil, fmt.Errorf("unknown Whatsapp field %s", name)
  34920. }
  34921. // SetField sets the value of a field with the given name. It returns an error if
  34922. // the field is not defined in the schema, or if the type mismatched the field
  34923. // type.
  34924. func (m *WhatsappMutation) SetField(name string, value ent.Value) error {
  34925. switch name {
  34926. case whatsapp.FieldCreatedAt:
  34927. v, ok := value.(time.Time)
  34928. if !ok {
  34929. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34930. }
  34931. m.SetCreatedAt(v)
  34932. return nil
  34933. case whatsapp.FieldUpdatedAt:
  34934. v, ok := value.(time.Time)
  34935. if !ok {
  34936. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34937. }
  34938. m.SetUpdatedAt(v)
  34939. return nil
  34940. case whatsapp.FieldStatus:
  34941. v, ok := value.(uint8)
  34942. if !ok {
  34943. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34944. }
  34945. m.SetStatus(v)
  34946. return nil
  34947. case whatsapp.FieldDeletedAt:
  34948. v, ok := value.(time.Time)
  34949. if !ok {
  34950. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34951. }
  34952. m.SetDeletedAt(v)
  34953. return nil
  34954. case whatsapp.FieldWaID:
  34955. v, ok := value.(string)
  34956. if !ok {
  34957. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34958. }
  34959. m.SetWaID(v)
  34960. return nil
  34961. case whatsapp.FieldCallback:
  34962. v, ok := value.(string)
  34963. if !ok {
  34964. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34965. }
  34966. m.SetCallback(v)
  34967. return nil
  34968. case whatsapp.FieldAgentID:
  34969. v, ok := value.(uint64)
  34970. if !ok {
  34971. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34972. }
  34973. m.SetAgentID(v)
  34974. return nil
  34975. case whatsapp.FieldAccount:
  34976. v, ok := value.(string)
  34977. if !ok {
  34978. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34979. }
  34980. m.SetAccount(v)
  34981. return nil
  34982. case whatsapp.FieldCc:
  34983. v, ok := value.(string)
  34984. if !ok {
  34985. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34986. }
  34987. m.SetCc(v)
  34988. return nil
  34989. case whatsapp.FieldPhone:
  34990. v, ok := value.(string)
  34991. if !ok {
  34992. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34993. }
  34994. m.SetPhone(v)
  34995. return nil
  34996. case whatsapp.FieldPhoneName:
  34997. v, ok := value.(string)
  34998. if !ok {
  34999. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35000. }
  35001. m.SetPhoneName(v)
  35002. return nil
  35003. case whatsapp.FieldPhoneStatus:
  35004. v, ok := value.(int8)
  35005. if !ok {
  35006. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35007. }
  35008. m.SetPhoneStatus(v)
  35009. return nil
  35010. case whatsapp.FieldOrganizationID:
  35011. v, ok := value.(uint64)
  35012. if !ok {
  35013. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35014. }
  35015. m.SetOrganizationID(v)
  35016. return nil
  35017. case whatsapp.FieldAPIBase:
  35018. v, ok := value.(string)
  35019. if !ok {
  35020. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35021. }
  35022. m.SetAPIBase(v)
  35023. return nil
  35024. case whatsapp.FieldAPIKey:
  35025. v, ok := value.(string)
  35026. if !ok {
  35027. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35028. }
  35029. m.SetAPIKey(v)
  35030. return nil
  35031. case whatsapp.FieldAllowList:
  35032. v, ok := value.([]string)
  35033. if !ok {
  35034. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35035. }
  35036. m.SetAllowList(v)
  35037. return nil
  35038. case whatsapp.FieldGroupAllowList:
  35039. v, ok := value.([]string)
  35040. if !ok {
  35041. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35042. }
  35043. m.SetGroupAllowList(v)
  35044. return nil
  35045. case whatsapp.FieldBlockList:
  35046. v, ok := value.([]string)
  35047. if !ok {
  35048. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35049. }
  35050. m.SetBlockList(v)
  35051. return nil
  35052. case whatsapp.FieldGroupBlockList:
  35053. v, ok := value.([]string)
  35054. if !ok {
  35055. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35056. }
  35057. m.SetGroupBlockList(v)
  35058. return nil
  35059. }
  35060. return fmt.Errorf("unknown Whatsapp field %s", name)
  35061. }
  35062. // AddedFields returns all numeric fields that were incremented/decremented during
  35063. // this mutation.
  35064. func (m *WhatsappMutation) AddedFields() []string {
  35065. var fields []string
  35066. if m.addstatus != nil {
  35067. fields = append(fields, whatsapp.FieldStatus)
  35068. }
  35069. if m.addphone_status != nil {
  35070. fields = append(fields, whatsapp.FieldPhoneStatus)
  35071. }
  35072. if m.addorganization_id != nil {
  35073. fields = append(fields, whatsapp.FieldOrganizationID)
  35074. }
  35075. return fields
  35076. }
  35077. // AddedField returns the numeric value that was incremented/decremented on a field
  35078. // with the given name. The second boolean return value indicates that this field
  35079. // was not set, or was not defined in the schema.
  35080. func (m *WhatsappMutation) AddedField(name string) (ent.Value, bool) {
  35081. switch name {
  35082. case whatsapp.FieldStatus:
  35083. return m.AddedStatus()
  35084. case whatsapp.FieldPhoneStatus:
  35085. return m.AddedPhoneStatus()
  35086. case whatsapp.FieldOrganizationID:
  35087. return m.AddedOrganizationID()
  35088. }
  35089. return nil, false
  35090. }
  35091. // AddField adds the value to the field with the given name. It returns an error if
  35092. // the field is not defined in the schema, or if the type mismatched the field
  35093. // type.
  35094. func (m *WhatsappMutation) AddField(name string, value ent.Value) error {
  35095. switch name {
  35096. case whatsapp.FieldStatus:
  35097. v, ok := value.(int8)
  35098. if !ok {
  35099. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35100. }
  35101. m.AddStatus(v)
  35102. return nil
  35103. case whatsapp.FieldPhoneStatus:
  35104. v, ok := value.(int8)
  35105. if !ok {
  35106. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35107. }
  35108. m.AddPhoneStatus(v)
  35109. return nil
  35110. case whatsapp.FieldOrganizationID:
  35111. v, ok := value.(int64)
  35112. if !ok {
  35113. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35114. }
  35115. m.AddOrganizationID(v)
  35116. return nil
  35117. }
  35118. return fmt.Errorf("unknown Whatsapp numeric field %s", name)
  35119. }
  35120. // ClearedFields returns all nullable fields that were cleared during this
  35121. // mutation.
  35122. func (m *WhatsappMutation) ClearedFields() []string {
  35123. var fields []string
  35124. if m.FieldCleared(whatsapp.FieldStatus) {
  35125. fields = append(fields, whatsapp.FieldStatus)
  35126. }
  35127. if m.FieldCleared(whatsapp.FieldDeletedAt) {
  35128. fields = append(fields, whatsapp.FieldDeletedAt)
  35129. }
  35130. if m.FieldCleared(whatsapp.FieldWaID) {
  35131. fields = append(fields, whatsapp.FieldWaID)
  35132. }
  35133. if m.FieldCleared(whatsapp.FieldCallback) {
  35134. fields = append(fields, whatsapp.FieldCallback)
  35135. }
  35136. if m.FieldCleared(whatsapp.FieldAccount) {
  35137. fields = append(fields, whatsapp.FieldAccount)
  35138. }
  35139. if m.FieldCleared(whatsapp.FieldOrganizationID) {
  35140. fields = append(fields, whatsapp.FieldOrganizationID)
  35141. }
  35142. if m.FieldCleared(whatsapp.FieldAPIBase) {
  35143. fields = append(fields, whatsapp.FieldAPIBase)
  35144. }
  35145. if m.FieldCleared(whatsapp.FieldAPIKey) {
  35146. fields = append(fields, whatsapp.FieldAPIKey)
  35147. }
  35148. if m.FieldCleared(whatsapp.FieldAllowList) {
  35149. fields = append(fields, whatsapp.FieldAllowList)
  35150. }
  35151. if m.FieldCleared(whatsapp.FieldGroupAllowList) {
  35152. fields = append(fields, whatsapp.FieldGroupAllowList)
  35153. }
  35154. if m.FieldCleared(whatsapp.FieldBlockList) {
  35155. fields = append(fields, whatsapp.FieldBlockList)
  35156. }
  35157. if m.FieldCleared(whatsapp.FieldGroupBlockList) {
  35158. fields = append(fields, whatsapp.FieldGroupBlockList)
  35159. }
  35160. return fields
  35161. }
  35162. // FieldCleared returns a boolean indicating if a field with the given name was
  35163. // cleared in this mutation.
  35164. func (m *WhatsappMutation) FieldCleared(name string) bool {
  35165. _, ok := m.clearedFields[name]
  35166. return ok
  35167. }
  35168. // ClearField clears the value of the field with the given name. It returns an
  35169. // error if the field is not defined in the schema.
  35170. func (m *WhatsappMutation) ClearField(name string) error {
  35171. switch name {
  35172. case whatsapp.FieldStatus:
  35173. m.ClearStatus()
  35174. return nil
  35175. case whatsapp.FieldDeletedAt:
  35176. m.ClearDeletedAt()
  35177. return nil
  35178. case whatsapp.FieldWaID:
  35179. m.ClearWaID()
  35180. return nil
  35181. case whatsapp.FieldCallback:
  35182. m.ClearCallback()
  35183. return nil
  35184. case whatsapp.FieldAccount:
  35185. m.ClearAccount()
  35186. return nil
  35187. case whatsapp.FieldOrganizationID:
  35188. m.ClearOrganizationID()
  35189. return nil
  35190. case whatsapp.FieldAPIBase:
  35191. m.ClearAPIBase()
  35192. return nil
  35193. case whatsapp.FieldAPIKey:
  35194. m.ClearAPIKey()
  35195. return nil
  35196. case whatsapp.FieldAllowList:
  35197. m.ClearAllowList()
  35198. return nil
  35199. case whatsapp.FieldGroupAllowList:
  35200. m.ClearGroupAllowList()
  35201. return nil
  35202. case whatsapp.FieldBlockList:
  35203. m.ClearBlockList()
  35204. return nil
  35205. case whatsapp.FieldGroupBlockList:
  35206. m.ClearGroupBlockList()
  35207. return nil
  35208. }
  35209. return fmt.Errorf("unknown Whatsapp nullable field %s", name)
  35210. }
  35211. // ResetField resets all changes in the mutation for the field with the given name.
  35212. // It returns an error if the field is not defined in the schema.
  35213. func (m *WhatsappMutation) ResetField(name string) error {
  35214. switch name {
  35215. case whatsapp.FieldCreatedAt:
  35216. m.ResetCreatedAt()
  35217. return nil
  35218. case whatsapp.FieldUpdatedAt:
  35219. m.ResetUpdatedAt()
  35220. return nil
  35221. case whatsapp.FieldStatus:
  35222. m.ResetStatus()
  35223. return nil
  35224. case whatsapp.FieldDeletedAt:
  35225. m.ResetDeletedAt()
  35226. return nil
  35227. case whatsapp.FieldWaID:
  35228. m.ResetWaID()
  35229. return nil
  35230. case whatsapp.FieldCallback:
  35231. m.ResetCallback()
  35232. return nil
  35233. case whatsapp.FieldAgentID:
  35234. m.ResetAgentID()
  35235. return nil
  35236. case whatsapp.FieldAccount:
  35237. m.ResetAccount()
  35238. return nil
  35239. case whatsapp.FieldCc:
  35240. m.ResetCc()
  35241. return nil
  35242. case whatsapp.FieldPhone:
  35243. m.ResetPhone()
  35244. return nil
  35245. case whatsapp.FieldPhoneName:
  35246. m.ResetPhoneName()
  35247. return nil
  35248. case whatsapp.FieldPhoneStatus:
  35249. m.ResetPhoneStatus()
  35250. return nil
  35251. case whatsapp.FieldOrganizationID:
  35252. m.ResetOrganizationID()
  35253. return nil
  35254. case whatsapp.FieldAPIBase:
  35255. m.ResetAPIBase()
  35256. return nil
  35257. case whatsapp.FieldAPIKey:
  35258. m.ResetAPIKey()
  35259. return nil
  35260. case whatsapp.FieldAllowList:
  35261. m.ResetAllowList()
  35262. return nil
  35263. case whatsapp.FieldGroupAllowList:
  35264. m.ResetGroupAllowList()
  35265. return nil
  35266. case whatsapp.FieldBlockList:
  35267. m.ResetBlockList()
  35268. return nil
  35269. case whatsapp.FieldGroupBlockList:
  35270. m.ResetGroupBlockList()
  35271. return nil
  35272. }
  35273. return fmt.Errorf("unknown Whatsapp field %s", name)
  35274. }
  35275. // AddedEdges returns all edge names that were set/added in this mutation.
  35276. func (m *WhatsappMutation) AddedEdges() []string {
  35277. edges := make([]string, 0, 1)
  35278. if m.agent != nil {
  35279. edges = append(edges, whatsapp.EdgeAgent)
  35280. }
  35281. return edges
  35282. }
  35283. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  35284. // name in this mutation.
  35285. func (m *WhatsappMutation) AddedIDs(name string) []ent.Value {
  35286. switch name {
  35287. case whatsapp.EdgeAgent:
  35288. if id := m.agent; id != nil {
  35289. return []ent.Value{*id}
  35290. }
  35291. }
  35292. return nil
  35293. }
  35294. // RemovedEdges returns all edge names that were removed in this mutation.
  35295. func (m *WhatsappMutation) RemovedEdges() []string {
  35296. edges := make([]string, 0, 1)
  35297. return edges
  35298. }
  35299. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  35300. // the given name in this mutation.
  35301. func (m *WhatsappMutation) RemovedIDs(name string) []ent.Value {
  35302. return nil
  35303. }
  35304. // ClearedEdges returns all edge names that were cleared in this mutation.
  35305. func (m *WhatsappMutation) ClearedEdges() []string {
  35306. edges := make([]string, 0, 1)
  35307. if m.clearedagent {
  35308. edges = append(edges, whatsapp.EdgeAgent)
  35309. }
  35310. return edges
  35311. }
  35312. // EdgeCleared returns a boolean which indicates if the edge with the given name
  35313. // was cleared in this mutation.
  35314. func (m *WhatsappMutation) EdgeCleared(name string) bool {
  35315. switch name {
  35316. case whatsapp.EdgeAgent:
  35317. return m.clearedagent
  35318. }
  35319. return false
  35320. }
  35321. // ClearEdge clears the value of the edge with the given name. It returns an error
  35322. // if that edge is not defined in the schema.
  35323. func (m *WhatsappMutation) ClearEdge(name string) error {
  35324. switch name {
  35325. case whatsapp.EdgeAgent:
  35326. m.ClearAgent()
  35327. return nil
  35328. }
  35329. return fmt.Errorf("unknown Whatsapp unique edge %s", name)
  35330. }
  35331. // ResetEdge resets all changes to the edge with the given name in this mutation.
  35332. // It returns an error if the edge is not defined in the schema.
  35333. func (m *WhatsappMutation) ResetEdge(name string) error {
  35334. switch name {
  35335. case whatsapp.EdgeAgent:
  35336. m.ResetAgent()
  35337. return nil
  35338. }
  35339. return fmt.Errorf("unknown Whatsapp edge %s", name)
  35340. }
  35341. // WhatsappChannelMutation represents an operation that mutates the WhatsappChannel nodes in the graph.
  35342. type WhatsappChannelMutation struct {
  35343. config
  35344. op Op
  35345. typ string
  35346. id *uint64
  35347. created_at *time.Time
  35348. updated_at *time.Time
  35349. status *uint8
  35350. addstatus *int8
  35351. deleted_at *time.Time
  35352. ak *string
  35353. sk *string
  35354. wa_id *string
  35355. wa_name *string
  35356. waba_id *uint64
  35357. addwaba_id *int64
  35358. business_id *uint64
  35359. addbusiness_id *int64
  35360. organization_id *uint64
  35361. addorganization_id *int64
  35362. verify_account *string
  35363. clearedFields map[string]struct{}
  35364. done bool
  35365. oldValue func(context.Context) (*WhatsappChannel, error)
  35366. predicates []predicate.WhatsappChannel
  35367. }
  35368. var _ ent.Mutation = (*WhatsappChannelMutation)(nil)
  35369. // whatsappchannelOption allows management of the mutation configuration using functional options.
  35370. type whatsappchannelOption func(*WhatsappChannelMutation)
  35371. // newWhatsappChannelMutation creates new mutation for the WhatsappChannel entity.
  35372. func newWhatsappChannelMutation(c config, op Op, opts ...whatsappchannelOption) *WhatsappChannelMutation {
  35373. m := &WhatsappChannelMutation{
  35374. config: c,
  35375. op: op,
  35376. typ: TypeWhatsappChannel,
  35377. clearedFields: make(map[string]struct{}),
  35378. }
  35379. for _, opt := range opts {
  35380. opt(m)
  35381. }
  35382. return m
  35383. }
  35384. // withWhatsappChannelID sets the ID field of the mutation.
  35385. func withWhatsappChannelID(id uint64) whatsappchannelOption {
  35386. return func(m *WhatsappChannelMutation) {
  35387. var (
  35388. err error
  35389. once sync.Once
  35390. value *WhatsappChannel
  35391. )
  35392. m.oldValue = func(ctx context.Context) (*WhatsappChannel, error) {
  35393. once.Do(func() {
  35394. if m.done {
  35395. err = errors.New("querying old values post mutation is not allowed")
  35396. } else {
  35397. value, err = m.Client().WhatsappChannel.Get(ctx, id)
  35398. }
  35399. })
  35400. return value, err
  35401. }
  35402. m.id = &id
  35403. }
  35404. }
  35405. // withWhatsappChannel sets the old WhatsappChannel of the mutation.
  35406. func withWhatsappChannel(node *WhatsappChannel) whatsappchannelOption {
  35407. return func(m *WhatsappChannelMutation) {
  35408. m.oldValue = func(context.Context) (*WhatsappChannel, error) {
  35409. return node, nil
  35410. }
  35411. m.id = &node.ID
  35412. }
  35413. }
  35414. // Client returns a new `ent.Client` from the mutation. If the mutation was
  35415. // executed in a transaction (ent.Tx), a transactional client is returned.
  35416. func (m WhatsappChannelMutation) Client() *Client {
  35417. client := &Client{config: m.config}
  35418. client.init()
  35419. return client
  35420. }
  35421. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  35422. // it returns an error otherwise.
  35423. func (m WhatsappChannelMutation) Tx() (*Tx, error) {
  35424. if _, ok := m.driver.(*txDriver); !ok {
  35425. return nil, errors.New("ent: mutation is not running in a transaction")
  35426. }
  35427. tx := &Tx{config: m.config}
  35428. tx.init()
  35429. return tx, nil
  35430. }
  35431. // SetID sets the value of the id field. Note that this
  35432. // operation is only accepted on creation of WhatsappChannel entities.
  35433. func (m *WhatsappChannelMutation) SetID(id uint64) {
  35434. m.id = &id
  35435. }
  35436. // ID returns the ID value in the mutation. Note that the ID is only available
  35437. // if it was provided to the builder or after it was returned from the database.
  35438. func (m *WhatsappChannelMutation) ID() (id uint64, exists bool) {
  35439. if m.id == nil {
  35440. return
  35441. }
  35442. return *m.id, true
  35443. }
  35444. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  35445. // That means, if the mutation is applied within a transaction with an isolation level such
  35446. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  35447. // or updated by the mutation.
  35448. func (m *WhatsappChannelMutation) IDs(ctx context.Context) ([]uint64, error) {
  35449. switch {
  35450. case m.op.Is(OpUpdateOne | OpDeleteOne):
  35451. id, exists := m.ID()
  35452. if exists {
  35453. return []uint64{id}, nil
  35454. }
  35455. fallthrough
  35456. case m.op.Is(OpUpdate | OpDelete):
  35457. return m.Client().WhatsappChannel.Query().Where(m.predicates...).IDs(ctx)
  35458. default:
  35459. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  35460. }
  35461. }
  35462. // SetCreatedAt sets the "created_at" field.
  35463. func (m *WhatsappChannelMutation) SetCreatedAt(t time.Time) {
  35464. m.created_at = &t
  35465. }
  35466. // CreatedAt returns the value of the "created_at" field in the mutation.
  35467. func (m *WhatsappChannelMutation) CreatedAt() (r time.Time, exists bool) {
  35468. v := m.created_at
  35469. if v == nil {
  35470. return
  35471. }
  35472. return *v, true
  35473. }
  35474. // OldCreatedAt returns the old "created_at" field's value of the WhatsappChannel entity.
  35475. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  35476. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35477. func (m *WhatsappChannelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  35478. if !m.op.Is(OpUpdateOne) {
  35479. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  35480. }
  35481. if m.id == nil || m.oldValue == nil {
  35482. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  35483. }
  35484. oldValue, err := m.oldValue(ctx)
  35485. if err != nil {
  35486. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  35487. }
  35488. return oldValue.CreatedAt, nil
  35489. }
  35490. // ResetCreatedAt resets all changes to the "created_at" field.
  35491. func (m *WhatsappChannelMutation) ResetCreatedAt() {
  35492. m.created_at = nil
  35493. }
  35494. // SetUpdatedAt sets the "updated_at" field.
  35495. func (m *WhatsappChannelMutation) SetUpdatedAt(t time.Time) {
  35496. m.updated_at = &t
  35497. }
  35498. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  35499. func (m *WhatsappChannelMutation) UpdatedAt() (r time.Time, exists bool) {
  35500. v := m.updated_at
  35501. if v == nil {
  35502. return
  35503. }
  35504. return *v, true
  35505. }
  35506. // OldUpdatedAt returns the old "updated_at" field's value of the WhatsappChannel entity.
  35507. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  35508. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35509. func (m *WhatsappChannelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  35510. if !m.op.Is(OpUpdateOne) {
  35511. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  35512. }
  35513. if m.id == nil || m.oldValue == nil {
  35514. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  35515. }
  35516. oldValue, err := m.oldValue(ctx)
  35517. if err != nil {
  35518. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  35519. }
  35520. return oldValue.UpdatedAt, nil
  35521. }
  35522. // ResetUpdatedAt resets all changes to the "updated_at" field.
  35523. func (m *WhatsappChannelMutation) ResetUpdatedAt() {
  35524. m.updated_at = nil
  35525. }
  35526. // SetStatus sets the "status" field.
  35527. func (m *WhatsappChannelMutation) SetStatus(u uint8) {
  35528. m.status = &u
  35529. m.addstatus = nil
  35530. }
  35531. // Status returns the value of the "status" field in the mutation.
  35532. func (m *WhatsappChannelMutation) Status() (r uint8, exists bool) {
  35533. v := m.status
  35534. if v == nil {
  35535. return
  35536. }
  35537. return *v, true
  35538. }
  35539. // OldStatus returns the old "status" field's value of the WhatsappChannel entity.
  35540. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  35541. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35542. func (m *WhatsappChannelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  35543. if !m.op.Is(OpUpdateOne) {
  35544. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  35545. }
  35546. if m.id == nil || m.oldValue == nil {
  35547. return v, errors.New("OldStatus requires an ID field in the mutation")
  35548. }
  35549. oldValue, err := m.oldValue(ctx)
  35550. if err != nil {
  35551. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  35552. }
  35553. return oldValue.Status, nil
  35554. }
  35555. // AddStatus adds u to the "status" field.
  35556. func (m *WhatsappChannelMutation) AddStatus(u int8) {
  35557. if m.addstatus != nil {
  35558. *m.addstatus += u
  35559. } else {
  35560. m.addstatus = &u
  35561. }
  35562. }
  35563. // AddedStatus returns the value that was added to the "status" field in this mutation.
  35564. func (m *WhatsappChannelMutation) AddedStatus() (r int8, exists bool) {
  35565. v := m.addstatus
  35566. if v == nil {
  35567. return
  35568. }
  35569. return *v, true
  35570. }
  35571. // ClearStatus clears the value of the "status" field.
  35572. func (m *WhatsappChannelMutation) ClearStatus() {
  35573. m.status = nil
  35574. m.addstatus = nil
  35575. m.clearedFields[whatsappchannel.FieldStatus] = struct{}{}
  35576. }
  35577. // StatusCleared returns if the "status" field was cleared in this mutation.
  35578. func (m *WhatsappChannelMutation) StatusCleared() bool {
  35579. _, ok := m.clearedFields[whatsappchannel.FieldStatus]
  35580. return ok
  35581. }
  35582. // ResetStatus resets all changes to the "status" field.
  35583. func (m *WhatsappChannelMutation) ResetStatus() {
  35584. m.status = nil
  35585. m.addstatus = nil
  35586. delete(m.clearedFields, whatsappchannel.FieldStatus)
  35587. }
  35588. // SetDeletedAt sets the "deleted_at" field.
  35589. func (m *WhatsappChannelMutation) SetDeletedAt(t time.Time) {
  35590. m.deleted_at = &t
  35591. }
  35592. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  35593. func (m *WhatsappChannelMutation) DeletedAt() (r time.Time, exists bool) {
  35594. v := m.deleted_at
  35595. if v == nil {
  35596. return
  35597. }
  35598. return *v, true
  35599. }
  35600. // OldDeletedAt returns the old "deleted_at" field's value of the WhatsappChannel entity.
  35601. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  35602. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35603. func (m *WhatsappChannelMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  35604. if !m.op.Is(OpUpdateOne) {
  35605. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  35606. }
  35607. if m.id == nil || m.oldValue == nil {
  35608. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  35609. }
  35610. oldValue, err := m.oldValue(ctx)
  35611. if err != nil {
  35612. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  35613. }
  35614. return oldValue.DeletedAt, nil
  35615. }
  35616. // ClearDeletedAt clears the value of the "deleted_at" field.
  35617. func (m *WhatsappChannelMutation) ClearDeletedAt() {
  35618. m.deleted_at = nil
  35619. m.clearedFields[whatsappchannel.FieldDeletedAt] = struct{}{}
  35620. }
  35621. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  35622. func (m *WhatsappChannelMutation) DeletedAtCleared() bool {
  35623. _, ok := m.clearedFields[whatsappchannel.FieldDeletedAt]
  35624. return ok
  35625. }
  35626. // ResetDeletedAt resets all changes to the "deleted_at" field.
  35627. func (m *WhatsappChannelMutation) ResetDeletedAt() {
  35628. m.deleted_at = nil
  35629. delete(m.clearedFields, whatsappchannel.FieldDeletedAt)
  35630. }
  35631. // SetAk sets the "ak" field.
  35632. func (m *WhatsappChannelMutation) SetAk(s string) {
  35633. m.ak = &s
  35634. }
  35635. // Ak returns the value of the "ak" field in the mutation.
  35636. func (m *WhatsappChannelMutation) Ak() (r string, exists bool) {
  35637. v := m.ak
  35638. if v == nil {
  35639. return
  35640. }
  35641. return *v, true
  35642. }
  35643. // OldAk returns the old "ak" field's value of the WhatsappChannel entity.
  35644. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  35645. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35646. func (m *WhatsappChannelMutation) OldAk(ctx context.Context) (v string, err error) {
  35647. if !m.op.Is(OpUpdateOne) {
  35648. return v, errors.New("OldAk is only allowed on UpdateOne operations")
  35649. }
  35650. if m.id == nil || m.oldValue == nil {
  35651. return v, errors.New("OldAk requires an ID field in the mutation")
  35652. }
  35653. oldValue, err := m.oldValue(ctx)
  35654. if err != nil {
  35655. return v, fmt.Errorf("querying old value for OldAk: %w", err)
  35656. }
  35657. return oldValue.Ak, nil
  35658. }
  35659. // ClearAk clears the value of the "ak" field.
  35660. func (m *WhatsappChannelMutation) ClearAk() {
  35661. m.ak = nil
  35662. m.clearedFields[whatsappchannel.FieldAk] = struct{}{}
  35663. }
  35664. // AkCleared returns if the "ak" field was cleared in this mutation.
  35665. func (m *WhatsappChannelMutation) AkCleared() bool {
  35666. _, ok := m.clearedFields[whatsappchannel.FieldAk]
  35667. return ok
  35668. }
  35669. // ResetAk resets all changes to the "ak" field.
  35670. func (m *WhatsappChannelMutation) ResetAk() {
  35671. m.ak = nil
  35672. delete(m.clearedFields, whatsappchannel.FieldAk)
  35673. }
  35674. // SetSk sets the "sk" field.
  35675. func (m *WhatsappChannelMutation) SetSk(s string) {
  35676. m.sk = &s
  35677. }
  35678. // Sk returns the value of the "sk" field in the mutation.
  35679. func (m *WhatsappChannelMutation) Sk() (r string, exists bool) {
  35680. v := m.sk
  35681. if v == nil {
  35682. return
  35683. }
  35684. return *v, true
  35685. }
  35686. // OldSk returns the old "sk" field's value of the WhatsappChannel entity.
  35687. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  35688. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35689. func (m *WhatsappChannelMutation) OldSk(ctx context.Context) (v string, err error) {
  35690. if !m.op.Is(OpUpdateOne) {
  35691. return v, errors.New("OldSk is only allowed on UpdateOne operations")
  35692. }
  35693. if m.id == nil || m.oldValue == nil {
  35694. return v, errors.New("OldSk requires an ID field in the mutation")
  35695. }
  35696. oldValue, err := m.oldValue(ctx)
  35697. if err != nil {
  35698. return v, fmt.Errorf("querying old value for OldSk: %w", err)
  35699. }
  35700. return oldValue.Sk, nil
  35701. }
  35702. // ResetSk resets all changes to the "sk" field.
  35703. func (m *WhatsappChannelMutation) ResetSk() {
  35704. m.sk = nil
  35705. }
  35706. // SetWaID sets the "wa_id" field.
  35707. func (m *WhatsappChannelMutation) SetWaID(s string) {
  35708. m.wa_id = &s
  35709. }
  35710. // WaID returns the value of the "wa_id" field in the mutation.
  35711. func (m *WhatsappChannelMutation) WaID() (r string, exists bool) {
  35712. v := m.wa_id
  35713. if v == nil {
  35714. return
  35715. }
  35716. return *v, true
  35717. }
  35718. // OldWaID returns the old "wa_id" field's value of the WhatsappChannel entity.
  35719. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  35720. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35721. func (m *WhatsappChannelMutation) OldWaID(ctx context.Context) (v string, err error) {
  35722. if !m.op.Is(OpUpdateOne) {
  35723. return v, errors.New("OldWaID is only allowed on UpdateOne operations")
  35724. }
  35725. if m.id == nil || m.oldValue == nil {
  35726. return v, errors.New("OldWaID requires an ID field in the mutation")
  35727. }
  35728. oldValue, err := m.oldValue(ctx)
  35729. if err != nil {
  35730. return v, fmt.Errorf("querying old value for OldWaID: %w", err)
  35731. }
  35732. return oldValue.WaID, nil
  35733. }
  35734. // ClearWaID clears the value of the "wa_id" field.
  35735. func (m *WhatsappChannelMutation) ClearWaID() {
  35736. m.wa_id = nil
  35737. m.clearedFields[whatsappchannel.FieldWaID] = struct{}{}
  35738. }
  35739. // WaIDCleared returns if the "wa_id" field was cleared in this mutation.
  35740. func (m *WhatsappChannelMutation) WaIDCleared() bool {
  35741. _, ok := m.clearedFields[whatsappchannel.FieldWaID]
  35742. return ok
  35743. }
  35744. // ResetWaID resets all changes to the "wa_id" field.
  35745. func (m *WhatsappChannelMutation) ResetWaID() {
  35746. m.wa_id = nil
  35747. delete(m.clearedFields, whatsappchannel.FieldWaID)
  35748. }
  35749. // SetWaName sets the "wa_name" field.
  35750. func (m *WhatsappChannelMutation) SetWaName(s string) {
  35751. m.wa_name = &s
  35752. }
  35753. // WaName returns the value of the "wa_name" field in the mutation.
  35754. func (m *WhatsappChannelMutation) WaName() (r string, exists bool) {
  35755. v := m.wa_name
  35756. if v == nil {
  35757. return
  35758. }
  35759. return *v, true
  35760. }
  35761. // OldWaName returns the old "wa_name" field's value of the WhatsappChannel entity.
  35762. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  35763. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35764. func (m *WhatsappChannelMutation) OldWaName(ctx context.Context) (v string, err error) {
  35765. if !m.op.Is(OpUpdateOne) {
  35766. return v, errors.New("OldWaName is only allowed on UpdateOne operations")
  35767. }
  35768. if m.id == nil || m.oldValue == nil {
  35769. return v, errors.New("OldWaName requires an ID field in the mutation")
  35770. }
  35771. oldValue, err := m.oldValue(ctx)
  35772. if err != nil {
  35773. return v, fmt.Errorf("querying old value for OldWaName: %w", err)
  35774. }
  35775. return oldValue.WaName, nil
  35776. }
  35777. // ClearWaName clears the value of the "wa_name" field.
  35778. func (m *WhatsappChannelMutation) ClearWaName() {
  35779. m.wa_name = nil
  35780. m.clearedFields[whatsappchannel.FieldWaName] = struct{}{}
  35781. }
  35782. // WaNameCleared returns if the "wa_name" field was cleared in this mutation.
  35783. func (m *WhatsappChannelMutation) WaNameCleared() bool {
  35784. _, ok := m.clearedFields[whatsappchannel.FieldWaName]
  35785. return ok
  35786. }
  35787. // ResetWaName resets all changes to the "wa_name" field.
  35788. func (m *WhatsappChannelMutation) ResetWaName() {
  35789. m.wa_name = nil
  35790. delete(m.clearedFields, whatsappchannel.FieldWaName)
  35791. }
  35792. // SetWabaID sets the "waba_id" field.
  35793. func (m *WhatsappChannelMutation) SetWabaID(u uint64) {
  35794. m.waba_id = &u
  35795. m.addwaba_id = nil
  35796. }
  35797. // WabaID returns the value of the "waba_id" field in the mutation.
  35798. func (m *WhatsappChannelMutation) WabaID() (r uint64, exists bool) {
  35799. v := m.waba_id
  35800. if v == nil {
  35801. return
  35802. }
  35803. return *v, true
  35804. }
  35805. // OldWabaID returns the old "waba_id" field's value of the WhatsappChannel entity.
  35806. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  35807. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35808. func (m *WhatsappChannelMutation) OldWabaID(ctx context.Context) (v uint64, err error) {
  35809. if !m.op.Is(OpUpdateOne) {
  35810. return v, errors.New("OldWabaID is only allowed on UpdateOne operations")
  35811. }
  35812. if m.id == nil || m.oldValue == nil {
  35813. return v, errors.New("OldWabaID requires an ID field in the mutation")
  35814. }
  35815. oldValue, err := m.oldValue(ctx)
  35816. if err != nil {
  35817. return v, fmt.Errorf("querying old value for OldWabaID: %w", err)
  35818. }
  35819. return oldValue.WabaID, nil
  35820. }
  35821. // AddWabaID adds u to the "waba_id" field.
  35822. func (m *WhatsappChannelMutation) AddWabaID(u int64) {
  35823. if m.addwaba_id != nil {
  35824. *m.addwaba_id += u
  35825. } else {
  35826. m.addwaba_id = &u
  35827. }
  35828. }
  35829. // AddedWabaID returns the value that was added to the "waba_id" field in this mutation.
  35830. func (m *WhatsappChannelMutation) AddedWabaID() (r int64, exists bool) {
  35831. v := m.addwaba_id
  35832. if v == nil {
  35833. return
  35834. }
  35835. return *v, true
  35836. }
  35837. // ResetWabaID resets all changes to the "waba_id" field.
  35838. func (m *WhatsappChannelMutation) ResetWabaID() {
  35839. m.waba_id = nil
  35840. m.addwaba_id = nil
  35841. }
  35842. // SetBusinessID sets the "business_id" field.
  35843. func (m *WhatsappChannelMutation) SetBusinessID(u uint64) {
  35844. m.business_id = &u
  35845. m.addbusiness_id = nil
  35846. }
  35847. // BusinessID returns the value of the "business_id" field in the mutation.
  35848. func (m *WhatsappChannelMutation) BusinessID() (r uint64, exists bool) {
  35849. v := m.business_id
  35850. if v == nil {
  35851. return
  35852. }
  35853. return *v, true
  35854. }
  35855. // OldBusinessID returns the old "business_id" field's value of the WhatsappChannel entity.
  35856. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  35857. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35858. func (m *WhatsappChannelMutation) OldBusinessID(ctx context.Context) (v uint64, err error) {
  35859. if !m.op.Is(OpUpdateOne) {
  35860. return v, errors.New("OldBusinessID is only allowed on UpdateOne operations")
  35861. }
  35862. if m.id == nil || m.oldValue == nil {
  35863. return v, errors.New("OldBusinessID requires an ID field in the mutation")
  35864. }
  35865. oldValue, err := m.oldValue(ctx)
  35866. if err != nil {
  35867. return v, fmt.Errorf("querying old value for OldBusinessID: %w", err)
  35868. }
  35869. return oldValue.BusinessID, nil
  35870. }
  35871. // AddBusinessID adds u to the "business_id" field.
  35872. func (m *WhatsappChannelMutation) AddBusinessID(u int64) {
  35873. if m.addbusiness_id != nil {
  35874. *m.addbusiness_id += u
  35875. } else {
  35876. m.addbusiness_id = &u
  35877. }
  35878. }
  35879. // AddedBusinessID returns the value that was added to the "business_id" field in this mutation.
  35880. func (m *WhatsappChannelMutation) AddedBusinessID() (r int64, exists bool) {
  35881. v := m.addbusiness_id
  35882. if v == nil {
  35883. return
  35884. }
  35885. return *v, true
  35886. }
  35887. // ResetBusinessID resets all changes to the "business_id" field.
  35888. func (m *WhatsappChannelMutation) ResetBusinessID() {
  35889. m.business_id = nil
  35890. m.addbusiness_id = nil
  35891. }
  35892. // SetOrganizationID sets the "organization_id" field.
  35893. func (m *WhatsappChannelMutation) SetOrganizationID(u uint64) {
  35894. m.organization_id = &u
  35895. m.addorganization_id = nil
  35896. }
  35897. // OrganizationID returns the value of the "organization_id" field in the mutation.
  35898. func (m *WhatsappChannelMutation) OrganizationID() (r uint64, exists bool) {
  35899. v := m.organization_id
  35900. if v == nil {
  35901. return
  35902. }
  35903. return *v, true
  35904. }
  35905. // OldOrganizationID returns the old "organization_id" field's value of the WhatsappChannel entity.
  35906. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  35907. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35908. func (m *WhatsappChannelMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  35909. if !m.op.Is(OpUpdateOne) {
  35910. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  35911. }
  35912. if m.id == nil || m.oldValue == nil {
  35913. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  35914. }
  35915. oldValue, err := m.oldValue(ctx)
  35916. if err != nil {
  35917. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  35918. }
  35919. return oldValue.OrganizationID, nil
  35920. }
  35921. // AddOrganizationID adds u to the "organization_id" field.
  35922. func (m *WhatsappChannelMutation) AddOrganizationID(u int64) {
  35923. if m.addorganization_id != nil {
  35924. *m.addorganization_id += u
  35925. } else {
  35926. m.addorganization_id = &u
  35927. }
  35928. }
  35929. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  35930. func (m *WhatsappChannelMutation) AddedOrganizationID() (r int64, exists bool) {
  35931. v := m.addorganization_id
  35932. if v == nil {
  35933. return
  35934. }
  35935. return *v, true
  35936. }
  35937. // ClearOrganizationID clears the value of the "organization_id" field.
  35938. func (m *WhatsappChannelMutation) ClearOrganizationID() {
  35939. m.organization_id = nil
  35940. m.addorganization_id = nil
  35941. m.clearedFields[whatsappchannel.FieldOrganizationID] = struct{}{}
  35942. }
  35943. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  35944. func (m *WhatsappChannelMutation) OrganizationIDCleared() bool {
  35945. _, ok := m.clearedFields[whatsappchannel.FieldOrganizationID]
  35946. return ok
  35947. }
  35948. // ResetOrganizationID resets all changes to the "organization_id" field.
  35949. func (m *WhatsappChannelMutation) ResetOrganizationID() {
  35950. m.organization_id = nil
  35951. m.addorganization_id = nil
  35952. delete(m.clearedFields, whatsappchannel.FieldOrganizationID)
  35953. }
  35954. // SetVerifyAccount sets the "verify_account" field.
  35955. func (m *WhatsappChannelMutation) SetVerifyAccount(s string) {
  35956. m.verify_account = &s
  35957. }
  35958. // VerifyAccount returns the value of the "verify_account" field in the mutation.
  35959. func (m *WhatsappChannelMutation) VerifyAccount() (r string, exists bool) {
  35960. v := m.verify_account
  35961. if v == nil {
  35962. return
  35963. }
  35964. return *v, true
  35965. }
  35966. // OldVerifyAccount returns the old "verify_account" field's value of the WhatsappChannel entity.
  35967. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  35968. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35969. func (m *WhatsappChannelMutation) OldVerifyAccount(ctx context.Context) (v string, err error) {
  35970. if !m.op.Is(OpUpdateOne) {
  35971. return v, errors.New("OldVerifyAccount is only allowed on UpdateOne operations")
  35972. }
  35973. if m.id == nil || m.oldValue == nil {
  35974. return v, errors.New("OldVerifyAccount requires an ID field in the mutation")
  35975. }
  35976. oldValue, err := m.oldValue(ctx)
  35977. if err != nil {
  35978. return v, fmt.Errorf("querying old value for OldVerifyAccount: %w", err)
  35979. }
  35980. return oldValue.VerifyAccount, nil
  35981. }
  35982. // ResetVerifyAccount resets all changes to the "verify_account" field.
  35983. func (m *WhatsappChannelMutation) ResetVerifyAccount() {
  35984. m.verify_account = nil
  35985. }
  35986. // Where appends a list predicates to the WhatsappChannelMutation builder.
  35987. func (m *WhatsappChannelMutation) Where(ps ...predicate.WhatsappChannel) {
  35988. m.predicates = append(m.predicates, ps...)
  35989. }
  35990. // WhereP appends storage-level predicates to the WhatsappChannelMutation builder. Using this method,
  35991. // users can use type-assertion to append predicates that do not depend on any generated package.
  35992. func (m *WhatsappChannelMutation) WhereP(ps ...func(*sql.Selector)) {
  35993. p := make([]predicate.WhatsappChannel, len(ps))
  35994. for i := range ps {
  35995. p[i] = ps[i]
  35996. }
  35997. m.Where(p...)
  35998. }
  35999. // Op returns the operation name.
  36000. func (m *WhatsappChannelMutation) Op() Op {
  36001. return m.op
  36002. }
  36003. // SetOp allows setting the mutation operation.
  36004. func (m *WhatsappChannelMutation) SetOp(op Op) {
  36005. m.op = op
  36006. }
  36007. // Type returns the node type of this mutation (WhatsappChannel).
  36008. func (m *WhatsappChannelMutation) Type() string {
  36009. return m.typ
  36010. }
  36011. // Fields returns all fields that were changed during this mutation. Note that in
  36012. // order to get all numeric fields that were incremented/decremented, call
  36013. // AddedFields().
  36014. func (m *WhatsappChannelMutation) Fields() []string {
  36015. fields := make([]string, 0, 12)
  36016. if m.created_at != nil {
  36017. fields = append(fields, whatsappchannel.FieldCreatedAt)
  36018. }
  36019. if m.updated_at != nil {
  36020. fields = append(fields, whatsappchannel.FieldUpdatedAt)
  36021. }
  36022. if m.status != nil {
  36023. fields = append(fields, whatsappchannel.FieldStatus)
  36024. }
  36025. if m.deleted_at != nil {
  36026. fields = append(fields, whatsappchannel.FieldDeletedAt)
  36027. }
  36028. if m.ak != nil {
  36029. fields = append(fields, whatsappchannel.FieldAk)
  36030. }
  36031. if m.sk != nil {
  36032. fields = append(fields, whatsappchannel.FieldSk)
  36033. }
  36034. if m.wa_id != nil {
  36035. fields = append(fields, whatsappchannel.FieldWaID)
  36036. }
  36037. if m.wa_name != nil {
  36038. fields = append(fields, whatsappchannel.FieldWaName)
  36039. }
  36040. if m.waba_id != nil {
  36041. fields = append(fields, whatsappchannel.FieldWabaID)
  36042. }
  36043. if m.business_id != nil {
  36044. fields = append(fields, whatsappchannel.FieldBusinessID)
  36045. }
  36046. if m.organization_id != nil {
  36047. fields = append(fields, whatsappchannel.FieldOrganizationID)
  36048. }
  36049. if m.verify_account != nil {
  36050. fields = append(fields, whatsappchannel.FieldVerifyAccount)
  36051. }
  36052. return fields
  36053. }
  36054. // Field returns the value of a field with the given name. The second boolean
  36055. // return value indicates that this field was not set, or was not defined in the
  36056. // schema.
  36057. func (m *WhatsappChannelMutation) Field(name string) (ent.Value, bool) {
  36058. switch name {
  36059. case whatsappchannel.FieldCreatedAt:
  36060. return m.CreatedAt()
  36061. case whatsappchannel.FieldUpdatedAt:
  36062. return m.UpdatedAt()
  36063. case whatsappchannel.FieldStatus:
  36064. return m.Status()
  36065. case whatsappchannel.FieldDeletedAt:
  36066. return m.DeletedAt()
  36067. case whatsappchannel.FieldAk:
  36068. return m.Ak()
  36069. case whatsappchannel.FieldSk:
  36070. return m.Sk()
  36071. case whatsappchannel.FieldWaID:
  36072. return m.WaID()
  36073. case whatsappchannel.FieldWaName:
  36074. return m.WaName()
  36075. case whatsappchannel.FieldWabaID:
  36076. return m.WabaID()
  36077. case whatsappchannel.FieldBusinessID:
  36078. return m.BusinessID()
  36079. case whatsappchannel.FieldOrganizationID:
  36080. return m.OrganizationID()
  36081. case whatsappchannel.FieldVerifyAccount:
  36082. return m.VerifyAccount()
  36083. }
  36084. return nil, false
  36085. }
  36086. // OldField returns the old value of the field from the database. An error is
  36087. // returned if the mutation operation is not UpdateOne, or the query to the
  36088. // database failed.
  36089. func (m *WhatsappChannelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  36090. switch name {
  36091. case whatsappchannel.FieldCreatedAt:
  36092. return m.OldCreatedAt(ctx)
  36093. case whatsappchannel.FieldUpdatedAt:
  36094. return m.OldUpdatedAt(ctx)
  36095. case whatsappchannel.FieldStatus:
  36096. return m.OldStatus(ctx)
  36097. case whatsappchannel.FieldDeletedAt:
  36098. return m.OldDeletedAt(ctx)
  36099. case whatsappchannel.FieldAk:
  36100. return m.OldAk(ctx)
  36101. case whatsappchannel.FieldSk:
  36102. return m.OldSk(ctx)
  36103. case whatsappchannel.FieldWaID:
  36104. return m.OldWaID(ctx)
  36105. case whatsappchannel.FieldWaName:
  36106. return m.OldWaName(ctx)
  36107. case whatsappchannel.FieldWabaID:
  36108. return m.OldWabaID(ctx)
  36109. case whatsappchannel.FieldBusinessID:
  36110. return m.OldBusinessID(ctx)
  36111. case whatsappchannel.FieldOrganizationID:
  36112. return m.OldOrganizationID(ctx)
  36113. case whatsappchannel.FieldVerifyAccount:
  36114. return m.OldVerifyAccount(ctx)
  36115. }
  36116. return nil, fmt.Errorf("unknown WhatsappChannel field %s", name)
  36117. }
  36118. // SetField sets the value of a field with the given name. It returns an error if
  36119. // the field is not defined in the schema, or if the type mismatched the field
  36120. // type.
  36121. func (m *WhatsappChannelMutation) SetField(name string, value ent.Value) error {
  36122. switch name {
  36123. case whatsappchannel.FieldCreatedAt:
  36124. v, ok := value.(time.Time)
  36125. if !ok {
  36126. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36127. }
  36128. m.SetCreatedAt(v)
  36129. return nil
  36130. case whatsappchannel.FieldUpdatedAt:
  36131. v, ok := value.(time.Time)
  36132. if !ok {
  36133. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36134. }
  36135. m.SetUpdatedAt(v)
  36136. return nil
  36137. case whatsappchannel.FieldStatus:
  36138. v, ok := value.(uint8)
  36139. if !ok {
  36140. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36141. }
  36142. m.SetStatus(v)
  36143. return nil
  36144. case whatsappchannel.FieldDeletedAt:
  36145. v, ok := value.(time.Time)
  36146. if !ok {
  36147. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36148. }
  36149. m.SetDeletedAt(v)
  36150. return nil
  36151. case whatsappchannel.FieldAk:
  36152. v, ok := value.(string)
  36153. if !ok {
  36154. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36155. }
  36156. m.SetAk(v)
  36157. return nil
  36158. case whatsappchannel.FieldSk:
  36159. v, ok := value.(string)
  36160. if !ok {
  36161. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36162. }
  36163. m.SetSk(v)
  36164. return nil
  36165. case whatsappchannel.FieldWaID:
  36166. v, ok := value.(string)
  36167. if !ok {
  36168. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36169. }
  36170. m.SetWaID(v)
  36171. return nil
  36172. case whatsappchannel.FieldWaName:
  36173. v, ok := value.(string)
  36174. if !ok {
  36175. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36176. }
  36177. m.SetWaName(v)
  36178. return nil
  36179. case whatsappchannel.FieldWabaID:
  36180. v, ok := value.(uint64)
  36181. if !ok {
  36182. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36183. }
  36184. m.SetWabaID(v)
  36185. return nil
  36186. case whatsappchannel.FieldBusinessID:
  36187. v, ok := value.(uint64)
  36188. if !ok {
  36189. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36190. }
  36191. m.SetBusinessID(v)
  36192. return nil
  36193. case whatsappchannel.FieldOrganizationID:
  36194. v, ok := value.(uint64)
  36195. if !ok {
  36196. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36197. }
  36198. m.SetOrganizationID(v)
  36199. return nil
  36200. case whatsappchannel.FieldVerifyAccount:
  36201. v, ok := value.(string)
  36202. if !ok {
  36203. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36204. }
  36205. m.SetVerifyAccount(v)
  36206. return nil
  36207. }
  36208. return fmt.Errorf("unknown WhatsappChannel field %s", name)
  36209. }
  36210. // AddedFields returns all numeric fields that were incremented/decremented during
  36211. // this mutation.
  36212. func (m *WhatsappChannelMutation) AddedFields() []string {
  36213. var fields []string
  36214. if m.addstatus != nil {
  36215. fields = append(fields, whatsappchannel.FieldStatus)
  36216. }
  36217. if m.addwaba_id != nil {
  36218. fields = append(fields, whatsappchannel.FieldWabaID)
  36219. }
  36220. if m.addbusiness_id != nil {
  36221. fields = append(fields, whatsappchannel.FieldBusinessID)
  36222. }
  36223. if m.addorganization_id != nil {
  36224. fields = append(fields, whatsappchannel.FieldOrganizationID)
  36225. }
  36226. return fields
  36227. }
  36228. // AddedField returns the numeric value that was incremented/decremented on a field
  36229. // with the given name. The second boolean return value indicates that this field
  36230. // was not set, or was not defined in the schema.
  36231. func (m *WhatsappChannelMutation) AddedField(name string) (ent.Value, bool) {
  36232. switch name {
  36233. case whatsappchannel.FieldStatus:
  36234. return m.AddedStatus()
  36235. case whatsappchannel.FieldWabaID:
  36236. return m.AddedWabaID()
  36237. case whatsappchannel.FieldBusinessID:
  36238. return m.AddedBusinessID()
  36239. case whatsappchannel.FieldOrganizationID:
  36240. return m.AddedOrganizationID()
  36241. }
  36242. return nil, false
  36243. }
  36244. // AddField adds the value to the field with the given name. It returns an error if
  36245. // the field is not defined in the schema, or if the type mismatched the field
  36246. // type.
  36247. func (m *WhatsappChannelMutation) AddField(name string, value ent.Value) error {
  36248. switch name {
  36249. case whatsappchannel.FieldStatus:
  36250. v, ok := value.(int8)
  36251. if !ok {
  36252. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36253. }
  36254. m.AddStatus(v)
  36255. return nil
  36256. case whatsappchannel.FieldWabaID:
  36257. v, ok := value.(int64)
  36258. if !ok {
  36259. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36260. }
  36261. m.AddWabaID(v)
  36262. return nil
  36263. case whatsappchannel.FieldBusinessID:
  36264. v, ok := value.(int64)
  36265. if !ok {
  36266. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36267. }
  36268. m.AddBusinessID(v)
  36269. return nil
  36270. case whatsappchannel.FieldOrganizationID:
  36271. v, ok := value.(int64)
  36272. if !ok {
  36273. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36274. }
  36275. m.AddOrganizationID(v)
  36276. return nil
  36277. }
  36278. return fmt.Errorf("unknown WhatsappChannel numeric field %s", name)
  36279. }
  36280. // ClearedFields returns all nullable fields that were cleared during this
  36281. // mutation.
  36282. func (m *WhatsappChannelMutation) ClearedFields() []string {
  36283. var fields []string
  36284. if m.FieldCleared(whatsappchannel.FieldStatus) {
  36285. fields = append(fields, whatsappchannel.FieldStatus)
  36286. }
  36287. if m.FieldCleared(whatsappchannel.FieldDeletedAt) {
  36288. fields = append(fields, whatsappchannel.FieldDeletedAt)
  36289. }
  36290. if m.FieldCleared(whatsappchannel.FieldAk) {
  36291. fields = append(fields, whatsappchannel.FieldAk)
  36292. }
  36293. if m.FieldCleared(whatsappchannel.FieldWaID) {
  36294. fields = append(fields, whatsappchannel.FieldWaID)
  36295. }
  36296. if m.FieldCleared(whatsappchannel.FieldWaName) {
  36297. fields = append(fields, whatsappchannel.FieldWaName)
  36298. }
  36299. if m.FieldCleared(whatsappchannel.FieldOrganizationID) {
  36300. fields = append(fields, whatsappchannel.FieldOrganizationID)
  36301. }
  36302. return fields
  36303. }
  36304. // FieldCleared returns a boolean indicating if a field with the given name was
  36305. // cleared in this mutation.
  36306. func (m *WhatsappChannelMutation) FieldCleared(name string) bool {
  36307. _, ok := m.clearedFields[name]
  36308. return ok
  36309. }
  36310. // ClearField clears the value of the field with the given name. It returns an
  36311. // error if the field is not defined in the schema.
  36312. func (m *WhatsappChannelMutation) ClearField(name string) error {
  36313. switch name {
  36314. case whatsappchannel.FieldStatus:
  36315. m.ClearStatus()
  36316. return nil
  36317. case whatsappchannel.FieldDeletedAt:
  36318. m.ClearDeletedAt()
  36319. return nil
  36320. case whatsappchannel.FieldAk:
  36321. m.ClearAk()
  36322. return nil
  36323. case whatsappchannel.FieldWaID:
  36324. m.ClearWaID()
  36325. return nil
  36326. case whatsappchannel.FieldWaName:
  36327. m.ClearWaName()
  36328. return nil
  36329. case whatsappchannel.FieldOrganizationID:
  36330. m.ClearOrganizationID()
  36331. return nil
  36332. }
  36333. return fmt.Errorf("unknown WhatsappChannel nullable field %s", name)
  36334. }
  36335. // ResetField resets all changes in the mutation for the field with the given name.
  36336. // It returns an error if the field is not defined in the schema.
  36337. func (m *WhatsappChannelMutation) ResetField(name string) error {
  36338. switch name {
  36339. case whatsappchannel.FieldCreatedAt:
  36340. m.ResetCreatedAt()
  36341. return nil
  36342. case whatsappchannel.FieldUpdatedAt:
  36343. m.ResetUpdatedAt()
  36344. return nil
  36345. case whatsappchannel.FieldStatus:
  36346. m.ResetStatus()
  36347. return nil
  36348. case whatsappchannel.FieldDeletedAt:
  36349. m.ResetDeletedAt()
  36350. return nil
  36351. case whatsappchannel.FieldAk:
  36352. m.ResetAk()
  36353. return nil
  36354. case whatsappchannel.FieldSk:
  36355. m.ResetSk()
  36356. return nil
  36357. case whatsappchannel.FieldWaID:
  36358. m.ResetWaID()
  36359. return nil
  36360. case whatsappchannel.FieldWaName:
  36361. m.ResetWaName()
  36362. return nil
  36363. case whatsappchannel.FieldWabaID:
  36364. m.ResetWabaID()
  36365. return nil
  36366. case whatsappchannel.FieldBusinessID:
  36367. m.ResetBusinessID()
  36368. return nil
  36369. case whatsappchannel.FieldOrganizationID:
  36370. m.ResetOrganizationID()
  36371. return nil
  36372. case whatsappchannel.FieldVerifyAccount:
  36373. m.ResetVerifyAccount()
  36374. return nil
  36375. }
  36376. return fmt.Errorf("unknown WhatsappChannel field %s", name)
  36377. }
  36378. // AddedEdges returns all edge names that were set/added in this mutation.
  36379. func (m *WhatsappChannelMutation) AddedEdges() []string {
  36380. edges := make([]string, 0, 0)
  36381. return edges
  36382. }
  36383. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  36384. // name in this mutation.
  36385. func (m *WhatsappChannelMutation) AddedIDs(name string) []ent.Value {
  36386. return nil
  36387. }
  36388. // RemovedEdges returns all edge names that were removed in this mutation.
  36389. func (m *WhatsappChannelMutation) RemovedEdges() []string {
  36390. edges := make([]string, 0, 0)
  36391. return edges
  36392. }
  36393. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  36394. // the given name in this mutation.
  36395. func (m *WhatsappChannelMutation) RemovedIDs(name string) []ent.Value {
  36396. return nil
  36397. }
  36398. // ClearedEdges returns all edge names that were cleared in this mutation.
  36399. func (m *WhatsappChannelMutation) ClearedEdges() []string {
  36400. edges := make([]string, 0, 0)
  36401. return edges
  36402. }
  36403. // EdgeCleared returns a boolean which indicates if the edge with the given name
  36404. // was cleared in this mutation.
  36405. func (m *WhatsappChannelMutation) EdgeCleared(name string) bool {
  36406. return false
  36407. }
  36408. // ClearEdge clears the value of the edge with the given name. It returns an error
  36409. // if that edge is not defined in the schema.
  36410. func (m *WhatsappChannelMutation) ClearEdge(name string) error {
  36411. return fmt.Errorf("unknown WhatsappChannel unique edge %s", name)
  36412. }
  36413. // ResetEdge resets all changes to the edge with the given name in this mutation.
  36414. // It returns an error if the edge is not defined in the schema.
  36415. func (m *WhatsappChannelMutation) ResetEdge(name string) error {
  36416. return fmt.Errorf("unknown WhatsappChannel edge %s", name)
  36417. }
  36418. // WorkExperienceMutation represents an operation that mutates the WorkExperience nodes in the graph.
  36419. type WorkExperienceMutation struct {
  36420. config
  36421. op Op
  36422. typ string
  36423. id *uint64
  36424. created_at *time.Time
  36425. updated_at *time.Time
  36426. deleted_at *time.Time
  36427. start_date *time.Time
  36428. end_date *time.Time
  36429. company *string
  36430. experience *string
  36431. organization_id *uint64
  36432. addorganization_id *int64
  36433. clearedFields map[string]struct{}
  36434. employee *uint64
  36435. clearedemployee bool
  36436. done bool
  36437. oldValue func(context.Context) (*WorkExperience, error)
  36438. predicates []predicate.WorkExperience
  36439. }
  36440. var _ ent.Mutation = (*WorkExperienceMutation)(nil)
  36441. // workexperienceOption allows management of the mutation configuration using functional options.
  36442. type workexperienceOption func(*WorkExperienceMutation)
  36443. // newWorkExperienceMutation creates new mutation for the WorkExperience entity.
  36444. func newWorkExperienceMutation(c config, op Op, opts ...workexperienceOption) *WorkExperienceMutation {
  36445. m := &WorkExperienceMutation{
  36446. config: c,
  36447. op: op,
  36448. typ: TypeWorkExperience,
  36449. clearedFields: make(map[string]struct{}),
  36450. }
  36451. for _, opt := range opts {
  36452. opt(m)
  36453. }
  36454. return m
  36455. }
  36456. // withWorkExperienceID sets the ID field of the mutation.
  36457. func withWorkExperienceID(id uint64) workexperienceOption {
  36458. return func(m *WorkExperienceMutation) {
  36459. var (
  36460. err error
  36461. once sync.Once
  36462. value *WorkExperience
  36463. )
  36464. m.oldValue = func(ctx context.Context) (*WorkExperience, error) {
  36465. once.Do(func() {
  36466. if m.done {
  36467. err = errors.New("querying old values post mutation is not allowed")
  36468. } else {
  36469. value, err = m.Client().WorkExperience.Get(ctx, id)
  36470. }
  36471. })
  36472. return value, err
  36473. }
  36474. m.id = &id
  36475. }
  36476. }
  36477. // withWorkExperience sets the old WorkExperience of the mutation.
  36478. func withWorkExperience(node *WorkExperience) workexperienceOption {
  36479. return func(m *WorkExperienceMutation) {
  36480. m.oldValue = func(context.Context) (*WorkExperience, error) {
  36481. return node, nil
  36482. }
  36483. m.id = &node.ID
  36484. }
  36485. }
  36486. // Client returns a new `ent.Client` from the mutation. If the mutation was
  36487. // executed in a transaction (ent.Tx), a transactional client is returned.
  36488. func (m WorkExperienceMutation) Client() *Client {
  36489. client := &Client{config: m.config}
  36490. client.init()
  36491. return client
  36492. }
  36493. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  36494. // it returns an error otherwise.
  36495. func (m WorkExperienceMutation) Tx() (*Tx, error) {
  36496. if _, ok := m.driver.(*txDriver); !ok {
  36497. return nil, errors.New("ent: mutation is not running in a transaction")
  36498. }
  36499. tx := &Tx{config: m.config}
  36500. tx.init()
  36501. return tx, nil
  36502. }
  36503. // SetID sets the value of the id field. Note that this
  36504. // operation is only accepted on creation of WorkExperience entities.
  36505. func (m *WorkExperienceMutation) SetID(id uint64) {
  36506. m.id = &id
  36507. }
  36508. // ID returns the ID value in the mutation. Note that the ID is only available
  36509. // if it was provided to the builder or after it was returned from the database.
  36510. func (m *WorkExperienceMutation) ID() (id uint64, exists bool) {
  36511. if m.id == nil {
  36512. return
  36513. }
  36514. return *m.id, true
  36515. }
  36516. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  36517. // That means, if the mutation is applied within a transaction with an isolation level such
  36518. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  36519. // or updated by the mutation.
  36520. func (m *WorkExperienceMutation) IDs(ctx context.Context) ([]uint64, error) {
  36521. switch {
  36522. case m.op.Is(OpUpdateOne | OpDeleteOne):
  36523. id, exists := m.ID()
  36524. if exists {
  36525. return []uint64{id}, nil
  36526. }
  36527. fallthrough
  36528. case m.op.Is(OpUpdate | OpDelete):
  36529. return m.Client().WorkExperience.Query().Where(m.predicates...).IDs(ctx)
  36530. default:
  36531. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  36532. }
  36533. }
  36534. // SetCreatedAt sets the "created_at" field.
  36535. func (m *WorkExperienceMutation) SetCreatedAt(t time.Time) {
  36536. m.created_at = &t
  36537. }
  36538. // CreatedAt returns the value of the "created_at" field in the mutation.
  36539. func (m *WorkExperienceMutation) CreatedAt() (r time.Time, exists bool) {
  36540. v := m.created_at
  36541. if v == nil {
  36542. return
  36543. }
  36544. return *v, true
  36545. }
  36546. // OldCreatedAt returns the old "created_at" field's value of the WorkExperience entity.
  36547. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  36548. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36549. func (m *WorkExperienceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  36550. if !m.op.Is(OpUpdateOne) {
  36551. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  36552. }
  36553. if m.id == nil || m.oldValue == nil {
  36554. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  36555. }
  36556. oldValue, err := m.oldValue(ctx)
  36557. if err != nil {
  36558. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  36559. }
  36560. return oldValue.CreatedAt, nil
  36561. }
  36562. // ResetCreatedAt resets all changes to the "created_at" field.
  36563. func (m *WorkExperienceMutation) ResetCreatedAt() {
  36564. m.created_at = nil
  36565. }
  36566. // SetUpdatedAt sets the "updated_at" field.
  36567. func (m *WorkExperienceMutation) SetUpdatedAt(t time.Time) {
  36568. m.updated_at = &t
  36569. }
  36570. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  36571. func (m *WorkExperienceMutation) UpdatedAt() (r time.Time, exists bool) {
  36572. v := m.updated_at
  36573. if v == nil {
  36574. return
  36575. }
  36576. return *v, true
  36577. }
  36578. // OldUpdatedAt returns the old "updated_at" field's value of the WorkExperience entity.
  36579. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  36580. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36581. func (m *WorkExperienceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  36582. if !m.op.Is(OpUpdateOne) {
  36583. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  36584. }
  36585. if m.id == nil || m.oldValue == nil {
  36586. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  36587. }
  36588. oldValue, err := m.oldValue(ctx)
  36589. if err != nil {
  36590. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  36591. }
  36592. return oldValue.UpdatedAt, nil
  36593. }
  36594. // ResetUpdatedAt resets all changes to the "updated_at" field.
  36595. func (m *WorkExperienceMutation) ResetUpdatedAt() {
  36596. m.updated_at = nil
  36597. }
  36598. // SetDeletedAt sets the "deleted_at" field.
  36599. func (m *WorkExperienceMutation) SetDeletedAt(t time.Time) {
  36600. m.deleted_at = &t
  36601. }
  36602. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  36603. func (m *WorkExperienceMutation) DeletedAt() (r time.Time, exists bool) {
  36604. v := m.deleted_at
  36605. if v == nil {
  36606. return
  36607. }
  36608. return *v, true
  36609. }
  36610. // OldDeletedAt returns the old "deleted_at" field's value of the WorkExperience entity.
  36611. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  36612. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36613. func (m *WorkExperienceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  36614. if !m.op.Is(OpUpdateOne) {
  36615. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  36616. }
  36617. if m.id == nil || m.oldValue == nil {
  36618. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  36619. }
  36620. oldValue, err := m.oldValue(ctx)
  36621. if err != nil {
  36622. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  36623. }
  36624. return oldValue.DeletedAt, nil
  36625. }
  36626. // ClearDeletedAt clears the value of the "deleted_at" field.
  36627. func (m *WorkExperienceMutation) ClearDeletedAt() {
  36628. m.deleted_at = nil
  36629. m.clearedFields[workexperience.FieldDeletedAt] = struct{}{}
  36630. }
  36631. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  36632. func (m *WorkExperienceMutation) DeletedAtCleared() bool {
  36633. _, ok := m.clearedFields[workexperience.FieldDeletedAt]
  36634. return ok
  36635. }
  36636. // ResetDeletedAt resets all changes to the "deleted_at" field.
  36637. func (m *WorkExperienceMutation) ResetDeletedAt() {
  36638. m.deleted_at = nil
  36639. delete(m.clearedFields, workexperience.FieldDeletedAt)
  36640. }
  36641. // SetEmployeeID sets the "employee_id" field.
  36642. func (m *WorkExperienceMutation) SetEmployeeID(u uint64) {
  36643. m.employee = &u
  36644. }
  36645. // EmployeeID returns the value of the "employee_id" field in the mutation.
  36646. func (m *WorkExperienceMutation) EmployeeID() (r uint64, exists bool) {
  36647. v := m.employee
  36648. if v == nil {
  36649. return
  36650. }
  36651. return *v, true
  36652. }
  36653. // OldEmployeeID returns the old "employee_id" field's value of the WorkExperience entity.
  36654. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  36655. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36656. func (m *WorkExperienceMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  36657. if !m.op.Is(OpUpdateOne) {
  36658. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  36659. }
  36660. if m.id == nil || m.oldValue == nil {
  36661. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  36662. }
  36663. oldValue, err := m.oldValue(ctx)
  36664. if err != nil {
  36665. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  36666. }
  36667. return oldValue.EmployeeID, nil
  36668. }
  36669. // ResetEmployeeID resets all changes to the "employee_id" field.
  36670. func (m *WorkExperienceMutation) ResetEmployeeID() {
  36671. m.employee = nil
  36672. }
  36673. // SetStartDate sets the "start_date" field.
  36674. func (m *WorkExperienceMutation) SetStartDate(t time.Time) {
  36675. m.start_date = &t
  36676. }
  36677. // StartDate returns the value of the "start_date" field in the mutation.
  36678. func (m *WorkExperienceMutation) StartDate() (r time.Time, exists bool) {
  36679. v := m.start_date
  36680. if v == nil {
  36681. return
  36682. }
  36683. return *v, true
  36684. }
  36685. // OldStartDate returns the old "start_date" field's value of the WorkExperience entity.
  36686. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  36687. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36688. func (m *WorkExperienceMutation) OldStartDate(ctx context.Context) (v time.Time, err error) {
  36689. if !m.op.Is(OpUpdateOne) {
  36690. return v, errors.New("OldStartDate is only allowed on UpdateOne operations")
  36691. }
  36692. if m.id == nil || m.oldValue == nil {
  36693. return v, errors.New("OldStartDate requires an ID field in the mutation")
  36694. }
  36695. oldValue, err := m.oldValue(ctx)
  36696. if err != nil {
  36697. return v, fmt.Errorf("querying old value for OldStartDate: %w", err)
  36698. }
  36699. return oldValue.StartDate, nil
  36700. }
  36701. // ResetStartDate resets all changes to the "start_date" field.
  36702. func (m *WorkExperienceMutation) ResetStartDate() {
  36703. m.start_date = nil
  36704. }
  36705. // SetEndDate sets the "end_date" field.
  36706. func (m *WorkExperienceMutation) SetEndDate(t time.Time) {
  36707. m.end_date = &t
  36708. }
  36709. // EndDate returns the value of the "end_date" field in the mutation.
  36710. func (m *WorkExperienceMutation) EndDate() (r time.Time, exists bool) {
  36711. v := m.end_date
  36712. if v == nil {
  36713. return
  36714. }
  36715. return *v, true
  36716. }
  36717. // OldEndDate returns the old "end_date" field's value of the WorkExperience entity.
  36718. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  36719. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36720. func (m *WorkExperienceMutation) OldEndDate(ctx context.Context) (v time.Time, err error) {
  36721. if !m.op.Is(OpUpdateOne) {
  36722. return v, errors.New("OldEndDate is only allowed on UpdateOne operations")
  36723. }
  36724. if m.id == nil || m.oldValue == nil {
  36725. return v, errors.New("OldEndDate requires an ID field in the mutation")
  36726. }
  36727. oldValue, err := m.oldValue(ctx)
  36728. if err != nil {
  36729. return v, fmt.Errorf("querying old value for OldEndDate: %w", err)
  36730. }
  36731. return oldValue.EndDate, nil
  36732. }
  36733. // ResetEndDate resets all changes to the "end_date" field.
  36734. func (m *WorkExperienceMutation) ResetEndDate() {
  36735. m.end_date = nil
  36736. }
  36737. // SetCompany sets the "company" field.
  36738. func (m *WorkExperienceMutation) SetCompany(s string) {
  36739. m.company = &s
  36740. }
  36741. // Company returns the value of the "company" field in the mutation.
  36742. func (m *WorkExperienceMutation) Company() (r string, exists bool) {
  36743. v := m.company
  36744. if v == nil {
  36745. return
  36746. }
  36747. return *v, true
  36748. }
  36749. // OldCompany returns the old "company" field's value of the WorkExperience entity.
  36750. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  36751. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36752. func (m *WorkExperienceMutation) OldCompany(ctx context.Context) (v string, err error) {
  36753. if !m.op.Is(OpUpdateOne) {
  36754. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  36755. }
  36756. if m.id == nil || m.oldValue == nil {
  36757. return v, errors.New("OldCompany requires an ID field in the mutation")
  36758. }
  36759. oldValue, err := m.oldValue(ctx)
  36760. if err != nil {
  36761. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  36762. }
  36763. return oldValue.Company, nil
  36764. }
  36765. // ResetCompany resets all changes to the "company" field.
  36766. func (m *WorkExperienceMutation) ResetCompany() {
  36767. m.company = nil
  36768. }
  36769. // SetExperience sets the "experience" field.
  36770. func (m *WorkExperienceMutation) SetExperience(s string) {
  36771. m.experience = &s
  36772. }
  36773. // Experience returns the value of the "experience" field in the mutation.
  36774. func (m *WorkExperienceMutation) Experience() (r string, exists bool) {
  36775. v := m.experience
  36776. if v == nil {
  36777. return
  36778. }
  36779. return *v, true
  36780. }
  36781. // OldExperience returns the old "experience" field's value of the WorkExperience entity.
  36782. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  36783. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36784. func (m *WorkExperienceMutation) OldExperience(ctx context.Context) (v string, err error) {
  36785. if !m.op.Is(OpUpdateOne) {
  36786. return v, errors.New("OldExperience is only allowed on UpdateOne operations")
  36787. }
  36788. if m.id == nil || m.oldValue == nil {
  36789. return v, errors.New("OldExperience requires an ID field in the mutation")
  36790. }
  36791. oldValue, err := m.oldValue(ctx)
  36792. if err != nil {
  36793. return v, fmt.Errorf("querying old value for OldExperience: %w", err)
  36794. }
  36795. return oldValue.Experience, nil
  36796. }
  36797. // ResetExperience resets all changes to the "experience" field.
  36798. func (m *WorkExperienceMutation) ResetExperience() {
  36799. m.experience = nil
  36800. }
  36801. // SetOrganizationID sets the "organization_id" field.
  36802. func (m *WorkExperienceMutation) SetOrganizationID(u uint64) {
  36803. m.organization_id = &u
  36804. m.addorganization_id = nil
  36805. }
  36806. // OrganizationID returns the value of the "organization_id" field in the mutation.
  36807. func (m *WorkExperienceMutation) OrganizationID() (r uint64, exists bool) {
  36808. v := m.organization_id
  36809. if v == nil {
  36810. return
  36811. }
  36812. return *v, true
  36813. }
  36814. // OldOrganizationID returns the old "organization_id" field's value of the WorkExperience entity.
  36815. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  36816. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36817. func (m *WorkExperienceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  36818. if !m.op.Is(OpUpdateOne) {
  36819. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  36820. }
  36821. if m.id == nil || m.oldValue == nil {
  36822. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  36823. }
  36824. oldValue, err := m.oldValue(ctx)
  36825. if err != nil {
  36826. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  36827. }
  36828. return oldValue.OrganizationID, nil
  36829. }
  36830. // AddOrganizationID adds u to the "organization_id" field.
  36831. func (m *WorkExperienceMutation) AddOrganizationID(u int64) {
  36832. if m.addorganization_id != nil {
  36833. *m.addorganization_id += u
  36834. } else {
  36835. m.addorganization_id = &u
  36836. }
  36837. }
  36838. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  36839. func (m *WorkExperienceMutation) AddedOrganizationID() (r int64, exists bool) {
  36840. v := m.addorganization_id
  36841. if v == nil {
  36842. return
  36843. }
  36844. return *v, true
  36845. }
  36846. // ResetOrganizationID resets all changes to the "organization_id" field.
  36847. func (m *WorkExperienceMutation) ResetOrganizationID() {
  36848. m.organization_id = nil
  36849. m.addorganization_id = nil
  36850. }
  36851. // ClearEmployee clears the "employee" edge to the Employee entity.
  36852. func (m *WorkExperienceMutation) ClearEmployee() {
  36853. m.clearedemployee = true
  36854. m.clearedFields[workexperience.FieldEmployeeID] = struct{}{}
  36855. }
  36856. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  36857. func (m *WorkExperienceMutation) EmployeeCleared() bool {
  36858. return m.clearedemployee
  36859. }
  36860. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  36861. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  36862. // EmployeeID instead. It exists only for internal usage by the builders.
  36863. func (m *WorkExperienceMutation) EmployeeIDs() (ids []uint64) {
  36864. if id := m.employee; id != nil {
  36865. ids = append(ids, *id)
  36866. }
  36867. return
  36868. }
  36869. // ResetEmployee resets all changes to the "employee" edge.
  36870. func (m *WorkExperienceMutation) ResetEmployee() {
  36871. m.employee = nil
  36872. m.clearedemployee = false
  36873. }
  36874. // Where appends a list predicates to the WorkExperienceMutation builder.
  36875. func (m *WorkExperienceMutation) Where(ps ...predicate.WorkExperience) {
  36876. m.predicates = append(m.predicates, ps...)
  36877. }
  36878. // WhereP appends storage-level predicates to the WorkExperienceMutation builder. Using this method,
  36879. // users can use type-assertion to append predicates that do not depend on any generated package.
  36880. func (m *WorkExperienceMutation) WhereP(ps ...func(*sql.Selector)) {
  36881. p := make([]predicate.WorkExperience, len(ps))
  36882. for i := range ps {
  36883. p[i] = ps[i]
  36884. }
  36885. m.Where(p...)
  36886. }
  36887. // Op returns the operation name.
  36888. func (m *WorkExperienceMutation) Op() Op {
  36889. return m.op
  36890. }
  36891. // SetOp allows setting the mutation operation.
  36892. func (m *WorkExperienceMutation) SetOp(op Op) {
  36893. m.op = op
  36894. }
  36895. // Type returns the node type of this mutation (WorkExperience).
  36896. func (m *WorkExperienceMutation) Type() string {
  36897. return m.typ
  36898. }
  36899. // Fields returns all fields that were changed during this mutation. Note that in
  36900. // order to get all numeric fields that were incremented/decremented, call
  36901. // AddedFields().
  36902. func (m *WorkExperienceMutation) Fields() []string {
  36903. fields := make([]string, 0, 9)
  36904. if m.created_at != nil {
  36905. fields = append(fields, workexperience.FieldCreatedAt)
  36906. }
  36907. if m.updated_at != nil {
  36908. fields = append(fields, workexperience.FieldUpdatedAt)
  36909. }
  36910. if m.deleted_at != nil {
  36911. fields = append(fields, workexperience.FieldDeletedAt)
  36912. }
  36913. if m.employee != nil {
  36914. fields = append(fields, workexperience.FieldEmployeeID)
  36915. }
  36916. if m.start_date != nil {
  36917. fields = append(fields, workexperience.FieldStartDate)
  36918. }
  36919. if m.end_date != nil {
  36920. fields = append(fields, workexperience.FieldEndDate)
  36921. }
  36922. if m.company != nil {
  36923. fields = append(fields, workexperience.FieldCompany)
  36924. }
  36925. if m.experience != nil {
  36926. fields = append(fields, workexperience.FieldExperience)
  36927. }
  36928. if m.organization_id != nil {
  36929. fields = append(fields, workexperience.FieldOrganizationID)
  36930. }
  36931. return fields
  36932. }
  36933. // Field returns the value of a field with the given name. The second boolean
  36934. // return value indicates that this field was not set, or was not defined in the
  36935. // schema.
  36936. func (m *WorkExperienceMutation) Field(name string) (ent.Value, bool) {
  36937. switch name {
  36938. case workexperience.FieldCreatedAt:
  36939. return m.CreatedAt()
  36940. case workexperience.FieldUpdatedAt:
  36941. return m.UpdatedAt()
  36942. case workexperience.FieldDeletedAt:
  36943. return m.DeletedAt()
  36944. case workexperience.FieldEmployeeID:
  36945. return m.EmployeeID()
  36946. case workexperience.FieldStartDate:
  36947. return m.StartDate()
  36948. case workexperience.FieldEndDate:
  36949. return m.EndDate()
  36950. case workexperience.FieldCompany:
  36951. return m.Company()
  36952. case workexperience.FieldExperience:
  36953. return m.Experience()
  36954. case workexperience.FieldOrganizationID:
  36955. return m.OrganizationID()
  36956. }
  36957. return nil, false
  36958. }
  36959. // OldField returns the old value of the field from the database. An error is
  36960. // returned if the mutation operation is not UpdateOne, or the query to the
  36961. // database failed.
  36962. func (m *WorkExperienceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  36963. switch name {
  36964. case workexperience.FieldCreatedAt:
  36965. return m.OldCreatedAt(ctx)
  36966. case workexperience.FieldUpdatedAt:
  36967. return m.OldUpdatedAt(ctx)
  36968. case workexperience.FieldDeletedAt:
  36969. return m.OldDeletedAt(ctx)
  36970. case workexperience.FieldEmployeeID:
  36971. return m.OldEmployeeID(ctx)
  36972. case workexperience.FieldStartDate:
  36973. return m.OldStartDate(ctx)
  36974. case workexperience.FieldEndDate:
  36975. return m.OldEndDate(ctx)
  36976. case workexperience.FieldCompany:
  36977. return m.OldCompany(ctx)
  36978. case workexperience.FieldExperience:
  36979. return m.OldExperience(ctx)
  36980. case workexperience.FieldOrganizationID:
  36981. return m.OldOrganizationID(ctx)
  36982. }
  36983. return nil, fmt.Errorf("unknown WorkExperience field %s", name)
  36984. }
  36985. // SetField sets the value of a field with the given name. It returns an error if
  36986. // the field is not defined in the schema, or if the type mismatched the field
  36987. // type.
  36988. func (m *WorkExperienceMutation) SetField(name string, value ent.Value) error {
  36989. switch name {
  36990. case workexperience.FieldCreatedAt:
  36991. v, ok := value.(time.Time)
  36992. if !ok {
  36993. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36994. }
  36995. m.SetCreatedAt(v)
  36996. return nil
  36997. case workexperience.FieldUpdatedAt:
  36998. v, ok := value.(time.Time)
  36999. if !ok {
  37000. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37001. }
  37002. m.SetUpdatedAt(v)
  37003. return nil
  37004. case workexperience.FieldDeletedAt:
  37005. v, ok := value.(time.Time)
  37006. if !ok {
  37007. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37008. }
  37009. m.SetDeletedAt(v)
  37010. return nil
  37011. case workexperience.FieldEmployeeID:
  37012. v, ok := value.(uint64)
  37013. if !ok {
  37014. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37015. }
  37016. m.SetEmployeeID(v)
  37017. return nil
  37018. case workexperience.FieldStartDate:
  37019. v, ok := value.(time.Time)
  37020. if !ok {
  37021. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37022. }
  37023. m.SetStartDate(v)
  37024. return nil
  37025. case workexperience.FieldEndDate:
  37026. v, ok := value.(time.Time)
  37027. if !ok {
  37028. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37029. }
  37030. m.SetEndDate(v)
  37031. return nil
  37032. case workexperience.FieldCompany:
  37033. v, ok := value.(string)
  37034. if !ok {
  37035. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37036. }
  37037. m.SetCompany(v)
  37038. return nil
  37039. case workexperience.FieldExperience:
  37040. v, ok := value.(string)
  37041. if !ok {
  37042. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37043. }
  37044. m.SetExperience(v)
  37045. return nil
  37046. case workexperience.FieldOrganizationID:
  37047. v, ok := value.(uint64)
  37048. if !ok {
  37049. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37050. }
  37051. m.SetOrganizationID(v)
  37052. return nil
  37053. }
  37054. return fmt.Errorf("unknown WorkExperience field %s", name)
  37055. }
  37056. // AddedFields returns all numeric fields that were incremented/decremented during
  37057. // this mutation.
  37058. func (m *WorkExperienceMutation) AddedFields() []string {
  37059. var fields []string
  37060. if m.addorganization_id != nil {
  37061. fields = append(fields, workexperience.FieldOrganizationID)
  37062. }
  37063. return fields
  37064. }
  37065. // AddedField returns the numeric value that was incremented/decremented on a field
  37066. // with the given name. The second boolean return value indicates that this field
  37067. // was not set, or was not defined in the schema.
  37068. func (m *WorkExperienceMutation) AddedField(name string) (ent.Value, bool) {
  37069. switch name {
  37070. case workexperience.FieldOrganizationID:
  37071. return m.AddedOrganizationID()
  37072. }
  37073. return nil, false
  37074. }
  37075. // AddField adds the value to the field with the given name. It returns an error if
  37076. // the field is not defined in the schema, or if the type mismatched the field
  37077. // type.
  37078. func (m *WorkExperienceMutation) AddField(name string, value ent.Value) error {
  37079. switch name {
  37080. case workexperience.FieldOrganizationID:
  37081. v, ok := value.(int64)
  37082. if !ok {
  37083. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37084. }
  37085. m.AddOrganizationID(v)
  37086. return nil
  37087. }
  37088. return fmt.Errorf("unknown WorkExperience numeric field %s", name)
  37089. }
  37090. // ClearedFields returns all nullable fields that were cleared during this
  37091. // mutation.
  37092. func (m *WorkExperienceMutation) ClearedFields() []string {
  37093. var fields []string
  37094. if m.FieldCleared(workexperience.FieldDeletedAt) {
  37095. fields = append(fields, workexperience.FieldDeletedAt)
  37096. }
  37097. return fields
  37098. }
  37099. // FieldCleared returns a boolean indicating if a field with the given name was
  37100. // cleared in this mutation.
  37101. func (m *WorkExperienceMutation) FieldCleared(name string) bool {
  37102. _, ok := m.clearedFields[name]
  37103. return ok
  37104. }
  37105. // ClearField clears the value of the field with the given name. It returns an
  37106. // error if the field is not defined in the schema.
  37107. func (m *WorkExperienceMutation) ClearField(name string) error {
  37108. switch name {
  37109. case workexperience.FieldDeletedAt:
  37110. m.ClearDeletedAt()
  37111. return nil
  37112. }
  37113. return fmt.Errorf("unknown WorkExperience nullable field %s", name)
  37114. }
  37115. // ResetField resets all changes in the mutation for the field with the given name.
  37116. // It returns an error if the field is not defined in the schema.
  37117. func (m *WorkExperienceMutation) ResetField(name string) error {
  37118. switch name {
  37119. case workexperience.FieldCreatedAt:
  37120. m.ResetCreatedAt()
  37121. return nil
  37122. case workexperience.FieldUpdatedAt:
  37123. m.ResetUpdatedAt()
  37124. return nil
  37125. case workexperience.FieldDeletedAt:
  37126. m.ResetDeletedAt()
  37127. return nil
  37128. case workexperience.FieldEmployeeID:
  37129. m.ResetEmployeeID()
  37130. return nil
  37131. case workexperience.FieldStartDate:
  37132. m.ResetStartDate()
  37133. return nil
  37134. case workexperience.FieldEndDate:
  37135. m.ResetEndDate()
  37136. return nil
  37137. case workexperience.FieldCompany:
  37138. m.ResetCompany()
  37139. return nil
  37140. case workexperience.FieldExperience:
  37141. m.ResetExperience()
  37142. return nil
  37143. case workexperience.FieldOrganizationID:
  37144. m.ResetOrganizationID()
  37145. return nil
  37146. }
  37147. return fmt.Errorf("unknown WorkExperience field %s", name)
  37148. }
  37149. // AddedEdges returns all edge names that were set/added in this mutation.
  37150. func (m *WorkExperienceMutation) AddedEdges() []string {
  37151. edges := make([]string, 0, 1)
  37152. if m.employee != nil {
  37153. edges = append(edges, workexperience.EdgeEmployee)
  37154. }
  37155. return edges
  37156. }
  37157. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  37158. // name in this mutation.
  37159. func (m *WorkExperienceMutation) AddedIDs(name string) []ent.Value {
  37160. switch name {
  37161. case workexperience.EdgeEmployee:
  37162. if id := m.employee; id != nil {
  37163. return []ent.Value{*id}
  37164. }
  37165. }
  37166. return nil
  37167. }
  37168. // RemovedEdges returns all edge names that were removed in this mutation.
  37169. func (m *WorkExperienceMutation) RemovedEdges() []string {
  37170. edges := make([]string, 0, 1)
  37171. return edges
  37172. }
  37173. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  37174. // the given name in this mutation.
  37175. func (m *WorkExperienceMutation) RemovedIDs(name string) []ent.Value {
  37176. return nil
  37177. }
  37178. // ClearedEdges returns all edge names that were cleared in this mutation.
  37179. func (m *WorkExperienceMutation) ClearedEdges() []string {
  37180. edges := make([]string, 0, 1)
  37181. if m.clearedemployee {
  37182. edges = append(edges, workexperience.EdgeEmployee)
  37183. }
  37184. return edges
  37185. }
  37186. // EdgeCleared returns a boolean which indicates if the edge with the given name
  37187. // was cleared in this mutation.
  37188. func (m *WorkExperienceMutation) EdgeCleared(name string) bool {
  37189. switch name {
  37190. case workexperience.EdgeEmployee:
  37191. return m.clearedemployee
  37192. }
  37193. return false
  37194. }
  37195. // ClearEdge clears the value of the edge with the given name. It returns an error
  37196. // if that edge is not defined in the schema.
  37197. func (m *WorkExperienceMutation) ClearEdge(name string) error {
  37198. switch name {
  37199. case workexperience.EdgeEmployee:
  37200. m.ClearEmployee()
  37201. return nil
  37202. }
  37203. return fmt.Errorf("unknown WorkExperience unique edge %s", name)
  37204. }
  37205. // ResetEdge resets all changes to the edge with the given name in this mutation.
  37206. // It returns an error if the edge is not defined in the schema.
  37207. func (m *WorkExperienceMutation) ResetEdge(name string) error {
  37208. switch name {
  37209. case workexperience.EdgeEmployee:
  37210. m.ResetEmployee()
  37211. return nil
  37212. }
  37213. return fmt.Errorf("unknown WorkExperience edge %s", name)
  37214. }
  37215. // WpChatroomMutation represents an operation that mutates the WpChatroom nodes in the graph.
  37216. type WpChatroomMutation struct {
  37217. config
  37218. op Op
  37219. typ string
  37220. id *uint64
  37221. created_at *time.Time
  37222. updated_at *time.Time
  37223. status *uint8
  37224. addstatus *int8
  37225. wx_wxid *string
  37226. chatroom_id *string
  37227. nickname *string
  37228. owner *string
  37229. avatar *string
  37230. member_list *[]string
  37231. appendmember_list []string
  37232. clearedFields map[string]struct{}
  37233. done bool
  37234. oldValue func(context.Context) (*WpChatroom, error)
  37235. predicates []predicate.WpChatroom
  37236. }
  37237. var _ ent.Mutation = (*WpChatroomMutation)(nil)
  37238. // wpchatroomOption allows management of the mutation configuration using functional options.
  37239. type wpchatroomOption func(*WpChatroomMutation)
  37240. // newWpChatroomMutation creates new mutation for the WpChatroom entity.
  37241. func newWpChatroomMutation(c config, op Op, opts ...wpchatroomOption) *WpChatroomMutation {
  37242. m := &WpChatroomMutation{
  37243. config: c,
  37244. op: op,
  37245. typ: TypeWpChatroom,
  37246. clearedFields: make(map[string]struct{}),
  37247. }
  37248. for _, opt := range opts {
  37249. opt(m)
  37250. }
  37251. return m
  37252. }
  37253. // withWpChatroomID sets the ID field of the mutation.
  37254. func withWpChatroomID(id uint64) wpchatroomOption {
  37255. return func(m *WpChatroomMutation) {
  37256. var (
  37257. err error
  37258. once sync.Once
  37259. value *WpChatroom
  37260. )
  37261. m.oldValue = func(ctx context.Context) (*WpChatroom, error) {
  37262. once.Do(func() {
  37263. if m.done {
  37264. err = errors.New("querying old values post mutation is not allowed")
  37265. } else {
  37266. value, err = m.Client().WpChatroom.Get(ctx, id)
  37267. }
  37268. })
  37269. return value, err
  37270. }
  37271. m.id = &id
  37272. }
  37273. }
  37274. // withWpChatroom sets the old WpChatroom of the mutation.
  37275. func withWpChatroom(node *WpChatroom) wpchatroomOption {
  37276. return func(m *WpChatroomMutation) {
  37277. m.oldValue = func(context.Context) (*WpChatroom, error) {
  37278. return node, nil
  37279. }
  37280. m.id = &node.ID
  37281. }
  37282. }
  37283. // Client returns a new `ent.Client` from the mutation. If the mutation was
  37284. // executed in a transaction (ent.Tx), a transactional client is returned.
  37285. func (m WpChatroomMutation) Client() *Client {
  37286. client := &Client{config: m.config}
  37287. client.init()
  37288. return client
  37289. }
  37290. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  37291. // it returns an error otherwise.
  37292. func (m WpChatroomMutation) Tx() (*Tx, error) {
  37293. if _, ok := m.driver.(*txDriver); !ok {
  37294. return nil, errors.New("ent: mutation is not running in a transaction")
  37295. }
  37296. tx := &Tx{config: m.config}
  37297. tx.init()
  37298. return tx, nil
  37299. }
  37300. // SetID sets the value of the id field. Note that this
  37301. // operation is only accepted on creation of WpChatroom entities.
  37302. func (m *WpChatroomMutation) SetID(id uint64) {
  37303. m.id = &id
  37304. }
  37305. // ID returns the ID value in the mutation. Note that the ID is only available
  37306. // if it was provided to the builder or after it was returned from the database.
  37307. func (m *WpChatroomMutation) ID() (id uint64, exists bool) {
  37308. if m.id == nil {
  37309. return
  37310. }
  37311. return *m.id, true
  37312. }
  37313. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  37314. // That means, if the mutation is applied within a transaction with an isolation level such
  37315. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  37316. // or updated by the mutation.
  37317. func (m *WpChatroomMutation) IDs(ctx context.Context) ([]uint64, error) {
  37318. switch {
  37319. case m.op.Is(OpUpdateOne | OpDeleteOne):
  37320. id, exists := m.ID()
  37321. if exists {
  37322. return []uint64{id}, nil
  37323. }
  37324. fallthrough
  37325. case m.op.Is(OpUpdate | OpDelete):
  37326. return m.Client().WpChatroom.Query().Where(m.predicates...).IDs(ctx)
  37327. default:
  37328. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  37329. }
  37330. }
  37331. // SetCreatedAt sets the "created_at" field.
  37332. func (m *WpChatroomMutation) SetCreatedAt(t time.Time) {
  37333. m.created_at = &t
  37334. }
  37335. // CreatedAt returns the value of the "created_at" field in the mutation.
  37336. func (m *WpChatroomMutation) CreatedAt() (r time.Time, exists bool) {
  37337. v := m.created_at
  37338. if v == nil {
  37339. return
  37340. }
  37341. return *v, true
  37342. }
  37343. // OldCreatedAt returns the old "created_at" field's value of the WpChatroom entity.
  37344. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  37345. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37346. func (m *WpChatroomMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  37347. if !m.op.Is(OpUpdateOne) {
  37348. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  37349. }
  37350. if m.id == nil || m.oldValue == nil {
  37351. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  37352. }
  37353. oldValue, err := m.oldValue(ctx)
  37354. if err != nil {
  37355. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  37356. }
  37357. return oldValue.CreatedAt, nil
  37358. }
  37359. // ResetCreatedAt resets all changes to the "created_at" field.
  37360. func (m *WpChatroomMutation) ResetCreatedAt() {
  37361. m.created_at = nil
  37362. }
  37363. // SetUpdatedAt sets the "updated_at" field.
  37364. func (m *WpChatroomMutation) SetUpdatedAt(t time.Time) {
  37365. m.updated_at = &t
  37366. }
  37367. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  37368. func (m *WpChatroomMutation) UpdatedAt() (r time.Time, exists bool) {
  37369. v := m.updated_at
  37370. if v == nil {
  37371. return
  37372. }
  37373. return *v, true
  37374. }
  37375. // OldUpdatedAt returns the old "updated_at" field's value of the WpChatroom entity.
  37376. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  37377. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37378. func (m *WpChatroomMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  37379. if !m.op.Is(OpUpdateOne) {
  37380. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  37381. }
  37382. if m.id == nil || m.oldValue == nil {
  37383. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  37384. }
  37385. oldValue, err := m.oldValue(ctx)
  37386. if err != nil {
  37387. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  37388. }
  37389. return oldValue.UpdatedAt, nil
  37390. }
  37391. // ResetUpdatedAt resets all changes to the "updated_at" field.
  37392. func (m *WpChatroomMutation) ResetUpdatedAt() {
  37393. m.updated_at = nil
  37394. }
  37395. // SetStatus sets the "status" field.
  37396. func (m *WpChatroomMutation) SetStatus(u uint8) {
  37397. m.status = &u
  37398. m.addstatus = nil
  37399. }
  37400. // Status returns the value of the "status" field in the mutation.
  37401. func (m *WpChatroomMutation) Status() (r uint8, exists bool) {
  37402. v := m.status
  37403. if v == nil {
  37404. return
  37405. }
  37406. return *v, true
  37407. }
  37408. // OldStatus returns the old "status" field's value of the WpChatroom entity.
  37409. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  37410. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37411. func (m *WpChatroomMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  37412. if !m.op.Is(OpUpdateOne) {
  37413. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  37414. }
  37415. if m.id == nil || m.oldValue == nil {
  37416. return v, errors.New("OldStatus requires an ID field in the mutation")
  37417. }
  37418. oldValue, err := m.oldValue(ctx)
  37419. if err != nil {
  37420. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  37421. }
  37422. return oldValue.Status, nil
  37423. }
  37424. // AddStatus adds u to the "status" field.
  37425. func (m *WpChatroomMutation) AddStatus(u int8) {
  37426. if m.addstatus != nil {
  37427. *m.addstatus += u
  37428. } else {
  37429. m.addstatus = &u
  37430. }
  37431. }
  37432. // AddedStatus returns the value that was added to the "status" field in this mutation.
  37433. func (m *WpChatroomMutation) AddedStatus() (r int8, exists bool) {
  37434. v := m.addstatus
  37435. if v == nil {
  37436. return
  37437. }
  37438. return *v, true
  37439. }
  37440. // ClearStatus clears the value of the "status" field.
  37441. func (m *WpChatroomMutation) ClearStatus() {
  37442. m.status = nil
  37443. m.addstatus = nil
  37444. m.clearedFields[wpchatroom.FieldStatus] = struct{}{}
  37445. }
  37446. // StatusCleared returns if the "status" field was cleared in this mutation.
  37447. func (m *WpChatroomMutation) StatusCleared() bool {
  37448. _, ok := m.clearedFields[wpchatroom.FieldStatus]
  37449. return ok
  37450. }
  37451. // ResetStatus resets all changes to the "status" field.
  37452. func (m *WpChatroomMutation) ResetStatus() {
  37453. m.status = nil
  37454. m.addstatus = nil
  37455. delete(m.clearedFields, wpchatroom.FieldStatus)
  37456. }
  37457. // SetWxWxid sets the "wx_wxid" field.
  37458. func (m *WpChatroomMutation) SetWxWxid(s string) {
  37459. m.wx_wxid = &s
  37460. }
  37461. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  37462. func (m *WpChatroomMutation) WxWxid() (r string, exists bool) {
  37463. v := m.wx_wxid
  37464. if v == nil {
  37465. return
  37466. }
  37467. return *v, true
  37468. }
  37469. // OldWxWxid returns the old "wx_wxid" field's value of the WpChatroom entity.
  37470. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  37471. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37472. func (m *WpChatroomMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  37473. if !m.op.Is(OpUpdateOne) {
  37474. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  37475. }
  37476. if m.id == nil || m.oldValue == nil {
  37477. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  37478. }
  37479. oldValue, err := m.oldValue(ctx)
  37480. if err != nil {
  37481. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  37482. }
  37483. return oldValue.WxWxid, nil
  37484. }
  37485. // ResetWxWxid resets all changes to the "wx_wxid" field.
  37486. func (m *WpChatroomMutation) ResetWxWxid() {
  37487. m.wx_wxid = nil
  37488. }
  37489. // SetChatroomID sets the "chatroom_id" field.
  37490. func (m *WpChatroomMutation) SetChatroomID(s string) {
  37491. m.chatroom_id = &s
  37492. }
  37493. // ChatroomID returns the value of the "chatroom_id" field in the mutation.
  37494. func (m *WpChatroomMutation) ChatroomID() (r string, exists bool) {
  37495. v := m.chatroom_id
  37496. if v == nil {
  37497. return
  37498. }
  37499. return *v, true
  37500. }
  37501. // OldChatroomID returns the old "chatroom_id" field's value of the WpChatroom entity.
  37502. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  37503. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37504. func (m *WpChatroomMutation) OldChatroomID(ctx context.Context) (v string, err error) {
  37505. if !m.op.Is(OpUpdateOne) {
  37506. return v, errors.New("OldChatroomID is only allowed on UpdateOne operations")
  37507. }
  37508. if m.id == nil || m.oldValue == nil {
  37509. return v, errors.New("OldChatroomID requires an ID field in the mutation")
  37510. }
  37511. oldValue, err := m.oldValue(ctx)
  37512. if err != nil {
  37513. return v, fmt.Errorf("querying old value for OldChatroomID: %w", err)
  37514. }
  37515. return oldValue.ChatroomID, nil
  37516. }
  37517. // ResetChatroomID resets all changes to the "chatroom_id" field.
  37518. func (m *WpChatroomMutation) ResetChatroomID() {
  37519. m.chatroom_id = nil
  37520. }
  37521. // SetNickname sets the "nickname" field.
  37522. func (m *WpChatroomMutation) SetNickname(s string) {
  37523. m.nickname = &s
  37524. }
  37525. // Nickname returns the value of the "nickname" field in the mutation.
  37526. func (m *WpChatroomMutation) Nickname() (r string, exists bool) {
  37527. v := m.nickname
  37528. if v == nil {
  37529. return
  37530. }
  37531. return *v, true
  37532. }
  37533. // OldNickname returns the old "nickname" field's value of the WpChatroom entity.
  37534. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  37535. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37536. func (m *WpChatroomMutation) OldNickname(ctx context.Context) (v string, err error) {
  37537. if !m.op.Is(OpUpdateOne) {
  37538. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  37539. }
  37540. if m.id == nil || m.oldValue == nil {
  37541. return v, errors.New("OldNickname requires an ID field in the mutation")
  37542. }
  37543. oldValue, err := m.oldValue(ctx)
  37544. if err != nil {
  37545. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  37546. }
  37547. return oldValue.Nickname, nil
  37548. }
  37549. // ResetNickname resets all changes to the "nickname" field.
  37550. func (m *WpChatroomMutation) ResetNickname() {
  37551. m.nickname = nil
  37552. }
  37553. // SetOwner sets the "owner" field.
  37554. func (m *WpChatroomMutation) SetOwner(s string) {
  37555. m.owner = &s
  37556. }
  37557. // Owner returns the value of the "owner" field in the mutation.
  37558. func (m *WpChatroomMutation) Owner() (r string, exists bool) {
  37559. v := m.owner
  37560. if v == nil {
  37561. return
  37562. }
  37563. return *v, true
  37564. }
  37565. // OldOwner returns the old "owner" field's value of the WpChatroom entity.
  37566. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  37567. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37568. func (m *WpChatroomMutation) OldOwner(ctx context.Context) (v string, err error) {
  37569. if !m.op.Is(OpUpdateOne) {
  37570. return v, errors.New("OldOwner is only allowed on UpdateOne operations")
  37571. }
  37572. if m.id == nil || m.oldValue == nil {
  37573. return v, errors.New("OldOwner requires an ID field in the mutation")
  37574. }
  37575. oldValue, err := m.oldValue(ctx)
  37576. if err != nil {
  37577. return v, fmt.Errorf("querying old value for OldOwner: %w", err)
  37578. }
  37579. return oldValue.Owner, nil
  37580. }
  37581. // ResetOwner resets all changes to the "owner" field.
  37582. func (m *WpChatroomMutation) ResetOwner() {
  37583. m.owner = nil
  37584. }
  37585. // SetAvatar sets the "avatar" field.
  37586. func (m *WpChatroomMutation) SetAvatar(s string) {
  37587. m.avatar = &s
  37588. }
  37589. // Avatar returns the value of the "avatar" field in the mutation.
  37590. func (m *WpChatroomMutation) Avatar() (r string, exists bool) {
  37591. v := m.avatar
  37592. if v == nil {
  37593. return
  37594. }
  37595. return *v, true
  37596. }
  37597. // OldAvatar returns the old "avatar" field's value of the WpChatroom entity.
  37598. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  37599. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37600. func (m *WpChatroomMutation) OldAvatar(ctx context.Context) (v string, err error) {
  37601. if !m.op.Is(OpUpdateOne) {
  37602. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  37603. }
  37604. if m.id == nil || m.oldValue == nil {
  37605. return v, errors.New("OldAvatar requires an ID field in the mutation")
  37606. }
  37607. oldValue, err := m.oldValue(ctx)
  37608. if err != nil {
  37609. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  37610. }
  37611. return oldValue.Avatar, nil
  37612. }
  37613. // ResetAvatar resets all changes to the "avatar" field.
  37614. func (m *WpChatroomMutation) ResetAvatar() {
  37615. m.avatar = nil
  37616. }
  37617. // SetMemberList sets the "member_list" field.
  37618. func (m *WpChatroomMutation) SetMemberList(s []string) {
  37619. m.member_list = &s
  37620. m.appendmember_list = nil
  37621. }
  37622. // MemberList returns the value of the "member_list" field in the mutation.
  37623. func (m *WpChatroomMutation) MemberList() (r []string, exists bool) {
  37624. v := m.member_list
  37625. if v == nil {
  37626. return
  37627. }
  37628. return *v, true
  37629. }
  37630. // OldMemberList returns the old "member_list" field's value of the WpChatroom entity.
  37631. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  37632. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37633. func (m *WpChatroomMutation) OldMemberList(ctx context.Context) (v []string, err error) {
  37634. if !m.op.Is(OpUpdateOne) {
  37635. return v, errors.New("OldMemberList is only allowed on UpdateOne operations")
  37636. }
  37637. if m.id == nil || m.oldValue == nil {
  37638. return v, errors.New("OldMemberList requires an ID field in the mutation")
  37639. }
  37640. oldValue, err := m.oldValue(ctx)
  37641. if err != nil {
  37642. return v, fmt.Errorf("querying old value for OldMemberList: %w", err)
  37643. }
  37644. return oldValue.MemberList, nil
  37645. }
  37646. // AppendMemberList adds s to the "member_list" field.
  37647. func (m *WpChatroomMutation) AppendMemberList(s []string) {
  37648. m.appendmember_list = append(m.appendmember_list, s...)
  37649. }
  37650. // AppendedMemberList returns the list of values that were appended to the "member_list" field in this mutation.
  37651. func (m *WpChatroomMutation) AppendedMemberList() ([]string, bool) {
  37652. if len(m.appendmember_list) == 0 {
  37653. return nil, false
  37654. }
  37655. return m.appendmember_list, true
  37656. }
  37657. // ResetMemberList resets all changes to the "member_list" field.
  37658. func (m *WpChatroomMutation) ResetMemberList() {
  37659. m.member_list = nil
  37660. m.appendmember_list = nil
  37661. }
  37662. // Where appends a list predicates to the WpChatroomMutation builder.
  37663. func (m *WpChatroomMutation) Where(ps ...predicate.WpChatroom) {
  37664. m.predicates = append(m.predicates, ps...)
  37665. }
  37666. // WhereP appends storage-level predicates to the WpChatroomMutation builder. Using this method,
  37667. // users can use type-assertion to append predicates that do not depend on any generated package.
  37668. func (m *WpChatroomMutation) WhereP(ps ...func(*sql.Selector)) {
  37669. p := make([]predicate.WpChatroom, len(ps))
  37670. for i := range ps {
  37671. p[i] = ps[i]
  37672. }
  37673. m.Where(p...)
  37674. }
  37675. // Op returns the operation name.
  37676. func (m *WpChatroomMutation) Op() Op {
  37677. return m.op
  37678. }
  37679. // SetOp allows setting the mutation operation.
  37680. func (m *WpChatroomMutation) SetOp(op Op) {
  37681. m.op = op
  37682. }
  37683. // Type returns the node type of this mutation (WpChatroom).
  37684. func (m *WpChatroomMutation) Type() string {
  37685. return m.typ
  37686. }
  37687. // Fields returns all fields that were changed during this mutation. Note that in
  37688. // order to get all numeric fields that were incremented/decremented, call
  37689. // AddedFields().
  37690. func (m *WpChatroomMutation) Fields() []string {
  37691. fields := make([]string, 0, 9)
  37692. if m.created_at != nil {
  37693. fields = append(fields, wpchatroom.FieldCreatedAt)
  37694. }
  37695. if m.updated_at != nil {
  37696. fields = append(fields, wpchatroom.FieldUpdatedAt)
  37697. }
  37698. if m.status != nil {
  37699. fields = append(fields, wpchatroom.FieldStatus)
  37700. }
  37701. if m.wx_wxid != nil {
  37702. fields = append(fields, wpchatroom.FieldWxWxid)
  37703. }
  37704. if m.chatroom_id != nil {
  37705. fields = append(fields, wpchatroom.FieldChatroomID)
  37706. }
  37707. if m.nickname != nil {
  37708. fields = append(fields, wpchatroom.FieldNickname)
  37709. }
  37710. if m.owner != nil {
  37711. fields = append(fields, wpchatroom.FieldOwner)
  37712. }
  37713. if m.avatar != nil {
  37714. fields = append(fields, wpchatroom.FieldAvatar)
  37715. }
  37716. if m.member_list != nil {
  37717. fields = append(fields, wpchatroom.FieldMemberList)
  37718. }
  37719. return fields
  37720. }
  37721. // Field returns the value of a field with the given name. The second boolean
  37722. // return value indicates that this field was not set, or was not defined in the
  37723. // schema.
  37724. func (m *WpChatroomMutation) Field(name string) (ent.Value, bool) {
  37725. switch name {
  37726. case wpchatroom.FieldCreatedAt:
  37727. return m.CreatedAt()
  37728. case wpchatroom.FieldUpdatedAt:
  37729. return m.UpdatedAt()
  37730. case wpchatroom.FieldStatus:
  37731. return m.Status()
  37732. case wpchatroom.FieldWxWxid:
  37733. return m.WxWxid()
  37734. case wpchatroom.FieldChatroomID:
  37735. return m.ChatroomID()
  37736. case wpchatroom.FieldNickname:
  37737. return m.Nickname()
  37738. case wpchatroom.FieldOwner:
  37739. return m.Owner()
  37740. case wpchatroom.FieldAvatar:
  37741. return m.Avatar()
  37742. case wpchatroom.FieldMemberList:
  37743. return m.MemberList()
  37744. }
  37745. return nil, false
  37746. }
  37747. // OldField returns the old value of the field from the database. An error is
  37748. // returned if the mutation operation is not UpdateOne, or the query to the
  37749. // database failed.
  37750. func (m *WpChatroomMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  37751. switch name {
  37752. case wpchatroom.FieldCreatedAt:
  37753. return m.OldCreatedAt(ctx)
  37754. case wpchatroom.FieldUpdatedAt:
  37755. return m.OldUpdatedAt(ctx)
  37756. case wpchatroom.FieldStatus:
  37757. return m.OldStatus(ctx)
  37758. case wpchatroom.FieldWxWxid:
  37759. return m.OldWxWxid(ctx)
  37760. case wpchatroom.FieldChatroomID:
  37761. return m.OldChatroomID(ctx)
  37762. case wpchatroom.FieldNickname:
  37763. return m.OldNickname(ctx)
  37764. case wpchatroom.FieldOwner:
  37765. return m.OldOwner(ctx)
  37766. case wpchatroom.FieldAvatar:
  37767. return m.OldAvatar(ctx)
  37768. case wpchatroom.FieldMemberList:
  37769. return m.OldMemberList(ctx)
  37770. }
  37771. return nil, fmt.Errorf("unknown WpChatroom field %s", name)
  37772. }
  37773. // SetField sets the value of a field with the given name. It returns an error if
  37774. // the field is not defined in the schema, or if the type mismatched the field
  37775. // type.
  37776. func (m *WpChatroomMutation) SetField(name string, value ent.Value) error {
  37777. switch name {
  37778. case wpchatroom.FieldCreatedAt:
  37779. v, ok := value.(time.Time)
  37780. if !ok {
  37781. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37782. }
  37783. m.SetCreatedAt(v)
  37784. return nil
  37785. case wpchatroom.FieldUpdatedAt:
  37786. v, ok := value.(time.Time)
  37787. if !ok {
  37788. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37789. }
  37790. m.SetUpdatedAt(v)
  37791. return nil
  37792. case wpchatroom.FieldStatus:
  37793. v, ok := value.(uint8)
  37794. if !ok {
  37795. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37796. }
  37797. m.SetStatus(v)
  37798. return nil
  37799. case wpchatroom.FieldWxWxid:
  37800. v, ok := value.(string)
  37801. if !ok {
  37802. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37803. }
  37804. m.SetWxWxid(v)
  37805. return nil
  37806. case wpchatroom.FieldChatroomID:
  37807. v, ok := value.(string)
  37808. if !ok {
  37809. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37810. }
  37811. m.SetChatroomID(v)
  37812. return nil
  37813. case wpchatroom.FieldNickname:
  37814. v, ok := value.(string)
  37815. if !ok {
  37816. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37817. }
  37818. m.SetNickname(v)
  37819. return nil
  37820. case wpchatroom.FieldOwner:
  37821. v, ok := value.(string)
  37822. if !ok {
  37823. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37824. }
  37825. m.SetOwner(v)
  37826. return nil
  37827. case wpchatroom.FieldAvatar:
  37828. v, ok := value.(string)
  37829. if !ok {
  37830. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37831. }
  37832. m.SetAvatar(v)
  37833. return nil
  37834. case wpchatroom.FieldMemberList:
  37835. v, ok := value.([]string)
  37836. if !ok {
  37837. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37838. }
  37839. m.SetMemberList(v)
  37840. return nil
  37841. }
  37842. return fmt.Errorf("unknown WpChatroom field %s", name)
  37843. }
  37844. // AddedFields returns all numeric fields that were incremented/decremented during
  37845. // this mutation.
  37846. func (m *WpChatroomMutation) AddedFields() []string {
  37847. var fields []string
  37848. if m.addstatus != nil {
  37849. fields = append(fields, wpchatroom.FieldStatus)
  37850. }
  37851. return fields
  37852. }
  37853. // AddedField returns the numeric value that was incremented/decremented on a field
  37854. // with the given name. The second boolean return value indicates that this field
  37855. // was not set, or was not defined in the schema.
  37856. func (m *WpChatroomMutation) AddedField(name string) (ent.Value, bool) {
  37857. switch name {
  37858. case wpchatroom.FieldStatus:
  37859. return m.AddedStatus()
  37860. }
  37861. return nil, false
  37862. }
  37863. // AddField adds the value to the field with the given name. It returns an error if
  37864. // the field is not defined in the schema, or if the type mismatched the field
  37865. // type.
  37866. func (m *WpChatroomMutation) AddField(name string, value ent.Value) error {
  37867. switch name {
  37868. case wpchatroom.FieldStatus:
  37869. v, ok := value.(int8)
  37870. if !ok {
  37871. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37872. }
  37873. m.AddStatus(v)
  37874. return nil
  37875. }
  37876. return fmt.Errorf("unknown WpChatroom numeric field %s", name)
  37877. }
  37878. // ClearedFields returns all nullable fields that were cleared during this
  37879. // mutation.
  37880. func (m *WpChatroomMutation) ClearedFields() []string {
  37881. var fields []string
  37882. if m.FieldCleared(wpchatroom.FieldStatus) {
  37883. fields = append(fields, wpchatroom.FieldStatus)
  37884. }
  37885. return fields
  37886. }
  37887. // FieldCleared returns a boolean indicating if a field with the given name was
  37888. // cleared in this mutation.
  37889. func (m *WpChatroomMutation) FieldCleared(name string) bool {
  37890. _, ok := m.clearedFields[name]
  37891. return ok
  37892. }
  37893. // ClearField clears the value of the field with the given name. It returns an
  37894. // error if the field is not defined in the schema.
  37895. func (m *WpChatroomMutation) ClearField(name string) error {
  37896. switch name {
  37897. case wpchatroom.FieldStatus:
  37898. m.ClearStatus()
  37899. return nil
  37900. }
  37901. return fmt.Errorf("unknown WpChatroom nullable field %s", name)
  37902. }
  37903. // ResetField resets all changes in the mutation for the field with the given name.
  37904. // It returns an error if the field is not defined in the schema.
  37905. func (m *WpChatroomMutation) ResetField(name string) error {
  37906. switch name {
  37907. case wpchatroom.FieldCreatedAt:
  37908. m.ResetCreatedAt()
  37909. return nil
  37910. case wpchatroom.FieldUpdatedAt:
  37911. m.ResetUpdatedAt()
  37912. return nil
  37913. case wpchatroom.FieldStatus:
  37914. m.ResetStatus()
  37915. return nil
  37916. case wpchatroom.FieldWxWxid:
  37917. m.ResetWxWxid()
  37918. return nil
  37919. case wpchatroom.FieldChatroomID:
  37920. m.ResetChatroomID()
  37921. return nil
  37922. case wpchatroom.FieldNickname:
  37923. m.ResetNickname()
  37924. return nil
  37925. case wpchatroom.FieldOwner:
  37926. m.ResetOwner()
  37927. return nil
  37928. case wpchatroom.FieldAvatar:
  37929. m.ResetAvatar()
  37930. return nil
  37931. case wpchatroom.FieldMemberList:
  37932. m.ResetMemberList()
  37933. return nil
  37934. }
  37935. return fmt.Errorf("unknown WpChatroom field %s", name)
  37936. }
  37937. // AddedEdges returns all edge names that were set/added in this mutation.
  37938. func (m *WpChatroomMutation) AddedEdges() []string {
  37939. edges := make([]string, 0, 0)
  37940. return edges
  37941. }
  37942. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  37943. // name in this mutation.
  37944. func (m *WpChatroomMutation) AddedIDs(name string) []ent.Value {
  37945. return nil
  37946. }
  37947. // RemovedEdges returns all edge names that were removed in this mutation.
  37948. func (m *WpChatroomMutation) RemovedEdges() []string {
  37949. edges := make([]string, 0, 0)
  37950. return edges
  37951. }
  37952. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  37953. // the given name in this mutation.
  37954. func (m *WpChatroomMutation) RemovedIDs(name string) []ent.Value {
  37955. return nil
  37956. }
  37957. // ClearedEdges returns all edge names that were cleared in this mutation.
  37958. func (m *WpChatroomMutation) ClearedEdges() []string {
  37959. edges := make([]string, 0, 0)
  37960. return edges
  37961. }
  37962. // EdgeCleared returns a boolean which indicates if the edge with the given name
  37963. // was cleared in this mutation.
  37964. func (m *WpChatroomMutation) EdgeCleared(name string) bool {
  37965. return false
  37966. }
  37967. // ClearEdge clears the value of the edge with the given name. It returns an error
  37968. // if that edge is not defined in the schema.
  37969. func (m *WpChatroomMutation) ClearEdge(name string) error {
  37970. return fmt.Errorf("unknown WpChatroom unique edge %s", name)
  37971. }
  37972. // ResetEdge resets all changes to the edge with the given name in this mutation.
  37973. // It returns an error if the edge is not defined in the schema.
  37974. func (m *WpChatroomMutation) ResetEdge(name string) error {
  37975. return fmt.Errorf("unknown WpChatroom edge %s", name)
  37976. }
  37977. // WpChatroomMemberMutation represents an operation that mutates the WpChatroomMember nodes in the graph.
  37978. type WpChatroomMemberMutation struct {
  37979. config
  37980. op Op
  37981. typ string
  37982. id *uint64
  37983. created_at *time.Time
  37984. updated_at *time.Time
  37985. status *uint8
  37986. addstatus *int8
  37987. wx_wxid *string
  37988. wxid *string
  37989. nickname *string
  37990. avatar *string
  37991. clearedFields map[string]struct{}
  37992. done bool
  37993. oldValue func(context.Context) (*WpChatroomMember, error)
  37994. predicates []predicate.WpChatroomMember
  37995. }
  37996. var _ ent.Mutation = (*WpChatroomMemberMutation)(nil)
  37997. // wpchatroommemberOption allows management of the mutation configuration using functional options.
  37998. type wpchatroommemberOption func(*WpChatroomMemberMutation)
  37999. // newWpChatroomMemberMutation creates new mutation for the WpChatroomMember entity.
  38000. func newWpChatroomMemberMutation(c config, op Op, opts ...wpchatroommemberOption) *WpChatroomMemberMutation {
  38001. m := &WpChatroomMemberMutation{
  38002. config: c,
  38003. op: op,
  38004. typ: TypeWpChatroomMember,
  38005. clearedFields: make(map[string]struct{}),
  38006. }
  38007. for _, opt := range opts {
  38008. opt(m)
  38009. }
  38010. return m
  38011. }
  38012. // withWpChatroomMemberID sets the ID field of the mutation.
  38013. func withWpChatroomMemberID(id uint64) wpchatroommemberOption {
  38014. return func(m *WpChatroomMemberMutation) {
  38015. var (
  38016. err error
  38017. once sync.Once
  38018. value *WpChatroomMember
  38019. )
  38020. m.oldValue = func(ctx context.Context) (*WpChatroomMember, error) {
  38021. once.Do(func() {
  38022. if m.done {
  38023. err = errors.New("querying old values post mutation is not allowed")
  38024. } else {
  38025. value, err = m.Client().WpChatroomMember.Get(ctx, id)
  38026. }
  38027. })
  38028. return value, err
  38029. }
  38030. m.id = &id
  38031. }
  38032. }
  38033. // withWpChatroomMember sets the old WpChatroomMember of the mutation.
  38034. func withWpChatroomMember(node *WpChatroomMember) wpchatroommemberOption {
  38035. return func(m *WpChatroomMemberMutation) {
  38036. m.oldValue = func(context.Context) (*WpChatroomMember, error) {
  38037. return node, nil
  38038. }
  38039. m.id = &node.ID
  38040. }
  38041. }
  38042. // Client returns a new `ent.Client` from the mutation. If the mutation was
  38043. // executed in a transaction (ent.Tx), a transactional client is returned.
  38044. func (m WpChatroomMemberMutation) Client() *Client {
  38045. client := &Client{config: m.config}
  38046. client.init()
  38047. return client
  38048. }
  38049. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  38050. // it returns an error otherwise.
  38051. func (m WpChatroomMemberMutation) Tx() (*Tx, error) {
  38052. if _, ok := m.driver.(*txDriver); !ok {
  38053. return nil, errors.New("ent: mutation is not running in a transaction")
  38054. }
  38055. tx := &Tx{config: m.config}
  38056. tx.init()
  38057. return tx, nil
  38058. }
  38059. // SetID sets the value of the id field. Note that this
  38060. // operation is only accepted on creation of WpChatroomMember entities.
  38061. func (m *WpChatroomMemberMutation) SetID(id uint64) {
  38062. m.id = &id
  38063. }
  38064. // ID returns the ID value in the mutation. Note that the ID is only available
  38065. // if it was provided to the builder or after it was returned from the database.
  38066. func (m *WpChatroomMemberMutation) ID() (id uint64, exists bool) {
  38067. if m.id == nil {
  38068. return
  38069. }
  38070. return *m.id, true
  38071. }
  38072. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  38073. // That means, if the mutation is applied within a transaction with an isolation level such
  38074. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  38075. // or updated by the mutation.
  38076. func (m *WpChatroomMemberMutation) IDs(ctx context.Context) ([]uint64, error) {
  38077. switch {
  38078. case m.op.Is(OpUpdateOne | OpDeleteOne):
  38079. id, exists := m.ID()
  38080. if exists {
  38081. return []uint64{id}, nil
  38082. }
  38083. fallthrough
  38084. case m.op.Is(OpUpdate | OpDelete):
  38085. return m.Client().WpChatroomMember.Query().Where(m.predicates...).IDs(ctx)
  38086. default:
  38087. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  38088. }
  38089. }
  38090. // SetCreatedAt sets the "created_at" field.
  38091. func (m *WpChatroomMemberMutation) SetCreatedAt(t time.Time) {
  38092. m.created_at = &t
  38093. }
  38094. // CreatedAt returns the value of the "created_at" field in the mutation.
  38095. func (m *WpChatroomMemberMutation) CreatedAt() (r time.Time, exists bool) {
  38096. v := m.created_at
  38097. if v == nil {
  38098. return
  38099. }
  38100. return *v, true
  38101. }
  38102. // OldCreatedAt returns the old "created_at" field's value of the WpChatroomMember entity.
  38103. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  38104. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38105. func (m *WpChatroomMemberMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  38106. if !m.op.Is(OpUpdateOne) {
  38107. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  38108. }
  38109. if m.id == nil || m.oldValue == nil {
  38110. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  38111. }
  38112. oldValue, err := m.oldValue(ctx)
  38113. if err != nil {
  38114. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  38115. }
  38116. return oldValue.CreatedAt, nil
  38117. }
  38118. // ResetCreatedAt resets all changes to the "created_at" field.
  38119. func (m *WpChatroomMemberMutation) ResetCreatedAt() {
  38120. m.created_at = nil
  38121. }
  38122. // SetUpdatedAt sets the "updated_at" field.
  38123. func (m *WpChatroomMemberMutation) SetUpdatedAt(t time.Time) {
  38124. m.updated_at = &t
  38125. }
  38126. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  38127. func (m *WpChatroomMemberMutation) UpdatedAt() (r time.Time, exists bool) {
  38128. v := m.updated_at
  38129. if v == nil {
  38130. return
  38131. }
  38132. return *v, true
  38133. }
  38134. // OldUpdatedAt returns the old "updated_at" field's value of the WpChatroomMember entity.
  38135. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  38136. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38137. func (m *WpChatroomMemberMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  38138. if !m.op.Is(OpUpdateOne) {
  38139. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  38140. }
  38141. if m.id == nil || m.oldValue == nil {
  38142. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  38143. }
  38144. oldValue, err := m.oldValue(ctx)
  38145. if err != nil {
  38146. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  38147. }
  38148. return oldValue.UpdatedAt, nil
  38149. }
  38150. // ResetUpdatedAt resets all changes to the "updated_at" field.
  38151. func (m *WpChatroomMemberMutation) ResetUpdatedAt() {
  38152. m.updated_at = nil
  38153. }
  38154. // SetStatus sets the "status" field.
  38155. func (m *WpChatroomMemberMutation) SetStatus(u uint8) {
  38156. m.status = &u
  38157. m.addstatus = nil
  38158. }
  38159. // Status returns the value of the "status" field in the mutation.
  38160. func (m *WpChatroomMemberMutation) Status() (r uint8, exists bool) {
  38161. v := m.status
  38162. if v == nil {
  38163. return
  38164. }
  38165. return *v, true
  38166. }
  38167. // OldStatus returns the old "status" field's value of the WpChatroomMember entity.
  38168. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  38169. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38170. func (m *WpChatroomMemberMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  38171. if !m.op.Is(OpUpdateOne) {
  38172. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  38173. }
  38174. if m.id == nil || m.oldValue == nil {
  38175. return v, errors.New("OldStatus requires an ID field in the mutation")
  38176. }
  38177. oldValue, err := m.oldValue(ctx)
  38178. if err != nil {
  38179. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  38180. }
  38181. return oldValue.Status, nil
  38182. }
  38183. // AddStatus adds u to the "status" field.
  38184. func (m *WpChatroomMemberMutation) AddStatus(u int8) {
  38185. if m.addstatus != nil {
  38186. *m.addstatus += u
  38187. } else {
  38188. m.addstatus = &u
  38189. }
  38190. }
  38191. // AddedStatus returns the value that was added to the "status" field in this mutation.
  38192. func (m *WpChatroomMemberMutation) AddedStatus() (r int8, exists bool) {
  38193. v := m.addstatus
  38194. if v == nil {
  38195. return
  38196. }
  38197. return *v, true
  38198. }
  38199. // ClearStatus clears the value of the "status" field.
  38200. func (m *WpChatroomMemberMutation) ClearStatus() {
  38201. m.status = nil
  38202. m.addstatus = nil
  38203. m.clearedFields[wpchatroommember.FieldStatus] = struct{}{}
  38204. }
  38205. // StatusCleared returns if the "status" field was cleared in this mutation.
  38206. func (m *WpChatroomMemberMutation) StatusCleared() bool {
  38207. _, ok := m.clearedFields[wpchatroommember.FieldStatus]
  38208. return ok
  38209. }
  38210. // ResetStatus resets all changes to the "status" field.
  38211. func (m *WpChatroomMemberMutation) ResetStatus() {
  38212. m.status = nil
  38213. m.addstatus = nil
  38214. delete(m.clearedFields, wpchatroommember.FieldStatus)
  38215. }
  38216. // SetWxWxid sets the "wx_wxid" field.
  38217. func (m *WpChatroomMemberMutation) SetWxWxid(s string) {
  38218. m.wx_wxid = &s
  38219. }
  38220. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  38221. func (m *WpChatroomMemberMutation) WxWxid() (r string, exists bool) {
  38222. v := m.wx_wxid
  38223. if v == nil {
  38224. return
  38225. }
  38226. return *v, true
  38227. }
  38228. // OldWxWxid returns the old "wx_wxid" field's value of the WpChatroomMember entity.
  38229. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  38230. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38231. func (m *WpChatroomMemberMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  38232. if !m.op.Is(OpUpdateOne) {
  38233. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  38234. }
  38235. if m.id == nil || m.oldValue == nil {
  38236. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  38237. }
  38238. oldValue, err := m.oldValue(ctx)
  38239. if err != nil {
  38240. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  38241. }
  38242. return oldValue.WxWxid, nil
  38243. }
  38244. // ResetWxWxid resets all changes to the "wx_wxid" field.
  38245. func (m *WpChatroomMemberMutation) ResetWxWxid() {
  38246. m.wx_wxid = nil
  38247. }
  38248. // SetWxid sets the "wxid" field.
  38249. func (m *WpChatroomMemberMutation) SetWxid(s string) {
  38250. m.wxid = &s
  38251. }
  38252. // Wxid returns the value of the "wxid" field in the mutation.
  38253. func (m *WpChatroomMemberMutation) Wxid() (r string, exists bool) {
  38254. v := m.wxid
  38255. if v == nil {
  38256. return
  38257. }
  38258. return *v, true
  38259. }
  38260. // OldWxid returns the old "wxid" field's value of the WpChatroomMember entity.
  38261. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  38262. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38263. func (m *WpChatroomMemberMutation) OldWxid(ctx context.Context) (v string, err error) {
  38264. if !m.op.Is(OpUpdateOne) {
  38265. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  38266. }
  38267. if m.id == nil || m.oldValue == nil {
  38268. return v, errors.New("OldWxid requires an ID field in the mutation")
  38269. }
  38270. oldValue, err := m.oldValue(ctx)
  38271. if err != nil {
  38272. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  38273. }
  38274. return oldValue.Wxid, nil
  38275. }
  38276. // ResetWxid resets all changes to the "wxid" field.
  38277. func (m *WpChatroomMemberMutation) ResetWxid() {
  38278. m.wxid = nil
  38279. }
  38280. // SetNickname sets the "nickname" field.
  38281. func (m *WpChatroomMemberMutation) SetNickname(s string) {
  38282. m.nickname = &s
  38283. }
  38284. // Nickname returns the value of the "nickname" field in the mutation.
  38285. func (m *WpChatroomMemberMutation) Nickname() (r string, exists bool) {
  38286. v := m.nickname
  38287. if v == nil {
  38288. return
  38289. }
  38290. return *v, true
  38291. }
  38292. // OldNickname returns the old "nickname" field's value of the WpChatroomMember entity.
  38293. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  38294. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38295. func (m *WpChatroomMemberMutation) OldNickname(ctx context.Context) (v string, err error) {
  38296. if !m.op.Is(OpUpdateOne) {
  38297. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  38298. }
  38299. if m.id == nil || m.oldValue == nil {
  38300. return v, errors.New("OldNickname requires an ID field in the mutation")
  38301. }
  38302. oldValue, err := m.oldValue(ctx)
  38303. if err != nil {
  38304. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  38305. }
  38306. return oldValue.Nickname, nil
  38307. }
  38308. // ResetNickname resets all changes to the "nickname" field.
  38309. func (m *WpChatroomMemberMutation) ResetNickname() {
  38310. m.nickname = nil
  38311. }
  38312. // SetAvatar sets the "avatar" field.
  38313. func (m *WpChatroomMemberMutation) SetAvatar(s string) {
  38314. m.avatar = &s
  38315. }
  38316. // Avatar returns the value of the "avatar" field in the mutation.
  38317. func (m *WpChatroomMemberMutation) Avatar() (r string, exists bool) {
  38318. v := m.avatar
  38319. if v == nil {
  38320. return
  38321. }
  38322. return *v, true
  38323. }
  38324. // OldAvatar returns the old "avatar" field's value of the WpChatroomMember entity.
  38325. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  38326. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38327. func (m *WpChatroomMemberMutation) OldAvatar(ctx context.Context) (v string, err error) {
  38328. if !m.op.Is(OpUpdateOne) {
  38329. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  38330. }
  38331. if m.id == nil || m.oldValue == nil {
  38332. return v, errors.New("OldAvatar requires an ID field in the mutation")
  38333. }
  38334. oldValue, err := m.oldValue(ctx)
  38335. if err != nil {
  38336. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  38337. }
  38338. return oldValue.Avatar, nil
  38339. }
  38340. // ResetAvatar resets all changes to the "avatar" field.
  38341. func (m *WpChatroomMemberMutation) ResetAvatar() {
  38342. m.avatar = nil
  38343. }
  38344. // Where appends a list predicates to the WpChatroomMemberMutation builder.
  38345. func (m *WpChatroomMemberMutation) Where(ps ...predicate.WpChatroomMember) {
  38346. m.predicates = append(m.predicates, ps...)
  38347. }
  38348. // WhereP appends storage-level predicates to the WpChatroomMemberMutation builder. Using this method,
  38349. // users can use type-assertion to append predicates that do not depend on any generated package.
  38350. func (m *WpChatroomMemberMutation) WhereP(ps ...func(*sql.Selector)) {
  38351. p := make([]predicate.WpChatroomMember, len(ps))
  38352. for i := range ps {
  38353. p[i] = ps[i]
  38354. }
  38355. m.Where(p...)
  38356. }
  38357. // Op returns the operation name.
  38358. func (m *WpChatroomMemberMutation) Op() Op {
  38359. return m.op
  38360. }
  38361. // SetOp allows setting the mutation operation.
  38362. func (m *WpChatroomMemberMutation) SetOp(op Op) {
  38363. m.op = op
  38364. }
  38365. // Type returns the node type of this mutation (WpChatroomMember).
  38366. func (m *WpChatroomMemberMutation) Type() string {
  38367. return m.typ
  38368. }
  38369. // Fields returns all fields that were changed during this mutation. Note that in
  38370. // order to get all numeric fields that were incremented/decremented, call
  38371. // AddedFields().
  38372. func (m *WpChatroomMemberMutation) Fields() []string {
  38373. fields := make([]string, 0, 7)
  38374. if m.created_at != nil {
  38375. fields = append(fields, wpchatroommember.FieldCreatedAt)
  38376. }
  38377. if m.updated_at != nil {
  38378. fields = append(fields, wpchatroommember.FieldUpdatedAt)
  38379. }
  38380. if m.status != nil {
  38381. fields = append(fields, wpchatroommember.FieldStatus)
  38382. }
  38383. if m.wx_wxid != nil {
  38384. fields = append(fields, wpchatroommember.FieldWxWxid)
  38385. }
  38386. if m.wxid != nil {
  38387. fields = append(fields, wpchatroommember.FieldWxid)
  38388. }
  38389. if m.nickname != nil {
  38390. fields = append(fields, wpchatroommember.FieldNickname)
  38391. }
  38392. if m.avatar != nil {
  38393. fields = append(fields, wpchatroommember.FieldAvatar)
  38394. }
  38395. return fields
  38396. }
  38397. // Field returns the value of a field with the given name. The second boolean
  38398. // return value indicates that this field was not set, or was not defined in the
  38399. // schema.
  38400. func (m *WpChatroomMemberMutation) Field(name string) (ent.Value, bool) {
  38401. switch name {
  38402. case wpchatroommember.FieldCreatedAt:
  38403. return m.CreatedAt()
  38404. case wpchatroommember.FieldUpdatedAt:
  38405. return m.UpdatedAt()
  38406. case wpchatroommember.FieldStatus:
  38407. return m.Status()
  38408. case wpchatroommember.FieldWxWxid:
  38409. return m.WxWxid()
  38410. case wpchatroommember.FieldWxid:
  38411. return m.Wxid()
  38412. case wpchatroommember.FieldNickname:
  38413. return m.Nickname()
  38414. case wpchatroommember.FieldAvatar:
  38415. return m.Avatar()
  38416. }
  38417. return nil, false
  38418. }
  38419. // OldField returns the old value of the field from the database. An error is
  38420. // returned if the mutation operation is not UpdateOne, or the query to the
  38421. // database failed.
  38422. func (m *WpChatroomMemberMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  38423. switch name {
  38424. case wpchatroommember.FieldCreatedAt:
  38425. return m.OldCreatedAt(ctx)
  38426. case wpchatroommember.FieldUpdatedAt:
  38427. return m.OldUpdatedAt(ctx)
  38428. case wpchatroommember.FieldStatus:
  38429. return m.OldStatus(ctx)
  38430. case wpchatroommember.FieldWxWxid:
  38431. return m.OldWxWxid(ctx)
  38432. case wpchatroommember.FieldWxid:
  38433. return m.OldWxid(ctx)
  38434. case wpchatroommember.FieldNickname:
  38435. return m.OldNickname(ctx)
  38436. case wpchatroommember.FieldAvatar:
  38437. return m.OldAvatar(ctx)
  38438. }
  38439. return nil, fmt.Errorf("unknown WpChatroomMember field %s", name)
  38440. }
  38441. // SetField sets the value of a field with the given name. It returns an error if
  38442. // the field is not defined in the schema, or if the type mismatched the field
  38443. // type.
  38444. func (m *WpChatroomMemberMutation) SetField(name string, value ent.Value) error {
  38445. switch name {
  38446. case wpchatroommember.FieldCreatedAt:
  38447. v, ok := value.(time.Time)
  38448. if !ok {
  38449. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38450. }
  38451. m.SetCreatedAt(v)
  38452. return nil
  38453. case wpchatroommember.FieldUpdatedAt:
  38454. v, ok := value.(time.Time)
  38455. if !ok {
  38456. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38457. }
  38458. m.SetUpdatedAt(v)
  38459. return nil
  38460. case wpchatroommember.FieldStatus:
  38461. v, ok := value.(uint8)
  38462. if !ok {
  38463. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38464. }
  38465. m.SetStatus(v)
  38466. return nil
  38467. case wpchatroommember.FieldWxWxid:
  38468. v, ok := value.(string)
  38469. if !ok {
  38470. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38471. }
  38472. m.SetWxWxid(v)
  38473. return nil
  38474. case wpchatroommember.FieldWxid:
  38475. v, ok := value.(string)
  38476. if !ok {
  38477. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38478. }
  38479. m.SetWxid(v)
  38480. return nil
  38481. case wpchatroommember.FieldNickname:
  38482. v, ok := value.(string)
  38483. if !ok {
  38484. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38485. }
  38486. m.SetNickname(v)
  38487. return nil
  38488. case wpchatroommember.FieldAvatar:
  38489. v, ok := value.(string)
  38490. if !ok {
  38491. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38492. }
  38493. m.SetAvatar(v)
  38494. return nil
  38495. }
  38496. return fmt.Errorf("unknown WpChatroomMember field %s", name)
  38497. }
  38498. // AddedFields returns all numeric fields that were incremented/decremented during
  38499. // this mutation.
  38500. func (m *WpChatroomMemberMutation) AddedFields() []string {
  38501. var fields []string
  38502. if m.addstatus != nil {
  38503. fields = append(fields, wpchatroommember.FieldStatus)
  38504. }
  38505. return fields
  38506. }
  38507. // AddedField returns the numeric value that was incremented/decremented on a field
  38508. // with the given name. The second boolean return value indicates that this field
  38509. // was not set, or was not defined in the schema.
  38510. func (m *WpChatroomMemberMutation) AddedField(name string) (ent.Value, bool) {
  38511. switch name {
  38512. case wpchatroommember.FieldStatus:
  38513. return m.AddedStatus()
  38514. }
  38515. return nil, false
  38516. }
  38517. // AddField adds the value to the field with the given name. It returns an error if
  38518. // the field is not defined in the schema, or if the type mismatched the field
  38519. // type.
  38520. func (m *WpChatroomMemberMutation) AddField(name string, value ent.Value) error {
  38521. switch name {
  38522. case wpchatroommember.FieldStatus:
  38523. v, ok := value.(int8)
  38524. if !ok {
  38525. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38526. }
  38527. m.AddStatus(v)
  38528. return nil
  38529. }
  38530. return fmt.Errorf("unknown WpChatroomMember numeric field %s", name)
  38531. }
  38532. // ClearedFields returns all nullable fields that were cleared during this
  38533. // mutation.
  38534. func (m *WpChatroomMemberMutation) ClearedFields() []string {
  38535. var fields []string
  38536. if m.FieldCleared(wpchatroommember.FieldStatus) {
  38537. fields = append(fields, wpchatroommember.FieldStatus)
  38538. }
  38539. return fields
  38540. }
  38541. // FieldCleared returns a boolean indicating if a field with the given name was
  38542. // cleared in this mutation.
  38543. func (m *WpChatroomMemberMutation) FieldCleared(name string) bool {
  38544. _, ok := m.clearedFields[name]
  38545. return ok
  38546. }
  38547. // ClearField clears the value of the field with the given name. It returns an
  38548. // error if the field is not defined in the schema.
  38549. func (m *WpChatroomMemberMutation) ClearField(name string) error {
  38550. switch name {
  38551. case wpchatroommember.FieldStatus:
  38552. m.ClearStatus()
  38553. return nil
  38554. }
  38555. return fmt.Errorf("unknown WpChatroomMember nullable field %s", name)
  38556. }
  38557. // ResetField resets all changes in the mutation for the field with the given name.
  38558. // It returns an error if the field is not defined in the schema.
  38559. func (m *WpChatroomMemberMutation) ResetField(name string) error {
  38560. switch name {
  38561. case wpchatroommember.FieldCreatedAt:
  38562. m.ResetCreatedAt()
  38563. return nil
  38564. case wpchatroommember.FieldUpdatedAt:
  38565. m.ResetUpdatedAt()
  38566. return nil
  38567. case wpchatroommember.FieldStatus:
  38568. m.ResetStatus()
  38569. return nil
  38570. case wpchatroommember.FieldWxWxid:
  38571. m.ResetWxWxid()
  38572. return nil
  38573. case wpchatroommember.FieldWxid:
  38574. m.ResetWxid()
  38575. return nil
  38576. case wpchatroommember.FieldNickname:
  38577. m.ResetNickname()
  38578. return nil
  38579. case wpchatroommember.FieldAvatar:
  38580. m.ResetAvatar()
  38581. return nil
  38582. }
  38583. return fmt.Errorf("unknown WpChatroomMember field %s", name)
  38584. }
  38585. // AddedEdges returns all edge names that were set/added in this mutation.
  38586. func (m *WpChatroomMemberMutation) AddedEdges() []string {
  38587. edges := make([]string, 0, 0)
  38588. return edges
  38589. }
  38590. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  38591. // name in this mutation.
  38592. func (m *WpChatroomMemberMutation) AddedIDs(name string) []ent.Value {
  38593. return nil
  38594. }
  38595. // RemovedEdges returns all edge names that were removed in this mutation.
  38596. func (m *WpChatroomMemberMutation) RemovedEdges() []string {
  38597. edges := make([]string, 0, 0)
  38598. return edges
  38599. }
  38600. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  38601. // the given name in this mutation.
  38602. func (m *WpChatroomMemberMutation) RemovedIDs(name string) []ent.Value {
  38603. return nil
  38604. }
  38605. // ClearedEdges returns all edge names that were cleared in this mutation.
  38606. func (m *WpChatroomMemberMutation) ClearedEdges() []string {
  38607. edges := make([]string, 0, 0)
  38608. return edges
  38609. }
  38610. // EdgeCleared returns a boolean which indicates if the edge with the given name
  38611. // was cleared in this mutation.
  38612. func (m *WpChatroomMemberMutation) EdgeCleared(name string) bool {
  38613. return false
  38614. }
  38615. // ClearEdge clears the value of the edge with the given name. It returns an error
  38616. // if that edge is not defined in the schema.
  38617. func (m *WpChatroomMemberMutation) ClearEdge(name string) error {
  38618. return fmt.Errorf("unknown WpChatroomMember unique edge %s", name)
  38619. }
  38620. // ResetEdge resets all changes to the edge with the given name in this mutation.
  38621. // It returns an error if the edge is not defined in the schema.
  38622. func (m *WpChatroomMemberMutation) ResetEdge(name string) error {
  38623. return fmt.Errorf("unknown WpChatroomMember edge %s", name)
  38624. }
  38625. // WxMutation represents an operation that mutates the Wx nodes in the graph.
  38626. type WxMutation struct {
  38627. config
  38628. op Op
  38629. typ string
  38630. id *uint64
  38631. created_at *time.Time
  38632. updated_at *time.Time
  38633. status *uint8
  38634. addstatus *int8
  38635. deleted_at *time.Time
  38636. port *string
  38637. process_id *string
  38638. callback *string
  38639. wxid *string
  38640. account *string
  38641. nickname *string
  38642. tel *string
  38643. head_big *string
  38644. organization_id *uint64
  38645. addorganization_id *int64
  38646. api_base *string
  38647. api_key *string
  38648. allow_list *[]string
  38649. appendallow_list []string
  38650. group_allow_list *[]string
  38651. appendgroup_allow_list []string
  38652. block_list *[]string
  38653. appendblock_list []string
  38654. group_block_list *[]string
  38655. appendgroup_block_list []string
  38656. clearedFields map[string]struct{}
  38657. server *uint64
  38658. clearedserver bool
  38659. agent *uint64
  38660. clearedagent bool
  38661. done bool
  38662. oldValue func(context.Context) (*Wx, error)
  38663. predicates []predicate.Wx
  38664. }
  38665. var _ ent.Mutation = (*WxMutation)(nil)
  38666. // wxOption allows management of the mutation configuration using functional options.
  38667. type wxOption func(*WxMutation)
  38668. // newWxMutation creates new mutation for the Wx entity.
  38669. func newWxMutation(c config, op Op, opts ...wxOption) *WxMutation {
  38670. m := &WxMutation{
  38671. config: c,
  38672. op: op,
  38673. typ: TypeWx,
  38674. clearedFields: make(map[string]struct{}),
  38675. }
  38676. for _, opt := range opts {
  38677. opt(m)
  38678. }
  38679. return m
  38680. }
  38681. // withWxID sets the ID field of the mutation.
  38682. func withWxID(id uint64) wxOption {
  38683. return func(m *WxMutation) {
  38684. var (
  38685. err error
  38686. once sync.Once
  38687. value *Wx
  38688. )
  38689. m.oldValue = func(ctx context.Context) (*Wx, error) {
  38690. once.Do(func() {
  38691. if m.done {
  38692. err = errors.New("querying old values post mutation is not allowed")
  38693. } else {
  38694. value, err = m.Client().Wx.Get(ctx, id)
  38695. }
  38696. })
  38697. return value, err
  38698. }
  38699. m.id = &id
  38700. }
  38701. }
  38702. // withWx sets the old Wx of the mutation.
  38703. func withWx(node *Wx) wxOption {
  38704. return func(m *WxMutation) {
  38705. m.oldValue = func(context.Context) (*Wx, error) {
  38706. return node, nil
  38707. }
  38708. m.id = &node.ID
  38709. }
  38710. }
  38711. // Client returns a new `ent.Client` from the mutation. If the mutation was
  38712. // executed in a transaction (ent.Tx), a transactional client is returned.
  38713. func (m WxMutation) Client() *Client {
  38714. client := &Client{config: m.config}
  38715. client.init()
  38716. return client
  38717. }
  38718. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  38719. // it returns an error otherwise.
  38720. func (m WxMutation) Tx() (*Tx, error) {
  38721. if _, ok := m.driver.(*txDriver); !ok {
  38722. return nil, errors.New("ent: mutation is not running in a transaction")
  38723. }
  38724. tx := &Tx{config: m.config}
  38725. tx.init()
  38726. return tx, nil
  38727. }
  38728. // SetID sets the value of the id field. Note that this
  38729. // operation is only accepted on creation of Wx entities.
  38730. func (m *WxMutation) SetID(id uint64) {
  38731. m.id = &id
  38732. }
  38733. // ID returns the ID value in the mutation. Note that the ID is only available
  38734. // if it was provided to the builder or after it was returned from the database.
  38735. func (m *WxMutation) ID() (id uint64, exists bool) {
  38736. if m.id == nil {
  38737. return
  38738. }
  38739. return *m.id, true
  38740. }
  38741. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  38742. // That means, if the mutation is applied within a transaction with an isolation level such
  38743. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  38744. // or updated by the mutation.
  38745. func (m *WxMutation) IDs(ctx context.Context) ([]uint64, error) {
  38746. switch {
  38747. case m.op.Is(OpUpdateOne | OpDeleteOne):
  38748. id, exists := m.ID()
  38749. if exists {
  38750. return []uint64{id}, nil
  38751. }
  38752. fallthrough
  38753. case m.op.Is(OpUpdate | OpDelete):
  38754. return m.Client().Wx.Query().Where(m.predicates...).IDs(ctx)
  38755. default:
  38756. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  38757. }
  38758. }
  38759. // SetCreatedAt sets the "created_at" field.
  38760. func (m *WxMutation) SetCreatedAt(t time.Time) {
  38761. m.created_at = &t
  38762. }
  38763. // CreatedAt returns the value of the "created_at" field in the mutation.
  38764. func (m *WxMutation) CreatedAt() (r time.Time, exists bool) {
  38765. v := m.created_at
  38766. if v == nil {
  38767. return
  38768. }
  38769. return *v, true
  38770. }
  38771. // OldCreatedAt returns the old "created_at" field's value of the Wx entity.
  38772. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  38773. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38774. func (m *WxMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  38775. if !m.op.Is(OpUpdateOne) {
  38776. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  38777. }
  38778. if m.id == nil || m.oldValue == nil {
  38779. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  38780. }
  38781. oldValue, err := m.oldValue(ctx)
  38782. if err != nil {
  38783. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  38784. }
  38785. return oldValue.CreatedAt, nil
  38786. }
  38787. // ResetCreatedAt resets all changes to the "created_at" field.
  38788. func (m *WxMutation) ResetCreatedAt() {
  38789. m.created_at = nil
  38790. }
  38791. // SetUpdatedAt sets the "updated_at" field.
  38792. func (m *WxMutation) SetUpdatedAt(t time.Time) {
  38793. m.updated_at = &t
  38794. }
  38795. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  38796. func (m *WxMutation) UpdatedAt() (r time.Time, exists bool) {
  38797. v := m.updated_at
  38798. if v == nil {
  38799. return
  38800. }
  38801. return *v, true
  38802. }
  38803. // OldUpdatedAt returns the old "updated_at" field's value of the Wx entity.
  38804. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  38805. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38806. func (m *WxMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  38807. if !m.op.Is(OpUpdateOne) {
  38808. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  38809. }
  38810. if m.id == nil || m.oldValue == nil {
  38811. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  38812. }
  38813. oldValue, err := m.oldValue(ctx)
  38814. if err != nil {
  38815. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  38816. }
  38817. return oldValue.UpdatedAt, nil
  38818. }
  38819. // ResetUpdatedAt resets all changes to the "updated_at" field.
  38820. func (m *WxMutation) ResetUpdatedAt() {
  38821. m.updated_at = nil
  38822. }
  38823. // SetStatus sets the "status" field.
  38824. func (m *WxMutation) SetStatus(u uint8) {
  38825. m.status = &u
  38826. m.addstatus = nil
  38827. }
  38828. // Status returns the value of the "status" field in the mutation.
  38829. func (m *WxMutation) Status() (r uint8, exists bool) {
  38830. v := m.status
  38831. if v == nil {
  38832. return
  38833. }
  38834. return *v, true
  38835. }
  38836. // OldStatus returns the old "status" field's value of the Wx entity.
  38837. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  38838. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38839. func (m *WxMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  38840. if !m.op.Is(OpUpdateOne) {
  38841. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  38842. }
  38843. if m.id == nil || m.oldValue == nil {
  38844. return v, errors.New("OldStatus requires an ID field in the mutation")
  38845. }
  38846. oldValue, err := m.oldValue(ctx)
  38847. if err != nil {
  38848. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  38849. }
  38850. return oldValue.Status, nil
  38851. }
  38852. // AddStatus adds u to the "status" field.
  38853. func (m *WxMutation) AddStatus(u int8) {
  38854. if m.addstatus != nil {
  38855. *m.addstatus += u
  38856. } else {
  38857. m.addstatus = &u
  38858. }
  38859. }
  38860. // AddedStatus returns the value that was added to the "status" field in this mutation.
  38861. func (m *WxMutation) AddedStatus() (r int8, exists bool) {
  38862. v := m.addstatus
  38863. if v == nil {
  38864. return
  38865. }
  38866. return *v, true
  38867. }
  38868. // ClearStatus clears the value of the "status" field.
  38869. func (m *WxMutation) ClearStatus() {
  38870. m.status = nil
  38871. m.addstatus = nil
  38872. m.clearedFields[wx.FieldStatus] = struct{}{}
  38873. }
  38874. // StatusCleared returns if the "status" field was cleared in this mutation.
  38875. func (m *WxMutation) StatusCleared() bool {
  38876. _, ok := m.clearedFields[wx.FieldStatus]
  38877. return ok
  38878. }
  38879. // ResetStatus resets all changes to the "status" field.
  38880. func (m *WxMutation) ResetStatus() {
  38881. m.status = nil
  38882. m.addstatus = nil
  38883. delete(m.clearedFields, wx.FieldStatus)
  38884. }
  38885. // SetDeletedAt sets the "deleted_at" field.
  38886. func (m *WxMutation) SetDeletedAt(t time.Time) {
  38887. m.deleted_at = &t
  38888. }
  38889. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  38890. func (m *WxMutation) DeletedAt() (r time.Time, exists bool) {
  38891. v := m.deleted_at
  38892. if v == nil {
  38893. return
  38894. }
  38895. return *v, true
  38896. }
  38897. // OldDeletedAt returns the old "deleted_at" field's value of the Wx entity.
  38898. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  38899. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38900. func (m *WxMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  38901. if !m.op.Is(OpUpdateOne) {
  38902. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  38903. }
  38904. if m.id == nil || m.oldValue == nil {
  38905. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  38906. }
  38907. oldValue, err := m.oldValue(ctx)
  38908. if err != nil {
  38909. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  38910. }
  38911. return oldValue.DeletedAt, nil
  38912. }
  38913. // ClearDeletedAt clears the value of the "deleted_at" field.
  38914. func (m *WxMutation) ClearDeletedAt() {
  38915. m.deleted_at = nil
  38916. m.clearedFields[wx.FieldDeletedAt] = struct{}{}
  38917. }
  38918. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  38919. func (m *WxMutation) DeletedAtCleared() bool {
  38920. _, ok := m.clearedFields[wx.FieldDeletedAt]
  38921. return ok
  38922. }
  38923. // ResetDeletedAt resets all changes to the "deleted_at" field.
  38924. func (m *WxMutation) ResetDeletedAt() {
  38925. m.deleted_at = nil
  38926. delete(m.clearedFields, wx.FieldDeletedAt)
  38927. }
  38928. // SetServerID sets the "server_id" field.
  38929. func (m *WxMutation) SetServerID(u uint64) {
  38930. m.server = &u
  38931. }
  38932. // ServerID returns the value of the "server_id" field in the mutation.
  38933. func (m *WxMutation) ServerID() (r uint64, exists bool) {
  38934. v := m.server
  38935. if v == nil {
  38936. return
  38937. }
  38938. return *v, true
  38939. }
  38940. // OldServerID returns the old "server_id" field's value of the Wx entity.
  38941. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  38942. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38943. func (m *WxMutation) OldServerID(ctx context.Context) (v uint64, err error) {
  38944. if !m.op.Is(OpUpdateOne) {
  38945. return v, errors.New("OldServerID is only allowed on UpdateOne operations")
  38946. }
  38947. if m.id == nil || m.oldValue == nil {
  38948. return v, errors.New("OldServerID requires an ID field in the mutation")
  38949. }
  38950. oldValue, err := m.oldValue(ctx)
  38951. if err != nil {
  38952. return v, fmt.Errorf("querying old value for OldServerID: %w", err)
  38953. }
  38954. return oldValue.ServerID, nil
  38955. }
  38956. // ClearServerID clears the value of the "server_id" field.
  38957. func (m *WxMutation) ClearServerID() {
  38958. m.server = nil
  38959. m.clearedFields[wx.FieldServerID] = struct{}{}
  38960. }
  38961. // ServerIDCleared returns if the "server_id" field was cleared in this mutation.
  38962. func (m *WxMutation) ServerIDCleared() bool {
  38963. _, ok := m.clearedFields[wx.FieldServerID]
  38964. return ok
  38965. }
  38966. // ResetServerID resets all changes to the "server_id" field.
  38967. func (m *WxMutation) ResetServerID() {
  38968. m.server = nil
  38969. delete(m.clearedFields, wx.FieldServerID)
  38970. }
  38971. // SetPort sets the "port" field.
  38972. func (m *WxMutation) SetPort(s string) {
  38973. m.port = &s
  38974. }
  38975. // Port returns the value of the "port" field in the mutation.
  38976. func (m *WxMutation) Port() (r string, exists bool) {
  38977. v := m.port
  38978. if v == nil {
  38979. return
  38980. }
  38981. return *v, true
  38982. }
  38983. // OldPort returns the old "port" field's value of the Wx entity.
  38984. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  38985. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38986. func (m *WxMutation) OldPort(ctx context.Context) (v string, err error) {
  38987. if !m.op.Is(OpUpdateOne) {
  38988. return v, errors.New("OldPort is only allowed on UpdateOne operations")
  38989. }
  38990. if m.id == nil || m.oldValue == nil {
  38991. return v, errors.New("OldPort requires an ID field in the mutation")
  38992. }
  38993. oldValue, err := m.oldValue(ctx)
  38994. if err != nil {
  38995. return v, fmt.Errorf("querying old value for OldPort: %w", err)
  38996. }
  38997. return oldValue.Port, nil
  38998. }
  38999. // ResetPort resets all changes to the "port" field.
  39000. func (m *WxMutation) ResetPort() {
  39001. m.port = nil
  39002. }
  39003. // SetProcessID sets the "process_id" field.
  39004. func (m *WxMutation) SetProcessID(s string) {
  39005. m.process_id = &s
  39006. }
  39007. // ProcessID returns the value of the "process_id" field in the mutation.
  39008. func (m *WxMutation) ProcessID() (r string, exists bool) {
  39009. v := m.process_id
  39010. if v == nil {
  39011. return
  39012. }
  39013. return *v, true
  39014. }
  39015. // OldProcessID returns the old "process_id" field's value of the Wx entity.
  39016. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  39017. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39018. func (m *WxMutation) OldProcessID(ctx context.Context) (v string, err error) {
  39019. if !m.op.Is(OpUpdateOne) {
  39020. return v, errors.New("OldProcessID is only allowed on UpdateOne operations")
  39021. }
  39022. if m.id == nil || m.oldValue == nil {
  39023. return v, errors.New("OldProcessID requires an ID field in the mutation")
  39024. }
  39025. oldValue, err := m.oldValue(ctx)
  39026. if err != nil {
  39027. return v, fmt.Errorf("querying old value for OldProcessID: %w", err)
  39028. }
  39029. return oldValue.ProcessID, nil
  39030. }
  39031. // ResetProcessID resets all changes to the "process_id" field.
  39032. func (m *WxMutation) ResetProcessID() {
  39033. m.process_id = nil
  39034. }
  39035. // SetCallback sets the "callback" field.
  39036. func (m *WxMutation) SetCallback(s string) {
  39037. m.callback = &s
  39038. }
  39039. // Callback returns the value of the "callback" field in the mutation.
  39040. func (m *WxMutation) Callback() (r string, exists bool) {
  39041. v := m.callback
  39042. if v == nil {
  39043. return
  39044. }
  39045. return *v, true
  39046. }
  39047. // OldCallback returns the old "callback" field's value of the Wx entity.
  39048. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  39049. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39050. func (m *WxMutation) OldCallback(ctx context.Context) (v string, err error) {
  39051. if !m.op.Is(OpUpdateOne) {
  39052. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  39053. }
  39054. if m.id == nil || m.oldValue == nil {
  39055. return v, errors.New("OldCallback requires an ID field in the mutation")
  39056. }
  39057. oldValue, err := m.oldValue(ctx)
  39058. if err != nil {
  39059. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  39060. }
  39061. return oldValue.Callback, nil
  39062. }
  39063. // ResetCallback resets all changes to the "callback" field.
  39064. func (m *WxMutation) ResetCallback() {
  39065. m.callback = nil
  39066. }
  39067. // SetWxid sets the "wxid" field.
  39068. func (m *WxMutation) SetWxid(s string) {
  39069. m.wxid = &s
  39070. }
  39071. // Wxid returns the value of the "wxid" field in the mutation.
  39072. func (m *WxMutation) Wxid() (r string, exists bool) {
  39073. v := m.wxid
  39074. if v == nil {
  39075. return
  39076. }
  39077. return *v, true
  39078. }
  39079. // OldWxid returns the old "wxid" field's value of the Wx entity.
  39080. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  39081. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39082. func (m *WxMutation) OldWxid(ctx context.Context) (v string, err error) {
  39083. if !m.op.Is(OpUpdateOne) {
  39084. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  39085. }
  39086. if m.id == nil || m.oldValue == nil {
  39087. return v, errors.New("OldWxid requires an ID field in the mutation")
  39088. }
  39089. oldValue, err := m.oldValue(ctx)
  39090. if err != nil {
  39091. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  39092. }
  39093. return oldValue.Wxid, nil
  39094. }
  39095. // ResetWxid resets all changes to the "wxid" field.
  39096. func (m *WxMutation) ResetWxid() {
  39097. m.wxid = nil
  39098. }
  39099. // SetAccount sets the "account" field.
  39100. func (m *WxMutation) SetAccount(s string) {
  39101. m.account = &s
  39102. }
  39103. // Account returns the value of the "account" field in the mutation.
  39104. func (m *WxMutation) Account() (r string, exists bool) {
  39105. v := m.account
  39106. if v == nil {
  39107. return
  39108. }
  39109. return *v, true
  39110. }
  39111. // OldAccount returns the old "account" field's value of the Wx entity.
  39112. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  39113. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39114. func (m *WxMutation) OldAccount(ctx context.Context) (v string, err error) {
  39115. if !m.op.Is(OpUpdateOne) {
  39116. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  39117. }
  39118. if m.id == nil || m.oldValue == nil {
  39119. return v, errors.New("OldAccount requires an ID field in the mutation")
  39120. }
  39121. oldValue, err := m.oldValue(ctx)
  39122. if err != nil {
  39123. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  39124. }
  39125. return oldValue.Account, nil
  39126. }
  39127. // ResetAccount resets all changes to the "account" field.
  39128. func (m *WxMutation) ResetAccount() {
  39129. m.account = nil
  39130. }
  39131. // SetNickname sets the "nickname" field.
  39132. func (m *WxMutation) SetNickname(s string) {
  39133. m.nickname = &s
  39134. }
  39135. // Nickname returns the value of the "nickname" field in the mutation.
  39136. func (m *WxMutation) Nickname() (r string, exists bool) {
  39137. v := m.nickname
  39138. if v == nil {
  39139. return
  39140. }
  39141. return *v, true
  39142. }
  39143. // OldNickname returns the old "nickname" field's value of the Wx entity.
  39144. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  39145. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39146. func (m *WxMutation) OldNickname(ctx context.Context) (v string, err error) {
  39147. if !m.op.Is(OpUpdateOne) {
  39148. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  39149. }
  39150. if m.id == nil || m.oldValue == nil {
  39151. return v, errors.New("OldNickname requires an ID field in the mutation")
  39152. }
  39153. oldValue, err := m.oldValue(ctx)
  39154. if err != nil {
  39155. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  39156. }
  39157. return oldValue.Nickname, nil
  39158. }
  39159. // ResetNickname resets all changes to the "nickname" field.
  39160. func (m *WxMutation) ResetNickname() {
  39161. m.nickname = nil
  39162. }
  39163. // SetTel sets the "tel" field.
  39164. func (m *WxMutation) SetTel(s string) {
  39165. m.tel = &s
  39166. }
  39167. // Tel returns the value of the "tel" field in the mutation.
  39168. func (m *WxMutation) Tel() (r string, exists bool) {
  39169. v := m.tel
  39170. if v == nil {
  39171. return
  39172. }
  39173. return *v, true
  39174. }
  39175. // OldTel returns the old "tel" field's value of the Wx entity.
  39176. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  39177. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39178. func (m *WxMutation) OldTel(ctx context.Context) (v string, err error) {
  39179. if !m.op.Is(OpUpdateOne) {
  39180. return v, errors.New("OldTel is only allowed on UpdateOne operations")
  39181. }
  39182. if m.id == nil || m.oldValue == nil {
  39183. return v, errors.New("OldTel requires an ID field in the mutation")
  39184. }
  39185. oldValue, err := m.oldValue(ctx)
  39186. if err != nil {
  39187. return v, fmt.Errorf("querying old value for OldTel: %w", err)
  39188. }
  39189. return oldValue.Tel, nil
  39190. }
  39191. // ResetTel resets all changes to the "tel" field.
  39192. func (m *WxMutation) ResetTel() {
  39193. m.tel = nil
  39194. }
  39195. // SetHeadBig sets the "head_big" field.
  39196. func (m *WxMutation) SetHeadBig(s string) {
  39197. m.head_big = &s
  39198. }
  39199. // HeadBig returns the value of the "head_big" field in the mutation.
  39200. func (m *WxMutation) HeadBig() (r string, exists bool) {
  39201. v := m.head_big
  39202. if v == nil {
  39203. return
  39204. }
  39205. return *v, true
  39206. }
  39207. // OldHeadBig returns the old "head_big" field's value of the Wx entity.
  39208. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  39209. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39210. func (m *WxMutation) OldHeadBig(ctx context.Context) (v string, err error) {
  39211. if !m.op.Is(OpUpdateOne) {
  39212. return v, errors.New("OldHeadBig is only allowed on UpdateOne operations")
  39213. }
  39214. if m.id == nil || m.oldValue == nil {
  39215. return v, errors.New("OldHeadBig requires an ID field in the mutation")
  39216. }
  39217. oldValue, err := m.oldValue(ctx)
  39218. if err != nil {
  39219. return v, fmt.Errorf("querying old value for OldHeadBig: %w", err)
  39220. }
  39221. return oldValue.HeadBig, nil
  39222. }
  39223. // ResetHeadBig resets all changes to the "head_big" field.
  39224. func (m *WxMutation) ResetHeadBig() {
  39225. m.head_big = nil
  39226. }
  39227. // SetOrganizationID sets the "organization_id" field.
  39228. func (m *WxMutation) SetOrganizationID(u uint64) {
  39229. m.organization_id = &u
  39230. m.addorganization_id = nil
  39231. }
  39232. // OrganizationID returns the value of the "organization_id" field in the mutation.
  39233. func (m *WxMutation) OrganizationID() (r uint64, exists bool) {
  39234. v := m.organization_id
  39235. if v == nil {
  39236. return
  39237. }
  39238. return *v, true
  39239. }
  39240. // OldOrganizationID returns the old "organization_id" field's value of the Wx entity.
  39241. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  39242. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39243. func (m *WxMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  39244. if !m.op.Is(OpUpdateOne) {
  39245. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  39246. }
  39247. if m.id == nil || m.oldValue == nil {
  39248. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  39249. }
  39250. oldValue, err := m.oldValue(ctx)
  39251. if err != nil {
  39252. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  39253. }
  39254. return oldValue.OrganizationID, nil
  39255. }
  39256. // AddOrganizationID adds u to the "organization_id" field.
  39257. func (m *WxMutation) AddOrganizationID(u int64) {
  39258. if m.addorganization_id != nil {
  39259. *m.addorganization_id += u
  39260. } else {
  39261. m.addorganization_id = &u
  39262. }
  39263. }
  39264. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  39265. func (m *WxMutation) AddedOrganizationID() (r int64, exists bool) {
  39266. v := m.addorganization_id
  39267. if v == nil {
  39268. return
  39269. }
  39270. return *v, true
  39271. }
  39272. // ClearOrganizationID clears the value of the "organization_id" field.
  39273. func (m *WxMutation) ClearOrganizationID() {
  39274. m.organization_id = nil
  39275. m.addorganization_id = nil
  39276. m.clearedFields[wx.FieldOrganizationID] = struct{}{}
  39277. }
  39278. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  39279. func (m *WxMutation) OrganizationIDCleared() bool {
  39280. _, ok := m.clearedFields[wx.FieldOrganizationID]
  39281. return ok
  39282. }
  39283. // ResetOrganizationID resets all changes to the "organization_id" field.
  39284. func (m *WxMutation) ResetOrganizationID() {
  39285. m.organization_id = nil
  39286. m.addorganization_id = nil
  39287. delete(m.clearedFields, wx.FieldOrganizationID)
  39288. }
  39289. // SetAgentID sets the "agent_id" field.
  39290. func (m *WxMutation) SetAgentID(u uint64) {
  39291. m.agent = &u
  39292. }
  39293. // AgentID returns the value of the "agent_id" field in the mutation.
  39294. func (m *WxMutation) AgentID() (r uint64, exists bool) {
  39295. v := m.agent
  39296. if v == nil {
  39297. return
  39298. }
  39299. return *v, true
  39300. }
  39301. // OldAgentID returns the old "agent_id" field's value of the Wx entity.
  39302. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  39303. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39304. func (m *WxMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  39305. if !m.op.Is(OpUpdateOne) {
  39306. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  39307. }
  39308. if m.id == nil || m.oldValue == nil {
  39309. return v, errors.New("OldAgentID requires an ID field in the mutation")
  39310. }
  39311. oldValue, err := m.oldValue(ctx)
  39312. if err != nil {
  39313. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  39314. }
  39315. return oldValue.AgentID, nil
  39316. }
  39317. // ResetAgentID resets all changes to the "agent_id" field.
  39318. func (m *WxMutation) ResetAgentID() {
  39319. m.agent = nil
  39320. }
  39321. // SetAPIBase sets the "api_base" field.
  39322. func (m *WxMutation) SetAPIBase(s string) {
  39323. m.api_base = &s
  39324. }
  39325. // APIBase returns the value of the "api_base" field in the mutation.
  39326. func (m *WxMutation) APIBase() (r string, exists bool) {
  39327. v := m.api_base
  39328. if v == nil {
  39329. return
  39330. }
  39331. return *v, true
  39332. }
  39333. // OldAPIBase returns the old "api_base" field's value of the Wx entity.
  39334. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  39335. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39336. func (m *WxMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  39337. if !m.op.Is(OpUpdateOne) {
  39338. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  39339. }
  39340. if m.id == nil || m.oldValue == nil {
  39341. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  39342. }
  39343. oldValue, err := m.oldValue(ctx)
  39344. if err != nil {
  39345. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  39346. }
  39347. return oldValue.APIBase, nil
  39348. }
  39349. // ClearAPIBase clears the value of the "api_base" field.
  39350. func (m *WxMutation) ClearAPIBase() {
  39351. m.api_base = nil
  39352. m.clearedFields[wx.FieldAPIBase] = struct{}{}
  39353. }
  39354. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  39355. func (m *WxMutation) APIBaseCleared() bool {
  39356. _, ok := m.clearedFields[wx.FieldAPIBase]
  39357. return ok
  39358. }
  39359. // ResetAPIBase resets all changes to the "api_base" field.
  39360. func (m *WxMutation) ResetAPIBase() {
  39361. m.api_base = nil
  39362. delete(m.clearedFields, wx.FieldAPIBase)
  39363. }
  39364. // SetAPIKey sets the "api_key" field.
  39365. func (m *WxMutation) SetAPIKey(s string) {
  39366. m.api_key = &s
  39367. }
  39368. // APIKey returns the value of the "api_key" field in the mutation.
  39369. func (m *WxMutation) APIKey() (r string, exists bool) {
  39370. v := m.api_key
  39371. if v == nil {
  39372. return
  39373. }
  39374. return *v, true
  39375. }
  39376. // OldAPIKey returns the old "api_key" field's value of the Wx entity.
  39377. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  39378. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39379. func (m *WxMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  39380. if !m.op.Is(OpUpdateOne) {
  39381. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  39382. }
  39383. if m.id == nil || m.oldValue == nil {
  39384. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  39385. }
  39386. oldValue, err := m.oldValue(ctx)
  39387. if err != nil {
  39388. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  39389. }
  39390. return oldValue.APIKey, nil
  39391. }
  39392. // ClearAPIKey clears the value of the "api_key" field.
  39393. func (m *WxMutation) ClearAPIKey() {
  39394. m.api_key = nil
  39395. m.clearedFields[wx.FieldAPIKey] = struct{}{}
  39396. }
  39397. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  39398. func (m *WxMutation) APIKeyCleared() bool {
  39399. _, ok := m.clearedFields[wx.FieldAPIKey]
  39400. return ok
  39401. }
  39402. // ResetAPIKey resets all changes to the "api_key" field.
  39403. func (m *WxMutation) ResetAPIKey() {
  39404. m.api_key = nil
  39405. delete(m.clearedFields, wx.FieldAPIKey)
  39406. }
  39407. // SetAllowList sets the "allow_list" field.
  39408. func (m *WxMutation) SetAllowList(s []string) {
  39409. m.allow_list = &s
  39410. m.appendallow_list = nil
  39411. }
  39412. // AllowList returns the value of the "allow_list" field in the mutation.
  39413. func (m *WxMutation) AllowList() (r []string, exists bool) {
  39414. v := m.allow_list
  39415. if v == nil {
  39416. return
  39417. }
  39418. return *v, true
  39419. }
  39420. // OldAllowList returns the old "allow_list" field's value of the Wx entity.
  39421. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  39422. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39423. func (m *WxMutation) OldAllowList(ctx context.Context) (v []string, err error) {
  39424. if !m.op.Is(OpUpdateOne) {
  39425. return v, errors.New("OldAllowList is only allowed on UpdateOne operations")
  39426. }
  39427. if m.id == nil || m.oldValue == nil {
  39428. return v, errors.New("OldAllowList requires an ID field in the mutation")
  39429. }
  39430. oldValue, err := m.oldValue(ctx)
  39431. if err != nil {
  39432. return v, fmt.Errorf("querying old value for OldAllowList: %w", err)
  39433. }
  39434. return oldValue.AllowList, nil
  39435. }
  39436. // AppendAllowList adds s to the "allow_list" field.
  39437. func (m *WxMutation) AppendAllowList(s []string) {
  39438. m.appendallow_list = append(m.appendallow_list, s...)
  39439. }
  39440. // AppendedAllowList returns the list of values that were appended to the "allow_list" field in this mutation.
  39441. func (m *WxMutation) AppendedAllowList() ([]string, bool) {
  39442. if len(m.appendallow_list) == 0 {
  39443. return nil, false
  39444. }
  39445. return m.appendallow_list, true
  39446. }
  39447. // ResetAllowList resets all changes to the "allow_list" field.
  39448. func (m *WxMutation) ResetAllowList() {
  39449. m.allow_list = nil
  39450. m.appendallow_list = nil
  39451. }
  39452. // SetGroupAllowList sets the "group_allow_list" field.
  39453. func (m *WxMutation) SetGroupAllowList(s []string) {
  39454. m.group_allow_list = &s
  39455. m.appendgroup_allow_list = nil
  39456. }
  39457. // GroupAllowList returns the value of the "group_allow_list" field in the mutation.
  39458. func (m *WxMutation) GroupAllowList() (r []string, exists bool) {
  39459. v := m.group_allow_list
  39460. if v == nil {
  39461. return
  39462. }
  39463. return *v, true
  39464. }
  39465. // OldGroupAllowList returns the old "group_allow_list" field's value of the Wx entity.
  39466. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  39467. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39468. func (m *WxMutation) OldGroupAllowList(ctx context.Context) (v []string, err error) {
  39469. if !m.op.Is(OpUpdateOne) {
  39470. return v, errors.New("OldGroupAllowList is only allowed on UpdateOne operations")
  39471. }
  39472. if m.id == nil || m.oldValue == nil {
  39473. return v, errors.New("OldGroupAllowList requires an ID field in the mutation")
  39474. }
  39475. oldValue, err := m.oldValue(ctx)
  39476. if err != nil {
  39477. return v, fmt.Errorf("querying old value for OldGroupAllowList: %w", err)
  39478. }
  39479. return oldValue.GroupAllowList, nil
  39480. }
  39481. // AppendGroupAllowList adds s to the "group_allow_list" field.
  39482. func (m *WxMutation) AppendGroupAllowList(s []string) {
  39483. m.appendgroup_allow_list = append(m.appendgroup_allow_list, s...)
  39484. }
  39485. // AppendedGroupAllowList returns the list of values that were appended to the "group_allow_list" field in this mutation.
  39486. func (m *WxMutation) AppendedGroupAllowList() ([]string, bool) {
  39487. if len(m.appendgroup_allow_list) == 0 {
  39488. return nil, false
  39489. }
  39490. return m.appendgroup_allow_list, true
  39491. }
  39492. // ResetGroupAllowList resets all changes to the "group_allow_list" field.
  39493. func (m *WxMutation) ResetGroupAllowList() {
  39494. m.group_allow_list = nil
  39495. m.appendgroup_allow_list = nil
  39496. }
  39497. // SetBlockList sets the "block_list" field.
  39498. func (m *WxMutation) SetBlockList(s []string) {
  39499. m.block_list = &s
  39500. m.appendblock_list = nil
  39501. }
  39502. // BlockList returns the value of the "block_list" field in the mutation.
  39503. func (m *WxMutation) BlockList() (r []string, exists bool) {
  39504. v := m.block_list
  39505. if v == nil {
  39506. return
  39507. }
  39508. return *v, true
  39509. }
  39510. // OldBlockList returns the old "block_list" field's value of the Wx entity.
  39511. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  39512. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39513. func (m *WxMutation) OldBlockList(ctx context.Context) (v []string, err error) {
  39514. if !m.op.Is(OpUpdateOne) {
  39515. return v, errors.New("OldBlockList is only allowed on UpdateOne operations")
  39516. }
  39517. if m.id == nil || m.oldValue == nil {
  39518. return v, errors.New("OldBlockList requires an ID field in the mutation")
  39519. }
  39520. oldValue, err := m.oldValue(ctx)
  39521. if err != nil {
  39522. return v, fmt.Errorf("querying old value for OldBlockList: %w", err)
  39523. }
  39524. return oldValue.BlockList, nil
  39525. }
  39526. // AppendBlockList adds s to the "block_list" field.
  39527. func (m *WxMutation) AppendBlockList(s []string) {
  39528. m.appendblock_list = append(m.appendblock_list, s...)
  39529. }
  39530. // AppendedBlockList returns the list of values that were appended to the "block_list" field in this mutation.
  39531. func (m *WxMutation) AppendedBlockList() ([]string, bool) {
  39532. if len(m.appendblock_list) == 0 {
  39533. return nil, false
  39534. }
  39535. return m.appendblock_list, true
  39536. }
  39537. // ResetBlockList resets all changes to the "block_list" field.
  39538. func (m *WxMutation) ResetBlockList() {
  39539. m.block_list = nil
  39540. m.appendblock_list = nil
  39541. }
  39542. // SetGroupBlockList sets the "group_block_list" field.
  39543. func (m *WxMutation) SetGroupBlockList(s []string) {
  39544. m.group_block_list = &s
  39545. m.appendgroup_block_list = nil
  39546. }
  39547. // GroupBlockList returns the value of the "group_block_list" field in the mutation.
  39548. func (m *WxMutation) GroupBlockList() (r []string, exists bool) {
  39549. v := m.group_block_list
  39550. if v == nil {
  39551. return
  39552. }
  39553. return *v, true
  39554. }
  39555. // OldGroupBlockList returns the old "group_block_list" field's value of the Wx entity.
  39556. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  39557. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39558. func (m *WxMutation) OldGroupBlockList(ctx context.Context) (v []string, err error) {
  39559. if !m.op.Is(OpUpdateOne) {
  39560. return v, errors.New("OldGroupBlockList is only allowed on UpdateOne operations")
  39561. }
  39562. if m.id == nil || m.oldValue == nil {
  39563. return v, errors.New("OldGroupBlockList requires an ID field in the mutation")
  39564. }
  39565. oldValue, err := m.oldValue(ctx)
  39566. if err != nil {
  39567. return v, fmt.Errorf("querying old value for OldGroupBlockList: %w", err)
  39568. }
  39569. return oldValue.GroupBlockList, nil
  39570. }
  39571. // AppendGroupBlockList adds s to the "group_block_list" field.
  39572. func (m *WxMutation) AppendGroupBlockList(s []string) {
  39573. m.appendgroup_block_list = append(m.appendgroup_block_list, s...)
  39574. }
  39575. // AppendedGroupBlockList returns the list of values that were appended to the "group_block_list" field in this mutation.
  39576. func (m *WxMutation) AppendedGroupBlockList() ([]string, bool) {
  39577. if len(m.appendgroup_block_list) == 0 {
  39578. return nil, false
  39579. }
  39580. return m.appendgroup_block_list, true
  39581. }
  39582. // ResetGroupBlockList resets all changes to the "group_block_list" field.
  39583. func (m *WxMutation) ResetGroupBlockList() {
  39584. m.group_block_list = nil
  39585. m.appendgroup_block_list = nil
  39586. }
  39587. // ClearServer clears the "server" edge to the Server entity.
  39588. func (m *WxMutation) ClearServer() {
  39589. m.clearedserver = true
  39590. m.clearedFields[wx.FieldServerID] = struct{}{}
  39591. }
  39592. // ServerCleared reports if the "server" edge to the Server entity was cleared.
  39593. func (m *WxMutation) ServerCleared() bool {
  39594. return m.ServerIDCleared() || m.clearedserver
  39595. }
  39596. // ServerIDs returns the "server" edge IDs in the mutation.
  39597. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  39598. // ServerID instead. It exists only for internal usage by the builders.
  39599. func (m *WxMutation) ServerIDs() (ids []uint64) {
  39600. if id := m.server; id != nil {
  39601. ids = append(ids, *id)
  39602. }
  39603. return
  39604. }
  39605. // ResetServer resets all changes to the "server" edge.
  39606. func (m *WxMutation) ResetServer() {
  39607. m.server = nil
  39608. m.clearedserver = false
  39609. }
  39610. // ClearAgent clears the "agent" edge to the Agent entity.
  39611. func (m *WxMutation) ClearAgent() {
  39612. m.clearedagent = true
  39613. m.clearedFields[wx.FieldAgentID] = struct{}{}
  39614. }
  39615. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  39616. func (m *WxMutation) AgentCleared() bool {
  39617. return m.clearedagent
  39618. }
  39619. // AgentIDs returns the "agent" edge IDs in the mutation.
  39620. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  39621. // AgentID instead. It exists only for internal usage by the builders.
  39622. func (m *WxMutation) AgentIDs() (ids []uint64) {
  39623. if id := m.agent; id != nil {
  39624. ids = append(ids, *id)
  39625. }
  39626. return
  39627. }
  39628. // ResetAgent resets all changes to the "agent" edge.
  39629. func (m *WxMutation) ResetAgent() {
  39630. m.agent = nil
  39631. m.clearedagent = false
  39632. }
  39633. // Where appends a list predicates to the WxMutation builder.
  39634. func (m *WxMutation) Where(ps ...predicate.Wx) {
  39635. m.predicates = append(m.predicates, ps...)
  39636. }
  39637. // WhereP appends storage-level predicates to the WxMutation builder. Using this method,
  39638. // users can use type-assertion to append predicates that do not depend on any generated package.
  39639. func (m *WxMutation) WhereP(ps ...func(*sql.Selector)) {
  39640. p := make([]predicate.Wx, len(ps))
  39641. for i := range ps {
  39642. p[i] = ps[i]
  39643. }
  39644. m.Where(p...)
  39645. }
  39646. // Op returns the operation name.
  39647. func (m *WxMutation) Op() Op {
  39648. return m.op
  39649. }
  39650. // SetOp allows setting the mutation operation.
  39651. func (m *WxMutation) SetOp(op Op) {
  39652. m.op = op
  39653. }
  39654. // Type returns the node type of this mutation (Wx).
  39655. func (m *WxMutation) Type() string {
  39656. return m.typ
  39657. }
  39658. // Fields returns all fields that were changed during this mutation. Note that in
  39659. // order to get all numeric fields that were incremented/decremented, call
  39660. // AddedFields().
  39661. func (m *WxMutation) Fields() []string {
  39662. fields := make([]string, 0, 21)
  39663. if m.created_at != nil {
  39664. fields = append(fields, wx.FieldCreatedAt)
  39665. }
  39666. if m.updated_at != nil {
  39667. fields = append(fields, wx.FieldUpdatedAt)
  39668. }
  39669. if m.status != nil {
  39670. fields = append(fields, wx.FieldStatus)
  39671. }
  39672. if m.deleted_at != nil {
  39673. fields = append(fields, wx.FieldDeletedAt)
  39674. }
  39675. if m.server != nil {
  39676. fields = append(fields, wx.FieldServerID)
  39677. }
  39678. if m.port != nil {
  39679. fields = append(fields, wx.FieldPort)
  39680. }
  39681. if m.process_id != nil {
  39682. fields = append(fields, wx.FieldProcessID)
  39683. }
  39684. if m.callback != nil {
  39685. fields = append(fields, wx.FieldCallback)
  39686. }
  39687. if m.wxid != nil {
  39688. fields = append(fields, wx.FieldWxid)
  39689. }
  39690. if m.account != nil {
  39691. fields = append(fields, wx.FieldAccount)
  39692. }
  39693. if m.nickname != nil {
  39694. fields = append(fields, wx.FieldNickname)
  39695. }
  39696. if m.tel != nil {
  39697. fields = append(fields, wx.FieldTel)
  39698. }
  39699. if m.head_big != nil {
  39700. fields = append(fields, wx.FieldHeadBig)
  39701. }
  39702. if m.organization_id != nil {
  39703. fields = append(fields, wx.FieldOrganizationID)
  39704. }
  39705. if m.agent != nil {
  39706. fields = append(fields, wx.FieldAgentID)
  39707. }
  39708. if m.api_base != nil {
  39709. fields = append(fields, wx.FieldAPIBase)
  39710. }
  39711. if m.api_key != nil {
  39712. fields = append(fields, wx.FieldAPIKey)
  39713. }
  39714. if m.allow_list != nil {
  39715. fields = append(fields, wx.FieldAllowList)
  39716. }
  39717. if m.group_allow_list != nil {
  39718. fields = append(fields, wx.FieldGroupAllowList)
  39719. }
  39720. if m.block_list != nil {
  39721. fields = append(fields, wx.FieldBlockList)
  39722. }
  39723. if m.group_block_list != nil {
  39724. fields = append(fields, wx.FieldGroupBlockList)
  39725. }
  39726. return fields
  39727. }
  39728. // Field returns the value of a field with the given name. The second boolean
  39729. // return value indicates that this field was not set, or was not defined in the
  39730. // schema.
  39731. func (m *WxMutation) Field(name string) (ent.Value, bool) {
  39732. switch name {
  39733. case wx.FieldCreatedAt:
  39734. return m.CreatedAt()
  39735. case wx.FieldUpdatedAt:
  39736. return m.UpdatedAt()
  39737. case wx.FieldStatus:
  39738. return m.Status()
  39739. case wx.FieldDeletedAt:
  39740. return m.DeletedAt()
  39741. case wx.FieldServerID:
  39742. return m.ServerID()
  39743. case wx.FieldPort:
  39744. return m.Port()
  39745. case wx.FieldProcessID:
  39746. return m.ProcessID()
  39747. case wx.FieldCallback:
  39748. return m.Callback()
  39749. case wx.FieldWxid:
  39750. return m.Wxid()
  39751. case wx.FieldAccount:
  39752. return m.Account()
  39753. case wx.FieldNickname:
  39754. return m.Nickname()
  39755. case wx.FieldTel:
  39756. return m.Tel()
  39757. case wx.FieldHeadBig:
  39758. return m.HeadBig()
  39759. case wx.FieldOrganizationID:
  39760. return m.OrganizationID()
  39761. case wx.FieldAgentID:
  39762. return m.AgentID()
  39763. case wx.FieldAPIBase:
  39764. return m.APIBase()
  39765. case wx.FieldAPIKey:
  39766. return m.APIKey()
  39767. case wx.FieldAllowList:
  39768. return m.AllowList()
  39769. case wx.FieldGroupAllowList:
  39770. return m.GroupAllowList()
  39771. case wx.FieldBlockList:
  39772. return m.BlockList()
  39773. case wx.FieldGroupBlockList:
  39774. return m.GroupBlockList()
  39775. }
  39776. return nil, false
  39777. }
  39778. // OldField returns the old value of the field from the database. An error is
  39779. // returned if the mutation operation is not UpdateOne, or the query to the
  39780. // database failed.
  39781. func (m *WxMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  39782. switch name {
  39783. case wx.FieldCreatedAt:
  39784. return m.OldCreatedAt(ctx)
  39785. case wx.FieldUpdatedAt:
  39786. return m.OldUpdatedAt(ctx)
  39787. case wx.FieldStatus:
  39788. return m.OldStatus(ctx)
  39789. case wx.FieldDeletedAt:
  39790. return m.OldDeletedAt(ctx)
  39791. case wx.FieldServerID:
  39792. return m.OldServerID(ctx)
  39793. case wx.FieldPort:
  39794. return m.OldPort(ctx)
  39795. case wx.FieldProcessID:
  39796. return m.OldProcessID(ctx)
  39797. case wx.FieldCallback:
  39798. return m.OldCallback(ctx)
  39799. case wx.FieldWxid:
  39800. return m.OldWxid(ctx)
  39801. case wx.FieldAccount:
  39802. return m.OldAccount(ctx)
  39803. case wx.FieldNickname:
  39804. return m.OldNickname(ctx)
  39805. case wx.FieldTel:
  39806. return m.OldTel(ctx)
  39807. case wx.FieldHeadBig:
  39808. return m.OldHeadBig(ctx)
  39809. case wx.FieldOrganizationID:
  39810. return m.OldOrganizationID(ctx)
  39811. case wx.FieldAgentID:
  39812. return m.OldAgentID(ctx)
  39813. case wx.FieldAPIBase:
  39814. return m.OldAPIBase(ctx)
  39815. case wx.FieldAPIKey:
  39816. return m.OldAPIKey(ctx)
  39817. case wx.FieldAllowList:
  39818. return m.OldAllowList(ctx)
  39819. case wx.FieldGroupAllowList:
  39820. return m.OldGroupAllowList(ctx)
  39821. case wx.FieldBlockList:
  39822. return m.OldBlockList(ctx)
  39823. case wx.FieldGroupBlockList:
  39824. return m.OldGroupBlockList(ctx)
  39825. }
  39826. return nil, fmt.Errorf("unknown Wx field %s", name)
  39827. }
  39828. // SetField sets the value of a field with the given name. It returns an error if
  39829. // the field is not defined in the schema, or if the type mismatched the field
  39830. // type.
  39831. func (m *WxMutation) SetField(name string, value ent.Value) error {
  39832. switch name {
  39833. case wx.FieldCreatedAt:
  39834. v, ok := value.(time.Time)
  39835. if !ok {
  39836. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39837. }
  39838. m.SetCreatedAt(v)
  39839. return nil
  39840. case wx.FieldUpdatedAt:
  39841. v, ok := value.(time.Time)
  39842. if !ok {
  39843. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39844. }
  39845. m.SetUpdatedAt(v)
  39846. return nil
  39847. case wx.FieldStatus:
  39848. v, ok := value.(uint8)
  39849. if !ok {
  39850. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39851. }
  39852. m.SetStatus(v)
  39853. return nil
  39854. case wx.FieldDeletedAt:
  39855. v, ok := value.(time.Time)
  39856. if !ok {
  39857. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39858. }
  39859. m.SetDeletedAt(v)
  39860. return nil
  39861. case wx.FieldServerID:
  39862. v, ok := value.(uint64)
  39863. if !ok {
  39864. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39865. }
  39866. m.SetServerID(v)
  39867. return nil
  39868. case wx.FieldPort:
  39869. v, ok := value.(string)
  39870. if !ok {
  39871. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39872. }
  39873. m.SetPort(v)
  39874. return nil
  39875. case wx.FieldProcessID:
  39876. v, ok := value.(string)
  39877. if !ok {
  39878. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39879. }
  39880. m.SetProcessID(v)
  39881. return nil
  39882. case wx.FieldCallback:
  39883. v, ok := value.(string)
  39884. if !ok {
  39885. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39886. }
  39887. m.SetCallback(v)
  39888. return nil
  39889. case wx.FieldWxid:
  39890. v, ok := value.(string)
  39891. if !ok {
  39892. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39893. }
  39894. m.SetWxid(v)
  39895. return nil
  39896. case wx.FieldAccount:
  39897. v, ok := value.(string)
  39898. if !ok {
  39899. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39900. }
  39901. m.SetAccount(v)
  39902. return nil
  39903. case wx.FieldNickname:
  39904. v, ok := value.(string)
  39905. if !ok {
  39906. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39907. }
  39908. m.SetNickname(v)
  39909. return nil
  39910. case wx.FieldTel:
  39911. v, ok := value.(string)
  39912. if !ok {
  39913. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39914. }
  39915. m.SetTel(v)
  39916. return nil
  39917. case wx.FieldHeadBig:
  39918. v, ok := value.(string)
  39919. if !ok {
  39920. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39921. }
  39922. m.SetHeadBig(v)
  39923. return nil
  39924. case wx.FieldOrganizationID:
  39925. v, ok := value.(uint64)
  39926. if !ok {
  39927. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39928. }
  39929. m.SetOrganizationID(v)
  39930. return nil
  39931. case wx.FieldAgentID:
  39932. v, ok := value.(uint64)
  39933. if !ok {
  39934. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39935. }
  39936. m.SetAgentID(v)
  39937. return nil
  39938. case wx.FieldAPIBase:
  39939. v, ok := value.(string)
  39940. if !ok {
  39941. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39942. }
  39943. m.SetAPIBase(v)
  39944. return nil
  39945. case wx.FieldAPIKey:
  39946. v, ok := value.(string)
  39947. if !ok {
  39948. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39949. }
  39950. m.SetAPIKey(v)
  39951. return nil
  39952. case wx.FieldAllowList:
  39953. v, ok := value.([]string)
  39954. if !ok {
  39955. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39956. }
  39957. m.SetAllowList(v)
  39958. return nil
  39959. case wx.FieldGroupAllowList:
  39960. v, ok := value.([]string)
  39961. if !ok {
  39962. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39963. }
  39964. m.SetGroupAllowList(v)
  39965. return nil
  39966. case wx.FieldBlockList:
  39967. v, ok := value.([]string)
  39968. if !ok {
  39969. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39970. }
  39971. m.SetBlockList(v)
  39972. return nil
  39973. case wx.FieldGroupBlockList:
  39974. v, ok := value.([]string)
  39975. if !ok {
  39976. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39977. }
  39978. m.SetGroupBlockList(v)
  39979. return nil
  39980. }
  39981. return fmt.Errorf("unknown Wx field %s", name)
  39982. }
  39983. // AddedFields returns all numeric fields that were incremented/decremented during
  39984. // this mutation.
  39985. func (m *WxMutation) AddedFields() []string {
  39986. var fields []string
  39987. if m.addstatus != nil {
  39988. fields = append(fields, wx.FieldStatus)
  39989. }
  39990. if m.addorganization_id != nil {
  39991. fields = append(fields, wx.FieldOrganizationID)
  39992. }
  39993. return fields
  39994. }
  39995. // AddedField returns the numeric value that was incremented/decremented on a field
  39996. // with the given name. The second boolean return value indicates that this field
  39997. // was not set, or was not defined in the schema.
  39998. func (m *WxMutation) AddedField(name string) (ent.Value, bool) {
  39999. switch name {
  40000. case wx.FieldStatus:
  40001. return m.AddedStatus()
  40002. case wx.FieldOrganizationID:
  40003. return m.AddedOrganizationID()
  40004. }
  40005. return nil, false
  40006. }
  40007. // AddField adds the value to the field with the given name. It returns an error if
  40008. // the field is not defined in the schema, or if the type mismatched the field
  40009. // type.
  40010. func (m *WxMutation) AddField(name string, value ent.Value) error {
  40011. switch name {
  40012. case wx.FieldStatus:
  40013. v, ok := value.(int8)
  40014. if !ok {
  40015. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40016. }
  40017. m.AddStatus(v)
  40018. return nil
  40019. case wx.FieldOrganizationID:
  40020. v, ok := value.(int64)
  40021. if !ok {
  40022. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40023. }
  40024. m.AddOrganizationID(v)
  40025. return nil
  40026. }
  40027. return fmt.Errorf("unknown Wx numeric field %s", name)
  40028. }
  40029. // ClearedFields returns all nullable fields that were cleared during this
  40030. // mutation.
  40031. func (m *WxMutation) ClearedFields() []string {
  40032. var fields []string
  40033. if m.FieldCleared(wx.FieldStatus) {
  40034. fields = append(fields, wx.FieldStatus)
  40035. }
  40036. if m.FieldCleared(wx.FieldDeletedAt) {
  40037. fields = append(fields, wx.FieldDeletedAt)
  40038. }
  40039. if m.FieldCleared(wx.FieldServerID) {
  40040. fields = append(fields, wx.FieldServerID)
  40041. }
  40042. if m.FieldCleared(wx.FieldOrganizationID) {
  40043. fields = append(fields, wx.FieldOrganizationID)
  40044. }
  40045. if m.FieldCleared(wx.FieldAPIBase) {
  40046. fields = append(fields, wx.FieldAPIBase)
  40047. }
  40048. if m.FieldCleared(wx.FieldAPIKey) {
  40049. fields = append(fields, wx.FieldAPIKey)
  40050. }
  40051. return fields
  40052. }
  40053. // FieldCleared returns a boolean indicating if a field with the given name was
  40054. // cleared in this mutation.
  40055. func (m *WxMutation) FieldCleared(name string) bool {
  40056. _, ok := m.clearedFields[name]
  40057. return ok
  40058. }
  40059. // ClearField clears the value of the field with the given name. It returns an
  40060. // error if the field is not defined in the schema.
  40061. func (m *WxMutation) ClearField(name string) error {
  40062. switch name {
  40063. case wx.FieldStatus:
  40064. m.ClearStatus()
  40065. return nil
  40066. case wx.FieldDeletedAt:
  40067. m.ClearDeletedAt()
  40068. return nil
  40069. case wx.FieldServerID:
  40070. m.ClearServerID()
  40071. return nil
  40072. case wx.FieldOrganizationID:
  40073. m.ClearOrganizationID()
  40074. return nil
  40075. case wx.FieldAPIBase:
  40076. m.ClearAPIBase()
  40077. return nil
  40078. case wx.FieldAPIKey:
  40079. m.ClearAPIKey()
  40080. return nil
  40081. }
  40082. return fmt.Errorf("unknown Wx nullable field %s", name)
  40083. }
  40084. // ResetField resets all changes in the mutation for the field with the given name.
  40085. // It returns an error if the field is not defined in the schema.
  40086. func (m *WxMutation) ResetField(name string) error {
  40087. switch name {
  40088. case wx.FieldCreatedAt:
  40089. m.ResetCreatedAt()
  40090. return nil
  40091. case wx.FieldUpdatedAt:
  40092. m.ResetUpdatedAt()
  40093. return nil
  40094. case wx.FieldStatus:
  40095. m.ResetStatus()
  40096. return nil
  40097. case wx.FieldDeletedAt:
  40098. m.ResetDeletedAt()
  40099. return nil
  40100. case wx.FieldServerID:
  40101. m.ResetServerID()
  40102. return nil
  40103. case wx.FieldPort:
  40104. m.ResetPort()
  40105. return nil
  40106. case wx.FieldProcessID:
  40107. m.ResetProcessID()
  40108. return nil
  40109. case wx.FieldCallback:
  40110. m.ResetCallback()
  40111. return nil
  40112. case wx.FieldWxid:
  40113. m.ResetWxid()
  40114. return nil
  40115. case wx.FieldAccount:
  40116. m.ResetAccount()
  40117. return nil
  40118. case wx.FieldNickname:
  40119. m.ResetNickname()
  40120. return nil
  40121. case wx.FieldTel:
  40122. m.ResetTel()
  40123. return nil
  40124. case wx.FieldHeadBig:
  40125. m.ResetHeadBig()
  40126. return nil
  40127. case wx.FieldOrganizationID:
  40128. m.ResetOrganizationID()
  40129. return nil
  40130. case wx.FieldAgentID:
  40131. m.ResetAgentID()
  40132. return nil
  40133. case wx.FieldAPIBase:
  40134. m.ResetAPIBase()
  40135. return nil
  40136. case wx.FieldAPIKey:
  40137. m.ResetAPIKey()
  40138. return nil
  40139. case wx.FieldAllowList:
  40140. m.ResetAllowList()
  40141. return nil
  40142. case wx.FieldGroupAllowList:
  40143. m.ResetGroupAllowList()
  40144. return nil
  40145. case wx.FieldBlockList:
  40146. m.ResetBlockList()
  40147. return nil
  40148. case wx.FieldGroupBlockList:
  40149. m.ResetGroupBlockList()
  40150. return nil
  40151. }
  40152. return fmt.Errorf("unknown Wx field %s", name)
  40153. }
  40154. // AddedEdges returns all edge names that were set/added in this mutation.
  40155. func (m *WxMutation) AddedEdges() []string {
  40156. edges := make([]string, 0, 2)
  40157. if m.server != nil {
  40158. edges = append(edges, wx.EdgeServer)
  40159. }
  40160. if m.agent != nil {
  40161. edges = append(edges, wx.EdgeAgent)
  40162. }
  40163. return edges
  40164. }
  40165. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  40166. // name in this mutation.
  40167. func (m *WxMutation) AddedIDs(name string) []ent.Value {
  40168. switch name {
  40169. case wx.EdgeServer:
  40170. if id := m.server; id != nil {
  40171. return []ent.Value{*id}
  40172. }
  40173. case wx.EdgeAgent:
  40174. if id := m.agent; id != nil {
  40175. return []ent.Value{*id}
  40176. }
  40177. }
  40178. return nil
  40179. }
  40180. // RemovedEdges returns all edge names that were removed in this mutation.
  40181. func (m *WxMutation) RemovedEdges() []string {
  40182. edges := make([]string, 0, 2)
  40183. return edges
  40184. }
  40185. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  40186. // the given name in this mutation.
  40187. func (m *WxMutation) RemovedIDs(name string) []ent.Value {
  40188. return nil
  40189. }
  40190. // ClearedEdges returns all edge names that were cleared in this mutation.
  40191. func (m *WxMutation) ClearedEdges() []string {
  40192. edges := make([]string, 0, 2)
  40193. if m.clearedserver {
  40194. edges = append(edges, wx.EdgeServer)
  40195. }
  40196. if m.clearedagent {
  40197. edges = append(edges, wx.EdgeAgent)
  40198. }
  40199. return edges
  40200. }
  40201. // EdgeCleared returns a boolean which indicates if the edge with the given name
  40202. // was cleared in this mutation.
  40203. func (m *WxMutation) EdgeCleared(name string) bool {
  40204. switch name {
  40205. case wx.EdgeServer:
  40206. return m.clearedserver
  40207. case wx.EdgeAgent:
  40208. return m.clearedagent
  40209. }
  40210. return false
  40211. }
  40212. // ClearEdge clears the value of the edge with the given name. It returns an error
  40213. // if that edge is not defined in the schema.
  40214. func (m *WxMutation) ClearEdge(name string) error {
  40215. switch name {
  40216. case wx.EdgeServer:
  40217. m.ClearServer()
  40218. return nil
  40219. case wx.EdgeAgent:
  40220. m.ClearAgent()
  40221. return nil
  40222. }
  40223. return fmt.Errorf("unknown Wx unique edge %s", name)
  40224. }
  40225. // ResetEdge resets all changes to the edge with the given name in this mutation.
  40226. // It returns an error if the edge is not defined in the schema.
  40227. func (m *WxMutation) ResetEdge(name string) error {
  40228. switch name {
  40229. case wx.EdgeServer:
  40230. m.ResetServer()
  40231. return nil
  40232. case wx.EdgeAgent:
  40233. m.ResetAgent()
  40234. return nil
  40235. }
  40236. return fmt.Errorf("unknown Wx edge %s", name)
  40237. }
  40238. // WxCardMutation represents an operation that mutates the WxCard nodes in the graph.
  40239. type WxCardMutation struct {
  40240. config
  40241. op Op
  40242. typ string
  40243. id *uint64
  40244. created_at *time.Time
  40245. updated_at *time.Time
  40246. deleted_at *time.Time
  40247. user_id *uint64
  40248. adduser_id *int64
  40249. wx_user_id *uint64
  40250. addwx_user_id *int64
  40251. avatar *string
  40252. logo *string
  40253. name *string
  40254. company *string
  40255. address *string
  40256. phone *string
  40257. official_account *string
  40258. wechat_account *string
  40259. email *string
  40260. api_base *string
  40261. api_key *string
  40262. ai_info *string
  40263. intro *string
  40264. clearedFields map[string]struct{}
  40265. done bool
  40266. oldValue func(context.Context) (*WxCard, error)
  40267. predicates []predicate.WxCard
  40268. }
  40269. var _ ent.Mutation = (*WxCardMutation)(nil)
  40270. // wxcardOption allows management of the mutation configuration using functional options.
  40271. type wxcardOption func(*WxCardMutation)
  40272. // newWxCardMutation creates new mutation for the WxCard entity.
  40273. func newWxCardMutation(c config, op Op, opts ...wxcardOption) *WxCardMutation {
  40274. m := &WxCardMutation{
  40275. config: c,
  40276. op: op,
  40277. typ: TypeWxCard,
  40278. clearedFields: make(map[string]struct{}),
  40279. }
  40280. for _, opt := range opts {
  40281. opt(m)
  40282. }
  40283. return m
  40284. }
  40285. // withWxCardID sets the ID field of the mutation.
  40286. func withWxCardID(id uint64) wxcardOption {
  40287. return func(m *WxCardMutation) {
  40288. var (
  40289. err error
  40290. once sync.Once
  40291. value *WxCard
  40292. )
  40293. m.oldValue = func(ctx context.Context) (*WxCard, error) {
  40294. once.Do(func() {
  40295. if m.done {
  40296. err = errors.New("querying old values post mutation is not allowed")
  40297. } else {
  40298. value, err = m.Client().WxCard.Get(ctx, id)
  40299. }
  40300. })
  40301. return value, err
  40302. }
  40303. m.id = &id
  40304. }
  40305. }
  40306. // withWxCard sets the old WxCard of the mutation.
  40307. func withWxCard(node *WxCard) wxcardOption {
  40308. return func(m *WxCardMutation) {
  40309. m.oldValue = func(context.Context) (*WxCard, error) {
  40310. return node, nil
  40311. }
  40312. m.id = &node.ID
  40313. }
  40314. }
  40315. // Client returns a new `ent.Client` from the mutation. If the mutation was
  40316. // executed in a transaction (ent.Tx), a transactional client is returned.
  40317. func (m WxCardMutation) Client() *Client {
  40318. client := &Client{config: m.config}
  40319. client.init()
  40320. return client
  40321. }
  40322. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  40323. // it returns an error otherwise.
  40324. func (m WxCardMutation) Tx() (*Tx, error) {
  40325. if _, ok := m.driver.(*txDriver); !ok {
  40326. return nil, errors.New("ent: mutation is not running in a transaction")
  40327. }
  40328. tx := &Tx{config: m.config}
  40329. tx.init()
  40330. return tx, nil
  40331. }
  40332. // SetID sets the value of the id field. Note that this
  40333. // operation is only accepted on creation of WxCard entities.
  40334. func (m *WxCardMutation) SetID(id uint64) {
  40335. m.id = &id
  40336. }
  40337. // ID returns the ID value in the mutation. Note that the ID is only available
  40338. // if it was provided to the builder or after it was returned from the database.
  40339. func (m *WxCardMutation) ID() (id uint64, exists bool) {
  40340. if m.id == nil {
  40341. return
  40342. }
  40343. return *m.id, true
  40344. }
  40345. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  40346. // That means, if the mutation is applied within a transaction with an isolation level such
  40347. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  40348. // or updated by the mutation.
  40349. func (m *WxCardMutation) IDs(ctx context.Context) ([]uint64, error) {
  40350. switch {
  40351. case m.op.Is(OpUpdateOne | OpDeleteOne):
  40352. id, exists := m.ID()
  40353. if exists {
  40354. return []uint64{id}, nil
  40355. }
  40356. fallthrough
  40357. case m.op.Is(OpUpdate | OpDelete):
  40358. return m.Client().WxCard.Query().Where(m.predicates...).IDs(ctx)
  40359. default:
  40360. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  40361. }
  40362. }
  40363. // SetCreatedAt sets the "created_at" field.
  40364. func (m *WxCardMutation) SetCreatedAt(t time.Time) {
  40365. m.created_at = &t
  40366. }
  40367. // CreatedAt returns the value of the "created_at" field in the mutation.
  40368. func (m *WxCardMutation) CreatedAt() (r time.Time, exists bool) {
  40369. v := m.created_at
  40370. if v == nil {
  40371. return
  40372. }
  40373. return *v, true
  40374. }
  40375. // OldCreatedAt returns the old "created_at" field's value of the WxCard entity.
  40376. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  40377. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40378. func (m *WxCardMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  40379. if !m.op.Is(OpUpdateOne) {
  40380. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  40381. }
  40382. if m.id == nil || m.oldValue == nil {
  40383. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  40384. }
  40385. oldValue, err := m.oldValue(ctx)
  40386. if err != nil {
  40387. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  40388. }
  40389. return oldValue.CreatedAt, nil
  40390. }
  40391. // ResetCreatedAt resets all changes to the "created_at" field.
  40392. func (m *WxCardMutation) ResetCreatedAt() {
  40393. m.created_at = nil
  40394. }
  40395. // SetUpdatedAt sets the "updated_at" field.
  40396. func (m *WxCardMutation) SetUpdatedAt(t time.Time) {
  40397. m.updated_at = &t
  40398. }
  40399. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  40400. func (m *WxCardMutation) UpdatedAt() (r time.Time, exists bool) {
  40401. v := m.updated_at
  40402. if v == nil {
  40403. return
  40404. }
  40405. return *v, true
  40406. }
  40407. // OldUpdatedAt returns the old "updated_at" field's value of the WxCard entity.
  40408. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  40409. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40410. func (m *WxCardMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  40411. if !m.op.Is(OpUpdateOne) {
  40412. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  40413. }
  40414. if m.id == nil || m.oldValue == nil {
  40415. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  40416. }
  40417. oldValue, err := m.oldValue(ctx)
  40418. if err != nil {
  40419. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  40420. }
  40421. return oldValue.UpdatedAt, nil
  40422. }
  40423. // ResetUpdatedAt resets all changes to the "updated_at" field.
  40424. func (m *WxCardMutation) ResetUpdatedAt() {
  40425. m.updated_at = nil
  40426. }
  40427. // SetDeletedAt sets the "deleted_at" field.
  40428. func (m *WxCardMutation) SetDeletedAt(t time.Time) {
  40429. m.deleted_at = &t
  40430. }
  40431. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  40432. func (m *WxCardMutation) DeletedAt() (r time.Time, exists bool) {
  40433. v := m.deleted_at
  40434. if v == nil {
  40435. return
  40436. }
  40437. return *v, true
  40438. }
  40439. // OldDeletedAt returns the old "deleted_at" field's value of the WxCard entity.
  40440. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  40441. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40442. func (m *WxCardMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  40443. if !m.op.Is(OpUpdateOne) {
  40444. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  40445. }
  40446. if m.id == nil || m.oldValue == nil {
  40447. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  40448. }
  40449. oldValue, err := m.oldValue(ctx)
  40450. if err != nil {
  40451. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  40452. }
  40453. return oldValue.DeletedAt, nil
  40454. }
  40455. // ClearDeletedAt clears the value of the "deleted_at" field.
  40456. func (m *WxCardMutation) ClearDeletedAt() {
  40457. m.deleted_at = nil
  40458. m.clearedFields[wxcard.FieldDeletedAt] = struct{}{}
  40459. }
  40460. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  40461. func (m *WxCardMutation) DeletedAtCleared() bool {
  40462. _, ok := m.clearedFields[wxcard.FieldDeletedAt]
  40463. return ok
  40464. }
  40465. // ResetDeletedAt resets all changes to the "deleted_at" field.
  40466. func (m *WxCardMutation) ResetDeletedAt() {
  40467. m.deleted_at = nil
  40468. delete(m.clearedFields, wxcard.FieldDeletedAt)
  40469. }
  40470. // SetUserID sets the "user_id" field.
  40471. func (m *WxCardMutation) SetUserID(u uint64) {
  40472. m.user_id = &u
  40473. m.adduser_id = nil
  40474. }
  40475. // UserID returns the value of the "user_id" field in the mutation.
  40476. func (m *WxCardMutation) UserID() (r uint64, exists bool) {
  40477. v := m.user_id
  40478. if v == nil {
  40479. return
  40480. }
  40481. return *v, true
  40482. }
  40483. // OldUserID returns the old "user_id" field's value of the WxCard entity.
  40484. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  40485. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40486. func (m *WxCardMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  40487. if !m.op.Is(OpUpdateOne) {
  40488. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  40489. }
  40490. if m.id == nil || m.oldValue == nil {
  40491. return v, errors.New("OldUserID requires an ID field in the mutation")
  40492. }
  40493. oldValue, err := m.oldValue(ctx)
  40494. if err != nil {
  40495. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  40496. }
  40497. return oldValue.UserID, nil
  40498. }
  40499. // AddUserID adds u to the "user_id" field.
  40500. func (m *WxCardMutation) AddUserID(u int64) {
  40501. if m.adduser_id != nil {
  40502. *m.adduser_id += u
  40503. } else {
  40504. m.adduser_id = &u
  40505. }
  40506. }
  40507. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  40508. func (m *WxCardMutation) AddedUserID() (r int64, exists bool) {
  40509. v := m.adduser_id
  40510. if v == nil {
  40511. return
  40512. }
  40513. return *v, true
  40514. }
  40515. // ClearUserID clears the value of the "user_id" field.
  40516. func (m *WxCardMutation) ClearUserID() {
  40517. m.user_id = nil
  40518. m.adduser_id = nil
  40519. m.clearedFields[wxcard.FieldUserID] = struct{}{}
  40520. }
  40521. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  40522. func (m *WxCardMutation) UserIDCleared() bool {
  40523. _, ok := m.clearedFields[wxcard.FieldUserID]
  40524. return ok
  40525. }
  40526. // ResetUserID resets all changes to the "user_id" field.
  40527. func (m *WxCardMutation) ResetUserID() {
  40528. m.user_id = nil
  40529. m.adduser_id = nil
  40530. delete(m.clearedFields, wxcard.FieldUserID)
  40531. }
  40532. // SetWxUserID sets the "wx_user_id" field.
  40533. func (m *WxCardMutation) SetWxUserID(u uint64) {
  40534. m.wx_user_id = &u
  40535. m.addwx_user_id = nil
  40536. }
  40537. // WxUserID returns the value of the "wx_user_id" field in the mutation.
  40538. func (m *WxCardMutation) WxUserID() (r uint64, exists bool) {
  40539. v := m.wx_user_id
  40540. if v == nil {
  40541. return
  40542. }
  40543. return *v, true
  40544. }
  40545. // OldWxUserID returns the old "wx_user_id" field's value of the WxCard entity.
  40546. // If the WxCard 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 *WxCardMutation) OldWxUserID(ctx context.Context) (v uint64, err error) {
  40549. if !m.op.Is(OpUpdateOne) {
  40550. return v, errors.New("OldWxUserID is only allowed on UpdateOne operations")
  40551. }
  40552. if m.id == nil || m.oldValue == nil {
  40553. return v, errors.New("OldWxUserID 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 OldWxUserID: %w", err)
  40558. }
  40559. return oldValue.WxUserID, nil
  40560. }
  40561. // AddWxUserID adds u to the "wx_user_id" field.
  40562. func (m *WxCardMutation) AddWxUserID(u int64) {
  40563. if m.addwx_user_id != nil {
  40564. *m.addwx_user_id += u
  40565. } else {
  40566. m.addwx_user_id = &u
  40567. }
  40568. }
  40569. // AddedWxUserID returns the value that was added to the "wx_user_id" field in this mutation.
  40570. func (m *WxCardMutation) AddedWxUserID() (r int64, exists bool) {
  40571. v := m.addwx_user_id
  40572. if v == nil {
  40573. return
  40574. }
  40575. return *v, true
  40576. }
  40577. // ClearWxUserID clears the value of the "wx_user_id" field.
  40578. func (m *WxCardMutation) ClearWxUserID() {
  40579. m.wx_user_id = nil
  40580. m.addwx_user_id = nil
  40581. m.clearedFields[wxcard.FieldWxUserID] = struct{}{}
  40582. }
  40583. // WxUserIDCleared returns if the "wx_user_id" field was cleared in this mutation.
  40584. func (m *WxCardMutation) WxUserIDCleared() bool {
  40585. _, ok := m.clearedFields[wxcard.FieldWxUserID]
  40586. return ok
  40587. }
  40588. // ResetWxUserID resets all changes to the "wx_user_id" field.
  40589. func (m *WxCardMutation) ResetWxUserID() {
  40590. m.wx_user_id = nil
  40591. m.addwx_user_id = nil
  40592. delete(m.clearedFields, wxcard.FieldWxUserID)
  40593. }
  40594. // SetAvatar sets the "avatar" field.
  40595. func (m *WxCardMutation) SetAvatar(s string) {
  40596. m.avatar = &s
  40597. }
  40598. // Avatar returns the value of the "avatar" field in the mutation.
  40599. func (m *WxCardMutation) Avatar() (r string, exists bool) {
  40600. v := m.avatar
  40601. if v == nil {
  40602. return
  40603. }
  40604. return *v, true
  40605. }
  40606. // OldAvatar returns the old "avatar" field's value of the WxCard entity.
  40607. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  40608. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40609. func (m *WxCardMutation) OldAvatar(ctx context.Context) (v string, err error) {
  40610. if !m.op.Is(OpUpdateOne) {
  40611. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  40612. }
  40613. if m.id == nil || m.oldValue == nil {
  40614. return v, errors.New("OldAvatar requires an ID field in the mutation")
  40615. }
  40616. oldValue, err := m.oldValue(ctx)
  40617. if err != nil {
  40618. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  40619. }
  40620. return oldValue.Avatar, nil
  40621. }
  40622. // ResetAvatar resets all changes to the "avatar" field.
  40623. func (m *WxCardMutation) ResetAvatar() {
  40624. m.avatar = nil
  40625. }
  40626. // SetLogo sets the "logo" field.
  40627. func (m *WxCardMutation) SetLogo(s string) {
  40628. m.logo = &s
  40629. }
  40630. // Logo returns the value of the "logo" field in the mutation.
  40631. func (m *WxCardMutation) Logo() (r string, exists bool) {
  40632. v := m.logo
  40633. if v == nil {
  40634. return
  40635. }
  40636. return *v, true
  40637. }
  40638. // OldLogo returns the old "logo" field's value of the WxCard entity.
  40639. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  40640. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40641. func (m *WxCardMutation) OldLogo(ctx context.Context) (v string, err error) {
  40642. if !m.op.Is(OpUpdateOne) {
  40643. return v, errors.New("OldLogo is only allowed on UpdateOne operations")
  40644. }
  40645. if m.id == nil || m.oldValue == nil {
  40646. return v, errors.New("OldLogo requires an ID field in the mutation")
  40647. }
  40648. oldValue, err := m.oldValue(ctx)
  40649. if err != nil {
  40650. return v, fmt.Errorf("querying old value for OldLogo: %w", err)
  40651. }
  40652. return oldValue.Logo, nil
  40653. }
  40654. // ResetLogo resets all changes to the "logo" field.
  40655. func (m *WxCardMutation) ResetLogo() {
  40656. m.logo = nil
  40657. }
  40658. // SetName sets the "name" field.
  40659. func (m *WxCardMutation) SetName(s string) {
  40660. m.name = &s
  40661. }
  40662. // Name returns the value of the "name" field in the mutation.
  40663. func (m *WxCardMutation) Name() (r string, exists bool) {
  40664. v := m.name
  40665. if v == nil {
  40666. return
  40667. }
  40668. return *v, true
  40669. }
  40670. // OldName returns the old "name" field's value of the WxCard entity.
  40671. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  40672. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40673. func (m *WxCardMutation) OldName(ctx context.Context) (v string, err error) {
  40674. if !m.op.Is(OpUpdateOne) {
  40675. return v, errors.New("OldName is only allowed on UpdateOne operations")
  40676. }
  40677. if m.id == nil || m.oldValue == nil {
  40678. return v, errors.New("OldName requires an ID field in the mutation")
  40679. }
  40680. oldValue, err := m.oldValue(ctx)
  40681. if err != nil {
  40682. return v, fmt.Errorf("querying old value for OldName: %w", err)
  40683. }
  40684. return oldValue.Name, nil
  40685. }
  40686. // ResetName resets all changes to the "name" field.
  40687. func (m *WxCardMutation) ResetName() {
  40688. m.name = nil
  40689. }
  40690. // SetCompany sets the "company" field.
  40691. func (m *WxCardMutation) SetCompany(s string) {
  40692. m.company = &s
  40693. }
  40694. // Company returns the value of the "company" field in the mutation.
  40695. func (m *WxCardMutation) Company() (r string, exists bool) {
  40696. v := m.company
  40697. if v == nil {
  40698. return
  40699. }
  40700. return *v, true
  40701. }
  40702. // OldCompany returns the old "company" field's value of the WxCard entity.
  40703. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  40704. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40705. func (m *WxCardMutation) OldCompany(ctx context.Context) (v string, err error) {
  40706. if !m.op.Is(OpUpdateOne) {
  40707. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  40708. }
  40709. if m.id == nil || m.oldValue == nil {
  40710. return v, errors.New("OldCompany requires an ID field in the mutation")
  40711. }
  40712. oldValue, err := m.oldValue(ctx)
  40713. if err != nil {
  40714. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  40715. }
  40716. return oldValue.Company, nil
  40717. }
  40718. // ResetCompany resets all changes to the "company" field.
  40719. func (m *WxCardMutation) ResetCompany() {
  40720. m.company = nil
  40721. }
  40722. // SetAddress sets the "address" field.
  40723. func (m *WxCardMutation) SetAddress(s string) {
  40724. m.address = &s
  40725. }
  40726. // Address returns the value of the "address" field in the mutation.
  40727. func (m *WxCardMutation) Address() (r string, exists bool) {
  40728. v := m.address
  40729. if v == nil {
  40730. return
  40731. }
  40732. return *v, true
  40733. }
  40734. // OldAddress returns the old "address" field's value of the WxCard entity.
  40735. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  40736. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40737. func (m *WxCardMutation) OldAddress(ctx context.Context) (v string, err error) {
  40738. if !m.op.Is(OpUpdateOne) {
  40739. return v, errors.New("OldAddress is only allowed on UpdateOne operations")
  40740. }
  40741. if m.id == nil || m.oldValue == nil {
  40742. return v, errors.New("OldAddress requires an ID field in the mutation")
  40743. }
  40744. oldValue, err := m.oldValue(ctx)
  40745. if err != nil {
  40746. return v, fmt.Errorf("querying old value for OldAddress: %w", err)
  40747. }
  40748. return oldValue.Address, nil
  40749. }
  40750. // ResetAddress resets all changes to the "address" field.
  40751. func (m *WxCardMutation) ResetAddress() {
  40752. m.address = nil
  40753. }
  40754. // SetPhone sets the "phone" field.
  40755. func (m *WxCardMutation) SetPhone(s string) {
  40756. m.phone = &s
  40757. }
  40758. // Phone returns the value of the "phone" field in the mutation.
  40759. func (m *WxCardMutation) Phone() (r string, exists bool) {
  40760. v := m.phone
  40761. if v == nil {
  40762. return
  40763. }
  40764. return *v, true
  40765. }
  40766. // OldPhone returns the old "phone" field's value of the WxCard entity.
  40767. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  40768. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40769. func (m *WxCardMutation) OldPhone(ctx context.Context) (v string, err error) {
  40770. if !m.op.Is(OpUpdateOne) {
  40771. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  40772. }
  40773. if m.id == nil || m.oldValue == nil {
  40774. return v, errors.New("OldPhone requires an ID field in the mutation")
  40775. }
  40776. oldValue, err := m.oldValue(ctx)
  40777. if err != nil {
  40778. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  40779. }
  40780. return oldValue.Phone, nil
  40781. }
  40782. // ResetPhone resets all changes to the "phone" field.
  40783. func (m *WxCardMutation) ResetPhone() {
  40784. m.phone = nil
  40785. }
  40786. // SetOfficialAccount sets the "official_account" field.
  40787. func (m *WxCardMutation) SetOfficialAccount(s string) {
  40788. m.official_account = &s
  40789. }
  40790. // OfficialAccount returns the value of the "official_account" field in the mutation.
  40791. func (m *WxCardMutation) OfficialAccount() (r string, exists bool) {
  40792. v := m.official_account
  40793. if v == nil {
  40794. return
  40795. }
  40796. return *v, true
  40797. }
  40798. // OldOfficialAccount returns the old "official_account" field's value of the WxCard entity.
  40799. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  40800. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40801. func (m *WxCardMutation) OldOfficialAccount(ctx context.Context) (v string, err error) {
  40802. if !m.op.Is(OpUpdateOne) {
  40803. return v, errors.New("OldOfficialAccount is only allowed on UpdateOne operations")
  40804. }
  40805. if m.id == nil || m.oldValue == nil {
  40806. return v, errors.New("OldOfficialAccount requires an ID field in the mutation")
  40807. }
  40808. oldValue, err := m.oldValue(ctx)
  40809. if err != nil {
  40810. return v, fmt.Errorf("querying old value for OldOfficialAccount: %w", err)
  40811. }
  40812. return oldValue.OfficialAccount, nil
  40813. }
  40814. // ResetOfficialAccount resets all changes to the "official_account" field.
  40815. func (m *WxCardMutation) ResetOfficialAccount() {
  40816. m.official_account = nil
  40817. }
  40818. // SetWechatAccount sets the "wechat_account" field.
  40819. func (m *WxCardMutation) SetWechatAccount(s string) {
  40820. m.wechat_account = &s
  40821. }
  40822. // WechatAccount returns the value of the "wechat_account" field in the mutation.
  40823. func (m *WxCardMutation) WechatAccount() (r string, exists bool) {
  40824. v := m.wechat_account
  40825. if v == nil {
  40826. return
  40827. }
  40828. return *v, true
  40829. }
  40830. // OldWechatAccount returns the old "wechat_account" field's value of the WxCard entity.
  40831. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  40832. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40833. func (m *WxCardMutation) OldWechatAccount(ctx context.Context) (v string, err error) {
  40834. if !m.op.Is(OpUpdateOne) {
  40835. return v, errors.New("OldWechatAccount is only allowed on UpdateOne operations")
  40836. }
  40837. if m.id == nil || m.oldValue == nil {
  40838. return v, errors.New("OldWechatAccount requires an ID field in the mutation")
  40839. }
  40840. oldValue, err := m.oldValue(ctx)
  40841. if err != nil {
  40842. return v, fmt.Errorf("querying old value for OldWechatAccount: %w", err)
  40843. }
  40844. return oldValue.WechatAccount, nil
  40845. }
  40846. // ResetWechatAccount resets all changes to the "wechat_account" field.
  40847. func (m *WxCardMutation) ResetWechatAccount() {
  40848. m.wechat_account = nil
  40849. }
  40850. // SetEmail sets the "email" field.
  40851. func (m *WxCardMutation) SetEmail(s string) {
  40852. m.email = &s
  40853. }
  40854. // Email returns the value of the "email" field in the mutation.
  40855. func (m *WxCardMutation) Email() (r string, exists bool) {
  40856. v := m.email
  40857. if v == nil {
  40858. return
  40859. }
  40860. return *v, true
  40861. }
  40862. // OldEmail returns the old "email" field's value of the WxCard entity.
  40863. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  40864. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40865. func (m *WxCardMutation) OldEmail(ctx context.Context) (v string, err error) {
  40866. if !m.op.Is(OpUpdateOne) {
  40867. return v, errors.New("OldEmail is only allowed on UpdateOne operations")
  40868. }
  40869. if m.id == nil || m.oldValue == nil {
  40870. return v, errors.New("OldEmail requires an ID field in the mutation")
  40871. }
  40872. oldValue, err := m.oldValue(ctx)
  40873. if err != nil {
  40874. return v, fmt.Errorf("querying old value for OldEmail: %w", err)
  40875. }
  40876. return oldValue.Email, nil
  40877. }
  40878. // ClearEmail clears the value of the "email" field.
  40879. func (m *WxCardMutation) ClearEmail() {
  40880. m.email = nil
  40881. m.clearedFields[wxcard.FieldEmail] = struct{}{}
  40882. }
  40883. // EmailCleared returns if the "email" field was cleared in this mutation.
  40884. func (m *WxCardMutation) EmailCleared() bool {
  40885. _, ok := m.clearedFields[wxcard.FieldEmail]
  40886. return ok
  40887. }
  40888. // ResetEmail resets all changes to the "email" field.
  40889. func (m *WxCardMutation) ResetEmail() {
  40890. m.email = nil
  40891. delete(m.clearedFields, wxcard.FieldEmail)
  40892. }
  40893. // SetAPIBase sets the "api_base" field.
  40894. func (m *WxCardMutation) SetAPIBase(s string) {
  40895. m.api_base = &s
  40896. }
  40897. // APIBase returns the value of the "api_base" field in the mutation.
  40898. func (m *WxCardMutation) APIBase() (r string, exists bool) {
  40899. v := m.api_base
  40900. if v == nil {
  40901. return
  40902. }
  40903. return *v, true
  40904. }
  40905. // OldAPIBase returns the old "api_base" field's value of the WxCard entity.
  40906. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  40907. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40908. func (m *WxCardMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  40909. if !m.op.Is(OpUpdateOne) {
  40910. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  40911. }
  40912. if m.id == nil || m.oldValue == nil {
  40913. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  40914. }
  40915. oldValue, err := m.oldValue(ctx)
  40916. if err != nil {
  40917. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  40918. }
  40919. return oldValue.APIBase, nil
  40920. }
  40921. // ClearAPIBase clears the value of the "api_base" field.
  40922. func (m *WxCardMutation) ClearAPIBase() {
  40923. m.api_base = nil
  40924. m.clearedFields[wxcard.FieldAPIBase] = struct{}{}
  40925. }
  40926. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  40927. func (m *WxCardMutation) APIBaseCleared() bool {
  40928. _, ok := m.clearedFields[wxcard.FieldAPIBase]
  40929. return ok
  40930. }
  40931. // ResetAPIBase resets all changes to the "api_base" field.
  40932. func (m *WxCardMutation) ResetAPIBase() {
  40933. m.api_base = nil
  40934. delete(m.clearedFields, wxcard.FieldAPIBase)
  40935. }
  40936. // SetAPIKey sets the "api_key" field.
  40937. func (m *WxCardMutation) SetAPIKey(s string) {
  40938. m.api_key = &s
  40939. }
  40940. // APIKey returns the value of the "api_key" field in the mutation.
  40941. func (m *WxCardMutation) APIKey() (r string, exists bool) {
  40942. v := m.api_key
  40943. if v == nil {
  40944. return
  40945. }
  40946. return *v, true
  40947. }
  40948. // OldAPIKey returns the old "api_key" field's value of the WxCard entity.
  40949. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  40950. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40951. func (m *WxCardMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  40952. if !m.op.Is(OpUpdateOne) {
  40953. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  40954. }
  40955. if m.id == nil || m.oldValue == nil {
  40956. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  40957. }
  40958. oldValue, err := m.oldValue(ctx)
  40959. if err != nil {
  40960. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  40961. }
  40962. return oldValue.APIKey, nil
  40963. }
  40964. // ClearAPIKey clears the value of the "api_key" field.
  40965. func (m *WxCardMutation) ClearAPIKey() {
  40966. m.api_key = nil
  40967. m.clearedFields[wxcard.FieldAPIKey] = struct{}{}
  40968. }
  40969. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  40970. func (m *WxCardMutation) APIKeyCleared() bool {
  40971. _, ok := m.clearedFields[wxcard.FieldAPIKey]
  40972. return ok
  40973. }
  40974. // ResetAPIKey resets all changes to the "api_key" field.
  40975. func (m *WxCardMutation) ResetAPIKey() {
  40976. m.api_key = nil
  40977. delete(m.clearedFields, wxcard.FieldAPIKey)
  40978. }
  40979. // SetAiInfo sets the "ai_info" field.
  40980. func (m *WxCardMutation) SetAiInfo(s string) {
  40981. m.ai_info = &s
  40982. }
  40983. // AiInfo returns the value of the "ai_info" field in the mutation.
  40984. func (m *WxCardMutation) AiInfo() (r string, exists bool) {
  40985. v := m.ai_info
  40986. if v == nil {
  40987. return
  40988. }
  40989. return *v, true
  40990. }
  40991. // OldAiInfo returns the old "ai_info" field's value of the WxCard entity.
  40992. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  40993. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40994. func (m *WxCardMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  40995. if !m.op.Is(OpUpdateOne) {
  40996. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  40997. }
  40998. if m.id == nil || m.oldValue == nil {
  40999. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  41000. }
  41001. oldValue, err := m.oldValue(ctx)
  41002. if err != nil {
  41003. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  41004. }
  41005. return oldValue.AiInfo, nil
  41006. }
  41007. // ClearAiInfo clears the value of the "ai_info" field.
  41008. func (m *WxCardMutation) ClearAiInfo() {
  41009. m.ai_info = nil
  41010. m.clearedFields[wxcard.FieldAiInfo] = struct{}{}
  41011. }
  41012. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  41013. func (m *WxCardMutation) AiInfoCleared() bool {
  41014. _, ok := m.clearedFields[wxcard.FieldAiInfo]
  41015. return ok
  41016. }
  41017. // ResetAiInfo resets all changes to the "ai_info" field.
  41018. func (m *WxCardMutation) ResetAiInfo() {
  41019. m.ai_info = nil
  41020. delete(m.clearedFields, wxcard.FieldAiInfo)
  41021. }
  41022. // SetIntro sets the "intro" field.
  41023. func (m *WxCardMutation) SetIntro(s string) {
  41024. m.intro = &s
  41025. }
  41026. // Intro returns the value of the "intro" field in the mutation.
  41027. func (m *WxCardMutation) Intro() (r string, exists bool) {
  41028. v := m.intro
  41029. if v == nil {
  41030. return
  41031. }
  41032. return *v, true
  41033. }
  41034. // OldIntro returns the old "intro" field's value of the WxCard entity.
  41035. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  41036. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41037. func (m *WxCardMutation) OldIntro(ctx context.Context) (v string, err error) {
  41038. if !m.op.Is(OpUpdateOne) {
  41039. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  41040. }
  41041. if m.id == nil || m.oldValue == nil {
  41042. return v, errors.New("OldIntro requires an ID field in the mutation")
  41043. }
  41044. oldValue, err := m.oldValue(ctx)
  41045. if err != nil {
  41046. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  41047. }
  41048. return oldValue.Intro, nil
  41049. }
  41050. // ClearIntro clears the value of the "intro" field.
  41051. func (m *WxCardMutation) ClearIntro() {
  41052. m.intro = nil
  41053. m.clearedFields[wxcard.FieldIntro] = struct{}{}
  41054. }
  41055. // IntroCleared returns if the "intro" field was cleared in this mutation.
  41056. func (m *WxCardMutation) IntroCleared() bool {
  41057. _, ok := m.clearedFields[wxcard.FieldIntro]
  41058. return ok
  41059. }
  41060. // ResetIntro resets all changes to the "intro" field.
  41061. func (m *WxCardMutation) ResetIntro() {
  41062. m.intro = nil
  41063. delete(m.clearedFields, wxcard.FieldIntro)
  41064. }
  41065. // Where appends a list predicates to the WxCardMutation builder.
  41066. func (m *WxCardMutation) Where(ps ...predicate.WxCard) {
  41067. m.predicates = append(m.predicates, ps...)
  41068. }
  41069. // WhereP appends storage-level predicates to the WxCardMutation builder. Using this method,
  41070. // users can use type-assertion to append predicates that do not depend on any generated package.
  41071. func (m *WxCardMutation) WhereP(ps ...func(*sql.Selector)) {
  41072. p := make([]predicate.WxCard, len(ps))
  41073. for i := range ps {
  41074. p[i] = ps[i]
  41075. }
  41076. m.Where(p...)
  41077. }
  41078. // Op returns the operation name.
  41079. func (m *WxCardMutation) Op() Op {
  41080. return m.op
  41081. }
  41082. // SetOp allows setting the mutation operation.
  41083. func (m *WxCardMutation) SetOp(op Op) {
  41084. m.op = op
  41085. }
  41086. // Type returns the node type of this mutation (WxCard).
  41087. func (m *WxCardMutation) Type() string {
  41088. return m.typ
  41089. }
  41090. // Fields returns all fields that were changed during this mutation. Note that in
  41091. // order to get all numeric fields that were incremented/decremented, call
  41092. // AddedFields().
  41093. func (m *WxCardMutation) Fields() []string {
  41094. fields := make([]string, 0, 18)
  41095. if m.created_at != nil {
  41096. fields = append(fields, wxcard.FieldCreatedAt)
  41097. }
  41098. if m.updated_at != nil {
  41099. fields = append(fields, wxcard.FieldUpdatedAt)
  41100. }
  41101. if m.deleted_at != nil {
  41102. fields = append(fields, wxcard.FieldDeletedAt)
  41103. }
  41104. if m.user_id != nil {
  41105. fields = append(fields, wxcard.FieldUserID)
  41106. }
  41107. if m.wx_user_id != nil {
  41108. fields = append(fields, wxcard.FieldWxUserID)
  41109. }
  41110. if m.avatar != nil {
  41111. fields = append(fields, wxcard.FieldAvatar)
  41112. }
  41113. if m.logo != nil {
  41114. fields = append(fields, wxcard.FieldLogo)
  41115. }
  41116. if m.name != nil {
  41117. fields = append(fields, wxcard.FieldName)
  41118. }
  41119. if m.company != nil {
  41120. fields = append(fields, wxcard.FieldCompany)
  41121. }
  41122. if m.address != nil {
  41123. fields = append(fields, wxcard.FieldAddress)
  41124. }
  41125. if m.phone != nil {
  41126. fields = append(fields, wxcard.FieldPhone)
  41127. }
  41128. if m.official_account != nil {
  41129. fields = append(fields, wxcard.FieldOfficialAccount)
  41130. }
  41131. if m.wechat_account != nil {
  41132. fields = append(fields, wxcard.FieldWechatAccount)
  41133. }
  41134. if m.email != nil {
  41135. fields = append(fields, wxcard.FieldEmail)
  41136. }
  41137. if m.api_base != nil {
  41138. fields = append(fields, wxcard.FieldAPIBase)
  41139. }
  41140. if m.api_key != nil {
  41141. fields = append(fields, wxcard.FieldAPIKey)
  41142. }
  41143. if m.ai_info != nil {
  41144. fields = append(fields, wxcard.FieldAiInfo)
  41145. }
  41146. if m.intro != nil {
  41147. fields = append(fields, wxcard.FieldIntro)
  41148. }
  41149. return fields
  41150. }
  41151. // Field returns the value of a field with the given name. The second boolean
  41152. // return value indicates that this field was not set, or was not defined in the
  41153. // schema.
  41154. func (m *WxCardMutation) Field(name string) (ent.Value, bool) {
  41155. switch name {
  41156. case wxcard.FieldCreatedAt:
  41157. return m.CreatedAt()
  41158. case wxcard.FieldUpdatedAt:
  41159. return m.UpdatedAt()
  41160. case wxcard.FieldDeletedAt:
  41161. return m.DeletedAt()
  41162. case wxcard.FieldUserID:
  41163. return m.UserID()
  41164. case wxcard.FieldWxUserID:
  41165. return m.WxUserID()
  41166. case wxcard.FieldAvatar:
  41167. return m.Avatar()
  41168. case wxcard.FieldLogo:
  41169. return m.Logo()
  41170. case wxcard.FieldName:
  41171. return m.Name()
  41172. case wxcard.FieldCompany:
  41173. return m.Company()
  41174. case wxcard.FieldAddress:
  41175. return m.Address()
  41176. case wxcard.FieldPhone:
  41177. return m.Phone()
  41178. case wxcard.FieldOfficialAccount:
  41179. return m.OfficialAccount()
  41180. case wxcard.FieldWechatAccount:
  41181. return m.WechatAccount()
  41182. case wxcard.FieldEmail:
  41183. return m.Email()
  41184. case wxcard.FieldAPIBase:
  41185. return m.APIBase()
  41186. case wxcard.FieldAPIKey:
  41187. return m.APIKey()
  41188. case wxcard.FieldAiInfo:
  41189. return m.AiInfo()
  41190. case wxcard.FieldIntro:
  41191. return m.Intro()
  41192. }
  41193. return nil, false
  41194. }
  41195. // OldField returns the old value of the field from the database. An error is
  41196. // returned if the mutation operation is not UpdateOne, or the query to the
  41197. // database failed.
  41198. func (m *WxCardMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  41199. switch name {
  41200. case wxcard.FieldCreatedAt:
  41201. return m.OldCreatedAt(ctx)
  41202. case wxcard.FieldUpdatedAt:
  41203. return m.OldUpdatedAt(ctx)
  41204. case wxcard.FieldDeletedAt:
  41205. return m.OldDeletedAt(ctx)
  41206. case wxcard.FieldUserID:
  41207. return m.OldUserID(ctx)
  41208. case wxcard.FieldWxUserID:
  41209. return m.OldWxUserID(ctx)
  41210. case wxcard.FieldAvatar:
  41211. return m.OldAvatar(ctx)
  41212. case wxcard.FieldLogo:
  41213. return m.OldLogo(ctx)
  41214. case wxcard.FieldName:
  41215. return m.OldName(ctx)
  41216. case wxcard.FieldCompany:
  41217. return m.OldCompany(ctx)
  41218. case wxcard.FieldAddress:
  41219. return m.OldAddress(ctx)
  41220. case wxcard.FieldPhone:
  41221. return m.OldPhone(ctx)
  41222. case wxcard.FieldOfficialAccount:
  41223. return m.OldOfficialAccount(ctx)
  41224. case wxcard.FieldWechatAccount:
  41225. return m.OldWechatAccount(ctx)
  41226. case wxcard.FieldEmail:
  41227. return m.OldEmail(ctx)
  41228. case wxcard.FieldAPIBase:
  41229. return m.OldAPIBase(ctx)
  41230. case wxcard.FieldAPIKey:
  41231. return m.OldAPIKey(ctx)
  41232. case wxcard.FieldAiInfo:
  41233. return m.OldAiInfo(ctx)
  41234. case wxcard.FieldIntro:
  41235. return m.OldIntro(ctx)
  41236. }
  41237. return nil, fmt.Errorf("unknown WxCard field %s", name)
  41238. }
  41239. // SetField sets the value of a field with the given name. It returns an error if
  41240. // the field is not defined in the schema, or if the type mismatched the field
  41241. // type.
  41242. func (m *WxCardMutation) SetField(name string, value ent.Value) error {
  41243. switch name {
  41244. case wxcard.FieldCreatedAt:
  41245. v, ok := value.(time.Time)
  41246. if !ok {
  41247. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41248. }
  41249. m.SetCreatedAt(v)
  41250. return nil
  41251. case wxcard.FieldUpdatedAt:
  41252. v, ok := value.(time.Time)
  41253. if !ok {
  41254. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41255. }
  41256. m.SetUpdatedAt(v)
  41257. return nil
  41258. case wxcard.FieldDeletedAt:
  41259. v, ok := value.(time.Time)
  41260. if !ok {
  41261. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41262. }
  41263. m.SetDeletedAt(v)
  41264. return nil
  41265. case wxcard.FieldUserID:
  41266. v, ok := value.(uint64)
  41267. if !ok {
  41268. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41269. }
  41270. m.SetUserID(v)
  41271. return nil
  41272. case wxcard.FieldWxUserID:
  41273. v, ok := value.(uint64)
  41274. if !ok {
  41275. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41276. }
  41277. m.SetWxUserID(v)
  41278. return nil
  41279. case wxcard.FieldAvatar:
  41280. v, ok := value.(string)
  41281. if !ok {
  41282. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41283. }
  41284. m.SetAvatar(v)
  41285. return nil
  41286. case wxcard.FieldLogo:
  41287. v, ok := value.(string)
  41288. if !ok {
  41289. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41290. }
  41291. m.SetLogo(v)
  41292. return nil
  41293. case wxcard.FieldName:
  41294. v, ok := value.(string)
  41295. if !ok {
  41296. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41297. }
  41298. m.SetName(v)
  41299. return nil
  41300. case wxcard.FieldCompany:
  41301. v, ok := value.(string)
  41302. if !ok {
  41303. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41304. }
  41305. m.SetCompany(v)
  41306. return nil
  41307. case wxcard.FieldAddress:
  41308. v, ok := value.(string)
  41309. if !ok {
  41310. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41311. }
  41312. m.SetAddress(v)
  41313. return nil
  41314. case wxcard.FieldPhone:
  41315. v, ok := value.(string)
  41316. if !ok {
  41317. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41318. }
  41319. m.SetPhone(v)
  41320. return nil
  41321. case wxcard.FieldOfficialAccount:
  41322. v, ok := value.(string)
  41323. if !ok {
  41324. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41325. }
  41326. m.SetOfficialAccount(v)
  41327. return nil
  41328. case wxcard.FieldWechatAccount:
  41329. v, ok := value.(string)
  41330. if !ok {
  41331. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41332. }
  41333. m.SetWechatAccount(v)
  41334. return nil
  41335. case wxcard.FieldEmail:
  41336. v, ok := value.(string)
  41337. if !ok {
  41338. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41339. }
  41340. m.SetEmail(v)
  41341. return nil
  41342. case wxcard.FieldAPIBase:
  41343. v, ok := value.(string)
  41344. if !ok {
  41345. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41346. }
  41347. m.SetAPIBase(v)
  41348. return nil
  41349. case wxcard.FieldAPIKey:
  41350. v, ok := value.(string)
  41351. if !ok {
  41352. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41353. }
  41354. m.SetAPIKey(v)
  41355. return nil
  41356. case wxcard.FieldAiInfo:
  41357. v, ok := value.(string)
  41358. if !ok {
  41359. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41360. }
  41361. m.SetAiInfo(v)
  41362. return nil
  41363. case wxcard.FieldIntro:
  41364. v, ok := value.(string)
  41365. if !ok {
  41366. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41367. }
  41368. m.SetIntro(v)
  41369. return nil
  41370. }
  41371. return fmt.Errorf("unknown WxCard field %s", name)
  41372. }
  41373. // AddedFields returns all numeric fields that were incremented/decremented during
  41374. // this mutation.
  41375. func (m *WxCardMutation) AddedFields() []string {
  41376. var fields []string
  41377. if m.adduser_id != nil {
  41378. fields = append(fields, wxcard.FieldUserID)
  41379. }
  41380. if m.addwx_user_id != nil {
  41381. fields = append(fields, wxcard.FieldWxUserID)
  41382. }
  41383. return fields
  41384. }
  41385. // AddedField returns the numeric value that was incremented/decremented on a field
  41386. // with the given name. The second boolean return value indicates that this field
  41387. // was not set, or was not defined in the schema.
  41388. func (m *WxCardMutation) AddedField(name string) (ent.Value, bool) {
  41389. switch name {
  41390. case wxcard.FieldUserID:
  41391. return m.AddedUserID()
  41392. case wxcard.FieldWxUserID:
  41393. return m.AddedWxUserID()
  41394. }
  41395. return nil, false
  41396. }
  41397. // AddField adds the value to the field with the given name. It returns an error if
  41398. // the field is not defined in the schema, or if the type mismatched the field
  41399. // type.
  41400. func (m *WxCardMutation) AddField(name string, value ent.Value) error {
  41401. switch name {
  41402. case wxcard.FieldUserID:
  41403. v, ok := value.(int64)
  41404. if !ok {
  41405. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41406. }
  41407. m.AddUserID(v)
  41408. return nil
  41409. case wxcard.FieldWxUserID:
  41410. v, ok := value.(int64)
  41411. if !ok {
  41412. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41413. }
  41414. m.AddWxUserID(v)
  41415. return nil
  41416. }
  41417. return fmt.Errorf("unknown WxCard numeric field %s", name)
  41418. }
  41419. // ClearedFields returns all nullable fields that were cleared during this
  41420. // mutation.
  41421. func (m *WxCardMutation) ClearedFields() []string {
  41422. var fields []string
  41423. if m.FieldCleared(wxcard.FieldDeletedAt) {
  41424. fields = append(fields, wxcard.FieldDeletedAt)
  41425. }
  41426. if m.FieldCleared(wxcard.FieldUserID) {
  41427. fields = append(fields, wxcard.FieldUserID)
  41428. }
  41429. if m.FieldCleared(wxcard.FieldWxUserID) {
  41430. fields = append(fields, wxcard.FieldWxUserID)
  41431. }
  41432. if m.FieldCleared(wxcard.FieldEmail) {
  41433. fields = append(fields, wxcard.FieldEmail)
  41434. }
  41435. if m.FieldCleared(wxcard.FieldAPIBase) {
  41436. fields = append(fields, wxcard.FieldAPIBase)
  41437. }
  41438. if m.FieldCleared(wxcard.FieldAPIKey) {
  41439. fields = append(fields, wxcard.FieldAPIKey)
  41440. }
  41441. if m.FieldCleared(wxcard.FieldAiInfo) {
  41442. fields = append(fields, wxcard.FieldAiInfo)
  41443. }
  41444. if m.FieldCleared(wxcard.FieldIntro) {
  41445. fields = append(fields, wxcard.FieldIntro)
  41446. }
  41447. return fields
  41448. }
  41449. // FieldCleared returns a boolean indicating if a field with the given name was
  41450. // cleared in this mutation.
  41451. func (m *WxCardMutation) FieldCleared(name string) bool {
  41452. _, ok := m.clearedFields[name]
  41453. return ok
  41454. }
  41455. // ClearField clears the value of the field with the given name. It returns an
  41456. // error if the field is not defined in the schema.
  41457. func (m *WxCardMutation) ClearField(name string) error {
  41458. switch name {
  41459. case wxcard.FieldDeletedAt:
  41460. m.ClearDeletedAt()
  41461. return nil
  41462. case wxcard.FieldUserID:
  41463. m.ClearUserID()
  41464. return nil
  41465. case wxcard.FieldWxUserID:
  41466. m.ClearWxUserID()
  41467. return nil
  41468. case wxcard.FieldEmail:
  41469. m.ClearEmail()
  41470. return nil
  41471. case wxcard.FieldAPIBase:
  41472. m.ClearAPIBase()
  41473. return nil
  41474. case wxcard.FieldAPIKey:
  41475. m.ClearAPIKey()
  41476. return nil
  41477. case wxcard.FieldAiInfo:
  41478. m.ClearAiInfo()
  41479. return nil
  41480. case wxcard.FieldIntro:
  41481. m.ClearIntro()
  41482. return nil
  41483. }
  41484. return fmt.Errorf("unknown WxCard nullable field %s", name)
  41485. }
  41486. // ResetField resets all changes in the mutation for the field with the given name.
  41487. // It returns an error if the field is not defined in the schema.
  41488. func (m *WxCardMutation) ResetField(name string) error {
  41489. switch name {
  41490. case wxcard.FieldCreatedAt:
  41491. m.ResetCreatedAt()
  41492. return nil
  41493. case wxcard.FieldUpdatedAt:
  41494. m.ResetUpdatedAt()
  41495. return nil
  41496. case wxcard.FieldDeletedAt:
  41497. m.ResetDeletedAt()
  41498. return nil
  41499. case wxcard.FieldUserID:
  41500. m.ResetUserID()
  41501. return nil
  41502. case wxcard.FieldWxUserID:
  41503. m.ResetWxUserID()
  41504. return nil
  41505. case wxcard.FieldAvatar:
  41506. m.ResetAvatar()
  41507. return nil
  41508. case wxcard.FieldLogo:
  41509. m.ResetLogo()
  41510. return nil
  41511. case wxcard.FieldName:
  41512. m.ResetName()
  41513. return nil
  41514. case wxcard.FieldCompany:
  41515. m.ResetCompany()
  41516. return nil
  41517. case wxcard.FieldAddress:
  41518. m.ResetAddress()
  41519. return nil
  41520. case wxcard.FieldPhone:
  41521. m.ResetPhone()
  41522. return nil
  41523. case wxcard.FieldOfficialAccount:
  41524. m.ResetOfficialAccount()
  41525. return nil
  41526. case wxcard.FieldWechatAccount:
  41527. m.ResetWechatAccount()
  41528. return nil
  41529. case wxcard.FieldEmail:
  41530. m.ResetEmail()
  41531. return nil
  41532. case wxcard.FieldAPIBase:
  41533. m.ResetAPIBase()
  41534. return nil
  41535. case wxcard.FieldAPIKey:
  41536. m.ResetAPIKey()
  41537. return nil
  41538. case wxcard.FieldAiInfo:
  41539. m.ResetAiInfo()
  41540. return nil
  41541. case wxcard.FieldIntro:
  41542. m.ResetIntro()
  41543. return nil
  41544. }
  41545. return fmt.Errorf("unknown WxCard field %s", name)
  41546. }
  41547. // AddedEdges returns all edge names that were set/added in this mutation.
  41548. func (m *WxCardMutation) AddedEdges() []string {
  41549. edges := make([]string, 0, 0)
  41550. return edges
  41551. }
  41552. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  41553. // name in this mutation.
  41554. func (m *WxCardMutation) AddedIDs(name string) []ent.Value {
  41555. return nil
  41556. }
  41557. // RemovedEdges returns all edge names that were removed in this mutation.
  41558. func (m *WxCardMutation) RemovedEdges() []string {
  41559. edges := make([]string, 0, 0)
  41560. return edges
  41561. }
  41562. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  41563. // the given name in this mutation.
  41564. func (m *WxCardMutation) RemovedIDs(name string) []ent.Value {
  41565. return nil
  41566. }
  41567. // ClearedEdges returns all edge names that were cleared in this mutation.
  41568. func (m *WxCardMutation) ClearedEdges() []string {
  41569. edges := make([]string, 0, 0)
  41570. return edges
  41571. }
  41572. // EdgeCleared returns a boolean which indicates if the edge with the given name
  41573. // was cleared in this mutation.
  41574. func (m *WxCardMutation) EdgeCleared(name string) bool {
  41575. return false
  41576. }
  41577. // ClearEdge clears the value of the edge with the given name. It returns an error
  41578. // if that edge is not defined in the schema.
  41579. func (m *WxCardMutation) ClearEdge(name string) error {
  41580. return fmt.Errorf("unknown WxCard unique edge %s", name)
  41581. }
  41582. // ResetEdge resets all changes to the edge with the given name in this mutation.
  41583. // It returns an error if the edge is not defined in the schema.
  41584. func (m *WxCardMutation) ResetEdge(name string) error {
  41585. return fmt.Errorf("unknown WxCard edge %s", name)
  41586. }
  41587. // WxCardUserMutation represents an operation that mutates the WxCardUser nodes in the graph.
  41588. type WxCardUserMutation struct {
  41589. config
  41590. op Op
  41591. typ string
  41592. id *uint64
  41593. created_at *time.Time
  41594. updated_at *time.Time
  41595. deleted_at *time.Time
  41596. wxid *string
  41597. account *string
  41598. avatar *string
  41599. nickname *string
  41600. remark *string
  41601. phone *string
  41602. open_id *string
  41603. union_id *string
  41604. session_key *string
  41605. is_vip *int
  41606. addis_vip *int
  41607. clearedFields map[string]struct{}
  41608. done bool
  41609. oldValue func(context.Context) (*WxCardUser, error)
  41610. predicates []predicate.WxCardUser
  41611. }
  41612. var _ ent.Mutation = (*WxCardUserMutation)(nil)
  41613. // wxcarduserOption allows management of the mutation configuration using functional options.
  41614. type wxcarduserOption func(*WxCardUserMutation)
  41615. // newWxCardUserMutation creates new mutation for the WxCardUser entity.
  41616. func newWxCardUserMutation(c config, op Op, opts ...wxcarduserOption) *WxCardUserMutation {
  41617. m := &WxCardUserMutation{
  41618. config: c,
  41619. op: op,
  41620. typ: TypeWxCardUser,
  41621. clearedFields: make(map[string]struct{}),
  41622. }
  41623. for _, opt := range opts {
  41624. opt(m)
  41625. }
  41626. return m
  41627. }
  41628. // withWxCardUserID sets the ID field of the mutation.
  41629. func withWxCardUserID(id uint64) wxcarduserOption {
  41630. return func(m *WxCardUserMutation) {
  41631. var (
  41632. err error
  41633. once sync.Once
  41634. value *WxCardUser
  41635. )
  41636. m.oldValue = func(ctx context.Context) (*WxCardUser, error) {
  41637. once.Do(func() {
  41638. if m.done {
  41639. err = errors.New("querying old values post mutation is not allowed")
  41640. } else {
  41641. value, err = m.Client().WxCardUser.Get(ctx, id)
  41642. }
  41643. })
  41644. return value, err
  41645. }
  41646. m.id = &id
  41647. }
  41648. }
  41649. // withWxCardUser sets the old WxCardUser of the mutation.
  41650. func withWxCardUser(node *WxCardUser) wxcarduserOption {
  41651. return func(m *WxCardUserMutation) {
  41652. m.oldValue = func(context.Context) (*WxCardUser, error) {
  41653. return node, nil
  41654. }
  41655. m.id = &node.ID
  41656. }
  41657. }
  41658. // Client returns a new `ent.Client` from the mutation. If the mutation was
  41659. // executed in a transaction (ent.Tx), a transactional client is returned.
  41660. func (m WxCardUserMutation) Client() *Client {
  41661. client := &Client{config: m.config}
  41662. client.init()
  41663. return client
  41664. }
  41665. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  41666. // it returns an error otherwise.
  41667. func (m WxCardUserMutation) Tx() (*Tx, error) {
  41668. if _, ok := m.driver.(*txDriver); !ok {
  41669. return nil, errors.New("ent: mutation is not running in a transaction")
  41670. }
  41671. tx := &Tx{config: m.config}
  41672. tx.init()
  41673. return tx, nil
  41674. }
  41675. // SetID sets the value of the id field. Note that this
  41676. // operation is only accepted on creation of WxCardUser entities.
  41677. func (m *WxCardUserMutation) SetID(id uint64) {
  41678. m.id = &id
  41679. }
  41680. // ID returns the ID value in the mutation. Note that the ID is only available
  41681. // if it was provided to the builder or after it was returned from the database.
  41682. func (m *WxCardUserMutation) ID() (id uint64, exists bool) {
  41683. if m.id == nil {
  41684. return
  41685. }
  41686. return *m.id, true
  41687. }
  41688. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  41689. // That means, if the mutation is applied within a transaction with an isolation level such
  41690. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  41691. // or updated by the mutation.
  41692. func (m *WxCardUserMutation) IDs(ctx context.Context) ([]uint64, error) {
  41693. switch {
  41694. case m.op.Is(OpUpdateOne | OpDeleteOne):
  41695. id, exists := m.ID()
  41696. if exists {
  41697. return []uint64{id}, nil
  41698. }
  41699. fallthrough
  41700. case m.op.Is(OpUpdate | OpDelete):
  41701. return m.Client().WxCardUser.Query().Where(m.predicates...).IDs(ctx)
  41702. default:
  41703. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  41704. }
  41705. }
  41706. // SetCreatedAt sets the "created_at" field.
  41707. func (m *WxCardUserMutation) SetCreatedAt(t time.Time) {
  41708. m.created_at = &t
  41709. }
  41710. // CreatedAt returns the value of the "created_at" field in the mutation.
  41711. func (m *WxCardUserMutation) CreatedAt() (r time.Time, exists bool) {
  41712. v := m.created_at
  41713. if v == nil {
  41714. return
  41715. }
  41716. return *v, true
  41717. }
  41718. // OldCreatedAt returns the old "created_at" field's value of the WxCardUser entity.
  41719. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  41720. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41721. func (m *WxCardUserMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  41722. if !m.op.Is(OpUpdateOne) {
  41723. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  41724. }
  41725. if m.id == nil || m.oldValue == nil {
  41726. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  41727. }
  41728. oldValue, err := m.oldValue(ctx)
  41729. if err != nil {
  41730. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  41731. }
  41732. return oldValue.CreatedAt, nil
  41733. }
  41734. // ResetCreatedAt resets all changes to the "created_at" field.
  41735. func (m *WxCardUserMutation) ResetCreatedAt() {
  41736. m.created_at = nil
  41737. }
  41738. // SetUpdatedAt sets the "updated_at" field.
  41739. func (m *WxCardUserMutation) SetUpdatedAt(t time.Time) {
  41740. m.updated_at = &t
  41741. }
  41742. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  41743. func (m *WxCardUserMutation) UpdatedAt() (r time.Time, exists bool) {
  41744. v := m.updated_at
  41745. if v == nil {
  41746. return
  41747. }
  41748. return *v, true
  41749. }
  41750. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardUser entity.
  41751. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  41752. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41753. func (m *WxCardUserMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  41754. if !m.op.Is(OpUpdateOne) {
  41755. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  41756. }
  41757. if m.id == nil || m.oldValue == nil {
  41758. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  41759. }
  41760. oldValue, err := m.oldValue(ctx)
  41761. if err != nil {
  41762. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  41763. }
  41764. return oldValue.UpdatedAt, nil
  41765. }
  41766. // ResetUpdatedAt resets all changes to the "updated_at" field.
  41767. func (m *WxCardUserMutation) ResetUpdatedAt() {
  41768. m.updated_at = nil
  41769. }
  41770. // SetDeletedAt sets the "deleted_at" field.
  41771. func (m *WxCardUserMutation) SetDeletedAt(t time.Time) {
  41772. m.deleted_at = &t
  41773. }
  41774. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  41775. func (m *WxCardUserMutation) DeletedAt() (r time.Time, exists bool) {
  41776. v := m.deleted_at
  41777. if v == nil {
  41778. return
  41779. }
  41780. return *v, true
  41781. }
  41782. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardUser entity.
  41783. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  41784. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41785. func (m *WxCardUserMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  41786. if !m.op.Is(OpUpdateOne) {
  41787. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  41788. }
  41789. if m.id == nil || m.oldValue == nil {
  41790. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  41791. }
  41792. oldValue, err := m.oldValue(ctx)
  41793. if err != nil {
  41794. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  41795. }
  41796. return oldValue.DeletedAt, nil
  41797. }
  41798. // ClearDeletedAt clears the value of the "deleted_at" field.
  41799. func (m *WxCardUserMutation) ClearDeletedAt() {
  41800. m.deleted_at = nil
  41801. m.clearedFields[wxcarduser.FieldDeletedAt] = struct{}{}
  41802. }
  41803. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  41804. func (m *WxCardUserMutation) DeletedAtCleared() bool {
  41805. _, ok := m.clearedFields[wxcarduser.FieldDeletedAt]
  41806. return ok
  41807. }
  41808. // ResetDeletedAt resets all changes to the "deleted_at" field.
  41809. func (m *WxCardUserMutation) ResetDeletedAt() {
  41810. m.deleted_at = nil
  41811. delete(m.clearedFields, wxcarduser.FieldDeletedAt)
  41812. }
  41813. // SetWxid sets the "wxid" field.
  41814. func (m *WxCardUserMutation) SetWxid(s string) {
  41815. m.wxid = &s
  41816. }
  41817. // Wxid returns the value of the "wxid" field in the mutation.
  41818. func (m *WxCardUserMutation) Wxid() (r string, exists bool) {
  41819. v := m.wxid
  41820. if v == nil {
  41821. return
  41822. }
  41823. return *v, true
  41824. }
  41825. // OldWxid returns the old "wxid" field's value of the WxCardUser entity.
  41826. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  41827. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41828. func (m *WxCardUserMutation) OldWxid(ctx context.Context) (v string, err error) {
  41829. if !m.op.Is(OpUpdateOne) {
  41830. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  41831. }
  41832. if m.id == nil || m.oldValue == nil {
  41833. return v, errors.New("OldWxid requires an ID field in the mutation")
  41834. }
  41835. oldValue, err := m.oldValue(ctx)
  41836. if err != nil {
  41837. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  41838. }
  41839. return oldValue.Wxid, nil
  41840. }
  41841. // ResetWxid resets all changes to the "wxid" field.
  41842. func (m *WxCardUserMutation) ResetWxid() {
  41843. m.wxid = nil
  41844. }
  41845. // SetAccount sets the "account" field.
  41846. func (m *WxCardUserMutation) SetAccount(s string) {
  41847. m.account = &s
  41848. }
  41849. // Account returns the value of the "account" field in the mutation.
  41850. func (m *WxCardUserMutation) Account() (r string, exists bool) {
  41851. v := m.account
  41852. if v == nil {
  41853. return
  41854. }
  41855. return *v, true
  41856. }
  41857. // OldAccount returns the old "account" field's value of the WxCardUser entity.
  41858. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  41859. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41860. func (m *WxCardUserMutation) OldAccount(ctx context.Context) (v string, err error) {
  41861. if !m.op.Is(OpUpdateOne) {
  41862. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  41863. }
  41864. if m.id == nil || m.oldValue == nil {
  41865. return v, errors.New("OldAccount requires an ID field in the mutation")
  41866. }
  41867. oldValue, err := m.oldValue(ctx)
  41868. if err != nil {
  41869. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  41870. }
  41871. return oldValue.Account, nil
  41872. }
  41873. // ResetAccount resets all changes to the "account" field.
  41874. func (m *WxCardUserMutation) ResetAccount() {
  41875. m.account = nil
  41876. }
  41877. // SetAvatar sets the "avatar" field.
  41878. func (m *WxCardUserMutation) SetAvatar(s string) {
  41879. m.avatar = &s
  41880. }
  41881. // Avatar returns the value of the "avatar" field in the mutation.
  41882. func (m *WxCardUserMutation) Avatar() (r string, exists bool) {
  41883. v := m.avatar
  41884. if v == nil {
  41885. return
  41886. }
  41887. return *v, true
  41888. }
  41889. // OldAvatar returns the old "avatar" field's value of the WxCardUser entity.
  41890. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  41891. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41892. func (m *WxCardUserMutation) OldAvatar(ctx context.Context) (v string, err error) {
  41893. if !m.op.Is(OpUpdateOne) {
  41894. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  41895. }
  41896. if m.id == nil || m.oldValue == nil {
  41897. return v, errors.New("OldAvatar requires an ID field in the mutation")
  41898. }
  41899. oldValue, err := m.oldValue(ctx)
  41900. if err != nil {
  41901. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  41902. }
  41903. return oldValue.Avatar, nil
  41904. }
  41905. // ResetAvatar resets all changes to the "avatar" field.
  41906. func (m *WxCardUserMutation) ResetAvatar() {
  41907. m.avatar = nil
  41908. }
  41909. // SetNickname sets the "nickname" field.
  41910. func (m *WxCardUserMutation) SetNickname(s string) {
  41911. m.nickname = &s
  41912. }
  41913. // Nickname returns the value of the "nickname" field in the mutation.
  41914. func (m *WxCardUserMutation) Nickname() (r string, exists bool) {
  41915. v := m.nickname
  41916. if v == nil {
  41917. return
  41918. }
  41919. return *v, true
  41920. }
  41921. // OldNickname returns the old "nickname" field's value of the WxCardUser entity.
  41922. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  41923. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41924. func (m *WxCardUserMutation) OldNickname(ctx context.Context) (v string, err error) {
  41925. if !m.op.Is(OpUpdateOne) {
  41926. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  41927. }
  41928. if m.id == nil || m.oldValue == nil {
  41929. return v, errors.New("OldNickname requires an ID field in the mutation")
  41930. }
  41931. oldValue, err := m.oldValue(ctx)
  41932. if err != nil {
  41933. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  41934. }
  41935. return oldValue.Nickname, nil
  41936. }
  41937. // ResetNickname resets all changes to the "nickname" field.
  41938. func (m *WxCardUserMutation) ResetNickname() {
  41939. m.nickname = nil
  41940. }
  41941. // SetRemark sets the "remark" field.
  41942. func (m *WxCardUserMutation) SetRemark(s string) {
  41943. m.remark = &s
  41944. }
  41945. // Remark returns the value of the "remark" field in the mutation.
  41946. func (m *WxCardUserMutation) Remark() (r string, exists bool) {
  41947. v := m.remark
  41948. if v == nil {
  41949. return
  41950. }
  41951. return *v, true
  41952. }
  41953. // OldRemark returns the old "remark" field's value of the WxCardUser entity.
  41954. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  41955. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41956. func (m *WxCardUserMutation) OldRemark(ctx context.Context) (v string, err error) {
  41957. if !m.op.Is(OpUpdateOne) {
  41958. return v, errors.New("OldRemark is only allowed on UpdateOne operations")
  41959. }
  41960. if m.id == nil || m.oldValue == nil {
  41961. return v, errors.New("OldRemark requires an ID field in the mutation")
  41962. }
  41963. oldValue, err := m.oldValue(ctx)
  41964. if err != nil {
  41965. return v, fmt.Errorf("querying old value for OldRemark: %w", err)
  41966. }
  41967. return oldValue.Remark, nil
  41968. }
  41969. // ResetRemark resets all changes to the "remark" field.
  41970. func (m *WxCardUserMutation) ResetRemark() {
  41971. m.remark = nil
  41972. }
  41973. // SetPhone sets the "phone" field.
  41974. func (m *WxCardUserMutation) SetPhone(s string) {
  41975. m.phone = &s
  41976. }
  41977. // Phone returns the value of the "phone" field in the mutation.
  41978. func (m *WxCardUserMutation) Phone() (r string, exists bool) {
  41979. v := m.phone
  41980. if v == nil {
  41981. return
  41982. }
  41983. return *v, true
  41984. }
  41985. // OldPhone returns the old "phone" field's value of the WxCardUser entity.
  41986. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  41987. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41988. func (m *WxCardUserMutation) OldPhone(ctx context.Context) (v string, err error) {
  41989. if !m.op.Is(OpUpdateOne) {
  41990. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  41991. }
  41992. if m.id == nil || m.oldValue == nil {
  41993. return v, errors.New("OldPhone requires an ID field in the mutation")
  41994. }
  41995. oldValue, err := m.oldValue(ctx)
  41996. if err != nil {
  41997. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  41998. }
  41999. return oldValue.Phone, nil
  42000. }
  42001. // ResetPhone resets all changes to the "phone" field.
  42002. func (m *WxCardUserMutation) ResetPhone() {
  42003. m.phone = nil
  42004. }
  42005. // SetOpenID sets the "open_id" field.
  42006. func (m *WxCardUserMutation) SetOpenID(s string) {
  42007. m.open_id = &s
  42008. }
  42009. // OpenID returns the value of the "open_id" field in the mutation.
  42010. func (m *WxCardUserMutation) OpenID() (r string, exists bool) {
  42011. v := m.open_id
  42012. if v == nil {
  42013. return
  42014. }
  42015. return *v, true
  42016. }
  42017. // OldOpenID returns the old "open_id" field's value of the WxCardUser entity.
  42018. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  42019. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42020. func (m *WxCardUserMutation) OldOpenID(ctx context.Context) (v string, err error) {
  42021. if !m.op.Is(OpUpdateOne) {
  42022. return v, errors.New("OldOpenID is only allowed on UpdateOne operations")
  42023. }
  42024. if m.id == nil || m.oldValue == nil {
  42025. return v, errors.New("OldOpenID requires an ID field in the mutation")
  42026. }
  42027. oldValue, err := m.oldValue(ctx)
  42028. if err != nil {
  42029. return v, fmt.Errorf("querying old value for OldOpenID: %w", err)
  42030. }
  42031. return oldValue.OpenID, nil
  42032. }
  42033. // ResetOpenID resets all changes to the "open_id" field.
  42034. func (m *WxCardUserMutation) ResetOpenID() {
  42035. m.open_id = nil
  42036. }
  42037. // SetUnionID sets the "union_id" field.
  42038. func (m *WxCardUserMutation) SetUnionID(s string) {
  42039. m.union_id = &s
  42040. }
  42041. // UnionID returns the value of the "union_id" field in the mutation.
  42042. func (m *WxCardUserMutation) UnionID() (r string, exists bool) {
  42043. v := m.union_id
  42044. if v == nil {
  42045. return
  42046. }
  42047. return *v, true
  42048. }
  42049. // OldUnionID returns the old "union_id" field's value of the WxCardUser entity.
  42050. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  42051. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42052. func (m *WxCardUserMutation) OldUnionID(ctx context.Context) (v string, err error) {
  42053. if !m.op.Is(OpUpdateOne) {
  42054. return v, errors.New("OldUnionID is only allowed on UpdateOne operations")
  42055. }
  42056. if m.id == nil || m.oldValue == nil {
  42057. return v, errors.New("OldUnionID requires an ID field in the mutation")
  42058. }
  42059. oldValue, err := m.oldValue(ctx)
  42060. if err != nil {
  42061. return v, fmt.Errorf("querying old value for OldUnionID: %w", err)
  42062. }
  42063. return oldValue.UnionID, nil
  42064. }
  42065. // ResetUnionID resets all changes to the "union_id" field.
  42066. func (m *WxCardUserMutation) ResetUnionID() {
  42067. m.union_id = nil
  42068. }
  42069. // SetSessionKey sets the "session_key" field.
  42070. func (m *WxCardUserMutation) SetSessionKey(s string) {
  42071. m.session_key = &s
  42072. }
  42073. // SessionKey returns the value of the "session_key" field in the mutation.
  42074. func (m *WxCardUserMutation) SessionKey() (r string, exists bool) {
  42075. v := m.session_key
  42076. if v == nil {
  42077. return
  42078. }
  42079. return *v, true
  42080. }
  42081. // OldSessionKey returns the old "session_key" field's value of the WxCardUser entity.
  42082. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  42083. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42084. func (m *WxCardUserMutation) OldSessionKey(ctx context.Context) (v string, err error) {
  42085. if !m.op.Is(OpUpdateOne) {
  42086. return v, errors.New("OldSessionKey is only allowed on UpdateOne operations")
  42087. }
  42088. if m.id == nil || m.oldValue == nil {
  42089. return v, errors.New("OldSessionKey requires an ID field in the mutation")
  42090. }
  42091. oldValue, err := m.oldValue(ctx)
  42092. if err != nil {
  42093. return v, fmt.Errorf("querying old value for OldSessionKey: %w", err)
  42094. }
  42095. return oldValue.SessionKey, nil
  42096. }
  42097. // ResetSessionKey resets all changes to the "session_key" field.
  42098. func (m *WxCardUserMutation) ResetSessionKey() {
  42099. m.session_key = nil
  42100. }
  42101. // SetIsVip sets the "is_vip" field.
  42102. func (m *WxCardUserMutation) SetIsVip(i int) {
  42103. m.is_vip = &i
  42104. m.addis_vip = nil
  42105. }
  42106. // IsVip returns the value of the "is_vip" field in the mutation.
  42107. func (m *WxCardUserMutation) IsVip() (r int, exists bool) {
  42108. v := m.is_vip
  42109. if v == nil {
  42110. return
  42111. }
  42112. return *v, true
  42113. }
  42114. // OldIsVip returns the old "is_vip" field's value of the WxCardUser entity.
  42115. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  42116. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42117. func (m *WxCardUserMutation) OldIsVip(ctx context.Context) (v int, err error) {
  42118. if !m.op.Is(OpUpdateOne) {
  42119. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  42120. }
  42121. if m.id == nil || m.oldValue == nil {
  42122. return v, errors.New("OldIsVip requires an ID field in the mutation")
  42123. }
  42124. oldValue, err := m.oldValue(ctx)
  42125. if err != nil {
  42126. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  42127. }
  42128. return oldValue.IsVip, nil
  42129. }
  42130. // AddIsVip adds i to the "is_vip" field.
  42131. func (m *WxCardUserMutation) AddIsVip(i int) {
  42132. if m.addis_vip != nil {
  42133. *m.addis_vip += i
  42134. } else {
  42135. m.addis_vip = &i
  42136. }
  42137. }
  42138. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  42139. func (m *WxCardUserMutation) AddedIsVip() (r int, exists bool) {
  42140. v := m.addis_vip
  42141. if v == nil {
  42142. return
  42143. }
  42144. return *v, true
  42145. }
  42146. // ResetIsVip resets all changes to the "is_vip" field.
  42147. func (m *WxCardUserMutation) ResetIsVip() {
  42148. m.is_vip = nil
  42149. m.addis_vip = nil
  42150. }
  42151. // Where appends a list predicates to the WxCardUserMutation builder.
  42152. func (m *WxCardUserMutation) Where(ps ...predicate.WxCardUser) {
  42153. m.predicates = append(m.predicates, ps...)
  42154. }
  42155. // WhereP appends storage-level predicates to the WxCardUserMutation builder. Using this method,
  42156. // users can use type-assertion to append predicates that do not depend on any generated package.
  42157. func (m *WxCardUserMutation) WhereP(ps ...func(*sql.Selector)) {
  42158. p := make([]predicate.WxCardUser, len(ps))
  42159. for i := range ps {
  42160. p[i] = ps[i]
  42161. }
  42162. m.Where(p...)
  42163. }
  42164. // Op returns the operation name.
  42165. func (m *WxCardUserMutation) Op() Op {
  42166. return m.op
  42167. }
  42168. // SetOp allows setting the mutation operation.
  42169. func (m *WxCardUserMutation) SetOp(op Op) {
  42170. m.op = op
  42171. }
  42172. // Type returns the node type of this mutation (WxCardUser).
  42173. func (m *WxCardUserMutation) Type() string {
  42174. return m.typ
  42175. }
  42176. // Fields returns all fields that were changed during this mutation. Note that in
  42177. // order to get all numeric fields that were incremented/decremented, call
  42178. // AddedFields().
  42179. func (m *WxCardUserMutation) Fields() []string {
  42180. fields := make([]string, 0, 13)
  42181. if m.created_at != nil {
  42182. fields = append(fields, wxcarduser.FieldCreatedAt)
  42183. }
  42184. if m.updated_at != nil {
  42185. fields = append(fields, wxcarduser.FieldUpdatedAt)
  42186. }
  42187. if m.deleted_at != nil {
  42188. fields = append(fields, wxcarduser.FieldDeletedAt)
  42189. }
  42190. if m.wxid != nil {
  42191. fields = append(fields, wxcarduser.FieldWxid)
  42192. }
  42193. if m.account != nil {
  42194. fields = append(fields, wxcarduser.FieldAccount)
  42195. }
  42196. if m.avatar != nil {
  42197. fields = append(fields, wxcarduser.FieldAvatar)
  42198. }
  42199. if m.nickname != nil {
  42200. fields = append(fields, wxcarduser.FieldNickname)
  42201. }
  42202. if m.remark != nil {
  42203. fields = append(fields, wxcarduser.FieldRemark)
  42204. }
  42205. if m.phone != nil {
  42206. fields = append(fields, wxcarduser.FieldPhone)
  42207. }
  42208. if m.open_id != nil {
  42209. fields = append(fields, wxcarduser.FieldOpenID)
  42210. }
  42211. if m.union_id != nil {
  42212. fields = append(fields, wxcarduser.FieldUnionID)
  42213. }
  42214. if m.session_key != nil {
  42215. fields = append(fields, wxcarduser.FieldSessionKey)
  42216. }
  42217. if m.is_vip != nil {
  42218. fields = append(fields, wxcarduser.FieldIsVip)
  42219. }
  42220. return fields
  42221. }
  42222. // Field returns the value of a field with the given name. The second boolean
  42223. // return value indicates that this field was not set, or was not defined in the
  42224. // schema.
  42225. func (m *WxCardUserMutation) Field(name string) (ent.Value, bool) {
  42226. switch name {
  42227. case wxcarduser.FieldCreatedAt:
  42228. return m.CreatedAt()
  42229. case wxcarduser.FieldUpdatedAt:
  42230. return m.UpdatedAt()
  42231. case wxcarduser.FieldDeletedAt:
  42232. return m.DeletedAt()
  42233. case wxcarduser.FieldWxid:
  42234. return m.Wxid()
  42235. case wxcarduser.FieldAccount:
  42236. return m.Account()
  42237. case wxcarduser.FieldAvatar:
  42238. return m.Avatar()
  42239. case wxcarduser.FieldNickname:
  42240. return m.Nickname()
  42241. case wxcarduser.FieldRemark:
  42242. return m.Remark()
  42243. case wxcarduser.FieldPhone:
  42244. return m.Phone()
  42245. case wxcarduser.FieldOpenID:
  42246. return m.OpenID()
  42247. case wxcarduser.FieldUnionID:
  42248. return m.UnionID()
  42249. case wxcarduser.FieldSessionKey:
  42250. return m.SessionKey()
  42251. case wxcarduser.FieldIsVip:
  42252. return m.IsVip()
  42253. }
  42254. return nil, false
  42255. }
  42256. // OldField returns the old value of the field from the database. An error is
  42257. // returned if the mutation operation is not UpdateOne, or the query to the
  42258. // database failed.
  42259. func (m *WxCardUserMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  42260. switch name {
  42261. case wxcarduser.FieldCreatedAt:
  42262. return m.OldCreatedAt(ctx)
  42263. case wxcarduser.FieldUpdatedAt:
  42264. return m.OldUpdatedAt(ctx)
  42265. case wxcarduser.FieldDeletedAt:
  42266. return m.OldDeletedAt(ctx)
  42267. case wxcarduser.FieldWxid:
  42268. return m.OldWxid(ctx)
  42269. case wxcarduser.FieldAccount:
  42270. return m.OldAccount(ctx)
  42271. case wxcarduser.FieldAvatar:
  42272. return m.OldAvatar(ctx)
  42273. case wxcarduser.FieldNickname:
  42274. return m.OldNickname(ctx)
  42275. case wxcarduser.FieldRemark:
  42276. return m.OldRemark(ctx)
  42277. case wxcarduser.FieldPhone:
  42278. return m.OldPhone(ctx)
  42279. case wxcarduser.FieldOpenID:
  42280. return m.OldOpenID(ctx)
  42281. case wxcarduser.FieldUnionID:
  42282. return m.OldUnionID(ctx)
  42283. case wxcarduser.FieldSessionKey:
  42284. return m.OldSessionKey(ctx)
  42285. case wxcarduser.FieldIsVip:
  42286. return m.OldIsVip(ctx)
  42287. }
  42288. return nil, fmt.Errorf("unknown WxCardUser field %s", name)
  42289. }
  42290. // SetField sets the value of a field with the given name. It returns an error if
  42291. // the field is not defined in the schema, or if the type mismatched the field
  42292. // type.
  42293. func (m *WxCardUserMutation) SetField(name string, value ent.Value) error {
  42294. switch name {
  42295. case wxcarduser.FieldCreatedAt:
  42296. v, ok := value.(time.Time)
  42297. if !ok {
  42298. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42299. }
  42300. m.SetCreatedAt(v)
  42301. return nil
  42302. case wxcarduser.FieldUpdatedAt:
  42303. v, ok := value.(time.Time)
  42304. if !ok {
  42305. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42306. }
  42307. m.SetUpdatedAt(v)
  42308. return nil
  42309. case wxcarduser.FieldDeletedAt:
  42310. v, ok := value.(time.Time)
  42311. if !ok {
  42312. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42313. }
  42314. m.SetDeletedAt(v)
  42315. return nil
  42316. case wxcarduser.FieldWxid:
  42317. v, ok := value.(string)
  42318. if !ok {
  42319. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42320. }
  42321. m.SetWxid(v)
  42322. return nil
  42323. case wxcarduser.FieldAccount:
  42324. v, ok := value.(string)
  42325. if !ok {
  42326. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42327. }
  42328. m.SetAccount(v)
  42329. return nil
  42330. case wxcarduser.FieldAvatar:
  42331. v, ok := value.(string)
  42332. if !ok {
  42333. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42334. }
  42335. m.SetAvatar(v)
  42336. return nil
  42337. case wxcarduser.FieldNickname:
  42338. v, ok := value.(string)
  42339. if !ok {
  42340. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42341. }
  42342. m.SetNickname(v)
  42343. return nil
  42344. case wxcarduser.FieldRemark:
  42345. v, ok := value.(string)
  42346. if !ok {
  42347. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42348. }
  42349. m.SetRemark(v)
  42350. return nil
  42351. case wxcarduser.FieldPhone:
  42352. v, ok := value.(string)
  42353. if !ok {
  42354. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42355. }
  42356. m.SetPhone(v)
  42357. return nil
  42358. case wxcarduser.FieldOpenID:
  42359. v, ok := value.(string)
  42360. if !ok {
  42361. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42362. }
  42363. m.SetOpenID(v)
  42364. return nil
  42365. case wxcarduser.FieldUnionID:
  42366. v, ok := value.(string)
  42367. if !ok {
  42368. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42369. }
  42370. m.SetUnionID(v)
  42371. return nil
  42372. case wxcarduser.FieldSessionKey:
  42373. v, ok := value.(string)
  42374. if !ok {
  42375. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42376. }
  42377. m.SetSessionKey(v)
  42378. return nil
  42379. case wxcarduser.FieldIsVip:
  42380. v, ok := value.(int)
  42381. if !ok {
  42382. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42383. }
  42384. m.SetIsVip(v)
  42385. return nil
  42386. }
  42387. return fmt.Errorf("unknown WxCardUser field %s", name)
  42388. }
  42389. // AddedFields returns all numeric fields that were incremented/decremented during
  42390. // this mutation.
  42391. func (m *WxCardUserMutation) AddedFields() []string {
  42392. var fields []string
  42393. if m.addis_vip != nil {
  42394. fields = append(fields, wxcarduser.FieldIsVip)
  42395. }
  42396. return fields
  42397. }
  42398. // AddedField returns the numeric value that was incremented/decremented on a field
  42399. // with the given name. The second boolean return value indicates that this field
  42400. // was not set, or was not defined in the schema.
  42401. func (m *WxCardUserMutation) AddedField(name string) (ent.Value, bool) {
  42402. switch name {
  42403. case wxcarduser.FieldIsVip:
  42404. return m.AddedIsVip()
  42405. }
  42406. return nil, false
  42407. }
  42408. // AddField adds the value to the field with the given name. It returns an error if
  42409. // the field is not defined in the schema, or if the type mismatched the field
  42410. // type.
  42411. func (m *WxCardUserMutation) AddField(name string, value ent.Value) error {
  42412. switch name {
  42413. case wxcarduser.FieldIsVip:
  42414. v, ok := value.(int)
  42415. if !ok {
  42416. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42417. }
  42418. m.AddIsVip(v)
  42419. return nil
  42420. }
  42421. return fmt.Errorf("unknown WxCardUser numeric field %s", name)
  42422. }
  42423. // ClearedFields returns all nullable fields that were cleared during this
  42424. // mutation.
  42425. func (m *WxCardUserMutation) ClearedFields() []string {
  42426. var fields []string
  42427. if m.FieldCleared(wxcarduser.FieldDeletedAt) {
  42428. fields = append(fields, wxcarduser.FieldDeletedAt)
  42429. }
  42430. return fields
  42431. }
  42432. // FieldCleared returns a boolean indicating if a field with the given name was
  42433. // cleared in this mutation.
  42434. func (m *WxCardUserMutation) FieldCleared(name string) bool {
  42435. _, ok := m.clearedFields[name]
  42436. return ok
  42437. }
  42438. // ClearField clears the value of the field with the given name. It returns an
  42439. // error if the field is not defined in the schema.
  42440. func (m *WxCardUserMutation) ClearField(name string) error {
  42441. switch name {
  42442. case wxcarduser.FieldDeletedAt:
  42443. m.ClearDeletedAt()
  42444. return nil
  42445. }
  42446. return fmt.Errorf("unknown WxCardUser nullable field %s", name)
  42447. }
  42448. // ResetField resets all changes in the mutation for the field with the given name.
  42449. // It returns an error if the field is not defined in the schema.
  42450. func (m *WxCardUserMutation) ResetField(name string) error {
  42451. switch name {
  42452. case wxcarduser.FieldCreatedAt:
  42453. m.ResetCreatedAt()
  42454. return nil
  42455. case wxcarduser.FieldUpdatedAt:
  42456. m.ResetUpdatedAt()
  42457. return nil
  42458. case wxcarduser.FieldDeletedAt:
  42459. m.ResetDeletedAt()
  42460. return nil
  42461. case wxcarduser.FieldWxid:
  42462. m.ResetWxid()
  42463. return nil
  42464. case wxcarduser.FieldAccount:
  42465. m.ResetAccount()
  42466. return nil
  42467. case wxcarduser.FieldAvatar:
  42468. m.ResetAvatar()
  42469. return nil
  42470. case wxcarduser.FieldNickname:
  42471. m.ResetNickname()
  42472. return nil
  42473. case wxcarduser.FieldRemark:
  42474. m.ResetRemark()
  42475. return nil
  42476. case wxcarduser.FieldPhone:
  42477. m.ResetPhone()
  42478. return nil
  42479. case wxcarduser.FieldOpenID:
  42480. m.ResetOpenID()
  42481. return nil
  42482. case wxcarduser.FieldUnionID:
  42483. m.ResetUnionID()
  42484. return nil
  42485. case wxcarduser.FieldSessionKey:
  42486. m.ResetSessionKey()
  42487. return nil
  42488. case wxcarduser.FieldIsVip:
  42489. m.ResetIsVip()
  42490. return nil
  42491. }
  42492. return fmt.Errorf("unknown WxCardUser field %s", name)
  42493. }
  42494. // AddedEdges returns all edge names that were set/added in this mutation.
  42495. func (m *WxCardUserMutation) AddedEdges() []string {
  42496. edges := make([]string, 0, 0)
  42497. return edges
  42498. }
  42499. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  42500. // name in this mutation.
  42501. func (m *WxCardUserMutation) AddedIDs(name string) []ent.Value {
  42502. return nil
  42503. }
  42504. // RemovedEdges returns all edge names that were removed in this mutation.
  42505. func (m *WxCardUserMutation) RemovedEdges() []string {
  42506. edges := make([]string, 0, 0)
  42507. return edges
  42508. }
  42509. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  42510. // the given name in this mutation.
  42511. func (m *WxCardUserMutation) RemovedIDs(name string) []ent.Value {
  42512. return nil
  42513. }
  42514. // ClearedEdges returns all edge names that were cleared in this mutation.
  42515. func (m *WxCardUserMutation) ClearedEdges() []string {
  42516. edges := make([]string, 0, 0)
  42517. return edges
  42518. }
  42519. // EdgeCleared returns a boolean which indicates if the edge with the given name
  42520. // was cleared in this mutation.
  42521. func (m *WxCardUserMutation) EdgeCleared(name string) bool {
  42522. return false
  42523. }
  42524. // ClearEdge clears the value of the edge with the given name. It returns an error
  42525. // if that edge is not defined in the schema.
  42526. func (m *WxCardUserMutation) ClearEdge(name string) error {
  42527. return fmt.Errorf("unknown WxCardUser unique edge %s", name)
  42528. }
  42529. // ResetEdge resets all changes to the edge with the given name in this mutation.
  42530. // It returns an error if the edge is not defined in the schema.
  42531. func (m *WxCardUserMutation) ResetEdge(name string) error {
  42532. return fmt.Errorf("unknown WxCardUser edge %s", name)
  42533. }
  42534. // WxCardVisitMutation represents an operation that mutates the WxCardVisit nodes in the graph.
  42535. type WxCardVisitMutation struct {
  42536. config
  42537. op Op
  42538. typ string
  42539. id *uint64
  42540. created_at *time.Time
  42541. updated_at *time.Time
  42542. deleted_at *time.Time
  42543. user_id *uint64
  42544. adduser_id *int64
  42545. bot_id *uint64
  42546. addbot_id *int64
  42547. bot_type *uint8
  42548. addbot_type *int8
  42549. clearedFields map[string]struct{}
  42550. done bool
  42551. oldValue func(context.Context) (*WxCardVisit, error)
  42552. predicates []predicate.WxCardVisit
  42553. }
  42554. var _ ent.Mutation = (*WxCardVisitMutation)(nil)
  42555. // wxcardvisitOption allows management of the mutation configuration using functional options.
  42556. type wxcardvisitOption func(*WxCardVisitMutation)
  42557. // newWxCardVisitMutation creates new mutation for the WxCardVisit entity.
  42558. func newWxCardVisitMutation(c config, op Op, opts ...wxcardvisitOption) *WxCardVisitMutation {
  42559. m := &WxCardVisitMutation{
  42560. config: c,
  42561. op: op,
  42562. typ: TypeWxCardVisit,
  42563. clearedFields: make(map[string]struct{}),
  42564. }
  42565. for _, opt := range opts {
  42566. opt(m)
  42567. }
  42568. return m
  42569. }
  42570. // withWxCardVisitID sets the ID field of the mutation.
  42571. func withWxCardVisitID(id uint64) wxcardvisitOption {
  42572. return func(m *WxCardVisitMutation) {
  42573. var (
  42574. err error
  42575. once sync.Once
  42576. value *WxCardVisit
  42577. )
  42578. m.oldValue = func(ctx context.Context) (*WxCardVisit, error) {
  42579. once.Do(func() {
  42580. if m.done {
  42581. err = errors.New("querying old values post mutation is not allowed")
  42582. } else {
  42583. value, err = m.Client().WxCardVisit.Get(ctx, id)
  42584. }
  42585. })
  42586. return value, err
  42587. }
  42588. m.id = &id
  42589. }
  42590. }
  42591. // withWxCardVisit sets the old WxCardVisit of the mutation.
  42592. func withWxCardVisit(node *WxCardVisit) wxcardvisitOption {
  42593. return func(m *WxCardVisitMutation) {
  42594. m.oldValue = func(context.Context) (*WxCardVisit, error) {
  42595. return node, nil
  42596. }
  42597. m.id = &node.ID
  42598. }
  42599. }
  42600. // Client returns a new `ent.Client` from the mutation. If the mutation was
  42601. // executed in a transaction (ent.Tx), a transactional client is returned.
  42602. func (m WxCardVisitMutation) Client() *Client {
  42603. client := &Client{config: m.config}
  42604. client.init()
  42605. return client
  42606. }
  42607. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  42608. // it returns an error otherwise.
  42609. func (m WxCardVisitMutation) Tx() (*Tx, error) {
  42610. if _, ok := m.driver.(*txDriver); !ok {
  42611. return nil, errors.New("ent: mutation is not running in a transaction")
  42612. }
  42613. tx := &Tx{config: m.config}
  42614. tx.init()
  42615. return tx, nil
  42616. }
  42617. // SetID sets the value of the id field. Note that this
  42618. // operation is only accepted on creation of WxCardVisit entities.
  42619. func (m *WxCardVisitMutation) SetID(id uint64) {
  42620. m.id = &id
  42621. }
  42622. // ID returns the ID value in the mutation. Note that the ID is only available
  42623. // if it was provided to the builder or after it was returned from the database.
  42624. func (m *WxCardVisitMutation) ID() (id uint64, exists bool) {
  42625. if m.id == nil {
  42626. return
  42627. }
  42628. return *m.id, true
  42629. }
  42630. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  42631. // That means, if the mutation is applied within a transaction with an isolation level such
  42632. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  42633. // or updated by the mutation.
  42634. func (m *WxCardVisitMutation) IDs(ctx context.Context) ([]uint64, error) {
  42635. switch {
  42636. case m.op.Is(OpUpdateOne | OpDeleteOne):
  42637. id, exists := m.ID()
  42638. if exists {
  42639. return []uint64{id}, nil
  42640. }
  42641. fallthrough
  42642. case m.op.Is(OpUpdate | OpDelete):
  42643. return m.Client().WxCardVisit.Query().Where(m.predicates...).IDs(ctx)
  42644. default:
  42645. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  42646. }
  42647. }
  42648. // SetCreatedAt sets the "created_at" field.
  42649. func (m *WxCardVisitMutation) SetCreatedAt(t time.Time) {
  42650. m.created_at = &t
  42651. }
  42652. // CreatedAt returns the value of the "created_at" field in the mutation.
  42653. func (m *WxCardVisitMutation) CreatedAt() (r time.Time, exists bool) {
  42654. v := m.created_at
  42655. if v == nil {
  42656. return
  42657. }
  42658. return *v, true
  42659. }
  42660. // OldCreatedAt returns the old "created_at" field's value of the WxCardVisit entity.
  42661. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  42662. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42663. func (m *WxCardVisitMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  42664. if !m.op.Is(OpUpdateOne) {
  42665. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  42666. }
  42667. if m.id == nil || m.oldValue == nil {
  42668. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  42669. }
  42670. oldValue, err := m.oldValue(ctx)
  42671. if err != nil {
  42672. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  42673. }
  42674. return oldValue.CreatedAt, nil
  42675. }
  42676. // ResetCreatedAt resets all changes to the "created_at" field.
  42677. func (m *WxCardVisitMutation) ResetCreatedAt() {
  42678. m.created_at = nil
  42679. }
  42680. // SetUpdatedAt sets the "updated_at" field.
  42681. func (m *WxCardVisitMutation) SetUpdatedAt(t time.Time) {
  42682. m.updated_at = &t
  42683. }
  42684. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  42685. func (m *WxCardVisitMutation) UpdatedAt() (r time.Time, exists bool) {
  42686. v := m.updated_at
  42687. if v == nil {
  42688. return
  42689. }
  42690. return *v, true
  42691. }
  42692. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardVisit entity.
  42693. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  42694. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42695. func (m *WxCardVisitMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  42696. if !m.op.Is(OpUpdateOne) {
  42697. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  42698. }
  42699. if m.id == nil || m.oldValue == nil {
  42700. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  42701. }
  42702. oldValue, err := m.oldValue(ctx)
  42703. if err != nil {
  42704. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  42705. }
  42706. return oldValue.UpdatedAt, nil
  42707. }
  42708. // ResetUpdatedAt resets all changes to the "updated_at" field.
  42709. func (m *WxCardVisitMutation) ResetUpdatedAt() {
  42710. m.updated_at = nil
  42711. }
  42712. // SetDeletedAt sets the "deleted_at" field.
  42713. func (m *WxCardVisitMutation) SetDeletedAt(t time.Time) {
  42714. m.deleted_at = &t
  42715. }
  42716. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  42717. func (m *WxCardVisitMutation) DeletedAt() (r time.Time, exists bool) {
  42718. v := m.deleted_at
  42719. if v == nil {
  42720. return
  42721. }
  42722. return *v, true
  42723. }
  42724. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardVisit entity.
  42725. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  42726. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42727. func (m *WxCardVisitMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  42728. if !m.op.Is(OpUpdateOne) {
  42729. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  42730. }
  42731. if m.id == nil || m.oldValue == nil {
  42732. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  42733. }
  42734. oldValue, err := m.oldValue(ctx)
  42735. if err != nil {
  42736. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  42737. }
  42738. return oldValue.DeletedAt, nil
  42739. }
  42740. // ClearDeletedAt clears the value of the "deleted_at" field.
  42741. func (m *WxCardVisitMutation) ClearDeletedAt() {
  42742. m.deleted_at = nil
  42743. m.clearedFields[wxcardvisit.FieldDeletedAt] = struct{}{}
  42744. }
  42745. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  42746. func (m *WxCardVisitMutation) DeletedAtCleared() bool {
  42747. _, ok := m.clearedFields[wxcardvisit.FieldDeletedAt]
  42748. return ok
  42749. }
  42750. // ResetDeletedAt resets all changes to the "deleted_at" field.
  42751. func (m *WxCardVisitMutation) ResetDeletedAt() {
  42752. m.deleted_at = nil
  42753. delete(m.clearedFields, wxcardvisit.FieldDeletedAt)
  42754. }
  42755. // SetUserID sets the "user_id" field.
  42756. func (m *WxCardVisitMutation) SetUserID(u uint64) {
  42757. m.user_id = &u
  42758. m.adduser_id = nil
  42759. }
  42760. // UserID returns the value of the "user_id" field in the mutation.
  42761. func (m *WxCardVisitMutation) UserID() (r uint64, exists bool) {
  42762. v := m.user_id
  42763. if v == nil {
  42764. return
  42765. }
  42766. return *v, true
  42767. }
  42768. // OldUserID returns the old "user_id" field's value of the WxCardVisit entity.
  42769. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  42770. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42771. func (m *WxCardVisitMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  42772. if !m.op.Is(OpUpdateOne) {
  42773. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  42774. }
  42775. if m.id == nil || m.oldValue == nil {
  42776. return v, errors.New("OldUserID requires an ID field in the mutation")
  42777. }
  42778. oldValue, err := m.oldValue(ctx)
  42779. if err != nil {
  42780. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  42781. }
  42782. return oldValue.UserID, nil
  42783. }
  42784. // AddUserID adds u to the "user_id" field.
  42785. func (m *WxCardVisitMutation) AddUserID(u int64) {
  42786. if m.adduser_id != nil {
  42787. *m.adduser_id += u
  42788. } else {
  42789. m.adduser_id = &u
  42790. }
  42791. }
  42792. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  42793. func (m *WxCardVisitMutation) AddedUserID() (r int64, exists bool) {
  42794. v := m.adduser_id
  42795. if v == nil {
  42796. return
  42797. }
  42798. return *v, true
  42799. }
  42800. // ClearUserID clears the value of the "user_id" field.
  42801. func (m *WxCardVisitMutation) ClearUserID() {
  42802. m.user_id = nil
  42803. m.adduser_id = nil
  42804. m.clearedFields[wxcardvisit.FieldUserID] = struct{}{}
  42805. }
  42806. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  42807. func (m *WxCardVisitMutation) UserIDCleared() bool {
  42808. _, ok := m.clearedFields[wxcardvisit.FieldUserID]
  42809. return ok
  42810. }
  42811. // ResetUserID resets all changes to the "user_id" field.
  42812. func (m *WxCardVisitMutation) ResetUserID() {
  42813. m.user_id = nil
  42814. m.adduser_id = nil
  42815. delete(m.clearedFields, wxcardvisit.FieldUserID)
  42816. }
  42817. // SetBotID sets the "bot_id" field.
  42818. func (m *WxCardVisitMutation) SetBotID(u uint64) {
  42819. m.bot_id = &u
  42820. m.addbot_id = nil
  42821. }
  42822. // BotID returns the value of the "bot_id" field in the mutation.
  42823. func (m *WxCardVisitMutation) BotID() (r uint64, exists bool) {
  42824. v := m.bot_id
  42825. if v == nil {
  42826. return
  42827. }
  42828. return *v, true
  42829. }
  42830. // OldBotID returns the old "bot_id" field's value of the WxCardVisit entity.
  42831. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  42832. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42833. func (m *WxCardVisitMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  42834. if !m.op.Is(OpUpdateOne) {
  42835. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  42836. }
  42837. if m.id == nil || m.oldValue == nil {
  42838. return v, errors.New("OldBotID requires an ID field in the mutation")
  42839. }
  42840. oldValue, err := m.oldValue(ctx)
  42841. if err != nil {
  42842. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  42843. }
  42844. return oldValue.BotID, nil
  42845. }
  42846. // AddBotID adds u to the "bot_id" field.
  42847. func (m *WxCardVisitMutation) AddBotID(u int64) {
  42848. if m.addbot_id != nil {
  42849. *m.addbot_id += u
  42850. } else {
  42851. m.addbot_id = &u
  42852. }
  42853. }
  42854. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  42855. func (m *WxCardVisitMutation) AddedBotID() (r int64, exists bool) {
  42856. v := m.addbot_id
  42857. if v == nil {
  42858. return
  42859. }
  42860. return *v, true
  42861. }
  42862. // ResetBotID resets all changes to the "bot_id" field.
  42863. func (m *WxCardVisitMutation) ResetBotID() {
  42864. m.bot_id = nil
  42865. m.addbot_id = nil
  42866. }
  42867. // SetBotType sets the "bot_type" field.
  42868. func (m *WxCardVisitMutation) SetBotType(u uint8) {
  42869. m.bot_type = &u
  42870. m.addbot_type = nil
  42871. }
  42872. // BotType returns the value of the "bot_type" field in the mutation.
  42873. func (m *WxCardVisitMutation) BotType() (r uint8, exists bool) {
  42874. v := m.bot_type
  42875. if v == nil {
  42876. return
  42877. }
  42878. return *v, true
  42879. }
  42880. // OldBotType returns the old "bot_type" field's value of the WxCardVisit entity.
  42881. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  42882. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42883. func (m *WxCardVisitMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  42884. if !m.op.Is(OpUpdateOne) {
  42885. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  42886. }
  42887. if m.id == nil || m.oldValue == nil {
  42888. return v, errors.New("OldBotType requires an ID field in the mutation")
  42889. }
  42890. oldValue, err := m.oldValue(ctx)
  42891. if err != nil {
  42892. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  42893. }
  42894. return oldValue.BotType, nil
  42895. }
  42896. // AddBotType adds u to the "bot_type" field.
  42897. func (m *WxCardVisitMutation) AddBotType(u int8) {
  42898. if m.addbot_type != nil {
  42899. *m.addbot_type += u
  42900. } else {
  42901. m.addbot_type = &u
  42902. }
  42903. }
  42904. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  42905. func (m *WxCardVisitMutation) AddedBotType() (r int8, exists bool) {
  42906. v := m.addbot_type
  42907. if v == nil {
  42908. return
  42909. }
  42910. return *v, true
  42911. }
  42912. // ResetBotType resets all changes to the "bot_type" field.
  42913. func (m *WxCardVisitMutation) ResetBotType() {
  42914. m.bot_type = nil
  42915. m.addbot_type = nil
  42916. }
  42917. // Where appends a list predicates to the WxCardVisitMutation builder.
  42918. func (m *WxCardVisitMutation) Where(ps ...predicate.WxCardVisit) {
  42919. m.predicates = append(m.predicates, ps...)
  42920. }
  42921. // WhereP appends storage-level predicates to the WxCardVisitMutation builder. Using this method,
  42922. // users can use type-assertion to append predicates that do not depend on any generated package.
  42923. func (m *WxCardVisitMutation) WhereP(ps ...func(*sql.Selector)) {
  42924. p := make([]predicate.WxCardVisit, len(ps))
  42925. for i := range ps {
  42926. p[i] = ps[i]
  42927. }
  42928. m.Where(p...)
  42929. }
  42930. // Op returns the operation name.
  42931. func (m *WxCardVisitMutation) Op() Op {
  42932. return m.op
  42933. }
  42934. // SetOp allows setting the mutation operation.
  42935. func (m *WxCardVisitMutation) SetOp(op Op) {
  42936. m.op = op
  42937. }
  42938. // Type returns the node type of this mutation (WxCardVisit).
  42939. func (m *WxCardVisitMutation) Type() string {
  42940. return m.typ
  42941. }
  42942. // Fields returns all fields that were changed during this mutation. Note that in
  42943. // order to get all numeric fields that were incremented/decremented, call
  42944. // AddedFields().
  42945. func (m *WxCardVisitMutation) Fields() []string {
  42946. fields := make([]string, 0, 6)
  42947. if m.created_at != nil {
  42948. fields = append(fields, wxcardvisit.FieldCreatedAt)
  42949. }
  42950. if m.updated_at != nil {
  42951. fields = append(fields, wxcardvisit.FieldUpdatedAt)
  42952. }
  42953. if m.deleted_at != nil {
  42954. fields = append(fields, wxcardvisit.FieldDeletedAt)
  42955. }
  42956. if m.user_id != nil {
  42957. fields = append(fields, wxcardvisit.FieldUserID)
  42958. }
  42959. if m.bot_id != nil {
  42960. fields = append(fields, wxcardvisit.FieldBotID)
  42961. }
  42962. if m.bot_type != nil {
  42963. fields = append(fields, wxcardvisit.FieldBotType)
  42964. }
  42965. return fields
  42966. }
  42967. // Field returns the value of a field with the given name. The second boolean
  42968. // return value indicates that this field was not set, or was not defined in the
  42969. // schema.
  42970. func (m *WxCardVisitMutation) Field(name string) (ent.Value, bool) {
  42971. switch name {
  42972. case wxcardvisit.FieldCreatedAt:
  42973. return m.CreatedAt()
  42974. case wxcardvisit.FieldUpdatedAt:
  42975. return m.UpdatedAt()
  42976. case wxcardvisit.FieldDeletedAt:
  42977. return m.DeletedAt()
  42978. case wxcardvisit.FieldUserID:
  42979. return m.UserID()
  42980. case wxcardvisit.FieldBotID:
  42981. return m.BotID()
  42982. case wxcardvisit.FieldBotType:
  42983. return m.BotType()
  42984. }
  42985. return nil, false
  42986. }
  42987. // OldField returns the old value of the field from the database. An error is
  42988. // returned if the mutation operation is not UpdateOne, or the query to the
  42989. // database failed.
  42990. func (m *WxCardVisitMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  42991. switch name {
  42992. case wxcardvisit.FieldCreatedAt:
  42993. return m.OldCreatedAt(ctx)
  42994. case wxcardvisit.FieldUpdatedAt:
  42995. return m.OldUpdatedAt(ctx)
  42996. case wxcardvisit.FieldDeletedAt:
  42997. return m.OldDeletedAt(ctx)
  42998. case wxcardvisit.FieldUserID:
  42999. return m.OldUserID(ctx)
  43000. case wxcardvisit.FieldBotID:
  43001. return m.OldBotID(ctx)
  43002. case wxcardvisit.FieldBotType:
  43003. return m.OldBotType(ctx)
  43004. }
  43005. return nil, fmt.Errorf("unknown WxCardVisit field %s", name)
  43006. }
  43007. // SetField sets the value of a field with the given name. It returns an error if
  43008. // the field is not defined in the schema, or if the type mismatched the field
  43009. // type.
  43010. func (m *WxCardVisitMutation) SetField(name string, value ent.Value) error {
  43011. switch name {
  43012. case wxcardvisit.FieldCreatedAt:
  43013. v, ok := value.(time.Time)
  43014. if !ok {
  43015. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43016. }
  43017. m.SetCreatedAt(v)
  43018. return nil
  43019. case wxcardvisit.FieldUpdatedAt:
  43020. v, ok := value.(time.Time)
  43021. if !ok {
  43022. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43023. }
  43024. m.SetUpdatedAt(v)
  43025. return nil
  43026. case wxcardvisit.FieldDeletedAt:
  43027. v, ok := value.(time.Time)
  43028. if !ok {
  43029. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43030. }
  43031. m.SetDeletedAt(v)
  43032. return nil
  43033. case wxcardvisit.FieldUserID:
  43034. v, ok := value.(uint64)
  43035. if !ok {
  43036. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43037. }
  43038. m.SetUserID(v)
  43039. return nil
  43040. case wxcardvisit.FieldBotID:
  43041. v, ok := value.(uint64)
  43042. if !ok {
  43043. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43044. }
  43045. m.SetBotID(v)
  43046. return nil
  43047. case wxcardvisit.FieldBotType:
  43048. v, ok := value.(uint8)
  43049. if !ok {
  43050. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43051. }
  43052. m.SetBotType(v)
  43053. return nil
  43054. }
  43055. return fmt.Errorf("unknown WxCardVisit field %s", name)
  43056. }
  43057. // AddedFields returns all numeric fields that were incremented/decremented during
  43058. // this mutation.
  43059. func (m *WxCardVisitMutation) AddedFields() []string {
  43060. var fields []string
  43061. if m.adduser_id != nil {
  43062. fields = append(fields, wxcardvisit.FieldUserID)
  43063. }
  43064. if m.addbot_id != nil {
  43065. fields = append(fields, wxcardvisit.FieldBotID)
  43066. }
  43067. if m.addbot_type != nil {
  43068. fields = append(fields, wxcardvisit.FieldBotType)
  43069. }
  43070. return fields
  43071. }
  43072. // AddedField returns the numeric value that was incremented/decremented on a field
  43073. // with the given name. The second boolean return value indicates that this field
  43074. // was not set, or was not defined in the schema.
  43075. func (m *WxCardVisitMutation) AddedField(name string) (ent.Value, bool) {
  43076. switch name {
  43077. case wxcardvisit.FieldUserID:
  43078. return m.AddedUserID()
  43079. case wxcardvisit.FieldBotID:
  43080. return m.AddedBotID()
  43081. case wxcardvisit.FieldBotType:
  43082. return m.AddedBotType()
  43083. }
  43084. return nil, false
  43085. }
  43086. // AddField adds the value to the field with the given name. It returns an error if
  43087. // the field is not defined in the schema, or if the type mismatched the field
  43088. // type.
  43089. func (m *WxCardVisitMutation) AddField(name string, value ent.Value) error {
  43090. switch name {
  43091. case wxcardvisit.FieldUserID:
  43092. v, ok := value.(int64)
  43093. if !ok {
  43094. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43095. }
  43096. m.AddUserID(v)
  43097. return nil
  43098. case wxcardvisit.FieldBotID:
  43099. v, ok := value.(int64)
  43100. if !ok {
  43101. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43102. }
  43103. m.AddBotID(v)
  43104. return nil
  43105. case wxcardvisit.FieldBotType:
  43106. v, ok := value.(int8)
  43107. if !ok {
  43108. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43109. }
  43110. m.AddBotType(v)
  43111. return nil
  43112. }
  43113. return fmt.Errorf("unknown WxCardVisit numeric field %s", name)
  43114. }
  43115. // ClearedFields returns all nullable fields that were cleared during this
  43116. // mutation.
  43117. func (m *WxCardVisitMutation) ClearedFields() []string {
  43118. var fields []string
  43119. if m.FieldCleared(wxcardvisit.FieldDeletedAt) {
  43120. fields = append(fields, wxcardvisit.FieldDeletedAt)
  43121. }
  43122. if m.FieldCleared(wxcardvisit.FieldUserID) {
  43123. fields = append(fields, wxcardvisit.FieldUserID)
  43124. }
  43125. return fields
  43126. }
  43127. // FieldCleared returns a boolean indicating if a field with the given name was
  43128. // cleared in this mutation.
  43129. func (m *WxCardVisitMutation) FieldCleared(name string) bool {
  43130. _, ok := m.clearedFields[name]
  43131. return ok
  43132. }
  43133. // ClearField clears the value of the field with the given name. It returns an
  43134. // error if the field is not defined in the schema.
  43135. func (m *WxCardVisitMutation) ClearField(name string) error {
  43136. switch name {
  43137. case wxcardvisit.FieldDeletedAt:
  43138. m.ClearDeletedAt()
  43139. return nil
  43140. case wxcardvisit.FieldUserID:
  43141. m.ClearUserID()
  43142. return nil
  43143. }
  43144. return fmt.Errorf("unknown WxCardVisit nullable field %s", name)
  43145. }
  43146. // ResetField resets all changes in the mutation for the field with the given name.
  43147. // It returns an error if the field is not defined in the schema.
  43148. func (m *WxCardVisitMutation) ResetField(name string) error {
  43149. switch name {
  43150. case wxcardvisit.FieldCreatedAt:
  43151. m.ResetCreatedAt()
  43152. return nil
  43153. case wxcardvisit.FieldUpdatedAt:
  43154. m.ResetUpdatedAt()
  43155. return nil
  43156. case wxcardvisit.FieldDeletedAt:
  43157. m.ResetDeletedAt()
  43158. return nil
  43159. case wxcardvisit.FieldUserID:
  43160. m.ResetUserID()
  43161. return nil
  43162. case wxcardvisit.FieldBotID:
  43163. m.ResetBotID()
  43164. return nil
  43165. case wxcardvisit.FieldBotType:
  43166. m.ResetBotType()
  43167. return nil
  43168. }
  43169. return fmt.Errorf("unknown WxCardVisit field %s", name)
  43170. }
  43171. // AddedEdges returns all edge names that were set/added in this mutation.
  43172. func (m *WxCardVisitMutation) AddedEdges() []string {
  43173. edges := make([]string, 0, 0)
  43174. return edges
  43175. }
  43176. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  43177. // name in this mutation.
  43178. func (m *WxCardVisitMutation) AddedIDs(name string) []ent.Value {
  43179. return nil
  43180. }
  43181. // RemovedEdges returns all edge names that were removed in this mutation.
  43182. func (m *WxCardVisitMutation) RemovedEdges() []string {
  43183. edges := make([]string, 0, 0)
  43184. return edges
  43185. }
  43186. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  43187. // the given name in this mutation.
  43188. func (m *WxCardVisitMutation) RemovedIDs(name string) []ent.Value {
  43189. return nil
  43190. }
  43191. // ClearedEdges returns all edge names that were cleared in this mutation.
  43192. func (m *WxCardVisitMutation) ClearedEdges() []string {
  43193. edges := make([]string, 0, 0)
  43194. return edges
  43195. }
  43196. // EdgeCleared returns a boolean which indicates if the edge with the given name
  43197. // was cleared in this mutation.
  43198. func (m *WxCardVisitMutation) EdgeCleared(name string) bool {
  43199. return false
  43200. }
  43201. // ClearEdge clears the value of the edge with the given name. It returns an error
  43202. // if that edge is not defined in the schema.
  43203. func (m *WxCardVisitMutation) ClearEdge(name string) error {
  43204. return fmt.Errorf("unknown WxCardVisit unique edge %s", name)
  43205. }
  43206. // ResetEdge resets all changes to the edge with the given name in this mutation.
  43207. // It returns an error if the edge is not defined in the schema.
  43208. func (m *WxCardVisitMutation) ResetEdge(name string) error {
  43209. return fmt.Errorf("unknown WxCardVisit edge %s", name)
  43210. }